NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Saving persistent data in sequence file

Ok, it behaves as it should! My sequence is not as short as yours, I have about 850 steps. I am also not using one of the standard Model sequences in order to get the desired behaviour (basically addition of StationGlobal variables, modified step types and modified report generator based on TS 3.0 sequences).

Is the saving of the modified sequence in any way dependant on the Model sequence being used or is this totally internal to the TS engine?
0 Kudos
Message 11 of 24
(1,975 Views)
More info. When I first loaded your sequence files into the sequence editor the modified flag (*) was on. I never updated (by saving) the files explicitly.

When I run my test in the sequence the modified flag (*) comes on, but unless I explicitly save it the changes do NOT get saved.

Could it be that the modified flag (*) comes on as a result of the actual modification and NOT as a result of telling TS that the sequence file has been modified, that would certainly explain the behaviour.
0 Kudos
Message 12 of 24
(1,975 Views)
To Hurst -
The model file and a modified sequence file are not related with respect to saving of the modified file. It is an internal engine issue.

Scott Richardson (NI)
Scott Richardson
https://testeract.com
0 Kudos
Message 13 of 24
(1,975 Views)
To Hurst -
To understand why TestStand thinks that the file has to be saved after you first open it in the sequence editor, you could save the original file to a different name and diff the original and the new file. If you attach the newly saved file, I could tell you why the engine wants you to resave it.

TestStand will mark a file as modified upon loading if the types in it are older than the current ones in memory. TestStand will mark a file as modified if the API is called to increment its change count. TestStand does not monitor for changes by the API to the file itself. It is up to the sequence editor to tell TestStand that the file had been edit
ed by incrementing its change count.

Scott Richardson (NI)
Scott Richardson
https://testeract.com
0 Kudos
Message 14 of 24
(1,975 Views)
I tried to comment out sending Testand the file modification notification, and when I run from the sequence editor, the file is modified at the end but the mod flag (*) is not present. I guess this means that TestStand is seeing the flag but refusing to update the hard-drive.

Ok, so how do I coerce TestStand into saving the modified sequence file, WITHOUT operator intervention ?
0 Kudos
Message 15 of 24
(1,976 Views)
To Hurst -
The TestStand engine, the sequence editor, and operator interfaces do not auto-save any files other there own configuration files. To save a sequence file, the Save method must be called on the sequence file object. It will be up to you to do this explicitly. I do not know if you want to do this in your code that alters the value, but that is your design decision.

I have not yet seen a customer trying to do what you are doing. Typically the station globals are used to do what you are doing. You would create an array of objects that contain the data that you want to persist. TestStand allows each element in an array of objects to b
e named in addition to be accessed by index. You could use the name of the sequence file as a lookup into the array. All the saving would be automatic and if you want to clear out the persisted data, you just have to operate on the global data, not each sequence file. Also, have you thought about how you are going to handle multiple thread running the same sequence that attempts to update the "global data"?

Just a thought.

Scott Richardson (NI)
Scott Richardson
https://testeract.com
0 Kudos
Message 16 of 24
(1,976 Views)
So are you now telling me that even though I tell TestStand that the current sequence file has changed, that the actual save operation is up to me?
0 Kudos
Message 17 of 24
(1,976 Views)
Yes, a GUI-less API cannot know when it is OK to save and not to save a file. The purpose of incrementing the change count is to communicate to an application that is editing the document that the file has been changed outside. An example is when a Tools menu, like Import/Export Properties edits the active file. So the application knows about the change because it can call PropertyObjectFile.IsModifiedByUser or PropertyObjectFile.ChangeCount and compare to the last value they knew about.

If the engine always saved a file, how could a user discard changes that they temporarily make to a sequence file in the sequence editor?


For example, Microsoft Word does not autosave documents on top of an original file. Its autosaving mechanism only backs the changes up to a special file in case the application crashes before the user has an opportunity to make the manual decision as to whether to save the file or not.

Scott Richardson (NI)
Scott Richardson
https://testeract.com
0 Kudos
Message 18 of 24
(1,976 Views)
Ok, I can do that instead of telling TestStand that the sequence file has changed. I have the sequence file handle already, is there a simple TestStand command to save the file?
0 Kudos
Message 19 of 24
(1,976 Views)
If you have a reference to the sequence file, you can use the method SequenceFile.Save(path).

You can pass a string to refer to a path to save it in, or leave it as an empty string to keep it in the same location.

Allen P.
NI
0 Kudos
Message 20 of 24
(1,976 Views)