{"id":13766557,"url":"https://github.com/hylasoft-usa/h-opc","last_synced_at":"2025-05-10T22:31:13.623Z","repository":{"id":26291935,"uuid":"29739673","full_name":"hylasoft-usa/h-opc","owner":"hylasoft-usa","description":"OPC client made simpler, for UA and DA","archived":false,"fork":false,"pushed_at":"2020-01-23T14:29:43.000Z","size":7397,"stargazers_count":305,"open_issues_count":40,"forks_count":147,"subscribers_count":49,"default_branch":"master","last_synced_at":"2025-04-18T01:01:06.179Z","etag":null,"topics":["c-sharp","client","monitoring","opc"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hylasoft-usa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-01-23T15:48:20.000Z","updated_at":"2025-04-16T08:47:21.000Z","dependencies_parsed_at":"2022-07-21T08:32:19.804Z","dependency_job_id":null,"html_url":"https://github.com/hylasoft-usa/h-opc","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hylasoft-usa%2Fh-opc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hylasoft-usa%2Fh-opc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hylasoft-usa%2Fh-opc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hylasoft-usa%2Fh-opc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hylasoft-usa","download_url":"https://codeload.github.com/hylasoft-usa/h-opc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253492529,"owners_count":21916959,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c-sharp","client","monitoring","opc"],"created_at":"2024-08-03T16:00:57.294Z","updated_at":"2025-05-10T22:31:12.683Z","avatar_url":"https://github.com/hylasoft-usa.png","language":"C#","funding_links":[],"categories":["Software"],"sub_categories":["SDKs and Libraries"],"readme":"h-opc [![Build status](https://ci.appveyor.com/api/projects/status/oajkgccisoe98gip?svg=true)](https://ci.appveyor.com/project/Hyla-Soft-Inc/h-opc) [![NuGet Status](http://img.shields.io/nuget/v/H.Opc.svg)](https://www.nuget.org/packages/H.Opc) [![Coverage Status](https://coveralls.io/repos/github/jmbeach/h-opc/badge.svg?branch=master)](https://coveralls.io/github/jmbeach/h-opc?branch=master)\n==============\n\nAn Opc Library and a command line to perform OPC operations with ease and transparency among different protocols. Currently supports synchronous operation over UA and DA protocols.\n\n## Table of Contents\n* [Use](#use)\n* [Documentation](#documentation)\n  * [Exploring the nodes](#exploring-the-nodes)\n  * [Read a node](#read-a-node)\n  * [Writing to a node](#writing-to-a-node)\n  * [Monitoring a tag](#monitoring-a-tag)\n  * [Go Asynchronous!](#go-asynchronous)\n* [Command line](#command-line)\n* [Build + Contribute](#build--contribute)\n  * [Unit Testing](#unit-testing)\n    * [UA](#ua)\n    * [DA](#da)\n* [Disclaimer](#disclaimer)\n* [Roadmap](#roadmap)\n\n\n## Use\n\nA [nuget package](https://www.nuget.org/packages/H.Opc/) is available for the library. To install `H.Opc`, run the following command in the Package Manager Console:\n\n    PM\u003e Install-Package H.Opc\n\n*NOTE: Package was moved on NuGet.org from Hylasoft.Opc to H.Opc because of NuGet account issues*\n\nTo install the command line interface, head to the [`release section`](https://github.com/hylasoft-usa/h-opc/releases).\n\n## Documentation\n\nto use the UA Client simply...\n\n````cs\nusing (var client = new UaClient(new Uri(\"opc.tcp://host-url\")))\n{\n  client.Connect();\n  // Use `client` here\n}\n````\n\nor with options...\n\n````cs\nvar options = new UaClientOptions {\n  UserIdentity = new Opc.Ua.UserIdentity(\"\u003cyour-username\u003e\", \"\u003cyour-password\u003e\")\n};\nusing (var client = new UaClient(new Uri(\"opc.tcp://host-url\")), options)\n{\n  client.Connect();\n  // Use `client` here\n}\n````\n\n\nand to use the DA Client instead:\n\n````cs\nusing (var client = new DaClient(new Uri(\"opcda://host-url\")))\n{\n  client.Connect();\n  // Use `client` here\n}\n````\n\n#### Exploring the nodes\n\nYou can get a reference to a node with...\n\n````cs\nvar node = client.FindNode(\"path.to.my.node\");\n````\n\nThis will get you a reference to the node `node` in the folder `path.to.my`.\n\nYou can use the node reference to explore the hieriarchy of nodes with the properties `Parent` and `SubNodes`. For example...\n\n````cs\nNode parentNode = node.Parent;\nIEnumerable\u003cNode\u003e children = client.ExploreFolder(node.Tag);\nIENumerable\u003cNode\u003e grandChildren = children.SelectMany(m =\u003e client.ExploreFolder(m.Tag));\n````\n\n#### Read a node\n\nReading a variable? As simple as...\n\n````cs\nvar myString = client.Read\u003cstring\u003e(\"path.to.string\").Value;\nvar myInt = client.Read\u003cint\u003e(\"path.to.num\").Value;\n````\n\nThe example above will read a string from the tags `string` and `num` in the folder `path.to`\n\n#### Writing to a node\n\nTo write a value just...\n\n````cs\nclient.Write(\"path.to.string\", \"My new value\");\nclient.Write(\"path.to.num\", 42);\n````\n\n#### Monitoring a tag\n\nDead-simple monitoring:\n\n````cs\nclient.Monitor\u003cstring\u003e(\"path.to.string\", (readEvent, unsubscribe) =\u003e\n{\n  DoSomethingWithYourValue(readEvent.Value);\n  if(ThatsEnough == true)\n    unsubscribe();\n});\n\n````\n\nThe second parameter is an `Action\u003cT, Action\u003e` that has two parameter:\n\n- `readEvent` contains all the information relevant to the event such as timestamps, quality and the value\n- `unsubscribe` is a function that unsubscribes the current monitored item. It's very handy when you want to terminate your callback\n\nit's **important** that you either enclose the client into a `using` statement or call `Dispose()` when you are finished, to unsubscribe all the monitored items and terminate the connection!\n\n### Go Asynchronous!\n\nEach method as an asynchornous counterpart that can be used with the async/await syntax. The asynchronous syntax is **recommended** over the synchronous one (maybe the synchronous one will be deprecated one day).\n\n## Command line\n\nYou can also use the command line interface project to quickly test your an OPC. Build the `h-opc-cli` project or download it from the `release` page of this repository, then run:\n\n````\nh-opc-cli.exe [OpcType] [server-url]\n````\n\nWhere `OpcType` is the type of opc to use (e.g: \"UA\", \"DA\"). Once the project is running, you can use the internal command to manipulate the variable. To have more information aboute the internal commands, type `help` or `?`\n\n## Build + Contribute\n\nThe repository uses [cs-boilerplate](https://github.com/hylasoft-usa/cs-boilerplate). Read the readme of the cs-boilerplate repository to understand how to build, run tasks and commit your work to `master`.\n\n### Unit Testing\n\n+ The unit tests rely on locally running simulator OPC servers. The ones used in this project are [OPC Foundation's Sample Server](https://opcfoundation.org/developer-tools/developer-kits-unified-architecture/sample-applications)\nand [Graybox Simulator](http://gray-box.net/download_graysim.php?lang=en)\n  + You must download OPC Foundation's Sample Server from the OPC Foundation website (link above), but GrayBox can be downloaded using [Chocolatey](https://chocolatey.org/)\n    + `choco install grayboxsimulator`\n  + OPC Foundation's Sample Server requires you register with the website before you can download.\n+ The tests use [NUnit](https://github.com/nunit/nunit). To run them in Visual Studio, install the [NUnit 3 Test Adapter](https://marketplace.visualstudio.com/items?itemName=NUnitDevelopers.NUnit3TestAdapter)\n+ To configure the test project, run the `configure.ps1` script in the root h-opc directory\n\n#### UA\n+ Open OPC Foundation's Sample Client (under Start -\u003e OPC Foundation -\u003e UA x.xx -\u003e Sample Applications -\u003e Opc.Ua.SampleClient.exe)\n  + This will start the server too\n  + Running tests will only work with this program open\n\n#### DA\n+ With Graybox Simulator installed, tests should automatically work\n\n## Disclaimer\n\nThe following binaries belong to the [OPC Foundation](https://opcfoundation.org/). You must become a registered user in order to use them:\n\n- `OPC.Ua.Client.dll`\n- `OPC.Ua.Core.dll`\n- `OPC.Ua.Configuration.dll`\n- `OpcComRcw.dll`\n- `OpcNetApi.Com.dll`\n- `OpcNetApi.dll`\n\nYou must agree to the terms and condition exposed on the OPC Foundation website. Hyla Soft is not responsible of their usage and cannot be held responsible.\n\n## Roadmap\n\n- [ ] Add promise-based asynchronous calls\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhylasoft-usa%2Fh-opc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhylasoft-usa%2Fh-opc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhylasoft-usa%2Fh-opc/lists"}