NI LabVIEW Idea Exchange user SteveChandler recently expressed his wish that the JKI State Machine shipped with LabVIEW so he could use it for his Certified LabVIEW Developer exam (CLD). This is a great idea, and it would be terrific if NI let professional developers use the best LabVIEW tools and LabVIEW libraries on exam day. But that day, if it ever comes, is probably a long way off.
In the meantime, we have a different suggestion: memorize enough of your favorite state machine template to recreate it from scratch in 10 minutes or less. You can do this with any template, but we're going to show you how we do it with the JKI State Machine (JKISM) when we train engineers to take the Certified LabVIEW Architect exam (CLA).
How to Create a Basic JKI State Machine From Scratch in 10 Minutes
You don't need the world's greatest template to rock your CLD or CLA exam. There are only a few features you really need to "feel" like you're working with the JKISM:
- Your own version of the "Add State(s) to Queue" VI to manage your state queue.
- A basic version of the "Parse State Queue" VI to drive your case structure.
- A few simple, standard states:
- Idle, with an Event Structure for catching UI events
- Default, with an exception handler to raise an error when you misspell a state name
- Error Handler, to catch and process any errors that occur
- Exit, to exit your state machine
- Data: Initialize, to set up your state machine's local data
That's only a handful of things, and they're all simple! We'll describe them, and then if you practice them for about an hour the day before your test, you'll have no trouble replicating them on the fly come test time.
Your Very Own "Add State(s) to Queue"
The JKISM's "Add State(s) to Queue" VI is pretty easy. It just ensures that every incoming state (or state queue) ends with a linefeed (LF), and throws some Trim Whitespace operations in there so the resulting state queue doesn't have extra LFs hanging around. It's not hard to literally memorize this VI and recreate it from scratch.
Your Very Own "Parse State Queue"
"Parse State Queue" is a little more complicated, but the trick is that you only need a simplified version of it. In particular, you need it to extract the first line from a multi-line string state queue, and branch to the Error Handler. That's really it. You don't need to handle disabled states (or state comments), nor do you need to handle state arguments. This eliminates the vast majority of the VI's code...
...and leaves you again with something you can definitely memorize:
Now Go Make a State Machine Template!
The two VIs you just created are the building blocks of your state machine: they enqueue and dequeue states. Now you just have to glue them together to form the skeleton of a working application.
A few basic states of the JKISM will give you everything you need. Rather than listening to me describe each of them, though, just download the JKI State Machine (VIPM users can install it directly) and see them for yourself. They're all pretty trivial. The hardest part is remembering which states are important. We use a mnemonic to help:
- I - Idle
- Doubt - Default
- Elvis - Error Handler (or, if you prefer, ELVIS)
- Ever - Exit
- Died - Data: Initialize
These five states give you a functional, extensible state machine with support for events, local state data, and error handling. Speaking from experience, that's all you need.
OK, It's Not Really ALL You Need
Memorizing your favorite state machine template will definitely make your CLD or CLA exam experience easier because you won't have to worry about using unfamiliar design patterns or sweating to figure something out on the fly. But don't neglect the other aspects of exam preparation! In particular, don't miss Darren Nattinger's great advice on Preparing for the CLD and recent Changes to the CLA. Good luck!
Do you have tips for helping developers pass their CLD or CLA exam? Any horror stories from your own exam? Join the discussion below!
Put your LabVIEW Certification to Use - Join Our Team
Want to work with an amazing team on exciting LabVIEW projects that change the world? Apply for a position at JKI.