03-24-2010 06:27 AM
Hi.
I'm trying to change a parameter of a DLL module inside TestStand programmaticaly.
I change the value, but the value of the parameter doesn't change.
If I reload the prototype on TestStand, the value apears inside the parameter.
Why doesn't it change emediatly?
Why can't I reload the prototype programmatically?
Please see the attached image.
I set the "KeyCode" parameter to "SetCellValue", but the parameter doesn't change.
If I click Reload, the value apears.
I'm using CVI 9.0 with the following code:
...
sprintf(strItemLabel2, "\"%s\"", strItemLabel);
TS_PropertySetValString(seqContextCVI, &errorInfo, "Step.TS.SData.Call.Parms[2].ArgVal", 0, strItemLabel2);
...
printf("%d\n", TS_StepGetModule (seqContextCVI, &errorInfo, &module));
printf("%d\n", TS_CommonCModuleLoadPrototype (module, &errorInfo, VTRUE, &hasPrototypeInfo));
CA_DiscardObjHandle (module);
CA_DiscardObjHandle (StepProperty);
...
I apreciate all the help.
Thank you in advance.
Solved! Go to Solution.
03-25-2010 11:51 AM
To add more information:
seqContextCVI is a parameter of a DLL function that receives "ThisContext" from TestStand.
"CAObjHandle seqContextCVI"
03-26-2010 04:45 AM
This example is great, but the only thing missing is what I want witch is setting the DLL parameters programmaticaly.
Programmatically Reloading a DLL Module Prototype using the TestStand API in CVI
04-05-2010 08:48 AM
To close this subject, here is the solution I found on another post:
http://forums.ni.com/ni/board/message?board.id=330&message.id=28523
//I changed from CVIModuleGetParameters() and CVIParametersGetItem() to TS_DllModuleGetParameters() and TS_DllParametersGetItem and now it works fine.
//seqContextCVI = ThisContext reference object
void __declspec(dllexport) __stdcall GetControlarParameters(CAObjHandle seqContext)
{
int error = 0;
ErrMsg errMsg = {'\0'};
ERRORINFO errorInfo;
char strItemLabel2[1024] = "";
CAObjHandle step = 0;
CAObjHandle seqFile = 0;
CAObjHandle module = 0;
CAObjHandle parameters = 0;
CAObjHandle parameter = 0;
tsErrChk(TS_SeqContextGetStep (seqContext, &errorInfo, &step));
tsErrChk(TS_StepGetModule(step, &errorInfo, &module));
tsErrChk(TS_DllModuleGetParameters (module, &errorInfo, ¶meters));
tsErrChk(TS_DllParametersGetItem (parameters, &errorInfo, CA_VariantInt(1), ¶meter));
sprintf(strItemLabel2, "\"%s\"", "TEST");
tsErrChk(TS_CommonCParameterSetValueExpr(parameter, &errorInfo, strItemLabel2));
// NOTE: After making an edit to a step you need to mark the file as modified by
// incrementing the file's change count. This is also necessary for the change to show
// up in the sequence editor imediately.
tsErrChk(TS_SeqContextGetSequenceFile (seqContext, &errorInfo, seqFile));
tsErrChk(TS_SeqFileIncChangeCount(seqFile, &errorInfo));
Error:
CA_DiscardObjHandle(step);
CA_DiscardObjHandle(seqFile);
CA_DiscardObjHandle(module);
CA_DiscardObjHandle(parameters);
CA_DiscardObjHandle(parameter);
// If an error occurred, set the error flag to cause a run-time error in TestStand.
if (error < 0)
TS_SetStepError(seqContext, error, errMsg);
}