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.
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.
06-24-2011 04:52 PM
I'm working on a project that requires communicating with Unidrive through OPC Server. I'm programming with LabWindows/CVI.
I cannot make those function calls work that require SAFEARRAY parameter to be passed in. For example, IOPCGroupAsyncRead( )...
Want to know if anybody has done the same thing successfully. I need your help. Thanks.
06-27-2011 05:12 PM
Hi Marg SZ,
What version of LabWindows/CVI are you using? Are you seeing any specific errors when trying to use the function calls?
Perry S.
06-27-2011 05:55 PM
Hi Perry,
I'm using LabWindows/CVI 6.0. There is no error messages. I can only read/write item successfully because they do not require SAFEARRAY parameters.
I would appreciate if you can help.
Margaret
06-28-2011 05:12 PM
Hi Margaret,
How are you creating the safe arrays? Is your array 1D or 2D? Are you using the conversion functions in LabWindows/CVI?
Regards,
Perry S.
06-28-2011 06:35 PM
My code is as follows. Some of the variables are global. Thanks.
void GroupAsyncRead(void)
{
OPCAutomationObj_OPCItems ppItems;
OPCAutomationObj_OPCItem ppItem;
long numItems, hvalue, i;
SAFEARRAY *serverHandles, *errors; SAFEARRAYBOUND rgsabound[1];
OPCAutomation_IOPCGroupGetOPCItems(OPCGroupHandle, &Error_Info, &ppItems);
OPCAutomation_OPCItemsGetCount(ppItems, &Error_Info, &numItems);
rgsabound[0].lLbound = 0;
rgsabound[0].cElements = numItems;
serverHandles = SafeArrayCreate(VT_I8, 1, rgsabound);
for(i=0; i < numItems; i++)
{
OPCAutomation_OPCItemsItem(ppItems, &Error_Info, CA_VariantInt(i+1), &ppItem);
OPCAutomation_OPCItemGetServerHandle(ppItem, &Error_Info, &hvalue);
SafeArrayPutElement(serverHandles, &i, &hvalue);
}
OPCAutomation_IOPCGroupAsyncRead(OPCGroupHandle, &Error_Info, numItems, &serverHandles,
errors, GetTransactionID(), &cancelID);
asyncReadInProgress = 1;
OPCAutomation_DIOPCGroupEventRegOnAsyncReadComplete(OPCServerHandle, ProcessGroupAsyncReadComplete, NULL, 1, NULL);
SafeArrayDestroy(serverHandles);
SafeArrayDestroy(errors);
}
06-29-2011 07:29 AM
Sorry, I pasted it wrongly in the previous post. "errors" is passed by reference as follows.
OPCAutomation_IOPCGroupAsyncRead(OPCGroupHandle, &Error_Info, numItems, &serverHandles,
&errors, GetTransactionID(), &cancelID);
06-29-2011 06:13 PM
Hi Margaret,
I think that you are using the wrong functions to create your safe arrays. Please use the functions that are located in the ActiveX Library, Array section.
Perry S.
06-30-2011 05:56 PM
Hi Margaret,
Where did you get the functions that you are using to create the safearrays? Which CVI library?
Perry S.
06-30-2011 06:16 PM
Perry,
Those are functions of Windows SDK. I haven't tried your suggestion on using ActiveX Array functions.
Thank you for following on this.
Margaret
07-01-2011 02:00 PM
Hi Margaret,
Let me know how it works when you try it.
Perry S.