06-05-2013 10:40 AM
Hello all,
I'm making a state machine that changes an array of boolean values based on the current state ie. State 1 = [F,F,F,F], State 2 = [F,F,T,F], etc.
My problem is that I need to dynamically add/remove stages based on user input (ideally the user would be able to select anywhere from 1 to 20 stages). I would have an "initialize" and "shutdown" stages that would be there regardless.
I know from this post that you technichally cannot modify cases in a case structure while the VI is running, so I was wondering if there is some workaround that I could use.
Thanks,
Laura
06-05-2013 10:50 AM
I would make the maximum number of states you could need and only use those that are required at the time. Dynamically changing your block diagram architecture isn't possible (as far as I know) and to try seems like a waste of time. Have your code detect the number of stages during the initialization phase and store the number of stages. Then, only utilize code relevant to those stages present.
Better yet, would be to have states for moving a single stage and the code inside determines which stage to move. This way your architecture is fixed and the code dynamically determines which stage to communicate with.
06-05-2013 11:12 AM
I would make the maximum number of states you could need and only use those that are required at the time.
Ahh, I had considered that but wanted to leave it as a last resort.
Better yet, would be to have states for moving a single stage and the code inside determines which stage to move. This way your architecture is fixed and the code dynamically determines which stage to communicate with.
What do you mean by "move" a stage?
Thanks for your help, it's great to have a second opinion.
06-05-2013 12:15 PM
Sorry, your original post mentioned adding/removing stages. In my field a stage is a device for linear motion. If this isn't what you meant, ignore me.
06-07-2013 01:46 PM - edited 06-07-2013 01:59 PM
Do you have a VI to post to better explain what you are trying to do? How is user selecting these states? What structure do you have (or think you will use to) set up? I would agree you would need to have max number (which seems like 16 if you have a 4 boolean array) of states already coded. Unless each state does the EXACT same code, then you could get away with one and just handle the inside of the state better.
06-07-2013 02:58 PM
lauraalkhoury,
You use the term state machine to describe your vi. It sounds like you are creating a sequencer. Can you describe your application a little be more?
06-11-2013 09:10 AM
have a look at LVOOP
you can use dynamic dispatch to dynamically launch states from a queue
this is a good introduction to OOP
https://decibel.ni.com/content/docs/DOC-21531
06-11-2013 01:23 PM