NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Unload Behavior of ProcessModel regarding VIs

Hi folks!

 

In our 'framework' we have developed a process model which - when unloading - does some additional actions (´for example: a log file is updated and some Hardware of the station is switched off). We do this since years, but now as I have reorganized the Unload callback of the process model a different behavior can be seen. VIs which are needed during the unload callback of the model are unloaded before the unload sequence enters. Because I rely on the content of some LV-Globals I get now an RTE (LV-Globals are empty because they were unloaded).

 

Currently I can not see why it worked before and now it doesn't work. I just reorganized the steps and sequences in the unload callback.

 

I think this information is not documented in the TS reference manuals, so maybe this is only known to some TS developer guys 🙂

 

 

Ciao

  weltaran

 

 

0 Kudos
Message 1 of 17
(4,468 Views)

Module loading is defined by the load/unload lifetimes you specify on your steps in the step settings. Also, using the "unload all modules" menu item would override this and unload everything currently loaded.

 

-Doug

0 Kudos
Message 2 of 17
(4,458 Views)

 

 

Yes, thats clear to me. But still I do not know, why some VIs are unloaded and some are not. Before I close my sequence editor I have about 840 VIs in memory (big framework). When I break at the beginning of the unload callback of the process model then I see that at that time only about 400 VIs are left in memory, the other ones were unloaded between the close button of the sequence editor and the beginning of the unload callback sequence. How does the TS engine decide which VIs to unload? By the way: it seems that also (all?) sequence files are unloaded even if they are needed in the unload sequence of the model. You can observe that these SEQ files are unloaded and loaded again when they are needed during the unload sequence (message popups inside the unload and load callbacks). This seems not very efficient.

 

Currently I have the assumption that the engine stores vor every VI the information by which SEQ file the VI was loaded and unloads the VI when the SEQ file is unloaded, even if they are still needed elsewhere for shutdown. But that is just an asumption.

 

Ciao

 weltaran

 

0 Kudos
Message 3 of 17
(4,444 Views)

Hi,

  quick point on the sequence file unloading / loading - there are edit time copies and run-time copies of sequence files. If the file is already loaded as in it's in view during edit time, then depending on certain step settings for sequence call step types (the run options and then the load option and unload option, that may or may not bring that sub sequence in to or out of memory. This can be overridden at the sequence file properties too.

That may then propogate to the code modules (VIs in this case) and whether there are any dependencies on keeping those in memory too.

 

Thanks
Sacha

// it takes almost no time to rate an answer Smiley Wink
0 Kudos
Message 4 of 17
(4,439 Views)

@weltaran wrote:

 

 

Yes, thats clear to me. But still I do not know, why some VIs are unloaded and some are not. Before I close my sequence editor I have about 840 VIs in memory (big framework). When I break at the beginning of the unload callback of the process model then I see that at that time only about 400 VIs are left in memory, the other ones were unloaded between the close button of the sequence editor and the beginning of the unload callback sequence. How does the TS engine decide which VIs to unload? By the way: it seems that also (all?) sequence files are unloaded even if they are needed in the unload sequence of the model. You can observe that these SEQ files are unloaded and loaded again when they are needed during the unload sequence (message popups inside the unload and load callbacks). This seems not very efficient.

 

Currently I have the assumption that the engine stores vor every VI the information by which SEQ file the VI was loaded and unloads the VI when the SEQ file is unloaded, even if they are still needed elsewhere for shutdown. But that is just an asumption.

 

Ciao

 weltaran

 



If the VIs you care about are all referenced in the unload callback, they should stay around as long as the load lifetimes you specify in the unload callback would keep them around.

 

Are the sequences called from your unload callback loaded by expression or directly specified? What are the load/unload options set to on those steps?

 

When you close teststand some additional cleanup is done, but it shouldn't unload modules whose lifetimes are still specified to be active. It might unload things related to executions though if you had execution windows open at the time.

 

What version of TestStand are you using?

 

-Doug

0 Kudos
Message 5 of 17
(4,433 Views)

