.net OPC 新手指南:如何编写 C# Hello World 客户端?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18275449/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Noob guide to OPC: how to write a C# Hello World client?
提问by sergio
here is my situation:
这是我的情况:
We have a software that is used to monitor solar power plants developed. I have to introduce OPC as a new way to acquire data from the physical devices themselves, so thats why i ended up trying to learn about opc, which so far is being frustrating.
我们开发了一款用于监控太阳能发电厂的软件。我必须介绍 OPC 作为一种从物理设备本身获取数据的新方法,所以这就是为什么我最终尝试了解 opc,到目前为止这令人沮丧。
I have installed the Matrikon simulator and using the Matrikon explorer i can see that data is being simulated. what i need now is to create a very basic proof of concept that i can connect to it and print something using C#. As i understand it, i have to use some proprietary API/SDK. Im only testing things so i dont want to commit to a proprietary way to do things right now. Wasnt OPC created to exactly avoid that?
我已经安装了 Matrikon 模拟器并使用 Matrikon 资源管理器我可以看到正在模拟数据。我现在需要的是创建一个非常基本的概念证明,我可以连接到它并使用 C# 打印一些东西。据我了解,我必须使用一些专有的 API/SDK。我只是在测试东西,所以我现在不想承诺以专有的方式做事。OPC 不是为了完全避免这种情况而创建的吗?
Is there a simple Opensource DLL that i can use to connect to the OPC server, that supports DA, HDA and AE, allowing me to work without worrying about vendors/sdks?
是否有一个简单的开源 DLL 可以用来连接到支持 DA、HDA 和 AE 的 OPC 服务器,让我可以工作而不必担心供应商/sdks?
To add to the confusion i have found OPC Xi and OPC UA.... and i havent found a tutorial from gound zero up, which is what im looking for.
更令人困惑的是,我发现了 OPC Xi 和 OPC UA .... 我还没有找到从零开始的教程,这正是我要找的。
采纳答案by Camille G.
First you need to know which OPC you want to use.
首先,您需要知道要使用哪个 OPC。
- "Classical OPC" DA/HDA and A&E based on Windows COM/DCOM
- OPC XML/DA, DA as a web service but with some limited perfomance.
- OPC UA, the last specification allowing you to implement it on non Windows platform and merging DA, HDA and A&E.
- 基于 Windows COM/DCOM 的“经典 OPC”DA/HDA 和 A&E
- OPC XML/DA、DA 作为 Web 服务但性能有限。
- OPC UA,最后一个允许您在非 Windows 平台上实现它并合并 DA、HDA 和 A&E 的规范。
After that, you could choose the language you want to use and so use some SDK free or not.
之后,您可以选择要使用的语言,因此是否免费使用某些 SDK。
One good website for OPC : http://www.opcconnect.com/source.phphas lists of Toolkits you could use.
一个很好的 OPC 网站:http: //www.opcconnect.com/source.php有您可以使用的工具包列表。
回答by Andrew Cullen
I recommend you use the newest flavor of OPC, OPC UA.
我建议您使用最新的 OPC 版本,即 OPC UA。
You can build a simple HMI app in C# using these free tools:
您可以使用以下免费工具在 C# 中构建一个简单的 HMI 应用程序:
1.Microsoft Visual Studio Express 2013 for Windows Desktop available from: http://www.microsoft.com/visualstudio/eng/products/visual-studio-express-for-windows-desktop.
1.适用于 Windows 桌面的 Microsoft Visual Studio Express 2013 可从以下网址获得:http: //www.microsoft.com/visualstudio/eng/products/visual-studio-express-for-windows-desktop。
2.The latest source from this site: https://github.com/convertersystems/opc-ua-samples
2.本站最新源码:https: //github.com/convertersystems/opc-ua-samples
With this kit you can: Browse OPC UA servers directly from the Visual Studio IDE. Drag and drop the variable nodes to create a data subscription. Use bindings to animate your UI control's properties from the subscription's data values.
使用此工具包,您可以: 直接从 Visual Studio IDE 浏览 OPC UA 服务器。拖放变量节点以创建数据订阅。使用绑定根据订阅的数据值为 UI 控件的属性设置动画。
Check out the sample application 'Workstation'.
查看示例应用程序“工作站”。
回答by AnyOneElse
Providing you with a tutorial... but a little bit of information first:
为您提供教程...但首先提供一些信息:
OPC is everything but open (in an open source way)... the OPC foundation has specified a lot of things to standardize the way automation can communicate - on top of which you could build your own stack. Be warned, the stuf is HUGE(!). So to ease the workload a little, there is a hand full of companies providing you with stacks for different programming languages. Matrikon, Prosys, Unified Automation to name some of them.
OPC 是一切,但不是开放的(以开源方式)...... OPC 基金会已经指定了很多东西来标准化自动化可以通信的方式 - 您可以在其上构建自己的堆栈。请注意,这些东西是巨大的(!)。因此,为了稍微减轻工作量,有很多公司为您提供不同编程语言的堆栈。Matrikon、Prosys、Unified Automation 等等。
However to connect to a demoserver you need to implement a provider and do still need a stack providing you with the basic functionality and to download such a stack, your company must register with the supplier. There is no way round I'm afraid. However there were OpenSource projects: http://www.openopcua.org/never tried the code though.
然而,要连接到演示服务器,您需要实现一个提供程序,并且仍然需要一个为您提供基本功能的堆栈,并且要下载这样的堆栈,您的公司必须向供应商注册。恐怕没有办法了。然而,有一些开源项目:http: //www.openopcua.org/虽然从未尝试过代码。
BUT just to prove the usefulness check this tutorial http://doc.unifiedautomation.com/
但只是为了证明有用性检查本教程http://doc.unifiedautomation.com/
And a book written by the company owner of UA (maybe your company has "Springerlink" access?) http://www.springer.com/computer/information+systems+and+applications/book/978-3-540-68898-3
还有一本UA公司老板写的书(也许你的公司有“Springerlink”权限?) http://www.springer.com/computer/information+systems+and+applications/book/978-3-540-68898 -3
回答by Michel4CE
I suggest you to look at the OpenOpcUa initiative. The full code for OPC UA client and server is available for download. This code run Windows, Linux and WVWorks. more information at www.openopcua.org
我建议您查看 OpenOpcUa 计划。OPC UA 客户端和服务器的完整代码可供下载。此代码运行 Windows、Linux 和 WVWorks。更多信息请访问 www.openopcua.org
回答by Corey
You can download all OPC materials from OPC Foundation, specifically you are looking for the OPC .NET API 2.00 Source Code Download Link. It contains a solution that has the OPC dlls and sample clients (AE, DA, DX, HDA) to give you an idea of how OPC works. This source and DLLs are the basis for the OPC standards. Using these you can call to any proprietary OPC server that is compliant with the OPC standards.
您可以从OPC Foundation下载所有 OPC 材料,特别是您正在寻找 OPC .NET API 2.00 源代码下载链接。它包含一个具有 OPC dll 和示例客户端(AE、DA、DX、HDA)的解决方案,让您了解 OPC 的工作原理。此源和 DLL 是 OPC 标准的基础。使用这些,您可以调用任何符合 OPC 标准的专有 OPC 服务器。

