Git Product home page Git Product logo

opcuatestclient's Introduction

OpcUaTestClient

OPC UA Client test console application, using One-Way Automation C++ OPC UA SDK.

How to build on Windows.

It is assumed that source code repository base folder is at RepoBaseFolder.

Please note that currently binaries for the OPC UA SDK are created only for VC++ 2017, 64 bit debug and release modes. If you need SDK binaries for other targets (not only VC++, any other target like Ubuntu or Raspberry Pi), please create an issue or contact us.

Install prerequisites

  • Install Microsoft Visual Studio 2017. Free Community edition is sufficient. Note that component Desktop development with C++ should be selected in Visual Studio Installer, and installed. Please also note that scripts which build dependencies, have path to the vcvarsall.bat file, which prepares environment to build C++ code, set for Community edition of Visual Studio (C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build). If you have Enterprise or Professional version, please adjust path in the build-botan.bat file.
  • Install Python 2.7 and add path to it into the Path environment variable;
  • Install nasm (download from http://www.nasm.us, and add path to it into Path environment variable;)
  • git should be availabe from Windows command line console, together with git shell sh.exe.

Clone and build dependencies

  • Open command line console and go to the folder RepoBaseFolder/OpcUaTestClient
  • Run script install-dependencies.cmd This can take for a while (around 15 minutes) to pull source code and build all the dependencies.

Build OpcUaTestClient

Open solution RepoBaseFolder/OpcUaTestClient/OpcUatestClient.sln with Visual Studio 2017 and build the solution.

Please note that at the very first run of the built application it will take some time to create CA certificate and Application Instance Certificate.

License and Copyright

Copyright 2018-2019, One-Way Aautomation Inc.

This source code can be distributed and used under MIT license terms (https://opensource.org/licenses/MIT)

Questions?

If you have questions / issues, or need binaries of the SDK for other targets, please contact us by email ravil at onewayautomation.com.

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.