public bool InitOPC(Action <string, eOutputType> output) { OutPut = output; try { opcClient.OnDataReveiced += new OPCClient.DataReveiced(opcClient_OnDataReveiced); opcClient.OnScanError += new OPCClient.ScanErrorEventHandler(opcClient_OnScanError); //连接OPC if (opcClient.Connect(this.ServerName, this.ServerIP)) { //创建组 opcClient.CreateGroup(Tags); //开始读数 opcClient.Read(); return(true); } return(false); } catch (Exception ex) { output(string.Format("OPC服务" + ServerName + "初始化异常:{0}", ex.Message), eOutputType.Error); } return(false); }
public string Read(string name) { string result = "null"; if (Connected) { result = OPC.Read(name); } return(result); }