HDL Home App 第二版本 旧平台金堂用 正在使用
hxb
2022-08-30 25429f085093d89d543a0b90e30d0d62d1b7dac9
ZigbeeApp/Shared/Phone/UserCenter/Device/AirConditioner/IndoorUnitListForm.cs
@@ -24,6 +24,10 @@
        /// 激活的设备地址
        /// </summary>
        private string actionDeviceKeys = null;
        /// <summary>
        /// 接收回复的端点
        /// </summary>
        private HashSet<int> listReceivePoint = new HashSet<int>();
        #endregion
@@ -36,6 +40,11 @@
        public void ShowForm(string i_diviceMac)
        {
            this.listDevice = Common.LocalDevice.Current.GetDevicesByMac(i_diviceMac);
            //收集全部端点
            foreach (var device in this.listDevice)
            {
                listReceivePoint.Add(device.DeviceEpoint);
            }
            //设置头部信息
            base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uIndoorUnitSettion));
@@ -133,9 +142,19 @@
            btnValue.Y = Application.GetRealHeight(58);
            btnValue.X = frameTable.Width - Application.GetRealWidth(300 + 58);
            btnValue.TextAlignment = TextAlignment.CenterRight;
            btnValue.TextID = R.MyInternationalizationString.uGetting;
            frameTable.AddChidren(btnValue, ChidrenBindMode.BindEvent);
            rowInfo.btnValue = btnValue;
            //室内温度
            if (device.currentLocalTemperature == 0)
            {
                //0℃
                btnValue.Text = "0.0℃";
            }
            else
            {
                btnValue.Text = device.currentLocalTemperature + ".0℃";
            }
            //警告图标
            var btnWarningIcon = new IconViewControl(69);
            btnWarningIcon.X = btnIconBack.X;
@@ -164,28 +183,46 @@
            {
                if (btnSwitch.IsSelected == false)
                {
                    //打开空调
                    var result = await HdlDeviceAirConditionerLogic.Current.OpenAirConditioner(device);
                    if (result == false)
                    //如果不是虚拟住宅的话
                    if (Common.Config.Instance.Home.IsVirtually == false)
                    {
                        return;
                        //打开空调
                        var result = await HdlDeviceAirConditionerLogic.Current.OpenAirConditioner(device);
                        if (result == false)
                        {
                            return;
                        }
                    }
                    btnIcon.IsSelected = true;
                    btnIconBack.BackgroundColor = 0xfffef1ed;
                }
                else
                {
                    //关闭空调
                    var result = await HdlDeviceAirConditionerLogic.Current.CloseAirConditioner(device);
                    if (result == false)
                    //如果不是虚拟住宅的话
                    if (Common.Config.Instance.Home.IsVirtually == false)
                    {
                        return;
                        //关闭空调
                        var result = await HdlDeviceAirConditionerLogic.Current.CloseAirConditioner(device);
                        if (result == false)
                        {
                            return;
                        }
                    }
                    btnIcon.IsSelected = false;
                    btnIconBack.BackgroundColor = 0xfff5f6fa;
                }
                btnSwitch.IsSelected = !btnSwitch.IsSelected;
                //如果是虚拟住宅的话
                if (Common.Config.Instance.Home.IsVirtually == true)
                {
                    device.currentSystemMode = btnSwitch.IsSelected == true ? 3 : 0;
                }
            };
            //如果是展示模板的话
            if (Common.Config.Instance.Home.IsShowTemplate == true)
            {
                btnSwitch.CanClick = false;
            }
            frameTable.ButtonClickEvent += (sender, e) =>
            {
@@ -207,17 +244,31 @@
        /// </summary>
        private void SetReadAttributeComand()
        {
            //如果是虚拟住宅或者展示模板的话
            if (Common.Config.Instance.Home.IsShowTemplate == true || Common.Config.Instance.Home.IsVirtually == true)
            {
                return;
            }
            HdlThreadLogic.Current.RunThread(() =>
            {
                for (int i = 0; i < listDevice.Count; i++)
                while (this.listReceivePoint.Count > 0 && this.Parent != null)
                {
                    if (this.Parent == null)
                    for (int i = 0; i < listDevice.Count; i++)
                    {
                        return;
                        if (this.Parent == null)
                        {
                            return;
                        }
                        //已经发送过了,就不用再发送
                        if (this.listReceivePoint.Contains(listDevice[i].DeviceEpoint) == true)
                        {
                            //读取状态
                            HdlDeviceAttributeLogic.Current.SendThermostatStatuComand(listDevice[i]);
                            System.Threading.Thread.Sleep(200);
                        }
                    }
                    //读取状态
                    HdlDeviceAttributeLogic.Current.SendThermostatStatuComand(listDevice[i]);
                    System.Threading.Thread.Sleep(200);
                    //3秒后再次循环
                    System.Threading.Thread.Sleep(3000);
                }
            });
        }
@@ -238,6 +289,13 @@
                {
                    return;
                }
                var localDevice = Common.LocalDevice.Current.GetDevice(mainkeys);
                if (localDevice == null)
                {
                    return;
                }
                //已经接收到数据,则移除端点
                this.listReceivePoint.Remove(device.DeviceEpoint);
                var rowInfo = dicControl[mainkeys];
                for (int i = 0; i < device.DeviceStatusReport.AttriBute.Count; i++)
@@ -248,25 +306,14 @@
                        HdlThreadLogic.Current.RunMain(() =>
                        {
                            //室内温度
                            if (data.AttriButeData == 0)
                            if (((AC)localDevice).currentLocalTemperature == 0)
                            {
                                //0℃
                                rowInfo.btnValue.Text = "0.0℃";
                            }
                            else if (data.AttriButeData > 32767)
                            {
                                //负数(特殊处理)
                                string strValue = (data.AttriButeData - 65536).ToString();
                                //小数点需要一位
                                strValue = strValue.Substring(0, strValue.Length - 1);
                                rowInfo.btnValue.Text = strValue.Insert(strValue.Length - 1, ".") + "℃";
                            }
                            else
                            {
                                //小数点需要一位
                                string strValue = data.AttriButeData.ToString();
                                strValue = strValue.Substring(0, strValue.Length - 1);
                                rowInfo.btnValue.Text = strValue.Insert(strValue.Length - 1, ".") + "℃";
                                rowInfo.btnValue.Text = ((AC)localDevice).currentLocalTemperature + ".0℃";
                            }
                        });
                    }