Esempio n. 1
0
 protected override void WriteRealTimeSignal()
 {
     try {
         if (outputThreadRun)
         {
             return;
         }
         outputThreadRun = true;
         OPCAdress adress = (OPCAdress)startOutputsAdress;
         while (connectFlag && outputThreadRun)
         {
             int[] temp = new int[2] {
                 0, opcGroup.OPCItems.Item(adress.signalID).ServerHandle
             };
             Array    serverHandles = (Array)temp;
             Array    Errors;
             object[] valueTemp = new object[2] {
                 "", SynOutputs
             };
             Array values = (Array)valueTemp;
             opcGroup.SyncWrite(1, ref serverHandles, ref values, out Errors);//同步写
             Thread.Sleep(100);
         }
     }
     catch (Exception) {
         outputThreadRun = false;
     }
 }
Esempio n. 2
0
        public void ReadAressFile(string filePath)
        {
            string path = System.Environment.CurrentDirectory;

            path = filePath + "\\OPCAdress";
            if (!File.Exists(path))
            {
                throw new Exception("配置文件不存在!");
            }
            using (StreamReader sr = new StreamReader(path)) {
                var line = sr.ReadLine();
                while (line != null)
                {
                    line = sr.ReadLine();
                    string[] strs = line.Split(',');
                    if (strs[0] != "No" && strs[0] != string.Empty)
                    {
                        if (strs[(int)eOPCAdressTitle.IsInput].Trim(' ') == "1")
                        {
                            OPCAdress adress = new OPCAdress();
                            adress.signalID = strs[(int)eOPCAdressTitle.AdressID];
                            AdressValueInfo valueInfo = new AdressValueInfo()
                            {
                                adress      = adress,
                                deviceValue = new OPCValue(),
                                valueType   = GetAdressType(strs[(int)eOPCAdressTitle.AdressType]),
                            };
                            this.AddInputSignal(strs[(int)eOPCAdressTitle.AdressName], valueInfo);
                        }
                        if (strs[(int)eOPCAdressTitle.IsOutput].Trim(' ') == "1")
                        {
                            OPCAdress adress = new OPCAdress();
                            adress.signalID = strs[(int)eOPCAdressTitle.AdressID];
                            AdressValueInfo valueInfo = new AdressValueInfo()
                            {
                                adress      = adress,
                                deviceValue = new OPCValue(),
                                valueType   = GetAdressType(strs[(int)eOPCAdressTitle.AdressType]),
                            };
                            this.AddOutputSignal(strs[(int)eOPCAdressTitle.AdressName], valueInfo);
                        }
                    }
                }
            }
        }
Esempio n. 3
0
 protected override void ReadRealTimeSignal()
 {
     try {
         if (inputThreadRun)
         {
             return;
         }
         inputThreadRun = true;
         while (connectFlag && inputThreadRun)
         {
             OPCAdress adress  = (OPCAdress)startInputsAdress;
             OPCItem   opcItem = opcGroup.OPCItems.Item(adress.signalID);
             SynInputs = opcItem.Value;
             Thread.Sleep(100);
         }
     }
     catch (Exception) {
         inputThreadRun = false;
     }
 }