03-09-2020 05:23 AM
Hi!
Thank you! i understand it much better now!
Have a nice day!
03-09-2020 07:39 AM
Hi!
I just have another question for you. As you said, I should not use event with sequential structure, I am now trying to rebuild my code with using shift registers and events. However, I have quite many buttons and indicators.
Do you suggest me to create a shift register for each one and then in the timeout create several case structures as you did to show what happens?
The problem is that all of these buttons execute respective actions in a strict sequence, hence this is why i wanted to use the sequence structure.
Best regards
Mirela
03-09-2020 08:08 AM
Hi Mirela,
@mirelche wrote:
The problem is that all of these buttons execute respective actions in a strict sequence, hence this is why i wanted to use the sequence structure.
When you want to execute certain actions in a defined order you should think of a statemachine…
03-09-2020 10:20 AM
@mirelche wrote:
I just have another question for you. As you said, I should not use event with sequential structure,
You shouldn't (need to) use a sequence structure at all.
Ideally, sequence is either irrelevant (so why force it), or forced by dataflow. There are hardly situations where order is relevant, and there's no dataflow. If this happens, a flat sequence structure (never a stacked one) can seem convenient at first, but not in the long run. And they're always avoidable, with a tiny bit of work.
03-09-2020 12:23 PM
wiebe@CARYA wrote:
@mirelche wrote:
I just have another question for you. As you said, I should not use event with sequential structure,
You shouldn't (need to) use a sequence structure at all.
Ideally, sequence is either irrelevant (so why force it), or forced by dataflow. There are hardly situations where order is relevant, and there's no dataflow. If this happens, a flat sequence structure (never a stacked one) can seem convenient at first, but not in the long run. And they're always avoidable, with a tiny bit of work.
I think a sequence structure is "allowable" in this one situation: Where you are reading from or writing to a variable and you need to make sure that the read or write happens exactly when it is supposed to. Even then, technically you could make a subVI to do this, but I will allow sequence structure laziness to avoid the creation of a subVI just for that one purpose.
03-09-2020 12:49 PM
Hi,
this is actually what i need to do. My Vi has many tabs and in each tab there are buttons. These buttons actuate usually a series of actions, eg start sensor logging, or wait 10 second with a countdown and then send signal to a LED.
Initially, I had sequences and events with the buttons inside, and it was functional, except for the problem which i had that while a countdown is running, then i cannot actuate the stop button, for instance.
So what would you recommend me? I am a bit confused, now what i have done is just started using shift register and events and cases instead of sequences, but I think there it is much harder to represent for instance a series of 10 things which need to happen in a certain order after a button is pressed.
03-09-2020 02:20 PM
Hi Mirela,
@mirelche wrote:
My Vi has many tabs and in each tab there are buttons. These buttons actuate usually a series of actions, eg start sensor logging, or wait 10 second with a countdown and then send signal to a LED.
Tabs are irrelevant from the block diagram point of view: all you need are the terminals and events for your UI elements.
I think there already was a suggestion to implement a producer-consumer scheme. The event handler loop would be the producer, while one or more consumers would execute your "series of actions"…