Actually in looking at things more carefully. It does seem like the sequence call steps might not be keeping the sequence file loaded in this case. If you don't use sequence calls into sequences in another file does the problem go away? Is that an acceptable solution?

 

-Doug

0 Kudos
Message 6 of 17
(4,426 Views)

OK, now I examined the problem further. It is definitely the case that when loading the VI not via the process model DIRECTLY but through a sequence file which is called from the process model, then the VI is unloaded from memory exactly when THAT SPECIFIC SEQ FILE is unloaded. Typically we have on all SEQ files the file setting 'load dynamically' and 'unload when sequence file is unloaded'. Because all SEQ files are unloaded at the same time in parallel when pressing the close button of the sequence editor the VIs are 'gone' when the unload sequence of the model executes (takes some seconds). In fact in this scenario a lot of VIs are unoaded and then loaded again during the execution of the unload callback.

 

Up to now I thought that - like with references in LV - some reference counter is maintained so that the VI is only unloaded when every SEQ file which contains the VI is closed (reference counter increases with every load and decreases with every unload).

 

Conclusion for me: I have to assure that all VIs which are needed during unload callback of the process model are loaded into memory by the process model directly. So I cannot pack hardware related steps (which rely for correct funtion on initialized LV Globals) into external sequences because the content of the LV globals will be gone when thy are needed in unload callback of the model.

 

Featrure request for TS 2018: unload setting 'when system is shutting down'  🙂

 

ciao

  weltaran

 

 

 

0 Kudos
Message 7 of 17
(4,423 Views)

"Up to now I thought that - like with references in LV - some reference counter is maintained so that the VI is only unloaded when every SEQ file which contains the VI is closed (reference counter increases with every load and decreases with every unload)."

 

It does work this way with VIs, but not with sequence files for sequence calls. What's probably happening is that the sequence files that are getting unloaded due to shutting down teststand are the only ones which reference the VIs you care about. If the unload callback itself (or some other sequence in the process model file) directly referenced the VIs you care about they would stay loaded.

 

The reason why sequence files for sequence calls can get unload prematurely is that when a user opens a file directly we want to be able to give them the latest version of the file, not necessarily the one loaded by the last sequence call which still has it loaded, so sequence calls hold onto what are called Releaseable References to sequence files. These are kind of like a weak reference to the file. It keeps the file loaded, but other things like a user directly opening the file, or TestStand shutting down can cause them to be released. In the case of shutdown they are released to ensure that any unload callbacks in such files are called before teststand exits.

 

Hope this helps explain things,

-Doug

0 Kudos
Message 8 of 17
(4,400 Views)

"

 If the unload callback itself (or some other sequence in the process model file) directly referenced the VIs you care about they would stay loaded.

"

 

No! It is as I said: the sequence file which loaded the VI into memory unloads the VI. It does not help to place the same VI in the unload callback (of the model) to prevent it from being unloaded. Because all SEQ files which are in the cache are unloaded at the same time (I think an execution for every SEQ file is started the moment I close my sequence editor) then the VI is already unloaded when it comes to the point where it must be executed (the other SEQ files unload instantly because they have no unload callback enabled) --> it must be loaded into memory again!

 

I have prepared a slightly modified sequential model + two VIs + one external SEQ file for demonstration. Should I post them?

 

By the way (maybe important?): I am working with TS2010 and LV2010SP1.

 

Ciao

 weltaran

 

 

0 Kudos
Message 9 of 17
(4,396 Views)

 

 

Here the demo files (place them in Teststand public folder). Within the load callback you can switch between the two situations:

Situation 1: VI is loaded directly be model (action step). -> VI is unloaded after unload callback of model (LV global has still value 42).

Situation 2: VI is loaded indirectly by 'external.seq' -> VI and Global are unloaded before unload callback of model and loaded again for execution in unload callback (LV Global has again value 0).

 

I always have set the process model as station model.

 

Ciao

 

  weltaran

 

0 Kudos
Message 10 of 17
(4,393 Views)