added startup and shutdown sequence

This commit is contained in:
Robin Müller 2021-06-15 16:44:31 +02:00
parent 16066b4cf9
commit 78cb72d12d
No known key found for this signature in database
GPG Key ID: 9C287E88FED11DF3
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() {} GPSHandler::~GPSHandler() {}
void GPSHandler::doStartUp() { 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() { void GPSHandler::doShutDown() {
internalState = InternalStates::NONE;
commandExecuted = false;
setMode(MODE_OFF);
} }
ReturnValue_t GPSHandler::buildTransitionDeviceCommand(DeviceCommandId_t *id) { ReturnValue_t GPSHandler::buildTransitionDeviceCommand(DeviceCommandId_t *id) {

View File

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