NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How to get execution object for SetRunModeEx?

I would like to know how to get an execution object for use with the function TS_StepSetRunModeEx.  I am using TestStand 3.1, calling CVI 7.1 code.
0 Kudos
Message 1 of 13
(3,928 Views)

Pass in the SequenceContext and then you can get the execution from that.  Or just pass in SequenceContext.Execution.  You may have to change it to a variant.

Regards,

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
0 Kudos
Message 2 of 13
(3,911 Views)
I am using TS_SeqContextGetExecution to get the execution object, but I get the error 0x80004005 (Unspecified Error) when I do.  In TestStand I declared an object reference named "MainSequenceContext."  In CVI I get the variable "Locals.MainSequenceContext" using TS_PropertyGetValIDispatch.  The variable is of type CAObjHandle and is named: oMainSequence.  I can use oMainSequence for functions like TS_SequenceGetNumSteps and it works fine.
0 Kudos
Message 3 of 13
(3,903 Views)

Hey Snood,

After you get the Obj Handle for the Execution are you converting it to a Variant before passing it to the set step mode call?  Try:

CA_VariantSetObjHandle

Then you can pass it into the TS_StepSetRunModeEx

Regards,

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
0 Kudos
Message 4 of 13
(3,897 Views)
Please understand that I can't get the execution object handle at all because I get the aformentioned error generated by TS_SeqContextGetExecution.
0 Kudos
Message 5 of 13
(3,893 Views)

Here is some code that should do the trick:

void __declspec(dllexport) setStepExec(CAObjHandle step, CAObjHandle context)
{
VARIANT execVariant;
LPDISPATCH execDispatch;
int error = 0;
CAObjHandle execObj;
TS_SeqContext
ERRORINFO errorInfo;
TS_SeqContextGetExecution (context, &errorInfo, &execObj);
CA_GetDispatchFromObjHandle (execObj, &execDispatch);
execVariant = CA_VariantDispatch (execDispatch);
TS_StepSetRunModeEx (step, &errorInfo, "Skip", execVariant);

Error:
if (error < 0)
{

}
}

There are probably memory leaks however but that is the gist of it.

Regards,

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
Message 6 of 13
(3,889 Views)
This code will probably work, but I should still get the same error when I call TS_SeqContextGetExecution.  For some reason it must not like the object handle I got from TS_PropertyGetValIDispatch.  Yet it likes it okay for a function like TS_SequenceGetNumSteps.
0 Kudos
Message 7 of 13
(3,875 Views)
The thing that would be most helpful would be assistance in figuring out why I get an error when calling TS_SeqContextGetExecution.
0 Kudos
Message 8 of 13
(3,837 Views)
I would like to try another angle:

Here is the function prototype for TS_SeqContextGetExecution.

RESULT CVIFUNC TS_SeqContextGetExecution (CAObjHandle objectHandle, ERRORINFO *errorInfo, TSObj_Execution *val);

Can you tell me how to get the objectHandle property?
0 Kudos
Message 9 of 13
(3,817 Views)

Hey Snood1,

The ObjectHandle would be the sequence context passed from TestStand into CVI.  Basically it contains all the information about the state of the current execution.  You should have an example that shows how to get the sequence context into your dll: <TestStand>\Examples\AccessingPropertiesAndVariables\PassingSequenceContextToDLL  It was written in CVI so it demonstrates what you are looking for. 

I hope this helps.  Let me know if there's anything else.

Regards,

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
0 Kudos
Message 10 of 13
(3,810 Views)