The minimal design of Murmex is demonstrated here. Murmex is a state machine where the method “Handle messages.vi” receives and executes the message / commands. The Handle messages method can be seen as the consumer part in the produced-consumer design pattern.
The disadvantage of the minimal design is that you cannot stop the program from within. You would need to send a TerminateMessage in order to stop it. This could be done by another component, but as this is the first program … there is a deadlock. We advice to go quickly after the minimal design to the basic design to test the framework.
Minimal design
- The Main.vi is the only method that does not need to call its parent and the call can be deleted. All other methods must call their parent when possible. Often you want to call the parent first, the exceptions when to call your parent last is in the Update and Terminate method. Rule of thumb, always call the parent method and then do your code, except the Update and Terminate methods where you first update your parameters and then call the parent method or send maybe still message before you close the RabbitMQ connection.
- The Main method must have a while loop that has the Handle message.vi method. Don’t forget to use shift registers for all while loops.
- Add to the front panel a text field, name is log. This log shows the messages you have received.
- Add a property node and link it to the class data. Advisable is to use the following settings:
- configure at startup?: TRUE.
- log reference: reference of the text field log.
- VI ref: the reference of the current method.
- Add after the property node the method “Clear log.vi”
- Add after the Clear log the method “Send” and wire as message the InitialiseMessage.lvclass (this one is located in your project >> Dependencies >> vi.lib
- Add to the start of the program, before the property node, the method “Set up ID.vi”. This method allows you to set the ID while debugging and can grab the ID when you call the executable by a ServiceManager.
As said before, by giving the control “id” a proper value, this minimal design should work. The program shall initialise itself and than wait for messages to receive. In order to stop the program, we should send such a message to ourself. This is explained in the next tutorial.