07-13-2015 04:42 PM
I'm familiar with a variety of standard SM labview implementaitons. Currently I'm developing an event driven SM. One of the state executions involves a flat sequence. Unfortunately the operations are sensitive, and if an error is encountered anywhere within this sequence, I need the ability to abort the program from that point in the sequence. To do this it seems best to turn this flat sequence into a SM.
My position now is such that I am unsure whether to add these new states to the original SM, or create a new SM within the original SM. The latter seems to make the most logical sense, as these substates don't seem to justify the distinction of states from the perspective of the original SM, however I'm not sure if this is a necessary approach.
I'd apprecaite any advice, thansk!
Solved! Go to Solution.
07-13-2015 04:46 PM
I would use the former instead of the latter.
07-13-2015 04:55 PM - edited 07-13-2015 04:58 PM
What altenbach said.
To expand a little bit, the “inside” state machine is going to need the ability to pass its state between loop iterations. This is going to be another shift register that is only used in one state. The "inside" state machine will also need the ability to send new states to the "outside" machine (otherwise the "outside" state machine would never exit the current state).
With this in mind, it makes sense to just add the extra states to your main state machine. It saves you a shift register and needless complexity.
Edit: It's late. I made my ramblings (slightly) more coherent
07-13-2015 07:10 PM
07-14-2015 07:27 AM
@mikeporter wrote:
You never want to have an embedded state machine. So you are left with two.options:
Can you explain why you said this?
I'm a great believer in "encapsulation" (or "lots of sub-VIs"). I can visualize a State Machine that looks like the following:
I would tend to write Task 1 and Task 2 as sub-VIs to emphasize that they are isolated individual tasks that (from the standpoint of this State Machine) are isolated except for their Return Value. If I now think about what Task 1 and Task 2 entail, why can't I envision them as State Machines, operating within their own "realm of influence"? And wouldn't this qualify as an "embedded State Machine"?
I do agree that you need to carefully consider the concept of a "State", and how State Transitions work. But I see no reason, a priori, that within a State (here considered as a body of code that runs to its conclusion using the usual Principles of Data Flow) one couldn't use any "encapsulated" design that fits the job.
Bob (Always Happy to Learn) Schor
07-14-2015 07:44 AM