public OpcController(OpcConfig config) { timer.Interval = 5 * 1000; timer.Elapsed += Timer_Elapsed; Config = config; opcClient = new OpcDaClient(x => { x.ProgId = config.ProgId; x.Tags = config.Items.Select(xx => new OpcTagItem() { Id = xx.Id, ItemId = xx.ItemId, Misc = xx.Misc }).ToArray(); x.DefaultGroupUpdateRate = 100; }) { Shutdown = (s, client) => { if (NetStatus) { NetStatus = false; NetChangedAction?.Invoke(this, false); } Log.Warning("OPC Shutdown,{s}", s); }, DataChange = OpcDataChanged }; }
public IOpcController CreateOpcDevice(OpcConfig config) { if (config == null) { throw new ArgumentNullException("OpcConfig参数不能为null"); } IOpcController opc = new OpcController(config); return(opc); }