LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

state machine template critique

Per other's suggestions in another thread here, I have put together a state machine type architecture that I have already somewhat started to pitch (it seemed to turn some heads) and I'm going to show it in a design meeting. I wanted it critiqued before I did though. Opinions, criticisms, and suggestions welcome!
0 Kudos
Message 1 of 11
(3,756 Views)
I should add, this is more of an example than a template. The template will have far less cases. Unless some of you think I should leave it as is?
0 Kudos
Message 2 of 11
(3,747 Views)

[Set Sarcasm Mode = True]

 

An empty template should handle just about anything but do we really want to be THAT fleixble? Smiley Happy

 

[Set Sarcasm_mode = False]

 

I tried to open that in LV 7.1 and LV 2009 and it looks empty.

 

Sorry,

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 3 of 11
(3,744 Views)
hmmm...weird. Here it is just zipped instead of in a .llb. Kudos for trying (literally)!
0 Kudos
Message 4 of 11
(3,738 Views)

A couple of quick comments

 

1) drop the name of the queue so you can run multiples of these in parallel without them stepping on each other.

 

2) Just a matter of taste but I prefer to le the consumer kill the queue since only it knows when it is done eating.

 

3) the type def was saved as LV 8.5 so watch out.

 

Ben

 

 

Message Edited by Ben on 10-23-2009 11:26 AM
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 5 of 11
(3,724 Views)

Ben wrote:

A couple of quick comments

 

1) drop the name of the queue so you can run multiples of these in parallel without them stepping on each other.

 

2) Just a matter of taste but I prefer to le the consumer kill the queue since only it knows when it is done eating.

 

3) the type def was saved as LV 8.5 so watch out.

 

Ben

 

 

Message Edited by Ben on 10-23-2009 11:26 AM

1. No problem

2. I originally had it that way, for the same reason you described. Then I looked at the LabVIEW producer consumer architecture and it had it after the producer loop. Thats what I get for being a "robot". I also like it after the consumer loop better because no error is thrown due to the queue being destroyed prior to the consumer loop finishing processing/reading from the queue.

3. Thats what I get for having two versions of LabVIEW open at once...fail.

 

Thanks!

Message Edited by for(imstuck) on 10-23-2009 11:43 AM
0 Kudos
Message 6 of 11
(3,715 Views)
Overall it looks pretty good. I posted another example architecture in another thread you may want to look it as well. I agree with Ben that you should drop the name. However I don't necessarily see a problem with your top level VI release the queue as part of its cleanup. I generally go by the rule that the creater of the queue should be the one responsible for destroying it. You do have an issue if your error handler kicks in in that there is no way for it to feed back to the event structure that it has exited. I would probably replace the error constant with the Clear Errors subVI. Both do the same thing but the Clear Errors looks cleaner and expresses better what is actually being done.


Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 7 of 11
(3,680 Views)

Have you looked at the JKI State Machine or this library that NI offers? I'm partial to JKI, but the other looked good to me, too. As I started learning to use the template I found myself appreciating some features that I wouldn't have come up with on my own in 1e6 years. One thing I like is that they both use strings instead of enums, contrary to what we'd learned from NI training.

 

<personal plug> I wrote a plugin that assists in state machine development.  It works on any Case Structure, but it has special features that only apply to the JKI State Machine. <\personal plug>

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

Message 8 of 11
(3,659 Views)

jcarmody wrote:

Have you looked at the JKI State Machine or this library that NI offers? I'm partial to JKI, but the other looked good to me, too. As I started learning to use the template I found myself appreciating some features that I wouldn't have come up with on my own in 1e6 years. One thing I like is that they both use strings instead of enums, contrary to what we'd learned from NI training.

 

<personal plug> I wrote a plugin that assists in state machine development.  It works on any Case Structure, but it has special features that only apply to the JKI State Machine. <\personal plug>


I know there is always the onging debate regarding using strings or ENUMS. Both have their advantages and disadvantages. I tend to like ENUMs though because they help to prevent coding errors by inserting incorrect states. I know JKI's state machine includes the state to catch unknown states but I like to enforce this check at coding time rather than at runtime. Plus, the old embedded programmer in me likes the fact that ENUMs use less space than strings. I know this doesn't matter much on today's PCs but old habits are sometimes hard to break.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 9 of 11
(3,642 Views)

Mark Yedinak wrote:

jcarmody wrote:

Have you looked at the JKI State Machine or this library that NI offers? I'm partial to JKI, but the other looked good to me, too. As I started learning to use the template I found myself appreciating some features that I wouldn't have come up with on my own in 1e6 years. One thing I like is that they both use strings instead of enums, contrary to what we'd learned from NI training.

 

<personal plug> I wrote a plugin that assists in state machine development.  It works on any Case Structure, but it has special features that only apply to the JKI State Machine. <\personal plug>


I know there is always the onging debate regarding using strings or ENUMS. Both have their advantages and disadvantages. I tend to like ENUMs though because they help to prevent coding errors by inserting incorrect states. I know JKI's state machine includes the state to catch unknown states but I like to enforce this check at coding time rather than at runtime. Plus, the old embedded programmer in me likes the fact that ENUMs use less space than strings. I know this doesn't matter much on today's PCs but old habits are sometimes hard to break.


You have been a ton of help, Mark. Thanks. I also like enum because it's so easy to take that strict type def control and just right click the case structure, and add a  case for every value when the control has been modified.

0 Kudos
Message 10 of 11
(3,632 Views)