03-29-2010 12:30 PM
Hi.
I started this post inside the LabWindows section, but had no replies there.
Hope I can get some help here.
Please see the follwing link
http://forums.ni.com/ni/board/message?board.id=180&message.id=46129&query.id=804485#M46129
Thanks in advance.
Solved! Go to Solution.
03-30-2010 08:23 AM
Here's where I'm at:
void __declspec(dllexport) GetControlarParameters(CAObjHandle seqContextCVI)
//seqContextCVI has ThisContext reference object
{
char strItemLabel2[1024] = "";
CAObjHandle module = 0;
ERRORINFO errorInfo;
CAObjHandle parameters = 0;
CAObjHandle parameter = 0;
VARIANT varParmIndex;
TS_StepGetModule %d\n", TS_StepGetModule (seqContextCVI, &errorInfo, &module);
TS_CVIModuleGetParameters %d\n", TS_CVIModuleGetParameters(module, &errorInfo, ¶meters);
sprintf(strItemLabel2, "\"%s\"", "TEST");
CA_VariantSetInt(&varParmIndex, 1);
TS_CVIParametersGetItem %d\n", TS_CVIParametersGetItem(parameters, &errorInfo, varParmIndex, ¶meter);
TS_CommonCParameterSetValueExpr %d\n", TS_CommonCParameterSetValueExpr(parameter, &errorInfo, strItemLabel2);
CA_DiscardObjHandle (parameter);
CA_DiscardObjHandle (parameters);
CA_DiscardObjHandle (module);
}
03-30-2010 09:10 AM
a sequence context is not a step, so cannot be used with TS_Step_GetModule(). Where do you want to get the step from? There are several possibilities, one is that the sequence file in which the step exists could be passed in as a parameter, another is that you could use the sequence file that was initially selected when your execution was started (generally for tool menu items), and really there are many more possibilities, please explain exactly what you are trying to do (i.e. where you are getting the sequence file from, why you are wanting to do this, etc.).
-Doug
03-30-2010 09:31 AM - edited 03-30-2010 09:33 AM
Thank you for your reply Doug.
I've created a type pallete in TestStand. One of the functions (Controlar) of my pallete creates an action as a C/C++ DLL Adapter (6 parameters apear with no values).
This step creates an "Edit" button that opens a user interface if you click on it.
Inside the UI the user selects the avalilable data to be inserted in each parameter.
So, when I click "OK", I want to directly write the data in each of the DLL parameters.
Instead of using ThisContext, I used Step or ThisContext.Step but I still can write the data.
I apreciate your help.
03-30-2010 11:54 AM
Ah ok, for an edit substep you should edit the step located at ThisContext.Step. You should still pass in the sequence context though because you will need other things on it too (see example code below).
Your function should look more like the following (also added error handling which will help you better diagnose any problems since you will get an error message rather than it failing silently like it will without error handling):
#include "tsutil.h" // use tsutil.fp as well as tsapicvi.fp
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_CVIModuleGetParameters(module, &errorInfo, ¶meters));
tsErrChk(TS_CVIParametersGetItem(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);
}
Hope this helps,
-Doug
03-30-2010 05:53 PM
You were very helpul, I understand a bit better what I was doing wrong.
Stiil, I'm getting Error -2147467262 "No such interface supported" at TS_CVIModuleGetParameters()
03-31-2010 09:58 AM
That will happen if the step does not currently have a CVI module specified (i.e. the module is for a different adapter so does not implement the CVIModule interface). Please make sure that the step actually has a CVI module specified.
-Doug
04-05-2010 08:44 AM
Hi Doug.
I'm sorry for the delay.
Here's how I solved the problem: I changed from CVI module to DLL module.
Here's a sample of my code:
//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);
}
Thank you for all the help.
My best regards.
04-05-2010 09:28 AM
You must be using the DLL adapter then and not the CVI adapter. Glad you got it working.
-Doug