using System; using System.Collections.Generic; using System.Linq; using System.Text; using OPCPLC; using System.Configuration; namespace EQUIPINTERFACETEST { public class ColorDistinguishTest { public void Test() { OPCPLCAutomation gtxConnection = new OPCPLC.OPCPLCAutomation(); //opcServer服务器IP string opcServerIP = ConfigurationManager.AppSettings.Get("OPCServerIP"); //opcServer服务名称 string opcServerName = ConfigurationManager.AppSettings.Get("OPCServerName"); gtxConnection.GetListOPCServers("127.0.0.1"); //连接Opc服务 gtxConnection.ConnectRemoteServer(opcServerName, "127.0.0.1"); gtxConnection.CreateGroup("GetData"); int a = gtxConnection.AddKepItem("Channel1.Device1.ColorTag1", 1); int b = gtxConnection.AddKepItem("Channel1.Device1.ColorTag2", 2); var result = gtxConnection.ReadtagValue(a); var result2 = gtxConnection.ReadtagValue(b); Console.WriteLine(result.ToString()); Console.WriteLine(result2.ToString()); } } }