//<summary> //读取数据库面板设置,将所有数据读至缓存 //</summary> public void ReadIRcodesFrmDBTobuf(int DIndex) { try { #region string strsql = string.Format("select * from dbClassInfomation where DIndex={0} and ClassID={1} order by SenNum", DIndex, 0); OleDbDataReader dr = DataModule.SearchAResultSQLDB(strsql, CsConst.mstrCurPath); if (dr != null) { while (dr.Read()) { string str = dr.GetValue(5).ToString(); RemoteEnable = Convert.ToByte(str.Split('-')[0].ToString()); mbytOne = Convert.ToByte(str.Split('-')[1].ToString()); mbytTwo = Convert.ToByte(str.Split('-')[2].ToString()); string strRemark = dr.GetValue(4).ToString(); strName = strName.Split('\\')[0].ToString() + "\\" + strRemark; } dr.Close(); } #endregion #region strsql = string.Format("select * from dbClassInfomation where DIndex={0} and ClassID={1} order by SenNum", DIndex, 1); dr = DataModule.SearchAResultSQLDB(strsql, CsConst.mstrCurPath); IRCodes = new List <UVCMD.IRCode>(); if (dr != null) { while (dr.Read()) { string strRemark = dr.GetValue(4).ToString(); string str = dr.GetValue(5).ToString(); UVCMD.IRCode temp = new UVCMD.IRCode(); temp.KeyID = Convert.ToInt32(str.Split('-')[0].ToString()); temp.IRLength = Convert.ToInt32(str.Split('-')[1].ToString()); temp.IRLoation = Convert.ToInt32(str.Split('-')[2].ToString()); temp.Enable = Convert.ToByte(str.Split('-')[3].ToString()); temp.Codes = str.Split('-')[4].ToString(); temp.Remark1 = strRemark; IRCodes.Add(temp); } dr.Close(); } #endregion } catch { } }
//<summary> //保存数据库面板设置,将所有数据保存 //</summary> public void SaveSendIRToDB() { try { string strsql = string.Format("delete * from dbClassInfomation where DIndex={0}", DIndex); DataModule.ExecuteSQLDatabase(strsql); #region string strDeviceRemark = ""; if (strName.Contains("\\")) { strDeviceRemark = strName.Split('\\')[1].ToString(); } string strBasic = RemoteEnable.ToString() + "-" + mbytOne.ToString() + "-" + mbytTwo.ToString(); strsql = string.Format("Insert into dbClassInfomation(DIndex,ClassID,ObjectID,SenNum,Remark,strParam1) values ({0},{1},{2},{3},'{4}','{5}')", DIndex, 0, 0, 0, strDeviceRemark, strBasic); DataModule.ExecuteSQLDatabase(strsql); #endregion #region if (IRCodes != null) { for (int i = 0; i < IRCodes.Count; i++) { UVCMD.IRCode temp = IRCodes[i]; string strParam = temp.KeyID.ToString() + "-" + temp.IRLength.ToString() + "-" + temp.IRLoation.ToString() + "-" + temp.Enable.ToString() + "-" + temp.Codes.ToString(); strsql = string.Format("Insert into dbClassInfomation(DIndex,ClassID,ObjectID,SenNum,Remark,strParam1) values ({0},{1},{2},{3},'{4}','{5}')", DIndex, 1, 0, i, temp.Remark1, strParam); DataModule.ExecuteSQLDatabase(strsql); } } #endregion } catch { } }
private void showBasicInfo() { try { isRead = true; if (oMultiRemoteSender != null) { if (oMultiRemoteSender.IRCodes != null) { dgvIR.Rows.Clear(); for (int i = 0; i < oMultiRemoteSender.IRCodes.Count; i++) { UVCMD.IRCode ir = oMultiRemoteSender.IRCodes[i]; string str = CsConst.WholeTextsList[1775].sDisplayName; if (ir.Enable == 1) { str = CsConst.mstrINIDefault.IniReadValue("public", "00042", ""); } object[] obj = new object[] { ir.KeyID.ToString(), ir.Remark1.ToString(), str, CsConst.mstrINIDefault.IniReadValue("public", "99810", "") }; dgvIR.Rows.Add(obj); } if (dgvIR.RowCount > 0) { dgvIR.Rows[0].Selected = true; } } chbEnable.Checked = (oMultiRemoteSender.RemoteEnable == 1); } if (btnFree.Visible) { btnFree_Click(null, null); } } catch { } isRead = false; }
/// <summary> /// download all ir codes from devices /// </summary> /// <param name="DevName"></param> /// <param name="wdDeviceType"></param> /// <returns></returns> public void DownLoadIRInfoFrmDevice(string DevNam, int wdDeviceType, int intActivePage, int num1, int num2) { string strMainRemark = DevNam.Split('\\')[1].Trim(); DevNam = DevNam.Split('\\')[0].Trim(); byte bytSubID = byte.Parse(DevNam.Split('-')[0].ToString()); byte bytDevID = byte.Parse(DevNam.Split('-')[1].ToString()); byte[] ArayTmp = null; if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x000E, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(wdDeviceType)) == false) { return; } else { byte[] arayRemark = new byte[20]; for (int intI = 0; intI < 20; intI++) { arayRemark[intI] = CsConst.myRevBuf[25 + intI]; } strName = bytSubID.ToString() + "-" + bytDevID.ToString() + "\\" + HDLPF.Byte2String(arayRemark); CsConst.myRevBuf = new byte[1200]; } if (CsConst.isRestore) { num1 = 1; num2 = 249; } if (intActivePage == 0 || intActivePage == 1) { IRCodes = new List <UVCMD.IRCode>(); #region if (wdDeviceType == 306 || wdDeviceType == 319 || wdDeviceType == 313) { ArayTmp = new byte[1]; ArayTmp[0] = 255; if (CsConst.mySends.AddBufToSndList(ArayTmp, 0xE017, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(wdDeviceType)) == true) { RemoteEnable = CsConst.myRevBuf[26]; CsConst.myRevBuf = new byte[1200]; } } HDLUDP.TimeBetwnNext(ArayTmp.Length); ArayTmp = new byte[2]; IRCodes = new List <UVCMD.IRCode>(); //读取红外有效性 for (int i = num1; i <= num2; i++) { UVCMD.IRCode temp = new UVCMD.IRCode(); temp.IRLength = 0; temp.IRLoation = 0; temp.KeyID = i; temp.Codes = ""; temp.Remark1 = ""; temp.Enable = 0; IRCodes.Add(temp); } ArayTmp = new byte[0]; int intTmp = 0; byte ValidCount = 0; byte FirstKey = 0; byte LastSendCount = 0; if (CsConst.mySends.AddBufToSndList(ArayTmp, 0xd914, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(wdDeviceType)) == true) { ValidCount = CsConst.myRevBuf[26]; FirstKey = CsConst.myRevBuf[27]; CsConst.myRevBuf = new byte[1200]; } else { return; } if (ValidCount > 11) { intTmp = ValidCount / 11; if (ValidCount % 11 != 0) { intTmp = intTmp + 1; LastSendCount = Convert.ToByte(ValidCount % 11); } } else if (ValidCount != 0 && ValidCount <= 11) { intTmp = 1; } List <byte> listTmp = new List <byte>(); for (int i = 0; i < intTmp; i++) { ArayTmp = new byte[2]; ArayTmp[0] = FirstKey; ArayTmp[1] = 11; if (i == intTmp - 1 && LastSendCount != 0) { ArayTmp[1] = LastSendCount; } if (CsConst.mySends.AddBufToSndList(ArayTmp, 0xd916, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(wdDeviceType)) == true) { FirstKey = CsConst.myRevBuf[40]; for (int j = 0; j < ArayTmp[1]; j++) { if (!listTmp.Contains(CsConst.myRevBuf[29 + j])) { listTmp.Add(CsConst.myRevBuf[29 + j]); } } CsConst.myRevBuf = new byte[1200]; } else { return; } HDLUDP.TimeBetwnNext(ArayTmp.Length); if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(i + 1); } } for (int i = 0; i < IRCodes.Count; i++) { for (int j = 0; j < listTmp.Count; j++) { if ((IRCodes[i].KeyID - 1) == Convert.ToInt32(listTmp[j])) { IRCodes[i].Enable = 1; break; } } } for (int i = 0; i < IRCodes.Count; i++) { if (IRCodes[i].Enable == 1) { ArayTmp = new byte[2]; ArayTmp[0] = Convert.ToByte(IRCodes[i].KeyID - 1); ArayTmp[1] = 0; byte[] arayRemark = new byte[20]; if (CsConst.mySends.AddBufToSndList(ArayTmp, 0xD90C, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(wdDeviceType)) == true) { Array.Copy(CsConst.myRevBuf, 29, arayRemark, 0, 10); CsConst.myRevBuf = new byte[1200]; } else { return; } HDLUDP.TimeBetwnNext(ArayTmp.Length); ArayTmp = new byte[2]; ArayTmp[0] = Convert.ToByte(IRCodes[i].KeyID - 1); ArayTmp[1] = 1; if (CsConst.mySends.AddBufToSndList(ArayTmp, 0xD90C, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(wdDeviceType)) == true) { Array.Copy(CsConst.myRevBuf, 29, arayRemark, 10, 10); CsConst.myRevBuf = new byte[1200]; } else { return; } HDLUDP.TimeBetwnNext(ArayTmp.Length); IRCodes[i].Remark1 = HDLPF.Byte2String(arayRemark); if (CsConst.isRestore) { ArayTmp = new byte[1]; ArayTmp[0] = Convert.ToByte(IRCodes[i].KeyID - 1); int Length = 0; int SendCount = 0; if (CsConst.mySends.AddBufToSndList(ArayTmp, 0xD908, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(wdDeviceType)) == true) { Length = CsConst.myRevBuf[26] * 256 + CsConst.myRevBuf[27]; CsConst.myRevBuf = new byte[1200]; } else { return; } Length = Length - 12; SendCount = Length / 14; SendCount = SendCount + 1; if (Length % 14 != 0) { SendCount = SendCount + 1; } string strCodes = ""; for (int j = 0; j < SendCount; j++) { ArayTmp = new byte[0]; if (CsConst.mySends.AddBufToSndList(ArayTmp, 0xD90A, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(wdDeviceType)) == true) { string str = "84 "; for (int k = 0; k < 15; k++) { str = str + CsConst.myRevBuf[26 + k].ToString("X2") + " "; } str = str.Trim(); if (j < (SendCount - 1)) { str = str + ";"; } strCodes = strCodes + str; CsConst.myRevBuf = new byte[1200]; } HDLUDP.TimeBetwnNext(20); } IRCodes[i].Codes = strCodes; } } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(i * (65 / (IRCodes.Count)) + 25); } } if (wdDeviceType == 302 || wdDeviceType == 306 || wdDeviceType == 313 || wdDeviceType == 319) { if (CsConst.mySends.AddBufToSndList(ArayTmp, 0xd962, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(wdDeviceType)) == true) { mbytOne = CsConst.myRevBuf[25]; mbytTwo = CsConst.myRevBuf[26]; CsConst.myRevBuf = new byte[1200]; } else { return; } } #endregion MyRead2UpFlags[0] = true; } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(100); } }
/// <summary> ///下载设置 /// </summary> public bool DownloadSensorInfosToDevice(string DevName, int DeviceType, int intActivePage, int num1, int num2) { string strMainRemark = DevName.Split('\\')[1].Trim(); DevName = DevName.Split('\\')[0].Trim(); //保存basic informations网络信息 byte bytSubID = byte.Parse(DevName.Split('-')[0].ToString()); byte bytDevID = byte.Parse(DevName.Split('-')[1].ToString()); byte[] ArayTmp = null; if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x000E, bytSubID, bytDevID, false, true, true, false) == false) { return(false); } else { byte[] arayRemark = new byte[20]; for (int intI = 0; intI < 20; intI++) { arayRemark[intI] = CsConst.myRevBuf[25 + intI]; } Devname = bytSubID.ToString() + "-" + bytDevID.ToString() + "\\" + HDLPF.Byte2String(arayRemark); HDLUDP.TimeBetwnNext(1); } ///红外发射 if (intActivePage == 0 || intActivePage == 1) { #region ArayTmp = new byte[2]; IRCodes = new List <UVCMD.IRCode>(); //读取红外有效性 for (int i = num1; i <= num2; i++) { UVCMD.IRCode temp = new UVCMD.IRCode(); temp.IRLength = 0; temp.IRLoation = 0; temp.KeyID = i; temp.Codes = ""; temp.Remark1 = ""; temp.Enable = 0; IRCodes.Add(temp); } ArayTmp = new byte[0]; int intTmp = 0; byte ValidCount = 0; byte FirstKey = 0; byte LastSendCount = 0; if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x168A, bytSubID, bytDevID, false, true, true, false) == true) { ValidCount = CsConst.myRevBuf[26]; FirstKey = CsConst.myRevBuf[27]; HDLUDP.TimeBetwnNext(1); } else { return(false); } if (ValidCount > 11) { intTmp = ValidCount / 11; if (ValidCount % 11 != 0) { intTmp = intTmp + 1; LastSendCount = Convert.ToByte(ValidCount % 11); } } else if (ValidCount != 0 && ValidCount <= 11) { intTmp = 1; } List <byte> listTmp = new List <byte>(); for (int i = 0; i < intTmp; i++) { ArayTmp = new byte[2]; ArayTmp[0] = FirstKey; ArayTmp[1] = 11; if (i == intTmp - 1 && LastSendCount != 0) { ArayTmp[1] = LastSendCount; } if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x168C, bytSubID, bytDevID, false, true, true, false) == true) { FirstKey = CsConst.myRevBuf[40]; for (int j = 0; j < ArayTmp[1]; j++) { if (!listTmp.Contains(CsConst.myRevBuf[29 + j])) { listTmp.Add(CsConst.myRevBuf[29 + j]); } } HDLUDP.TimeBetwnNext(1); } else { return(false); } } for (int i = 0; i < IRCodes.Count; i++) { for (int j = 0; j < listTmp.Count; j++) { if ((IRCodes[i].KeyID - 1) == Convert.ToInt32(listTmp[j])) { IRCodes[i].Enable = 1; break; } } } for (int i = 0; i < IRCodes.Count; i++) { if (IRCodes[i].Enable == 1) { ArayTmp = new byte[2]; ArayTmp[0] = Convert.ToByte(IRCodes[i].KeyID - 1); ArayTmp[1] = 0; byte[] arayRemark = new byte[20]; if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x168E, bytSubID, bytDevID, false, true, true, false) == true) { Array.Copy(CsConst.myRevBuf, 29, arayRemark, 0, 10); HDLUDP.TimeBetwnNext(1); } else { return(false); } ArayTmp = new byte[2]; ArayTmp[0] = Convert.ToByte(IRCodes[i].KeyID - 1); ArayTmp[1] = 1; if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x168E, bytSubID, bytDevID, false, true, true, false) == true) { Array.Copy(CsConst.myRevBuf, 29, arayRemark, 10, 10); HDLUDP.TimeBetwnNext(1); } else { return(false); } IRCodes[i].Remark1 = HDLPF.Byte2String(arayRemark); } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(10 * (i + 1) / IRCodes.Count); } } #endregion MyRead2UpFlags[0] = true; } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(10); } // 红外接收 if (intActivePage == 0 || intActivePage == 2) { #region IrReceiver = new List <IRReceive>(); if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x1672, bytSubID, bytDevID, false, true, true, false) == true) { ArayTmpMode = new byte[40]; Array.Copy(CsConst.myRevBuf, 26, ArayTmpMode, 0, 40); HDLUDP.TimeBetwnNext(1); for (int intI = num1; intI <= num2; intI++) { IRReceive oTmp = new IRReceive(); oTmp.BtnNum = intI; oTmp.IRBtnModel = ArayTmpMode[intI - 1]; oTmp.TargetInfo = new List <UVCMD.ControlTargets>(); //读取按键备注 #region ArayTmp = new byte[1]; ArayTmp[0] = Convert.ToByte(intI); if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x167A, bytSubID, bytDevID, false, true, true, false) == true) { byte[] arayRemark = new byte[20]; for (int intJ = 0; intJ < 20; intJ++) { arayRemark[intJ] = CsConst.myRevBuf[27 + intJ]; } oTmp.IRBtnRemark = HDLPF.Byte2String(arayRemark); HDLUDP.TimeBetwnNext(1); } else { return(false); } #endregion //按键目标 #region oTmp.TargetInfo = new List <UVCMD.ControlTargets>(); if (CsConst.isRestore) { byte bytTotalCMD = 1; switch (oTmp.IRBtnModel) { case 0: bytTotalCMD = 1; break; case 1: case 2: case 3: case 6: case 10: bytTotalCMD = 1; break; case 4: case 5: case 7: case 13: bytTotalCMD = 99; break; case 11: bytTotalCMD = 98; break; case 16: case 17: bytTotalCMD = 49; break; } for (byte bytJ = 0; bytJ < bytTotalCMD; bytJ++) { ArayTmp = new byte[2]; ArayTmp[0] = (byte)(intI); ArayTmp[1] = (byte)(bytJ + 1); if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x1676, bytSubID, bytDevID, false, true, true, false) == true) { UVCMD.ControlTargets oCMD = new UVCMD.ControlTargets(); oCMD.ID = CsConst.myRevBuf[27]; oCMD.Type = CsConst.myRevBuf[28]; //转换为正确的类型 oCMD.SubnetID = CsConst.myRevBuf[29]; oCMD.DeviceID = CsConst.myRevBuf[30]; oCMD.Param1 = CsConst.myRevBuf[31]; oCMD.Param2 = CsConst.myRevBuf[32]; oCMD.Param3 = CsConst.myRevBuf[33]; oCMD.Param4 = CsConst.myRevBuf[34]; oTmp.TargetInfo.Add(oCMD); HDLUDP.TimeBetwnNext(1); } else { return(false); } } } #endregion IrReceiver.Add(oTmp); if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(2 + intI / 2); } } } else { return(false); } #endregion MyRead2UpFlags[1] = true; } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(20); } //传感器设置 if (intActivePage == 0 || intActivePage == 3 || intActivePage == 4) { #region if (intActivePage == 0 || intActivePage == 3) { // read led灯使能位 #region if (CsConst.mySends.AddBufToSndList(ArayTmp, 0xDB3E, bytSubID, bytDevID, false, true, true, false) == true) { Array.Copy(CsConst.myRevBuf, 27, ONLEDs, 0, CsConst.myRevBuf[26]); HDLUDP.TimeBetwnNext(1); } else { return(false); } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(21); } #endregion } if (intActivePage == 0 || intActivePage == 3 || intActivePage == 4) { //读取使能位 #region ArayTmp = null; if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x165E, bytSubID, bytDevID, false, true, true, false) == true) { Array.Copy(CsConst.myRevBuf, 26, EnableSensors, 0, 7); HDLUDP.TimeBetwnNext(1); } else { return(false); } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(23); } #endregion } if (intActivePage == 0 || intActivePage == 3) { //读取温度补偿值 #region if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x1641, bytSubID, bytDevID, false, true, true, false) == true) { Array.Copy(CsConst.myRevBuf, 26, ParamSensors, 0, 1); HDLUDP.TimeBetwnNext(1); } else { return(false); } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(24); } #endregion //读取灵敏度 #region if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x166E, bytSubID, bytDevID, false, true, true, false) == true) { Array.Copy(CsConst.myRevBuf, 26, ParamSensors, 1, 1); HDLUDP.TimeBetwnNext(1); } else { return(false); } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(25); } #endregion //恒照度读取 if (DeviceType == 329) { #region if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x16A9, bytSubID, bytDevID, false, true, true, false) == true) { Array.Copy(CsConst.myRevBuf, 26, EnableBroads, 0, 9); HDLUDP.TimeBetwnNext(1); } else { return(false); } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(26); } #endregion } } #endregion MyRead2UpFlags[2] = true; } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(30); } //逻辑块功能设置 if (intActivePage == 0 || intActivePage == 4) { #region // 读取24个逻辑的使能位 if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x165A, bytSubID, bytDevID, false, true, true, false) == true) { logic = new List <SensorLogic>(); byte[] ArayTmpMode = new byte[24]; Array.Copy(CsConst.myRevBuf, 26, ArayTmpMode, 0, Eightin1DeviceTypeList.TotalLogic); HDLUDP.TimeBetwnNext(1); for (int intI = 1; intI <= Eightin1DeviceTypeList.TotalLogic; intI++) { SensorLogic oTmp = new SensorLogic(); oTmp.ID = (byte)intI; oTmp.EnableSensors = new byte[15]; oTmp.Paramters = new byte[20]; oTmp.Enabled = ArayTmpMode[intI - 1]; //无效则不读取 if (oTmp.Enabled != 1) { logic.Add(oTmp); continue; } //读取备注 #region ArayTmp = new byte[1]; ArayTmp[0] = Convert.ToByte(intI); if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x1648, bytSubID, bytDevID, false, true, true, false) == true) { byte[] arayRemark = new byte[20]; for (int intJ = 0; intJ < 20; intJ++) { arayRemark[intJ] = CsConst.myRevBuf[27 + intJ]; } oTmp.Remarklogic = HDLPF.Byte2String(arayRemark); HDLUDP.TimeBetwnNext(1); } else { return(false); } #endregion //读取设置 #region if (CsConst.isRestore) { if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x1650, bytSubID, bytDevID, false, true, true, false) == true) { oTmp.bytRelation = CsConst.myRevBuf[27]; oTmp.EnableSensors = new byte[15]; int intTmp = CsConst.myRevBuf[28]; if (intTmp == 255) { intTmp = 0; } //oTmp.EnableSensors for (byte bytI = 0; bytI <= 6; bytI++) { oTmp.EnableSensors[bytI] = Convert.ToByte((intTmp & (1 << bytI)) == (1 << bytI)); } oTmp.DelayTimeT = CsConst.myRevBuf[29] * 256 + CsConst.myRevBuf[30]; Array.Copy(CsConst.myRevBuf, 31, oTmp.Paramters, 0, 7); oTmp.UV1 = new UniversalSwitchSet(); oTmp.UV1.id = Convert.ToByte(HDLPF.IsNumStringMode(CsConst.myRevBuf[38].ToString(), 201, 248)); oTmp.UV1.condition = CsConst.myRevBuf[39]; oTmp.UV2 = new UniversalSwitchSet(); oTmp.UV2.id = Convert.ToByte(HDLPF.IsNumStringMode(CsConst.myRevBuf[40].ToString(), 201, 248)); if (oTmp.UV2.id == oTmp.UV1.id) { oTmp.UV2.id = Convert.ToByte(oTmp.UV1.id + 1); } oTmp.UV2.condition = CsConst.myRevBuf[41]; oTmp.DelayTimeF = CsConst.myRevBuf[42] * 256 + CsConst.myRevBuf[43]; if (oTmp.DelayTimeT == 65535) { oTmp.DelayTimeT = 0; } if (oTmp.DelayTimeF == 65535) { oTmp.DelayTimeF = 0; } HDLUDP.TimeBetwnNext(1); ArayTmp = new byte[1]; ArayTmp[0] = oTmp.UV1.id; if ((CsConst.mySends.AddBufToSndList(ArayTmp, 0x164C, bytSubID, bytDevID, false, false, true, false) == true)) { byte[] arayRemark = new byte[20]; Array.Copy(CsConst.myRevBuf, 27, arayRemark, 0, arayRemark.Length); oTmp.UV1.remark = HDLPF.Byte2String(arayRemark); oTmp.UV1.isAutoOff = (CsConst.myRevBuf[47] == 1); if (CsConst.myRevBuf[48] * 256 + CsConst.myRevBuf[49] > 3600) { oTmp.UV1.autoOffDelay = 1; } else { oTmp.UV1.autoOffDelay = CsConst.myRevBuf[48] * 256 + CsConst.myRevBuf[49]; } HDLUDP.TimeBetwnNext(1); } ArayTmp[0] = oTmp.UV2.id; if ((CsConst.mySends.AddBufToSndList(ArayTmp, 0x164C, bytSubID, bytDevID, false, false, true, false) == true)) { byte[] arayRemark = new byte[20]; Array.Copy(CsConst.myRevBuf, 27, arayRemark, 0, arayRemark.Length); oTmp.UV2.remark = HDLPF.Byte2String(arayRemark); oTmp.UV2.isAutoOff = (CsConst.myRevBuf[47] == 1); if (CsConst.myRevBuf[48] * 256 + CsConst.myRevBuf[49] > 3600) { oTmp.UV2.autoOffDelay = 1; } else { oTmp.UV2.autoOffDelay = CsConst.myRevBuf[48] * 256 + CsConst.myRevBuf[49]; } HDLUDP.TimeBetwnNext(1); } } else { return(false); } } #endregion //成立的触发目标 oTmp.DownloadLogicTrueCommandsFromDevice(bytSubID, bytDevID, DeviceType, 0, 0); //不成立的触发目标 oTmp.DownloadLogicFalseCommandsFromDevice(bytSubID, bytDevID, DeviceType, 0, 0); logic.Add(oTmp); if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(24 + intI * 2); } } } else { return(false); } #endregion MyRead2UpFlags[3] = true; } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(40); } if (intActivePage == 0 || intActivePage == 5) { //安防设置 #region fireset = new List <UVCMD.SecurityInfo>(); ArayTmp = new byte[1]; for (byte intI = 1; intI <= 3; intI++) { ArayTmp[0] = intI; //读取备注 #region UVCMD.SecurityInfo oTmp = new UVCMD.SecurityInfo(); oTmp.bytSeuID = intI; if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x1666, bytSubID, bytDevID, false, true, true, false) == true) { byte[] arayRemark = new byte[20]; for (int intJ = 0; intJ < 20; intJ++) { arayRemark[intJ] = CsConst.myRevBuf[27 + intJ]; } oTmp.strRemark = HDLPF.Byte2String(arayRemark); HDLUDP.TimeBetwnNext(1); } else { return(false); } #endregion //读取设置 #region if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x166A, bytSubID, bytDevID, false, true, true, false) == true) { oTmp.bytTerms = CsConst.myRevBuf[27]; oTmp.bytSubID = CsConst.myRevBuf[28]; oTmp.bytDevID = CsConst.myRevBuf[29]; oTmp.bytArea = CsConst.myRevBuf[30]; HDLUDP.TimeBetwnNext(1); } else { return(false); } fireset.Add(oTmp); if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(40 + (10 * intI / 4)); } #endregion } #endregion MyRead2UpFlags[4] = true; } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(50); } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(100); } return(true); }
private void btnNew_Click(object sender, EventArgs e) { // 检测是不是重复备注 如果重复提示替换 默认为新增 if (cboDevice.Text == null || cboDevice.Text == "") { return; } if (txtGrAddress.Text == null || cboDevice.Text == "") { return; } if (rtxCodes.Text == null || rtxCodes.Lines.Length == 0) { return; } int IRLegth = 0; string str0 = rtxCodes.Lines[0].ToString().Split(':')[1].Trim(); string[] strlist0 = str0.Split(' '); IRLegth = Convert.ToInt32(strlist0[2], 16) * 256 + Convert.ToInt32(strlist0[3], 16); int strLength = 0; strLength = (rtxCodes.Lines.Length * 16) - (2 * rtxCodes.Lines.Length); if (strLength < IRLegth) { if (MessageBox.Show(CsConst.mstrINIDefault.IniReadValue("public", "99583", ""), "", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.OK) { return; } else { return; } } Cursor.Current = Cursors.WaitCursor; string strDevice = cboDevice.Text; string strRemark = txtGrAddress.Text; bool blnIsExistedDev = false; TreeNode oNode = null; //临时存放节点 用于取其ID // 判断是否存在当前设备类型 是否存在当前红外码 UVCMD.IRCode TmpIR = null; int intIRID = 1; List <int> TmpIRIDs = new List <int>(); //取出所有已用的红外码号 #region if (tvExisted.Nodes != null && tvExisted.Nodes.Count != 0) { for (int intI = 0; intI < tvExisted.Nodes.Count; intI++) { blnIsExistedDev = strDevice.Equals(tvExisted.Nodes[intI].Text.ToString()); if (blnIsExistedDev == true) { oNode = tvExisted.Nodes[intI]; if (tvExisted.Nodes[intI].Nodes != null && tvExisted.Nodes[intI].Nodes.Count != 0) { foreach (TreeNode NodeTmp in tvExisted.Nodes[intI].Nodes) { TmpIRIDs.Add(Convert.ToInt32(NodeTmp.Name)); if (strRemark.Equals(NodeTmp.Text.ToString())) { break; } } } break; } } } #endregion //新红外码 #region if (TmpIRIDs != null) { //查找位置,替换buffer while (TmpIRIDs.Contains(intIRID)) { intIRID++; } } #endregion TmpIR = new UVCMD.IRCode(); TmpIR.KeyID = intIRID; TmpIR.Remark1 = strDevice; TmpIR.Remark2 = strRemark; TmpIR.IRLength = rtxCodes.Lines.Length - 1; TmpIR.Codes = ""; for (int intI = 0; intI < rtxCodes.Lines.Length; intI++) { if (rtxCodes.Lines[intI] != "" && rtxCodes.Lines[intI] != null) { TmpIR.Codes += rtxCodes.Lines[intI].ToString().Split(':')[1].Trim() + ";"; } } if (TmpIR.Codes.Length > 0) { TmpIR.Codes = TmpIR.Codes.Substring(0, TmpIR.Codes.Length - 1); } Cursor.Current = Cursors.Default; }