LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to save the data in a Subvi

Dear people,
 
I am currently making a program which is calling with a Call by Reference Node. after that, I read out data (in this case an array of clusters) and I am writing new data to the cluster of the subvi.
 
My problem is that the new data isn't stored in the subVI. If I close my Caller VI and i take a look in the SubVI all the 'new' data is erased and it seems to me that the program returned to its Default Values...
 
How can I make a program so that the new data is stored in the subVI after I called it. I tried already with a invoke Node and then as method: Make all current Values Default. Actually, the SubVI is in the wrong state to execute that node...So I don't know how to go...
 
 
 
 
 
 

Message Edited by btwesseling on 09-21-2006 07:37 AM

0 Kudos
Message 1 of 10
(4,358 Views)
Hi,

I wouldn't be sure of the best method to do this without seeing your code but have you considered using an uninitialised shift register to store the values?

Shift registers remember data from previous executions of a VI, so if you write data to a shift register, the next time you run the VI that data will still be stored there.

Could you post your code so I can have a look at what you're trying to implement? (if it's a large application just post the section that's applicable)
Sarah

Applications Engineer | National Instruments | UK & Ireland
0 Kudos
Message 2 of 10
(4,343 Views)
Hi,
 
I posted a picture with my block diagram. ....
 
 
0 Kudos
Message 3 of 10
(4,338 Views)
Could you also post the block diagram of your subvi?
Sarah

Applications Engineer | National Instruments | UK & Ireland
0 Kudos
Message 4 of 10
(4,329 Views)

Yes...here is the code.

The only thing it does is transferring the Data from an input array to an output array...nothing special...

when I am in runnign mode the data is been written in the output VI, but when I stop executigin the mainprogram, and the open the Subiv, all the data is gone...

 

0 Kudos
Message 5 of 10
(4,310 Views)
Hi,

Could you explain a bit more about what you're trying to achieve? I'm guessing that you plan on loading a different SubVI depending on interaction on the user interface, is that right? Why do you want to dynamically call the SubVIs? Is there a particular reason why you don't want to load each SubVI at runtime?

The way your VI is currently written, when you stop your VI, VI server will unload those SubVIs from memory which means they won't remember any data that's been passed to them. If you were calling them as regular SubVIs they would be kept in memory after the main VI is finished running so the front panel objects would remember the last value that was passed to them.

If you explain a bit more about your application, ie why you want to call the subVIs dynamically and why you want to be able to remember the front panel values then there may be another way to do what you need.
Sarah

Applications Engineer | National Instruments | UK & Ireland
0 Kudos
Message 6 of 10
(4,295 Views)
Yes, I can explain,
 
I am making a test program which is testing a device. There are around 400 different tests, and it is important that all the tests go in a sequential order.
Before I actually run a test I need to give up some parameters. The parameters are been given in a mainprogram.
 
so, if I load my main program, it is scanning which tests are available.  From each test I would like to see the paramters in my main-program. I am doing this by putting it into a cluster, which is been read-out by my main program. 
I also would like to change the paramters, and then save the paramters back into the SubVI. For Example, In my main prgram I can set if a test is enabled or disabled.
 
After setting the paramters the subvi closes. At the begin of testing, I scan all the tests outputs using a 'Call by Reference' node and I look if they are enabled or not. If yes, I make up an array of paths and after that all the tests which are in that array are been called and executed. the results aretransferred back to the main program, stored, and finally written in a TSV file (Tab Separated Value file.)
 
the reason for a dynamically load is that in the case of someone wants to add a new test, it is dificult to change the mainprogram. In other words, the program which I am writing is for people who don't know much about labview, so I want to make it as user-friendly as possible. I am planning to make a kind of an wizard that helps the engineers to add tests.
 
the second reason is that there are different devices which needs to be tested.  If I load all my tests in one time, that means that for each different device I have to load all the tests. that means that I have to load over 5000 tests in one time, which is not so nice.
 
iI hope it is more clear now, but If you have more questions please let me know!
 
 
0 Kudos
Message 7 of 10
(4,288 Views)
Hi,

I think I understand what you're doing a bit better now. As you're loading the SubVIs into memory then unloading them, they won't remember the data you're passing them. You'll have to include the code to get the subVI to save this information. One way to do this would be to write the parameters of each subVI to an XML file, then when the subVI is reloaded you can call the XML file and load the appropriate information into the front panel controls.

Another way to do it, although it may involve changing the structure of your aplication a bit, would be to write all the configuration parameters to an INI file. This Knowledge Base explains a bit more about how to do this and I believe the attached example does almost exactly what you want.

Let me know if you need any more information on this. I'm a bit busy today so I haven't been able to look into this much but hopefully I'll be a bit quieter tomorrow!
Sarah

Applications Engineer | National Instruments | UK & Ireland
0 Kudos
Message 8 of 10
(4,269 Views)
Hi Sarah,
 
The Knowledge base was a great help. I think I am gonna use that one.
 
But it is not possible to do it in a way so that I don't generate an extra file outside of the SubVI?
 
Bernard W.
 
 
0 Kudos
Message 9 of 10
(4,252 Views)
Hi,

I don't believe so. You have to explicitly store the data somewhere. You could possibly write it to a global variable, although that would still technically be another file...
Sarah

Applications Engineer | National Instruments | UK & Ireland
0 Kudos
Message 10 of 10
(4,239 Views)