| | |
| | | #region ■ 变量声明___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 设备mac地址
|
| | | /// 设备Ota
|
| | | /// </summary>
|
| | | private string deviceMac = null;
|
| | | private OTADevice otaDevice = null;
|
| | | /// <summary>
|
| | | /// 设备
|
| | | /// </summary>
|
| | | private AC deviceAc = null;
|
| | | /// <summary>
|
| | | /// 前回选择的控件
|
| | | /// </summary>
|
| | | private NormalSelectControl oldSelectContr = null;
|
| | |
|
| | | #endregion
|
| | |
|
| | |
| | | /// <summary>
|
| | | /// 画面显示(底层会固定调用此方法,借以完成画面创建)
|
| | | /// </summary>
|
| | | /// <param name="i_deviceMac">设备mac地址</param>
|
| | | public void ShowForm(string i_deviceMac)
|
| | | /// <param name="i_deviceAc">设备</param>
|
| | | public void ShowForm(AC i_deviceAc)
|
| | | {
|
| | | this.deviceMac = i_deviceMac;
|
| | | this.deviceAc = i_deviceAc;
|
| | | this.otaDevice = Common.LocalDevice.Current.GetOTADevice(i_deviceAc.DeviceAddr);
|
| | |
|
| | | //设置头部信息
|
| | | base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uAirConditioningModule));
|
| | |
| | | listView.BackgroundColor = UserCenterColor.Current.White;
|
| | | bodyFrameLayout.AddChidren(listView);
|
| | |
|
| | | //升级
|
| | | var btnUpdate = new BottomClickButton();
|
| | | btnUpdate.TextID = R.MyInternationalizationString.uLevelUp;
|
| | | bodyFrameLayout.AddChidren(btnUpdate);
|
| | | btnUpdate.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | };
|
| | | //初始化空调模块列表
|
| | | this.InitAirConditioningModuleList(listView);
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | private async void DoDeviceUpdate()
|
| | | #region ■ 初始化空调模块列表_________________
|
| | |
|
| | | /// <summary>
|
| | | /// 初始化空调模块列表
|
| | | /// </summary>
|
| | | private void InitAirConditioningModuleList(VerticalListControl listView)
|
| | | {
|
| | | var listDevice = Common.LocalDevice.Current.GetDevicesByMac(this.deviceMac);
|
| | | if (listDevice.Count == 0)
|
| | | var list = HdlFirmwareUpdateLogic.GetFirmwareVersionListInfo(FirmwareLevelType.ZigbeeDevice, otaDevice.HwVersion.ToString(), otaDevice.ImgTypeId.ToString());
|
| | | if (list.Count == 0)
|
| | | {
|
| | | //没有可升级的空调模块
|
| | | this.ShowNotDataImage(bodyFrameLayout, Language.StringByID(R.MyInternationalizationString.uNotHadAirConditioningUpdateModule));
|
| | | return;
|
| | | }
|
| | | |
| | | HdlThreadLogic.Current.RunMainInThread(() =>
|
| | | {
|
| | | for (int i = 0; i < list.Count; i++)
|
| | | {
|
| | | //添加模块行
|
| | | this.AddModuleRow(listView, list[i], i.ToString(), i != list.Count - 1);
|
| | | }
|
| | | //调整高度
|
| | | listView.AdjustRealHeightByBottomButton(Application.GetRealHeight(23));
|
| | |
|
| | | //升级
|
| | | var btnUpdate = new BottomClickButton();
|
| | | btnUpdate.TextID = R.MyInternationalizationString.uLevelUp;
|
| | | bodyFrameLayout.AddChidren(btnUpdate);
|
| | | btnUpdate.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | var selectInfo = this.GetSelectFirmware(listView, list);
|
| | | if (selectInfo == null)
|
| | | {
|
| | | //没有选择固件
|
| | | return;
|
| | | }
|
| | | //设备升级
|
| | | HdlThreadLogic.Current.RunThread(() =>
|
| | | {
|
| | | this.DoDeviceUpdate(selectInfo);
|
| | | });
|
| | | };
|
| | | });
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 添加模块行
|
| | | /// </summary>
|
| | | /// <param name="listView"></param>
|
| | | /// <param name="info"></param>
|
| | | /// <param name="mainkeys"></param>
|
| | | private void AddModuleRow(VerticalListControl listView, FirmwareVersionInfo info, string mainkeys,bool addLine)
|
| | | {
|
| | | //获取空调模块的名字
|
| | | string textView = this.GetAirConditioningModuleName(info);
|
| | | var row = new NormalSelectControl(textView, listView.rowSpace / 2);
|
| | | row.MainKeys = mainkeys;
|
| | | listView.AddChidren(row);
|
| | | row.InitControl("Device/AirConditionerEpoint.png");
|
| | | if (addLine == true)
|
| | | {
|
| | | row.AddBottomLine();
|
| | | }
|
| | | row.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | //取消
|
| | | if (row.IsSelected == true)
|
| | | {
|
| | | row.IsSelected = false;
|
| | | oldSelectContr = null;
|
| | | return;
|
| | | }
|
| | | //选择
|
| | | row.IsSelected = true;
|
| | | if (oldSelectContr != null)
|
| | | {
|
| | | oldSelectContr.IsSelected = false;
|
| | | }
|
| | | oldSelectContr = row;
|
| | | };
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 获取空调模块的名字
|
| | | /// </summary>
|
| | | /// <param name="info"></param>
|
| | | /// <returns></returns>
|
| | | private string GetAirConditioningModuleName(FirmwareVersionInfo info)
|
| | | {
|
| | | string textView = string.Empty;
|
| | | if (info.Name.Contains("IRACC_DAK") == true)
|
| | | {
|
| | | //大金空调模块
|
| | | textView = Language.StringByID(R.MyInternationalizationString.uDakAirConditioningModule);
|
| | | }
|
| | | else if (info.Name.Contains("IRACC_HIC") == true)
|
| | | {
|
| | | //重工空调模块
|
| | | textView = Language.StringByID(R.MyInternationalizationString.uHicAirConditioningModule);
|
| | | }
|
| | | else
|
| | | {
|
| | | //空调升级模块
|
| | | textView = Language.StringByID(R.MyInternationalizationString.uAirConditioningUpdateModule);
|
| | | }
|
| | | return textView;
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 一般方法___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 获取选择的升级固件
|
| | | /// </summary>
|
| | | /// <param name="listView"></param>
|
| | | /// <param name=""></param>
|
| | | /// <returns></returns>
|
| | | private FirmwareVersionInfo GetSelectFirmware(VerticalListControl listView, List<FirmwareVersionInfo> listInfo)
|
| | | {
|
| | | int contrCount = listView.ChildrenCount;
|
| | | for (int i = 0; i < contrCount; i++)
|
| | | {
|
| | | var myView = listView.GetChildren(i) as NormalSelectControl;
|
| | | if (myView == null || myView.IsSelected == false)
|
| | | {
|
| | | continue;
|
| | | }
|
| | | return listInfo[i];
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 设备升级___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 设备升级
|
| | | /// </summary>
|
| | | private void DoDeviceUpdate(FirmwareVersionInfo updateInfo)
|
| | | {
|
| | | //打开进度条
|
| | | ProgressFormBar.Current.Start();
|
| | | //设备升级
|
| | | var updateLogic = new HdlACZbGatewayUpdateLogic(deviceAc, updateInfo);
|
| | | //更新状态变化的事件
|
| | | updateLogic.UpdateStatuChangedEvent += (div, msg) =>
|
| | | {
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | if (div == -1)
|
| | | {
|
| | | //异常
|
| | | this.ShowMassage(ShowMsgType.Tip, msg);
|
| | | ProgressFormBar.Current.Close();
|
| | | }
|
| | | else if (div == 0)
|
| | | {
|
| | | //一般信息
|
| | | ProgressFormBar.Current.SetMsg(msg);
|
| | | }
|
| | | else if (div == 1)
|
| | | {
|
| | | //升级完成
|
| | | ProgressFormBar.Current.Close();
|
| | | this.ShowMassage(ShowMsgType.Tip, msg);
|
| | |
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | //关闭界面
|
| | | this.CloseForm();
|
| | | });
|
| | | }
|
| | | });
|
| | | };
|
| | | //进度值改变事件
|
| | | updateLogic.ProgressEvent += (value) =>
|
| | | {
|
| | | ProgressFormBar.Current.SetValue(value);
|
| | | };
|
| | | //设备升级开始
|
| | | updateLogic.StartUpdateReady();
|
| | | //关闭事件
|
| | | ProgressFormBar.Current.CloseEvent += () =>
|
| | | {
|
| | | //升级对象
|
| | | if (FirmwareUpdateResourse.dicUpdateList.ContainsKey(deviceAc.DeviceAddr) == true
|
| | | && FirmwareUpdateResourse.dicUpdateList[deviceAc.DeviceAddr].IsFinishUpdate == true)
|
| | | {
|
| | | //如果设备已经升级完成,界面关闭时,则移除内存
|
| | | FirmwareUpdateResourse.dicUpdateList[deviceAc.DeviceAddr].Dispose();
|
| | | FirmwareUpdateResourse.dicUpdateList.Remove(deviceAc.DeviceAddr);
|
| | | }
|
| | | };
|
| | | }
|
| | |
|
| | | #endregion
|
| | | }
|
| | | }
|