NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Saving persistent data in sequence file

I need to be able to save data collected and processed during one session and have it available during the next session (i.e. I want to be able to update the initial value of some sequence file globals). How do I do this in TestStand? e.g. I might want to keep track of how many times a particular sequence has been run. I know that I can store this information in StationGlobals, but the variable is unique to the sequence and does not qualify as a global.
0 Kudos
Message 1 of 24
(4,813 Views)
To Hurst -
A running sequence has access to its default global values, i.e. using the lookup string "RunState.SequenceFile.Data.FileGlobalDefaults" or the API SequenceContext.SequenceFile.FileGlobalsDefaultValues. If you change values, you must also call PropertyObjectFile.IncChangeCount so that the TestStand knows to refresh the document if open and mark it as edited.

Note that the runtime copy of the file globals will not be updated when editing the default copy until you start a new execution.

Scott Richardson (NI)
Scott Richardson
https://testeract.com
0 Kudos
Message 2 of 24
(4,813 Views)
I figured out how to everything but the

'PropertyObjectFile.IncChangeCount'

call, please be specific, the function doing this task has the the current sequence context available.
0 Kudos
Message 3 of 24
(4,813 Views)
Hurst -
If you are using the TestStand expression language, you could use the expression:

RunState.SequenceFile.ChangeCount++

If you are using the API, you need to call the IncChangeCount method using the PropertyObjectFile class. A SequenceFile object is derived from the PropertyObjectFile class. So if you are using the ActiveX adapter you just need to call the above class method on the object specified by RunState.SequenceFile. The adapter will query the SequenceFile object for the PropertyObjectFile class that you give it.

Scott Richardson (NI)
Scott Richardson
https://testeract.com
0 Kudos
Message 4 of 24
(4,813 Views)
I guess I wasn't clear in my request, how do I do that at the 'C' level?
0 Kudos
Message 5 of 24
(4,813 Views)
If you are using CVI and you call a step that does this it might look something like this:

void __declspec(dllexport) __stdcall AccessLocalVariables(CAObjHandle seqContextCVI, short *errorOccurred,
long *errorCode, char errorMsg[1024])
{
ERRORINFO errorInfo;
int error = 0;
ErrMsg errMsg = {'\0'};

CAObjHandle sequenceFile = 0;
CAObjHandle propertyObjFile = 0;
tsErrChk(TS_SeqContextGetSequenceFile (seqContextCVI, &errorInfo, &sequenceFile));
tsErrChk(TS_SeqFileAsPropertyObject (sequenceFile, &errorInfo, &propertyObjFile));
tsErrChk(TS_PropertyObjectFileIncChangeCount (propertyObjFile, &errorInfo));

Error:
if (propertyObjFile)
CA_DiscardOb
jHandle(propertyObjFile);
if (sequenceFile)
CA_DiscardObjHandle(sequenceFile);

// If an error occurred, set the error flag to cause a run-time error in TestStand.
if (error < 0) {
*errorOccurred = TRUE;
*errorCode = error;
strcpy(errorMsg, errMsg);
}
}
Scott Richardson
https://testeract.com
0 Kudos
Message 6 of 24
(4,813 Views)
Ok, I got it all coded up, but there's one big problem TestStand does not update the file!

Here's my implementation:

// Get a handle to the sequence file
errChk (TS_SeqContextGetSequenceFile (testData->seqContextCVI, &errorInfo, &seqFileH));

// Get a handle to the property object file
errChk (TS_SeqFileAsPropertyObject (seqFileH, &errorInfo, &propObjFileH));

// Tell TestStand that the file needs to be saved
errChk (TS_PropertyObjectFileIncChangeCount (propObjFileH, &errorInfo));


When I run this with the sequence editor and place a breakpoint immediately AFTER this step and examine the default value, it has been updated. And after the test is over the modification flag (*) comes ON in
the sequence file.

But when I run the sequence with TestStand and then open up the sequence file AFTER the test is complete, then the default value has not changed even though it should have.

What's going on?
0 Kudos
Message 7 of 24
(4,813 Views)
To Hurst -
In TestStand 3.1, I tried it and the engine behaved propertly. If a file is opened by the engine but does not have a window, the engine will not unload the file if modified. So if you modify the file at runtime and then open it, the modified flag should be on. Did you see the modified flag (*) for the file when opened after running? What version of TestStand are you using?

Scott Richardson (NI)
Scott Richardson
https://testeract.com
0 Kudos
Message 8 of 24
(4,813 Views)
I'm running TestStand 3.0 through an operator interface and so the sequence file is never shown in a window. When I opened the sequence file after the test the modified flag was NOT on.
0 Kudos
Message 9 of 24
(4,813 Views)
To Hurst -
I still could not reproduce the problem. I have attached two sequences.
temp30a.seq:
"MainSequence" calls teh "Alter Default Globals" sequence in temp30b.seq

temp30b.seq:
Contains file globals string with value "Original".
"Alter Default Globals" alters itself and increments the count.
"MainSequence" displays the file global

Open temp30a.seq and run "MainSequence". Close execution display.
Open temp30b.seq and run "MainSequence". You will get a prompt showing "New Value", not "Original"

Scott Richardson (NI)
Scott Richardson
https://testeract.com
Download All
0 Kudos
Message 10 of 24
(4,813 Views)