02-23-2012 07:28 PM
References are not pointers. Front panel references are the least efficient way to move data through a LabVIEW program. The most efficient way to move data is on a wire. Here's a quick attempt at reworking (most of) your program:
This is more efficient, easier to read and faster to debug, than your original version:
02-25-2012 05:15 PM
Thanks a million ! I just tried it out, and it's quite neat; for example:
02-28-2012 10:24 AM
Alex,
Thats one of the oddest code constructs I've ever seen. I can understand an array of enums to document the transitions for a given "Event." (Lets rename that to "Condition", Event is something different in LabVIEW, treat it like a keyword) but for several reasons I would argue for using a Queued state machine:
Passing 1D arrays of enums via queue will meet your "Self-documentating" transition map and the case frames of the state machine decouple the "Working code" (I still fail to see where requireing a prototype con pane does not add unnecessary coupling between the sub-vis) This design pattern is known as a Queue Driven State Machine and one of the real workhorse design patterns because it leverages a lot of what LabVIEW developers have learned over 25 years of programming in LabVIEW.
Those VI server refs are very powerful tools but this is not a good way to use them.
Now, Sometimes we DO want to extend the QDSM by making it less specific of the actions the states take. This is not only possible to do in LabVIEW but an entire Framework has been developed that does this effectivly and whithout requireing the UI thread. Take a look at the Actor Framework here It depends on LVOOP to accomplish what I think you originally had in mind and approached from a slippery angle because of your background in languages that have native "by-reference" conventions.
02-28-2012 10:31 AM
Mega-kudos Jeff!
As a an ex-C developer let me please try to make the important point that you seem to be missing.
You would be better served to learn how to work with LV than these attempts to turn LV into C.
I believe the origin of the following quote is Mark Twain
"When all you have is a hammer, everything looks like a nail."
So learn to use the LV screwdriver for a different twist.
Ben