public static void InitPLCS() { docPlc = PLCDriverDoc.LoadObj(); dicDrivers = new Dictionary <string, PLCBaseClass>(); foreach (KeyValuePair <string, PLCDriverInfo> posInfoPair in docPlc.dicPlcInfo) { if (posInfoPair.Value.plcType == PLCType.Panasonic) { dicDrivers.Add(posInfoPair.Key, new PLCPanasonicClass()); dicDrivers[posInfoPair.Key].Init(posInfoPair.Value.PortName, posInfoPair.Value.BaudRate, posInfoPair.Value.Parity, posInfoPair.Value.DataBits, posInfoPair.Value.StopBits); } if (posInfoPair.Value.plcType == PLCType.Omron) { dicDrivers.Add(posInfoPair.Key, new PLCOmronClass()); dicDrivers[posInfoPair.Key].Init(posInfoPair.Value.PortName, posInfoPair.Value.BaudRate, posInfoPair.Value.Parity, posInfoPair.Value.DataBits, posInfoPair.Value.StopBits); } } PLCControlManageClass.StartScan(); }
internal static PLCDriverDoc LoadObj() { PLCDriverDoc pDoc; BinaryFormatter fmt = new BinaryFormatter(); FileStream fsReader = null; try { fsReader = File.OpenRead(@".//Parameter/PLC/PlcDoc.dat"); pDoc = (PLCDriverDoc)fmt.Deserialize(fsReader); fsReader.Close(); } catch //(Exception eMy) { //MessageBox.Show(eMy.ToString()); if (fsReader != null) { fsReader.Close(); } pDoc = new PLCDriverDoc(); } return(pDoc); }
public static void LoadData() { docPlc = PLCDriverDoc.LoadObj(); }