public bool UploadInfosToDevice(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()); int wdMaxValue = DeviceTypeList.GetMaxValueFromPublicModeGroup(DeviceType); byte[] ArayMain = new byte[20]; byte[] arayTmpRemark = HDLUDP.StringToByte(strMainRemark); HDLSysPF.CopyRemarkBufferToSendBuffer(arayTmpRemark, ArayMain, 0); if (CsConst.mySends.AddBufToSndList(ArayMain, 0x0010, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(DeviceType)) == false) { return(false); } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(5); } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(100); } return(true); }
//<summary> //保存数据库面板设置,将所有数据保存 //</summary> public override void SaveSendIRToDB(int intDeviceType) { base.SaveSendIRToDB(intDeviceType); int wdMaxValue = DeviceTypeList.GetMaxValueFromPublicModeGroup(intDeviceType); Chans = new List <DimmerChannelGenerationTwo>(); for (int i = 0; i < wdMaxValue; i++) { DimmerChannel oChan = Chans[i]; string str = ""; string chid = "", remark = "", loadType = "", MinValue = "", MaxValue = "", MaxLevel = ""; string temp = "", Belongs = ""; if (Chans == null) { return; } temp = "-"; chid += "1" + temp; remark += oChan.remark + temp; loadType += oChan.loadType.ToString() + temp; MinValue += oChan.minValue.ToString() + temp; MaxValue += oChan.maxValue.ToString() + temp; MaxLevel += oChan.maxLevel.ToString() + temp; Belongs += oChan.belongArea.ToString() + temp; str = "insert into dbDevChnsDR(ID,ChannelID,Remark,LoadType,Low,High,MaxValue,AreaID) values(" + "1".ToString() + ",'" + chid + "','" + remark + "','" + loadType + "','" + MinValue + "','" + MaxValue + "','" + MaxLevel + "','" + Belongs + "')"; DataModule.ExecuteSQLDatabase(str); } }
private void frmMain_Load(object sender, EventArgs e) { backgroundWorker1.WorkerReportsProgress = true; backgroundWorker1.WorkerSupportsCancellation = true; CsConst.mstrDefaultPath = Application.StartupPath + @"\Database\Easy_Design.mdb"; LoadControlsText.LoadButtonCoontrolTypeFromDatabaseToPublicClass(); HDLSysPF.GetWeekdaysFromPublicStruct(); //LoadControlsText.CheckAndLoadControlsNew(); LoadControlsText.LoadControlsTextIdListFromXML(); LoadControlsText.DisplayTextToFormWhenFirstShow(this); CsConst.mstrINIDefault = new IniFile(Application.StartupPath + @"\ini\LAN0.ini"); ButtonMode.LoadButtonModeFromDatabaseToPublicClass(); DryMode.LoadButtonModeFromDatabaseToPublicClass(); ButtonControlType.LoadButtonCoontrolTypeFromDatabaseToPublicClass(); DryControlType.LoadButtonCoontrolTypeFromDatabaseToPublicClass(); DeviceTypeList.LoadButtonCoontrolTypeFromDatabaseToPublicClass(); ControlTemplates.ReadAllGroupCommandsFrmDatabase(); HDLSysPF.AutoScale((Form)sender); HDLSysPF.AddedDevicesIndexToAPublicListInt(); GetDeviceList(); // dgOnline.RowCount = 28; }
public String sSimpleFunctionList; // 简易功能分解列表 public static void LoadButtonCoontrolTypeFromDatabaseToPublicClass() { CsConst.myDeviceTypeLists = new List <DeviceTypeList>(); try { string strsql = string.Format("select * from defDeviceType order by DeviceType"); OleDbDataReader dr = DataModule.SearchAResultSQLDB(strsql, CsConst.mstrDefaultPath); if (dr != null) { while (dr.Read()) { DeviceTypeList TmpButtonMode = new DeviceTypeList(); TmpButtonMode.DeviceType = dr.GetInt32(0); if (dr.GetString(1) != null) { TmpButtonMode.sModelChn = dr.GetString(1); } if (dr.GetString(2) != null) { TmpButtonMode.sModelEng = dr.GetString(2); } if (CsConst.iLanguageId == 1) { TmpButtonMode.DeviceName = dr.GetString(3); if (TmpButtonMode.DeviceName.Contains('(')) { TmpButtonMode.DeviceName = TmpButtonMode.DeviceName.Split('(')[0].ToString(); } } else { TmpButtonMode.DeviceName = dr.GetString(4); } TmpButtonMode.iMaxValue = dr.GetInt32(5); if (TmpButtonMode.DeviceType >= 60000) { dr.Close(); return; } else { if (dr.GetString(13) != null) { TmpButtonMode.sSimpleFunctionList = (String)dr.GetString(13); } } CsConst.myDeviceTypeLists.Add(TmpButtonMode); } dr.Close(); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
internal List <RelayChannel> Chans; //12个回路 //<summary> //读取默认的MHIOU设置,将所有数据读取缓存 //</summary> public override void ReadDefaultInfo(int intDeviceType) { base.ReadDefaultInfo(intDeviceType); int wdMaxValue = DeviceTypeList.GetMaxValueFromPublicModeGroup(intDeviceType); Chans = new List <RelayChannel>(); for (int i = 0; i < wdMaxValue; i++) { RelayChannel Chn = new RelayChannel(); #region Chn.Remark = "Relay Chn "; Chn.LoadType = 0; Chn.OnDelay = 0; Chn.ProtectDelay = 0; Chn.intBelongs = 0; #endregion } }
/// <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); } }
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); }
public bool DownLoadInfoFrmDevice(string DevNam, int wdDeviceType, int intActivePage) { 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; int wdMaxValue = DeviceTypeList.GetMaxValueFromPublicModeGroup(wdDeviceType); DeviceName = bytSubID.ToString() + "-" + bytDevID.ToString() + "\\" + HDLSysPF.ReadDeviceMainRemark(bytSubID, bytDevID); if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(5, null); } if (intActivePage == 0 || intActivePage == 1) { #region arayHotel = new byte[13]; ArayTmp = new byte[0]; if (CsConst.mySends.AddBufToSndList(ArayTmp, 0xE010, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(wdDeviceType)) == true) { Backlight = CsConst.myRevBuf[25]; Ledlight = CsConst.myRevBuf[26]; HDLUDP.TimeBetwnNext(1); } else { return(false); } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(10, null); } if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x2014, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(wdDeviceType)) == true) { Array.Copy(CsConst.myRevBuf, 25, arayHotel, 0, 13); HDLUDP.TimeBetwnNext(1); } else { return(false); } #endregion MyRead2UpFlags[0] = true; } byte[] ArayMode = new byte[wdMaxValue]; //按键模式 byte[] ArayDelay = new byte[wdMaxValue * 2]; if (intActivePage == 0 || intActivePage == 2) { #region myKeySetting = new List <Key>(); if (CsConst.mySends.AddBufToSndList(ArayTmp, 0xE008, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(wdDeviceType)) == true) { if (wdDeviceType == 3076) { for (int intJ = 0; intJ < wdMaxValue; intJ++) { ArayMode[intJ] = CsConst.myRevBuf[25 + intJ]; } } else if (wdDeviceType == 3078 || wdDeviceType == 3080) { for (int intJ = 0; intJ < wdMaxValue; intJ++) { ArayMode[intJ] = CsConst.myRevBuf[25 + intJ]; } } else if (wdDeviceType == 3064 || wdDeviceType == 3065 || wdDeviceType == 3068 || wdDeviceType == 3069) { for (int intJ = 0; intJ < wdMaxValue; intJ++) { ArayMode[intJ] = CsConst.myRevBuf[25 + intJ]; } } HDLUDP.TimeBetwnNext(1); } else { return(false); } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(15, null); } if (wdDeviceType != 3058) { if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x2024, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(wdDeviceType)) == true) { Array.Copy(CsConst.myRevBuf, 26, ArayDelay, 0, ArayDelay.Length); HDLUDP.TimeBetwnNext(1); } else { return(false); } } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(20, null); } for (int intI = 0; intI < wdMaxValue; intI++) { ArayTmp = new byte[1]; Key oKey = new Key(); oKey.ID = (Byte)(intI + 1); ArayTmp[0] = oKey.ID; if (oKey.ReadButtonRemarkAndCMDFromDevice(bytSubID, bytDevID, wdDeviceType, -1, 255, false, 0, 0) == false) { return(false); } oKey.Delay = ArayDelay[intI * 2] * 256 + ArayDelay[(intI * 2) + 1]; oKey.Mode = ArayMode[intI]; oKey.KeyTargets = new List <UVCMD.ControlTargets>(); if (oKey.Mode == 10 || oKey.Mode == 14) { for (byte byt = 50; byt <= 98; byt++) { byte[] arayTmp = new byte[2]; arayTmp[0] = Convert.ToByte(oKey.ID); arayTmp[1] = byt; if (CsConst.mySends.AddBufToSndList(arayTmp, 0xE000, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(wdDeviceType)) == true) { UVCMD.ControlTargets oCMD = new UVCMD.ControlTargets(); oCMD.ID = Convert.ToByte(CsConst.myRevBuf[26]); oCMD.Type = CsConst.myRevBuf[27]; //转换为正确的类型 oCMD.SubnetID = CsConst.myRevBuf[28]; oCMD.DeviceID = CsConst.myRevBuf[29]; oCMD.Param1 = CsConst.myRevBuf[30]; oCMD.Param2 = CsConst.myRevBuf[31]; oCMD.Param3 = CsConst.myRevBuf[32]; oCMD.Param4 = CsConst.myRevBuf[33]; oKey.KeyTargets.Add(oCMD); HDLUDP.TimeBetwnNext(1); } else { return(false); } } } myKeySetting.Add(oKey); if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(30 + 5 * intI, null); } } #endregion MyRead2UpFlags[1] = true; } if (intActivePage == 0 || intActivePage == 3) { #region if (wdDeviceType == 3076 || wdDeviceType == 3078 || wdDeviceType == 3080) { if (wdDeviceType == 3076 || wdDeviceType == 3078 || wdDeviceType == 3080) { wdMaxValue = 3; } arayButtonSensitiVity = new byte[wdMaxValue]; arayButtonColor = new byte[wdMaxValue * 6]; arayButtonBalance = new byte[wdMaxValue * 3 + 1]; ArayTmp = null; if (CsConst.mySends.AddBufToSndList(ArayTmp, 0xE150, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(wdDeviceType)) == true) { Array.Copy(CsConst.myRevBuf, 25, arayButtonSensitiVity, 0, wdMaxValue); HDLUDP.TimeBetwnNext(1); } else { return(false); } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(81); } ArayTmp = new byte[1]; for (int i = 1; i <= wdMaxValue; i++) { ArayTmp[0] = Convert.ToByte(i); if (CsConst.mySends.AddBufToSndList(ArayTmp, 0xE14C, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(wdDeviceType)) == true) { Array.Copy(CsConst.myRevBuf, 26, arayButtonColor, (i - 1) * 6, 6); HDLUDP.TimeBetwnNext(1); } else { return(false); } } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(82); } ArayTmp = null; if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x1998, bytSubID, bytDevID, false, false, true, CsConst.minAllWirelessDeviceType.Contains(wdDeviceType)) == true) { for (int i = 1; i <= wdMaxValue; i++) { arayButtonBalance[0] = Convert.ToByte(i); Array.Copy(CsConst.myRevBuf, 25 + (i - 1) * 3, arayButtonBalance, (i - 1) * 3 + 1, 3); } HDLUDP.TimeBetwnNext(1); } MyRead2UpFlags[2] = true; } #endregion } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(100, null); } return(true); }
public bool UploadInfosToDevice(string DevNam, int wdDeviceType, int intActivePage) { 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()); int wdMaxValue = DeviceTypeList.GetMaxValueFromPublicModeGroup(wdDeviceType); byte[] ArayMain = new byte[20]; byte[] arayTmpRemark = HDLUDP.StringToByte(strMainRemark); byte[] ArayTmp = null; if (HDLSysPF.ModifyDeviceMainRemark(bytSubID, bytDevID, strMainRemark, wdDeviceType) == false) { return(false); } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(5, null); } if (intActivePage == 0 || intActivePage == 1) { #region byte[] arayLED = new byte[11]; arayLED[0] = Backlight; // modify LED and backlight arayLED[1] = Ledlight; if (CsConst.mySends.AddBufToSndList(arayLED, 0xE012, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(wdDeviceType)) == true) { HDLUDP.TimeBetwnNext(20); } else { return(false); } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(10, null); } if (CsConst.mySends.AddBufToSndList(arayHotel, 0x2016, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(wdDeviceType)) == true) { HDLUDP.TimeBetwnNext(20); } else { return(false); } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(15, null); } #endregion } if (intActivePage == 0 || intActivePage == 2) { #region byte[] arayKeyMode = new byte[wdMaxValue]; byte[] arayRemark = new byte[21]; byte[] arayDely = new byte[wdMaxValue * 2]; foreach (Key TmpKey in myKeySetting) { arayRemark = new byte[21]; TmpKey.UploadButtonRemarkAndCMDToDevice(bytSubID, bytDevID, wdDeviceType, -1, 255); arayDely[(TmpKey.ID - 1) * 2] = Convert.ToByte(TmpKey.Delay / 256); arayDely[(TmpKey.ID - 1) * 2 + 1] = Convert.ToByte(TmpKey.Delay % 256); arayKeyMode[TmpKey.ID - 1] = TmpKey.Mode; if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(25 + TmpKey.ID, null); } } if (CsConst.mySends.AddBufToSndList(arayKeyMode, 0xE00A, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(wdDeviceType)) == true) { HDLUDP.TimeBetwnNext(20); } else { return(false); } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(40, null); } if (wdDeviceType != 3058 && wdDeviceType != 3060) { if (CsConst.mySends.AddBufToSndList(arayDely, 0x2026, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(wdDeviceType)) == true) { HDLUDP.TimeBetwnNext(20); } else { return(false); } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(45, null); } } #endregion } if (intActivePage == 0 || intActivePage == 3) { #region if (wdDeviceType == 3076 || wdDeviceType == 3078 || wdDeviceType == 3080) { if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(91); } int maxLength = wdMaxValue; if (wdDeviceType == 3076 || wdDeviceType == 3078 || wdDeviceType == 3080) { maxLength = 3; } for (int i = 1; i <= maxLength; i++) { ArayTmp = new byte[7]; ArayTmp[0] = Convert.ToByte(i); Array.Copy(arayButtonColor, (i - 1) * 6, ArayTmp, 1, 6); if (CsConst.mySends.AddBufToSndList(ArayTmp, 0xE14E, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(wdDeviceType)) == true) { HDLUDP.TimeBetwnNext(20); } else { return(false); } } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(92); } if (arayButtonBalance[0] >= 0) { ArayTmp = new byte[arayButtonBalance[0] * 3]; Array.Copy(arayButtonBalance, 1, ArayTmp, 0, arayButtonBalance.Length - 1); if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x199A, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(wdDeviceType)) == true) { HDLUDP.TimeBetwnNext(20); } else { return(false); } } ArayTmp = new byte[maxLength]; Array.Copy(arayButtonSensitiVity, 0, ArayTmp, 0, maxLength); if (CsConst.mySends.AddBufToSndList(ArayTmp, 0xE152, bytSubID, bytDevID, false, false, false, CsConst.minAllWirelessDeviceType.Contains(wdDeviceType)) == true) { HDLUDP.TimeBetwnNext(20); } else { return(false); } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(93); } } #endregion } 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(); string TmpDeviceName = strDevName.Split('\\')[0].Trim(); byte bytSubID = byte.Parse(TmpDeviceName.Split('-')[0].ToString()); byte bytDevID = byte.Parse(TmpDeviceName.Split('-')[1].ToString()); byte[] ArayTmp = new Byte[1]; base.DownLoadInformationFrmDevice(strDevName, intDeviceType, intActivePage, 0, 0); int wdMaxValue = DeviceTypeList.GetMaxValueFromPublicModeGroup(intDeviceType); if (intActivePage == 0 || intActivePage == 3) { // 读取回路信息 Chans = new List <DimmerChannelGenerationTwo>(); #region for (int i = 0; i < wdMaxValue; i++) { DimmerChannelGenerationTwo oChn = new DimmerChannelGenerationTwo(); oChn.loadType = 0; oChn.minValue = 0; oChn.maxValue = 100; oChn.maxLevel = 100; ArayTmp[0] = (byte)(i + 1); if (CsConst.mySends.AddBufToSndList(ArayTmp, 0xF00E, bytSubID, bytDevID, false, false, false, false) == true) { if (CsConst.myRevBuf != null) { byte[] arayRemark = new byte[20]; HDLSysPF.CopyRemarkBufferFrmMyRevBuffer(CsConst.myRevBuf, arayRemark, 26); oChn.remark = HDLPF.Byte2String(arayRemark); } CsConst.myRevBuf = new byte[1200]; HDLUDP.TimeBetwnNext(10); } Chans.Add(oChn); if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress((i + 95), null); } } ArayTmp = null; // read low limit ArayTmp = new byte[1]; ArayTmp[0] = 0; if (CsConst.mySends.AddBufToSndList(ArayTmp, 0xF016, bytSubID, bytDevID, false, false, true, false) == true) { for (int i = 0; i < wdMaxValue; i++) { Chans[i].minValue = CsConst.myRevBuf[25]; } CsConst.myRevBuf = new byte[1200]; HDLUDP.TimeBetwnNext(50); } // read high limit ArayTmp[0] = 1; if (CsConst.mySends.AddBufToSndList(ArayTmp, 0xF016, bytSubID, bytDevID, false, false, true, false) == true) { for (int i = 0; i < wdMaxValue; i++) { Chans[i].maxValue = CsConst.myRevBuf[25]; } CsConst.myRevBuf = new byte[1200]; HDLUDP.TimeBetwnNext(50); } // read High Level ArayTmp = null; if (CsConst.mySends.AddBufToSndList(ArayTmp, 0xF020, bytSubID, bytDevID, false, false, true, false) == true) { for (int i = 0; i < wdMaxValue; i++) { Chans[i].maxLevel = CsConst.myRevBuf[25]; } CsConst.myRevBuf = new byte[1200]; HDLUDP.TimeBetwnNext(10); } //读取调光曲线 if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x3366, bytSubID, bytDevID, false, true, true, true) == true) { if (CsConst.myRevBuf != null) { for (int i = 0; i < wdMaxValue; i++) { Chans[i].dimmingProfile = CsConst.myRevBuf[25 + i]; } } CsConst.myRevBuf = new byte[1200]; HDLUDP.TimeBetwnNext(10); if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(39, null); } } } #endregion MyRead2UpFlags[0] = true; if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(100, null); } BlnIsSuccess = true; return; }
/// <summary> /// upload panel information to device /// </summary> /// <param name="DIndex"></param> /// <param name="DevID"></param> /// <param name="DeviceType"></param> /// <param name="DevName"></param> /// <returns></returns> public override bool UploadPanelInfosToDevice(string DevName, int intActivePage, int DeviceType)// 0 mean all, else that tab only { //保存回路信息 string strMainRemark = DevName.Split('\\')[1].Trim(); string TmpDevName = DevName.Split('\\')[0].Trim(); byte SubNetID = byte.Parse(TmpDevName.Split('-')[0].ToString()); byte DeviceID = byte.Parse(TmpDevName.Split('-')[1].ToString()); int wdMaxValue = DeviceTypeList.GetMaxValueFromPublicModeGroup(DeviceType); base.UploadPanelInfosToDevice(DeviceName, intActivePage, DeviceType); Byte FhLowLimit = 5; Byte FhHighLimit = 35; if (DLPFH == null) { DLPFH = new FloorHeating(); } else { FhLowLimit = DLPFH.minTemp; FhHighLimit = DLPFH.maxTemp; } if (intActivePage == 0 || intActivePage == 3)//空调窗体 { if (DLPAC != null) { DLPAC.UploadACSettingToDevice(SubNetID, DeviceID, DeviceType, bytTempType, FhLowLimit, FhHighLimit, AdjustValue); } } else if (intActivePage == 0 || intActivePage == 4) //音乐窗体 { #region byte[] ArayTmp = new byte[3]; ArayTmp[0] = DLPMusic.bytEnable; ArayTmp[1] = DLPMusic.bytCurZone; ArayTmp[2] = DLPMusic.bytMusicType; CsConst.mySends.AddBufToSndList(ArayTmp, 0x1932, SubNetID, DeviceID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(DeviceType)); HDLUDP.TimeBetwnNext(ArayTmp.Length); ArayTmp = new byte[25]; ArayTmp[0] = 0; Array.Copy(DLPMusic.ArayDevs, 0, ArayTmp, 1, 24); CsConst.mySends.AddBufToSndList(ArayTmp, 0x1936, SubNetID, DeviceID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(DeviceType)); HDLUDP.TimeBetwnNext(ArayTmp.Length); Byte CmdID = 0; foreach (UVCMD.ControlTargets TmpCmd in DLPMusic.KeyTargets) { if (TmpCmd != null) { if (TmpCmd.ID == 0) { TmpCmd.ID = 1; } byte[] arayCMD = new byte[8]; arayCMD[0] = CmdID; arayCMD[1] = TmpCmd.Type; arayCMD[2] = TmpCmd.SubnetID; arayCMD[3] = TmpCmd.DeviceID; arayCMD[4] = TmpCmd.Param1; arayCMD[5] = TmpCmd.Param2; arayCMD[6] = TmpCmd.Param3; // save targets arayCMD[7] = TmpCmd.Param4; CsConst.mySends.AddBufToSndList(arayCMD, 0x195C, SubNetID, DeviceID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(DeviceType)); HDLUDP.TimeBetwnNext(arayCMD.Length); } CmdID++; } #endregion MyRead2UpFlags[4] = true; } else if (intActivePage == 0 || intActivePage == 5) //地热窗体 { if (DLPAC == null) { DLPAC = new ACSetting(); Byte TempOldLowlimit = 5; Byte TempOldHighLimit = 35; DLPAC.ReadDLPACPTemperatureRange(SubNetID, DeviceID, DeviceType, ref TempOldLowlimit, ref TempOldHighLimit); } DLPFH.UploadFloorheatingSettingToDevice(SubNetID, DeviceID, DeviceType, DLPAC.bytTempArea); } else if (intActivePage == 0 || intActivePage == 9) // 触摸14按键面板 { // LEd颜色 #region if (CsConst.mintMPTLDeviceType.Contains(DeviceType)) { if (arayButtonColor != null) { if (arayButtonColor.Length == 387 && arayButtonColor[0] == 7) { Byte[] ArayMain = null; if (DeviceType == 170 || DeviceType == 172 || DeviceType == 175) { ArayMain = new byte[9]; ArayMain[0] = 0; Array.Copy(arayButtonColor, 1, ArayMain, 1, 8); if (CsConst.mySends.AddBufToSndList(ArayMain, 0x198E, SubNetID, DeviceID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(DeviceType)) == false) { return(false); } CsConst.myRevBuf = new byte[1200]; HDLUDP.TimeBetwnNext(20); } else { ArayMain = new byte[5]; ArayMain[0] = 0; Array.Copy(arayButtonColor, 1, ArayMain, 1, 5); if (CsConst.mySends.AddBufToSndList(ArayMain, 0x198E, SubNetID, DeviceID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(DeviceType)) == false) { return(false); } CsConst.myRevBuf = new byte[1200]; HDLUDP.TimeBetwnNext(20); } for (int i = 1; i <= 7; i++) { ArayMain = new byte[55]; ArayMain[0] = Convert.ToByte(i); Array.Copy(arayButtonColor, (i - 1) * 54 + 9, ArayMain, 1, 54); if (CsConst.mySends.AddBufToSndList(ArayMain, 0x198E, SubNetID, DeviceID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(DeviceType)) == false) { return(false); } CsConst.myRevBuf = new byte[1200]; HDLUDP.TimeBetwnNext(20); } } } } #endregion //白平衡 #region if (arayButtonBalance[0] > 0) { byte[] arayTmp = new byte[arayButtonBalance[0] * 3]; Array.Copy(arayButtonBalance, 1, arayTmp, 0, arayButtonBalance.Length - 1); if (CsConst.mySends.AddBufToSndList(arayTmp, 0x199A, SubNetID, DeviceID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(DeviceType)) == true) { CsConst.myRevBuf = new byte[1200]; HDLUDP.TimeBetwnNext(10); } else { return(false); } } #endregion //休眠 #region if (DeviceType == 175 || DeviceType == 180 || DeviceType == 5004) { if (araySleep != null) { byte[] arayTmp = new byte[5]; Array.Copy(araySleep, 1, arayTmp, 0, 5); if (CsConst.mySends.AddBufToSndList(arayTmp, 0xE4F8, SubNetID, DeviceID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(DeviceType)) == true) { CsConst.myRevBuf = new byte[1200]; } } } #endregion //基本信息 #region //2014-12-25 新增休眠模式(状态灯关闭延迟、红外感应按键号) Byte[] bytTmp = new byte[8]; // 显示要不要跳转,跳转时间 bytTmp[0] = otherInfo.bytBacklightTime; bytTmp[1] = otherInfo.bytBacklight; bytTmp[2] = otherInfo.bytGotoPage; bytTmp[3] = otherInfo.bytGotoTime; bytTmp[4] = 0; bytTmp[5] = otherInfo.AutoLock; bytTmp[6] = 0; bytTmp[7] = 0; if (DeviceType == 165) { bytTmp[4] = otherInfo.SoundClick; bytTmp[5] = otherInfo.AutoLock; bytTmp[6] = otherInfo.bytLigthDelayState; bytTmp[7] = otherInfo.IRCloseTargets; } if (DeviceType == 168 || DeviceType == 170 || DeviceType == 172 || DeviceType == 175) { bytTmp = new byte[9]; // 显示要不要跳转,跳转时间 bytTmp[0] = otherInfo.bytBacklightTime; bytTmp[1] = otherInfo.bytBacklight; bytTmp[2] = otherInfo.bytGotoPage; bytTmp[3] = otherInfo.bytGotoTime; bytTmp[4] = otherInfo.SoundClick; bytTmp[5] = otherInfo.AutoLock; bytTmp[6] = otherInfo.bytLigthDelayState; bytTmp[7] = otherInfo.IRCloseTargets; bytTmp[8] = otherInfo.IRCloseSensor; if (otherInfo.isHasSensorSensitivity) { bytTmp = new byte[10]; // 显示要不要跳转,跳转时间 bytTmp[0] = otherInfo.bytBacklightTime; bytTmp[1] = otherInfo.bytBacklight; bytTmp[2] = otherInfo.bytGotoPage; bytTmp[3] = otherInfo.bytGotoTime; bytTmp[4] = otherInfo.SoundClick; bytTmp[5] = otherInfo.AutoLock; bytTmp[6] = otherInfo.bytLigthDelayState; bytTmp[7] = otherInfo.IRCloseTargets; bytTmp[8] = otherInfo.IRCloseSensor; bytTmp[9] = otherInfo.CloseToSensorSensitivity; } } if (CsConst.mySends.AddBufToSndList(bytTmp, 0xE13A, SubNetID, DeviceID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(DeviceType)) == false) { return(false); } HDLUDP.TimeBetwnNext(otherInfo.bytAryShowPage.Length); CsConst.myRevBuf = new byte[1200]; #endregion } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(100); } return(true); }
public override void DownLoadInformationFrmDevice(string DevName, int intActivePage, int DeviceType, int num1, int num2)// 0 mean all, else that tab only { string strMainRemark = DevName.Split('\\')[1].Trim(); String TmpDevName = DevName.Split('\\')[0].Trim(); byte SubNetID = byte.Parse(TmpDevName.Split('-')[0].ToString()); byte DeviceID = byte.Parse(TmpDevName.Split('-')[1].ToString()); byte[] ArayTmp = null; int wdMaxValue = DeviceTypeList.GetMaxValueFromPublicModeGroup(DeviceType); base.DownLoadInformationFrmDevice(DeviceName, intActivePage, DeviceType, num1, num2); IsBrdTemp = (arayTempBroadCast[1] == 1); String sBrdName = arayTempBroadCast[2].ToString() + "-" + arayTempBroadCast[3].ToString(); BrdDev = new DeviceInfo(sBrdName); if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(25); } Byte FhLowLimit = 5; Byte FhHighLimit = 35; DLPAC = new ACSetting(); if (intActivePage == 0 || intActivePage == 2) { ModifyPageVisibleOrNotInformation(SubNetID, DeviceID, DeviceType); } if (intActivePage == 0 || intActivePage == 3) { DLPAC.DownloadACSettingFromDevice(SubNetID, DeviceID, DeviceType, ref AdjustValue, ref FhLowLimit, ref FhHighLimit); if (DLPFH == null) { DLPFH = new FloorHeating(); } DLPFH.minTemp = FhLowLimit; DLPFH.maxTemp = FhHighLimit; } else if (intActivePage == 0 || intActivePage == 4) { // music setup #region DLPMusic = new BGMusic(); if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x1930, SubNetID, DeviceID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(DeviceType)) == true) { DLPMusic.bytEnable = CsConst.myRevBuf[25]; //背光时间 ,永远显示:0,其他 10-99s DLPMusic.bytCurZone = CsConst.myRevBuf[26]; //背光亮度 DLPMusic.bytMusicType = CsConst.myRevBuf[27]; //不跳转0,其他页面1-7 //otherInfo.bytGotoTime = CsConst.myRevBuf[28]; //20-150s CsConst.myRevBuf = new byte[1200]; } DLPMusic.ArayDevs = new byte[48]; ArayTmp = new byte[1]; for (byte bytI = 0; bytI < 2; bytI++) { ArayTmp[0] = bytI; if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x1934, SubNetID, DeviceID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(DeviceType)) == true) { Array.Copy(CsConst.myRevBuf, 27, DLPMusic.ArayDevs, bytI * 24, 24); CsConst.myRevBuf = new byte[1200]; } } // read advance commands when playing DLPMusic.KeyTargets = new UVCMD.ControlTargets[14]; ArayTmp = new byte[1]; Byte bTotalMusic = 8; if (DLPPanelDeviceTypeList.DLPWithNewMusicSources.Contains(DeviceType)) // new music sources { bTotalMusic = 14; } for (byte bytI = 0; bytI < bTotalMusic; bytI++) { ArayTmp[0] = bytI; if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x195A, SubNetID, DeviceID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(DeviceType)) == true) { DLPMusic.KeyTargets[bytI] = new UVCMD.ControlTargets(); DLPMusic.KeyTargets[bytI].ID = CsConst.myRevBuf[26]; DLPMusic.KeyTargets[bytI].Type = CsConst.myRevBuf[27]; DLPMusic.KeyTargets[bytI].SubnetID = CsConst.myRevBuf[28]; DLPMusic.KeyTargets[bytI].DeviceID = CsConst.myRevBuf[29]; DLPMusic.KeyTargets[bytI].Param1 = CsConst.myRevBuf[30]; DLPMusic.KeyTargets[bytI].Param2 = CsConst.myRevBuf[31]; DLPMusic.KeyTargets[bytI].Param3 = CsConst.myRevBuf[32]; DLPMusic.KeyTargets[bytI].Param4 = CsConst.myRevBuf[33]; CsConst.myRevBuf = new byte[1200]; } } #endregion } else if (intActivePage == 0 || intActivePage == 5) // 地热页面 { DLPFH = new FloorHeating(); if (DLPAC == null) { DLPAC = new ACSetting(); } DLPFH.DownloadFloorheatingsettingFromDevice(SubNetID, DeviceID, DeviceType, ref DLPAC.bytTempArea); } else if (intActivePage == 0 || intActivePage == 9) // LED颜色和快捷键页面 { //页面跳转信息 #region if (CsConst.mySends.AddBufToSndList(ArayTmp, 0xE138, SubNetID, DeviceID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(DeviceType)) == true) { otherInfo.bytBacklightTime = CsConst.myRevBuf[25]; //背光时间 ,永远显示:0,其他 10-99s otherInfo.bytBacklight = CsConst.myRevBuf[26]; //背光亮度 otherInfo.bytGotoPage = CsConst.myRevBuf[27]; //不跳转0,其他页面1-7 otherInfo.bytGotoTime = CsConst.myRevBuf[28]; //20-150s otherInfo.AutoLock = CsConst.myRevBuf[30]; if (CsConst.mintMPTLDeviceType.Contains(DeviceType)) { otherInfo.bytLigthDelayState = CsConst.myRevBuf[31]; otherInfo.IRCloseTargets = CsConst.myRevBuf[32]; otherInfo.IRCloseSensor = CsConst.myRevBuf[33]; if (CsConst.myRevBuf[16] >= 0x15) { otherInfo.isHasSensorSensitivity = true; otherInfo.CloseToSensorSensitivity = CsConst.myRevBuf[34]; } else { otherInfo.isHasSensorSensitivity = false; } } CsConst.myRevBuf = new byte[1200]; } #endregion //白平衡 #region ArayTmp = null; if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x1998, SubNetID, DeviceID, false, false, true, CsConst.minAllWirelessDeviceType.Contains(DeviceType)) == true) { int num = wdMaxValue; if (CsConst.mintMPTLDeviceType.Contains(DeviceType)) { arayButtonBalance = new byte[12 * 3 + 1]; num = 12; } for (int i = 1; i <= num; i++) { arayButtonBalance[0] = Convert.ToByte(i); Array.Copy(CsConst.myRevBuf, 25 + (i - 1) * 3, arayButtonBalance, (i - 1) * 3 + 1, 3); } } #endregion //睡眠模式 #region if (DeviceType == 175 || DeviceType == 180 || DeviceType == 5004) { araySleep = new byte[6]; if (CsConst.mySends.AddBufToSndList(ArayTmp, 0xE4FA, SubNetID, DeviceID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(DeviceType)) == true) { araySleep[0] = 1; Array.Copy(CsConst.myRevBuf, 25, araySleep, 1, 5); CsConst.myRevBuf = new byte[1200]; } } MyRead2UpFlags[9] = true; #endregion // LED颜色和快捷键 #region arayButtonColor = new byte[387]; for (int i = 0; i <= 7; i++) { ArayTmp = new byte[1]; ArayTmp[0] = Convert.ToByte(i); if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x198C, SubNetID, DeviceID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(DeviceType)) == true) { arayButtonColor[0] = Convert.ToByte(i); if (i == 0) { Array.Copy(CsConst.myRevBuf, 26, arayButtonColor, 1, 8); } else { Array.Copy(CsConst.myRevBuf, 26, arayButtonColor, (i - 1) * 54 + 9, 54); } CsConst.myRevBuf = new byte[1200]; HDLUDP.TimeBetwnNext(10); } } #endregion } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(100); } }
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; }
void calculationWorker_DoWork(object sender, DoWorkEventArgs e) { try { UDPReceive.receiveQueue.Clear(); dgvResult.Rows.Clear(); if (CsConst.myOnlines == null) { CsConst.myOnlines = new List <DevOnLine>(); } //CsConst.mySends.AddBufToSndList(null, 0x000E, 255, 255, false, false, false, false); lbCurrentSubValue.Text = txtASub.Text; if (txtASub.Text == "255" || (txtADev1.Text == "255" && txtADev2.Text == "255")) { Process.Visible = false; lbCurrentDevValue.Text = "255"; CsConst.FastSearch = true; Byte RepeatSendTimes = 1; Random R1 = new Random(); Random R2 = new Random(); List <Byte> SearchDeviceAddressesList = new List <byte>(); R1.Next(); Byte[] RandomWhenSearch = new Byte[2]; R1.NextBytes(RandomWhenSearch); Byte[] DataSendBuffer = new Byte[2 + SearchDeviceAddressesList.Count]; RandomWhenSearch.CopyTo(DataSendBuffer, 0); RepeatSearch: if (SearchDeviceAddressesList != null && SearchDeviceAddressesList.Count > 0) { DataSendBuffer = new Byte[2 + SearchDeviceAddressesList.Count]; RandomWhenSearch.CopyTo(DataSendBuffer, 0); SearchDeviceAddressesList.CopyTo(DataSendBuffer, 2); SearchDeviceAddressesList = new List <byte>(); } CsConst.mySends.AddBufToSndList(DataSendBuffer, 0x000E, 255, 255, false, false, false, false); // 广播搜索方式汇集 #region DateTime d1, d2; d1 = DateTime.Now; d2 = DateTime.Now; while (UDPReceive.receiveQueue.Count > 0 || HDLSysPF.Compare(d2, d1) < 2000) { if (isStopSearch) { break; } d2 = DateTime.Now; if (UDPReceive.receiveQueue.Count > 0) { byte[] readData = UDPReceive.receiveQueue.Dequeue(); if (readData[21] == 0x00 && readData[22] == 0x0F && readData.Length >= 45) { int index = 1; while (CsConst.AddedDevicesIndexGroup.Contains(index)) { index++; } DevOnLine temp = new DevOnLine(); byte[] arayRemark = new byte[20]; HDLSysPF.CopyRemarkBufferFrmMyRevBuffer(readData, arayRemark, 25); string strRemark = HDLPF.Byte2String(arayRemark); temp.bytSub = readData[17]; temp.bytDev = readData[18]; temp.DevName = temp.bytSub.ToString() + "-" + temp.bytDev.ToString() + "\\" + strRemark.ToString(); temp.DeviceType = readData[19] * 256 + readData[20]; temp.strVersion = "Unread"; temp.intDIndex = index; String[] strTmp = DeviceTypeList.GetDisplayInformationFromPublicModeGroup(temp.DeviceType); String deviceDescription = strTmp[1]; String strModel = strTmp[0]; if (temp.strVersion == null) { temp.strVersion = ""; } string strVersion = temp.strVersion; if (strVersion == "") { strVersion = "Unread"; } object[] obj1 = new object[] { true, temp.bytSub, temp.bytDev, temp.DevName.Split('\\')[1].ToString(), deviceDescription, strModel, temp.DeviceType }; object[] obj2 = { false, HDL_Buspro_Setup_Tool.Properties.Resources.OK, DGV.RowCount + 1, temp.bytSub, temp.bytDev, strModel, temp.DevName.Split('\\')[1].ToString(), deviceDescription, strVersion, temp.intDIndex.ToString(), "", temp.DeviceType }; Boolean isAddDeviceToMain = true; // 是不是增加到在线设备列表和主窗体 #region if (CsConst.myOnlines.Count > 0) { foreach (DevOnLine tmp in CsConst.myOnlines) { if (temp.DevName == tmp.DevName && temp.bytSub == tmp.bytSub && temp.bytDev == tmp.bytDev && temp.DeviceType == tmp.DeviceType) { isAddDeviceToMain = false; break; } } } if (isAddDeviceToMain) { CsConst.myOnlines.Add(temp); HDLSysPF.AddItsDefaultSettings(temp.DeviceType, temp.intDIndex, temp.DevName); CsConst.AddedDevicesIndexGroup.Add(index); if (this.DGV.InvokeRequired)//等待异步 { FlushClient2 fc = new FlushClient2(ThreadFunction2); this.DGV.Invoke(fc, new object[] { obj2 }); } else { DGV.Rows.Add(obj2); } } #endregion //添加到当前窗体 #region isAddToList = true; if (dgvResult.Rows.Count > 0) { for (int i = 0; i < dgvResult.Rows.Count; i++) { if (temp.DevName == dgvResult[1, i].Value.ToString() + "-" + dgvResult[2, i].Value.ToString() + "\\" + dgvResult[3, i].Value.ToString()) { isAddToList = false; break; } } if (isAddToList) { if (this.dgvResult.InvokeRequired)//等待异步 { FlushClient1 fc = new FlushClient1(ThreadFunction1); this.dgvResult.Invoke(fc, new object[] { obj1 }); } else { dgvResult.Rows.Add(obj1); } } } else { if (this.dgvResult.InvokeRequired)//等待异步 { FlushClient1 fc = new FlushClient1(ThreadFunction1); this.dgvResult.Invoke(fc, new object[] { obj1 }); } else { dgvResult.Rows.Add(obj1); } } if (isAddToList) { SearchDeviceAddressesList.Add(temp.bytSub); SearchDeviceAddressesList.Add(temp.bytDev); } #endregion } } } #endregion RepeatSendTimes++; if (RepeatSendTimes <= 4) { goto RepeatSearch; } } else { Process.Visible = true; SubnetID = Convert.ToByte(txtASub.Text); DeviceID1 = Convert.ToByte(txtADev1.Text); DeviceID2 = Convert.ToByte(txtADev2.Text); int intTmp = 0; for (byte byt = DeviceID1; byt <= DeviceID2; byt++) { if (isStopSearch) { break; } byte[] ArayTmp = new byte[0]; byte bytSubID = Convert.ToByte(SubnetID); byte bytDevID = Convert.ToByte(byt); if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x000E, bytSubID, bytDevID, false, false, true, false) == true) { int index = 1; if (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]; for (int intI = 0; intI < 20; intI++) { arayRemark[intI] = CsConst.myRevBuf[25 + intI]; } 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]; temp.strVersion = "Unread"; String[] strArayTmp = DeviceTypeList.GetDisplayInformationFromPublicModeGroup(temp.DeviceType); String deviceDescription = strArayTmp[1]; String strModel = strArayTmp[0]; string strTmp = string.Format("{0,-3}{1,-1}{2,-3}{3,-1}{4,-20}", temp.bytSub.ToString(), "-", temp.bytDev.ToString(), "-", strModel); if (temp.strVersion == null) { temp.strVersion = ""; } string strVersion = temp.strVersion; if (strVersion == "") { strVersion = "Unread"; } isAddDeviceToMain = true; if (CsConst.myOnlines.Count > 0) { foreach (DevOnLine tmp in CsConst.myOnlines) { if (temp.DevName == tmp.DevName && temp.bytSub == tmp.bytSub && temp.bytDev == tmp.bytDev && temp.DeviceType == tmp.DeviceType) { isAddDeviceToMain = false; break; } } if (isAddDeviceToMain) { index = index + 1; temp.intDIndex = index; CsConst.myOnlines.Add(temp); HDLSysPF.AddItsDefaultSettings(temp.DeviceType, temp.intDIndex, temp.DevName); } } else { temp.intDIndex = 1; CsConst.myOnlines.Add(temp); HDLSysPF.AddItsDefaultSettings(temp.DeviceType, temp.intDIndex, temp.DevName); } object[] obj1 = new object[] { true, temp.bytSub, temp.bytDev, temp.DevName.Split('\\')[1].ToString(), deviceDescription, strModel }; object[] obj2 = new object[] { false, DGV.RowCount + 1, temp.DevName.Split('\\')[1].ToString(), deviceDescription, strVersion, temp.bytSub, temp.bytDev, strModel, index, "" }; if (DGV.InvokeRequired)//等待异步 { FlushClient2 fc = new FlushClient2(ThreadFunction2); this.DGV.Invoke(fc, new object[] { obj2 }); } else { if (isAddDeviceToMain) { DGV.Rows.Add(obj2); } } isAddToList = true; if (dgvResult.Rows.Count > 0) { for (int i = 0; i < dgvResult.Rows.Count; i++) { if (temp.DevName == dgvResult[1, i].Value.ToString() + "-" + dgvResult[2, i].Value.ToString() + "\\" + dgvResult[3, i].Value.ToString()) { isAddToList = false; break; } } if (isAddToList) { if (this.dgvResult.InvokeRequired)//等待异步 { FlushClient1 fc = new FlushClient1(ThreadFunction1); this.dgvResult.Invoke(fc, new object[] { obj1 }); } else { dgvResult.Rows.Add(obj1); } } } else { if (this.dgvResult.InvokeRequired)//等待异步 { FlushClient1 fc = new FlushClient1(ThreadFunction1); this.dgvResult.Invoke(fc, new object[] { obj1 }); } else { dgvResult.Rows.Add(obj1); } } //CsConst.myRevBuf = new byte[1200]; //System.Threading.Thread.Sleep(10); } if (byt + 1 <= DeviceID2) { lbCurrentDevValue.Text = (byt + 1).ToString(); } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { if (intTmp * 100 / (DeviceID2 - DeviceID1) <= 100) { CsConst.calculationWorker.ReportProgress(intTmp * 100 / (DeviceID2 - DeviceID1)); } } intTmp++; } } } catch { } }
/// <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]; String Remark = HDLSysPF.ReadDeviceMainRemark(bytSubID, bytDevID); Devname = bytSubID.ToString() + "-" + bytDevID.ToString() + "\\" + Remark; if (intActivePage == 0 || intActivePage == 1) { #region //读取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]; ONLEDs[1] = CsConst.myRevBuf[28]; CsConst.myRevBuf = new byte[1200]; 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]; CsConst.myRevBuf = new byte[1200]; 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]; CsConst.myRevBuf = new byte[1200]; HDLUDP.TimeBetwnNext(1); } else { return; } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(3, null); } #endregion MyRead2UpFlags[1] = 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); CsConst.myRevBuf = new byte[1200]; 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>(); #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); CsConst.myRevBuf = new byte[1200]; HDLUDP.TimeBetwnNext(1); } else { return; } if (oTmp.Enabled == 1) // 有效才读取信息 { if (CsConst.isRestore) { //读取设置 oTmp.DownloadOnlyLogicSettingFromDevice(bytSubID, bytDevID, DeviceType); //读取通用开关信息 #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]; } CsConst.myRevBuf = new byte[1200]; 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]; CsConst.myRevBuf = new byte[1200]; 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]; } CsConst.myRevBuf = new byte[1200]; 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]; CsConst.myRevBuf = new byte[1200]; HDLUDP.TimeBetwnNext(1); } else { return; } #endregion oTmp.DownloadLogicTrueCommandsFromDevice(bytSubID, bytDevID, DeviceType, 0, 0); //不成立的触发目标 oTmp.DownloadLogicFalseCommandsFromDevice(bytSubID, bytDevID, DeviceType, 0, 0); } } logic.Add(oTmp); #endregion if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(10 + intI); } } } else { return; } #endregion MyRead2UpFlags[2] = 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 = 3; intI <= 4; 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); CsConst.myRevBuf = new byte[1200]; 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]; CsConst.myRevBuf = new byte[1200]; HDLUDP.TimeBetwnNext(1); } else { return; } fireset.Add(oTmp); if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(35 + intI); } } #endregion MyRead2UpFlags[3] = 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]; CsConst.myRevBuf = new byte[1200]; HDLUDP.TimeBetwnNext(1); } else { return; } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(31, null); } #endregion MyRead2UpFlags[4] = true; } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(40); } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(100); } }
private void UpdateDataGridViewOfOnlineDevice() { dgOnline.Rows.Clear(); dgOnline.BringToFront(); #region if (CsConst.myOnlines == null) { return; } if (CsConst.myOnlines.Count == 0) { return; } int[,] arayTmp = new int[CsConst.myOnlines.Count, 3]; for (int i = 0; i < CsConst.myOnlines.Count; i++) { arayTmp[i, 0] = CsConst.myOnlines[i].bytSub; arayTmp[i, 1] = CsConst.myOnlines[i].bytDev; arayTmp[i, 2] = Convert.ToInt32(i); } #region for (int i = 0; i < arayTmp.Length / 3; i++) { for (int j = 0; j < (arayTmp.Length / 3) - i - 1; j++) { if ((arayTmp[j, 0] > arayTmp[j + 1, 0]) || ((arayTmp[j, 0] == arayTmp[j + 1, 0]) && (arayTmp[j, 1] > arayTmp[j + 1, 1]))) { int Tmp0 = arayTmp[j, 0]; int Tmp1 = arayTmp[j, 1]; int Tmp2 = arayTmp[j, 2]; arayTmp[j, 0] = arayTmp[j + 1, 0]; arayTmp[j, 1] = arayTmp[j + 1, 1]; arayTmp[j, 2] = arayTmp[j + 1, 2]; arayTmp[j + 1, 0] = Tmp0; arayTmp[j + 1, 1] = Tmp1; arayTmp[j + 1, 2] = Tmp2; } } } #endregion for (int i = 0; i < CsConst.myOnlines.Count; i++) { DevOnLine tmp = CsConst.myOnlines[arayTmp[i, 2]]; if (tmp.DevName == "") { return; } Image oimg1 = HDL_Buspro_Setup_Tool.Properties.Resources.OK; String[] strTmp = DeviceTypeList.GetDisplayInformationFromPublicModeGroup(tmp.DeviceType); String deviceModel = strTmp[0]; String deviceDescription = strTmp[1]; if (tmp.strVersion == null) { tmp.strVersion = ""; } string strVersion = tmp.strVersion; if (strVersion == "") { strVersion = "Unread"; } object[] obj = { false, oimg1, dgOnline.RowCount + 1, tmp.bytSub, tmp.bytDev, deviceModel, tmp.DevName.Split('\\')[1].ToString(), deviceDescription, strVersion, tmp.intDIndex.ToString(), "" }; dgOnline.Rows.Add(obj); } #endregion }
public bool UploadInfosToDevice(string DevNam, int wdDeviceType, int intActivePage) { 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()); int wdMaxValue = DeviceTypeList.GetMaxValueFromPublicModeGroup(wdDeviceType); byte[] arayTmp = new byte[20]; if (HDLSysPF.ModifyDeviceMainRemark(bytSubID, bytDevID, strMainRemark, wdDeviceType) == true) { HDLUDP.TimeBetwnNext(20); } else { return(false); } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(5, null); } if (intActivePage == 0 || intActivePage == 1) { if (strNO == "") { strNO = "0000"; } if (strPassword == "") { strPassword = "******"; } if (strNO.Length < 4) { strNO = GlobalClass.AddLeftZero(strNO, 4); } if (strPassword.Length < 4) { strPassword = GlobalClass.AddLeftZero(strPassword, 6); } arayTmp = HDLUDP.StringToByte(strNO + strPassword); if (CsConst.mySends.AddBufToSndList(arayTmp, 0x352F, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(wdDeviceType)) == true) { HDLUDP.TimeBetwnNext(20); } else { return(false); } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(6, null); } if (CsConst.mySends.AddBufToSndList(arayBasic, 0x3527, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(wdDeviceType)) == true) { HDLUDP.TimeBetwnNext(20); } else { return(false); } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(6, null); } arayTmp = new byte[2]; arayTmp[0] = arayInfo[0]; arayTmp[1] = arayInfo[1]; if (CsConst.mySends.AddBufToSndList(arayTmp, 0x350E, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(wdDeviceType)) == true) { HDLUDP.TimeBetwnNext(20); } else { return(false); } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(7, null); } arayTmp = new byte[11]; Array.Copy(arayCall, 0, arayTmp, 0, 11); if (CsConst.mySends.AddBufToSndList(arayTmp, 0x138C, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(wdDeviceType)) == true) { HDLUDP.TimeBetwnNext(20); } else { return(false); } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(8, null); } arayTmp = new byte[2]; arayTmp[0] = arayInfo[3]; arayTmp[1] = arayInfo[4]; if (CsConst.mySends.AddBufToSndList(arayTmp, 0x353D, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(wdDeviceType)) == true) { HDLUDP.TimeBetwnNext(20); } else { return(false); } arayTmp = new byte[2]; arayTmp[0] = arayInfo[5]; arayTmp[1] = arayInfo[6]; if (CsConst.mySends.AddBufToSndList(arayTmp, 0x3340, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(wdDeviceType)) == true) { HDLUDP.TimeBetwnNext(20); } else { return(false); } arayTmp = new byte[1] { arayInfo[2] }; if (CsConst.mySends.AddBufToSndList(arayTmp, 0x3535, bytSubID, bytDevID, false, false, true, CsConst.minAllWirelessDeviceType.Contains(wdDeviceType)) == true) { HDLUDP.TimeBetwnNext(20); } arayTmp = new byte[1] { bEnableCard }; if (CsConst.mySends.AddBufToSndList(arayTmp, 0x3346, bytSubID, bytDevID, false, false, true, CsConst.minAllWirelessDeviceType.Contains(wdDeviceType)) == true) { HDLUDP.TimeBetwnNext(20); } } if (CsConst.isRestore) { if (intActivePage == 0 || intActivePage == 2) { for (int i = 0; i < MyCardInfo.Count; i++) { if (MyCardInfo[i].CardType != 0 && MyCardInfo[i].CardType != 0xFF) { CardInfo tmp = MyCardInfo[i]; arayTmp = new byte[64]; arayTmp[0] = tmp.UIDL; Array.Copy(tmp.UID, 0, arayTmp, 1, tmp.UIDL); arayTmp[11] = tmp.CardType; arayTmp[12] = Convert.ToByte(tmp.CardNum / 256); arayTmp[13] = Convert.ToByte(tmp.CardNum % 256); arayTmp[14] = Convert.ToByte(tmp.BuildingNO / 256); arayTmp[15] = Convert.ToByte(tmp.BuildingNO % 256); arayTmp[16] = Convert.ToByte(tmp.UnitNO / 256); arayTmp[17] = Convert.ToByte(tmp.UnitNO % 256); arayTmp[18] = Convert.ToByte(tmp.RoomNO / 256); arayTmp[19] = Convert.ToByte(tmp.RoomNO % 256); Array.Copy(tmp.arayDate, 0, arayTmp, 20, tmp.arayDate.Length); Array.Copy(tmp.arayName, 0, arayTmp, 25, tmp.arayName.Length); Array.Copy(tmp.arayPhone, 0, arayTmp, 35, tmp.arayPhone.Length); Byte[] arayTmpRemark = HDLUDP.StringToByte(tmp.Remark); if (arayTmpRemark.Length > 18) { Array.Copy(arayTmpRemark, 0, arayTmp, 46, 18); } else { Array.Copy(arayTmpRemark, 0, arayTmp, 46, arayTmpRemark.Length); } if (CsConst.mySends.AddBufToSndList(arayTmp, 0x3518, bytSubID, bytDevID, false, false, true, CsConst.minAllWirelessDeviceType.Contains(wdDeviceType)) == true) { HDLUDP.TimeBetwnNext(20); } else { return(false); } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(15 + i, null); } } } } } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(100, null); } return(true); }
/// <summary> /// devname device name /// </summary> /// <param name="DevName"></param> public void DownLoadInformationFrmDevice(string DevName, int wdDeviceType) { 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 = new byte[0]; DeviceName = bytSubID.ToString() + "-" + bytDevID.ToString() + "\\" + HDLSysPF.ReadDeviceMainRemark(bytSubID, bytDevID); if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(5, null); } int MaxValue = DeviceTypeList.GetMaxValueFromPublicModeGroup(wdDeviceType); ArayTmp = new byte[1]; Curtains = new List <BasicCurtain>(); // read curtain paramters #region if (CurtainDeviceType.NormalCurtainG1DeviceType.Contains(wdDeviceType) || CurtainDeviceType.CurtainG2DeviceType.Contains(wdDeviceType)) { for (byte bytI = 1; bytI <= MaxValue * 2; bytI++) { ArayTmp[0] = bytI; BasicCurtain oTmp = new BasicCurtain(); oTmp.ReadCurtainSetupInformation(bytSubID, bytDevID, bytI, wdDeviceType); Curtains.Add(oTmp); if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(bytI * 45 / MaxValue, null); } } } #endregion // read joggle time if (CurtainDeviceType.CurtainG2DeviceType.Contains(wdDeviceType)) { bytCurType = 1; } else if (CurtainDeviceType.RollerCurtainDeviceType.Contains(wdDeviceType)) { bytCurType = 2; } else if (CurtainDeviceType.NormalMotorCurtainDeviceType.Contains(wdDeviceType)) { bytCurType = 2; } if (bytCurType == 1) { for (byte bytI = 1; bytI <= 4; bytI++) { ArayTmp[0] = bytI; BasicCurtain oTmp = new BasicCurtain(); if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x1C76, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(wdDeviceType)) == true) { switch (bytI) { case 1: intJogTime = CsConst.myRevBuf[26] * 256 + CsConst.myRevBuf[27]; break; case 2: intJogTime1 = CsConst.myRevBuf[26] * 256 + CsConst.myRevBuf[27]; break; case 3: intJogTime2 = CsConst.myRevBuf[26] * 256 + CsConst.myRevBuf[27]; break; case 4: intJogTime3 = CsConst.myRevBuf[26] * 256 + CsConst.myRevBuf[27]; break; } CsConst.myRevBuf = new byte[1200]; } else { return; } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(80 + bytI, null); } } } else if (bytCurType == 2) { if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x1F02, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(wdDeviceType)) == true) { bytInvert = CsConst.myRevBuf[25]; // forward and backwork or Backward forward bytAutoMeasure = CsConst.myRevBuf[26]; // 上电自动测速 bytDragMode = CsConst.myRevBuf[27]; // 0 : no action, 1 long drag ; 2 short drag intDragLong = (CsConst.myRevBuf[28] * 256 + CsConst.myRevBuf[29]) / 100; intDragShort = (CsConst.myRevBuf[30] * 256 + CsConst.myRevBuf[31]) / 100; intDragSafe = (CsConst.myRevBuf[32] * 256 + CsConst.myRevBuf[33]) / 100; } else { return; } CsConst.myRevBuf = new byte[1200]; if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(95, null); } } MyRead2UpFlags[0] = true; if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(100, null); } }