public virtual void loadTC_AndBuildManaer() { try { manager = new TC_Manager(); SqlDataReader rd; SqlConnection cn = new SqlConnection(SQL.SQL.dbConnectionStr); rd = SQL.SQL.getDeviceConfigReader(cn, this.mfccid); // Comm.TCBase tc=null; while (rd.Read()) { string devtype = rd[8].ToString(); try { this.AddDevice(rd[0].ToString()); } catch (Exception ex) { ConsoleServer.WriteLine(ex.Message + ex.StackTrace); } } rd.Close(); cn.Close(); } catch (Exception ex) { ConsoleServer.WriteLine(ex.Message+ex.StackTrace); } }
public virtual void loadTC_AndBuildManaer() { try { manager = new TC_Manager(); System.Data.Odbc.OdbcDataReader rd; System.Data.Odbc.OdbcConnection cn = new System.Data.Odbc.OdbcConnection(Comm.DB2.Db2.db2ConnectionStr); rd = Comm.DB2.Db2.getDeviceConfigReader(cn, this.mfccid); // Comm.TCBase tc=null; while (rd.Read()) { try { this.AddDevice(rd[0].ToString()); } catch (Exception ex) { ConsoleServer.WriteLine(ex.Message + ex.StackTrace); } /* byte[] hw_status = new byte[4]; byte opmode, opstatus; for (int i = 0; i < 4; i++) hw_status[i] = System.Convert.ToByte(rd[3 + i]); opmode=System.Convert.ToByte(rd[7]); opstatus=System.Convert.ToByte(rd[8]); if (this.devType == "VD") { tc = new Comm.TC.VDTC(protocol, rd[0].ToString().Trim(), rd[1].ToString(), (int)rd[2], 0xffff, hw_status,opmode,opstatus); } else if (this.devType == "RGS") { tc = new Comm.TC.RGSTC(protocol, rd[0].ToString().Trim(), rd[1].ToString(), (int)rd[2], 0xffff, hw_status,opmode, opstatus); } else if (this.devType == "RMS") { tc = new Comm.TC.RMSTC(protocol, rd[0].ToString().Trim(), rd[1].ToString(), (int)rd[2], 0xffff, hw_status,opmode, opstatus); } else if (this.devType == "CMS") { tc = new Comm.TC.CMSTC(protocol, rd[0].ToString().Trim(), rd[1].ToString(), (int)rd[2], 0xffff, hw_status, opmode, opstatus); } else if (this.devType == "WIS") { tc = new Comm.TC.WISTC(protocol, rd[0].ToString().Trim(), rd[1].ToString(), (int)rd[2], 0xffff, hw_status, opmode, opstatus); } else if (this.devType == "LCS") { tc = new Comm.TC.LCSTC(protocol, rd[0].ToString().Trim(), rd[1].ToString(), (int)rd[2], 0xffff, hw_status, opmode, opstatus); } else if (this.devType == "CSLS") { tc = new Comm.TC.CSLSTC(protocol, rd[0].ToString().Trim(), rd[1].ToString(), (int)rd[2], 0xffff, hw_status, opmode, opstatus); } ConsoleServer.WriteLine(string.Format("load tc:{0} ip:{1} port:{2}", rd[0], rd[1], rd[2])); tcAry.Add(tc); tc.OnHwStatusChanged += new HWStatusChangeHandler(tc_OnHwStatusChanged); tc.OnConnectStatusChanged += new ConnectStatusChangeHandler(tc_OnConnectStatusChanged); tc.OnOpModeChanged += new OnOPModeChangeHandler(tc_OnOpModeChanged); tc.OnOpStatusChanged += new OnOPStatusChangeHandler(tc_OnOpStatusChanged); // if(tc is OutputTCBase) if (tc is OutputTCBase) { ((OutputTCBase)tc).OnOutputChanged += new Comm.OnOutputChangedHandler(MFCC_Base_OnOutputChanged); ((OutputTCBase)tc).OnOutputDataCompareWrongEvent += new OnOutputDataCompareWrongEventHandler(MFCC_Base_OnOutputDataCompareWrongEvent); } this.BindEvent(tc); * */ } rd.Close(); cn.Close(); } catch (Exception ex) { ConsoleServer.WriteLine(ex.Message+ex.StackTrace); } }