03-15-2010 10:57 AM
For a state machine, is there a way to make a state to become a sub-state of another state? What I mean is that I want the substate to have an indentation to distinguish it from another state. ?It is easier for viewing when you are looking at the cases in the case structure.
Yik
03-15-2010 11:17 AM
You could give the substate a name that has a few spaces at the beginning of it.
03-15-2010 11:43 AM
Or.... you could nest a state machine in one state of your top level SM. It would act hierarachal that way but require an additional case selector variable..... Hmmmm Not sure If I'd do it this way but it could be done.
Actually, Thinking it through I about to say that you may want to re-assess your archetecture. When you start looking for ways to differentiate "States" by dependancies on other "States" it time to ask if your machine is cohesieve.
03-15-2010 11:44 AM
Ravens Fan wrote:a few spaces
you mean underscores, right? 😉
You could have a subVI that is/contains a State Machine. Give it a suitable name and it can be called within one(or more) statesof the state machine in your main VI. You can even pass arguments via the connector pane.
There are many other approaches depending on what you are doing and how you want to architecture your code. Things like re-entrant vi's, dynamic vi's (Daemon), ActionEngines (well.. if it contained a state machine 😉 I'd have to think about that last one). I recall doing an ActionEngine with a StateMachine. It ran the state once per call.. The state came from the calling VI.
03-15-2010 01:03 PM - edited 03-15-2010 01:03 PM
I did mean spaces, but underscores are fine to.
Though my preference would be the state machine within a state machine. The substate would also be passed by a shift register. Or it could be one shift register that is a cluster of state and the substate.
03-15-2010 01:26 PM
I'm confused if your design has the same state appearing more than once in the State Transition Diagram or if you are talking about a sub-routine which should translate to a sub-VI. I have seen queued state machines that use a state as if it was a sub-routine but I felt that was a good example of a sub-VI rather than a state. The ancillary issue that comes from the smae state being called by different states is how to re-direct program flow for each call.
Confussed,
Ben
03-15-2010 02:20 PM
Ben wrote:I'm confused if your design has the same state appearing more than once in the State Transition Diagram or if you are talking about a sub-routine which should translate to a sub-VI.
I share your confusion. Until we know what the intent of the code is and why nest a state machine, then it is up to many different interpretations.
03-15-2010 03:31 PM - edited 03-15-2010 03:34 PM