FACT++
1.0
|
|
virtual |
Start the mainloop.
This is the main loop, or what could be called the running state machine. The flow diagram below shows what the loop is actually doing. It's main purpose is to serialize command excecution and the main loop in the state machine (e.g. the tracking loop)
Leaving the loop can be forced by setting fExitRequested to another value than zero. This is done automatically if dim's EXIT command is received or can be forced by calling Stop().
As long as no new command arrives the Execute() command is called continously. This should implement the current action which should be performed in the current state, e.g. calculating a new command value and sending it to the hardware.
If a command is received it is put into the fifo by the commandHandler(). The main loop now checks the fifo. If commands are in the fifo, it is checked whether the command is valid ithin this state or not. If it is not valid it is ignored. If it is valid the corresponding action is performed. This can either be a call to Configure() (when no state change is connected to the command) or Transition() (if the command involves a state change). In both cases areference to the received command (Command) is passed to the function. Note that after the functions have finished the command will go out of scope and be deleted.
None of the commands should take to long for execution. Otherwise the response time of the main loop will become too slow.
Any of the three commands should usually return the current state or (in case of the Transition() command) return the new state. However, all three command can issue a state change by returning a new state. However, this will just change the internal state. Any action which is connected with the state change must have been executed already.
dummy | If this parameter is set to treu then no action is executed and now events are dispatched from the event list. It is usefull if functions are assigned directly to any event to simulate a running loop (e.g. block until Stop() was called or fExitRequested was set by an EXIT command. If dummy==true, fRunning is not set to true to allow handling events directly from the event handler. |
Implements MainImp.
Definition at line 994 of file StateMachineImp.cc.
References MessageImp::Error(), Execute(), MessageImp::Fatal(), fCond, fCurrentState, fExitRequested, fMutex, fRunning, HandleEvent(), HandleNewState(), IsQueueEmpty(), kSM_NotReady, kSM_Ready, PopEvent(), and SetCurrentState().
Referenced by main(), and RunThread().