LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Non-blocking timer function

Solved!
Go to solution

Hi!

 

I'm still learning a lot of stuff about Labview, and one onf the things I'm struggling a bit with right now, is how to create a non-blocking delay or wait function:

"Display this information for X amount of time, do something else in the meantime, stop displaying when the time is over"

Typically, I have a loop reading a queue to display a certain amount of info (various clusters). Some cluster are receiving info that are more important than others (for instance display an error message longer than normal message.

 

My current solution (far from optimal I think) is to duplicate that cluster and place it exactly right above the first one. It is constantly hidden (Property node "Visible" = false) but when needed, I asynchronously call a function (it is an action engine, see below) that will display it for 2s (hiding then the "normal" other messages, less important) and then hide it again. That way, my Data UI loop can still deal with the other clusters.

I currently have only one cluster like this, so this isn't too much trouble... But if it comes to more, then that would be annoying.

Delayed display.png

What do you think about this solution? How would you deal with this?

 

Another idea I have, more generic would be to have a Wait.vi which only function would be to wait for a given amount of time and then generate a User Event. This vi would be a shared clone so that I can call it asynchronously with as many clones as I want (depending on the number of instances I need), the references would need to be managed. The user event generated could have a queue+message as data type, and the event loop could then simply send away these info. Here is an illustration of what I mean.

 

VinnyLaTaupe_1-1639753945886.pngVinnyLaTaupe_2-1639753979915.png

 

I would really appreciate your advices/sugggestions on this 🙂

 

Vinny

 

 

0 Kudos
Message 1 of 5
(743 Views)

All you probably need is keep track of time since last update, keep the last value in a feedback node and keep displaying it until a new value comes in or a certain time gas elapsed. Then decide what to do based on the priority of the new message compared to the old one and the elapsed time.

 

(Your snippet is broken and cannot be used for testing. your second image is useless to say anything)

0 Kudos
Message 2 of 5
(714 Views)

Hi Altenbach, thanks for your answer.

 


@altenbach wrote:

All you probably need is keep track of time since last update, keep the last value in a feedback node and keep displaying it until a new value comes in or a certain time gas elapsed. Then decide what to do based on the priority of the new message compared to the old one and the elapsed time.


So basically in my case "update status" I should then check what time it is and what's the priority of ths status. If this status has a high priority, load the timestamp and during the next status update check if the current time is higher than "High priority timestamp" from before +2s and if not then just not display it?

 

Sorry for the snippet, not sure why it was broken. I can upload the vi if necessary, but not sure it is. As for the screenshot, it was just a visual explanation of what I meant, but by reading my text again, I'm not sure that was helpful anyway, sorry.

0 Kudos
Message 3 of 5
(662 Views)
Solution
Accepted by topic author VinnyAstro

Your snippet is broken because we don't have your type definitions.

 

No, don't check "what time it is", just keep track of a timer that resets to zero whenever an update occurs and otherwise gives you the time since last update. (A "high resolution relative seconds", a feedback node, and a few wires and trimmings is all you probably need for that).

Message 4 of 5
(641 Views)

@altenbach wrote:

(A "high resolution relative seconds", a feedback node, and a few wires and trimmings is all you probably need for that).


Sorry, what do you mea by "trimmings"?

But I have the general idea! Thanks, I'll try and do some changes in my code and adapt this soon!

0 Kudos
Message 5 of 5
(623 Views)