LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to wait for different source of occurrences in same loop

Is it possible to wait for more than one different (= from different generated sources) occurrence in same loop ? (while ...)

 

I've tried with two and the loop never runs unless seems both occur, or if one/other times out say.   What I need is to un-block on _any_ one of the occurrence.

 

I would like to have different few generators, but have same one loop to wake up on any one of those occurrences. 

 

How ? 🙂

0 Kudos
Message 1 of 14
(3,168 Views)

Could you post an example of what you have done so far because at the moment I can't work out what you are asking for.

 

Are you asking if you can have one wait on occurrence wait for for any one of multiple occurrences to be set? If this is the case...then no (I don't think). The only way you could do that is to poll them all like below. You have to be careful with occurences, I have a love hate relationship with them, on the one hand they can be really neat, simplistic and use minimal diagram space. On the other hand they can be a real pain to use, this is one of those examples. I suggest reading this Wiki for more info. https://labviewwiki.org/wiki/Occurrence

 

occurences.png

 

I'd probably suggest replacing occurrences with a notifier. This does have a wait on multiple that you could use and is going to be a lot less hassle.

 

If I have misunderstood what you are asking get back to us

0 Kudos
Message 2 of 14
(3,142 Views)

When you do reply with more details, it would really help if you could post the VI(s) you have tried to write to solve this question.  It will give us a lot more information on what you are trying to do (and on how you are doing it).  We may have some interesting "different ideas" for you.

 

Bob Schor

0 Kudos
Message 3 of 14
(3,111 Views)

Let's assume you are talking about LabVIEW occurrences and not using the term generically. Occurrences date back to the stone age of LabVIEW and were useful before the introduction of the event structure and more modern tools.

 

Even the help for generate occurrences states that:

Note:  National Instruments encourages you to use the Notifier Operations functions in place of occurrences for most operations.

 

So either you started programming LabVIEW 30 years ago and remember this function, got some ancient code, or stumbled by accident on the occurrence palette. Either way, there are probably much better ways to do whatever you are trying to do. (e.g. a single event case can be triggered by multiple events)

 

As you learned, dataflow dictates that a loop iteration can only complete if all containing code has completed, (and both occurrences have fired in your situation). Instead of trying to fight dataflow by programming around it, you need to embrace it. Yes, I can think of several ways to work around it, but they probably all belong into the Rube Goldberg thread.

 

Can you take a step back and describe what you are trying to do, not how you are trying to do it? I am sure the collective wisdom of the forum will be able to point you in the right direction. What triggers each occurrence? What needs to happen based on which of the occurrences has triggered? 

0 Kudos
Message 4 of 14
(3,091 Views)

@Niatross 

 

Yea that is probably, it.   The top loop is definitely what I though I can do : but I just had two units of wait on occurrence. But , from your picture , you have only one occurrence trigger (with !), and I thought, I could have say 2 (or more ..)  and channel them as separate occurrences ( and separate lines )  into the waiting loop. Assuming I thought the loop will be triggered on _any_one_ of those. But that didn't work.

 

You have a very interesting example (to me anyway) : reminds me of C / Unix   fd set  /select pattern calls. Except that you have to poll , else you never wake up it seems.

 

I prob misunderstood what they are .. I thought they more like events but easier to use.  

0 Kudos
Message 5 of 14
(3,062 Views)

Hello,

 

Yes, those are the occurrences.  And , I thought I use them instead of Notifier because they seemed more straightfoward to setup rather than going for notifications (which, looked like effort for someone who never setup either in LabView).

 

 

0 Kudos
Message 6 of 14
(3,057 Views)

@BoB_Shor , and others

 

Hey , thanks for much for replying and so quick. I do not have now my own example as I didn't work & I nuked it. But, I started with  Simple Occurrence example provided with LabView.  And I wanted to split the generator into two. 

See top block generates one with timer, and one on exit when button pressed.   I wanted to split out the timer  / periodic generator into it's own loop, with own occurrence generator instance.

 

But the receiver would have two lines going in, two separate possible occurrences : so i thought, i can wake up/ get triggered on either one.  But, that loop never woke up  (unless I put a time out value on my new wait for occurrence; and that's not what I wanted anyway).

 

The whole thing why i thought I give them ago, I wanted to pass  /notify / send events , signal  to different sub-loops or sub-systems  from a dedicated place where I monitor my buttons.  So say, if I have a global "kill all" switch,  I want all working sub-states to receive it and do what's needed and exit normally.

That's just one example, but a good one for me, there is a couple of such global buttons or switches , yet I don't want to be reading them in every single sub-work or loop  (i.e. also possibly avoid the polling of them in many places).

 

 

lv_occ.jpg

0 Kudos
Message 7 of 14
(3,054 Views)

You may recall I asked that you send a VI (not a picture).  So you sent a picture.  So I'll ask the Direct Question -- what version of LabVIEW are you using?

 

Bob Schor (the "c" is silent, but necessary ...)

0 Kudos
Message 8 of 14
(3,046 Views)

Hi Bob,

 

I don't know if I wrote clearly above: I do not have my own vi with the question I'm asking as explained.   Thus I send a pic of an _example_ vi provided as part of the 'standard' LabView install. And tried to show on the pic what I meant ..

 

But to answer your direct question : My LabView is as I got off the NI website ~ 2 weeks ago, and I see it says its version 20.0 32-bit LabVIEW 2020 (Community Edition).

 

Is this satisfactory?   Btw, I did , it seems, include that example VI.    (  NOTE: I have no problem with this vi , just in case you misunderstood it)

0 Kudos
Message 9 of 14
(3,027 Views)

I am not 100% certain what you are trying to achieve, but it does sound like occurrences won't be the best way. As I said before, I have a love hate relationship with them. They can be really neat and simplistic but more often than not they give me more headaches than anything else, especially when you aren't ignoring previous occurrences.

 

I would definitely recommend notifiers as a more robust solution. If you want to make it look more minimalist put your notifier in a sub-vi with a small icon. The benefit of the notifiers is that there is a wait on multiple node which means you don't have to poll them.

0 Kudos
Message 10 of 14
(3,019 Views)