Coder Social home page Coder Social logo

huangfusu / ua-.netstandardlibrary Goto Github PK

View Code? Open in Web Editor NEW

This project forked from opcfoundation/ua-.netstandard

0.0 2.0 0.0 15.74 MB

OPC Unified Architecture .NET Standard Library

C# 88.12% Batchfile 0.01% C++ 5.69% C 4.81% CSS 0.01% ASP 0.01% HTML 0.02% JavaScript 1.36% Smalltalk 0.01%

ua-.netstandardlibrary's Introduction

OPC UA .Net Standard Library Stack and Samples

Overview

This OPC UA reference implementation is targeting the .NET Standard Library. .Net Standard allows developing apps that run on all common platforms available today, including Linux, iOS, Android (via Xamarin) and Windows 7/8/8.1/10 (including embedded/IoT editions) without requiring platform-specific modifications. Furthermore, cloud applications and services (such as ASP.Net, DNX, Azure Websites, Azure Webjobs, Azure Nano Server and Azure Service Fabric) are also supported. For more information and license terms, see here.

Features included

  1. Fully ported Core UA stack and SDK (Client, Server, Configuration & Sample assemblies)
  2. Sample Servers and Clients, including all required controls, for .Net 4.6, .NetCore and UWP.
  3. X.509 certificate support for client and server authentication
  4. Anonymous, username, X.509 certificate (experimental) and JWT (experimental) user authentication
  5. UA-TCP & HTTPS transports (client and server)
  6. Folder & OS-level (X509Store) certificate-store support
  7. Sessions (including UI support in the samples)
  8. Subscriptions (including UI support in the samples)
  9. OPC UA Reference Server, Aggregation Server and COM Server Wrapper samples

Getting Started

All the tools you need for .Net Standard come with the .Net Core tools. See here for what you need.

All required application certificates for OPC UA are created at the first start of each application in a directory store and remain in use until deleted from the store.

Windows .Net applications

By default the self signed certificates are stored in a folder called OPC Foundation\CertificateStores\MachineDefault in a root folder which is specified by the environment variable ProgramData. On Windows 7/8/8.1/10 this is usually the invisible folder C:\ProgramData. Note: Since the sample applications in the UA-.Net repository use the same storage and application names as UA-.NetStandardLibrary, but create only certificates with hostname localhost, it is recommended to delete all existing certificates in MachineDefault to recreate proper certificates for all sample applications when moving to the UA-.NetStandardLibrary repository.

Windows UWP applications

By default the self signed certificates are stored in a folder called OPC Foundation\CertificateStores\MachineDefault in the LocalState folder of the installed universal windows package. Deleting the application state also deletes the certificate store.

.Net Standard Console applications on Windows, Linux, iOS etc.

The self signed certificates are stored in OPC Foundation/CertificateStores/MachineDefault in each application project folder

Local Discovery Server

By default all sample applications are configured to register with a Local Discovery Server (LDS). A reference implementation of a LDS for Windows can be downloaded from here. To setup trust with the LDS the certificates need to be exchanged or registration will fail.

How to build and run the samples in Visual Studio on Windows

  1. Open the UA-NetStandard.sln solution file using Visual Studio 2015.

Open the UA-NetStandard_2017.sln solution file if you want to build with Visual Studio 2017. Note that only .net Standard stack and console samples are included in this solution file. However, you can pack the build output into nuget packages directly from within Visual Studio 2017 and use these to build .net, UWP, or .net Standard applications with Visual Studio 2017.

  1. Choose a project in the Solution Explorer and set it with a right click as Startup Project.
  2. Hit F5 to build and execute the sample.

How to build and run the console samples on Windows, Linux and iOS

This section describes how to run the NetCoreConsoleClient and NetCoreConsoleServer sample applications.

Please follow instructions in this article to setup the dotnet command line environment for your platform.

Prerequisites

  1. Once the dotnet command is available, navigate to the root folder in your local copy of the repository and execute dotnet restore. This command calls into NuGet to restore the tree of dependencies.

Start the server

  1. Open a command prompt
  2. Now navigate to the folder SampleApplications/Samples/NetCoreConsoleServer.
  3. To run the server sample type dotnet run. The server is now running and waiting for connections. In this sample configuration the server always rejects new client certificates.

