Navarre Posted December 21, 2012 Report Share Posted December 21, 2012 Hi, I have done a fair amount of LabView development but have rarely used (or run into) the state machine construct. From what little I have read it seems that almost anything can be modeled as a state machine. Are there situations where a state machine wouldn't be effective? Are there real-world examples of things that are not state machines? Thanks, Nina Quote Link to comment
V_T_S Posted December 21, 2012 Report Share Posted December 21, 2012 Does your code need to respond to user interface? Does your code has series of steps/defined sequence? Then "YES", state machines are the way to go. Quote Link to comment
PaulL Posted December 21, 2012 Report Share Posted December 21, 2012 Are there real-world examples of things that are not state machines? Yes. For instance, a transformational system (a data processing algorithm not requiring user interaction) is not a reactive system (that responds to events). State machines are appropriate for designing reactive systems. Here is a link I have found helpful when contemplating the essence of state machines: http://xlinux.nist.gov/dads/HTML/statemachine.html. Quote Link to comment
crelf Posted December 21, 2012 Report Share Posted December 21, 2012 For reference (and open to ppl improving): http://labviewwiki.org/State_Machine Quote Link to comment
Oakromulo Posted December 21, 2012 Report Share Posted December 21, 2012 (edited) Even if some code doesn't actually respond to user interface it could still be useful to model it using a state machine pattern. Useful in a sense that it could actually improve both code readability and performance. For example: imagine a VI with a "latch when released" switch and a boolean indicator. For every push in the switch you toggle an automatic blinking pattern to the output. I have implemented this solution both with and without state machines. Take a look below. Which one do you prefer? without.vi withSM.vi Edited December 21, 2012 by Oakromulo Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.