LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VI Server Needing a New Reference Every Call or it Returns Old Data

Solved!
Go to solution

So I am running a simple program where I am just trying to poll data between LabVIEW Projects on 1 computer, with the final goal of doing the same from another computer over a network connection. 

 

Problem I am running into is that I have to get a new reference every time for this to work, it isn't allowing me to use the same reference to get new data. 

 

I'm wondering why I need to get a new reference every time to read fresh data. The VI I am reading data from is in a different project on this computer and is running within that project. 

 

DOES NOT WORK - THIS ONLY RETURNS VALID DATA THE FIRST LOOP AND STALE DATA EVERY LOOP AFTER

 

rkmadse_0-1615930626566.png

rkmadse_1-1615930638616.png

rkmadse_2-1615930652941.png

 

DOES WORK - THIS METHOD RETURNS FRESH DATA EVERY TIME

 

rkmadse_3-1615931311479.png

 

 

 

Message 1 of 7
(1,135 Views)

What happens if you run the first one with out the options wired into the "Open VI" node, or copy the options to the second one? It's not actually the same code.

 

Also, did you mean to make the options in decimal?  Usually it should be in hex to make it more obvious which ones are enabled.

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

I think if the VI goes idle, the references will become invalid.  How are you calling it?  What happens between calls?

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 3 of 7
(1,069 Views)

So when I remove the options selection I get the same behavior, it returns valid data for the first iteration, and then every time after that it returns the same data and never fresh data. 

0 Kudos
Message 4 of 7
(1,046 Views)

So this is all there is to this test we are running (it's just a mock up of what we really intend to do). 

 

Project 1 - VI 1

rkmadse_0-1615994279386.png

Project 2 - VI 2

rkmadse_1-1615994356485.png

The intent here is to just constantly read data from with VI 2 from VI 1. 

 

And for whatever reason the reference goes bad after the first read. I guess my follow up question to you would be, what is considered "idle"? Neither of these are being called as SubVIs. They are running in separate projects though. 

 

0 Kudos
Message 5 of 7
(1,043 Views)

"Idle" is one of the 4 execution states (Bad, Idle, Run Top Level, Running).  Idle state is indicated by a white run-arrow.

 

Note that each project has it's own context.  When project 2 opens a VI reference, there is a copy of that VI in project 2, and it's data is isolated from the data in project 1.  Therefore anything that happens in project 1 won't propagate to project 2.  When you close the VI reference in project 2, the copy of VI 1 is unloaded from project 2's memory space.  I'm actually surprised that reopening the VI reference yields fresh data; I would have expected to just get default values.

 

The "Open VI Reference" function does have an "application reference" input and if VI 2 could get a reference to project 1's application context, then VI 2 could open a reference to the copy of VI 1 that's in project 1's memory space.

 

Passing data between 2 projects is a very odd thing.  You might want to consider rearchitecting.

"If you weren't supposed to push it, it wouldn't be a button."
Message 6 of 7
(1,020 Views)
Solution
Accepted by rkmadse

Something like this:
p2p.png

Don't forget to close all 3 references.

"If you weren't supposed to push it, it wouldn't be a button."
Message 7 of 7
(1,014 Views)