void SetVisibleAccordingly() { networkinfo = new NetworkInForm(SubNetID, DevID, MyintDeviceType); groupBox1.Controls.Add(networkinfo); networkinfo.Dock = DockStyle.Fill; cbtype.Items.Clear(); cbtype.DropDownStyle = ComboBoxStyle.DropDownList; for (int i = 1; i < 20; i++) { cbtype.Items.Add(CsConst.mstrINIDefault.IniReadValue("KeyFunType", "000" + GlobalClass.AddLeftZero(i.ToString(), 2), "")); } cbpam1Analog.Items.Clear(); cbpam1Analog.DropDownStyle = ComboBoxStyle.DropDownList; cbpam1Analog.Items.Add(CsConst.mstrINIDefault.IniReadValue("public", "99848", "")); cbpam1PanelControl.Items.Clear(); cbpam1PanelControl.DropDownStyle = ComboBoxStyle.DropDownList; string sql = ""; if (CsConst.iLanguageId == 0) { sql = "select NoteInEng from tmpAirControlTypeForPanelControl"; } else if (CsConst.iLanguageId == 1) { sql = "select NoteInChn from tmpAirControlTypeForPanelControl"; } HDLSysPF.AddItemtoCbFromDB(sql, cbpam1PanelControl); DgvList.Controls.Add(txtpam1); DgvList.Controls.Add(cbpam1Analog); DgvList.Controls.Add(cbpam1PanelControl); DgvList.Controls.Add(txtpam2); DgvList.Controls.Add(timetxt); isReading = true; setAllVisible(false); isReading = false; }
private void showBackNetSetupInfo() { try { if (myBcakNet.otherInfo == null) { return; } if (myBcakNet.otherInfo.Count <= 0) { return; } DgvList.Rows.Clear(); #region for (int i = 0; i < myBcakNet.otherInfo.Count; i++) { BacNet.OtherInfo temp = myBcakNet.otherInfo[i]; int intValue = ((((temp.BackNetIDAry[3] * 256 + temp.BackNetIDAry[2]) & 0x7FF) * 65536 + temp.BackNetIDAry[1] * 256 + temp.BackNetIDAry[0]) & 0x7FFFFFF); string strID = ""; string strhexID = ""; if (intValue >= 0 && intValue <= 0x3FFFFF) { strID = CsConst.BackNetIDString[0] + ":" + Convert.ToString(intValue); } else if (intValue >= 0x400000 && intValue <= 0x7FFFFF) { strID = CsConst.BackNetIDString[1] + ":" + Convert.ToString(intValue - 0x400000); } else if (intValue >= 0x800000 && intValue <= 0xBFFFFF) { strID = CsConst.BackNetIDString[2] + ":" + Convert.ToString(intValue - 0x800000); } else if (intValue >= 0xC00000 && intValue <= 0xFFFFFF) { strID = CsConst.BackNetIDString[3] + ":" + Convert.ToString(intValue - 0xC00000); } else if (intValue >= 0x1000000 && intValue <= 0x13FFFFF) { strID = CsConst.BackNetIDString[4] + ":" + Convert.ToString(intValue - 0x1000000); } else if (intValue >= 0x1400000 && intValue <= 0x17FFFFF) { strID = CsConst.BackNetIDString[5] + ":" + Convert.ToString(intValue - 0x1400000); } else if (intValue >= 0x3400000 && intValue <= 0x37FFFFF) { strID = CsConst.BackNetIDString[6] + ":" + Convert.ToString(intValue - 0x3400000); } else if (intValue >= 0x3800000 && intValue <= 0x3BFFFFF) { strID = CsConst.BackNetIDString[7] + ":" + Convert.ToString(intValue - 0x3800000); } else if (intValue >= 0x4C00000 && intValue <= 0x4FFFFFF) { strID = CsConst.BackNetIDString[8] + ":" + Convert.ToString(intValue - 0x4C00000); } else { strID = CsConst.BackNetIDString[9] + ":" + Convert.ToString(intValue); } strhexID = "0x" + GlobalClass.AddLeftZero(Convert.ToString(intValue, 16), 8); string strType = ""; string stFirst = ""; string strSecond = ""; switch (temp.Type) { case 0x000C: if (temp.Param1 == 255) ///广播场景 { strType = CsConst.mstrINIDefault.IniReadValue("KeyFunType", "00010", ""); stFirst = CsConst.WholeTextsList[2566].sDisplayName; } else ////场景控制 { strType = CsConst.mstrINIDefault.IniReadValue("KeyFunType", "00002", ""); stFirst = temp.Param1.ToString() + "(" + CsConst.WholeTextsList[2510].sDisplayName + ")"; } break; case 0xE014: ///序列控制 strType = CsConst.mstrINIDefault.IniReadValue("KeyFunType", "00003", ""); stFirst = temp.Param1.ToString() + "(" + CsConst.WholeTextsList[2510].sDisplayName + ")"; break; case 0xE018: ////通用开关 strType = CsConst.mstrINIDefault.IniReadValue("KeyFunType", "00004", ""); stFirst = temp.Param1.ToString() + "(" + CsConst.WholeTextsList[2513].sDisplayName + ")"; break; case 0x0033: if (temp.Param1 == 255) ////广播回路 { strType = CsConst.mstrINIDefault.IniReadValue("KeyFunType", "00011", ""); stFirst = CsConst.WholeTextsList[2567].sDisplayName; } else ///单路调节 { strType = CsConst.mstrINIDefault.IniReadValue("KeyFunType", "00005", ""); stFirst = temp.Param1.ToString() + "(" + CsConst.WholeTextsList[934].sDisplayName + ")"; } int intTime = temp.Param2 * 256 + temp.Param3; intTime = intTime % 3659; strSecond = Convert.ToString(intTime / 60) + ":" + Convert.ToString(intTime % 60); break; case 0xF112: ///时间开关 strType = CsConst.mstrINIDefault.IniReadValue("KeyFunType", "00006", ""); stFirst = temp.Param1.ToString() + "(" + CsConst.mstrINIDefault.IniReadValue("public", "99921", "") + ")"; break; case 0xE3E2: ////窗帘开关 strType = CsConst.mstrINIDefault.IniReadValue("KeyFunType", "00007", ""); stFirst = temp.Param1.ToString() + "(" + CsConst.mstrINIDefault.IniReadValue("public", "99844", "") + ")"; break; case 0xE3D6: ///GPRS控制 strType = CsConst.mstrINIDefault.IniReadValue("KeyFunType", "00008", ""); stFirst = temp.Param1.ToString() + "(" + CsConst.mstrINIDefault.IniReadValue("public", "99845", "") + ")"; break; case 0xE3DA: ///面板控制 strType = CsConst.mstrINIDefault.IniReadValue("KeyFunType", "00009", ""); if (temp.Param1 > 28 || temp.Param1 < 0) { temp.Param1 = 0; } stFirst = HDLSysPF.selectNoteResultFromDB("tmpAirControlTypeForPanelControl", Convert.ToInt32(temp.Param1)); switch (temp.Param1) { case 15: case 17: case 18: strSecond = temp.Param2.ToString() + "(" + CsConst.mstrINIDefault.IniReadValue("public", "99846", "") + ")"; break; case 16: strSecond = temp.Param2.ToString() + "(" + CsConst.mstrINIDefault.IniReadValue("public", "99847", "") + ")"; break; } break; case 0x011E: ///消防模块 strType = CsConst.mstrINIDefault.IniReadValue("KeyFunType", "00012", ""); //if (Param1 > 8 || Param1 < 1) Param1 = 1; stFirst = Convert.ToString(temp.Param1) + "(" + CsConst.WholeTextsList[2510].sDisplayName + ")"; break; case 0x16A4: ///通用控制 strType = CsConst.mstrINIDefault.IniReadValue("KeyFunType", "00013", ""); stFirst = Convert.ToString(temp.Param2); strSecond = Convert.ToString(temp.Param1); break; case 0x15CE: ///干接点 strType = CsConst.mstrINIDefault.IniReadValue("KeyFunType", "00014", ""); stFirst = Convert.ToString(temp.Param1); break; case 0xE440: ///模拟量输出 strType = CsConst.mstrINIDefault.IniReadValue("KeyFunType", "00015", ""); stFirst = cbpam1Analog.Items[0].ToString(); break; case 0xE3E7: ///温度读取 1byte strType = CsConst.mstrINIDefault.IniReadValue("KeyFunType", "00016", ""); stFirst = Convert.ToString(temp.Param1) + "(" + CsConst.mstrINIDefault.IniReadValue("public", "99921", "") + ")"; break; case 0x1948: ///温度读取 4byte strType = CsConst.mstrINIDefault.IniReadValue("KeyFunType", "00017", ""); stFirst = Convert.ToString(temp.Param1) + "(" + CsConst.mstrINIDefault.IniReadValue("public", "99921", "") + ")"; break; case 0xA008: ///读取DALI灯状态 strType = CsConst.mstrINIDefault.IniReadValue("KeyFunType", "00018", ""); stFirst = Convert.ToString(temp.Param1); break; case 0xE444: ///模拟量设置 strType = CsConst.mstrINIDefault.IniReadValue("KeyFunType", "00019", ""); stFirst = cbpam1Analog.Items[0].ToString(); break; } if (strType == "") { strType = CsConst.mstrINIDefault.IniReadValue("KeyFunType", "00001", ""); stFirst = "N/A"; } if (strSecond == "") { strSecond = "N/A"; } object[] obj = new object[] { temp.ID.ToString(), strID, strhexID, strType, temp.strDevName.Split('/')[0].ToString(), temp.strDevName.Split('/')[1].ToString(), stFirst, strSecond, temp.Remark }; DgvList.Rows.Add(obj); } #endregion } catch { } isReading = false; }
private void backnetid_UserControlValueChanged(object sender, EventArgs e) { if (DgvList.CurrentRow.Index < 0) { return; } if (DgvList.RowCount <= 0) { return; } int index = DgvList.CurrentRow.Index; string str = backnetid.Text; DgvList[1, index].Value = str; int intTmp = 0; string strTmp1 = str.Split(':')[0]; string strTmp2 = str.Split(':')[1]; switch (strTmp1) { case "AI": intTmp = 0; break; case "AO": intTmp = 0x400000; break; case "AV": intTmp = 0x800000; break; case "BI": intTmp = 0xC00000; break; case "BO": intTmp = 0x1000000; break; case "BV": intTmp = 0x1400000; break; case "MI": intTmp = 0x3400000; break; case "MO": intTmp = 0x3800000; break; case "MV": intTmp = 0x4C00000; break; case "Others": intTmp = 0; break; } intTmp = intTmp + Convert.ToInt32(strTmp2); DgvList[2, index].Value = "0x" + GlobalClass.AddLeftZero(Convert.ToString(intTmp, 16), 8); ModifyMultilinesIfNeeds(DgvList[1, index].Value.ToString(), 1); ModifyMultilinesIfNeeds(DgvList[2, index].Value.ToString(), 2); }
private void txtpam1_TextChanged(object sender, EventArgs e) { if (DgvList.CurrentRow.Index < 0) { return; } if (DgvList.RowCount <= 0) { return; } int index = DgvList.CurrentRow.Index; string str = txtpam1.Text; if (!GlobalClass.IsNumeric(str)) { str = "1"; } int num = Convert.ToInt32(str); switch (cbtype.SelectedIndex) { case 1: ///场景 case 2: ///序列 if (num > 254) { str = "0"; } DgvList[6, index].Value = str + "(" + CsConst.WholeTextsList[2510].sDisplayName + ")"; break; case 3: ///通用开关 if (num > 255) { str = "0"; } DgvList[6, index].Value = str + "(" + CsConst.WholeTextsList[2513].sDisplayName + ")"; break; case 5: //时间开关 if (num > 255) { str = "0"; } DgvList[6, index].Value = str + "(" + CsConst.mstrINIDefault.IniReadValue("public", "99921", "") + ")"; break; case 6: ///窗帘 if (num > 255) { str = "0"; } DgvList[6, index].Value = str + "(" + CsConst.mstrINIDefault.IniReadValue("public", "99844", "") + ")"; break; case 7: //GPRS控制 if (num > 255) { str = "0"; } DgvList[6, index].Value = str + "(" + CsConst.mstrINIDefault.IniReadValue("public", "99845", "") + ")"; break; case 11: ///消防 if (num < 1 || num > 8) { str = "1"; } DgvList[6, index].Value = str + "(" + CsConst.WholeTextsList[2513].sDisplayName + ")"; break; case 15: ///温度读取(1 byte) case 16: ///温度读取(4 byte) if (num < 1 || num > 255) { str = "1"; } DgvList[6, index].Value = str + "(" + CsConst.mstrINIDefault.IniReadValue("public", "99921", "") + ")"; break; case 4: ///单路调节 if (num < 1 || num > 254) { str = "1"; } DgvList[6, index].Value = str + "(" + CsConst.WholeTextsList[934].sDisplayName + ")"; break; case 12: ///通用控制 if (num > 65535) { str = "0"; } DgvList[6, index].Value = str; break; case 13: //干接点 if (num < 1 || num > 255) { str = "1"; } DgvList[6, index].Value = str; break; case 17: //DALI灯状态 if (num > 255) { str = "1"; } DgvList[6, index].Value = str; break; } txtpam1.Text = str; }
/// <summary> /// 下载所有数据 /// </summary> /// <param name="DevName"></param> /// <returns></returns> public bool DownloadDSInforsFrmDevice(string DevName, int intDeviceType, int intActivePage, int num1, int num2) { 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[0]; if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x000E, bytSubID, bytDevID, false, true, true, false) == true) { 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); } else { return(false); } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(1); } if (intActivePage == 0 || intActivePage == 1) { #region if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x352D, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(intDeviceType)) == true) { byte[] arayRemark = new byte[4]; Array.Copy(CsConst.myRevBuf, 25, arayRemark, 0, 4); strNO = HDLPF.Byte2String(arayRemark); arayRemark = new byte[6]; Array.Copy(CsConst.myRevBuf, 29, arayRemark, 0, 6); strPassword = HDLPF.Byte2String(arayRemark); if (strNO == "") { strNO = "0000"; } if (strNO.Length < 4) { strNO = GlobalClass.AddLeftZero(strNO, 4); } HDLUDP.TimeBetwnNext(1); } else { return(false); } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(2, null); } arayBasic = new byte[] { 7, 7, 7, 7, 0 }; if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x3525, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(intDeviceType)) == true) { Array.Copy(CsConst.myRevBuf, 25, arayBasic, 0, 5); if (arayBasic[0] < 1 || arayBasic[0] > 7) { arayBasic[0] = 7; } if (arayBasic[1] < 1 || arayBasic[1] > 7) { arayBasic[1] = 7; } if (arayBasic[2] < 1 || arayBasic[2] > 7) { arayBasic[2] = 7; } if (arayBasic[3] < 1 || arayBasic[3] > 7) { arayBasic[3] = 7; } HDLUDP.TimeBetwnNext(1); } else { return(false); } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(3, null); } arayInfo = new byte[20]; if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x350C, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(intDeviceType)) == true) { arayInfo[0] = CsConst.myRevBuf[25]; arayInfo[1] = CsConst.myRevBuf[26]; HDLUDP.TimeBetwnNext(1); } else { return(false); } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(4, null); } arayCall = new byte[20]; if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x138E, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(intDeviceType)) == true) { Array.Copy(CsConst.myRevBuf, 25, arayCall, 0, 11); HDLUDP.TimeBetwnNext(1); } else { return(false); } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(5, null); } arayBrightness = new byte[20]; if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x353B, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(intDeviceType)) == true) { Array.Copy(CsConst.myRevBuf, 25, arayBrightness, 0, 5); HDLUDP.TimeBetwnNext(1); } else { return(false); } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(6, null); } for (byte i = 0; i < 4; i++) { ArayTmp = new byte[1]; ArayTmp[0] = i; if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x3504, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(intDeviceType)) == true) { Array.Copy(CsConst.myRevBuf, 26, arayPassword, i * 12, 12); HDLUDP.TimeBetwnNext(1); } else { return(false); } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(6 + i, null); } } #endregion MyRead2UpFlags[0] = true; } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(10, null); } if (intActivePage == 0 || intActivePage == 2 || intActivePage == 5 || intActivePage == 6) { #region if (ImageList == null) { ImageList = new List <byte[]>(); } confiinfo = new List <RoomInfo>(); if (CsConst.mySends.AddBufToSndList(null, 0x351C, bytSubID, bytDevID, false, true, true, false) == true) { RoomCount = CsConst.myRevBuf[25] * 256 + CsConst.myRevBuf[26]; if (RoomCount > 100) { RoomCount = 100; } } else { return(false); } if (CsConst.isRestore) { num1 = 1; num2 = 100; } for (int i = num1; i <= num2; i++) { ArayTmp = new byte[2]; ArayTmp[0] = Convert.ToByte(i / 256); ArayTmp[1] = Convert.ToByte(i % 256); if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x3500, bytSubID, bytDevID, false, true, true, false) == true) { RoomInfo temp = new RoomInfo(); temp.ID = i; string strHex = GlobalClass.AddLeftZero(CsConst.myRevBuf[28].ToString("X"), 2) + GlobalClass.AddLeftZero(CsConst.myRevBuf[29].ToString("X"), 2) + GlobalClass.AddLeftZero(CsConst.myRevBuf[30].ToString("X"), 2) + GlobalClass.AddLeftZero(CsConst.myRevBuf[31].ToString("X"), 2); temp.RoomNum = Convert.ToUInt64(strHex, 16); temp.Address = CsConst.myRevBuf[32].ToString() + "." + CsConst.myRevBuf[33].ToString() + CsConst.myRevBuf[34].ToString() + "." + CsConst.myRevBuf[35].ToString(); byte[] arayRemark = new byte[20]; Array.Copy(CsConst.myRevBuf, 36, arayRemark, 0, 20); temp.Remark = HDLPF.Byte2String(arayRemark); confiinfo.Add(temp); HDLUDP.TimeBetwnNext(1); } else { return(false); } if (intActivePage == 0 || intActivePage == 5 || intActivePage == 6) { byte[] arayImge = new byte[323]; ArayTmp = new byte[3]; ArayTmp[0] = Convert.ToByte(i / 256); ArayTmp[1] = Convert.ToByte(i % 256); arayImge[0] = ArayTmp[0]; arayImge[1] = ArayTmp[1]; for (byte j = 0; j < 5; j++) { ArayTmp[2] = j; if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x353F, bytSubID, bytDevID, false, true, true, false) == true) { Array.Copy(CsConst.myRevBuf, 29, arayImge, 64 * j + 2, 64); HDLUDP.TimeBetwnNext(1); } else { return(false); } } for (int j = 0; j < ImageList.Count; j++) { byte[] arayImageTmp = ImageList[j]; if (arayImageTmp[0] == Convert.ToByte(i / 256) && arayImageTmp[1] == Convert.ToByte(i % 256)) { ImageList.RemoveAt(j); break; } } ImageList.Add(arayImge); } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(((i - num1) * 20) / (num2 - num1 + 1) + 10, null); } } #endregion MyRead2UpFlags[1] = true; } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(30, null); } if (intActivePage == 0 || intActivePage == 3) { #region MyCardInfo = new List <CardInfo>(); for (int i = 0; i < 1000; i++) { CardInfo temp = new CardInfo(); temp.UID = new byte[10]; temp.UIDL = 0; temp.CardType = 0; temp.CardNum = Convert.ToInt32(i + 1); temp.BuildingNO = 0; temp.RoomNO = 0; temp.UnitNO = 0; temp.arayDate = new byte[5]; temp.arayPhone = new byte[11]; temp.arayName = new byte[10]; temp.Remark = ""; MyCardInfo.Add(temp); } string strEnable = ""; ArayTmp = new byte[4]; ArayTmp[0] = 0; ArayTmp[1] = 0; ArayTmp[2] = Convert.ToByte(500 / 256); ArayTmp[3] = Convert.ToByte(500 % 256); if (CsConst.mySends.AddBufToSndList(ArayTmp, 0xE474, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(intDeviceType)) == true) { int MaxCount = 0; byte[] arayValid = new byte[63]; Array.Copy(CsConst.myRevBuf, 29, arayValid, 0, 63); for (int i = 0; i < 63; i++) { string strTmp = GlobalClass.AddLeftZero(Convert.ToString(arayValid[i], 2), 8); for (int j = 7; j >= 0; j--) { if (MaxCount >= 500) { break; } string str = strTmp.Substring(j, 1); strEnable = strEnable + str; MaxCount = MaxCount + 1; } } } ArayTmp = new byte[4]; ArayTmp[0] = Convert.ToByte(500 / 256); ArayTmp[1] = Convert.ToByte(500 % 256); ArayTmp[2] = Convert.ToByte(500 / 256); ArayTmp[3] = Convert.ToByte(500 % 256); if (CsConst.mySends.AddBufToSndList(ArayTmp, 0xE474, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(intDeviceType)) == true) { int MaxCount = 0; byte[] arayValid = new byte[63]; Array.Copy(CsConst.myRevBuf, 29, arayValid, 0, 63); for (int i = 0; i < 63; i++) { string strTmp = GlobalClass.AddLeftZero(Convert.ToString(arayValid[i], 2), 8); for (int j = 7; j >= 0; j--) { if (MaxCount >= 500) { break; } string str = strTmp.Substring(j, 1); strEnable = strEnable + str; } } } System.Diagnostics.Debug.WriteLine(strEnable.Length.ToString()); for (int i = 0; i < 1000; i++) { if (strEnable.Substring(i, 1) == "1") { ArayTmp = new byte[2]; ArayTmp[0] = Convert.ToByte((i + 1) / 256); ArayTmp[1] = Convert.ToByte((i + 1) % 256); if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x3516, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(intDeviceType)) == true) { MyCardInfo[i].UIDL = CsConst.myRevBuf[26]; Array.Copy(CsConst.myRevBuf, 27, MyCardInfo[i].UID, 0, 10); MyCardInfo[i].CardType = CsConst.myRevBuf[37]; MyCardInfo[i].BuildingNO = CsConst.myRevBuf[40] * 256 + CsConst.myRevBuf[41]; MyCardInfo[i].UnitNO = CsConst.myRevBuf[42] * 256 + CsConst.myRevBuf[43]; MyCardInfo[i].RoomNO = CsConst.myRevBuf[44] * 256 + CsConst.myRevBuf[45]; Array.Copy(CsConst.myRevBuf, 46, MyCardInfo[i].arayDate, 0, 5); Array.Copy(CsConst.myRevBuf, 51, MyCardInfo[i].arayName, 0, 10); Array.Copy(CsConst.myRevBuf, 61, MyCardInfo[i].arayPhone, 0, 11); byte[] arayRemark = new byte[18]; for (int intI = 0; intI < 18; intI++) { arayRemark[intI] = CsConst.myRevBuf[72 + intI]; } MyCardInfo[i].Remark = HDLPF.Byte2String(arayRemark); HDLUDP.TimeBetwnNext(1); } else { return(false); } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(10 + i, null); } } } MyRead2UpFlags[2] = true; #endregion } if (intActivePage == 0 || intActivePage == 4) { if (!CsConst.isRestore) { #region MyHistory = new List <History>(); ArayTmp = new byte[2]; ArayTmp[0] = 0; ArayTmp[1] = 1; if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x3512, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(intDeviceType)) == true) { if (CsConst.myRevBuf[25] == 0xF8) { HistoryCount = CsConst.myRevBuf[28] * 256 + CsConst.myRevBuf[29]; } else { HistoryCount = 0; } HDLUDP.TimeBetwnNext(1); if (HistoryCount > 0) { for (int i = num1; i <= num2; i++) { ArayTmp[0] = Convert.ToByte(i / 256); ArayTmp[1] = Convert.ToByte(i % 256); if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x3512, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(intDeviceType)) == true) { if (CsConst.myRevBuf[25] == 0xF8) { History temp = new History(); temp.ID = i; temp.arayDate = new byte[6]; Array.Copy(CsConst.myRevBuf, 30, temp.arayDate, 0, 6); temp.Type = CsConst.myRevBuf[36]; temp.arayInfo = new byte[25]; Array.Copy(CsConst.myRevBuf, 37, temp.arayInfo, 0, 25); MyHistory.Add(temp); HDLUDP.TimeBetwnNext(1); } else { return(false); } } else { return(false); } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(50 + (i - num1) * 40 / (num2 - num1), null); } } } } else { return(false); } #endregion } MyRead2UpFlags[3] = true; } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(40, null); } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(100, null); } return(true); }
/// <summary> ///上传设置 /// </summary> public bool UploadDSInfoToDevice(string DevName, int intDeviceType, int intActivePage) { string strMainRemark = DevName.Split('\\')[1].Trim().Split('(')[0].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[] ArayMain = new byte[20]; byte[] arayTmpRemark = HDLUDP.StringToByte(strMainRemark); byte[] arayTmp; if (arayTmpRemark.Length > 20) { Array.Copy(arayTmpRemark, 0, ArayMain, 0, 20); } else { Array.Copy(arayTmpRemark, 0, ArayMain, 0, arayTmpRemark.Length); } if (CsConst.isRestore) { if (CsConst.mySends.AddBufToSndList(ArayMain, 0x0010, bytSubID, bytDevID, false, true, true, false) == true) { HDLUDP.TimeBetwnNext(20); } else { return(false); } } if (intActivePage == 0 || intActivePage == 1) { #region if (strNO == "") { strNO = "0000"; } if (strPassword == "") { strPassword = "******"; } if (strNO.Length < 4) { strNO = GlobalClass.AddLeftZero(strNO, 4); } if (strPassword.Length < 4) { strPassword = GlobalClass.AddLeftZero(strPassword, 6); } arayTmp = HDLUDP.StringToByte(strNO + strPassword); if (CsConst.mySends.AddBufToSndList(arayTmp, 0x352F, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(intDeviceType)) == true) { HDLUDP.TimeBetwnNext(20); } else { return(false); } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(1, null); } if (CsConst.mySends.AddBufToSndList(arayBasic, 0x3527, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(intDeviceType)) == true) { HDLUDP.TimeBetwnNext(20); } else { return(false); } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(2, null); } arayTmp = new byte[2]; arayTmp[0] = arayInfo[0]; arayTmp[1] = arayInfo[1]; if (CsConst.mySends.AddBufToSndList(arayTmp, 0x350E, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(intDeviceType)) == true) { HDLUDP.TimeBetwnNext(20); } else { return(false); } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(3, null); } arayTmp = new byte[11]; Array.Copy(arayCall, 0, arayTmp, 0, 11); if (CsConst.mySends.AddBufToSndList(arayTmp, 0x138C, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(intDeviceType)) == true) { HDLUDP.TimeBetwnNext(20); } else { return(false); } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(4, null); } arayTmp = new byte[5]; Array.Copy(arayBrightness, 0, arayTmp, 0, 5); if (CsConst.mySends.AddBufToSndList(arayTmp, 0x353D, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(intDeviceType)) == true) { HDLUDP.TimeBetwnNext(20); } else { return(false); } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(5, null); } for (int i = 0; i < 4; i++) { arayTmp = new byte[12]; Array.Copy(arayPassword, i * 12, arayTmp, 0, 12); if (CsConst.mySends.AddBufToSndList(arayTmp, 0x3506, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(intDeviceType)) == true) { HDLUDP.TimeBetwnNext(20); } else { return(false); } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(5 + i, null); } } #endregion } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(10, null); } if (intActivePage == 0 || intActivePage == 2 || intActivePage == 5 || intActivePage == 6) { #region arayTmp = new byte[2]; arayTmp[0] = Convert.ToByte(RoomCount / 256); arayTmp[1] = Convert.ToByte(RoomCount % 256); if (CsConst.mySends.AddBufToSndList(arayTmp, 0x351E, bytSubID, bytDevID, false, true, true, false) == true) { HDLUDP.TimeBetwnNext(20); } else { return(false); } for (int i = 0; i < confiinfo.Count; i++) { if (intActivePage == 0 || intActivePage == 2 || intActivePage == 6) { RoomInfo temp = confiinfo[i]; arayTmp = new byte[30]; arayTmp[0] = Convert.ToByte(temp.ID / 256); arayTmp[1] = Convert.ToByte(temp.ID % 256); string strHex = temp.RoomNum.ToString("X2"); strHex = GlobalClass.AddLeftZero(strHex, 8); arayTmp[2] = Convert.ToByte(strHex.Substring(0, 2), 16); arayTmp[3] = Convert.ToByte(strHex.Substring(2, 2), 16); arayTmp[4] = Convert.ToByte(strHex.Substring(4, 2), 16); arayTmp[5] = Convert.ToByte(strHex.Substring(6, 2), 16); arayTmp[6] = 0; arayTmp[7] = 0; arayTmp[8] = 0; arayTmp[9] = 0; arayTmpRemark = HDLUDP.StringToByte(temp.Remark); if (arayTmpRemark.Length > 20) { Array.Copy(arayTmpRemark, 0, arayTmp, 10, 20); } else { Array.Copy(arayTmpRemark, 0, arayTmp, 10, arayTmpRemark.Length); } if (CsConst.mySends.AddBufToSndList(arayTmp, 0x3502, bytSubID, bytDevID, false, true, true, false) == true) { HDLUDP.TimeBetwnNext(20); } else { return(false); } } if (intActivePage == 0 || intActivePage == 5 || intActivePage == 6) { for (int j = 0; j < ImageList.Count; j++) { byte[] arayImageTmp = ImageList[j]; if (arayImageTmp[0] == Convert.ToByte(confiinfo[i].ID / 256) && arayImageTmp[1] == Convert.ToByte(confiinfo[i].ID % 256)) { if (arayImageTmp[322] == 1) { arayTmp = new byte[67]; arayTmp[0] = Convert.ToByte(confiinfo[i].ID / 256); arayTmp[1] = Convert.ToByte(confiinfo[i].ID % 256); for (byte k = 0; k < 5; k++) { arayTmp[2] = k; Array.Copy(arayImageTmp, k * 64, arayTmp, 3, 64); if (CsConst.mySends.AddBufToSndList(arayTmp, 0x3541, bytSubID, bytDevID, false, true, true, false) == true) { HDLUDP.TimeBetwnNext(20); } else { return(false); } } arayImageTmp[322] = 0; } break; } } } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(10 * i / confiinfo.Count + 10, null); } } #endregion } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(20, null); } if (intActivePage == 0 || intActivePage == 3) { #region if (CsConst.isRestore) { for (int i = 0; i < MyCardInfo.Count; i++) { if (MyCardInfo[i].CardType != 0 && MyCardInfo[i].CardType != 0xFF) { CardInfo tmp = MyCardInfo[i]; arayTmp = new byte[64]; arayTmp[0] = tmp.UIDL; Array.Copy(tmp.UID, 0, arayTmp, 1, tmp.UIDL); arayTmp[11] = tmp.CardType; arayTmp[12] = Convert.ToByte(tmp.CardNum / 256); arayTmp[13] = Convert.ToByte(tmp.CardNum % 256); arayTmp[14] = Convert.ToByte(tmp.BuildingNO / 256); arayTmp[15] = Convert.ToByte(tmp.BuildingNO % 256); arayTmp[16] = Convert.ToByte(tmp.UnitNO / 256); arayTmp[17] = Convert.ToByte(tmp.UnitNO % 256); arayTmp[18] = Convert.ToByte(tmp.RoomNO / 256); arayTmp[19] = Convert.ToByte(tmp.RoomNO % 256); Array.Copy(tmp.arayDate, 0, arayTmp, 20, tmp.arayDate.Length); Array.Copy(tmp.arayName, 0, arayTmp, 25, tmp.arayName.Length); Array.Copy(tmp.arayPhone, 0, arayTmp, 35, tmp.arayPhone.Length); arayTmpRemark = HDLUDP.StringToByte(tmp.Remark); if (arayTmpRemark.Length > 18) { Array.Copy(arayTmpRemark, 0, arayTmp, 46, 18); } else { Array.Copy(arayTmpRemark, 0, arayTmp, 46, arayTmpRemark.Length); } if (CsConst.mySends.AddBufToSndList(arayTmp, 0x3518, bytSubID, bytDevID, false, false, true, CsConst.minAllWirelessDeviceType.Contains(intDeviceType)) == true) { HDLUDP.TimeBetwnNext(20); } else { return(false); } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(20 + i, null); } } } } #endregion } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(100); } return(true); }
public void DownloadFloorheatingsettingFromDevice(Byte SubNetID, Byte DeviceID, int DeviceType, ref Byte[] AcTemperatureRange) { Byte[] ArayTmp = new byte[0]; // floor heating #region if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x1940, SubNetID, DeviceID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(DeviceType)) == true) { #region if (CsConst.mintNewDLPFHSetupDeviceType.Contains(DeviceType) || NormalPanelDeviceTypeList.WirelessSimpleFloorHeatingDeviceTypeList.Contains(DeviceType)) //新版读取设置的功能 { HeatEnable = CsConst.myRevBuf[25]; SourceTemp = CsConst.myRevBuf[26]; OutDoorParam = new byte[20]; Array.Copy(CsConst.myRevBuf, 27, OutDoorParam, 0, 8); SourceParam = new byte[20]; Array.Copy(CsConst.myRevBuf, 35, SourceParam, 0, 8); PIDEnable = CsConst.myRevBuf[43]; OutputType = CsConst.myRevBuf[44]; minPWM = CsConst.myRevBuf[45]; maxPWM = CsConst.myRevBuf[46]; Speed = CsConst.myRevBuf[47]; Cycle = CsConst.myRevBuf[48]; ModeAry = new byte[] { 0, 0, 0, 0, 0 }; string strTmp = GlobalClass.IntToBit(Convert.ToInt32(CsConst.myRevBuf[49]), 8); if (strTmp.Substring(7, 1) == "1") { ModeAry[0] = 1; } if (strTmp.Substring(6, 1) == "1") { ModeAry[1] = 1; } if (strTmp.Substring(5, 1) == "1") { ModeAry[2] = 1; } if (strTmp.Substring(4, 1) == "1") { ModeAry[3] = 1; } if (strTmp.Substring(3, 1) == "1") { ModeAry[4] = 1; } Switch = CsConst.myRevBuf[50]; TimeAry = new byte[4]; Array.Copy(CsConst.myRevBuf, 51, TimeAry, 0, 4); ProtectTemperature = CsConst.myRevBuf[55]; ControlMode = CsConst.myRevBuf[57]; HeatType = CsConst.myRevBuf[58]; SysEnable = new byte[4]; if (CsConst.myRevBuf[59] == 1) { SysEnable[0] = 1; } strTmp = GlobalClass.IntToBit(Convert.ToInt32(CsConst.myRevBuf[60]), 8); if (strTmp.Substring(7, 1) == "1") { SysEnable[1] = 1; } if (strTmp.Substring(6, 1) == "1") { SysEnable[2] = 1; } if (strTmp.Substring(5, 1) == "1") { SysEnable[3] = 1; } CompenValue = CsConst.myRevBuf[61]; CsConst.myRevBuf = new byte[1200]; CalculationModeTargets = new byte[40]; if (CsConst.mySends.AddBufToSndList(null, 0x1972, SubNetID, DeviceID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(DeviceType)) == true) //新版把目标独立出来 { Array.Copy(CsConst.myRevBuf, 25, CalculationModeTargets, 0, 33); CsConst.myRevBuf = new byte[1200]; //从机读取目标 RelayCommandGroup = new byte[33]; if (CsConst.mySends.AddBufToSndList(null, 0x1976, SubNetID, DeviceID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(DeviceType)) == true) //新版把目标独立出来 { Array.Copy(CsConst.myRevBuf, 25, RelayCommandGroup, 0, 33); } else { return; } CsConst.myRevBuf = new byte[1200]; HDLUDP.TimeBetwnNext(10); } else { return; } } else { HeatEnable = CsConst.myRevBuf[25]; RelayCommandGroup = new byte[33]; Array.Copy(CsConst.myRevBuf, 26, RelayCommandGroup, 0, 16); SourceTemp = CsConst.myRevBuf[42]; OutDoorParam = new byte[20]; Array.Copy(CsConst.myRevBuf, 43, OutDoorParam, 0, 8); SourceParam = new byte[20]; Array.Copy(CsConst.myRevBuf, 51, SourceParam, 0, 8); PIDEnable = CsConst.myRevBuf[59]; CsConst.myRevBuf = new byte[1200]; HDLUDP.TimeBetwnNext(10); } if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x1900, SubNetID, DeviceID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(DeviceType)) == true) // read temperature range { if (AcTemperatureRange == null) { AcTemperatureRange = new Byte[9]; } Array.Copy(CsConst.myRevBuf, 25, AcTemperatureRange, 0, 9); minTemp = CsConst.myRevBuf[34]; maxTemp = CsConst.myRevBuf[35]; CsConst.myRevBuf = new byte[1200]; HDLUDP.TimeBetwnNext(10); } else { return; } ReadFloorheatingAdvancedCommandsGroup(SubNetID, DeviceID, DeviceType); #endregion } else { return; } #endregion }
private void showHistory() { try { dgvHistory.Rows.Clear(); if (oNewDS == null) { return; } if (oNewDS.HistoryCount == 0) { lbHistoryCount.Text = oNewDS.HistoryCount.ToString(); lbTarget.Text = CsConst.mstrINIDefault.IniReadValue("Public", "99798", ""); txtFrm.Enabled = false; txtTo.Enabled = false; txtFrm.Text = "0"; txtTo.Text = "0"; } else { lbHistoryCount.Text = oNewDS.HistoryCount.ToString(); lbTarget.Text = CsConst.mstrINIDefault.IniReadValue("Public", "99798", "") + "(1-" + lbHistoryCount.Text + "):"; txtFrm.Enabled = true; txtTo.Enabled = true; btnSure.Enabled = true; if (Convert.ToInt32(txtTo.Text) > oNewDS.HistoryCount) { txtTo.Text = oNewDS.HistoryCount.ToString(); } if (Convert.ToInt32(txtFrm.Text) > oNewDS.HistoryCount) { txtFrm.Text = txtTo.Text; } if (Convert.ToInt32(txtFrm.Text) <= 0) { txtFrm.Text = "1"; } if (oNewDS.MyHistory == null) { return; } for (int i = 0; i < oNewDS.MyHistory.Count; i++) { NewDS.History temp = oNewDS.MyHistory[i]; string strTime = (temp.arayDate[0] + 2000).ToString() + "/" + temp.arayDate[1].ToString() + "/" + temp.arayDate[2].ToString() + " " + temp.arayDate[3].ToString("D2") + ":" + temp.arayDate[4].ToString("D2") + ":" + temp.arayDate[5].ToString("D2"); string strType = CsConst.mstrINIDefault.IniReadValue("Public", "00354", ""); strType = CsConst.mstrINIDefault.IniReadValue("Public", "0035" + (temp.Type - 1).ToString(), ""); string strInfo = ""; string strTmp = ""; if (temp.Type == 1) { strInfo = CsConst.mstrINIDefault.IniReadValue("Public", "0031" + temp.arayInfo[0].ToString(), "") + " " + CsConst.mstrINIDefault.IniReadValue("Public", "99797", "") + ":" + (temp.arayInfo[1] * 256 + temp.arayInfo[2]).ToString(); } else if (temp.Type == 2) { strInfo = CsConst.mstrINIDefault.IniReadValue("Public", "0032" + temp.arayInfo[1].ToString(), ""); } else if (temp.Type == 3) { for (int j = 0; j < temp.arayInfo[8]; j++) { if ((9 + j) < temp.arayInfo.Length) { strTmp = strTmp + GlobalClass.AddLeftZero(temp.arayInfo[9 + j].ToString("X"), 2); } } strInfo = CsConst.mstrINIDefault.IniReadValue("Public", "99796", "") + ":" + (temp.arayInfo[0] * 256 + temp.arayInfo[1]).ToString() + " " + CsConst.mstrINIDefault.IniReadValue("Public", "99795", "") + ":" + (temp.arayInfo[2] * 256 + temp.arayInfo[3]).ToString() + " " + CsConst.mstrINIDefault.IniReadValue("Public", "99794", "") + ":" + (temp.arayInfo[4] * 256 + temp.arayInfo[5]).ToString() + " " + CsConst.mstrINIDefault.IniReadValue("Public", "99797", "") + ":" + (temp.arayInfo[6] * 256 + temp.arayInfo[7]).ToString() + " " + "UID" + CsConst.mstrINIDefault.IniReadValue("Public", "99793", "") + ":" + temp.arayInfo[8].ToString() + " " + "UID" + CsConst.mstrINIDefault.IniReadValue("Public", "99792", "") + ":" + strTmp; } else if (temp.Type == 4) { if (temp.arayInfo[0] == 1) { strTmp = CsConst.mstrINIDefault.IniReadValue("Public", "00038", ""); } else if (temp.arayInfo[0] == 0) { strTmp = CsConst.mstrINIDefault.IniReadValue("Public", "00037", ""); } strInfo = CsConst.mstrINIDefault.IniReadValue("Public", "99791", "") + ":" + strTmp + " " + CsConst.mstrINIDefault.IniReadValue("Public", "99790", "") + ":" + CsConst.mstrINIDefault.IniReadValue("Public", "0033" + temp.arayInfo[1].ToString(), ""); } else if (temp.Type == 5) { strType = CsConst.mstrINIDefault.IniReadValue("Public", "00352", ""); strInfo = CsConst.mstrINIDefault.IniReadValue("Public", "99768", "") + ":" + CsConst.mstrINIDefault.IniReadValue("Public", "00354", ""); } else if (temp.Type == 10) { strInfo = CsConst.mstrINIDefault.IniReadValue("Public", "99789", "") + ":" + CsConst.mstrINIDefault.IniReadValue("Public", "0034" + temp.arayInfo[0].ToString(), ""); } object[] obj = new object[] { temp.ID.ToString(), strTime, strType, strInfo }; dgvHistory.Rows.Add(obj); } } } catch { } }
public Boolean UploadFloorheatingSettingToDevice(Byte SubNetID, Byte DeviceID, int DeviceType, Byte TemperatureType) { Boolean blnIsSuccess = true; #region byte[] arayTmp = new byte[44]; arayTmp[0] = HeatEnable; arayTmp[1] = SourceTemp; if (OutDoorParam == null) { OutDoorParam = new byte[8]; } Array.Copy(OutDoorParam, 0, arayTmp, 2, 8); if (SourceParam == null) { SourceParam = new byte[8]; } Array.Copy(SourceParam, 10, arayTmp, 10, 8); arayTmp[18] = PIDEnable; arayTmp[19] = OutputType; arayTmp[20] = minPWM; arayTmp[21] = maxPWM; arayTmp[22] = Speed; arayTmp[23] = Cycle; string str1 = "000"; string str2 = "0"; string str3 = "0"; string str4 = "0"; string str5 = "0"; string str6 = "0"; if (ModeAry == null) { ModeAry = new byte[5]; } if (ModeAry[0] == 1) { str2 = "1"; } if (ModeAry[1] == 1) { str3 = "1"; } if (ModeAry[2] == 1) { str4 = "1"; } if (ModeAry[3] == 1) { str5 = "1"; } if (ModeAry[4] == 1) { str6 = "1"; } string str = str1 + str2 + str3 + str4 + str5 + str6; arayTmp[24] = Convert.ToByte(GlobalClass.BitToInt(str)); arayTmp[25] = Switch; if (TimeAry == null) { TimeAry = new byte[4]; } Array.Copy(TimeAry, 0, arayTmp, 26, 4); arayTmp[30] = ProtectTemperature; arayTmp[32] = ControlMode; arayTmp[33] = HeatType; if (SysEnable == null) { SysEnable = new byte[4]; } arayTmp[34] = SysEnable[0]; str1 = "00000"; str2 = "0"; str3 = "0"; str4 = "0"; if (SysEnable[1] == 1) { str2 = "1"; } if (SysEnable[2] == 1) { str3 = "1"; } if (SysEnable[3] == 1) { str4 = "1"; } str = str1 + str2 + str3 + str4; arayTmp[35] = Convert.ToByte(GlobalClass.BitToInt(str)); arayTmp[36] = CompenValue; arayTmp[37] = DesSubnetID; arayTmp[38] = DesDeviceID; arayTmp[39] = Channel; arayTmp[40] = minTemp; arayTmp[41] = maxTemp; arayTmp[42] = TemperatureType; arayTmp[43] = Convert.ToByte(ID); if (CsConst.mySends.AddBufToSndList(arayTmp, 0x1942, SubNetID, DeviceID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(DeviceType)) == true) { CsConst.myRevBuf = new byte[1200]; } else { return(false); } HDLUDP.TimeBetwnNext(arayTmp.Length); #endregion return(blnIsSuccess); }
void calculationWorker_DoWork(object sender, DoWorkEventArgs e) { try { #region if (tempSend.IRCodes == null) { return; } Cursor.Current = Cursors.WaitCursor; List <string> listCode = new List <string>(); List <string> listRemark = new List <string>(); int RowIndex = dgvIR.CurrentRow.Index; int RowCount = dgvIR.RowCount; for (int i = 0; i < tvIR.Nodes.Count; i++) { if (tvIR.Nodes[i].Checked) { for (int j = 0; j < tvIR.Nodes[i].Nodes.Count; j++) { int DeviceID = Convert.ToInt32(tvIR.Nodes[i].Name); int KeyID = Convert.ToInt32(tvIR.Nodes[i].Nodes[j].Name); string strCodes = ""; for (int k = 0; k < tempSend.IRCodes.Count; k++) { if (tempSend.IRCodes[k].KeyID == KeyID && tempSend.IRCodes[k].IRLoation == DeviceID) { strCodes = tempSend.IRCodes[k].Codes; break; } } if (strCodes != "") { listCode.Add(strCodes); listRemark.Add(tvIR.Nodes[i].Text.ToString() + "-" + tvIR.Nodes[i].Nodes[j].Text.ToString()); } } } else { for (int j = 0; j < tvIR.Nodes[i].Nodes.Count; j++) { if (tvIR.Nodes[i].Nodes[j].Checked) { int DeviceID = Convert.ToInt32(tvIR.Nodes[i].Name); int KeyID = Convert.ToInt32(tvIR.Nodes[i].Nodes[j].Name); string strCodes = ""; for (int k = 0; k < tempSend.IRCodes.Count; k++) { if (tempSend.IRCodes[k].KeyID == KeyID && tempSend.IRCodes[k].IRLoation == DeviceID) { strCodes = tempSend.IRCodes[k].Codes; break; } } if (strCodes != "") { listCode.Add(strCodes); listRemark.Add(tvIR.Nodes[i].Text.ToString() + "-" + tvIR.Nodes[i].Nodes[j].Text.ToString()); } } } } } int CodeIndex = 0; int FirstIndex = dgvIR.CurrentRow.Index; if (MyBackGroup != null && MyBackGroup.IsBusy) { MyBackGroup.ReportProgress(0); } for (int i = RowIndex; i < RowCount; i++) { string strCodes = listCode[CodeIndex]; string[] ListData = new string[0]; if (strCodes.Contains(";")) { ListData = strCodes.Split(';'); } else { ListData = new string[1]; ListData[0] = strCodes; } byte[] arayCode = new byte[ListData.Length * 16]; for (int j = 0; j < ListData.Length; j++) { byte[] arayCodeTmp = GlobalClass.HexToByte(ListData[j]); Array.Copy(arayCodeTmp, 0, arayCode, 16 * j, 16); } byte[] arayTmp = new byte[3]; arayTmp[0] = Convert.ToByte(Convert.ToInt32(dgvIR[0, dgvIR.CurrentRow.Index].Value.ToString()) - 1); arayTmp[1] = arayCode[2]; arayTmp[2] = arayCode[3]; if (CsConst.mySends.AddBufToSndList(arayTmp, 0xD900, SubNetID, DevID, false, true, true, false) == true) { if (CsConst.myRevBuf[25] == 0xF8) { CsConst.myRevBuf = new byte[1200]; for (int j = 0; j < ListData.Length; j++) { arayTmp = new byte[16]; Array.Copy(arayCode, j * 16, arayTmp, 0, 16); if (CsConst.mySends.AddBufToSndList(arayTmp, 0xD906, SubNetID, DevID, false, true, true, false) == true) { CsConst.myRevBuf = new byte[1200]; } else { return; } HDLUDP.TimeBetwnNext(20); } arayTmp = new byte[12]; arayTmp[0] = Convert.ToByte(Convert.ToInt32(dgvIR[0, dgvIR.CurrentRow.Index].Value.ToString()) - 1); arayTmp[1] = 0; string strRemark = listRemark[CodeIndex]; byte[] arayTmpRemark = HDLUDP.StringToByte(strRemark); if (arayTmpRemark.Length >= 10) { Array.Copy(arayTmpRemark, 0, arayTmp, 2, 10); } else { Array.Copy(arayTmpRemark, 0, arayTmp, 2, arayTmpRemark.Length); } if (CsConst.mySends.AddBufToSndList(arayTmp, 0xD90E, SubNetID, DevID, false, true, true, false) == true) { CsConst.myRevBuf = new byte[1200]; } else { return; } HDLUDP.TimeBetwnNext(arayTmp.Length); arayTmp = new byte[12]; arayTmp[0] = Convert.ToByte(Convert.ToInt32(dgvIR[0, dgvIR.CurrentRow.Index].Value.ToString()) - 1); arayTmp[1] = 1; if (arayTmpRemark.Length >= 20) { Array.Copy(arayTmpRemark, 10, arayTmp, 2, 10); } else if (arayTmpRemark.Length > 10 && arayTmpRemark.Length < 20) { Array.Copy(arayTmpRemark, 10, arayTmp, 2, arayTmpRemark.Length - 10); } if (CsConst.mySends.AddBufToSndList(arayTmp, 0xD90E, SubNetID, DevID, false, true, true, false) == true) { CsConst.myRevBuf = new byte[1200]; } else { return; } dgvIR.Rows[FirstIndex + CodeIndex].Cells[1].Value = strRemark; dgvIR.Rows[FirstIndex + CodeIndex].Cells[2].Value = CsConst.mstrINIDefault.IniReadValue("public", "00042", ""); CodeIndex = CodeIndex + 1; dgvIR.Rows[FirstIndex + CodeIndex].Selected = true; this.dgvIR.CurrentCell = this.dgvIR.Rows[FirstIndex + CodeIndex].Cells[0]; if (isStopDownloadCodes) { break; } if (CodeIndex >= listCode.Count) { break; } } } else { break; } if (MyBackGroup != null && MyBackGroup.IsBusy) { MyBackGroup.ReportProgress(i * 90 / RowCount); } } if (btnFree.Visible) { btnFree_Click(null, null); } #endregion } catch { } }
public Boolean DownloadFloorheatingsettingFromDevice(Byte SubNetID, Byte DeviceID, int DeviceType) { Byte[] ArayTmp = new byte[1] { (Byte)ID }; try { // floor heating #region if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x1940, SubNetID, DeviceID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(DeviceType)) == true) { AdvancedCommands = new UVCMD.ControlTargets[8]; HeatEnable = CsConst.myRevBuf[25]; SourceTemp = CsConst.myRevBuf[26]; OutDoorParam = new byte[20]; Array.Copy(CsConst.myRevBuf, 27, OutDoorParam, 0, 8); SourceParam = new byte[20]; Array.Copy(CsConst.myRevBuf, 35, SourceParam, 0, 8); PIDEnable = CsConst.myRevBuf[43]; OutputType = CsConst.myRevBuf[44]; minPWM = CsConst.myRevBuf[45]; maxPWM = CsConst.myRevBuf[46]; Speed = CsConst.myRevBuf[47]; Cycle = CsConst.myRevBuf[48]; ModeAry = new byte[] { 0, 0, 0, 0, 0 }; string strTmp = GlobalClass.IntToBit(Convert.ToInt32(CsConst.myRevBuf[49]), 8); if (strTmp.Substring(7, 1) == "1") { ModeAry[0] = 1; } if (strTmp.Substring(6, 1) == "1") { ModeAry[1] = 1; } if (strTmp.Substring(5, 1) == "1") { ModeAry[2] = 1; } if (strTmp.Substring(4, 1) == "1") { ModeAry[3] = 1; } if (strTmp.Substring(3, 1) == "1") { ModeAry[4] = 1; } Switch = CsConst.myRevBuf[50]; TimeAry = new byte[4]; Array.Copy(CsConst.myRevBuf, 51, TimeAry, 0, 4); ProtectTemperature = CsConst.myRevBuf[55]; ControlMode = CsConst.myRevBuf[57]; HeatType = CsConst.myRevBuf[58]; SysEnable = new byte[4]; if (CsConst.myRevBuf[59] == 1) { SysEnable[0] = 1; } strTmp = GlobalClass.IntToBit(Convert.ToInt32(CsConst.myRevBuf[60]), 8); if (strTmp.Substring(7, 1) == "1") { SysEnable[1] = 1; } if (strTmp.Substring(6, 1) == "1") { SysEnable[2] = 1; } if (strTmp.Substring(5, 1) == "1") { SysEnable[3] = 1; } CompenValue = CsConst.myRevBuf[61]; DesSubnetID = CsConst.myRevBuf[62]; DesDeviceID = CsConst.myRevBuf[63]; Channel = CsConst.myRevBuf[64]; minTemp = CsConst.myRevBuf[65]; maxTemp = CsConst.myRevBuf[66]; CsConst.myRevBuf = new byte[1200]; } else { return(false); } CalculationModeTargets = new byte[40]; if (CsConst.isRestore) { ReadSalveChannelWhenSlaveMode(SubNetID, DeviceID, DeviceType); } #endregion } catch { return(false); } return(true); }
private void btnSure_Click(object sender, EventArgs e) { try { int wdMaxValue = 33; setAllControlVisible(false); Cursor.Current = Cursors.WaitCursor; dgvCommand.Rows.Clear(); btnSure.Enabled = false; byte bytFrm = Convert.ToByte(Convert.ToInt32(txtFrm.Text)); byte bytTo = Convert.ToByte(txtTo.Text); int CMD = 0xE424; if (Type == 1) { CMD = 0xE424; } else if (Type == 2) { CMD = 0xDA65; } for (byte byt = bytFrm; byt <= bytTo; byt++) { byte[] ArayTmp = new byte[2]; ArayTmp[0] = Convert.ToByte(CommandID); ArayTmp[1] = Convert.ToByte(byt); if (CsConst.mySends.AddBufToSndList(ArayTmp, CMD, SubNetID, DevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(MyintDeviceType)) == true) { string strTime = CsConst.WholeTextsList[1775].sDisplayName; if (1 <= CsConst.myRevBuf[28] && CsConst.myRevBuf[28] <= 8) { strTime = CsConst.strAryRS232Time[CsConst.myRevBuf[28] - 1]; } string strType = CsConst.WholeTextsList[1775].sDisplayName; string strCMD = ""; string strEnd = cbEndChar.Items[0].ToString(); byte[] arayCMD = new byte[wdMaxValue + 1]; Array.Copy(CsConst.myRevBuf, 30, arayCMD, 0, arayCMD.Length); if (CsConst.myRevBuf[29] == 0) { strType = CsConst.mstrINIDefault.IniReadValue("public", "99838", ""); int Count = arayCMD[arayCMD.Length - 1]; byte[] arayTmp = new byte[Count]; Array.Copy(arayCMD, 0, arayTmp, 0, Count); strCMD = HDLPF.Byte2String(arayTmp); if (arayTmp.Length > 2 && arayTmp[arayTmp.Length - 1] == 0x0A && arayTmp[arayTmp.Length - 2] == 0x0D) { strEnd = cbEndChar.Items[2].ToString(); } else if (arayTmp.Length > 1 && arayTmp[arayTmp.Length - 1] == 0x0D) { strEnd = cbEndChar.Items[1].ToString(); } } else if (CsConst.myRevBuf[29] == 1) { strType = CsConst.mstrINIDefault.IniReadValue("public", "99839", ""); int Count = arayCMD[arayCMD.Length - 1]; for (int j = 0; j < Count; j++) { strCMD = strCMD + GlobalClass.AddLeftZero(arayCMD[j].ToString("X"), 2) + " "; } } object[] obj = new object[] { byt.ToString(), strTime, strType, strCMD, strEnd }; dgvCommand.Rows.Add(obj); HDLUDP.TimeBetwnNext(1); } else { break; } } } catch { } btnSure.Enabled = true; Cursor.Current = Cursors.Default; }
private void btnRefAC_Click(object sender, EventArgs e) { try { Cursor.Current = Cursors.WaitCursor; if (cbACNO.SelectedIndex < 0) { cbACNO.SelectedIndex = 0; } byte[] arayTmp = new byte[1]; arayTmp[0] = Convert.ToByte(cbACNO.SelectedIndex + 1); if (CsConst.mySends.AddBufToSndList(arayTmp, 0x1938, SubNetID, DevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(MyintDeviceType)) == true) { if (CsConst.myRevBuf[26] == 0) { sbCoolTemp.Minimum = 0; sbHeatTemp.Minimum = 0; sbAutoTemp.Minimum = 0; sbDryTemp.Minimum = 0; sbCoolTemp.Maximum = 30; sbHeatTemp.Maximum = 30; sbAutoTemp.Maximum = 30; sbDryTemp.Maximum = 30; strTest = "C"; } else if (CsConst.myRevBuf[26] == 1) { sbCoolTemp.Minimum = 32; sbHeatTemp.Minimum = 32; sbAutoTemp.Minimum = 32; sbDryTemp.Minimum = 32; sbCoolTemp.Maximum = 86; sbHeatTemp.Maximum = 86; sbAutoTemp.Maximum = 86; sbDryTemp.Maximum = 86; strTest = "F"; } lbCurTempValue.Text = CsConst.myRevBuf[27].ToString() + strTest; sbCoolTemp.Value = CsConst.myRevBuf[28]; sbHeatTemp.Value = CsConst.myRevBuf[29]; sbAutoTemp.Value = CsConst.myRevBuf[30]; sbDryTemp.Value = CsConst.myRevBuf[31]; string strRunnig = ""; string strTmp = GlobalClass.IntToBit(Convert.ToInt32(CsConst.myRevBuf[32]), 8); string str1 = strTmp.Substring(0, 4); string str2 = strTmp.Substring(4, 4); int intTmp = GlobalClass.BitToInt(str1); if (intTmp == 0) { strRunnig = CsConst.mstrINIDefault.IniReadValue("Public", "00050", ""); } else if (intTmp == 1) { strRunnig = CsConst.mstrINIDefault.IniReadValue("Public", "00051", ""); } else if (intTmp == 2) { strRunnig = CsConst.mstrINIDefault.IniReadValue("Public", "00052", ""); } else if (intTmp == 3) { strRunnig = CsConst.mstrINIDefault.IniReadValue("Public", "00053", ""); } else if (intTmp == 4) { strRunnig = CsConst.mstrINIDefault.IniReadValue("Public", "00054", ""); } intTmp = GlobalClass.BitToInt(str2); if (intTmp == 0) { strRunnig = strRunnig + "," + CsConst.mstrINIDefault.IniReadValue("Public", "00060", ""); } else if (intTmp == 1) { strRunnig = strRunnig + "," + CsConst.mstrINIDefault.IniReadValue("Public", "00061", ""); } else if (intTmp == 2) { strRunnig = strRunnig + "," + CsConst.mstrINIDefault.IniReadValue("Public", "00062", ""); } else if (intTmp == 3) { strRunnig = strRunnig + "," + CsConst.mstrINIDefault.IniReadValue("Public", "00063", ""); } lbRunningValue.Text = strRunnig; cbACPower.SelectedIndex = CsConst.myRevBuf[33]; cbMode.SelectedIndex = CsConst.myRevBuf[34]; cbFanSpeed.SelectedIndex = CsConst.myRevBuf[35]; } } catch { } Cursor.Current = Cursors.Default; }
private void dgvFilter_CellValueChanged(object sender, DataGridViewCellEventArgs e) { try { if (myIPModule == null) { return; } if (myIPModule.MyBlocks == null) { return; } if ((e.RowIndex == -1) || (e.ColumnIndex == -1)) { return; } if (dgvFilter[e.ColumnIndex, e.RowIndex].Value == null) { return; } if (dgvFilter.SelectedRows.Count == 0) { return; } if (isRead) { return; } if (dgvFilter[e.ColumnIndex, e.RowIndex].Value == null) { dgvFilter[e.ColumnIndex, e.RowIndex].Value = ""; } for (int i = 0; i < dgvFilter.SelectedRows.Count; i++) { dgvFilter.SelectedRows[i].Cells[e.ColumnIndex].Value = dgvFilter[e.ColumnIndex, e.RowIndex].Value.ToString(); string strTmp = ""; string strEnable = "00000"; switch (e.ColumnIndex) { case 1: if (dgvFilter[1, dgvFilter.SelectedRows[i].Index].Value.ToString().ToLower() == "true") { myIPModule.MyBlocks[dgvFilter.SelectedRows[i].Index].isEnable = 1; } else { myIPModule.MyBlocks[dgvFilter.SelectedRows[i].Index].isEnable = 0; } break; case 2: string str1 = "0"; string str2 = "0"; if (dgvFilter[5, dgvFilter.SelectedRows[i].Index].Value.ToString().ToLower() == "true") { str1 = "1"; } if (dgvFilter[7, dgvFilter.SelectedRows[i].Index].Value.ToString().ToLower() == "true") { str2 = "1"; } if (dgvFilter[2, dgvFilter.SelectedRows[i].Index].Value.ToString().ToLower() == "true") { strEnable = strEnable + str2 + str1 + "1"; } else { strEnable = strEnable + str2 + str1 + "0"; } myIPModule.MyBlocks[dgvFilter.SelectedRows[i].Index].blockType = Convert.ToByte(GlobalClass.BitToInt(strEnable)); break; case 3: strTmp = dgvFilter[3, dgvFilter.SelectedRows[i].Index].Value.ToString(); myIPModule.MyBlocks[dgvFilter.SelectedRows[i].Index].sourceSubnetID = byte.Parse(HDLPF.IsNumStringMode(strTmp, 0, 255)); break; case 4: strTmp = dgvFilter[4, dgvFilter.SelectedRows[i].Index].Value.ToString(); myIPModule.MyBlocks[dgvFilter.SelectedRows[i].Index].sourceDeviceID = byte.Parse(HDLPF.IsNumStringMode(strTmp, 0, 255)); break; case 5: str1 = "0"; str2 = "0"; if (dgvFilter[2, dgvFilter.SelectedRows[i].Index].Value.ToString().ToLower() == "true") { str1 = "1"; } if (dgvFilter[7, dgvFilter.SelectedRows[i].Index].Value.ToString().ToLower() == "true") { str2 = "1"; } if (dgvFilter[5, dgvFilter.SelectedRows[i].Index].Value.ToString().ToLower() == "true") { strEnable = strEnable + str2 + "1" + str1; } else { strEnable = strEnable + str2 + "0" + str1; } myIPModule.MyBlocks[dgvFilter.SelectedRows[i].Index].blockType = Convert.ToByte(GlobalClass.BitToInt(strEnable)); break; case 6: strTmp = dgvFilter[6, dgvFilter.SelectedRows[i].Index].Value.ToString(); myIPModule.MyBlocks[dgvFilter.SelectedRows[i].Index].command = Convert.ToInt32(strTmp, 16); break; case 7: str1 = "0"; str2 = "0"; if (dgvFilter[2, dgvFilter.SelectedRows[i].Index].Value.ToString().ToLower() == "true") { str1 = "1"; } if (dgvFilter[5, dgvFilter.SelectedRows[i].Index].Value.ToString().ToLower() == "true") { str2 = "1"; } if (dgvFilter[7, dgvFilter.SelectedRows[i].Index].Value.ToString().ToLower() == "true") { strEnable = strEnable + "1" + str2 + str1; } else { strEnable = strEnable + "0" + str2 + str1; } myIPModule.MyBlocks[dgvFilter.SelectedRows[i].Index].blockType = Convert.ToByte(GlobalClass.BitToInt(strEnable)); break; case 8: strTmp = dgvFilter[8, dgvFilter.SelectedRows[i].Index].Value.ToString(); myIPModule.MyBlocks[dgvFilter.SelectedRows[i].Index].destSubnetID = byte.Parse(HDLPF.IsNumStringMode(strTmp, 0, 255)); break; case 9: strTmp = dgvFilter[8, dgvFilter.SelectedRows[i].Index].Value.ToString(); myIPModule.MyBlocks[dgvFilter.SelectedRows[i].Index].destDeviceID = byte.Parse(HDLPF.IsNumStringMode(strTmp, 0, 255)); break; } } if (e.RowIndex == 1) { if (dgvFilter[1, e.RowIndex].Value.ToString().ToLower() == "true") { myIPModule.MyBlocks[e.RowIndex].isEnable = 1; } else { myIPModule.MyBlocks[e.RowIndex].isEnable = 0; } } else if (e.ColumnIndex == 2) { string strEnable = "00000"; string str1 = "0"; string str2 = "0"; if (dgvFilter[5, e.RowIndex].Value.ToString().ToLower() == "true") { str1 = "1"; } if (dgvFilter[7, e.RowIndex].Value.ToString().ToLower() == "true") { str2 = "1"; } if (dgvFilter[2, e.RowIndex].Value.ToString().ToLower() == "true") { strEnable = strEnable + str2 + str1 + "1"; } else { strEnable = strEnable + str2 + str1 + "0"; } myIPModule.MyBlocks[e.RowIndex].blockType = Convert.ToByte(GlobalClass.BitToInt(strEnable)); } else if (e.ColumnIndex == 3) { string strTmp = dgvFilter[3, e.RowIndex].Value.ToString(); myIPModule.MyBlocks[e.RowIndex].sourceSubnetID = byte.Parse(HDLPF.IsNumStringMode(strTmp, 0, 255)); } else if (e.ColumnIndex == 4) { string strTmp = dgvFilter[4, e.RowIndex].Value.ToString(); myIPModule.MyBlocks[e.RowIndex].sourceDeviceID = byte.Parse(HDLPF.IsNumStringMode(strTmp, 0, 255)); } else if (e.ColumnIndex == 5) { string strEnable = "00000"; string str1 = "0"; string str2 = "0"; if (dgvFilter[2, e.RowIndex].Value.ToString().ToLower() == "true") { str1 = "1"; } if (dgvFilter[7, e.RowIndex].Value.ToString().ToLower() == "true") { str2 = "1"; } if (dgvFilter[5, e.RowIndex].Value.ToString().ToLower() == "true") { strEnable = strEnable + str2 + "1" + str1; } else { strEnable = strEnable + str2 + "0" + str1; } myIPModule.MyBlocks[e.RowIndex].blockType = Convert.ToByte(GlobalClass.BitToInt(strEnable)); } else if (e.ColumnIndex == 6) { string strTmp = dgvFilter[6, e.RowIndex].Value.ToString(); myIPModule.MyBlocks[e.RowIndex].command = Convert.ToInt32(strTmp, 16); } else if (e.ColumnIndex == 7) { string strEnable = "00000"; string str1 = "0"; string str2 = "0"; if (dgvFilter[2, e.RowIndex].Value.ToString().ToLower() == "true") { str1 = "1"; } if (dgvFilter[5, e.RowIndex].Value.ToString().ToLower() == "true") { str2 = "1"; } if (dgvFilter[7, e.RowIndex].Value.ToString().ToLower() == "true") { strEnable = strEnable + "1" + str2 + str1; } else { strEnable = strEnable + "0" + str2 + str1; } myIPModule.MyBlocks[e.RowIndex].blockType = Convert.ToByte(GlobalClass.BitToInt(strEnable)); } else if (e.ColumnIndex == 8) { string strTmp = dgvFilter[8, e.RowIndex].Value.ToString(); myIPModule.MyBlocks[e.RowIndex].destSubnetID = byte.Parse(HDLPF.IsNumStringMode(strTmp, 0, 255)); } else if (e.ColumnIndex == 9) { string strTmp = dgvFilter[9, e.RowIndex].Value.ToString(); myIPModule.MyBlocks[e.RowIndex].destDeviceID = byte.Parse(HDLPF.IsNumStringMode(strTmp, 0, 255)); } } catch { } }
public Boolean UploadFloorheatingSettingToDevice(Byte SubNetID, Byte DeviceID, int DeviceType, Byte[] AcTemperatureRange) { Boolean blnIsSuccess = true; try { #region if (CsConst.mintDLPDeviceType.Contains(DeviceType) || NormalPanelDeviceTypeList.WirelessSimpleFloorHeatingDeviceTypeList.Contains(DeviceType)) { if (DeviceType != 176) { byte[] arayTmp = new byte[38]; arayTmp[0] = HeatEnable; arayTmp[1] = SourceTemp; if (OutDoorParam == null) { OutDoorParam = new byte[8]; } Array.Copy(OutDoorParam, 0, arayTmp, 2, 8); if (SourceParam == null) { SourceParam = new byte[8]; } Array.Copy(SourceParam, 0, arayTmp, 10, 8); arayTmp[18] = PIDEnable; arayTmp[19] = OutputType; arayTmp[20] = minPWM; arayTmp[21] = maxPWM; arayTmp[22] = Speed; arayTmp[23] = Cycle; string str1 = "000"; string str2 = "0"; string str3 = "0"; string str4 = "0"; string str5 = "0"; string str6 = "0"; if (ModeAry == null) { ModeAry = new byte[5]; } if (ModeAry[0] == 1) { str2 = "1"; } if (ModeAry[1] == 1) { str3 = "1"; } if (ModeAry[2] == 1) { str4 = "1"; } if (ModeAry[3] == 1) { str5 = "1"; } if (ModeAry[4] == 1) { str6 = "1"; } string str = str1 + str2 + str3 + str4 + str5 + str6; arayTmp[24] = Convert.ToByte(GlobalClass.BitToInt(str)); arayTmp[25] = Switch; if (TimeAry == null) { TimeAry = new byte[4]; } Array.Copy(TimeAry, 0, arayTmp, 26, 4); arayTmp[30] = ProtectTemperature; arayTmp[32] = ControlMode; arayTmp[33] = HeatType; if (SysEnable == null) { SysEnable = new byte[4]; } arayTmp[34] = SysEnable[0]; str1 = "00000"; str2 = "0"; str3 = "0"; str4 = "0"; if (SysEnable[1] == 1) { str2 = "1"; } if (SysEnable[2] == 1) { str3 = "1"; } if (SysEnable[3] == 1) { str4 = "1"; } str = str1 + str2 + str3 + str4; arayTmp[35] = Convert.ToByte(GlobalClass.BitToInt(str)); arayTmp[36] = CompenValue; if (CsConst.mySends.AddBufToSndList(arayTmp, 0x1942, SubNetID, DeviceID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(DeviceType)) == true) { CsConst.myRevBuf = new byte[1200]; } else { return(false); } HDLUDP.TimeBetwnNext(arayTmp.Length); if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(61); } blnIsSuccess = ModifyTemperatureRange(SubNetID, DeviceID, DeviceType, AcTemperatureRange); } } #endregion } catch { return(blnIsSuccess); } return(blnIsSuccess); }
/// <summary> /// 获取ReportHeader /// </summary> /// <param name="data"></param> /// <returns></returns> public string GetReportHeader(string data) { return(GetReportHeader(GlobalClass.HexToByte(data))); }
private void showBasicInfo() { isRead = true; try { txtCallNum.Text = oNewDS.strNO; txtPassword.Text = oNewDS.strPassword; chbSound.Checked = (oNewDS.arayBasic[4] == 1); for (int i = 0; i < 4; i++) { System.Windows.Forms.Panel temp = this.Controls.Find("pnlC" + (i + 1).ToString(), true)[0] as System.Windows.Forms.Panel; switch (oNewDS.arayBasic[i]) { case 1: temp.BackColor = Color.Red; break; case 2: temp.BackColor = Color.FromArgb(0, 255, 0); break; case 3: temp.BackColor = Color.FromArgb(0, 0, 255); break; case 4: temp.BackColor = Color.Yellow; break; case 5: temp.BackColor = Color.Cyan; break; case 6: temp.BackColor = Color.Purple; break; case 7: temp.BackColor = Color.White; break; } } txtRelay.Text = oNewDS.arayInfo[0].ToString(); cbRelay.SelectedIndex = oNewDS.arayInfo[1]; byte[] arayTmp = new byte[4]; Array.Copy(oNewDS.arayCall, 0, arayTmp, 0, 4); txtZone.Text = GlobalClass.AddLeftZero(HDLPF.Byte2String(arayTmp), 4); chb1.Checked = (oNewDS.arayCall[4] == 1); txtConn.Text = oNewDS.arayCall[5].ToString(); chb2.Checked = (oNewDS.arayCall[6] == 1); ip1.Text = oNewDS.arayCall[7].ToString() + "." + oNewDS.arayCall[8].ToString() + "." + oNewDS.arayCall[9].ToString() + "." + oNewDS.arayCall[10].ToString(); if (oNewDS.arayInfo[2] <= 90) { sbSensitivity.Value = oNewDS.arayInfo[2]; } sbSensitivity_ValueChanged(null, null); if (1 <= oNewDS.arayInfo[3] && oNewDS.arayInfo[3] <= 11) { cbBell.SelectedIndex = (oNewDS.arayInfo[3] - 1); } if (cbBell.SelectedIndex < 0) { cbBell.SelectedIndex = 0; } txtLux.Text = (oNewDS.arayInfo[5] * 256 + oNewDS.arayInfo[6]).ToString(); luLuxValue.Text = (oNewDS.arayInfo[7] * 256 + oNewDS.arayInfo[8]).ToString(); sbLcdLimit.Value = oNewDS.arayInfo[9]; chbCardEnable.Checked = (oNewDS.bEnableCard == 1); } catch { } isRead = false; }