public Input Clone() { InputSerial input = new InputSerial() { PortName = this.PortName, BaudRate = this.BaudRate, DataBits = this.DataBits, Parity = this.Parity, StopBits = this.StopBits, Handshake = this.Handshake, ReadBufferSize = this.ReadBufferSize, ReadTimeout = this.ReadTimeout, Dtr = this.Dtr, Rts = this.Rts, Title = this.Title, InputType = this.InputType, IsUsed = this.IsUsed, SymbolSplitter = this.SymbolSplitter, IDSlave = this.IDSlave }; foreach (DataParam dp in this.ListDataParams) { input.ListDataParams.Add(dp.Clone()); } foreach (DataParamOutput dp in this.ListDataParamsOut) { input.ListDataParamsOut.Add(dp.Clone()); } return(input); }
/* private static void ReadOutput() { * int countOutput = 0; * while (true) { * if (File.Exists(EnvPath + "toOutput" + countOutput + ".dat")) { * countOutput++; * } else { * break; * } * } * string[] data = new string[countOutput]; * for (int i = 0; i < countOutput; i++) { * data[i] = Service.WorkFile.Do(EnvPath + "toOutput" + i.ToString() + ".dat", Service.WorkFileMode.ReadAllText).ToString(); * Service.WorkFile.DeleteFile(EnvPath + "toOutput" + i.ToString() + ".dat"); * } * titleDB = Service.WorkFile.Do(EnvPath + "outputTitle.dat", Service.WorkFileMode.ReadAllText).ToString(); * Service.WorkFile.DeleteFile(EnvPath + "outputTitle.dat"); * dbConn = new SQLiteConnection("Data Source=" + EnvPath + titleDB + ".sqlite;Version=3;"); * dbConn.Open(); * sqlCmd.Connection = dbConn; * UpdateOutputs(data); * }*/ public static void UpdateOutputs(string[] data) { StopPorts(); Inputs = new ObservableCollection <InputM>(); for (int i = 0; i < data.Length; i++) { JObject json = JObject.Parse(data[i]); if (json.Property("PortName") != null) { Service.InputSerial input = JsonConvert.DeserializeObject <Service.InputSerial>(data[i]); Inputs.Add(new InputM { Input = input }); } else { Service.InputEthernet input = JsonConvert.DeserializeObject <Service.InputEthernet>(data[i]); Inputs.Add(new InputM { Input = input }); } } StartPorts(); }