【问题标题】:Iconics Simulator OPC Serve and C#Iconics Simulator OPC 服务和 C#
【发布时间】:2014-06-13 05:42:43
【问题描述】:

我正在通过“OPC DA Automation Wrapper 2.02”开发用于 OPC 访问的 C# 应用程序

为了在我的 WIN8 机器上进行测试,我使用的是“Iconics Simulator OPC Server 3.12”

我在服务器上配置了 4 个不同名称的布尔 OPCItem。

连接,读取 OPCItems 工作正常。

但是: 如果我写其中一个,监视器(OPC DataSpy 9.01)和其他工具显示所有 OPCItems 都已更改。更改事件出现在所有 OPCItems

为了检查这种行为,我使用 VisualBasic 6 编写了相同的应用程序 - 结果相同!

出了什么问题,我的代码还是模拟器服务器?

using System;
using System.Windows.Forms;
using OPCAutomation;

namespace opc {
public partial class Form1 : Form {

    OPCGroups opcGroups;
    OPCGroup opcGroup;

    bool aliveToggle;
    Timer aliveTimer;

    public Form1() {
        InitializeComponent();

        OPCServer opcServer = new OPCServer();
        opcServer.Connect("Iconics.SimulatorOPCDA.2");
        opcGroup = opcServer.OPCGroups.Add("Gruppe1");

        opcGroup.OPCItems.AddItem("BOOL_1", 1);
        opcGroup.OPCItems.AddItem("BOOL_2", 2);
        opcGroup.OPCItems.AddItem("BOOL_3", 3);
        opcGroup.OPCItems.AddItem("BOOL_4", 4);

        opcGroup.UpdateRate     = 10;
        opcGroup.IsActive       = true;
        opcGroup.IsSubscribed   = true;

        aliveTimer = new Timer();
        aliveTimer.Tick += new EventHandler(sendAlive);
        aliveTimer.Interval=1000;
        aliveTimer.Start();

        }

    private void sendAlive(object sender, EventArgs e) {
        aliveToggle=!aliveToggle;
        opcGroup.OPCItems.Item(2).Write(aliveToggle);
        }
    }
}

【问题讨论】:

  • 你应该在其他服务器上尝试,例如Prosys OPC Simulation Server。我他们都失败了,问题出在你的代码中。我无法从您的代码中发现任何问题。
  • 感谢您的参与。我尝试过使用 WinTech 的 WTOPCSvr - 没有问题。所以我认为“Iconics Simulator”配置一定有问题......

标签: c# simulator opc


【解决方案1】:

简单的解决方法是每当添加一个需要独立通知事件的标记时,它应该有自己的组,因为不幸的是,更改事件是基于组而不是基于标记触发的。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-06-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多