Start the client

  1. Open a command prompt
  2. Now navigate to the folder SampleApplications/Samples/NetCoreConsoleClient.
  3. To execute the sample type dotnet run to connect to the OPC UA console sample server running on the same host. To connect to another OPC UA server specify the server as first argument and type e.g. dotnet run opc.tcp://myserver:51210/UA/SampleServer.
  4. On first connection, or after certificates were renewed, the server may have refused the client certificate. Check the server and client folder OPC Foundation\CertificateStores\RejectedCertificates for rejected certificates. To approve a certificate copy it to the OPC Foundation\CertificateStores\UA Applications folder.
  5. Retry step 3 to connect using a secure connection.

How to build and run the OPC UA COM Server Wrapper

  • Please refer to the OPC Foundation UA .Net Standard Library COM Server Wrapper for a detailed description how to run the OPC COM wrapper.

How to build and run the OPC UA Aggregation Client and Server

  • Please refer to the OPC Foundation UA .Net Standard Library Aggregation Client and Server for a detailed description how to run the aggregation client and server.

How to build and run the OPC UA Reference Server with UACTT

  • Please refer to the OPC Foundation UA .Net Standard Library Reference Server for a detailed description how to run the reference server against the UACTT.

How to build and run the OPC UA Web Telemetry sample

  • Go to the Azure portal and create a new Storage account.

  • Open the solution OpcUaWebTelemetry.sln with VisualStudio 2015.

  • Open the MessageProcessing\Configuration.cs file to configure the app to use your Azure resources (Storage account and IoTHub).

        // {StorageAccountName} is the name of the storage account and could be found 
        // under Settings->Access keys->Storage account name of your storage account on the Azure portal.
        // {AccessKey} is the access key of the storage account and could be found 
        // under Settings->Access keys->key1 of your storage account on the Azure portal.
        public static string StorageConnectionString = "DefaultEndpointsProtocol=https;AccountName={StorageAccountName};AccountKey={AccessKey}";

        // {ConsumerGroupName} is the name of a aonsumer group of your IoTHub. The IoTHub you use is the
        // one you have created for use with the OPC UA Publisher sample.
        // You need to create this consumer group via the messaging settings of your IoTHub in the Azure portal. 
        // We recommend that you do not share this Consumer group with other consumers, nor that you use the $Default consumer group. 
        public static string EventHubConsumerGroup = "{ConsumerGroupName}";

        // {EventHubEndpoint} is the Event Hub compatible endpoint of your IoTHub and could be found 
        // under Settings->Messaging->Event Hub-compatible endpoint of your IoTHub in the Azure portal.
        // {PrimaryKey} is the IoT Hub primary key for access with iothubowner policy and could be found
        // under Settings->Shared access policies->iothubowner->Primary key of your IoTHub in the Azure portal.  
        public static string EventHubConnectionString = "Endpoint={EventHubEndpoint};SharedAccessKeyName=iothubowner;{PrimaryKey}";

        // {HubName} is the Event Hub compatible name of your IoTHub and could be found 
        // under Settings->Messaging->Event Hub-compatible name of your IoTHub in the Azure portal.
        public static string EventHubName = "{HubName}";
  • Save the file, rebuild the solution and start it. This will start a local instance of the application.

  • The solution can also be deployed into a Azure App service. Please use VisualStudio 2015's Azure publishing functionality for this purpose.

  • Now run the OPC UA Publisher sample, connect to a OPC UA server and publish a node.

  • You should see the node value on the web page after a few seconds.

Contributing

We strongly encourage community participation and contribution to this project. First, please fork the repository and commit your changes there. Once happy with your changes you can generate a 'pull request'.

You must agree to the contributor license agreement before we can accept your changes. The CLA and "I AGREE" button is automatically displayed when you perform the pull request. You can preview CLA here.

ua-.netstandardlibrary's People

Contributors

barnstee avatar mregen avatar nathanpocock avatar marcschier avatar oscarreynhout avatar hansgschossmann avatar jonnybi avatar md-v avatar jh-isw avatar jtkech avatar mchwalt avatar

Watchers

James Cloos avatar Victor avatar

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.