User Tools

Site Tools


code:dqmh:state-machine:how-to

03 How to

Polling States

Example implementation of a polling state

Polling states can easily be implemented. In the example, the value of a boolean control is repeatedly read, until it changes to true. If the polling value won't change, still other transitions can lead to state changes.

Error Handling

When code in a MHL case throws an error, or e.g. another module reports an error via broadcast, the Exception transition might be requested, indicating the erroring state.

Request Exception transition

If the Exception transition is requested, wire in the error which should be handled into the variant input of the SM Request Transition.vi. When a state allows a Exception transition, the SM Process Exception Transition.vi is called. Exception transition

It will add the information from within which state and by which transition it was called to the error and the State Machine will go into the Error - Waiting For Action state. There a HSE Logger is used to log the error information before the State Machine waits for a transition, which should handle the error (e.g. reset hardware, initialize again, …).

Error - Waiting For Action

Stopping the State Machine

The HSE State Machine Template doesn't use the normal DQMH stop procedure, to ensure, that the module will only stop, if the state machine allows it. Therefore, the EHL case Stop Module only requests a transition called Exit. Depending on the implementation of the State Machine, three reactions can happen:

  • The current state allows the Exit transition leading to the Exiting state, where it will trigger the stop of the MHL and EHL.
  • The current state ignores the Exit transition and the State Machine will stay in the current state.
  • The current state defines the Exit transition to throw an exception, leading to the Error - Waiting For Action state.
code/dqmh/state-machine/how-to.txt · Last modified: 2023/02/13 15:50 by joerg.hampel