07-13-2021 09:31 AM
Hello Folks,
I need your help.
In the event-based state machine when a Boolean is true then the event will occur but I want to keep my event running until Boolean (I’m using mechanical action “Switch when pressed”) is false.
Thanks.
- Reduanul
Solved! Go to Solution.
07-13-2021 09:52 AM
Could you attach your code? It sounds like you are running your code inside the event structure. I would recommend moving your code to its own loop and sending messages to start and stop based on the boolean events (you will get a value change event for both T-F and F-T).
07-13-2021 10:24 AM - edited 07-13-2021 10:33 AM
@REDUANUL wrote:
Hello Folks,
I need your help.
In the event-based state machine when a Boolean is true then the event will occur but I want to keep my event running until Boolean (I’m using mechanical action “Switch when pressed”) is false.
Thanks.
- Reduanul
I typically use the Value(Signaling) Property Node for this.
Here's an example of what I think you are asking...
I would probably put the Val(Sgnl) property node inside a case that follows your Boolean so it only triggers a value change when true.
07-13-2021 10:48 AM - edited 07-13-2021 10:49 AM
Please define "Keep the event running". Do you want to remain inside the event (not recommended) or re-enter the same event over and over as long as the boolean is true? What else needs to happen in parallel?
I sometimes use the timeout event for the bulk of the work and switch the timeout (held in a shift register) based on the new switch value between "short" and "-1" (i.e. infinite).
In any case, we need significantly more detail to give advice. Show us your VI.
07-13-2021 11:20 AM
@ RTSLVU,
Thanks for your advice but in my code, it's not working probably I have to do another way around.
@ altenbach,
Sorry for not being attaching the full code but for easy understanding please have a look:
Here when I press the ON/OFF button all messages are executed once but afterward Event Handing loop wait for another event from other cases or from the ON/OFF case.
So what I am trying is, when ON/OFF remained pressed messages will execute continuously instead of once. Then in the false case Event handling loop will wait for another event. Hope it helps you.
07-13-2021 11:22 AM
@REDUANUL wrote:
So what I am trying is, when ON/OFF remained pressed messages will execute continuously instead of once. Then in the false case Event handling loop will wait for another event. Hope it helps you.
Use my timeout suggestion.
07-13-2021 11:35 AM
Here's how that could look like. (Assuming that your subVIs execute and return quickly, you can easily adapt it to your scenario.)
07-13-2021 12:04 PM
@ altenbach,
I tried your approach. I not getting where is the problem.
Here is my implementation:
I wired the timeout case according to your suggestion as well. Till now event handler only executing the message once to the Message handling loop.
07-13-2021 12:30 PM
07-13-2021 02:43 PM
@altenbach wrote:
@REDUANUL wrote:
Here is my implementation:
No, that's just a picture.
And the picture doesn't even show all of the code. I don't think that you implemented the code the way altenbach suggested.