private void ReadConfig() { PLC.Connect("OPC.SimaticNET", "127.0.0.1"); //配置 string[] items = null; //switch (Duty) //{ // case "E": items = new string[plcCount]; for (int i = 0; i < plcCount; i++) { items[i] = plcConnection[i] + string.Format("DB{0},W{1}", 1, 30); } PLC.AddGroup("Cfg", 1, 0); PLC.AddItems("Cfg", items); PLC.Read("Cfg"); // break; //case "M": items = new string[plcCount]; for (int i = 0; i < plcCount; i++) { items[i] = plcConnection[i] + "DB1,W32"; } PLC.AddGroup("Cfg-DataItem", 1, 0); PLC.AddItems("Cfg-DataItem", items); PLC.Read("Cfg-DataItem"); }
internal protected virtual bool Connect(string OPCServerIP) { bool success = true; success &= PLC.Connect("OPC.SimaticNET", OPCServerIP); success &= PLC.AddGroup(GROUP_NAME_CTRL, 1, 0); success &= PLC.AddItems(GROUP_NAME_CTRL, ItemCtrl); success &= PLC.AddGroup(GROUP_NAME_STATE, 1, 0); success &= PLC.AddItems(GROUP_NAME_STATE, ItemStatus); PLC.SetState(GROUP_NAME_STATE, true); ConnectionState = (success) ? (ConnectionState.Open) : (ConnectionState.Closed); return(success); }