使用 OPCDA.NET 工具远程访问 OPC 服务器

发布于 2024-11-07 07:12:30 字数 464 浏览 5 评论 0原文

我正在 Windows C# 中开发 OPC 客户端。我已经开发了代码并阅读 OPC 项目基于采样以及基于事件 (OnDataChange)。当我在 使用本地机器,那么我的代码也可以很好地使用采样 作为 OnDataChange,但是当我尝试从远程 OPC 服务器读取数据时 然后采样工作正常,但我无法获取基于事件的过程的数据。 我能够连接到 OPC 服务器,但是当我添加订阅时 然后我收到错误。

H结果:0x80040202。

       group1.DataChanged += new DataChangeEventHandler(this.DataChangeHandler);
               group1.AdviseIOPCDataCallback();//exception HRESULT : 0x80040202.

OPC 服务器已连接&然后也注册该组,但我在读取数据时遇到异常。

I am developing OPC Client in windows C#. I have developed the code and reading
OPC Items on Sampling as well as event based (OnDataChange). When I am
working with local machine then my code works fine with both Sampling as well
as OnDataChange, but when I am trying to read data from Remote OPC Server
then Sampling works fine but I am not able fetch data on event based process.
I am able to connect to the OPC Server but when i am adding subscription to
it then i am getting error.

HRESULT : 0x80040202.

       group1.DataChanged += new DataChangeEventHandler(this.DataChangeHandler);
               group1.AdviseIOPCDataCallback();//exception HRESULT : 0x80040202.

OPC server connected & then register the group also but i got the exception when reading data.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

不离久伴 2024-11-14 07:12:30

问题通常是,当您使用 Advise() 时,服务器将建立一个返回客户端的 DCOM 连接(标准 DC​​OM 连接点)。需要正确设置客户端以允许这种情况发生(即正确的安全设置以允许服务器在客户端上执行代码)。

您应该阅读此页面:http://www.softwaretoolbox.com/xpsp2/,它涵盖了关于如何正确设置 DCOM 以供 OPC 使用的大量建议。这里存在很多安全问题。 Software Toolbox 网站提供了大量精彩信息(还有视频)。如果您仍然无法使其正常工作,我建议您投资购买 OPC 隧道产品,该产品将允许您执行远程 OPC,而无需跳过所有 DCOM 循环。

您不必使用 OPCDA.NET 也会遇到同样的问题。您可以使用任何 OPC 客户端并首先使其与远程服务器一起工作,然后专注于弄清楚如何将其全部连接到 OPCDA.NET 中。我推荐 OPC Quick Client(附带 Software Toolbox TOP Server 演示)。

The issue usually is that when you use Advise(), the server will make a DCOM connection back to the client (standard DCOM connection points). The client needs to be set up properly to allow this to happen (i.e. the right security settings to allow the server to execute code on the client).

You should read this page: http://www.softwaretoolbox.com/xpsp2/, it covers a lot of recommendations on how to set up DCOM properly for OPC usage. There are a lot of security concerns here. The Software Toolbox site has a lot of great information (and videos too). If you are still having trouble getting it to work, I recommend investing in an OPC tunneling product that will allow you to do remote OPC without having to jump through all the DCOM loops.

You don't have to be using OPCDA.NET to have the same issue. You can use any OPC client and get it working first with your remote server, then focus on figuring out how to get it all hooked up in OPCDA.NET. I recommend OPC Quick Client (comes with Software Toolbox TOP Server demo).

故事灯 2024-11-14 07:12:30

您实际上遇到的问题是回调。换句话说,并不是建议调用让您失败,而是来自 OPC 服务器的回调(建议触发器)。此错误通常是由用户身份验证问题引起的(即两台计算机上的用户帐户不匹配)。检查远程计算机上 OPC 服务器的用户帐户。如果您的本地计算机上不存在该文件,那么您就发现了问题!

有一个自动化应用程序可以帮助您解决问题。我建议您下载 OPC Expert(Google 即可)。它是一个免费应用程序,不需要安装,并且不会更改 Windows 注册表。它救了我很多次。此外,供应商 (OPCTI) 非常有帮助,所以请检查一下。

The problem you are actually having is with the callback. In other words, it isn't the advise call that is failing you, it is the callback from the OPC server (which advise triggers). This error is usually caused by user authentication problems (i.e. the user accounts do not match on both computers). Check out the OPC server's user account on the remote computer. If it doesn't exist on your local computer, you found the problem!

There is an automated application to help you figure out your problem. I recommend you download OPC Expert (Google it). It is a free application, does not require installation, and does not change Windows Registry. It has saved me many times. Also, the vendor (OPCTI) is extremely helpful, so check them out.

岁吢 2024-11-14 07:12:30

这个问题是因为当您连接到服务器时,您可能会使用第一个连接函数,即 server.connect();

相反,请尝试:

server.connect(new Opc.ConnectData(new System.Net.NetworkCredential()));

这对我有用。希望它有帮助:)

That problem is because when you connect to the server, you might use the first connect function, which is server.connect();

Instead, try:

server.connect(new Opc.ConnectData(new System.Net.NetworkCredential()));

This works for me. Hope it helps:)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文