LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how do I wait for a shared variable to change with a timeout function

I am (about to) using global (shared) variables to request that an image be taken by a remote computer.  When the image is taken, the remote computer will set the "Image Ready" flag and put the image in the shared image variable.  (That's the plan anyway.).  I need some advice about how to send the request and then patiently wait for the return...for a while...before deciding that the remote machine has failed to do what I asked it to do.
 
I noticed the timed event structure, and the timeout stucture...but what do you do with them...create an error?...
If you are waiting and the response arrives before the timeout occurs, what do you do about the timeout?
 
Humm
0 Kudos
Message 1 of 8
(4,520 Views)

Hi Humm,

instead of using shared variables you could also use TCP/IP functions. Program the communication by yourself. Use the "TCP Read" function and connect your timeout to it. I think thats all you need. If the timeout execute, you can react on it.

Hope it helps.
Mike

0 Kudos
Message 2 of 8
(4,504 Views)

I usually don't use shared variables but I'll share what I know.

You can right click on shared variable nodes and select the option to return an error. I think the erro code will return an erro code if there was a timeout.

If you are using LabVIEW DSC, you can register an event that fires when the value changes.

Just trying to help,

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 3 of 8
(4,496 Views)

Thanks Ben and Mike for your help.

I am using DSC and will look for a value change to generate an event.  Mike, I think I would like to try to let LabView handle the variable sharing just to see if it is as simple as it seems.  I'm trying to stay as abstracted as possible from the systems, just for fun. 

I have to gather several of these from different computers, so what I am wondering about is a good strategy for (read "diagram approach") sending out all the "take image" flags, and then making sure that I have all the "here is your image" flags come in in a reasonable time.  My thought was that I would use some arrangement in a timed event loop with one of the events being a timeout...Here I start scratching my head...do I do things like increase a "gee ... you missed your deadline again...counter" until it reaches "I'm fed up with this, so skip it..."...or what.  I have looked at the examples for using the mode of the timer to skip or process the data that comes in after the deadline...but those don't inspire me to a direct solution.

Send the flags.

Get some of the flags back...then...(wait forever for the rest of the flags to show up...? or Send an error to the operator to check on why the images arn't arriving...?which stops the whole show...or just publish that set of data without the missing information and wait for the data next time?)

 

0 Kudos
Message 4 of 8
(4,489 Views)

As I indicated in my previous reply I don't use shared varibles. The reason is that I have very little control over when and how they are updated and syncronizing multiple data structures (is the new data really on my machine before I find that the flag is true? ) is hit an miss.

Using the DSC value change event may eliminate the need for the flag (but in at least one case the "new value" was always stale) which forced mt then turna around and do a data socket read to get the actual new data.

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 5 of 8
(4,485 Views)

Ahhhh....I see !

Does it make any difference that I can do this rather slowly...?  Is there some way to ASSURE that the new image is "NEW".

0 Kudos
Message 6 of 8
(4,481 Views)
you can also use FGV (functional global variables). This uses the propriety of th shift register which is that if you don't initialize it, it keeps the same value. The FGV vi has to be non reentrant

Hope this helps
Message 7 of 8
(4,479 Views)

Excellent suggestion Milas!

They are also known as Action Engines. I wrote a Nugget about them which can be found here.

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 8 of 8
(4,473 Views)