State Manager
State Manager¶
The TrackMan 3e navigates from one state to another using a Finite State Machine. The diagram below shows the FSM. The main job of the FSM is to try and keep the system out of error states, as auto-recovery kicks in every time the system enters an error state.
States¶
Initializing¶
Upon normal startup (one short click on the power button), the device will enter this state.
Exit conditions:
-
All goes well, go to Idle
-
Initialization fails, go to InitializeFailed
InitializeFailed¶
When initialization fails, the device will try to auto-recover from the failure.
Exit conditions:
- The error that got it into this state is resolved, go to Initializing
Recovery¶
If the power button is held down for 4 seconds, the device will enter this state.
From here it is very limited what the device can do.
Exit conditions:
- If a firmware update is requested, go to FirmwareUpdate
FirmwareUpdate¶
If a firmware update is initiated, then state changes to FirmwareUpdate.
Exit conditions:
- On firmware update complete, reboot system
Idle¶
When the device enters idle, the webserver and camera is enabled. This is done to be able to get an image much faster when entering Active state.
Exit conditions:
-
User logs in through HTTP POST. Go to Active
-
An error occurs. Go to Error
Active¶
Here the device can be controlled, GPS and Leveling is enabled
Exit conditions:
-
IsMeasuring is set to true. Go to Measuring
-
An error occurs. Go to ActiveError
-
An unrecoverable error occurs. Go to Error
ActiveError¶
An error occurred in Active.
Exit conditions:
-
Could recover from error, go to Active
-
Could not recover, go to Error
Measuring¶
Here measuring is enabled, and leveling is disabled.
Exit conditions:
- No activity (strokes hit or login tokens requested for xxx seconds)
MeasuringError¶
An error occurred in Measuring.
Exit conditions:
-
Could recover from error, go to Measuring
-
Could not recover, go to Error
Error¶
If the system cannot recover from ActiveError or MeasurementError or another state transitions to Error this is where the system ends up.
Exit conditions:
-
If Recovered from error, go to Init
-
Restart
How to handle error states¶
Whenever the systemstate changes to one of the errorstates, either a message or a warning graphics should be presented to the user.
ActiveError / MeasuringError¶
When this happens, the best thing would be to show a warning to the user and let it try to recover from the error for a period of time. If this is a success, continue to where the user left off.
Error¶
If the system continues into Error, it's advisable to reboot the TrackMan if it cannot get into Idle, and therefore also restart the app (or go to wherever communication with the TrackMan begins).