Git Product home page Git Product logo

opcuatestclient's People

Contributors

raviln avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

0000duck

opcuatestclient's Issues

Endpoints not matching

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:

image

Hope you can support me with this problem.

Thanks in advance!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.