LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

while loop next iteration inside producer consumer

Solved!
Go to solution

Hi,

 

I have a double array that is feed inside the producer loop. I want to display all data of the array in a sequence to the data indicator but the element inside the event structure can not be triggered. I don't want to use the timeout of the event structure.

 

What do you think is the problem ? and what is the solution?

 

vi is Attached. Thanks!

jK20

0 Kudos
Message 1 of 8
(3,271 Views)

A value change event is trigger whenever the user enters new data into a control, or you programmatically write data to a Value(Signalling) property node.

 

You don't have any of those property nodes, and your Data array is an indicator, not a control, so there is no way for you user to enter data into it.

0 Kudos
Message 2 of 8
(3,245 Views)

Hi jK,

 

What do you think is the problem ?

The problem is you are waiting for a value change event of an indicator "data". Indicators will NEVER create valuechange events (unless you use a special property node)!

 

and what is the solution?

You should wait for your user-defined event instead…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 3 of 8
(3,241 Views)

Thanks Raven.

 

But Unfortunately when I used property node (value) (initial value say = -1), the event has not been triggedred as well.

 

Please help. (screenshot attached)

 

Regards,

Wilmar

0 Kudos
Message 4 of 8
(3,188 Views)

hi GerdW,

 

I did your suggestion to put initial value in the property node value, but got no luck. The event does not recogized it.

 

I have no idea with user defined even and how to implement it.

Thanks

Wilmar

0 Kudos
Message 5 of 8
(3,187 Views)

hi GerdW,

 

I did your suggestion to put initial value in the property node value, but got no luck. The event does not recognized it.

 

I have no idea with user defined even and how to implement it.

Thanks

Wilmar

Download All
0 Kudos
Message 6 of 8
(3,186 Views)
Solution
Accepted by topic author jengkamK20

Hi jengkamK20,

 

Looking at your VI, despite the helpful comments, it's really not clear which loop is really the consumer!

 

Your producer labelled loop reads the data (presumably this array + 100ms wait simulates a 10Hz data source) and then you want to send it to the 'data' indicator, is this right?

 

The consumer doesn't consume the data. Instead, it seems to be just passing it back to the producer, which has to then both produce and consume! It's not surprising that the loop is difficult to work out.

 

If you want to use a Queue with the producer (this is the normal P/C Data structure) then don't make the enqueuing of data conditionally depend on the execution of the Event Structure. In the top producer loop, if the Event Structure doesn't trigger, then the loop iteration never finishes (as you're seeing). If you remove the Event Structure then the loop will enqueue an element with no problem. Then, the consumer can dequeue the element and place it in the 'data' indicator.

 

Alternatively, if you want to use User Events, then you need to be clear about where you want data to start, go to, be processed and so on. If the producer generates the data and you want to handle it based on the event, you should generate an event when the data is 'produced' - perhaps by placing a Generate Event node outside of the Event Structure. Then, changing the Event Case to be the dynamic user event will work (and you can keep your data indicator in the event structure). Note, that in this case, your consumer isn't involved at all (and further, you're making a very convoluted setup that could be replaced by a simple wire...)

 

It's pretty likely that this is a test VI to check how things work, or to explore the tools available in LabVIEW, so something being convoluted is fine if you know how you want to use it in future. Just make sure you know what you want to happen where!

 

Edit: I attached a VI which compares Queues with Events. Neither of the cases I show uses both, although you can if you want/need to.


GCentral
Message 7 of 8
(3,176 Views)
Solution
Accepted by topic author jengkamK20

@jengkamK20 wrote:

hi GerdW,

 

I did your suggestion to put initial value in the property node value, but got no luck. The event does not recogized it.

 

I have no idea with user defined even and how to implement it.

Thanks

Wilmar


I didn't say Value property node.  I said Value (Signalling).    The "signalling" part is the one that tells it to fire an event.

Message 8 of 8
(3,152 Views)