11-04-2011 12:32 PM
Is there a way to display 2,3,4... different messages in the same string indicator at different times?? I've designed a GUI w a specific area to display to the operator directions. ie "plug in power supply..click OK to continue." They click OK. Now in that same designated space I want to display ie "turn on power supply..click OK, the same OK button from the 1st step, to continue. " would this be a do while loop or a event structure?? If an event struct how does it know which time the OK was hit? The 1st or the 2nd or...
I don't want to use a dialog box.
Thanks
Solved! Go to Solution.
11-04-2011 03:54 PM
Easy with a state machine. Look here to get started. Attached is an example of a very simple state machine type thing that will do what you are asking.
11-04-2011 04:21 PM
The attached example includes two of the most hated elements --- sequence structures and local variables. However, in this case, they work perfectly well.
One thing to keep in mind is that an "OK" button usually has a latch action, meaning it acts as a momentary switch. This is not compatible with local variables, so you have to change it to be a toggle switch and then programatically reset it after each step.
11-04-2011 04:28 PM
This example shows how to do it using a loop structure where all the instructions are in an array.
The nice thing about it is you avoid using both the sequence and the local variables. It also makes it very easy to add more instructions.
The disadvantage is that it is somewhat limiting in how it works with other code elements. Because it's a loop, it executes the same code each time it goes round. That works well if you just want to display instructions... but if you want to run different subVIs after each process step, it's difficult. You can accomplish that, if you like, using a case structure on the iteration value, but it gets a bit cluttered.
11-07-2011 06:12 AM
The State Machine example is in LV 2011...I have...of course LV2010. I think the example LandBelenky sent might work. I just have to see how it will behave w other code. After I posted I continued searching in the Discussion Groups looking for a vi that would count the number of times a button was pushed. I found one. With that I put it w a case statement. If the button was pushed the 1st time it displayed "plug in PS". Then the 2nd ...."turn it on". Third.."do instruction three" My gut feeling tells me this isn't very robust even though from the on set it appears to work. I like LandBelenky's solution with the caveat I haven't tried it in my code yet.
Thanks.
11-07-2011 11:54 AM
Unless I'm doing something wrong this doesn't work in an event structure. If I click run then "Initial Setup" then the "OK" button, it hangs up. If I use the highlight exexcution it just keeps constantly monitoring the OK button inside the inner loop of event Initial Setup. I'm guessing w an event structure it only looks at the event 1x so if there is a conditional loop inside it that particular event it never sees it after the 1st time. I thought that once it "entered" the event it would execute everything inside it.
11-07-2011 11:56 AM
Duh..sorry. Forgot attachment.
11-07-2011 07:14 PM
The reason it is hanging is because the event structure will lock the front panel until a triggered event case has completed. Your "Initial Setup" event case is triggered by the Initial Setup button. It locks the front panel until the case has completed. However you have a while loop that stops when the OK button is pressed. You cannot click on the OK button because the panel is still locked.
If you click on Events Handled For This Case you can unselect the Lock front panel (defer processing of user actions) until this event case completes.
One suggestion is to put the boolean controls with latching action inside the event case that handles them. Doing so will reset the state when the event case fires.
11-08-2011 05:27 AM
Nice !! Thanks!
After I posted I continued to search the Grp and found another post that recommended placing the ..boolean controls inside the event. Which I did.
Again, thanks.