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));
}
When I ask the propertyobject if "PopupEr
rorMessage" exists, I get an error "Handle invalid".

Does somebody now how to do it

thanks in advance
0 Kudos
Message 1 of 5
(3,380 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
Message 2 of 5
(3,380 Views)
Hi Bob

Thank you for the quick responds, but there is still a little problem.
TS_PropertyGetValBoolean (modelFile, NULL, "FileGlobals.PopupErrorMessage", 0, &Val);
causes an error "Unknown variable or property name Fileglobals".

I have also tryed:
if (hasModel){
OleErrChk( TS_SeqFileGetModelSeqFile (gCurrentSequenceFile, &errorInfo, &modelDesc, &modelFile));
OleErrChk(TS_SeqFileAsPropertyObject (modelFile, &errorInfo, &modeFilePropObj));
CA_FreeMemory (modelDesc);
OleErrChk(TS_PropertyGetValBoolean (modeFilePropObj, &errorInfo, "FileGlobals.PopupErrorMessage", 0, &Val));
}
But the errormessage is the same

Tonnie
0 Kudos
Message 3 of 5
(3,380 Views)
Hi Tonnie,

Oops, I forgot to mention something. The reason you are getting this error is that there is no sequence context object created. You need to create one using the NewEditContext method of the engine. I have attached a simple file that demonstrates this. Please excuse the lack of error checking, etc. Just a quick test to make sure that it works.

Hope this helps.

Muppet Man
0 Kudos
Message 4 of 5
(3,380 Views)
Hi "Muppet Man"

Now it works fine,
Thank you for your effort.

Tonnie
0 Kudos
Message 5 of 5
(3,380 Views)