private void ActualizaTabla(easyportcnf epcnf) { bool reemplazo = false; for (int i = 0; i < port_cnf.Rows.Count; i++) { if (String.Equals(port_cnf.Rows[i]["portName"].ToString(), epcnf.PortName)) { port_cnf.Rows[i]["bps"] = epcnf.BaudRate; port_cnf.Rows[i]["bitslen"] = epcnf.dataBits; port_cnf.Rows[i]["parity"] = epcnf.parity; port_cnf.Rows[i]["stop"] = epcnf.stopbits; port_cnf.Rows[i]["hs"] = epcnf.handshake; port_cnf.Rows[i]["read_t"] = epcnf.readtimeout; port_cnf.Rows[i]["write_t"] = epcnf.writetimeout; reemplazo = true; } } if (!reemplazo) { //esto deberia ser un falso positivo pero igual lo pongo por si las moscas port_cnf.Rows.Add(epcnf.PortName, epcnf.BaudRate, epcnf.dataBits, epcnf.parity, epcnf.stopbits, epcnf.handshake, epcnf.readtimeout, epcnf.writetimeout); } //Actualizar archivo de configuracion //eliminar archivo (Se supone ya esta cargado) string cFile = Environment.CurrentDirectory + "\\portconfig.xml"; System.IO.File.Delete(cFile); port_cnf.WriteXml(cFile); }
public easyPort(int xid, easyportcnf cnf) { id = xid; timerTabla.Interval = Convert.ToInt32(Properties.Settings.Default.tiempo); timerTabla.Tick += new EventHandler(LeerTabla); pbw.DoWork += new DoWorkEventHandler(miBw_DoWork); pbw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(miBw_WorkComplete); portName = cnf.PortName; baudrate = cnf.BaudRate; mycnf = cnf; this.resetPort(); }
void leeSeriales() { MisPuertos = new List <easyPort>(); string[] ps_Names = SerialPort.GetPortNames(); int i = 0; foreach (string nm in ps_Names) { Object[] dr = BuscaConfi(nm); easyportcnf confi = new easyportcnf((string)dr[0], (int)dr[1], (int)dr[2], (Parity)dr[3], (StopBits)dr[4], (Handshake)dr[5], (int)dr[6], (int)dr[7]); easyPort pA = new easyPort(i, confi); pA.Actualizar += new easyPort.ActualizarEventHandler(unPuertoLee); MisPuertos.Add(pA); i += 1; } ActualizaGRID(); }