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.
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.
09-15-2014 01:05 PM - edited 09-15-2014 01:07 PM
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
Solved! Go to Solution.
09-15-2014 02:41 PM
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?
09-15-2014 03:20 PM - edited 09-15-2014 03:23 PM
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/COM, Get Reference to Step Module {Locals.LVModuleObjRef = Get Step{Locals.LVStep}.Module}
=> Action ActiveX/COM, Set Module to Selected VI {Set LabVIEWModule{Locals.LVModuleObjRef}.VIPath (Locals.ViPathToLoad)}
=> Action ActiveX/COM, Load 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.
09-15-2014 03:23 PM
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,
09-15-2014 03:25 PM
RunState.Sequence.Main["Statement"].Module.Load() can also be called in a statement before the loop.
09-16-2014 07:39 AM - edited 09-16-2014 08:08 AM
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.