private void btnRead1A_Click(object sender, EventArgs e) { if (numSub.Value == 255 || numDevA.Value == 255) { return; } Cursor.Current = Cursors.WaitCursor; byte bytSub = Convert.ToByte(numSub.Value); byte bytDev = Convert.ToByte(numDevA.Value); byte[] ArayTmp = null; MbytFlag = 1; if (CsConst.mySends.AddBufToSndList(ArayTmp, 0xF81A, bytSub, bytDev, false, false, false, false) == true) { byte[] arayRemark = new byte[20]; for (int intI = 0; intI < 20; intI++) { arayRemark[intI] = CsConst.myRevBuf[25 + intI]; } lbModelVA.Text = HDLPF.Byte2String(arayRemark); CsConst.myRevBuf = new byte[1200]; } Cursor.Current = Cursors.Default; }
private Boolean ReadServerURLInformation() { Boolean blnIsSuccess = false; try { Byte[] ArayTmp = null; if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x3020, bytSubID, bytDevID, false, true, true, false) == true) { ArayTmp = new Byte[68]; Array.Copy(CsConst.myRevBuf, 25, ArayTmp, 0, 68); URL.Text = HDLPF.Byte2String(ArayTmp); CsConst.myRevBuf = new byte[1200]; blnIsSuccess = true; } else { blnIsSuccess = false; } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } return(blnIsSuccess); }
public Boolean ReadButtonRemark(byte SubNetID, byte DeviceID, int DeviceType, bool isShowMessage) { try { byte[] ArayTmp = null; int CMD = 0xE004; if (EnviroNewDeviceTypeList.EnviroNewPanelDeviceTypeList.Contains(DeviceType)) { ArayTmp = new byte[4]; ArayTmp[0] = Convert.ToByte(ID + 1); ArayTmp[1] = 5; ArayTmp[2] = 0; ArayTmp[3] = 9; } //读取备注 if (CsConst.mySends.AddBufToSndList(ArayTmp, CMD, SubNetID, DeviceID, false, isShowMessage, true, CsConst.minAllWirelessDeviceType.Contains(DeviceType)) == true) { byte[] arayRemark = new byte[20]; Array.Copy(CsConst.myRevBuf, 26, arayRemark, 0, 20); Remark = HDLPF.Byte2String(arayRemark); HDLUDP.TimeBetwnNext(1); } else { return(false); } } catch { return(false); } return(true); }
private void showBasicInfo() { try { isRead = true; if (MyMHIC == null) { return; } sb1.Value = MyMHIC.Backlight; sb2.Value = MyMHIC.Ledlight; byte[] arayRemark = new byte[8]; Array.Copy(MyMHIC.arayHotel, 0, arayRemark, 0, 8); txtName.Text = HDLPF.Byte2String(arayRemark); txtBuilding.Text = GlobalClass.AddLeftZero(MyMHIC.arayHotel[8].ToString("X"), 2); txtStorey.Text = GlobalClass.AddLeftZero(MyMHIC.arayHotel[9].ToString("X"), 2); txtRoom.Text = GlobalClass.AddLeftZero(MyMHIC.arayHotel[10].ToString("X"), 2) + GlobalClass.AddLeftZero(MyMHIC.arayHotel[11].ToString("X"), 2); chbEnable.Checked = (MyMHIC.arayHotel[12] == 1); } catch { } isRead = false; }
private void DisplayIPProjectInformation(Byte[] RevData) { byte[] arayRemark = new byte[20]; HDLSysPF.CopyRemarkBufferFrmMyRevBuffer(RevData, arayRemark, 26); this.strGrpName = HDLPF.Byte2String(arayRemark); arayRemark = new byte[20]; HDLSysPF.CopyRemarkBufferFrmMyRevBuffer(RevData, arayRemark, 46); this.strProName = HDLPF.Byte2String(arayRemark); arayRemark = new byte[8]; for (int intI = 0; intI < 8; intI++) { arayRemark[intI] = RevData[66 + intI]; } this.strUser = HDLPF.Byte2String(arayRemark); arayRemark = new byte[8]; for (int intI = 0; intI < 8; intI++) { arayRemark[intI] = RevData[74 + intI]; } this.strPWD = HDLPF.Byte2String(arayRemark); cbType.SelectedIndex = this.ConnetionType; tbGroup.Text = this.strGrpName; tbProject.Text = this.strProName; tbUser.Text = this.strUser; tbPWD.Text = this.strPWD; CsConst.myRevBuf = new byte[1200]; }
public bool DownLoadInfoFrmDevice(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 false; } else { byte[] arayRemark = new byte[20]; for (int intI = 0; intI < 20; intI++) { arayRemark[intI] = CsConst.myRevBuf[25 + intI]; } DeviceName = bytSubID.ToString() + "-" + bytDevID.ToString() + "\\" + HDLPF.Byte2String(arayRemark); CsConst.myRevBuf = new byte[1200]; } if (CsConst.isRestore) { num1 = 1; num2 = 64; } if (intActivePage == 0 || intActivePage == 1) { myACSetting = new List<ThirdPartAC>(); for (int i = num1; i <= num2; i++) { ArayTmp = new byte[1]; ArayTmp[0] = Convert.ToByte(i); if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x0240, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(wdDeviceType)) == true) { ThirdPartAC temp = new ThirdPartAC(); temp.ID = Convert.ToByte(i); temp.ACNO = CsConst.myRevBuf[26]; temp.Enable = CsConst.myRevBuf[27]; temp.CoolMasterAddress = CsConst.myRevBuf[28]; temp.GroupID = CsConst.myRevBuf[29]; temp.arayACinfo = new byte[10]; Array.Copy(CsConst.myRevBuf, 30, temp.arayACinfo, 0, 10); CsConst.myRevBuf = new byte[1200]; HDLUDP.TimeBetwnNext(ArayTmp.Length); if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x0244, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(wdDeviceType)) == true) { byte[] arayRemark = new byte[20]; Array.Copy(CsConst.myRevBuf, 26, arayRemark, 0, 20); temp.Remark = HDLPF.Byte2String(arayRemark); CsConst.myRevBuf = new byte[1200]; HDLUDP.TimeBetwnNext(ArayTmp.Length); } else return false; myACSetting.Add(temp); } else return false; if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) CsConst.calculationWorker.ReportProgress(i, null); } } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) CsConst.calculationWorker.ReportProgress(100, null); return true; }
private void ReadVersionOfSomeRow(int row, DataGridView dgv) { Cursor.Current = Cursors.WaitCursor; string strVersion = null; GetSubnetIdAndDeviceIdFromSelectedOnlineDevice(); int DeviceType = CsConst.myOnlines[currentSelectDeviceDindex].DeviceType; if (CsConst.mySends.AddBufToSndList(null, 0xEFFD, currentSelectDeviceSubnetId, currentSelectDeviceDeviceId, false, true, true, CsConst.mintWIFIDeviceType.Contains(DeviceType)) == true) { byte[] bytTmp = new byte[22]; for (int i = 0; i < 22; i++) { bytTmp[i] = CsConst.myRevBuf[i + 25]; } strVersion = HDLPF.Byte2String(bytTmp); if (strVersion == "MIRACLE") { strVersion = "V01.01"; } if (tabSim.SelectedTab.Name == "tabDev") { CsConst.myOnlines[currentSelectDeviceDindex].strVersion = strVersion; dgOnline[8, row].Value = strVersion; } } Cursor.Current = Cursors.Default; }
public String ReadButtonRemark(Byte SubNetID, Byte DeviceID, int DeviceType, int RemoteAddress) { String currentRemark = ""; Byte ExtraLength = 0; if (IPmoduleDeviceTypeList.RFIpModuleV2.Contains(DeviceType)) { ExtraLength = 1; } Byte[] ArayTmp = new Byte[1 + 1]; ArayTmp[0] = ID; if (ExtraLength != 0) { ArayTmp[1] = (Byte)RemoteAddress; } //读取备注 if (CsConst.mySends.AddBufToSndList(ArayTmp, 0xE004, SubNetID, DeviceID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(DeviceType)) == true) { byte[] arayRemark = new byte[20]; Array.Copy(CsConst.myRevBuf, 26, arayRemark, 0, 20); currentRemark = HDLPF.Byte2String(arayRemark); CsConst.myRevBuf = new byte[1200]; } return(currentRemark); }
public Boolean ReadNormalCurtainSetupInformation(Byte SubNetID, Byte DeviceID, Byte CurtainID, int wdDeviceType) { Boolean blnIsSuccess = true; Byte[] ArayTmp = new Byte[] { CurtainID }; int OperationCode = 0xF00E; if (CsConst.mySends.AddBufToSndList(ArayTmp, OperationCode, SubNetID, DeviceID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(wdDeviceType)) == true) { byte[] arayRemark = new byte[20]; HDLSysPF.CopyRemarkBufferFrmMyRevBuffer(CsConst.myRevBuf, arayRemark, 26); remark = HDLPF.Byte2String(arayRemark); CsConst.myRevBuf = new byte[1200]; } else { return(false); } OperationCode = 0xE800; if (CsConst.mySends.AddBufToSndList(ArayTmp, OperationCode, SubNetID, DeviceID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(wdDeviceType)) == true) { runTime = CsConst.myRevBuf[26] * 256 + CsConst.myRevBuf[27]; CsConst.myRevBuf = new byte[1200]; } else { return(false); } OperationCode = 0xE805; if (CsConst.mySends.AddBufToSndList(ArayTmp, OperationCode, SubNetID, DeviceID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(wdDeviceType)) == true) { onDelay = CsConst.myRevBuf[26] * 256 + CsConst.myRevBuf[27]; CsConst.myRevBuf = new byte[1200]; } else { return(false); } if (wdDeviceType != 707 && !(MS04DeviceTypeList.WirelessMS04WithOneCurtain.Contains(wdDeviceType))) //有开关延迟的 { if (CsConst.mySends.AddBufToSndList(ArayTmp, 0xE809, SubNetID, DeviceID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(wdDeviceType)) == true) { offDelay = CsConst.myRevBuf[26] * 256 + CsConst.myRevBuf[27]; CsConst.myRevBuf = new byte[1200]; } else { return(false); } } return(blnIsSuccess); }
private void ModifyCard() { try { NewDS.CardInfo temp = null; if (oNewDS != null) { temp = oNewDS.MyCardInfo[ID]; } else if (oDS != null) { temp = oDS.MyCardInfo[ID]; } lbUIDLV.Text = temp.UIDL.ToString(); string strUID = ""; for (int i = 0; i < temp.UIDL; i++) { strUID = strUID + GlobalClass.AddLeftZero(temp.UID[i].ToString("X"), 2) + " "; } lbUIDDV.Text = strUID.Trim(); cbType.SelectedIndex = temp.CardType - 1; txtBuilding.Text = temp.BuildingNO.ToString("X"); txtUnit.Text = temp.UnitNO.ToString("X"); txtRoom.Text = temp.RoomNO.ToString("X"); txtName.Text = HDLPF.Byte2String(temp.arayName); txtPhone.Text = HDLPF.Byte2String(temp.arayPhone); txtRemark.Text = temp.Remark; if (temp.arayDate[3] > 23) { temp.arayDate[3] = 23; } if (temp.arayDate[4] > 59) { temp.arayDate[4] = 59; } numTime1.Value = Convert.ToDecimal(temp.arayDate[3]); numTime2.Value = Convert.ToDecimal(temp.arayDate[4]); if (temp.arayDate[1] > 12) { temp.arayDate[1] = 12; } if (temp.arayDate[2] > 31) { temp.arayDate[2] = 31; } DateTime d2 = new DateTime(temp.arayDate[0] + 2000, temp.arayDate[1], temp.arayDate[2]); TimePicker.Text = d2.ToString(); TimePicker.Value = d2; } catch { } }
private void PIC_MouseHover(object sender, EventArgs e) { string str = ""; NewDS.CardInfo temp = oNewDS.MyCardInfo[ID]; str = CsConst.mstrINIDefault.IniReadValue("Public", "00360", "") + ":" + GlobalClass.AddLeftZero(temp.BuildingNO.ToString("X"), 2) + "\r\n" + CsConst.mstrINIDefault.IniReadValue("Public", "00361", "") + ":" + GlobalClass.AddLeftZero(temp.UnitNO.ToString("X"), 2) + "\r\n" + CsConst.mstrINIDefault.IniReadValue("Public", "00362", "") + ":" + GlobalClass.AddLeftZero(temp.RoomNO.ToString("X"), 2) + "\r\n" + CsConst.mstrINIDefault.IniReadValue("Public", "00363", "") + ":" + (temp.arayDate[0] + 2000).ToString() + "/" + temp.arayDate[1].ToString() + "/" + temp.arayDate[2].ToString() + " " + temp.arayDate[3].ToString() + ":" + temp.arayDate[4].ToString() + "\r\n" + CsConst.mstrINIDefault.IniReadValue("Public", "00364", "") + ":" + HDLPF.Byte2String(temp.arayName) + "\r\n" + CsConst.mstrINIDefault.IniReadValue("Public", "00365", "") + ":" + HDLPF.Byte2String(temp.arayPhone) + "\r\n" + CsConst.mstrINIDefault.IniReadValue("Public", "00366", "") + ":" + temp.Remark.ToString(); toolTip1.Show(str, PIC); }
void DisplayRFSettingToForm() { try { tbSSID.Text = myIPModule.intSSID.ToString(); if (myIPModule.bytCFre >= 0 && myIPModule.bytCFre <= 2) { cboCF.SelectedIndex = myIPModule.bytCFre; } if (myIPModule.bytChns >= 0 && myIPModule.bytChns <= 12) { cboChn.SelectedIndex = myIPModule.bytChns; } tbPSK.Text = HDLPF.Byte2String(myIPModule.bytPWD); if (myIPModule.bytStatus == 1) { if (CsConst.iLanguageId == 1) { lbRfState.Text = "配置状态"; } else if (CsConst.iLanguageId == 0) { lbRfState.Text = "Configuration Status"; } } else { if (CsConst.iLanguageId == 1) { lbRfState.Text = "正常状态"; } else if (CsConst.iLanguageId == 0) { lbRfState.Text = "Normal Status"; } } } catch { } }
public void LoadUser(int Type) { NewDS.CardInfo temp = oNewDS.MyCardInfo[ID]; switch (Type) { case 0: lb.Text = temp.BuildingNO.ToString("X"); break; case 1: lb.Text = temp.UnitNO.ToString("X"); break; case 2: lb.Text = temp.RoomNO.ToString("X"); break; case 3: lb.Text = (temp.arayDate[0] + 2000).ToString() + "/" + temp.arayDate[1].ToString() + "/" + temp.arayDate[2].ToString() + " " + temp.arayDate[3].ToString() + ":" + temp.arayDate[4].ToString(); break; case 4: lb.Text = HDLPF.Byte2String(temp.arayName); break; case 5: lb.Text = HDLPF.Byte2String(temp.arayPhone); break; case 6: lb.Text = temp.Remark; break; } }
public bool DownloadNewIRInfoFrmDevice(string DevName, int intDeviceType, int intActivePage) { 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]; String sRemark = HDLSysPF.ReadDeviceMainRemark(bytSubID, bytDevID); strName = bytSubID.ToString() + "-" + bytDevID.ToString() + "\\" + sRemark; if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(1); } if (intActivePage == 0 || intActivePage == 1) { arayBrocast = new byte[5]; arayTime = new byte[7]; ArayTmp = new byte[2]; IRCodes = new List <NewIRCode>(); //读取28红外备注 int MaxIRDevice = 28; if (intDeviceType == 6100) { MaxIRDevice = 10; } if (intDeviceType == 1301 || intDeviceType == 1300 || intDeviceType == 6100) { ArayTmp = new byte[3]; } for (int i = 0; i < MaxIRDevice; i++) { ArayTmp[0] = Convert.ToByte(i + 1); ArayTmp[1] = 0; if (intDeviceType == 1301 || intDeviceType == 1300) { if (i >= 4) { ArayTmp[0] = Convert.ToByte(ArayTmp[0] - 4); ArayTmp[2] = 0; } else { ArayTmp[2] = 1; } } else if (intDeviceType == 6100) { if (i >= 3) { ArayTmp[0] = Convert.ToByte(ArayTmp[0] - 3); ArayTmp[2] = 0; } else { ArayTmp[2] = 1; } } if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x137C, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(intDeviceType)) == true) { NewIRCode temp = new NewIRCode(); temp.KeyID = ArayTmp[0]; temp.DevID = CsConst.myRevBuf[27]; temp.IRIndex = CsConst.myRevBuf[28] * 256 + CsConst.myRevBuf[29]; temp.IRLength = CsConst.myRevBuf[30]; temp.KeyCodes = new List <UVCMD.IRCode>(); byte[] arayRemark = new byte[20]; for (int intI = 0; intI < 20; intI++) { arayRemark[intI] = CsConst.myRevBuf[32 + intI]; } ; temp.Remark = HDLPF.Byte2String(arayRemark); temp.Codes = ""; if (temp.DevID >= 6) { temp.Remark = ""; } if (temp.IRLength != 0 && temp.IRLength != 255) { ArayTmp[1] = 1; ArayTmp[2] = (Byte)temp.IRLength; if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x137C, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(intDeviceType)) == true) { for (int intI = 0; intI < temp.IRLength; intI++) { temp.Codes = temp.Codes + CsConst.myRevBuf[27 + intI].ToString("X2") + " "; } } } IRCodes.Add(temp); } else { return(false); } HDLUDP.TimeBetwnNext(1); if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(1 + i); } } if (intDeviceType != 1301) { ArayTmp = new byte[0]; if (CsConst.mySends.AddBufToSndList(ArayTmp, 0xE0F8, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(intDeviceType)) == true) { Array.Copy(CsConst.myRevBuf, 25, arayBrocast, 0, 5); HDLUDP.TimeBetwnNext(1); } else { return(false); } } if (intDeviceType == 6100) { ArayTmp = new byte[0]; if (CsConst.mySends.AddBufToSndList(ArayTmp, 0xDA00, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(intDeviceType)) == true) { Array.Copy(CsConst.myRevBuf, 26, arayTime, 0, 6); HDLUDP.TimeBetwnNext(1); } else { return(false); } } MyRead2UpFlags[0] = true; } if (intActivePage == 0 || intActivePage == 2) { if (CsConst.isRestore) { } } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(40); } if (intActivePage == 0 || intActivePage == 3) { if (CsConst.isRestore) { } } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(50); } if (intActivePage == 0 || intActivePage == 4) { if (CsConst.isRestore) { } } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(60); } if (intActivePage == 0 || intActivePage == 5) { } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(70); } if (intActivePage == 0 || intActivePage == 6) { #region if (intDeviceType == 6100) { Clocks = new List <Clock>(); Scenes = new List <Scene>(); for (int i = 1; i <= 16; i++) { ArayTmp = new byte[1]; ArayTmp[0] = Convert.ToByte(i); if (CsConst.mySends.AddBufToSndList(ArayTmp, 0xE46E, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(intDeviceType)) == true) { Clock temp = new Clock(); temp.ID = Convert.ToByte(i); temp.Enable = CsConst.myRevBuf[26]; temp.Type = CsConst.myRevBuf[27]; if (temp.Type > 1) { temp.Type = 0; } temp.arayParam = new byte[5]; Array.Copy(CsConst.myRevBuf, 28, temp.arayParam, 0, 5); temp.SceneID = CsConst.myRevBuf[33]; if (temp.SceneID > 16 || temp.SceneID < 1) { temp.SceneID = 1; } Clocks.Add(temp); } else { return(false); } } if (CsConst.isRestore) { for (int i = 1; i <= 8; i++) { Scene temp = new Scene(); temp.ID = Convert.ToByte(i); temp.Targets = new List <UVCMD.ControlTargets>(); ArayTmp = new byte[2]; ArayTmp[0] = Convert.ToByte(i); for (int j = 1; j <= 32; j++) { ArayTmp[1] = Convert.ToByte(j); if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x1402, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(intDeviceType)) == true) { UVCMD.ControlTargets tmp = new UVCMD.ControlTargets(); tmp.ID = Convert.ToByte(CsConst.myRevBuf[26]); tmp.Type = CsConst.myRevBuf[27]; //转换为正确的类型 tmp.SubnetID = CsConst.myRevBuf[28]; tmp.DeviceID = CsConst.myRevBuf[29]; tmp.Param1 = CsConst.myRevBuf[30]; tmp.Param2 = CsConst.myRevBuf[31]; tmp.Param3 = CsConst.myRevBuf[32]; tmp.Param4 = CsConst.myRevBuf[33]; temp.Targets.Add(tmp); Scenes.Add(temp); } else { return(false); } } } } } #endregion MyRead2UpFlags[5] = true; } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(100); } return(true); }
/// <summary> /// 下载所有数据 /// </summary> /// <param name="DevName"></param> /// <returns></returns> public bool DownloadEIBInforsFrmDevice(string DevName, int wdDeviceType, 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) == 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); CsConst.myRevBuf = new byte[1200]; } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(1); } if (intActivePage == 0) { // 读取基本信息bacnet地址设置 #region if (CsConst.mySends.AddBufToSndList(ArayTmp, 0xBACE, bytSubID, bytDevID, false, true, true, false) == true) { Address = CsConst.myRevBuf[25] * 256 * 256 * 256 + CsConst.myRevBuf[26] * 256 * 256 + CsConst.myRevBuf[27] * 256 + CsConst.myRevBuf[28]; CsConst.myRevBuf = new byte[1200]; } else { return(false); } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(3); } #endregion //读取bacnet端口 #region if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x180D, bytSubID, bytDevID, false, true, true, false) == true) { blnSwitch = (CsConst.myRevBuf[26] == 1); intPort = CsConst.myRevBuf[31] * 256 + CsConst.myRevBuf[32]; } else { return(false); } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(3); } #endregion // 读取转换信息列表 //读取bacnet个数 #region if (CsConst.mySends.AddBufToSndList(ArayTmp, 0xBAC6, bytSubID, bytDevID, false, true, true, false) == true) { ValidCount = CsConst.myRevBuf[25] * 256 + CsConst.myRevBuf[26]; CsConst.myRevBuf = new byte[1200]; } else { return(false); } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(3); } #endregion } if (intActivePage == 0 || intActivePage == 1) { #region ArayTmp = new byte[1]; otherInfo = new List <OtherInfo>(); for (int i = num1; i <= num2; i++) { OtherInfo ch = new OtherInfo(); ArayTmp[0] = (byte)(i); if (CsConst.mySends.AddBufToSndList(ArayTmp, 0xBAC4, bytSubID, bytDevID, false, true, true, false) == true) { if (CsConst.myRevBuf != null) { ch.ID = CsConst.myRevBuf[26]; ch.BackNetIDAry[0] = CsConst.myRevBuf[27]; ch.BackNetIDAry[1] = CsConst.myRevBuf[28]; ch.BackNetIDAry[2] = CsConst.myRevBuf[29]; ch.BackNetIDAry[3] = CsConst.myRevBuf[30]; ch.Type = CsConst.myRevBuf[32] * 256 + CsConst.myRevBuf[31]; ch.strDevName = CsConst.myRevBuf[39].ToString() + " / " + CsConst.myRevBuf[40].ToString(); ch.Param1 = CsConst.myRevBuf[41]; ch.Param2 = CsConst.myRevBuf[42]; ch.Param3 = CsConst.myRevBuf[43]; ch.Param4 = CsConst.myRevBuf[44]; byte[] arayRemark = new byte[40]; for (int intJ = 0; intJ < 40; intJ++) { arayRemark[intJ] = CsConst.myRevBuf[49 + intJ]; } ch.Remark = HDLPF.Byte2String(arayRemark); } CsConst.myRevBuf = new byte[1200]; HDLUDP.TimeBetwnNext(10); otherInfo.Add(ch); } else { return(false); } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(i / 3, null); } } #endregion } MyRead2UpFlags[0] = true; if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(100, null); } return(true); }
/// <summary> /// strDevName device subnet id and device id /// </summary> /// <param name="strDevName"></param> public override void DownLoadInformationFrmDevice(string strDevName, int intDeviceType, int intActivePage, int num1, int num2)// 0 mean all, else that tab only { Boolean BlnIsSuccess = false; if (strDevName == null) { return; } string strMainRemark = strDevName.Split('\\')[1].Trim(); DeviceName = strDevName.Split('\\')[0].Trim(); byte bytSubID = byte.Parse(DeviceName.Split('-')[0].ToString()); byte bytDevID = byte.Parse(DeviceName.Split('-')[1].ToString()); byte[] ArayTmp = new Byte[1]; base.DownLoadInformationFrmDevice(strDevName, intDeviceType, intActivePage, 0, 0); // 读取回路信息 Chans = new List <RelayChannel>(); #region int wdMaxValue = 1; for (int i = 0; i < wdMaxValue; i++) { RelayChannel Ch = new RelayChannel(); Ch.LoadType = 0; Ch.OnDelay = 0; Ch.ProtectDelay = 0; ArayTmp[0] = (byte)(i + 1); if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x331A, bytSubID, bytDevID, false, false, true, false) == true) { if (CsConst.myRevBuf != null) { byte[] arayRemark = new byte[20]; HDLSysPF.CopyRemarkBufferFrmMyRevBuffer(CsConst.myRevBuf, arayRemark, 26); Ch.Remark = HDLPF.Byte2String(arayRemark); } CsConst.myRevBuf = new byte[1200]; } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(i * (50 / wdMaxValue), null); } Chans.Add(Ch); } ArayTmp = null; // read off delay if (CsConst.mySends.AddBufToSndList(ArayTmp, 0xF084, bytSubID, bytDevID, false, false, true, true) == true) { for (int intI = 0; intI < wdMaxValue; intI++) { Chans[intI].OFFDelay = CsConst.myRevBuf[25 + intI]; if (Chans[intI].LoadType == 255 || Chans[intI].LoadType > CsConst.LoadType.Length - 1) { Chans[intI].LoadType = 0; } } CsConst.myRevBuf = new byte[1200]; } // read on delay ArayTmp = null; if (CsConst.mySends.AddBufToSndList(ArayTmp, 0xF04D, bytSubID, bytDevID, false, false, true, true) == true) { for (int intI = 0; intI < wdMaxValue; intI++) { Chans[intI].OnDelay = CsConst.myRevBuf[25 + intI]; } CsConst.myRevBuf = new byte[1200]; } // read protoct delay if (CsConst.mySends.AddBufToSndList(ArayTmp, 0xF03F, bytSubID, bytDevID, false, false, true, false) == true) { for (int intI = 0; intI < wdMaxValue; intI++) { Chans[intI].ProtectDelay = CsConst.myRevBuf[25 + intI]; } CsConst.myRevBuf = new byte[1200]; } #endregion MyRead2UpFlags[0] = true; if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(100, null); } BlnIsSuccess = true; return; }
/// <summary> /// devname device name /// </summary> /// <param name="DevName"></param> public void DownloadZaudioFrmDeviceToBuf(string DevName, int PageIndex, int DeviceType) { string strMainRemark = DevName.Split('\\')[1].Trim(); String TmpDevName = DevName.Split('\\')[0].Trim(); //保存basic informations网络信息 byte SubNetID = byte.Parse(TmpDevName.Split('-')[0].ToString()); byte DeviceID = byte.Parse(TmpDevName.Split('-')[1].ToString()); byte[] ArayTmp = null; String TmpRemark = HDLSysPF.ReadDeviceMainRemark(SubNetID, DeviceID); DeviceName = SubNetID.ToString() + "-" + DeviceID.ToString() + "\\" + TmpRemark; if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(10); } if (PageIndex == 0 || PageIndex == 1) { if (netWork == null) { netWork = new NetworkInformation(); } netWork.readNetworkInfomation(SubNetID, DeviceID); #region if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x3007, SubNetID, DeviceID, false, true, true, false) == true) { bytWorkType = CsConst.myRevBuf[25]; byte[] arayRemark = new byte[20]; for (int intI = 0; intI < 20; intI++) { arayRemark[intI] = CsConst.myRevBuf[26 + intI]; } strGroup = HDLPF.Byte2String(arayRemark); if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(20); } arayRemark = new byte[20]; for (int intI = 0; intI < 20; intI++) { arayRemark[intI] = CsConst.myRevBuf[46 + intI]; } strPrjName = HDLPF.Byte2String(arayRemark); if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(30); } arayRemark = new byte[8]; for (int intI = 0; intI < 8; intI++) { arayRemark[intI] = CsConst.myRevBuf[66 + intI]; } strUser = HDLPF.Byte2String(arayRemark); arayRemark = new byte[8]; for (int intI = 0; intI < 8; intI++) { arayRemark[intI] = CsConst.myRevBuf[74 + intI]; } strPWD = HDLPF.Byte2String(arayRemark); CsConst.myRevBuf = new byte[1200]; if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(40); } } else { return; } if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x3009, SubNetID, DeviceID, false, true, true, false) == true) { strServer1 = CsConst.myRevBuf[25].ToString("d3") + "." + CsConst.myRevBuf[26].ToString("d3") + "." + CsConst.myRevBuf[27].ToString("d3") + "." + CsConst.myRevBuf[28].ToString("d3"); intPort1 = CsConst.myRevBuf[29] * 256 + CsConst.myRevBuf[30]; strServer2 = CsConst.myRevBuf[31].ToString("d3") + "." + CsConst.myRevBuf[32].ToString("d3") + "." + CsConst.myRevBuf[33].ToString("d3") + "." + CsConst.myRevBuf[34].ToString("d3"); intPort2 = CsConst.myRevBuf[35] * 256 + CsConst.myRevBuf[36]; bytEnDHCP = CsConst.myRevBuf[37]; bytTimer = CsConst.myRevBuf[38]; CsConst.myRevBuf = new byte[1200]; } else { return; } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(50); } #endregion MyRead2UpFlags[0] = true; } if (PageIndex == 0 || PageIndex == 2) { if (!IPmoduleDeviceTypeList.IpModuleV3TimeZoneUrl.Contains(DeviceType)) //bus版不支持子网过滤 { if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x1D46, SubNetID, DeviceID, false, true, true, false) == true) { isEnable = CsConst.myRevBuf[25]; bytPassSub = CsConst.myRevBuf[26]; } } //读取拦截列表 #region MyBlocks = new List <RFBlock>(); for (byte bytI = 0; bytI < 16; bytI++) { RFBlock Tmp = new RFBlock(); if (Tmp.ReadRfBlockSetupInformation(SubNetID, DeviceID, bytI) == true) { MyBlocks.Add(Tmp); } else { return; } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(50 + bytI); } } #endregion MyRead2UpFlags[1] = true; } //下载无线遥控器地址 if (PageIndex == 0 || PageIndex == 3) { Byte[] RemoteAddress = new Byte[11]; MyRemoteControllers = new HDLButton[48 * 4]; if (CsConst.mySends.AddBufToSndList(ArayTmp, 0xE010, SubNetID, DeviceID, false, true, true, false) == true) { Array.Copy(CsConst.myRevBuf, 28, RemoteControllers, 0, 8); RemoteControllers.CopyTo(RemoteAddress, 3); } Byte ValidRemoteNumber = 4; //判断地址是不是全部一样 一样保存一个即可 if (((RemoteAddress[3] == RemoteAddress[5]) && (RemoteAddress[5] == RemoteAddress[7]) && (RemoteAddress[7] == RemoteAddress[9])) && ((RemoteAddress[4] == RemoteAddress[6]) && (RemoteAddress[6] == RemoteAddress[8]) && (RemoteAddress[8] == RemoteAddress[10]))) { ValidRemoteNumber = 1; } //测试按键是不是支持目标有效无效的读取 Boolean blnIsSupportE474 = false; blnIsSupportE474 = CsConst.mySends.AddBufToSndList(ArayTmp, 0xE474, SubNetID, DeviceID, false, false, true, false); for (Byte i = 0; i < ValidRemoteNumber; i++) { //无效地址不保存 if (RemoteAddress[3 + i * 2] == 0 && RemoteAddress[4 + i * 2] == 0) { continue; } if (RemoteAddress[3 + i * 2] == 255 && RemoteAddress[4 + i * 2] == 255) { continue; } //读取模式是否有效 Byte[] arayKeyMode = new byte[IPmoduleDeviceTypeList.HowManyButtonsEachPage]; //按键模式 Byte[] arayKeyDimmer = new byte[IPmoduleDeviceTypeList.HowManyButtonsEachPage]; // 要不要调光,要不要保存调光 arayKeyMode = ReadButtonModeFrmDeviceToBuf(i, SubNetID, DeviceID); arayKeyDimmer = ReadButtonDimFlagFrmDeviceToBuf(i, SubNetID, DeviceID); if (arayKeyMode == null) { return; } for (int j = 0; j < 48; j++) { HDLButton oKey = MyRemoteControllers[IPmoduleDeviceTypeList.HowManyButtonsEachPage * i + j]; oKey = new HDLButton(); oKey.ID = Convert.ToByte(j + 1); oKey.Mode = arayKeyMode[j]; oKey.IsDimmer = (Byte)(arayKeyDimmer[j] >> 4); oKey.SaveDimmer = (Byte)(arayKeyDimmer[j] & 0x01); oKey.ReadButtonRemarkAndCMDFromDevice(SubNetID, DeviceID, DeviceType, i, 255, blnIsSupportE474, 0, 0); if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(60 + j / 2); } MyRemoteControllers[IPmoduleDeviceTypeList.HowManyButtonsEachPage * i + j] = oKey; } } } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(100); } }
public void btnRead_Click(object sender, EventArgs e) { try { Cursor.Current = Cursors.WaitCursor; lvHistory.Items.Clear(); int Count = 0; byte[] arayTmp = new byte[1]; arayTmp[0] = 1; if (CsConst.mySends.AddBufToSndList(arayTmp, 0x3017, bytSubID, bytDevID, false, true, true, false) == true) { Count = CsConst.myRevBuf[26]; CsConst.myRevBuf = new byte[1200]; } else { Cursor.Current = Cursors.Default; return; } if (Count == 0) { MessageBox.Show(CsConst.mstrINIDefault.IniReadValue("Public", "99780", ""), "" , MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); } else { for (int i = 1; i <= Count; i++) { arayTmp[0] = Convert.ToByte(i); if (CsConst.mySends.AddBufToSndList(arayTmp, 0x3017, bytSubID, bytDevID, false, true, true, false) == true) { string strIP = CsConst.myRevBuf[27].ToString() + "." + CsConst.myRevBuf[28].ToString() + "." + CsConst.myRevBuf[29].ToString() + "." + CsConst.myRevBuf[30].ToString(); string strPort = (CsConst.myRevBuf[31] * 256 + CsConst.myRevBuf[32]).ToString(); string strDate = (CsConst.myRevBuf[33] + 2000).ToString() + "/" + CsConst.myRevBuf[34].ToString() + "/" + CsConst.myRevBuf[35].ToString() + "-" + CsConst.myRevBuf[36].ToString() + ":" + CsConst.myRevBuf[37].ToString() + ":" + CsConst.myRevBuf[38].ToString(); byte[] arayRemark = new byte[16]; Array.Copy(CsConst.myRevBuf, 39, arayRemark, 0, 16); string strRemark = HDLPF.Byte2String(arayRemark); ListViewItem oTmp = new ListViewItem(); oTmp.Text = (i.ToString()); oTmp.SubItems.Add(strDate); oTmp.SubItems.Add(strRemark); oTmp.SubItems.Add(strIP); oTmp.SubItems.Add(strPort); //object[] obj = new object[] { i.ToString(), strDate, strRemark, strIP, strPort }; lvHistory.Items.Insert(0, oTmp); } else { Cursor.Current = Cursors.Default; return; } } } } catch { } Cursor.Current = Cursors.Default; }
/// <summary> ///下载设置 /// </summary> public void DownloadMSPUInfoToDevice(string DevName, int DeviceType, int intActivePage) { 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()); int wdMaxValue = DeviceTypeList.GetMaxValueFromPublicModeGroup(DeviceType); byte[] ArayTmp = new byte[0]; if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x000E, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(DeviceType)) == 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); HDLUDP.TimeBetwnNext(1); } else { return; } if (intActivePage == 0 || intActivePage == 1) { #region ONLEDs = new byte[5]; //读取LED状态 if (CsConst.mySends.AddBufToSndList(ArayTmp, 0xDB3E, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(DeviceType)) == true) { ONLEDs = new byte[5]; ONLEDs[0] = CsConst.myRevBuf[27]; HDLUDP.TimeBetwnNext(1); } else { return; } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(1, null); } //读取传感器使能 if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x161C, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(DeviceType)) == true) { EnableSensors = new byte[15]; EnableSensors[0] = CsConst.myRevBuf[26]; EnableSensors[1] = CsConst.myRevBuf[27]; EnableSensors[2] = CsConst.myRevBuf[31]; EnableSensors[3] = CsConst.myRevBuf[37]; EnableSensors[4] = CsConst.myRevBuf[32]; EnableSensors[5] = CsConst.myRevBuf[34]; EnableSensors[6] = CsConst.myRevBuf[35]; EnableSensors[7] = CsConst.myRevBuf[36]; HDLUDP.TimeBetwnNext(1); } else { return; } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(2, null); } //读取补偿值 if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x1600, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(DeviceType)) == true) { ParamSensors = new byte[15]; ParamSensors[0] = CsConst.myRevBuf[26]; ParamSensors[1] = CsConst.myRevBuf[27]; ParamSensors[2] = CsConst.myRevBuf[38]; ParamSensors[3] = CsConst.myRevBuf[39]; HDLUDP.TimeBetwnNext(1); } else { return; } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(3); } //恒照度读取 if (DeviceType == 326) { EnableBroads = new byte[15]; 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; } } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(4); } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(5, null); } #endregion MyRead2UpFlags[0] = true; } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(10); } if (intActivePage == 0 || intActivePage == 2) { //逻辑块功能设置 #region // 读取24个逻辑的使能位 if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x1618, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(DeviceType)) == true) { logic = new List <SensorLogic>(); byte[] ArayTmpMode = new byte[24]; Array.Copy(CsConst.myRevBuf, 26, ArayTmpMode, 0, 24); HDLUDP.TimeBetwnNext(1); for (int intI = 1; intI <= 24; intI++) { SensorLogic oTmp = new SensorLogic(); oTmp.ID = (byte)intI; oTmp.Enabled = ArayTmpMode[intI - 1]; oTmp.SetUp = new List <UVCMD.ControlTargets>(); oTmp.NoSetUp = new List <UVCMD.ControlTargets>(); if (oTmp.Enabled != 1) { logic.Add(oTmp); continue; } #region //读取备注 ArayTmp = new byte[1]; ArayTmp[0] = Convert.ToByte(intI); if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x1606, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(DeviceType)) == 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; } if (CsConst.isRestore) { //读取设置 #region if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x160E, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(DeviceType)) == true) { oTmp.bytRelation = CsConst.myRevBuf[27]; oTmp.EnableSensors = new byte[15]; int intTmp = CsConst.myRevBuf[28] * 256 + CsConst.myRevBuf[29]; if (intTmp == 65535) { intTmp = 0; } for (byte i = 0; i < 12; i++) { if ((intTmp & (1 << i)) == (1 << i)) { switch (i) { case 0: oTmp.EnableSensors[0] = 1; break; case 1: oTmp.EnableSensors[1] = 1; break; case 5: oTmp.EnableSensors[2] = 1; break; case 6: oTmp.EnableSensors[4] = 1; break; case 8: oTmp.EnableSensors[5] = 1; break; case 9: oTmp.EnableSensors[6] = 1; break; case 10: oTmp.EnableSensors[7] = 1; break; case 11: oTmp.EnableSensors[3] = 1; break; } } } oTmp.DelayTimeT = CsConst.myRevBuf[30] * 256 + CsConst.myRevBuf[31]; oTmp.DelayTimeF = CsConst.myRevBuf[32] * 256 + CsConst.myRevBuf[33]; if (oTmp.DelayTimeT == 65535) { oTmp.DelayTimeT = 0; } if (oTmp.DelayTimeF == 65535) { oTmp.DelayTimeF = 0; } Array.Copy(CsConst.myRevBuf, 34, oTmp.Paramters, 0, 6); oTmp.Paramters[6] = CsConst.myRevBuf[46]; oTmp.Paramters[7] = CsConst.myRevBuf[55]; oTmp.Paramters[8] = CsConst.myRevBuf[47]; oTmp.UV1 = new UniversalSwitchSet(); if (201 <= CsConst.myRevBuf[49] && CsConst.myRevBuf[49] <= 248) { oTmp.UV1.id = CsConst.myRevBuf[49]; } else { oTmp.UV1.id = 201; } if (CsConst.myRevBuf[50] <= 1) { oTmp.UV1.condition = CsConst.myRevBuf[50]; } oTmp.UV2 = new UniversalSwitchSet(); if (201 <= CsConst.myRevBuf[51] && CsConst.myRevBuf[51] <= 248) { oTmp.UV2.id = CsConst.myRevBuf[51]; } else { oTmp.UV2.id = 201; if (oTmp.UV1.id == 201) { oTmp.UV2.id = 202; } } if (CsConst.myRevBuf[52] <= 1) { oTmp.UV2.condition = CsConst.myRevBuf[52]; } oTmp.Paramters[9] = CsConst.myRevBuf[53]; oTmp.Paramters[10] = CsConst.myRevBuf[54]; HDLUDP.TimeBetwnNext(1); } else { return; } #endregion //读取通用开关信息 #region ArayTmp[0] = oTmp.UV1.id; if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x160A, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(DeviceType)) == true) { byte[] arayRemark = new byte[20]; for (int i = 0; i < 20; i++) { arayRemark[i] = CsConst.myRevBuf[27 + i]; } oTmp.UV1.remark = HDLPF.Byte2String(arayRemark); if (CsConst.myRevBuf[47] == 1) { oTmp.UV1.isAutoOff = true; } 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); } else { return; } if ((CsConst.mySends.AddBufToSndList(ArayTmp, 0xE018, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(DeviceType)) == true)) { oTmp.UV1.state = CsConst.myRevBuf[26]; HDLUDP.TimeBetwnNext(1); } else { return; } ArayTmp[0] = oTmp.UV2.id; if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x160A, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(DeviceType)) == true) { byte[] arayRemark = new byte[20]; for (int i = 0; i < 20; i++) { arayRemark[i] = CsConst.myRevBuf[27 + i]; } oTmp.UV2.remark = HDLPF.Byte2String(arayRemark); if (CsConst.myRevBuf[47] == 1) { oTmp.UV2.isAutoOff = true; } 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; } if ((CsConst.mySends.AddBufToSndList(ArayTmp, 0xE018, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(DeviceType)) == true)) { oTmp.UV2.state = CsConst.myRevBuf[26]; } else { return; } #endregion //成立的触发目标 #region for (byte bytJ = 0; bytJ < 20; bytJ++) { ArayTmp = new byte[2]; ArayTmp[0] = (byte)(intI); ArayTmp[1] = (byte)(bytJ + 1); if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x1612, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(DeviceType)) == true) { UVCMD.ControlTargets oCMD = new UVCMD.ControlTargets(); oCMD.ID = CsConst.myRevBuf[27]; oCMD.Type = CsConst.myRevBuf[28]; //转换为正确的类型 if (oCMD.Type != 3) { 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.SetUp.Add(oCMD); } HDLUDP.TimeBetwnNext(1); } else { return; } } #endregion //不成立的触发目标 #region for (byte bytJ = 0; bytJ < 20; bytJ++) { ArayTmp = new byte[2]; ArayTmp[0] = (byte)(intI + 24); ArayTmp[1] = (byte)(bytJ + 1); if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x1612, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(DeviceType)) == true) { UVCMD.ControlTargets oCMD = new UVCMD.ControlTargets(); oCMD.ID = CsConst.myRevBuf[27]; oCMD.Type = CsConst.myRevBuf[28]; //转换为正确的类型 if (oCMD.Type != 3) { 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.NoSetUp.Add(oCMD); } HDLUDP.TimeBetwnNext(1); } else { return; } } #endregion } logic.Add(oTmp); #endregion if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(10 + intI); } } } else { return; } #endregion MyRead2UpFlags[1] = true; } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(20); } if (intActivePage == 0 || intActivePage == 3) { fireset = new List <UVCMD.SecurityInfo>(); ArayTmp = new byte[1]; #region for (byte intI = 1; intI <= 1; intI++) { ArayTmp[0] = intI; //读取备注 UVCMD.SecurityInfo oTmp = new UVCMD.SecurityInfo(); oTmp.bytSeuID = intI; switch (intI) { default: if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x1624, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(DeviceType)) == 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; } break; } //读取设置 if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x1628, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(DeviceType)) == 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; } fireset.Add(oTmp); if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(35 + intI); } } #endregion MyRead2UpFlags[2] = true; } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(30); } if (intActivePage == 0 || intActivePage == 4) { #region //读取模拟测试 if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x1620, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(DeviceType)) == true) { SimulateEnable = new byte[15]; SimulateEnable[0] = CsConst.myRevBuf[26]; SimulateEnable[1] = CsConst.myRevBuf[27]; SimulateEnable[2] = CsConst.myRevBuf[28]; SimulateEnable[3] = CsConst.myRevBuf[32]; SimulateEnable[4] = CsConst.myRevBuf[40]; ParamSimulate = new byte[15]; ParamSimulate[0] = CsConst.myRevBuf[33]; ParamSimulate[1] = CsConst.myRevBuf[34]; ParamSimulate[2] = CsConst.myRevBuf[35]; ParamSimulate[3] = CsConst.myRevBuf[39]; ParamSimulate[4] = CsConst.myRevBuf[41]; HDLUDP.TimeBetwnNext(1); } else { return; } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(31, null); } #endregion MyRead2UpFlags[3] = true; } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(40); } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(100); } }
/// <summary> ///下载设置 /// </summary> public bool DownLoadInformationFrmDevice(string DevName) { 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[] ArayMain = new byte[20]; byte[] arayTmpRemark = HDLUDP.StringToByte(strMainRemark); Array.Copy(arayTmpRemark, 0, ArayMain, 0, arayTmpRemark.Length); if (CsConst.mySends.AddBufToSndList(ArayMain, 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]; } DeviceName = bytSubID.ToString() + "-" + bytDevID.ToString() + "\\" + HDLPF.Byte2String(arayRemark); } //HAI unit to single light control #region units = new List <Unit>(); for (byte bytI = 1; bytI <= 192; bytI++) { Unit oTmp = new Unit(); oTmp.bytID = bytI; oTmp.Command = "^A" + String.Format("{0:D3} ", bytI); ArayMain = new byte[3]; ArayMain[0] = 1; ArayMain[1] = bytI; ArayMain[2] = 0; if (CsConst.mySends.AddBufToSndList(ArayMain, 0x0238, bytSubID, bytDevID, false, true, true, false) == true) { UVCMD.ControlTargets oCMD = new UVCMD.ControlTargets(); oCMD.ID = 1; oCMD.Type = CsConst.myRevBuf[28]; //转换为正确的类型 if (oCMD.Type != 3 && oCMD.Type < 13) { 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]; CsConst.myRevBuf = new byte[1200]; oTmp.oUnit = oCMD; } } else { return(false); } units.Add(oTmp); if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(bytI / 6, null); } } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(33, null); } #endregion //HAI scene to scene #region scen = new List <Scene>(); for (byte bytI = 1; bytI <= 254; bytI++) { Scene oTmp = new Scene(); oTmp.bytID = bytI; oTmp.Command = "^C" + String.Format("{0:D3} ", bytI); ArayMain = new byte[3]; ArayMain[0] = 2; ArayMain[1] = bytI; ArayMain[2] = 0; if (CsConst.mySends.AddBufToSndList(ArayMain, 0x0238, bytSubID, bytDevID, false, true, true, false) == true) { UVCMD.ControlTargets oCMD = new UVCMD.ControlTargets(); oCMD.ID = 1; oCMD.Type = CsConst.myRevBuf[28]; //转换为正确的类型 if (oCMD.Type != 3 && oCMD.Type < 13) { 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]; CsConst.myRevBuf = new byte[1200]; oTmp.oUnit = oCMD; } } else { return(false); } scen.Add(oTmp); if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(33 + bytI / 6, null); } } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(66, null); } #endregion //HAI buttons to UV switch #region buttonstatus = new List <ButtonStatus>(); for (byte bytI = 1; bytI <= 192; bytI++) { ButtonStatus oTmp = new ButtonStatus(); oTmp.bytID = bytI; oTmp.Command = String.Format("{0:D3} ", bytI) + " Button Tab/Press<-->OFF/ON"; ArayMain = new byte[2]; ArayMain[0] = 3; ArayMain[1] = bytI; if (CsConst.mySends.AddBufToSndList(ArayMain, 0x0238, bytSubID, bytDevID, false, true, true, false) == true) { UVCMD.ControlTargets oCMD = new UVCMD.ControlTargets(); oCMD.ID = 1; if (CsConst.myRevBuf[27] == 1) { oCMD.Type = 2; //转换为正确的类型 } else { oCMD.Type = 3; } if (oCMD.Type != 3) { oCMD.SubnetID = CsConst.myRevBuf[28]; oCMD.DeviceID = CsConst.myRevBuf[29]; oCMD.Param1 = CsConst.myRevBuf[30]; oCMD.Param2 = 0; oCMD.Param3 = 0; oCMD.Param4 = 0; CsConst.myRevBuf = new byte[1200]; oTmp.oUnit = oCMD; } } else { return(false); } buttonstatus.Add(oTmp); if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(66 + bytI / 6, null); } } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(100, null); } #endregion MyRead2UpFlags[0] = true; return(true); }
private void btnSure_Click(object sender, EventArgs e) { if (oRS232 != null) { if (Type == 1) { oRS232.myBUS2RS = new List <RS232.BUS2RS>(); } else if (Type == 2) { oRS232.myBUS2485 = new List <RS232.BUS2RS>(); } } else if (oMHRCU != null) { if (Type == 1) { oMHRCU.myBUS2RS = new List <MHRCU.BUS2RS>(); } else if (Type == 2) { oMHRCU.myBUS2485 = new List <MHRCU.BUS2RS>(); } } allVisible(false); dgvUV.Rows.Clear(); Cursor.Current = Cursors.WaitCursor; btnSure.Enabled = false; byte[] arayTmp = new byte[1]; byte bytFrm = Convert.ToByte(Convert.ToInt32(txtFrm.Text)); byte bytTo = Convert.ToByte(txtTo.Text); int CMD1 = 0xE420; int CMD2 = 0xE428; if (Type == 1) { CMD1 = 0xE420; CMD2 = 0xE428; } else if (Type == 2) { CMD1 = 0xDA61; CMD2 = 0xDA69; } for (byte byt = bytFrm; byt <= bytTo; byt++) { if (oRS232 != null) { RS232.BUS2RS temp = new RS232.BUS2RS(); temp.ID = Convert.ToByte(byt); arayTmp = new byte[1]; arayTmp[0] = Convert.ToByte(byt); if (CsConst.mySends.AddBufToSndList(arayTmp, CMD1, SubNetID, DevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(MyintDeviceType)) == true) { temp.bytType = CsConst.myRevBuf[27]; temp.bytParam1 = CsConst.myRevBuf[28]; temp.bytParam2 = CsConst.myRevBuf[29]; temp.bytParam3 = CsConst.myRevBuf[30]; temp.bytParam4 = CsConst.myRevBuf[31]; } else { Cursor.Current = Cursors.Default; return; } HDLUDP.TimeBetwnNext(1); if (CsConst.mySends.AddBufToSndList(arayTmp, CMD2, SubNetID, DevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(MyintDeviceType)) == true) { byte[] arayRemark = new byte[20]; for (int intI = 0; intI < 20; intI++) { arayRemark[intI] = CsConst.myRevBuf[27 + intI]; } temp.Remark = HDLPF.Byte2String(arayRemark); } else { Cursor.Current = Cursors.Default; return; } if (Type == 1) { oRS232.myBUS2RS.Add(temp); } else if (Type == 2) { oRS232.myBUS2485.Add(temp); } } else if (oMHRCU != null) { MHRCU.BUS2RS temp = new MHRCU.BUS2RS(); temp.ID = Convert.ToByte(byt); arayTmp = new byte[1]; arayTmp[0] = Convert.ToByte(byt); if (CsConst.mySends.AddBufToSndList(arayTmp, CMD1, SubNetID, DevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(MyintDeviceType)) == true) { temp.bytType = CsConst.myRevBuf[27]; temp.bytParam1 = CsConst.myRevBuf[28]; temp.bytParam2 = CsConst.myRevBuf[29]; System.Threading.Thread.Sleep(1); } else { Cursor.Current = Cursors.Default; return; } if (CsConst.mySends.AddBufToSndList(arayTmp, CMD2, SubNetID, DevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(MyintDeviceType)) == true) { byte[] arayRemark = new byte[20]; for (int intI = 0; intI < 20; intI++) { arayRemark[intI] = CsConst.myRevBuf[27 + intI]; } temp.Remark = HDLPF.Byte2String(arayRemark); System.Threading.Thread.Sleep(1); } else { Cursor.Current = Cursors.Default; return; } if (Type == 1) { oMHRCU.myBUS2RS.Add(temp); } else if (Type == 2) { oMHRCU.myBUS2485.Add(temp); } } HDLUDP.TimeBetwnNext(1); } btnSure.Enabled = true; Cursor.Current = Cursors.Default; getDataGridViewList(); }
private void btnRead1A_Click(object sender, EventArgs e) { if (numSub.Value == 255 || numDevA.Value == 255) { return; } if (numSub.Value == 0 && numDevA.Value == 0) { return; } Cursor.Current = Cursors.WaitCursor; bSubNetId = Convert.ToByte(numSub.Value); bDeviceId = Convert.ToByte(numDevA.Value); dgvListA.Rows.Clear(); try { // 读取TX 接着读取RX for (Byte i = 1; i <= 24; i++) // (DataGridViewRow oTmp in dgvListA.Rows) { Byte[] arayTmp = new Byte[2] { 0, i }; if (CsConst.mySends.AddBufToSndList(arayTmp, 0xE420, bSubNetId, bDeviceId, false, true, true, false)) { Byte[] arayTmpRemark = new Byte[20]; Array.Copy(CsConst.myRevBuf, 25, arayTmpRemark, 0, 20); String sSerialNumber = HDLPF.Byte2String(arayTmpRemark); if (sSerialNumber != null && sSerialNumber != "") { Object[] obj = new Object[] { true, i, "TX", sSerialNumber }; dgvListA.Rows.Add(obj); } } else { return; } } for (Byte i = 1; i <= 24; i++) // (DataGridViewRow oTmp in dgvListA.Rows) { Byte[] arayTmp = new Byte[2] { 1, i }; if (CsConst.mySends.AddBufToSndList(arayTmp, 0xE420, bSubNetId, bDeviceId, false, true, true, false)) { Byte[] arayTmpRemark = new Byte[20]; Array.Copy(CsConst.myRevBuf, 25, arayTmpRemark, 0, 20); String sSerialNumber = HDLPF.Byte2String(arayTmpRemark); if (sSerialNumber != null && sSerialNumber != "") { Object[] obj = new Object[] { true, i, "RX", sSerialNumber }; dgvListA.Rows.Add(obj); } } else { return; } } } catch { } Cursor.Current = Cursors.Default; }
/// <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); }
/// <summary> /// 下载所有数据 /// </summary> /// <param name="DevName"></param> /// <returns></returns> public bool DownloadEIBInforsFrmDevice(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[0]; 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); CsConst.myRevBuf = new byte[1200]; } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(1); } // 读取基本信息物理地址设置 if (CsConst.mySends.AddBufToSndList(ArayTmp, 0xF255, bytSubID, bytDevID, false, true, true, false) == true) { Address = (CsConst.myRevBuf[25] & 0xF0 >> 4).ToString() + " / " + (CsConst.myRevBuf[25] & 0x0F).ToString() + CsConst.myRevBuf[26].ToString(); CsConst.myRevBuf = new byte[1200]; } else { return(false); } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(2); } // 读取转换信息列表 #region otherInfo = new List <OtherInfo>(); for (int i = 0; i < 254; i++) { ArayTmp = new byte[1]; OtherInfo ch = new OtherInfo(); ArayTmp[0] = (byte)(i); if (CsConst.mySends.AddBufToSndList(ArayTmp, 0xC080, bytSubID, bytDevID, false, true, true, false) == true) { if (CsConst.myRevBuf != null) { ch.GroupAddress = (CsConst.myRevBuf[26] & 0x78 >> 3).ToString() + (CsConst.myRevBuf[26] & 0x07).ToString() + CsConst.myRevBuf[27]; ch.Type = CsConst.myRevBuf[28]; ch.strDevName = CsConst.myRevBuf[29].ToString() + " / " + CsConst.myRevBuf[30].ToString(); ch.ControlType = CsConst.myRevBuf[31]; ch.Param1 = CsConst.myRevBuf[32]; ch.Param2 = CsConst.myRevBuf[33]; ch.Param3 = CsConst.myRevBuf[34]; ch.Param4 = CsConst.myRevBuf[35]; } CsConst.myRevBuf = new byte[1200]; HDLUDP.TimeBetwnNext(10); otherInfo.Add(ch); } else { return(false); } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(i / 3, null); } } #endregion if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(100, null); } MyRead2UpFlags[0] = true; return(true); }
/// <summary> /// strDevName device subnet id and device id /// </summary> /// <param name="strDevName"></param> public override void DownLoadInformationFrmDevice(string strDevName, int DeviceType, int intActivePage, int num1, int num2)// 0 mean all, else that tab only { if (strDevName == null) { return; } string strMainRemark = strDevName.Split('\\')[1].Trim(); String TmpDeviceName = strDevName.Split('\\')[0].Trim(); byte bytSubID = byte.Parse(TmpDeviceName.Split('-')[0].ToString()); byte bytDevID = byte.Parse(TmpDeviceName.Split('-')[1].ToString()); base.DownLoadInformationFrmDevice(strDevName, DeviceType, intActivePage, 0, 0); // 读取回路信息 Byte[] ArayTmp = new Byte[0]; if (ChnList == null || ChnList.Count == 0) { return; } int wdMaxValue = ChnList.Count; if (intActivePage == 0 || intActivePage == 7 || intActivePage == 8) { // 读取区域信息 #region Areas = new List <Area>(); byte bytTalArea = 0; if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x0004, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(DeviceType)) == true) { bytTalArea = CsConst.myRevBuf[29]; if (bytTalArea == 255) { bytTalArea = 0; } if (bytTalArea > wdMaxValue) { bytTalArea = 0; } for (int intI = 0; intI < wdMaxValue; intI++) { ChnList[intI].intBelongs = CsConst.myRevBuf[30 + intI]; } CsConst.myRevBuf = new byte[1200]; HDLUDP.TimeBetwnNext(1); if (bytTalArea == 0) { for (int intI = 0; intI < ChnList.Count; intI++) { ChnList[intI].intBelongs = 0; } } } else { return; } #endregion #region for (byte intI = 0; intI < bytTalArea; intI++) { Area area = new Area(); area.ID = (byte)(intI + 1); ArayTmp = new byte[1]; ArayTmp[0] = (byte)(intI + 1); if (CsConst.mySends.AddBufToSndList(ArayTmp, 0xF00A, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(DeviceType)) == true) { byte[] arayRemark = new byte[20]; for (int intJ = 0; intJ < 20; intJ++) { arayRemark[intJ] = CsConst.myRevBuf[26 + intJ]; } area.Remark = HDLPF.Byte2String(arayRemark); } else { return; } CsConst.myRevBuf = new byte[1200]; HDLUDP.TimeBetwnNext(1); area.Scen = new List <Scene>(); Areas.Add(area); } #endregion if (intActivePage == 0 || intActivePage == 8) { for (byte intI = 0; intI < bytTalArea; intI++) { // 读取场景信息 Areas[intI].Scen = new List <Scene>(); #region for (byte bytI = 0; bytI < 13; bytI++) { ArayTmp = new byte[2]; ArayTmp[0] = (byte)(intI + 1); ArayTmp[1] = (byte)(bytI); if (CsConst.mySends.AddBufToSndList(ArayTmp, 0xF024, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(DeviceType)) == true) { if (CsConst.myRevBuf[25] == (intI + 1) && CsConst.myRevBuf[26] == bytI) { Scene scen = new Scene(); scen.ID = (byte)(bytI); byte[] arayRemark = new byte[20]; for (int intJ = 0; intJ < 20; intJ++) { arayRemark[intJ] = CsConst.myRevBuf[27 + intJ]; } scen.Remark = HDLPF.Byte2String(arayRemark); CsConst.myRevBuf = new byte[1200]; HDLUDP.TimeBetwnNext(1); if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x0000, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(DeviceType)) == true) { scen.Time = CsConst.myRevBuf[27] * 256 + CsConst.myRevBuf[28]; byte[] ArayByt = new byte[wdMaxValue]; for (int intJ = 0; intJ < wdMaxValue; intJ++) { ArayByt[intJ] = CsConst.myRevBuf[29 + intJ]; } scen.light = ArayByt.ToList(); } else { return; } Areas[intI].Scen.Add(scen); CsConst.myRevBuf = new byte[1200]; HDLUDP.TimeBetwnNext(1); } } else { return; } } #endregion //表示掉电前状态 #region if (intActivePage == 0 || intActivePage == 3) { if (Areas != null && Areas.Count > 0) { ArayTmp = new byte[0]; if (CsConst.mySends.AddBufToSndList(ArayTmp, 0xF051, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(DeviceType)) == true) { for (int i = 0; i < Areas.Count; i++) { Areas[i].bytDefaultSce = CsConst.myRevBuf[25 + i]; if (Areas[i].bytDefaultSce == 0 || Areas[i].bytDefaultSce == 255) { Areas[i].bytDefaultSce = 13; // 255 表示掉电前状态 } } CsConst.myRevBuf = new byte[1200]; HDLUDP.TimeBetwnNext(1); } else { return; } if (CsConst.mySends.AddBufToSndList(ArayTmp, 0xF055, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(DeviceType)) == true) { for (int i = 0; i < Areas.Count; i++) { if (Areas[i].bytDefaultSce != 255) { Areas[i].bytDefaultSce = CsConst.myRevBuf[25 + i]; } } CsConst.myRevBuf = new byte[1200]; HDLUDP.TimeBetwnNext(1); } } } #endregion if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(20 + 60 + intI / 13, null); } } MyRead2UpFlags[7] = true; } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(60, null); } } MyRead2UpFlags[0] = true; if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(100, null); } }
public bool DownLoadInfoFrmDeviceNetVersion(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, false) == false) { return(false); } else { byte[] arayRemark = new byte[20]; for (int intI = 0; intI < 20; intI++) { arayRemark[intI] = CsConst.myRevBuf[25 + intI]; } DeviceName = bytSubID.ToString() + "-" + bytDevID.ToString() + "\\" + HDLPF.Byte2String(arayRemark); CsConst.myRevBuf = new byte[1200]; } if (CsConst.isRestore) { num1 = 1; num2 = 64; } if (intActivePage == 0 || intActivePage == 1) { ArayTmp = new byte[1]; ArayTmp[0] = 0; if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x1388, bytSubID, bytDevID, false, true, true, false) == true) { Enable = (CsConst.myRevBuf[26] == 1); strIP = CsConst.myRevBuf[27].ToString("D3") + "." + CsConst.myRevBuf[28].ToString("D3") + "." + CsConst.myRevBuf[29].ToString("D3") + "." + CsConst.myRevBuf[30].ToString("D3"); Port = CsConst.myRevBuf[31] * 256 + CsConst.myRevBuf[32]; } else { return(false); } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(5, null); } myACSetting = new List <ThirdPartAC>(); for (int i = num1; i <= num2; i++) { ArayTmp = new byte[1]; ArayTmp[0] = Convert.ToByte(i); if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x1388, bytSubID, bytDevID, false, true, true, false) == true) { ThirdPartAC temp = new ThirdPartAC(); temp.ID = Convert.ToByte(i); temp.Enable = CsConst.myRevBuf[26]; temp.ACNO = CsConst.myRevBuf[27]; temp.GroupID = CsConst.myRevBuf[28]; temp.arayACinfo = new byte[3]; Array.Copy(CsConst.myRevBuf, 29, temp.arayACinfo, 0, 3); myACSetting.Add(temp); } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(5 + i, null); } } } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(100, null); } return(true); }
public bool DownLoadInformationFrmDevice(string DevName, int DeviceType, int intActivePage)// 0 mean all, else that tab only { string strMainRemark = DevName.Split('\\')[1].Trim(); String TmpDevName = DevName.Split('\\')[0].Trim(); byte bytSubID = byte.Parse(TmpDevName.Split('-')[0].ToString()); byte bytDevID = byte.Parse(TmpDevName.Split('-')[1].ToString()); byte[] ArayTmp = null; int wdMaxValue = DeviceTypeList.GetMaxValueFromPublicModeGroup(DeviceType); if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x000E, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(DeviceType)) == false) { return(false); } else { byte[] arayRemark = new byte[20]; HDLSysPF.CopyRemarkBufferFrmMyRevBuffer(CsConst.myRevBuf, arayRemark, 25); DeviceName = bytSubID.ToString() + "-" + bytDevID.ToString() + "\\" + HDLPF.Byte2String(arayRemark); } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(5); } if (intActivePage == 0 || intActivePage == 1) { MyBasicInfo.arayElectri = new byte[13]; MyBasicInfo.arayAlarm = new byte[8]; if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x1D80, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(DeviceType)) == true) { Array.Copy(CsConst.myRevBuf, 25, MyBasicInfo.arayElectri, 0, 13); HDLUDP.TimeBetwnNext(10); CsConst.myRevBuf = new byte[1200]; } else { return(false); } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(10); } if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x1D90, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(DeviceType)) == true) { Array.Copy(CsConst.myRevBuf, 26, MyBasicInfo.arayAlarm, 0, 8); HDLUDP.TimeBetwnNext(10); CsConst.myRevBuf = new byte[1200]; } else { return(false); } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(15); } MyRead2UpFlags[0] = true; } if (intActivePage == 0 || intActivePage == 2) { MyBasicInfo.araAdjustV = new byte[2]; MyBasicInfo.araAdjustE = new byte[2]; MyBasicInfo.araAdjustP = new byte[2]; if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x1D84, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(DeviceType)) == true) { Array.Copy(CsConst.myRevBuf, 26, MyBasicInfo.araAdjustV, 0, 2); HDLUDP.TimeBetwnNext(1); CsConst.myRevBuf = new byte[1200]; } else { return(false); } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(20); } if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x1D88, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(DeviceType)) == true) { Array.Copy(CsConst.myRevBuf, 26, MyBasicInfo.araAdjustE, 0, 2); HDLUDP.TimeBetwnNext(1); CsConst.myRevBuf = new byte[1200]; } else { return(false); } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(25); } if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x1D8C, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(DeviceType)) == true) { Array.Copy(CsConst.myRevBuf, 26, MyBasicInfo.araAdjustP, 0, 2); HDLUDP.TimeBetwnNext(1); CsConst.myRevBuf = new byte[1200]; } else { return(false); } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(30); } MyRead2UpFlags[1] = true; } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(100); } return(true); }
/// <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); } }
public bool DownLoadInfoFrmDevice(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)) == true) { byte[] arayRemark = new byte[20]; for (int intI = 0; intI < 20; intI++) { arayRemark[intI] = CsConst.myRevBuf[25 + intI]; } DevNam = bytSubID.ToString() + "-" + bytDevID.ToString() + "\\" + HDLPF.Byte2String(arayRemark); HDLUDP.TimeBetwnNext(1); } else { return(false); } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(5, null); } if (intActivePage == 0 || intActivePage == 1) { if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x352D, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(wdDeviceType)) == 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(6, null); } arayBasic = new byte[] { 7, 7, 7, 7, 0 }; if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x3525, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(wdDeviceType)) == 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(7, null); } arayInfo = new byte[20]; if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x350C, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(wdDeviceType)) == 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(8, null); } arayCall = new byte[20]; if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x138E, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(wdDeviceType)) == 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(9, null); } if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x3533, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(wdDeviceType)) == true) { arayInfo[2] = CsConst.myRevBuf[25]; HDLUDP.TimeBetwnNext(1); } else { return(false); } if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x353B, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(wdDeviceType)) == true) { arayInfo[3] = CsConst.myRevBuf[25]; arayInfo[4] = CsConst.myRevBuf[26]; HDLUDP.TimeBetwnNext(1); } else { return(false); } if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x3342, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(wdDeviceType)) == true) { arayInfo[5] = CsConst.myRevBuf[25]; arayInfo[6] = CsConst.myRevBuf[26]; arayInfo[7] = CsConst.myRevBuf[27]; arayInfo[8] = CsConst.myRevBuf[28]; arayInfo[9] = CsConst.myRevBuf[29]; HDLUDP.TimeBetwnNext(1); } else { return(false); } //刷卡使能位 if (CsConst.mySends.AddBufToSndList(null, 0x3344, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(wdDeviceType)) == true) { bEnableCard = CsConst.myRevBuf[25]; HDLUDP.TimeBetwnNext(1); } else { return(false); } } if (intActivePage == 0 || intActivePage == 2) { MyCardInfo = new List <CardInfo>(); for (int i = 0; i < 32; i++) { CardInfo temp = new CardInfo(); temp.UID = new byte[10]; temp.UIDL = 0; temp.CardType = 0; temp.CardNum = Convert.ToByte(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); } ArayTmp = new byte[4]; ArayTmp[0] = 0; ArayTmp[1] = 0; ArayTmp[2] = 0; ArayTmp[3] = 32; if (CsConst.mySends.AddBufToSndList(ArayTmp, 0xE474, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(wdDeviceType)) == true) { byte[] arayValid = new byte[4]; Array.Copy(CsConst.myRevBuf, 29, arayValid, 0, 4); string strEnable = ""; for (int i = 0; i < 4; i++) { string strTmp = GlobalClass.AddLeftZero(Convert.ToString(arayValid[i], 2), 8); for (int j = 7; j >= 0; j--) { string str = strTmp.Substring(j, 1); strEnable = strEnable + str; } } for (int i = 0; i < 32; i++) { if (strEnable.Substring(i, 1) == "1") { ArayTmp = new byte[2]; ArayTmp[0] = 0; ArayTmp[1] = Convert.ToByte(i + 1); if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x3516, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(wdDeviceType)) == 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); } } } } else { return(false); } MyRead2UpFlags[1] = true; } if (intActivePage == 0 || intActivePage == 3) { 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(wdDeviceType)) == 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(wdDeviceType)) == 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 + 1), null); } } } } else { return(false); } MyRead2UpFlags[2] = true; } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(100, null); } return(true); }
private void btnManual_Click(object sender, EventArgs e) { try { Cursor.Current = Cursors.WaitCursor; byte[] ArayTmp = new byte[0]; byte bytSubID = Convert.ToByte(txtMSub.Text); byte bytDevID = Convert.ToByte(txtMDev.Text); if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x000E, bytSubID, bytDevID, false, true, true, false) == true) { int index = 1; if (CsConst.myOnlines != null && CsConst.myOnlines.Count > 0) { for (int i = 0; i < CsConst.myOnlines.Count; i++) { int intTmp1 = CsConst.myOnlines[i].intDIndex; if (intTmp1 > index) { index = intTmp1; } } } byte[] arayRemark = new byte[20]; Array.Copy(CsConst.myRevBuf, 25, arayRemark, 0, 20); string strRemark = HDLPF.Byte2String(arayRemark); DevOnLine temp = new DevOnLine(); temp.bytSub = CsConst.myRevBuf[17]; temp.bytDev = CsConst.myRevBuf[18]; temp.DevName = temp.bytSub.ToString() + "-" + temp.bytDev.ToString() + "\\" + strRemark.ToString(); temp.DeviceType = CsConst.myRevBuf[19] * 256 + CsConst.myRevBuf[20]; Image oimg1 = HDL_Buspro_Setup_Tool.Properties.Resources.OK; String[] strTmp = DeviceTypeList.GetDisplayInformationFromPublicModeGroup(temp.DeviceType); String deviceModel = strTmp[0]; String deviceDescription = strTmp[1]; if (temp.strVersion == null) { temp.strVersion = ""; } string strVersion = temp.strVersion; if (strVersion == "") { strVersion = "Unread"; } if (CsConst.myOnlines.Count > 0) { bool isAdd = true; foreach (DevOnLine tmp in CsConst.myOnlines) { if (temp.DevName == tmp.DevName && temp.bytSub == tmp.bytSub && temp.bytDev == tmp.bytDev && temp.DeviceType == tmp.DeviceType) { isAdd = false; break; } } if (isAdd) { index = index + 1; temp.intDIndex = index; CsConst.myOnlines.Add(temp); HDLSysPF.AddItsDefaultSettings(temp.DeviceType, temp.intDIndex, temp.DevName); object[] obj = new object[] { false, oimg1, DGV.RowCount + 1, temp.bytSub, temp.bytDev, deviceModel, temp.DevName.Split('\\')[1].ToString(), deviceDescription, strVersion, index, "" }; DGV.Rows.Add(obj); } else { bool isAddRow = true; for (int i = 0; i < DGV.Rows.Count; i++) { if (DGV[9, i].Value.ToString() == index.ToString()) { isAddRow = false; break; } } object[] obj; if (isAddRow) { obj = new object[] { false, oimg1, DGV.RowCount + 1, temp.bytSub, temp.bytDev, deviceModel, temp.DevName.Split('\\')[1].ToString(), deviceDescription, strVersion, index, "" }; DGV.Rows.Add(obj); } obj = new object[] { true, temp.bytSub, temp.bytDev, temp.DevName.Split('\\')[1].ToString(), deviceModel, deviceDescription }; dgvResult.Rows.Add(obj); } } else { temp.intDIndex = 1; if (CsConst.myOnlines == null) { CsConst.myOnlines = new List <DevOnLine>(); } CsConst.myOnlines.Add(temp); HDLSysPF.AddItsDefaultSettings(temp.DeviceType, temp.intDIndex, temp.DevName); object[] obj = new object[] { false, oimg1, DGV.RowCount + 1, temp.bytSub, temp.bytDev, deviceModel, temp.DevName.Split('\\')[1].ToString(), deviceDescription, strVersion, index, "" }; DGV.Rows.Add(obj); obj = new object[] { true, temp.bytSub, temp.bytDev, temp.DevName.Split('\\')[1].ToString(), deviceDescription, deviceModel }; dgvResult.Rows.Add(obj); } CsConst.myRevBuf = new byte[1200]; } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } Cursor.Current = Cursors.Default; }