NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Hi,


How to unload a new sequence file created by GetNewSequenceFile using TestStand API?

Many Thanks! In a function "CreateTemp" of my project, I create a new sequencefile by using TS API fn GetNewSequenceFile. After insert sequences&steps, I use SequenceFile Save fn to save as "C:\Test\Dut_Tmp.seq" and ReleaseSequenceFile on exit. On entry to the function the second time, the "Dut_Tmp.seq" is deleted and creating of new sequence file is repeated. But could not save the file because the same name is already loaded. I try to figure out how to unload a loaded sequence file using TS API functions. My project using VC++/MFC and TestStand 1.0.2
0 Kudos
Message 1 of 5
(2,696 Views)
Engine.NewSequenceFile() method creates and returns a SequenceFile object. After you are done using this object you must call Engine.ReleaseSequenceFile() method. These methods are described in the TestStand help file.
0 Kudos
Message 2 of 5
(2,696 Views)
Hi Danh,


To backup Nemo comment.

Attached is a sequence file. If you run this it will create a sequencefile in c:\temp.
If you run this again it will still create a sequencefile (no errors).
If you set the Locals.SkipStep to True, then run this two more times, the second run will error with the error you are getting.

Follow up question:
If the Engine.ReleaseSequenceFile() is not performed, maybe because of an error. How can you get a new reference to an already loaded sequencefile so that the sequencefile can be released and unloaded from memory.

Ray Farmer
Regards
Ray Farmer
Message 3 of 5
(2,696 Views)
Dahn,

You can use the Engine.UnloadAllModules method to unload the sequence file from memory. In addition, be sure to release the Active X reference to the sequence file after you have released the sequence file itself (look in the ActiveX API Help under "Releasing References").
Message 4 of 5
(2,696 Views)
Hi,

The Engine.UnloadAllModules doesnt appear to remove the sequence file from memory. In fact the only action that seems to get out the error listed below. is to exit from TestStand.

When using the ActiveX adapter does this automatically close any references to objects generated.

An error occurred in the 'Save Sequence File' step of the 'MainSequence' sequence in 'NewSequenceFile.seq'.
An exception occurred calling 'Save' in 'SequenceFile' of 'TestStand API 1.0'
Unable to save sequence file as 'c:\temp\my sequence.seq' because a sequence file with that path is already loaded.
Source: TSAPI
ActiveX automation server exception. Error Code: -17811

(This error generated by following steps in comment to Danh question.)



Adding an addition ReleaseSequ
enceFile step to ensure reference was unloaded only produce the following error -

[An error occurred in the 'Release SequenceFile_Copy' step of the 'MainSequence' sequence in 'NewSequenceFile.seq'.
An exception occurred calling 'ReleaseSequenceFile' in 'IEngine' of 'TestStand API 1.0'
Operation failed for sequence file ''.
File was unloaded from the TestStand Engine.
Source: TSAPI
ActiveX automation server exception. Error Code: -17811].


When the sequence was run again the first error occurred for the NewSequenceFile step. But the error for the ReleaseSequenceFile clearly showed that the sequencefile was unloaded.

confused Ray Farmer
Regards
Ray Farmer
0 Kudos
Message 5 of 5
(2,696 Views)