State machines can go from any state to the other. Either in Murmex you send a Message to yourself to go from one state to the next. How to go to user-defined states, we will see in a tutorial later. For now, let us imagine we either receive from another component, either from ourself the StartMessage. This message calls the Start method. In here we want to start doing something. And perhaps we want to continue doing that, but check if we are done. And later we want to stop the component. In this tutorial we will discuss the methods Start, Proceed and Stop.
When a component is added to the configuration as observer, it can receive the start and stop message.
- In the Configure method, click on Configure Murmex.
- Add a new observer. This observer can receive data (see other tutorials) and start and stop messages. The boolean flag “wait until done?” means it waits for a Proceed message from the observer before it is ready itself.
- Add to the main the accessor “Relay start/stop to observers?”. By setting this to TRUE your components receive both messages and when FALSE the observers won’t receive the message.
- If not existing in your project, add the virtual folder “action methods”.
- Add to the action methods folder the method Start. Use the Right-mouse click menu >> New >> VI for Override…
- In the Start method you might want to reset some parameters, like a counter, open a file to read from/write to, start a device etc.
- Add to the action methods folder the method Stop. Use the Right-mouse click menu >> New >> VI for Override…
- In the Stop method you might want to stop a device, close a reference, write the last data to a file etc.
- More Murmex tools are available. For example you can find out if it has started.
- When you add a component as observer to the configuration of your component, this means it can receive data and it will receive the start and stop triggers. Also you can set the checkmark to wait for the component. This means that the component sends a Proceed trigger to the observee back once this component and its observers are ready, making thus a whole cascade.
First send a Proceed message to yourself in the Start method.
- Add to the action methods folder the method Proceed. Use the Right-mouse click menu >> New >> VI for Override…
- Check if your component is ready in the Proceed method.
- You can also do polling with a while loop and thus keep checking if a parameters gives a TRUE value as output. Also you can keep sending a Proceed message to itself, creating a while loop that can be stopped. You better also check if the program has already stopped.