NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to overwrite loaded sequence

I am trying to copy and overwrite a set of sequence files which were previously called from a main sequence file.
However, they are not affected by the copy command but are left unchanged. I think I need to perform
some "release" or "close" action on the files but I have so far not found a solution to this. Please, anyone,
what is missing in my example attached?

/Stefan
0 Kudos
Message 1 of 3
(3,216 Views)
Stefan -
I assume that you want to force TestStand to reload a sequence file when the file has been changed on disk even after a sequence in the file has previously executed within the execution.

When TestStand loads a sequence file it places it in an internal cache. A sequence file can only be reloaded when no "editor" references are open for the file. "Editor" references are those that are created using the Engine.GetSequenceFileEx method (the file is open in the sequence editor), and those that the engine acquires internally to support executing its sequences.

One example of when TestStand internally adds an editor reference to a file is when TestStand wants to call a sequence in the file. To execute the sequence TestStand clones the edit-time copy of the sequence to create a run-time copy of the sequence. While the run-time copy of the sequence exists, the file is locked and cannot be reloaded. Obviously the run-time copy exists while the execution runs the sequence.

When TestStand creates the run-time copy of the sequence, the more steps that a edit-time sequence contains, the longer the clone operation takes to create the run-time copy. To optimize performance, a sequence has an option that specifies whether the execution should discard the run-time copy of the sequence after it executes or add the copy to a private cache associated with the execution. The sequence setting "Optimize Non-Reentrant Calls to This Sequence" determines this behavior. If the execution caches the run-time copy of the sequence, the execution can reuse it when the sequence is called again, without having to clone a new copy. But this keeps the "editor" reference around. For large sequences, this caching can significantly improve performance. So if any sequence in a file is called and the sequence has the Optimize option enabled, the file cannot be unloaded until sequence cache is cleared and this occurs when the execution completes.

In TestStand there is no way to explicitly force the release of run-time sequences from the execution's cache. The only workaround is to disable the above sequence option for all sequences in a file that you expect to reload dynamically.

Note that when running multiple executions, ex. using the parallel model, if there is always at least one execution executing a sequence in the file, the file will always have at least one editor reference open, so the file can never be reloaded.

I should point out that TestStand 3.1 does have an additional workaround. TestStand 3.1 has a new feature to support "loading limits" into a sequence once instead of every time the sequence executes. To support this feature, the following API methods were added to the Execution interface: NewSequenceDefaultValues, GetSequenceDefaultValues, SetSequenceDefaultValues, ClearSequenceDefaultValues. A side affect of the ClearSequenceDefaultValues method is that it clears the run-time sequences from the execution's cache, thus releasing its "editor" reference to its files.

Now, even if you disable the optimization setting in the sequences in a file, sequence call steps still hold onto there own editor reference to a file while its module is loaded. There are various ways to force a step to unload its module. If the sequence call step's Unload Option" is set to "Unload after the step executes", the step releases its "editor" reference after the step executes. Another way to force the module to be unloaded is to call one of the following methods: Step.UnloadModule, Sequence.UnloadModules, or Engine.UnloadAllModules.

Lastly, if the file is a model file or the client sequence file, there are additional references that the engine and sequence editor/OI hold that prevent the file from being unloaded. These references are very difficult to work around at this time.

In summary, if the file that you want to reload is not the model or client file and you are not running parallel executions, and the subsequence file is NOT loaded in the sequence editor, you should be able to do the following:
1) In the calling sequence, set the sequence call step's load and unload option to be load dynamically and release after step executes
2) In the called sequence file, set "Optimize Non-Reentrant Calls to This Sequence" for each sequence to False.
Scott Richardson
0 Kudos
Message 2 of 3
(3,211 Views)
Scott!
Thanks a lot for your response. I tried the settings suggested in your last paragraph with positive results!
Now I can edit my subsequence files "online" while the application is running, and there is no more need to interrupt the operator to download new limits for testing.

/Stefan
0 Kudos
Message 3 of 3
(3,193 Views)