User Tools

Site Tools


code:dqmh:state-machine:getting-started

02 Getting Started

Installation

The easiest way to get started with the HSE State Machine is by installing and using it as a module template. However, the State Machine implementation is not restricted to be used inside a DQMH module. To use it in an already existing project, follow these steps:

  • download and unzip the latest source distribution from our Releases page
  • open the TEMPLATE.lvproj and navigate to StateMachine.lvlib
  • right click on HSE-State-Machine.lvlib and select Save –> Save As…; uncheck Add copy options and follow the dialog
  • open your existing project and add the newly saved lvlib
  • open SM DEMO.vi and copy the State Machine Loop, SM Create Event and SM Destroy Event to your Block Diagram as needed
  • remove / replace the following dependencies from your project as needed
    • SM DEMO.vi
    • HSE Logger in SM Wait for Transition.vi
    • DQMH Message Queue in SM Update UI State.vi
    • DQMH Message Queue in SM Process Exception Transition.vi

Adaption

  • edit SM_States.ctl to reflect the needed states for your project
  • edit SM_Transitions.ctl to reflect the needed transitions for your project
  • implement states and transitions as needed
    • create a case for every state
    • in each state, create a case fo each allowed transition
    • in each case, which defines an allowed transition, define the next state and, if needed, trigger an action calling a MHL case
  • call SM Request Transition.vi in MHL or EHL as needed to request transitions

Communication to the State Machine

Local Events used for request transitions

Communication to the State Machine Helper Loop takes place over a local user event. The event reference is created when the module starts and destroyed afterwards. The events can be triggered from the Event Handling Loop (EHL) and the Message Handling Loop (MHL) to request a transition. For transitions, we always use the verb request and not trigger, indicating that a transition only informs the state machine about a command or something that happened. Only the state machine itself decides if this transition will actually change its state.

Request a transition from the MHL

code/dqmh/state-machine/getting-started.txt · Last modified: 2023/02/13 15:36 by alexander.elbert