Part two of two.
Start of Ben's "Ode to a State Diagram"
I love thee state diagrams, let me count the ways (W. Shakespear ?).
I develop the designs of most of the applications that come out of my shop. This means that I have to start with a bunch of "fluffy cloud" pictures my customers give me into a set of requirements for VI's that will be developed to implement the solution. The state diagrams I devlelop help me "catch a cloud and pin it down" (How do You solve a Problem Like Maria?", Sound of Music).
State diagrams are great for documenting in an understandable form what an application will do before it is developed.
They serve as guides to discussions of the approaches that will be used. This is when I tell customers, "See,the data will not be saved until you hit save, if there is a power failure before that, the data will be lost. Are you OK with that?"
Once refined and accepted the designs then serve to control scope creep. Any request that requires the State Diagrams (SD's) be changed, is big warning that the scope is changing.
The SD's also jump start the code requirements! As I document what needs done in each state of the application, I am in effect describing what the code that executes in that state is required to do. Each state can (depending on the complexity) become a unique sub-VI who's VI documentation is the documentation for that state.
The discusion of a sub-VI's functionality is never complete without a mention of the data coming into it and the data it returns. This is where the SD drives the data analysis portion of the design. LV after all does implement a data flow paradim (sp?). No code in LV can be implemented properly without concideration being given to dataflow. While specifying the functionality of a state, I am asking myself
"Where am I going to keep that I/O reference?",
"Where is it needed?",
"Who is going to be writting to it?",
"Is this going to be a memory pig?",
etc.
The results of this questioning lets me structure the applications data. (This is another story)
So...
When I am done with the SD and everything is documented, I end up with an application I can then turn over to developers that may not understand the complexities of the application, but can develop all the required sub-VI and have them all work together as expected.
General Note:
The image included is a screen shot of the LabVIEW State Diagram Editor (SDE). The SDE is not required to devlop SD's but simplifies their development. I have used paper and pencil to develop SD's for code written in C. MS Paint and MS PowerPoint for LV before the SDE was released.
The SDE in its current form is primative.
It does not have a "undo". You can not select more than one object at a time and allign them. You can not have more than one SDE screen open at a time (in LV 7.1).
It is primative.
Having said that, let me go on to say,
It is great!
It has simplified my life greatly.
I now can work in a LV environment. I do not have to edit diagrams in PP and then import and paste in diagrams. They are included.
I can watch my ideas in execution highlighting more where my "fluffy clouds" come to life.
I can quickly move from the design view of the SDE to the LV code by clicking on a state or one of the transitions.
I can step into someones cube that is "drawing up my clouds" and quickly figure out why those "lightning bolts" are coming from.
Warning:
SD should not be over-used! They are an excellent way to slow down your code. If you can "see" the LV code, write it in LV!
SD's and event structures do work together but "These things must be done delicately" (Wicked Witch, Wizard of Oz).
I hope this helps,
Ben