//<summary> //读取数据库里的调光模块的设置,将所有数据读取缓存 //</summary> public void ReadInfoForDB(int id) { Chans = new List <Chn>(); //read all channels information save them to the buffer string str = "select * from dbTempSensor where DIndex=" + id.ToString() + " order by ChnID"; OleDbDataReader dr = DataModule.SearchAResultSQLDB(str); if (dr.HasRows) { while (dr.Read()) { Chn Tmp = new Chn(); Tmp.bytTheType = dr.GetByte(2); Tmp.bytRValue = new byte[6]; Tmp.bytRValue[0] = byte.Parse((dr.GetInt16(3) / 256).ToString()); Tmp.bytRValue[1] = byte.Parse((dr.GetInt16(3) % 256).ToString()); Tmp.bytRValue[2] = byte.Parse((dr.GetInt16(4) / 256).ToString()); Tmp.bytRValue[3] = byte.Parse((dr.GetInt16(4) % 256).ToString()); Tmp.bytRValue[4] = byte.Parse((dr.GetInt16(5) / 256).ToString()); Tmp.bytRValue[5] = byte.Parse((dr.GetInt16(5) % 256).ToString()); Tmp.blnBroadTemp = dr.GetBoolean(6); Tmp.bytSubID = dr.GetByte(7); Tmp.bytDevID = dr.GetByte(8); Tmp.byAdjustVal = dr.GetByte(9); Chans.Add(Tmp); } } dr.Close(); }
////<summary> ////读取默认的温度传感器设置,将所有数据读取缓存 ////</summary> public void ReadDefaultInfo(int wdMaxValue) { ////set all channel to default 0,未定义,0.0 ,0.0 Chans = new List <Chn>(); for (int i = 0; i < wdMaxValue; i++) { Chn ch = new Chn(); ch.bytTheType = 1; ch.bytRValue = new byte[] { 29100 / 256, 29100 % 256, 18570 / 256, 18570 % 256, 10000 / 256, 10000 % 256 }; ch.blnBroadTemp = false; ch.bytSubID = 255; ch.bytDevID = 255; ch.byAdjustVal = 0; Chans.Add(ch); } }
/// <summary> /// device name subnet id + device id + remark /// </summary> /// <param name="DevName"></param> public void DownLoadInformationFrmDevice(string DevName) { string strMainRemark = DevName.Split('\\')[1].Trim(); DevName = DevName.Split('\\')[0].Trim(); byte bytSubID = byte.Parse(DevName.Split('-')[0].ToString()); byte bytDevID = byte.Parse(DevName.Split('-')[1].ToString()); byte[] ArayTmp = new byte[1]; Chans = new List <Chn>(); #region for (byte bytI = 1; bytI < 5; bytI++) { Chn oTmp = new Chn(); ArayTmp[0] = bytI; // read broadcast informations if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x1C00, bytSubID, bytDevID, false, true, true, false) == true) { if (CsConst.myRevBuf != null) { oTmp.blnBroadTemp = (CsConst.myRevBuf[26] == 1); oTmp.bytSubID = CsConst.myRevBuf[27]; oTmp.bytDevID = CsConst.myRevBuf[27]; oTmp.byAdjustVal = CsConst.myRevBuf[27]; } CsConst.myRevBuf = new byte[1200]; HDLUDP.TimeBetwnNext(10); } else { MessageBox.Show("This module is not online or the address is another one, please check it !!"); return; } // read other setups if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x1C04, bytSubID, bytDevID, false, true, true, false) == true) { if (CsConst.myRevBuf != null) { oTmp.bytTheType = CsConst.myRevBuf[26]; oTmp.bytRValue = new byte[6]; for (int intI = 0; intI < 6; intI++) { oTmp.bytRValue[intI] = CsConst.myRevBuf[27 + intI]; } } CsConst.myRevBuf = new byte[1200]; HDLUDP.TimeBetwnNext(10); } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(bytI * 25, null); } Chans.Add(oTmp); } #endregion if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(100, null); } MyRead2UpFlags[0] = true; }