NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Access fileglobals of procesmodel

Hi,

I use Teststand 2.0 and labwindows 6.0.
I have build a ui in labwindows and I want to acces a variable (runtime) in the procesmodel.
Below you can see a codesnippet but this doesn't work
What is the best way of doing it


int TSAL_SetDBError(int State)
{
ERRORINFO errorInfo;
int error = 0, WhasRunning=0;
CAObjHandle modelFile=0,ModelFilePropObj=0;
char *modelDesc=NULL;
VBOOL hasModel,Val;

OleErrChk( TS_SeqFileGetModelSeqFile (gCurrentSequenceFile, &errorInfo, &modelDesc, &modelFile));
CA_FreeMemory (modelDesc);
OleErrChk(TS_SeqFileAsPropertyObject (modelFile, NULL, &ModelFilePropObj));

if (State){
OleErrChk(TS_PropertySetValBoolean (ModelFilePropObj, &errorInfo, "FileGlobals.DBerror", 0, VTRUE));
}
else{
OleErrChk(TS_PropertySetValBoolean (ModelFilePropObj, &errorInfo, "FileGlobals.DBerror", 0, VFALSE));
}

Error:
if (seqContext)
CA_DiscardObjHandle(seqContext);
if (modelFile)
CA_DiscardObjHandle(modelFile);
return 0;
}
0 Kudos
Message 1 of 3
(3,156 Views)
Hi,

You will need to determine where you are in the execution.
If you are executing steps in the process model sequence, you will beable to use the lookup string "FileGlobals.DBerror" using the SequenceContext to derive the reference.

But you maybe executing outside the process model sequence when you do your check. In which case you will need to determine where you are in relationship to the pprocess model. This you can do by obtaining the value from RunState.StackDepth.

eg if you are in the MainSequence called from TestUUT's, the StackDepth will be 1, if you are in a sub-sequence of MainSequence called from TestUUT's the stach depth will be 2 and so on.

To find the lookup string to FileGlobls.DBerror while in MainSequence it would be RunState.Caller.SequenceFle.FileGlobals.DBerror.
For every increase in the StackDepth you add another RunState.Caller. to the front end of the string.

You can check for the existence of RunState.Caller, and if it exists then you will know that you are in a subsequence. You can check RunState.ClientSequenceFile (not quite sure if thats the exact wording of that property but you can check the help) and if this exists then you are using the processmodel.


One final point.
By default each sequenceFile is setup to have seperate FileGlobals. But you can set the properties of your sequencefile to use a common FileGlobals which may make life a little easier because you can then just use FileGlobals.DBerror as the lookup string from what every position.


Hope this helps

Regards
Ray Farmer
Regards
Ray Farmer
0 Kudos
Message 2 of 3
(3,141 Views)
Hi,

A few corrections:
>>This you can do by obtaining the value from RunState.StackDepth

This should read:
This you can do by obtaining the value from RunState.CallStackDepth

>>......RunState.Caller.SequenceFle.FileGlobals.DBerror

This should be:
RunState.Caller.FileGlobals.DBerror

>>....check RunState.ClientSequenceFile

This should read:
check RunState.ProcessModelClient


In addition, you can also check whether you are in the process model by checking the state of
RunState.InProcessModel. If this is True you are in the process model.

Regards
Ray Farmer
Regards
Ray Farmer
0 Kudos
Message 3 of 3
(3,129 Views)