public Boolean SaveButtonDimFlagToDeviceFrmBuf(Byte RemoteControllerID, Byte bytSubID, Byte sourceDeviceIDvID, int DeviceType) { Boolean blnSuccessModify = false; Byte[] arayKeyMode = new Byte[IPmoduleDeviceTypeList.HowManyButtonsEachPage + 1]; arayKeyMode[IPmoduleDeviceTypeList.HowManyButtonsEachPage] = RemoteControllerID; for (Byte bytI = 0; bytI < IPmoduleDeviceTypeList.HowManyButtonsEachPage; bytI++) { // key mode HDLButton oTmpButton = MyRemoteControllers[RemoteControllerID * IPmoduleDeviceTypeList.HowManyButtonsEachPage + bytI]; arayKeyMode[bytI] = (Byte)((oTmpButton.IsDimmer << 4) + oTmpButton.SaveDimmer); } // upload all key mode blnSuccessModify = CsConst.mySends.AddBufToSndList(arayKeyMode, 0xE136, bytSubID, sourceDeviceIDvID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(DeviceType)); return(blnSuccessModify); }
private void cboPages_SelectedIndexChanged(object sender, EventArgs e) { if (myIPModule == null) { return; } if (cboController.SelectedIndex == -1) { return; } if (cboPages.SelectedIndex == -1) { return; } dgvRfbuttons.Rows.Clear(); Byte ControllerID = Convert.ToByte(cboController.SelectedIndex); Byte PageID = Convert.ToByte(cboPages.SelectedIndex); for (int i = 0; i < 8; i++) { HDLButton obutton = myIPModule.MyRemoteControllers[ControllerID * 64 + PageID * 8 + i]; if (obutton == null) { obutton = new HDLButton(); } String ButtonModeString = ButtonMode.ConvertorKeyModeToPublicModeGroup(obutton.Mode); int TmpMode = cboButtonMode.Items.IndexOf(ButtonModeString); if (TmpMode != -1) { Object[] obj = new object[] { (i + 1).ToString(), obutton.Remark, ButtonModeString }; dgvRfbuttons.Rows.Add(obj); } else { Object[] obj = new object[] { (i + 1).ToString(), obutton.Remark, cboButtonMode.Items[0] }; dgvRfbuttons.Rows.Add(obj); } } }
/// <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); } }
/// <summary> /// 上传设置到窗帘模块 /// </summary> /// <param name="DIndex"></param> /// <param name="DevID"></param> /// <param name="DeviceType"></param> /// <param name="DevName"></param> /// <returns></returns> public bool UploadCurtainInfosToDevice(string DevName, int PageIndex, int DeviceType) { string strMainRemark = DevName.Split('\\')[1].Trim().Split('(')[0].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[] ArayMain = new byte[20]; byte[] arayTmpRemark = HDLUDP.StringToByte(strMainRemark); if (arayTmpRemark.Length > 20) { Array.Copy(arayTmpRemark, 0, ArayMain, 0, 20); } else { Array.Copy(arayTmpRemark, 0, ArayMain, 0, arayTmpRemark.Length); } if (CsConst.mySends.AddBufToSndList(ArayMain, 0x0010, SubNetID, DeviceID, false, true, true, false) == false) { return(false); } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(10, null); } if (PageIndex == 0 || PageIndex == 1) { netWork.ModifyNetworkInfomation(SubNetID, DeviceID); #region byte[] arayTmp = new byte[57]; arayTmp[0] = bytWorkType; arayTmpRemark = HDLUDP.StringToByte(strGroup); Array.Copy(arayTmpRemark, 0, arayTmp, 1, arayTmpRemark.Length); arayTmpRemark = HDLUDP.StringToByte(strPrjName); Array.Copy(arayTmpRemark, 0, arayTmp, 21, arayTmpRemark.Length); arayTmpRemark = HDLUDP.StringToByte(strUser); Array.Copy(arayTmpRemark, 0, arayTmp, 41, arayTmpRemark.Length); arayTmpRemark = HDLUDP.StringToByte(strPWD); Array.Copy(arayTmpRemark, 0, arayTmp, 49, arayTmpRemark.Length); if (CsConst.mySends.AddBufToSndList(arayTmp, 0x3003, SubNetID, DeviceID, false, true, true, false) == false) { return(false); } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(20, null); } arayTmp = new byte[14]; string[] strTmp = strServer1.Split('.'); for (int i = 0; i < 4; i++) { arayTmp[i] = byte.Parse(strTmp[i].ToString()); } arayTmp[4] = (byte)(intPort1 / 256); arayTmp[5] = (byte)(intPort1 % 256); strTmp = strServer2.Split('.'); for (int i = 0; i < 4; i++) { arayTmp[i + 6] = byte.Parse(strTmp[i].ToString()); } arayTmp[10] = (byte)(intPort2 / 256); arayTmp[11] = (byte)(intPort2 % 256); arayTmp[12] = bytEnDHCP; arayTmp[13] = bytTimer; if (CsConst.mySends.AddBufToSndList(arayTmp, 0x3005, SubNetID, DeviceID, false, true, true, false) == false) { return(false); } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(30, null); } #endregion } if (PageIndex == 0 || PageIndex == 2) { //上传拦截列表 #region byte bytI = 0; if (MyBlocks != null) { foreach (RFBlock Tmp in MyBlocks) { Tmp.ModifyfBlockSetupInformation(SubNetID, DeviceID, bytI); if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(50 + bytI); } bytI++; } } #endregion } if (PageIndex == 0 || PageIndex == 3) // 无线遥控器或者无源开关 { #region // 上传无源开关的地址 byte[] RemoteAddress = new Byte[11]; RemoteControllers.CopyTo(RemoteAddress, 3); if (CsConst.mySends.AddBufToSndList(RemoteAddress, 0xE012, SubNetID, DeviceID, false, true, true, false)) { return(false); } 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; } 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[] arayKeyMutex = new Byte[IPmoduleDeviceTypeList.HowManyButtonsEachPage]; Byte[] arayKeyDimmer = new Byte[IPmoduleDeviceTypeList.HowManyButtonsEachPage]; Byte[] arayKeyLED = new Byte[IPmoduleDeviceTypeList.HowManyButtonsEachPage]; for (int j = 0; j < IPmoduleDeviceTypeList.HowManyButtonsEachPage; j++) { HDLButton TmpKey = MyRemoteControllers[i * IPmoduleDeviceTypeList.HowManyButtonsEachPage + j]; // key mode and dimmer valid arayKeyMode[TmpKey.ID - 1] = TmpKey.Mode; arayKeyMutex[TmpKey.ID - 1] = TmpKey.bytMutex; arayKeyDimmer[TmpKey.ID - 1] = byte.Parse(((TmpKey.IsDimmer << 4) + TmpKey.SaveDimmer).ToString()); arayKeyLED[TmpKey.ID - 1] = (byte)(TmpKey.IsLEDON); if (TmpKey.Mode == 0 || TmpKey.Mode > 30) { continue; } TmpKey.UploadButtonRemarkAndCMDToDevice(SubNetID, DeviceID, DeviceType, i + 1, 255); if (TmpKey.ID + 2 < 15) { if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(2 + TmpKey.ID); } } } // upload all key mode if (CsConst.mySends.AddBufToSndList(arayKeyMode, 0xE00A, SubNetID, DeviceID, false, true, true, true) == false) { return(false); } HDLUDP.TimeBetwnNext(64); SaveButtonDimFlagToDeviceFrmBuf(i, SubNetID, DeviceID, DeviceType); CsConst.myRevBuf = new byte[1200]; } #endregion } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(100, null); } return(true); }
/// <summary> /// 不同类型显示到界面 /// </summary> void DisplayButtonParametersToGridTable() { if (MyActiveObject is IPModule) { #region IPModule TmpIpModule = (IPModule)MyActiveObject; if (TmpIpModule == null) { return; } if (cboController.SelectedIndex == -1) { return; } if (cboPages.SelectedIndex == -1) { return; } dgvListA.Rows.Clear(); Byte ControllerID = Convert.ToByte(cboController.SelectedIndex); Byte PageID = Convert.ToByte(cboPages.SelectedIndex); for (int i = 0; i < 8; i++) { HDLButton obutton = TmpIpModule.MyRemoteControllers[ControllerID * 64 + PageID * 8 + i]; if (obutton == null) { obutton = new HDLButton(); } String ButtonModeTmp = ButtonMode.ConvertorKeyModeToPublicModeGroup(obutton.Mode); Object[] obj = new object[] { (i + 1).ToString(), obutton.Remark, ButtonModeTmp, (obutton.IsLEDON == 1), (obutton.IsDimmer == 1), (obutton.SaveDimmer == 1), clMutux.Items[obutton.bytMutex], clLink.Items[obutton.byteLink] }; dgvListA.Rows.Add(obj); } #endregion } else if (MyActiveObject is DLP) // { Panel TmpPanel = (Panel)MyActiveObject; if (TmpPanel == null) { return; } dgvListA.Rows.Clear(); Byte PageID = Convert.ToByte(cboPages.SelectedIndex); int wdMaxValue = int.Parse(CsConst.mstrINIDefault.IniReadValue("DeviceType" + mywdDevicerType.ToString(), "MaxValue", "0")); for (int i = 0; i < 8; i++) { HDLButton obutton = TmpPanel.PanelKey[PageID * 8 + i]; if (obutton == null) { obutton = new HDLButton(); } String ButtonModeTmp = ButtonMode.ConvertorKeyModeToPublicModeGroup(obutton.Mode); Object[] obj = new object[] { (i + 1).ToString(), obutton.Remark, ButtonModeTmp, (obutton.IsLEDON == 0), (obutton.IsDimmer == 1), (obutton.SaveDimmer == 1), clMutux.Items[obutton.bytMutex], clLink.Items[obutton.byteLink] }; dgvListA.Rows.Add(obj); } } else if (MyActiveObject is Panel) { #region Panel TmpPanel = (Panel)MyActiveObject; if (TmpPanel == null) { return; } dgvListA.Rows.Clear(); for (int i = 0; i < TmpPanel.PanelKey.Count; i++) { HDLButton obutton = TmpPanel.PanelKey[i]; if (obutton == null) { obutton = new HDLButton(); } String ButtonModeTmp = ButtonMode.ConvertorKeyModeToPublicModeGroup(obutton.Mode); if (obutton.bytMutex >= clMutux.Items.Count) { obutton.bytMutex = (Byte)(clMutux.Items.Count - 1); } Object[] obj = new object[] { (i + 1).ToString(), obutton.Remark, ButtonModeTmp, (obutton.IsLEDON == 0), (obutton.IsDimmer == 1), (obutton.SaveDimmer == 1), clMutux.Items[obutton.bytMutex], clLink.Items[obutton.byteLink] }; dgvListA.Rows.Add(obj); } #endregion } else if (MyActiveObject is MS04) { #region MS04 TmpPanel = (MS04)MyActiveObject; if (TmpPanel == null) { return; } dgvListA.Rows.Clear(); for (int i = 0; i < TmpPanel.MSKeys.Count; i++) { HDLButton obutton = TmpPanel.MSKeys[i]; if (obutton == null) { obutton = new HDLButton(); } String ButtonModeTmp = DryMode.ConvertorKeyModeToPublicModeGroup(obutton.Mode); Object[] obj = new object[] { (i + 1).ToString(), obutton.Remark, ButtonModeTmp, (obutton.IsLEDON == 0), (obutton.IsDimmer == 1), (obutton.SaveDimmer == 1), clMutux.Items[obutton.bytMutex], clLink.Items[obutton.byteLink], DryDim.Items[obutton.IsDimmer] }; dgvListA.Rows.Add(obj); } #endregion } else if (MyActiveObject is MHRCU) { #region MHRCU TmpPanel = (MHRCU)MyActiveObject; if (TmpPanel == null) { return; } dgvListA.Rows.Clear(); for (int i = 0; i < TmpPanel.MSKeys.Count; i++) { HDLButton obutton = TmpPanel.MSKeys[i]; if (obutton == null) { obutton = new HDLButton(); } String ButtonModeTmp = DryMode.ConvertorKeyModeToPublicModeGroup(obutton.Mode); Object[] obj = new object[] { (i + 1).ToString(), obutton.Remark, ButtonModeTmp, (obutton.IsLEDON == 0), (obutton.IsDimmer == 1), (obutton.SaveDimmer == 1), clMutux.Items[obutton.bytMutex], clLink.Items[obutton.byteLink], DryDim.Items[obutton.IsDimmer] }; dgvListA.Rows.Add(obj); } #endregion } }