added startup and shutdown sequence

This commit is contained in:
Robin Müller 2021-06-15 16:44:31 +02:00 committed by Robin.Mueller
parent ca73d37f46
commit 2c2c82da6b
2 changed files with 21 additions and 1 deletions

View File

@ -8,11 +8,24 @@ GPSHandler::GPSHandler(object_id_t objectId, object_id_t deviceCommunication,
GPSHandler::~GPSHandler() {}
void GPSHandler::doStartUp() {
if(internalState == InternalStates::NONE) {
commandExecuted = false;
internalState = InternalStates::WAIT_FIRST_MESSAGE;
}
if(internalState == InternalStates::WAIT_FIRST_MESSAGE) {
if(commandExecuted) {
internalState = InternalStates::IDLE;
setMode(MODE_ON);
commandExecuted = false;
}
}
}
void GPSHandler::doShutDown() {
internalState = InternalStates::NONE;
commandExecuted = false;
setMode(MODE_OFF);
}
ReturnValue_t GPSHandler::buildTransitionDeviceCommand(DeviceCommandId_t *id) {

View File

@ -16,6 +16,13 @@ public:
virtual ~GPSHandler();
protected:
enum class InternalStates {
NONE,
WAIT_FIRST_MESSAGE,
IDLE
};
InternalStates internalState = InternalStates::NONE;
bool commandExecuted = false;
/* DeviceHandlerBase overrides */
ReturnValue_t buildTransitionDeviceCommand(