private void wndParam_Click(object sender, EventArgs e) { FrmParam frm = new FrmParam(); frm.ShowDialog(); }
public void Start() { if (!RelayServer.GetInstance().CanStart()) { return; } //表集合 DataSet ds = FrmParam.ReadDataSet(); //串口 DataTable tableSerial = ds.Tables[FrmParam.s_GridSerial]; DataTable tableServer = ds.Tables[FrmParam.s_GridServer]; DataTable tableClient = ds.Tables[FrmParam.s_GridClient]; DataTable tableRelay = ds.Tables[FrmParam.s_GridRelay]; if (tableSerial != null) { foreach (DataRow dr in tableSerial.Rows) { SerialRow sr = new SerialRow(dr); if (sr.select) { SerialPort sp = new SerialPort("COM" + sr.port, sr.baud, (Parity)sr.parity); IoSerial serial = new IoSerial(sr.id, sp, this); RelayServer.GetInstance().AddHeader(serial); } } } if (tableServer != null) { foreach (DataRow dr in tableServer.Rows) { ServerRow sr = new ServerRow(dr); if (sr.select) { IoServer server = new IoServer(sr.id, sr.ip, sr.port, this); RelayServer.GetInstance().AddHeader(server); } } } if (tableClient != null) { foreach (DataRow dr in tableClient.Rows) { ClientRow sr = new ClientRow(dr); if (sr.select) { IoClient client = new IoClient(sr.id, sr.ip, sr.port, this); RelayServer.GetInstance().AddHeader(client); } } } if (tableRelay != null) { foreach (DataRow dr in tableRelay.Rows) { RelayRow sr = new RelayRow(dr); if (sr.select) { RelayServer.GetInstance().AddRelay(sr.id1, sr.id2); } } } RelayServer.GetInstance().Start(); }