From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Passing Parameters to TestStand from VC++

Hi folks,

I'm trying to send parameters to a "MainSequence" test sequence whem executing
them from VC++6.

Say "MainSequence" takes in one parameter, a number called "number". I'm
trying to use code such as

ParameterProperty=m_TestStandEngine.NewPropertyObject(TS_PropValType_Container,FALSE,"",0);
ParameterProperty.NewSubProperty("Number",TS_PropValType_Number,FALSE,"",0);
ParameterProperty.SetValNumber("Number",0,123);
Parametervar.pdispVal=ParameterProperty.m_lpDispatch;

,then sending it out with Engine.NewExecution(.......)

However, on execution, TestStand is coming back with as error "Specified
value does not have expected type".

Can anyone give me some thoughts here?

Thanks!

Dan
0 Kudos
Message 1 of 2
(2,944 Views)
Dan,

I have successfully compiled and run some VC++ code that accomplishes what you are trying to do. Actually it looks very similar to your code, so it might just be that the ParameterProperty object needs to be converted to a variant in order to pass it to the NewExecution method.
Here is the code from an example on National Instrument's web site:

TS::PropertyObjectPtr sequenceArgs;

// Passed arguments must be a container type
sequenceArgs = m_engine->NewPropertyObject(TS::PropValType_Container, FALSE, "", 0);

// Create subproperties for new propertyObject

sequenceArgs->SetValNumber("param1", TS::PropOption_InsertIfMissing, 4);
sequenceArgs->SetValString("param2", TS::PropOption_InsertIfMissing, "Hello");

// Create
variant to pass to NewExecution method
_variant_t sequenceArguments(sequenceArgs, true);

// run the specified sequence in the currently loaded file
m_currentExecution = m_engine->NewExecution(m_currentSequenceFile,
(const _TCHAR *)sequenceName, modelSeqFile,
VARIANT_FALSE, TS::ExecTypeMask_Normal, sequenceArguments);

I have attached a simple MFC Operator Interface that implements this call. Also, you'll find the sequence to call in the zip file.

Best Regards,

Azucena Perez
Message 2 of 2
(2,944 Views)