コード例 #1
0
 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();
 }
コード例 #2
0
        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);
        }
コード例 #3
0
 public static void LoadData()
 {
     docPlc = PLCDriverDoc.LoadObj();
 }