From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Actor Framework Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Only allow one message of a particular type in queue at a time

Solved!
Go to solution

I have an actor for a serial device. I want to be able to queue up any number of messages except for one. Periodically I put a "send update" message in the queue. If there is one already in there then I don't want to allow another until the one already in the queue has been processed. I doubt this is possible. Does anyone have any advice on how to solve this problem?

=====================
LabVIEW 2012


0 Kudos
Message 1 of 10
(5,517 Views)

You're right; what you want isn't possible in the current framework.  What is the larger problem you are trying to solve?

0 Kudos
Message 2 of 10
(4,122 Views)
Solution
Accepted by topic author SteveChandler

Turn Update Msg into a Reply Msg, then use "Send Msg and Wait for Response.vi". Probably a bad idea, but it's there for you.

Better idea: Define an Update Was Processed Msg and have your sender keep track of whether an update is still hanging in the pipe. Requires a little state information (a single Boolean) in your sender, but it keeps the actors asynchronous.

0 Kudos
Message 3 of 10
(4,122 Views)

Would a Time-Delayed Send Message Once VI help in this case?

Science & Wires — a blog on LabVIEW and scientific programming
http://scienceandwires.com
0 Kudos
Message 4 of 10
(4,122 Views)

The behavior can't be restricted by the framework itself, but it can definitely be restricted by considerate actor and message design.

0 Kudos
Message 5 of 10
(4,122 Views)

David_Staab wrote:

Turn Update Msg into a Reply Msg, then use "Send Msg and Wait for Response.vi". Probably a bad idea, but it's there for you.

Better idea: Define an Update Was Processed Msg and have your sender keep track of whether an update is still hanging in the pipe. Requires a little state information (a single Boolean) in your sender, but it keeps the actors asynchronous.

Even if the message was a wait for response, wouldn't others get queued up behind it? I was thinking that I would have to add something like an "update was processed". I think that is probably the best way to go.

onnodb, I will take a look at the time delayed send once.

What I am doing now is sending my update status message from the timeout event of an event structure. Depending on what commands are sent to the queue, it might take more than the timeout time to complete. This causes multiple "send status" messages to get queued up.

=====================
LabVIEW 2012


0 Kudos
Message 6 of 10
(4,122 Views)

I would probably make an intermediary actor that receives and passes the messages from both sides. It can pass the first "send update" and wait for reply. Until no reply received, it shoul just not pass the "send update" messages. When the reply arrives it passes it further and sets it's status to pass the next "send update".

0 Kudos
Message 7 of 10
(4,122 Views)

Timestamp the messages?  Allow multiple "send update" messages to be enqueued, but have the "Do" method do nothing if the timestamp isn't greater than the time the last update was sent.

0 Kudos
Message 8 of 10
(4,122 Views)

Why would you want to only have on in the queue at a time?  Perhaps the reasonaing behind your need will help us offer an alternative.

In a slightly related case, if you were trying to do the opposite and send multiple messages but only act on the freshest data, I would use a notifier as your data type and then have the sender update the data in the notifer so that your processor would only see the latest status when it processes the first message.

-John
------------------------
Certified LabVIEW Architect
0 Kudos
Message 9 of 10
(4,122 Views)

David_Staab wrote:

Turn Update Msg into a Reply Msg, then use "Send Msg and Wait for Response.vi". Probably a bad idea, but it's there for you.

Better idea: Define an Update Was Processed Msg and have your sender keep track of whether an update is still hanging in the pipe. Requires a little state information (a single Boolean) in your sender, but it keeps the actors asynchronous.

Thanks, I implemented the "Better idea"

=====================
LabVIEW 2012


0 Kudos
Message 10 of 10
(4,122 Views)