LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

TS_StepSetRunModeEx

I'm trying to use function TS_StepSetRunModeEx to set the run mode on a TestStand step from CVI. I want to pass a reference to the execution object in the last parameter in my call to TS_StepSetRunModeEx so that only the current execution is affected. However, I can't find a way to get the reference to the execution object so that I can pass it into TS_StepSetRunModeEx. I tried using function TS_ExecutionAsPropertyObject to get the execution object, but this function returns an object (TSObj_Property) whereas TS_StepSetRunModeEx requires a VARIANT. I tried casting the object to a variant in the call to TS_StepSetRunModeEx, but that wouldn't compile. How do I get the reference to the execution object?

Thanks,
BB
0 Kudos
Message 1 of 9
(4,004 Views)
Billy,

The best way to get the execution object would be to pass the sequence context into your code module and then use the PropertyGetValVariant function and use the lookup string "RunState.Execution" which will always get the current execution. This will also already be a Variant data type which should be able to be passed directly into TS_StepSetRunModeEx. Give this a try and repost if you have any other questions. Thanks and have a good one.

Adam B.
Applications Engineer
National Instruments
0 Kudos
Message 2 of 9
(3,984 Views)
Thanks for the reply, but I am still having problems. I thought I had tried what you suggested already, but I went ahead and tried it again. Here is the code:

ERRORINFO errorInfo = {0};
VARIANT vTemp;

//
// Get reference to execution object
//
TS_PropertyGetValVariant (testData->seqContextCVI,
&errorInfo,
"RunState.Execution",
0,
&vTemp);

And here is the error generated by the call to TS_PropertyGetValVariant:

wCode:0
sCode:-17308
source:TSAPI
description:Specified value does not have the expected type.
helpFile:
helpContext:0
errorParamPos:-1

To me this looks like "RunState.Execution" cannot be stored to a VARIANT. Somehow I need to get a VARIANT so that I can pass that to TS_StepSetRunModeEx.

Thanks,
Bill Bartol
0 Kudos
Message 3 of 9
(3,980 Views)
Billy,


Here is some code I made that should accomplish what you want.
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)
{

}
}

Allen P.
NI

PS- I may have a few memory leaks in there, but this should at least show you the way to do what you want.

Message Edited by AllenP on 05-17-2005 02:19 PM

0 Kudos
Message 4 of 9
(3,927 Views)
No dice... The call to TS_SeqContextGetExecution gives me a compiler error - "missing prototype". So I tried using TS_ExecutionAsPropertyObject in its place. That compiled and linked no problem (no more errors), but then the call to TS_StepSetRunModeEx is not altering the run mode on the step. I also tried using TS_SequenceAsPropertyObject to get the execution object - no change in behavior.

Thanks,
Bill
0 Kudos
Message 5 of 9
(3,916 Views)
Bill,

I'm not sure why you are getting the missing prototype error. The function should be defined in the function panel as part of the TestStand API (at least in 3.0 and higher). Are you able to hit Ctrl-P to bring up the function panel for it? Under Instrument >> TestStand API 3.x, are you able to browse to this property? (Advanced >> Sequence Context >> Static Properties >> Run State >> Get Execution). I'll double check in earlier versions if you are using an earlier version of TestStand. Also, make sure you have tsapicvi.h included in your project.

As for the method TS_ExecutionAsPropertyObject, that will convert an execution object to a property object. Since you do not have an execution object before that (the TS_SeqContextGetExecution function will retrieve an execution object from a sequence context), I will assume that you are passing it the Sequence Context. This will convert the Sequence Context to a Property Object, which can still be converted to a variant, which is why you are seeing the compile, but incorrect behavior.
0 Kudos
Message 6 of 9
(3,904 Views)
The problem is I am using TestStand v2.x. We are in the process of upgrading to 3.x, so I'll give it a shot again when we have done that.

Thanks,
Bill
0 Kudos
Message 7 of 9
(3,899 Views)
My apologizes. I'll install 2.0.1 later today and hopefully give you a better way to solve the problem.
0 Kudos
Message 8 of 9
(3,889 Views)
Here is the method that you can use in 2.x

TS_SeqContextGetProperty (seqContext, &errorInfo, TS_SeqContextExecution, CAVT_OBJHANDLE,&execObj);

Hope this helps!
0 Kudos
Message 9 of 9
(3,886 Views)