LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Strange (but maybe correct) notifier behavior

Solved!
Go to solution

Hi all,

 

I have a VI that allows to run two tasks A and B. The tasks are always run one after the other, never at the same time, no matter the order (A->B or B->A can happen). Usually I use notifiers to stop my tasks and here I wanted to use the same notifier to stop tasks A and B since (again), they never run at the same time. My problem is that when task A receives the notification, it stops, task B starts (so far so good) and stops immediatly (bad !) because it receives also the notification that made A stop.

I attach a small VI reproducing the problem.

 

In my case, setting "Ignore previous" input to True in both tasks doesn't help because in that case all notifications seem to be ignored...

 

Any idea how I can make it work ? I was thinking that my task B would never receive the notification since A had already received it...

 

Thanks !

____________________
JB
0 Kudos
Message 1 of 8
(2,658 Views)

Hi Tycho,

Notifiers work as demultiplexers, thus the behavior of your code is not strange ; it's just the expected one : once the notifier is trigered, the same "True" message is sent to both loops and they stop !

But your code doesn't correspond to the situation you describe : both loops (tasks) run simultaneously ; that's why they receive the same notification !

What do you want to do : do you always want task B to start immediatly when task A stops, and vice-versa ? Only once or in a loop ?

Best regards,

HL

 

0 Kudos
Message 2 of 8
(2,650 Views)

 

Hi HL,

 

In the example I sent, the loop on the right starts only when the first one is finished, because it waits for the error and notifier wires. The loop with the event structure runs in parallel to fire notifications when I press the button.

 

What I want to do is this:

+ I have a data acquisition that can run in two modes,

+ these two modes correspond two the tasks I called A and B in my examples,

+ if the data acqusition is running in mode A, when I hit a switch to go from task A to task B, I stop task A with the notifier and starts task B. My problem is that the notifier also stops task B. This is what I show in a simpler way in my example.

 

Cheers,

T

____________________
JB
0 Kudos
Message 3 of 8
(2,639 Views)

 

Hey, I just discovered the VI "Cancel Notification".

I'm going to try that !

____________________
JB
0 Kudos
Message 4 of 8
(2,636 Views)

Oups ! Sorry, I didn't notice the wires between the top loops 😞

In that case, it should work if you wire "True" to "Ignore previous" in the right one : a first notification stops the left loop and starts the right one, but you'll have to modify the bottom structure to be able to send a second notification to stop the right loop.

HL

0 Kudos
Message 5 of 8
(2,630 Views)
Solution
Accepted by topic author tycho75

 

Actually "ignore previous" does not work properly because in my application (unlike the small example I sent), I can have A->B or B->A. It could work if I had always the same order.

If I call "Cancel Notification" at the end of A task and B task, it works perfectly.

 

Cheers,

T

____________________
JB
0 Kudos
Message 6 of 8
(2,623 Views)

WHy not implement this using a state machine. It sounds like your tasks are mutually exclusive so they can reside in a single state machine. You may also get more code reuse since there is a likely chance that you can share some states between the tasks.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 7 of 8
(2,581 Views)

Hi,

 

Actually, I'm using a queued state machine and each of my process A and B correspond to a specific state.

The notification is used to stop both A and B. The problem I had was when stopping A and proceed immediatly to B. The notification was still "on" at the start of B and B was stopped immediatly after it started...

The problem is solved when I use "Cancel Notification" and the end of A and B.

 

Cheers,

T

 

____________________
JB
0 Kudos
Message 8 of 8
(2,572 Views)