LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Cluster of string and class in a queue not working because dequeu is stuck from not having any messages in the queue

I have a queue which takes in a cluster as a datatype, and inside the cluster it a string for the state that has to be wired to the case structure and also a class which will be used inside the state to excute. So here is the problem. I start programming, did everything and it works fine and i got the data from the class. But now a new data has occured somewhere else so I need to send in a new state and for that i dequeu the queue to get the cluster of string and class and I can add the new state by using the bundle function. But here is the problem. When I run the dequeue, there is no messages in the queue so it will be stuck there and wont move forward. Without dequeing I wont get the cluster to add in the new state. I cant also create a new cluster with the state and a new instance of the class, then all the data till now will be lost. When I started programming, i thought it would be a good idea. But now I am stuck. Is there a work around this. Or do I have to make complete changes like use the state and class in two seperate queues so as to not use a cluster. Kindly let me know. Thank you. 

0 Kudos
Message 1 of 6
(870 Views)

I just came with a solution that I created a temporary case called Idle case in between where if nothing else is happening it keeps dequeing and enqueing again & again. So the dequeue will give out the state idle and current instansce of the class and the enqueue will queue them back in and then again and again. I also kept a wait timer for 1 sec. I dont know if this is a good solution, but it worked.

0 Kudos
Message 2 of 6
(847 Views)

What do you mean by

"When I run the dequeue, there is no messages in the queue"? The Dequeue Element vi just waits for any data to come into the queue. It will be blocked until then (unless you specify a timeout).

 

You didn't attach any code, but from your description it sounds like a simple QMH like this:

QMH with class.png

 

Is this what you have? Because this works perfectly well.

 

  

0 Kudos
Message 3 of 6
(840 Views)

@basjong53, yes except the fact that I dont have any shift register. Everything will be shared via queues. 

0 Kudos
Message 4 of 6
(826 Views)

After you dequeue you data and update class, you have to enqueue the data again. 

 

Can you attach your code? Or just a snippet if it's too large / proprietary?

0 Kudos
Message 5 of 6
(785 Views)

Yeah I solved it in a different way. I changed the design. I am no longer sending the class. Only the state. Instead the class I changed it into a shift register. I think that is the best design for now. My problem was the data that was coming is from a third loop. I had a third loop where some stuff happened and I got data. Now this data needs to be work in the second loop. This data, I just sent as a local variable. But then for the second loop to execute, I need to enqueue the new state where the local variable data is to be used plus the current instance of the class and in the third loop i cannot get the current instance of the class. That was my problem. So from the third loop, I just sent in the new state and the current instance of the class is present in the shift register of the second loop. Thank you. 

0 Kudos
Message 6 of 6
(779 Views)