LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Change Prototype Parameter from a TestStand DLL Module Programmaticaly

Solved!
Go to solution

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.

Daniel Coelho
VISToolkit - http://www.vistoolkit.com - Your Real Virtual Instrument Solution
Controlar - Electronica Industrial e Sistemas, Lda
0 Kudos
Message 1 of 4
(4,254 Views)

To add more information:

 

seqContextCVI is a parameter of a DLL function that receives "ThisContext" from TestStand.

 

"CAObjHandle seqContextCVI"

Daniel Coelho
VISToolkit - http://www.vistoolkit.com - Your Real Virtual Instrument Solution
Controlar - Electronica Industrial e Sistemas, Lda
0 Kudos
Message 2 of 4
(4,225 Views)

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

Daniel Coelho
VISToolkit - http://www.vistoolkit.com - Your Real Virtual Instrument Solution
Controlar - Electronica Industrial e Sistemas, Lda
0 Kudos
Message 3 of 4
(4,208 Views)
Solution
Accepted by topic author Daniel Coelho

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, &parameters));
    tsErrChk(TS_DllParametersGetItem (parameters, &errorInfo, CA_VariantInt(1), &parameter));
    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);
}

Daniel Coelho
VISToolkit - http://www.vistoolkit.com - Your Real Virtual Instrument Solution
Controlar - Electronica Industrial e Sistemas, Lda
0 Kudos
Message 4 of 4
(4,141 Views)