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++ Notive console apllication need to read from OPC server cache.

More
06 Sep 2016 12:14 #4327 by support
That's easy:
ReadItemArguments1Ptr->ReadParameters->DataSource = DADataSource_Cache;
because DataSource property gets transformed from TLB to:
__declspec(property(get=GetDataSource,put=PutDataSource))
    enum DADataSource DataSource;
and DADataSource is defined as:
enum __declspec(uuid("b0e1f79b-7601-44b3-8013-9398e4151091"))
DADataSource
{
    DADataSource_ByValueAge = 0,
    DADataSource_Cache = 1,
    DADataSource_Device = 2
};

Best regards

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

More
06 Sep 2016 10:49 #4326 by olab
Hello,

In attached code i need to set this to read from OPC servers cache and not directly from the device. I just can't get the syntax on this line. Can someone help me?

#include "stdafx.h"
#include <atlsafe.h>
#include <comutil.h>
#include <iostream>


using namespace std;

#import "libid:BED7F4EA-1A96-11D2-8F08-00A0C9A6186D" // mscorlib
using namespace mscorlib;

#import "libid:ecf2e77d-3a90-4fb8-b0e2-f529f0cae9c9" // OpcLabs.BaseLib
using namespace OpcLabs_BaseLib;

#import "libid:14D1A788-0333-4D64-8547-8FB0357408EF" // OpcLabs.EasyOpcClassicInternal
using namespace OpcLabs_EasyOpcClassicInternal;

#import "libid:1F165598-2F77-41C8-A9F9-EAF00C943F9F" // OpcLabs.EasyOpcClassic
using namespace OpcLabs_EasyOpcClassic;




int _tmain(int argc, _TCHAR* argv[])
{

bool exit = false;

while (exit == false)
{
// Initialize the COM library
CoInitialize(NULL);

// Instatiate the EasyOPC-DA client object
_EasyDAClientPtr ClientPtr(__uuidof(EasyDAClient));

_DAReadItemArgumentsPtr ReadItemArguments1Ptr(_uuidof(DAReadItemArguments));
ReadItemArguments1Ptr->ServerDescriptor->MachineName = L"";
ReadItemArguments1Ptr->ServerDescriptor->ServerClass = L"Kepware.KEPServerEx.V5";
ReadItemArguments1Ptr->ItemDescriptor->ItemId = L"Simulation Examples.Functions.Ramp2";
//ReadItemArguments1Ptr->DAReadParameters->DADataSource = 1;
//THIS WON't WORK
ReadItemArguments1Ptr->ReadParameters->DataSource = 1;
//************************************************************************************************
CComSafeArray<VARIANT> ArgumentsArray(1);
ArgumentsArray.SetAt(0, _variant_t((IDispatch*)ReadItemArguments1Ptr));


LPSAFEARRAY pArgumentsArray = ArgumentsArray.Detach();
CComSafeArray<VARIANT> ResultArray(ClientPtr->ReadMultipleItems(&pArgumentsArray));
ArgumentsArray.Attach(pArgumentsArray);

for (int i = ResultArray.GetLowerBound(0); i <= ResultArray.GetUpperBound(0); i++)
{
_DAVtqResultPtr DAVtqResultPtr(ResultArray);
_DAVtqPtr DAVtqPtr(DAVtqResultPtr->Vtq);





variant_t res = DAVtqPtr->Value;
cout << res.fltVal;
cout << endl;
}

// Release all interface pointers BEFORE calling CoUninitialize()
ResultArray.Destroy();
ClientPtr = NULL;

CoUninitialize();


Sleep(1000);
}
return 0;
}

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

Moderators: support
Time to create page: 0.049 seconds