| | |
| | | using System.Collections.Generic;
|
| | | using System.Threading.Tasks;
|
| | | using Shared.Common;
|
| | | using Shared.Phone.UserCenter.Device.Bind;
|
| | | using Shared.Phone.UserCenter.DeviceBind;
|
| | | using ZigBee.Device;
|
| | |
|
| | | namespace Shared.Phone.UserCenter.Device
|
| | |
| | | /// 中央空调的版本控件
|
| | | /// </summary>
|
| | | private NormalViewControl btnAirConditionerVersion = null;
|
| | |
|
| | | /// <summary>
|
| | | /// 简约面板绑定的温度目标名字
|
| | | /// </summary>
|
| | | private string bindTemperatureName = string.Empty;
|
| | | /// <summary>
|
| | | /// 简约面板绑定的湿度目标名字
|
| | | /// </summary>
|
| | | private string bindHumidityName = string.Empty;
|
| | | /// <summary>
|
| | | /// 简约面板绑定被绑目标是温度
|
| | | /// </summary>
|
| | | private CommonDevice bindTemperatureDev;
|
| | | /// <summary>
|
| | | /// 简约面板绑定被绑目标是湿度
|
| | | /// </summary>
|
| | | private CommonDevice bindHumidityDev;
|
| | | /// <summary>
|
| | | /// 简约面板当前Mac
|
| | | /// </summary>
|
| | | private string deviceMacTemp = string.Empty;
|
| | | // <summary>
|
| | | /// 简约面板中被绑定的温湿度目标列表
|
| | | /// </summary>
|
| | | private List<BindObj.BindListResponseObj> bindList = new List<BindObj.BindListResponseObj>();
|
| | | #endregion
|
| | |
|
| | | #region ■ 初始化_____________________________
|
| | |
| | | //针对单纯只有一个200端点的设备
|
| | | listNewDevice.Add(Common.LocalDevice.Current.GetOTADevice(deviceMac));
|
| | | }
|
| | |
|
| | | this.listDeviceType.Clear();
|
| | | deviceMacTemp = deviceMac;
|
| | | foreach (var device in listNewDevice)
|
| | | {
|
| | | //收集设备类型
|
| | |
| | |
|
| | | //重新获取硬件信息
|
| | | this.RefreshHardFirmwareInfo();
|
| | |
|
| | | //简约多功能面板获取绑定目标的显示
|
| | | if (deviceEnumInfo.ConcreteType == DeviceConcreteType.ButtonPanel_SimpleMultifunction)
|
| | | {
|
| | | //简约面板随便一个回路来获取设备信息
|
| | | var dev = Common.LocalDevice.Current.GetDevice(deviceMac, 62);
|
| | | if (dev != null)
|
| | | {
|
| | | var key = new ZigBee.Device.Panel();
|
| | | key.DeviceAddr = deviceMac;
|
| | | key.CurrentGateWayId = dev.CurrentGateWayId;
|
| | | InitBindInfo(key);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | else if (deviceEnumInfo.ConcreteType == DeviceConcreteType.ButtonPanel_SimpleMultifunction)
|
| | | {
|
| | | //简约多功能面板
|
| | | this.AddIBindRow();
|
| | | this.AddIBindRow(deviceMacTemp);
|
| | | this.AddFunctionSettionRow();
|
| | | this.AddHumiditySourceRow();
|
| | | this.AddTemperatureSensorRow();
|
| | |
|
| | | this.AddHumiditySourceRow(deviceMacTemp);
|
| | | this.AddTemperatureSensorRow(deviceMacTemp);
|
| | | }
|
| | | else if (deviceEnumInfo.ConcreteType == DeviceConcreteType.ButtonPanel_SimpleEnvironment)
|
| | | {
|
| | |
| | | btnFunction.AddBottomLine();
|
| | | btnFunction.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | var form = new DeviceBind.PanelSimpleEnvironmentTargetsForm();
|
| | |
|
| | | //简约环境面板的按键配置
|
| | | var form = new DevicePanel.PanelSimpleEnvironmentButtonSettionForm();
|
| | | form.AddForm(listNewDevice[0]);
|
| | | };
|
| | | }
|
| | |
|
| | | #endregion
|
| | | |
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 按键设置(方悦)_____________________
|
| | |
| | | var form = new DevicePanel.PanelFangyueEnvironmentButtonSettionForm();
|
| | | form.AddForm(listNewDevice[0]);
|
| | | }
|
| | | else
|
| | | else if (deviceEnumInfo.ConcreteType == DeviceConcreteType.ButtonPanel_FangyueFreshAir)
|
| | | {
|
| | | //方悦新风面板的按键配置
|
| | | var form = new DevicePanel.PanelFangyueFreshAirButtonSettionForm();
|
| | | form.AddForm(listNewDevice[0]);
|
| | | }
|
| | | else
|
| | | {
|
| | | var form = new DevicePanel.PanelFangyueButtonSettionForm();
|
| | | form.AddForm(listNewDevice[0]);
|
| | | }
|
| | | };
|
| | |
| | | private void AddPirSensorWorkModeRow()
|
| | | {
|
| | | if (this.deviceEnumInfo.ConcreteType != DeviceConcreteType.Sensor_Pir
|
| | | || deviceEnumInfo.IsHdlDevice == false)
|
| | | || deviceEnumInfo.IsHdlDevice == false
|
| | | || this.listNewDevice.Count != 2)
|
| | | {
|
| | | return;
|
| | | }
|
| | |
| | | /// </summary>
|
| | | private void AddPirSensorBindRow()
|
| | | {
|
| | | if (this.deviceEnumInfo.ConcreteType != DeviceConcreteType.Sensor_Pir)
|
| | | if (this.deviceEnumInfo.ConcreteType != DeviceConcreteType.Sensor_Pir
|
| | | || this.listNewDevice.Count != 2)
|
| | | {
|
| | | return;
|
| | | }
|
| | |
| | | {
|
| | | var form = new DevicePanel.PanelFangyueFunctionSettionForm();
|
| | | form.AddForm(listNewDevice[0], deviceEnumInfo);
|
| | | }
|
| | | //简约环境面板的按键配置
|
| | | else if (deviceEnumInfo.ConcreteType == DeviceConcreteType.ButtonPanel_SimpleMultifunction)
|
| | | {
|
| | | var form = new DeviceFunctionSettionForm();
|
| | | if (listNewDevice.Count > 62)
|
| | | {
|
| | | form.AddForm(listNewDevice[62], true);
|
| | | }
|
| | | }
|
| | | //河东的面板设备
|
| | | else if (deviceEnumInfo.BeloneType == DeviceBeloneType.A按键面板 && deviceEnumInfo.IsHdlDevice == true)
|
| | |
| | |
|
| | | #region ■ 简约多功能面板用___________________
|
| | | /// <summary>
|
| | | /// 添加【绑定目标】行 |
| | | /// 添加【绑定目标】行
|
| | | /// </summary>
|
| | | private void AddIBindRow()
|
| | | private void AddIBindRow(string deviceMac)
|
| | | {
|
| | | string bindTargets = Language.StringByID(R.MyInternationalizationString.uBindTargets);
|
| | | var btnBindTargets = new FrameRowControl(listview.rowSpace / 2);
|
| | |
| | | btnBindTargets.AddBottomLine();
|
| | | btnBindTargets.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | var form = new DeviceBind.PanelSimpleMutilfunctionTargetsForm();
|
| | | var simpleMutilfunctionTargetsPage = new Shared.Phone.UserCenter.DeviceBind.PanelSimpleMutilfunctionTargetsForm(deviceMac);
|
| | | Shared.Phone.UserView.HomePage.Instance.AddChidren(simpleMutilfunctionTargetsPage);
|
| | | Shared.Phone.UserView.HomePage.Instance.PageIndex += 1;
|
| | | simpleMutilfunctionTargetsPage.Show();
|
| | | };
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 湿度来源行
|
| | | /// </summary>
|
| | | private void AddHumiditySourceRow()
|
| | | private void AddHumiditySourceRow(string deviceMac)
|
| | | {
|
| | | //湿度
|
| | | var rowHumidity = new FrameRowControl(listview.rowSpace / 2);
|
| | |
| | | //右箭头
|
| | | rowHumidity.AddRightArrow();
|
| | | var msg = Language.StringByID(R.MyInternationalizationString.nothing);
|
| | | //if (!string.IsNullOrEmpty(bindHumidityName))
|
| | | //{
|
| | | // msg = bindHumidityName;
|
| | | //}
|
| | | if (!string.IsNullOrEmpty(bindHumidityName))
|
| | | {
|
| | | msg = bindHumidityName;
|
| | | }
|
| | | var btnHumidityStatu = rowHumidity.AddMostRightView(msg, 700);
|
| | | rowHumidity.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | //var key = new Panel();
|
| | | //var bindHumiditySensorPage = new Shared.Phone.UserCenter.DeviceBind.PanelSimpleMutilfunctionBindSensorForm(key, bindHumidityDev, 3);
|
| | | //Shared.Phone.UserView.HomePage.Instance.AddChidren(bindHumiditySensorPage);
|
| | | //Shared.Phone.UserView.HomePage.Instance.PageIndex += 1;
|
| | | //bindHumiditySensorPage.Show();
|
| | |
|
| | | //bindHumiditySensorPage.actionHumidityTarget += (bindName) =>
|
| | | //{
|
| | | // Application.RunOnMainThread(() =>
|
| | | // {
|
| | | // if (string.IsNullOrEmpty(bindName))
|
| | | // {
|
| | | // btnHumidityStatu.Text = Language.StringByID(R.MyInternationalizationString.nothing);
|
| | | // }
|
| | | // else
|
| | | // {
|
| | | // btnHumidityStatu.Text = bindName;
|
| | | // }
|
| | | // });
|
| | | //};
|
| | | var dev = Common.LocalDevice.Current.GetDevice(deviceMac, 62);//简约面板随便一个回路来获取设备
|
| | | var device = new CommonDevice();
|
| | | if (dev != null)
|
| | | {
|
| | | device.CurrentGateWayId = dev.CurrentGateWayId;
|
| | | }
|
| | | device.Type = DeviceType.OnOffSwitch;
|
| | | device.DeviceAddr = deviceMac;
|
| | | device.DeviceEpoint = 65;//能绑定湿度的回路
|
| | | var paneTargetsBaseFormp = new PaneTargetsBaseForm(device, bindHumidityDev, BindInfo.BindType.Humidity);
|
| | | Shared.Phone.UserView.HomePage.Instance.AddChidren(paneTargetsBaseFormp);
|
| | | Shared.Phone.UserView.HomePage.Instance.PageIndex += 1;
|
| | | paneTargetsBaseFormp.Show();
|
| | | paneTargetsBaseFormp.actionHumidityTarget += (bindName) =>
|
| | | {
|
| | | Application.RunOnMainThread(() =>
|
| | | {
|
| | | if (string.IsNullOrEmpty(bindName))
|
| | | {
|
| | | btnHumidityStatu.Text = Language.StringByID(R.MyInternationalizationString.nothing);
|
| | | }
|
| | | else
|
| | | {
|
| | | btnHumidityStatu.Text = bindName;
|
| | | }
|
| | | });
|
| | | };
|
| | | };
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 温度来源行
|
| | | /// </summary>
|
| | | private void AddTemperatureSensorRow()
|
| | | private void AddTemperatureSensorRow(string deviceMac)
|
| | | {
|
| | | //温度来源
|
| | | var rowTemPerature = new FrameRowControl(listview.rowSpace / 2);
|
| | |
| | | //右箭头
|
| | | rowTemPerature.AddRightArrow();
|
| | | var msg = Language.StringByID(R.MyInternationalizationString.nothing);
|
| | | //if (!string.IsNullOrEmpty(bindTemperatureName))
|
| | | //{
|
| | | // msg = bindTemperatureName;
|
| | | //}
|
| | | if (!string.IsNullOrEmpty(bindTemperatureName))
|
| | | {
|
| | | msg = bindTemperatureName;
|
| | | }
|
| | | var btnTemperatureStatu = rowTemPerature.AddMostRightView(msg, 700);
|
| | | rowTemPerature.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | //var key = new Panel();
|
| | | //var bindTemperatureSensorPage = new Shared.Phone.UserCenter.DeviceBind.PanelFangyueFreshAirTargetsForm(key, bindTemperatureDev, 2);
|
| | | //Shared.Phone.UserView.HomePage.Instance.AddChidren(bindTemperatureSensorPage);
|
| | | //Shared.Phone.UserView.HomePage.Instance.PageIndex += 1;
|
| | | //bindTemperatureSensorPage.Show();
|
| | |
|
| | | //bindTemperatureSensorPage.actionTemperatureTarget += (bindName) =>
|
| | | //{
|
| | | // Application.RunOnMainThread(() =>
|
| | | // {
|
| | | // if (string.IsNullOrEmpty(bindName))
|
| | | // {
|
| | | // btnTemperatureStatu.Text = Language.StringByID(R.MyInternationalizationString.nothing);
|
| | | // }
|
| | | // else
|
| | | // {
|
| | | // btnTemperatureStatu.Text = bindName;
|
| | | // }
|
| | | // });
|
| | | //};
|
| | | var dev = Common.LocalDevice.Current.GetDevice(deviceMac, 62);//简约面板随便一个回路来获取设备
|
| | | var device = new CommonDevice();
|
| | | if (dev != null)
|
| | | {
|
| | | device.CurrentGateWayId = dev.CurrentGateWayId;
|
| | | }
|
| | | device.Type = DeviceType.OnOffSwitch;
|
| | | device.DeviceAddr = deviceMac;
|
| | | device.DeviceEpoint = 64;//能绑定温度的回路
|
| | | var paneTargetsBaseFormp = new PaneTargetsBaseForm(device, bindTemperatureDev, BindInfo.BindType.Temperature);
|
| | | Shared.Phone.UserView.HomePage.Instance.AddChidren(paneTargetsBaseFormp);
|
| | | Shared.Phone.UserView.HomePage.Instance.PageIndex += 1;
|
| | | paneTargetsBaseFormp.Show();
|
| | | paneTargetsBaseFormp.actionTemperatureTarget += (bindName) =>
|
| | | {
|
| | | Application.RunOnMainThread(() =>
|
| | | {
|
| | | if (string.IsNullOrEmpty(bindName))
|
| | | {
|
| | | btnTemperatureStatu.Text = Language.StringByID(R.MyInternationalizationString.nothing);
|
| | | }
|
| | | else
|
| | | {
|
| | | btnTemperatureStatu.Text = bindName;
|
| | | }
|
| | | });
|
| | | };
|
| | | };
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | ///读温湿度数据
|
| | | /// </summary>
|
| | | void InitBindInfo(CommonDevice curControlDev)
|
| | | {
|
| | | System.Threading.Tasks.Task.Run(async () =>
|
| | | {
|
| | | try
|
| | | {
|
| | | Application.RunOnMainThread(() =>
|
| | | {
|
| | | CommonPage.Loading.Start("");
|
| | | });
|
| | | //1、获去绑定的温度传感器
|
| | | curControlDev.DeviceEpoint = 64;
|
| | | var result = await GetBindName(curControlDev);
|
| | | if (!result)
|
| | | {
|
| | | Application.RunOnMainThread(() =>
|
| | | {
|
| | | new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(Common.CommonPage.Instance);
|
| | | });
|
| | | return;
|
| | | }
|
| | |
|
| | | //2、获去绑定的湿度度传感器
|
| | | curControlDev.DeviceEpoint = 65;
|
| | | var result2 = await GetBindName(curControlDev);
|
| | | if (!result2)
|
| | | {
|
| | | Application.RunOnMainThread(() =>
|
| | | {
|
| | | new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(Common.CommonPage.Instance);
|
| | | });
|
| | | return;
|
| | | }
|
| | | }
|
| | | catch (Exception ex)
|
| | | {
|
| | | var mess = ex.Message;
|
| | | }
|
| | | finally
|
| | | {
|
| | | Application.RunOnMainThread(() =>
|
| | | {
|
| | | //初始化中部控件
|
| | | this.InitMiddleFrame();
|
| | | CommonPage.Loading.Hide();
|
| | | });
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 获取绑定的温湿度目标
|
| | | /// </summary>
|
| | | /// <param name="curControlDev"></param>
|
| | | /// <returns></returns>
|
| | | private async System.Threading.Tasks.Task<bool> GetBindName(CommonDevice curControlDev)
|
| | | {
|
| | | bool result = false;
|
| | | var panelBindListRes = HdlDeviceBindLogic.Current.GetDeviceBindAsync(curControlDev);
|
| | | if (panelBindListRes != null && panelBindListRes.getAllBindResponseData != null)
|
| | | {
|
| | | bindList = panelBindListRes.getAllBindResponseData.BindList;
|
| | | foreach (var bDev in bindList)
|
| | | {
|
| | | var device = Common.LocalDevice.Current.GetDevice(bDev.BindMacAddr, bDev.BindEpoint);
|
| | | if (device == null)
|
| | | {
|
| | | continue;
|
| | | }
|
| | | if (device.Type == DeviceType.TemperatureSensor)
|
| | | {
|
| | | var bD = device as TemperatureSensor;
|
| | | if (bD.SensorDiv == 1 && bDev.BindCluster == 1026)
|
| | | {
|
| | | if (string.IsNullOrEmpty(bDev.ESName))
|
| | | {
|
| | | bindTemperatureName = Common.LocalDevice.Current.GetDeviceEpointName(device);
|
| | | }
|
| | | else
|
| | | {
|
| | | bindTemperatureName = bDev.ESName;
|
| | | }
|
| | | bindTemperatureDev = device;
|
| | | }
|
| | | if (bD.SensorDiv == 2 && bDev.BindCluster == 1029)
|
| | | {
|
| | | if (string.IsNullOrEmpty(bDev.ESName))
|
| | | {
|
| | | bindHumidityName = Common.LocalDevice.Current.GetDeviceEpointName(device);
|
| | | }
|
| | | else
|
| | | {
|
| | | bindHumidityName = bDev.ESName;
|
| | | }
|
| | |
|
| | | bindHumidityDev = device;
|
| | | }
|
| | | }
|
| | | if (device.Type == DeviceType.FreshAirHumiditySensor)
|
| | | {
|
| | | if (string.IsNullOrEmpty(bDev.ESName))
|
| | | {
|
| | | bindHumidityName = Common.LocalDevice.Current.GetDeviceEpointName(device);
|
| | | }
|
| | | else
|
| | | {
|
| | | bindHumidityName = bDev.ESName;
|
| | | }
|
| | |
|
| | | bindHumidityDev = device;
|
| | | }
|
| | | }
|
| | | result = true;
|
| | | }
|
| | | return result;
|
| | | }
|
| | | #endregion
|
| | |
|
| | |
| | | btnNewVersion.Visible = false;
|
| | | btnNewVersion.X = Application.GetRealWidth(242);
|
| | | btnNewVersion.Y = Application.GetRealHeight(23);
|
| | | rowUpDate.AddChidren(btnNewVersion, ChidrenBindMode.BindEventOnly);
|
| | | rowUpDate.AddChidren(btnNewVersion, ChidrenBindMode.BindEvent);
|
| | |
|
| | | rowUpDate.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | |
| | | /// <param name="oTADevice">ota设备</param>
|
| | | private void SetDeviceVersionInfo(PicViewControl btnNewVersion, OTADevice oTADevice)
|
| | | {
|
| | | HdlThreadLogic.Current.RunThread(async () =>
|
| | | HdlThreadLogic.Current.RunThread(() =>
|
| | | {
|
| | | bool receiveImageInfo = false;
|
| | | //设置设备全部的镜像信息
|
| | |
| | | while (receiveImageInfo == false && count > 0)
|
| | | {
|
| | | //等待设备镜像的反馈
|
| | | await Task.Delay(300);
|
| | | System.Threading.Thread.Sleep(300);
|
| | | count--;
|
| | | }
|
| | | //移除事件
|
| | |
| | |
|
| | | oTADevice = Common.LocalDevice.Current.GetOTADevice(listNewDevice[0].DeviceAddr);
|
| | | //添加升级固件信息(成不成功都无所谓)
|
| | | var result = await HdlFirmwareUpdateLogic.AddFirmwareVersionInfo(FirmwareLevelType.ZigbeeDevice, oTADevice.HwVersion.ToString(), oTADevice.ImgTypeId.ToString());
|
| | | var result = HdlFirmwareUpdateLogic.AddFirmwareVersionInfo(FirmwareLevelType.ZigbeeDevice, oTADevice.HwVersion.ToString(), oTADevice.ImgTypeId.ToString());
|
| | |
|
| | | //获取设备最新版本
|
| | | var deviceFirmware = HdlFirmwareUpdateLogic.GetFirmwareMostVersionInfo(FirmwareLevelType.ZigbeeDevice,
|
| | |
| | | //检测此回路是否拥有定位功能(拿端点最小的那个回路去定位)
|
| | | bool canTest = Common.LocalDevice.Current.DeviceIsCanFixedPosition(listNewDevice[0]);
|
| | |
|
| | | var frame = new TopRightMenuControl(canTest == true ? 2 : 1, 1);
|
| | | TopRightMenuControl frame = null;
|
| | |
|
| | | if (deviceEnumInfo.ConcreteType == DeviceConcreteType.ButtonPanel_SimpleMultifunction)
|
| | | {
|
| | | frame = new TopRightMenuControl(3, 1);
|
| | | }
|
| | | else
|
| | | {
|
| | | frame = new TopRightMenuControl(canTest == true ? 2 : 1, 1);
|
| | | }
|
| | |
|
| | | string deviceMenu = string.Empty;
|
| | | if (canTest == true)
|
| | | {
|
| | |
| | | });
|
| | | });
|
| | |
|
| | | //同步
|
| | | deviceMenu = Language.StringByID(R.MyInternationalizationString.Synchronization);
|
| | | if (Common.LocalDevice.Current.DeviceIsCanFixedPosition(listNewDevice[0]))
|
| | | {
|
| | | frame.AddRowMenu(deviceMenu, "", "Item/SynchronizationSelected.png", () =>
|
| | | {
|
| | | //如果当前住宅是虚拟住宅,此功能无效
|
| | | if (Common.Config.Instance.Home.IsVirtually == true)
|
| | | {
|
| | | return;
|
| | | }
|
| | |
|
| | | //同步指定设备
|
| | | this.SynchronizationDevice();
|
| | | });
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | });
|
| | | });
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 同步指定设备
|
| | | /// </summary>
|
| | | private void SynchronizationDevice()
|
| | | {
|
| | | HdlThreadLogic.Current.RunThread(async () =>
|
| | | {
|
| | | //打开进度条
|
| | | this.ShowProgressBar();
|
| | |
|
| | | //同步设备
|
| | | bool result = await Common.LocalDevice.Current.SynchronizationDevice(listNewDevice);
|
| | | //关闭进度条
|
| | | this.CloseProgressBar();
|
| | | if (result == false)
|
| | | {
|
| | | return;
|
| | | }
|
| | | });
|
| | | }
|
| | | #endregion
|
| | |
|
| | | #region ■ 关闭界面___________________________
|