01-01-2018 02:13 PM - edited 01-01-2018 02:16 PM
@SegFault1119 wrote:
I added 200 as you did in your example VI and it's working now.
The right way would be to add an event for the stop button and place the terminal inside it (or add a stop event to an existing event, like I did above). It is incorrect to add a timeout case to poll the stop button if that is the only purpose for the timeout case.
Also note that latch action booleans should have their terminal inside their respective event. This way they correctly reset when the event happens.
01-01-2018 02:28 PM
Here's one possibility to simplify your code. One single event case is sufficient, making the code much more readable.
01-01-2018 03:27 PM
"It is incorrect to add a timeout case to poll the stop button if that is the only purpose for the timeout case."
When placing an event structure inside a while-loop, does the loop iterate/increment if no event occurs?
Your simplified program is easier to follow for me. Though my program will have more than 2 buttons but I think I know how to modify it.
01-01-2018 05:25 PM
SegFault1119 wrote:When placing an event structure inside a while-loop, does the loop iterate/increment if no event occurs?
Data flow dictates that the loop cannot iterate until everything inside has completed. So if no event is being generated, the event structure will sit there idle waiting. So the loop will not iterate until an event is generated and handled by the event structure.
01-01-2018 07:07 PM
@SegFault1119 wrote:
Though my program will have more than 2 buttons but I think I know how to modify it.
Again, make sure not to over-complicate things. Best would be a radio-button control, but if you want to use individual latch action buttons as you did in your last code, easiest would be to build the buttons into an array and use "search array" to see which one is true. There are many ways to do all that, make sure it is scalable!
01-02-2018 12:53 PM
Thanks for the tips. I think radio button function works for my program because I want all the buttons disabled when one button is pressed.
01-02-2018 12:59 PM - edited 01-02-2018 01:03 PM
"disabled" means that the other buttons can no longer be operated. In a radiobutton control, only one can be true, but you can switch at any time. If you want to disable some elements, you need property nodes.
Note that a radiobutton container can contain any number and style of Boolean controls.