Blog

Where’s the Beef?

Written by Ben Rayner | Nov 21, 2023 3:47:50 AM

Queued State Machine, Queued Message handler, Master/Slave, Producer Consumer, Channeled State Machine … (the list goes on) are design patterns often used to develop applications in LabVIEW. They each have their own features and no single design pattern is correct for every situation and application. Choosing the appropriate design pattern or creating a customized variation is key to developing a robust application that will meet the requirements and grow as the application grows over the years.

A Queued State Machine (QSM) is a design pattern that was adopted by many early LabVIEW developers. In part because it closely mimics the behavior of “Pushing onto a stack” and Popping off of a stack,” or in other cases a “Go To” command in other software development environments. Like the “Go To” statement (see Dhijkstra) ,  the Queued State Machine is a design pattern that prevents the normal controlled documentation of a State Transition Diagram,  as when poorly implemented each state ‘outsources’ it’s transition logic to commands from other portions of the code. QSMs are the Worm Ouroboros of LabVIEW design patterns and are best kept under control if they are starved.

Their main flaw lies in the nature that defines a QSM. It can, and will, add state transitions from one or more of the cases of the QSM and only handles messages passed to it by other threads. This is in stark contrast to a Queued Message Handler, or a State Machine where all of the transitions are fully defined at development time. Match your design pattern to your needs, and match your skill set to your design pattern, for the best results.

To ensure you are developing applications and design patterns properly and efficiently, consider taking a DSA Certified LabVIEW training course. If you don’t have the resources internally, then you could certainly benefit from an investment in time with one of our Automation Systems Consultants.  Or, you could hire someone like “Eight-Dollar Eddy” who offers “code for less,” and end up with a really nice cube steak machine.