Showing results for 
Search instead for 
Did you mean: 

Use events to change from auto to manual mode

Hi, My program can work in two modes. Auto and Manual

In Auto mode it suppose to automatically follow a sequence and so I used a basic State Machine . But when the operator click on the manual mode the program should step into Manual mode. I think for this part I need to use event but I don't know where to use this event structure. Out of the case structure and everytime I run through my sequence I also check for that event or Inside the case structure

I greatly appreciate if youd show me with a basic example how I can implement this.

0 Kudos
Message 1 of 5

Generally, one would structure programs like these using parallel loops, one for the Event Structure (so it will always "be responsive"), the other for whatever else you are doing.  There are various ways to get information from one loop into the other -- you need to be a little careful, as you can get into a "race condition" where both loops are trying to change the same thing at more-or-less the same time.


If your loop-to-be-controlled is written so that it has an (internal) control that governs whether it is in Automatic or Manual mode, you can simply build an Event case that looks at a (separate) control, say a switch that has a Manual and Automatic setting, monitoring a Value Change for this switch.  In the Event loop, you can (safely) use a Local Variable to change the Manual/Automatic control to the appropriate state.

0 Kudos
Message 2 of 5

Please explain in detail, "manual mode"?


  • manually advancing one by one in order
  • manually advancing each state out of order
0 Kudos
Message 3 of 5

a producer consumer design comes to mind, though you can make it a state machine with some thought on how you want to process it...

prod_cons auto.png

0 Kudos
Message 4 of 5

slightly elegant...

prod_cons auto.png

0 Kudos
Message 5 of 5