NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Retrieve data form a fileglobal in a process model

Hi,

In the process model I have declared a boolean variable, and in my UI I want to access that variable.
To do that I have tried the code below but it doesn't work
OleErrChk( TS_SeqFileGetProperty (gCurrentSequenceFile, &errorInfo, TS_SeqFileHasModel, CAVT_BOOL, &hasModel));

if (hasModel){
OleErrChk( TS_SeqFileGetModelSeqFile (gCurrentSequenceFile, &errorInfo, &modelDesc, &modelFile));
CA_FreeMemory (modelDesc);
OleErrChk(TS_SeqFileAsPropertyObject (modelFile, NULL, &modeFilePropObj));
OleErrChk(TS_PropertyExists (modelSeqFile, NULL, "PopupErrorMessage", 0, &VarExists));
}

Does somebody now how to do it

thank
s in advance
0 Kudos
Message 1 of 3
(3,161 Views)
Hi,

Are you trying to get access to the global at run-time? If this is the case then you should use post a UIMessage from within the process model that contains the value of your global variable. This is the recommended way.

If you are trying to access the global before an execution of your model sequence file has begun, your code should look something like this ( I have exlcuded the error checks):


/* Providing you have a handle to the current sequence file*/

TS_SeqFileGetProperty(gCurrentSeqFile, NULL, TS_SeqFileHasModel, CAVT_BOOL, &hasModel);

if(hasModel)
{
TS_SeqFileGetModelSeqFile(gCurrentSeqFile, NULL, &ModelDesc, &modelFile);
CA_FreeMemory(ModelDesc);
TS_PropertyGetValBoolean (modelFile, NULL, "FileGlobals.MyGlobal", 0, &boolVal);

}

This should work.

Let me know if this helps.

Bob
0 Kudos
Message 2 of 3
(3,161 Views)
> In the process model I have declared a boolean variable, and in my UI
> I want to access that variable.
> To do that I have tried the code below but it doesn't work
> OleErrChk( TS_SeqFileGetProperty (gCurrentSequenceFile, &errorInfo,
> TS_SeqFileHasModel, CAVT_BOOL, &hasModel));
>
> if (hasModel){
> OleErrChk( TS_SeqFileGetModelSeqFile (gCurrentSequenceFile,
> &errorInfo, &modelDesc, &modelFile));
> CA_FreeMemory (modelDesc);
> OleErrChk(TS_SeqFileAsPropertyObject (modelFile, NULL,
> &modeFilePropObj));
> OleErrChk(TS_PropertyExists (modelSeqFile, NULL,
> "PopupErrorMessage", 0, &VarExists));
> }

If the variable you want to twiddle at run-time is a FileGlobal, the method
Execution.GetFileGlobals will return a reference to a proper
ty object of the
FileGlobals for the specified sequence file object. See the online docs.

I have not found a way to change run-time versions of other non-FileGlobal
variables yet.

HTH,

---
Joe
0 Kudos
Message 3 of 3
(3,161 Views)