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.

NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamically preload a VI

Solved!
Go to solution

Hi,

 

I dynamically load and execute an equipment driver VI in a for loop.The VI to execute is defined at runtime from a custom Test Station Configuration File.

 

Is there a way to load the VI once on the first loop and keep it loaded until the sequence ends or is unloaded (thus avoid losing time by reloading it on each loop).

 

I tried to set the following load/unload options to the labview Action step, but it does not seem to work properly... The VI takes ~3sec to be executed on each loop (due to the loading time). 

Load option: Load dynamically

Unload option: Unload when sequence file is unloaded.

 

 

I also tried to set a step calling the same VI once before the loop with the "preload when execution begins" option. In this condition, the VI seems to remain loaded properly as the execution of the VI in the loop takes

0.5s (instead of 3sec).

 

Therefore, why the load/unload option does not seem to work properly when the VI is called dynamically in the for loop and is it possible to dynamically preload a VI ?

 

 

Thank you

C.

 

 Note: I'm using TestStand 2013

 

 

 

 

 

 

 

 

 

 

 

0 Kudos
Message 1 of 6
(6,408 Views)

Have you tried to leave the load option as "preload when execution begins" even though the code module is being called dynamically from your station file? What behavior did you see?

0 Kudos
Message 2 of 6
(6,383 Views)

Hi meow, 

 

I had the same behavior... However, I found a workaround by creating a new step to load the VI but without executing it... Kinda patch I guess, but it works.

 

the path of my driver VI is in variable Locals.ViPathToLoad

 

In teststand: 

 

----------------------------------------------------------------------------------------

** PRELOAD Equipment VI **

if ( bViInitDone != true)

 => Action ActiveX/COM, Get Step Reference {Locals.LVStep = Call Sequence{RunState.Sequence}.GetStepByName ("Load VI", StepGroup_Main)}

 => Action ActiveX/COMGet Reference to Step Module {Locals.LVModuleObjRef = Get Step{Locals.LVStep}.Module}

 => Action ActiveX/COMSet Module to Selected VI {Set LabVIEWModule{Locals.LVModuleObjRef}.VIPath (Locals.ViPathToLoad)}

 => Action ActiveX/COMLoad Prototype to Selected VI {Call Module{Locals.LVModuleObjRef}.LoadPrototype (0)}

 => Action ActiveX/COM, Load Module of Selected VI {Locals.IsModuleLoaded = Call Step{Locals.LVStep}.LoadModule (0, )}

 => Action Labview, "Load VI"   => set to SKIP

 => bViInitDone = true

end

 

{.. some code to set all parameters of the VI to execute in the loop .. }

 

** Execute VI **

FOR{} 

 

 Configure Equipment VI (path = ViPathToLoad)

 

end

----------------------------------------------------------------------------------------

 

Even if the step "Load VI" is not executed, the "Load Module of Selected VI" step force loading the driver VI in my dummy step "Load VI". Therefore, the VI is already loaded in memory when running the loop and the execution is way faster.  

 

I believe the trick is to load a step with the appropriate code module and never modify it afterward. 

 

Thanks

C.

0 Kudos
Message 3 of 6
(6,375 Views)

Set the step to Unload after sequence executes.  Then in a statement step outside of the looping you can call:

RunState.Sequence.Main["My Step"].Module.Unload()

 

Hope this helps,

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
0 Kudos
Message 4 of 6
(6,370 Views)
Solution
Accepted by topic author NutaqTestDept

RunState.Sequence.Main["Statement"].Module.Load() can also be called in a statement before the loop.

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
Message 5 of 6
(6,368 Views)

Nice hint! Thank you very much !

 

Maybe to clarify, the function RunState.Sequence.Main["YourStepName"].Module.Load() replace all the ActiveX/COM commands to preload the step.

 

However, if you want the module to remain loaded, it seems that you should load it from a step that you will never edit dynamically afterward. In my case, the parameters of the VI executed in my loop are edited with some activeX steps and it seems that preloading this step does not work properly. However, if I load the module from a dummy step, it works. Even if I force the step to be skipped. 

 

Therefore, to fix my issue, I created a new step that I populate dynamically with the VI name to load (the same VI than the one in my loop), I load the module from this step using the aforementionned command, and force it to be skipped (RunMode = "skip"). Look as a patch, but works fine and let me cut by more than two the overall test time.   

 

Average VI execution time (spectrum analyzer signal & measurements capture) :

before: 2.7sec

now: 0.6sec 

 

C.

 

0 Kudos
Message 6 of 6
(6,350 Views)