onewayautomation / opcuatestclient Goto Github PK
View Code? Open in Web Editor NEWOPC UA Client test application, using One-Way Automation C++ OPC UA SDK.
OPC UA Client test application, using One-Way Automation C++ OPC UA SDK.
Hello,
I am currently trying to connect to two different OPC-UA Servers with your SDK and "Hello World" example.
For the first one it works totally fine and I can access and read all nodes.
With the second one I am encountering a connection problem where I receive the wrong endpoint from the server. Connecting to this particular server works fine with UaExpert (it somehow ignores the wrong returned endpoint-url).
This is the Code I am using:
#include <opcua/Connection.h>
#include <iostream>
#include <conio.h>
using namespace std;
using namespace OWA::OpcUa;
int main (int argc, char** argv)
{
(void)argc;
(void)argv;
bool succeeded = false;
{
auto connection = Connection::create("opc.tcp://128.130.57.75:4840", true);
if (connection->connect().get().isGood())
{
cout << "Connection established" << endl;
NodeId nodeId("NS1|String|DISPLAY_CURRENT", 1);
nodeId.setStringIdentifier("DISPLAY_CURRENT", 1);
for (int i = 0; i < 100; i++) {
ReadRequest::Ptr readRequest(new ReadRequest(nodeId));
auto readResponse = connection->send(readRequest).get();
if (readResponse->isGood() && readResponse->results.size() == 1 && Utils::isGood(readResponse->results[0].statusCode))
{
cout << "READREQUEST # " << i << endl;
// We know that data type of the value is String, therefore convert it to string should succeed:
float currentValue = readResponse->results[0].value;
DateTime tstamp = readResponse->results[0].sourceTimestamp;
//string newValue = (currentValue == value1) ? value2 : value1;
cout << "DISPLAY_CURRENT: " << currentValue << endl;
const string abc;
cout << "TSTAMP: " << tstamp.toString() << endl;
succeeded = true;
}
}
_getch();
}
}
OWA::OpcUa::Utils::closeSdk();
if (!succeeded)
{
std::cout << "Reading value failed!" << std::endl;
return -1;
}
else
{
return 0;
}
}
Console Output:
Hope you can support me with this problem.
Thanks in advance!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.