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.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Flush shared variables

Hi all,

In my rt application I have a separate task that is responsible for saving the data an displaying the latest values to the user. As I want to see only the latest ones, I do not care about the losses in that case - I use network published shared variables, which have the buffering disabled and rt fifo disabled as well. However it seems that the shared variables are buffered anyway - even though I stop the acquisition (I am sure it is stopped and there is no data being sent to the npsvs) it still takes a while before the host part notices that, becasue there are lots of data being displayed. I check if there are new values with timeout put to 0. I tried using Flush vi, but it didn't do the job. Do you have any idea how to discard all those values that seem buffered?

Thanks for any suggestions

0 Kudos
Message 1 of 7
(2,898 Views)

Hello Kasik,

 

You can use flush shared variable data.vi to flush all variable data. You can get this vi in data communication--> Shared Variable --> PSP Variable --> flush shared variable data.

Thanks and Regards
Himanshu Goyal | LabVIEW Engineer- Power System Automation
Values that steer us ahead: Passion | Innovation | Ambition | Diligence | Teamwork
It Only gets BETTER!!!
0 Kudos
Message 2 of 7
(2,889 Views)

Hi
That's what I tried, but still - it didn't work. And I am sure that the measurement is stopped so there is no new data.

0 Kudos
Message 3 of 7
(2,883 Views)

Hi Kasik,

 

                 Could you tell us how did you configure the shared variables (the data type for instance) ?.

                

                Then, one possibility would be that you are still using buffering in the acquisition, and therefore even if you stop the measurement at some point, there will still be some data left in that buffer, which will be later transmitted to the shared variable. Therefore, a good idea might be to flush the data from that one too. Actually, when you are using the Flush Shared Variable Data VI, LabVIEW sends all of the shared variable data that has not yet transmitted over the network, but there could be up to 8 kilobytes when you are performing this, due to the data stored previously in the acquisition buffer.

 

                Also, another thing to try would be one of the examples available in Labview - Simple Shared Variable and Event Monitor. It shows how to build a variable and event monitor. It displays a list of currently deployed processes or libraries and allows you to monitor all shared variables in a process.

 

Regards,

 

Denis

0 Kudos
Message 4 of 7
(2,855 Views)

If you are sure you are not pushing new data to the network shared vairables, then it could be that your client end is slow to receive and display the data it previously received. There will always be a small delay when transmitting data through NSVs, so when you stop publishing data it could be a short while before the subscribers stop receiving updates, but not usually more than a second or two. If you are receiving lots of data then there is some buffering occurring somewhere. Can you share any code, or recreate the issue with a slimmed down version of the project for us?

Thoric (CLA, CLED, CTD and LabVIEW Champion)


0 Kudos
Message 5 of 7
(2,848 Views)

I can't find this example:  Simple Shared Variable and Event Monitor (we are using LabVIEW 2011, may it be this reason?)


Well it would be hard, the project is quite complex, we use several instruments for the measurement - some sequentially, some in parallel. And yes - the host part is slower for sure. This is visible only when the acquisition of data from ni card is used (also when this is the only instrument used). We acquire with 2MHz sampling rate and each time I read I take 200k from 4 channels to process. The data read is enqueued, processed and decimated in another task and sent to the publishing task that pushes the data to the shared variables and saves (only when the specific event occures). On the host part there is only one loop running continuouesly - the one to get data from shared variables. When debugging I see that the command - stop was sent and the measurement is stopped, the queues are empty and no new data is pushed. While on the host it takes even a minute to notice that it was really stopped. Sometimes also during the aqcuisition it seems frozen, because the new don't appear, while on the target part everything works fine. The data type of this shared variable is quite complex - it is a cluster of clusters that have arrays (with only 5 elements). It is configured not to use buffering. There is only one writer and one reader.

Thank you for any suggestions.

0 Kudos
Message 6 of 7
(2,819 Views)

Hi Kasik,

 

 

              What I would suggest to you, would be to test the transmission system - you could just build a very simple application ( project ) that would generate some simple data on your target, and then send it via the shared variables to the host. This way you will be able to benchmark the transmission rate, and see if there is indeed a problem with the variables, or maybe something else - although, it looks like your client machine seems to be the cause.

 

            Also, I have attached the example ( from LV 2013 ) that I have mentioned previously. See, if you can use it to monitor your application.

 

Regards,

 

Denis

0 Kudos
Message 7 of 7
(2,803 Views)