NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Use

  I'm building an executable application, which is used to set variable flags in Teststand. I have the following codes and I'm sure I have a trouble in use of "TS_PropertySetFlags". Appreciate if anyone could help me on how to get the CAObjHandle in "TS_PropertySetFlags" function
 
.......
errChk(TS_NewEngine(NULL,&engine));
tsErrChkMsgPopup(TS_EngineGetSeqFileEx(engine,&errorInfo,OpenedSequenceFile,11,TS_ConflictHandler_Promt,&SeqFileObj);
tsErrChkMsgPopup(TS_PropertySetFlags(seqFileObj,NULL,ts_Context,0,FlagSetNumber));
......
 
Regards!
Jacky
0 Kudos
Message 1 of 7
(4,091 Views)
Jacky,
 
Check the following code.
I am setting the "TS_PropFlags_Hidden" flag corresponfing to the SequenceFile.Path property to true.
 
#define CLEAR(__handle, __func)    \
 if(__handle)       \
 {          \
  __func(__handle);     \
  __handle = 0;      \
 }
 
void __declspec(dllexport) __stdcall MyFunction(CAObjHandle seqContextCVI,
        char reportText[1024], short *errorOccurred, long *errorCode, char errorMsg[1024])
{
    int error = 0;
    ErrMsg errMsg = {'\0'};
    ERRORINFO errorInfo;
    CAObjHandle engine = 0;
    CAObjHandle sequenceFile = 0;  
   
    tsErrChkMsgPopup( TS_SeqContextGetEngine (seqContextCVI, &errorInfo, &engine));
 tsErrChk(TS_SeqContextGetSequenceFile (seqContextCVI, &errorInfo, &sequenceFile));
 tsErrChk(TS_PropertySetFlags (sequenceFile, &errorInfo, "Path", 0,
          TS_PropFlags_Hidden));
   
   
Error:
 CLEAR(engine, CA_DiscardObjHandle);
 CLEAR(sequenceFile, CA_DiscardObjHandle);
}
 
Hope it Helps.
 
Antonio Lie.
0 Kudos
Message 2 of 7
(4,066 Views)
Hi Antonio Lie
   I think you have misunderstood my way. I'm buiding an executable application, which is used to set Flags in Teststand. In your code, you are buiding a DLL which already have avaiable seqContextCVI. However, in my code, this "seqContextCVI" value is unkown.
 
 
Thanks and hope to  get your help again.
 
Jacky
0 Kudos
Message 3 of 7
(4,061 Views)
Jacky,
 
You can create a SequenceContext object by using Engine.NewEditContext.
 
VARIANT  optParameter = {0};
CAObjHandle     sequenceFileObject = 0;
CAObjHandle     seqContextObject = 0;
 
//obtain engine and sequence file
 
tsErrChk(TS_EngineNewEditContext (engine, &errorInfo,
                                                              sequenceFileObject ,
                                                              CA_DEFAULT_VAL,
                                                             &optParameter,
                                                             &seqContextObject));

tsErrChkMsgPopup(TS_PropertySetFlags(sequenceFileObject ,NULL,seqContextObject,0,FlagSetNumber));
 
 
 
This method returns a sequence context that approximates the sequence context TestStand creates when you run a sequence.
For more information refer to NI TestStand Help.
 
Hope it helps.
 
Antonio Lie.
 
 
0 Kudos
Message 4 of 7
(4,035 Views)
Jacky,
 
After reviewing your first post I noticed that you do not need the sequence context to set the flags of the sequence file object.
It seems that you  are already getting the sequence file object from the engine and the next step would be  to use  TS_PropertySetFlags to set the desired flags.
TS_PropertySetFlags do not take a sequence context as an input.
Disregard my previous post.
 
Hope it helps.
 
Antonio Lie.
 
 
 
0 Kudos
Message 5 of 7
(4,024 Views)

Hi Antonio

One thing: If I use the following codes in my EXE file, it will popup up an ActiveX error(-2147352567), I attached the error screenshot here. The reason why there comes this kind of error, I think is the wrong using the "SeqFileObj", the datatype of SeqFileObj during use of TS_EngineGetSeqFileEx  is "TSObj_SeqFile", not CAObjHandle.


    errChk( TS_NewEngine (NULL, &engine));
   CA_VariantSetCString (&optParameter, ts_GlobalsContext);
   tsErrChkMsgPopup(TS_EngineGetSeqFileEx (engine, &errorInfo,OpenedSequenceFilePath, 11,TS_ConflictHandler_Prompt, &SeqFileObj));
   tsErrChkMsgPopup(TS_PropertySetFlags (SeqFileObj, NULL, ts_GlobalsContext, 0, flagSet));

Anoter thing: According to your suggestion, I think to use the following codes are also not correct. Please see red part below, the datatype for it should be a string, not Obj.  

tsErrChk(TS_EngineNewEditContext (engine, &errorInfo,
                                                              sequenceFileObject ,
                                                              CA_DEFAULT_VAL,
                                                             &optParameter,
                                                             &seqContextObject));

tsErrChkMsgPopup(TS_PropertySetFlags(sequenceFileObject ,NULL,seqContextObject,0,FlagSetNumber));
 
Last:I modified my codes again according to your suggestion, please see below. There comes the same error with the first.
 
  errChk( TS_NewEngine (NULL, &engine));
 CA_VariantSetCString (&optParameter, ts_GlobalsContext);
 tsErrChkMsgPopup(TS_EngineGetSeqFileEx (engine, &errorInfo,OpenedSequenceFilePath, 11,TS_ConflictHandler_Prompt, &SeqFileObj));
 tsErrChkMsgPopup(TS_EngineNewEditContext (engine, &errorInfo,SeqFileObj ,CA_DEFAULT_VAL,&optParameter,&seqContextObject));
 tsErrChkMsgPopup(TS_PropertySetFlags (seqContextObject, NULL, ts_GlobalsContext, 0, flagSet)); 
 
Thanks!
Jacky
 


 

0 Kudos
Message 6 of 7
(4,013 Views)

Jacky,

You do not need the sequence context in order to load a sequence file and modify a flag.
The TS_PropertySetFlags method does not take the sequence context as an input parameter.
I created a small application that sets the TS_PropFlags_Hidden flag of a sequence you load by browsing to the corresponding file.
Youa have to remember that if you load a sequence file using TS_EngineGetSeqFileEx you have to release it using TS_EngineReleaseSeqFileEx.
Check the attached example and let me know if you have any questions.

Antonio Lie.

 

0 Kudos
Message 7 of 7
(3,993 Views)