如何使用C#使用opcdaauto.dll连接远程OPC服务器?

时间:2014-02-19 08:24:06

标签: c#-4.0 opc

使用的DLL:来自OPC Foundation的opcdaauto.dll

        OPCServer ObjOPCServer;
        OPCGroups ObjOPCGroups;
        OPCGroup ObjOPCGroup;

        ObjOPCServer = new OPCServer();
        string _serverName = "Kepware.KEPServerEX.V5";

        //In place of "", I need to give IP address of machine where OPC Server is present
        ObjOPCServer.Connect(_serverName, ""); 

然后我也无法沟通。任何帮助高度赞赏。

提前致谢

1 个答案:

答案 0 :(得分:2)

            OPCServer ObjOPCServer = new OPCServer();
            OPCGroups ObjOPCGroups;
            OPCGroup ObjOPCGroup;
            //string _serverName = "Kepware.KEPServerEX.V5";
            string _serverName = "Matrikon.OPC.OMRON.1";

            ObjOPCServer.Connect(_serverName, "192.168.0.110");
            ObjOPCGroups = ObjOPCServer.OPCGroups;

            ObjOPCGroup = ObjOPCGroups.Add("Group1");
            ObjOPCGroup.DataChange += new DIOPCGroupEvent_DataChangeEventHandler(ObjOPCGroup_DataChange);
            ObjOPCGroup.OPCItems.AddItem("#MonitorACLFile", 1);

            //ObjOPCGroup.OPCItems.AddItem("Channel1.Device1.Tag2", 2);
            ObjOPCGroup.UpdateRate = 1000;
            ObjOPCGroup.IsActive = true;
            ObjOPCGroup.IsSubscribed = true;

参考:http://revanayya.blogspot.in/2013/12/opcclient-development-using-observer.html