Professional OPC
Development Tools

logos

Online Forums

Technical support is provided through Support Forums below. Anybody can view them; you need to Register/Login to our site (see links in upper right corner) in order to Post questions. You do not have to be a licensed user of our product.

Please read Rules for forum posts before reporting your issue or asking a question. OPC Labs team is actively monitoring the forums, and replies as soon as possible. Various technical information can also be found in our Knowledge Base. For your convenience, we have also assembled a Frequently Asked Questions page.

Do not use the Contact page for technical issues.

C++ ReadMultipleItems example

More
14 Jul 2011 14:02 #414 by support
R., K.,
I have managed to create a C++ example with ReadMultipleItems and DAVtqResult at this last moment.

Here is a code that works (tested with QuickOPC-COM 5.10):

#include "stdafx.h"
#include 
#include 
 
#import "libid:FAB7A1E3-3B79-4292-9C3A-DF39A6F65EC1" version(5.1)    // EasyOpcLib
using namespace EasyOpcLib;
 
int _tmain(int argc, _TCHAR* argv[])
{
       // Initialize the COM library
       CoInitialize(NULL);
 
       // Instatiate the EasyOPC-DA client object
       IEasyDAClientPtr EasyDAClientPtr(__uuidof(EasyDAClient));
 
       CComSafeArray ItemIdArray(4);
       ItemIdArray[0] = _T("Simulation.Random");
       ItemIdArray[1] = _T("Trends.Ramp (1 min)");
       ItemIdArray[2] = _T("Trends.Sine (1 min)");
       ItemIdArray[3] = _T("Simulation.Register_I4");
 
       CComVariant vMissing;
       vMissing.vt = VT_ERROR;
 
       CComVariant vResults(EasyDAClientPtr->ReadMultipleItems(_T(""), _T("OPCLabs.KitServer.2"), 
              CComVariant(ItemIdArray.Detach()), vMissing));
 
       CComSafeArray ResultArray(vResults.parray);
       for (int i = ResultArray.GetLowerBound(0); i < ResultArray.GetUpperBound(0); i++)
       {
              IDAVtqResultPtr DAVtqResultPtr(ResultArray);
              IDAVtqPtr DAVtqPtr(DAVtqResultPtr->Vtq);
              _tprintf(_T("results(%d).Vtq.ToString(): %s\n"), i, DAVtqPtr->ToString().bstrVal);
       }
 
       // Release all interface pointers BEFORE calling CoUninitialize()
       ResultArray.Destroy();
       vResults.Clear();
       EasyDAClientPtr = NULL;
 
       CoUninitialize();
 
       TCHAR line[80];
       _putts(_T("Press Enter to continue..."));
       _fgetts(line, sizeof(line), stdin);
       return 0;
}


I am attaching a zipped project, too (in VS 2010).
If the customer is using managed C++ with QuickOPC.NET, the code would be quite different, though; in such case, let me know again.

Best regards,

Please Log in or Create an account to join the conversation.

More
14 Jul 2011 13:59 #413 by support
From: R.
Sent: Thursday, June 30, 2011 6:35 PM
To: Zbynek Zahradnik
Subject: C++ ReadMultipleItems example

Hello Zbynek,
I have a customer who is having trouble with the ReadMultipleItems callback using C++. He said he is getting some errors about the DaVTQResult being an invalid structure?

Do you have any quick examples that demonstrate this method?

Thanks,
R.

Please Log in or Create an account to join the conversation.

Moderators: support
Time to create page: 0.085 seconds