NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Unloading a module used in another sequence/sequence file

Hi,

 

I have created a custom step and an edit sub-step for it. In the edit sub-step, I basically have a sub-panel into which the specified module/VI is loaded and displayed. The VI can also be run from the edit sub-step.

Now the problem is, once a sequence is executed, the VIs loaded in the sequence's steps are reserved. When I try to configure and run the same VIs from the edit sub-step of the custom step in another sequence/sequence file, I get the error - "Error 1000 - LabVIEW: The VI is not in a state compatible with this operation.Method Name: Run VI" (Screenshot attached). So, the VI/module has to be unloaded before running it. But the 'Unload' method of 'Module' object does not unload the module if the module is used (and executed) in a different sequence/sequence file (Snippet used to unload a module is shown below).

Unload Module

 

I have already considered 'Unload Modules' method of the SequenceFile object. I am not using it because it unloads all the other modules which need not be unloaded unnecessarily (it had to be loaded again when a step containing that module is configured) and also because it does not unload the module if it is reserved in another sequence file.

I have also considered using the 'EditCode' method of the module which also unloads it. But it opens up the VI for editing in Labview which is not desirable.

What is the best way of unloading a module before executing it in Edit sub-step if it is reserved by another sequence or sequence file?

 

Thank you,

Ganesh Kumar

 

Message 1 of 5
(3,727 Views)

Ganesh,

 

if you are running the VI from another location concurrently (simultaneously), there is one possible way to solve this:

Set the VI reentrant.

 

Please note that this significantly changes the behavior of the VI for the runtime (e.g. caching data internally), so this might not be a solution for you!

 

Another possible solution is to make sure that the unload option of the sequence steps calling this (sub)VI as module are configured to unload the module either after step execution or sequence execution. The default unload option is "sequence file unload".

 

A third option is to include a step in the sequence calling the (sub)VI in the cleanup step group where you call into the TestStand API Engine.UnloadAllModules().

 

hope this helps,

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 2 of 5
(3,720 Views)

Norbert,

 

Thanks for the reply. The requirement is that the Custom step must be self-containing (It should not depend on anything external). The solutions that you have proposed involves modifying the VI that is loaded (first solution) or modifying the sequence (second and third solutions). But I am looking for a way to unload only that particular module that is configured using this Custom-Step.

The 'Unload' method of the Module object does not unload the module if any other sequence containing this module had already been executed. Is there any way to unload a particular module (even if it has been reserved by another sequence) without modifying the sequence or the VI being configured?

 

Thank you,

Ganesh Kumar

0 Kudos
Message 3 of 5
(3,707 Views)

Ganesh, I have exactly the same problem; did you find a way to resolve it?

 

I can think of one possible method but it is tricky: in my case it is only the current sequence that might have previously loaded the VI of interest; I could look though all the preceding steps to locate calls to the same VI and then call step.UnloadModule on each one (if there is more than one they must all be done).

0 Kudos
Message 4 of 5
(2,978 Views)

FWIW I attach a LV2013 VI that works (it runs the VI whose path is passed in, which is what I want to do):

  1. Open the VI and get it's Execution State. If it is "Idle" TestStand has not loaded it so we can go straight to 4.
  2. Get the Sequence object from the SequenceContext.
  3. For each step group {Setup, Main} (yes, my VI can be called from Setup too Smiley Sad)
    • For each step in the group
      1. Get it's Module object
      2. If the Module uses the LabVIEW adapter AND the VI path is the same as the VI I want to run, call module.Unload().
  4. Run the VI.
0 Kudos
Message 5 of 5
(2,966 Views)