gxc
2019-11-14 159ec8ae413683e1ce134ec204d1c0b4d175baec
ZigbeeApp/Shared/Phone/Device/AC/ACControl.cs
@@ -72,10 +72,6 @@
        /// </summary>
        private Button currentModeBtn;
        /// <summary>
        /// 当前温度
        /// </summary>
        private Button currentTemperatureBtn;
        /// <summary>
        /// 添加温度
        /// </summary>
        private Button addTemperatureBtn;
@@ -112,6 +108,11 @@
        /// 传过来的ac
        /// </summary>
        private ZigBee.Device.AC ac;
        /// <summary>
        /// mArcScaleSeekBar
        /// </summary>
        private ArcScaleSeekBar mArcScaleSeekBar = new ArcScaleSeekBar { };
        #endregion
        #region ◆ 接口___________________________
@@ -174,7 +175,7 @@
                                    ac.currentCoolingSetpoint = curTemp;
                                    if (ac.currentSystemMode == 3 || ac.currentSystemMode == 8)
                                    {
                                        currentTemperatureBtn.Text = $"{ac.currentCoolingSetpoint} ℃";
                                        mArcScaleSeekBar.Progress = ac.currentCoolingSetpoint;
                                    }
                                    ac.LastDateTime = DateTime.Now;
@@ -184,7 +185,7 @@
                                    ac.currentHeatingSetpoint = curTemp;
                                    if (ac.currentSystemMode == 4)
                                    {
                                        currentTemperatureBtn.Text = $"{ac.currentHeatingSetpoint} ℃";
                                        mArcScaleSeekBar.Progress = ac.currentHeatingSetpoint;
                                    }
                                    ac.LastDateTime = DateTime.Now;
                                    break;
@@ -193,7 +194,7 @@
                                    ac.currentAutoSetpoint = curTemp;
                                    if (ac.currentSystemMode == 1)
                                    {
                                        currentTemperatureBtn.Text = $"{ac.currentAutoSetpoint} ℃";
                                        mArcScaleSeekBar.Progress = ac.currentAutoSetpoint;
                                    }
                                    ac.LastDateTime = DateTime.Now;
                                    break;
@@ -210,8 +211,9 @@
                                        modeBtn.SelectedImagePath = ACControlBase.GetModeSelectedImagePathByModeId(ac.currentSystemMode);
                                        modeBtn.UnSelectedImagePath = ACControlBase.GetModeUnSelectedImagePathByModeId(ac.currentSystemMode);
                                        currentModeBtn.Text = ACControlBase.GetModeNameByModeId(ac.currentSystemMode);
                                        currentTemperatureBtn.Text = $"{ACControlBase.GetCurrentModeTemperature(ac)} ℃";
                                        mArcScaleSeekBar.Progress = ACControlBase.GetCurrentModeTemperature(ac);
                                        fanModeBtn.IsSelected = false;
                                        FanSwingModeBtn.IsSelected = false;
                                    }
@@ -222,8 +224,8 @@
                                        modeBtn.SelectedImagePath = ACControlBase.GetModeSelectedImagePathByModeId(ac.currentSystemMode);
                                        modeBtn.UnSelectedImagePath = ACControlBase.GetModeUnSelectedImagePathByModeId(ac.currentSystemMode);
                                        currentModeBtn.Text = ACControlBase.GetModeNameByModeId(ac.currentSystemMode);
                                        currentTemperatureBtn.Text = $"{ACControlBase.GetCurrentModeTemperature(ac)} ℃";
                                        mArcScaleSeekBar.Progress = ACControlBase.GetCurrentModeTemperature(ac);
                                        fanModeBtn.IsSelected = true;
                                        FanSwingModeBtn.IsSelected = true;
                                    }
@@ -377,14 +379,26 @@
                //发送读取状态命令
                UserView.UserHomeView.ReadStatus(ac, () =>
                {
                    ac.ReadAttri(Cluster_ID.Identify, AttriButeId.Switch);
                    ac.ReadLocalTemperature();
                    ac.ReadCoolingSetpoint();
                    ac.ReadHeatingSetpoint();
                    ac.ReadAutoSetpoint();
                    ac.ReadFanMode();
                    ac.ReadSystemMode();
                    ac.ReadSystemFansSwingMode();
                    new System.Threading.Thread(() =>
                    {
                        System.Threading.Thread.Sleep(100);
                        ac.ReadAttri(Cluster_ID.Identify, AttriButeId.Switch);
                        System.Threading.Thread.Sleep(100);
                        ac.ReadLocalTemperature();
                        System.Threading.Thread.Sleep(100);
                        ac.ReadCoolingSetpoint();
                        System.Threading.Thread.Sleep(100);
                        ac.ReadHeatingSetpoint();
                        System.Threading.Thread.Sleep(100);
                        ac.ReadAutoSetpoint();
                        System.Threading.Thread.Sleep(100);
                        ac.ReadFanMode();
                        System.Threading.Thread.Sleep(100);
                        ac.ReadSystemMode();
                        System.Threading.Thread.Sleep(100);
                        ac.ReadSystemFansSwingMode();
                    })
                    { IsBackground = true }.Start();
                });
            }
            else
@@ -392,14 +406,26 @@
                //防止短时间内多次读取设备状态
                if ((DateTime.Now - ac.LastDateTime).TotalSeconds > CommonPage.ReadDeviceStatuSpan)
                {
                    ac.ReadAttri(Cluster_ID.Identify, AttriButeId.Switch);
                    ac.ReadLocalTemperature();
                    ac.ReadCoolingSetpoint();
                    ac.ReadHeatingSetpoint();
                    ac.ReadAutoSetpoint();
                    ac.ReadFanMode();
                    ac.ReadSystemMode();
                    ac.ReadSystemFansSwingMode();
                    new System.Threading.Thread(() =>
                    {
                        System.Threading.Thread.Sleep(100);
                        ac.ReadAttri(Cluster_ID.Identify, AttriButeId.Switch);
                        System.Threading.Thread.Sleep(100);
                        ac.ReadLocalTemperature();
                        System.Threading.Thread.Sleep(100);
                        ac.ReadCoolingSetpoint();
                        System.Threading.Thread.Sleep(100);
                        ac.ReadHeatingSetpoint();
                        System.Threading.Thread.Sleep(100);
                        ac.ReadAutoSetpoint();
                        System.Threading.Thread.Sleep(100);
                        ac.ReadFanMode();
                        System.Threading.Thread.Sleep(100);
                        ac.ReadSystemMode();
                        System.Threading.Thread.Sleep(100);
                        ac.ReadSystemFansSwingMode();
                    })
                    { IsBackground = true }.Start();
                }
            }
@@ -435,15 +461,6 @@
                RemoveFromParent();
            };
            var sharedBtn = new Button
            {
                X = Application.GetRealWidth(850),
                Width = Application.GetMinReal(69),
                Height = Application.GetMinReal(69),
                Gravity = Gravity.CenterVertical,
                UnSelectedImagePath = "Item/Shared.png"
            };
            top.topView.AddChidren(sharedBtn);
            var moreBtn = new Button
            {
@@ -516,72 +533,71 @@
            };
            itemView.AddChidren(indoorTemperatureBtn);
            var controlBG = new FrameLayout()
            mArcScaleSeekBar = new ArcScaleSeekBar
            {
                Y = Application.GetRealHeight(412),
                Height = Application.GetMinRealAverage(547),
                Width = Application.GetMinRealAverage(671),
                Width = Application.GetRealWidth(671),
                Height = Application.GetRealHeight(671),
                Gravity = Gravity.CenterHorizontal,
                BackgroundImagePath = "AC/Group.png"
                MinValue=ACControlBase.Temperature_Low,
                MaxValue=ACControlBase.Temperature_High,
                Progress=ACControlBase.GetCurrentModeTemperature(ac)
            };
            itemView.AddChidren(controlBG);
            var controlBG2 = new Button()
            itemView.AddChidren(mArcScaleSeekBar);
            mArcScaleSeekBar.OnStopTrackingTouchEvent += (sender, e) =>
            {
                Y = Application.GetRealHeight(873),
                Height = Application.GetMinRealAverage(121),
                Width = Application.GetMinRealAverage(351),
                UnSelectedImagePath = "AC/Path.png",
                Gravity = Gravity.CenterHorizontal
                //cool  //dry
                if (ac.currentSystemMode == 3 || ac.currentSystemMode == 8)
                {
                    ac.currentCoolingSetpoint = e;
                    ac.SetCoolingTemperatureAsync(ac.currentCoolingSetpoint * 100);
                }
                //heat
                else if (ac.currentSystemMode == 4)
                {
                    ac.currentHeatingSetpoint = e;
                    ac.SetHeatingTemperatureAsync(ac.currentHeatingSetpoint * 100);
                }
                //auto
                else if (ac.currentSystemMode == 1)
                {
                    ac.currentAutoSetpoint = e;
                    ac.SetAutoTemperatureAsync(ac.currentAutoSetpoint * 100);
                }
            };
            itemView.AddChidren(controlBG2);
            //当前模式
            currentModeBtn = new Button()
            {
                Y = Application.GetRealHeight(187),
                Y = Application.GetRealHeight(599),
                Height = Application.GetRealHeight(80),
                Width = Application.GetRealWidth(200),
                TextColor = ZigbeeColor.Current.GXCTextBlackColor,
                Gravity = Gravity.CenterHorizontal,
                Text = ACControlBase.GetModeNameByModeId(ac.currentSystemMode)
            };
            controlBG.AddChidren(currentModeBtn);
            itemView.AddChidren(currentModeBtn);
            //降低温度
            reduceTemperatureBtn = new Button()
            {
                X = Application.GetRealWidth(112),
                Y = Application.GetRealHeight(268),
                X = Application.GetRealWidth(268),
                Y = Application.GetRealHeight(680),
                Width = Application.GetMinRealAverage(80),
                Height = Application.GetMinRealAverage(80),
                UnSelectedImagePath = "AC/Reduce.png"
            };
            controlBG.AddChidren(reduceTemperatureBtn);
            //温度
            currentTemperatureBtn = new Button()
            {
                //X = Application.GetRealWidth(239),
                Y = Application.GetRealHeight(248),
                Width = Application.GetRealWidth(180),
                Height = Application.GetRealHeight(100),
                TextColor = ZigbeeColor.Current.GXCTextBlackColor,
                TextSize = 15,
                Text = $"{ACControlBase.GetCurrentModeTemperature(ac)} °C",
                Gravity = Gravity.CenterHorizontal
            };
            controlBG.AddChidren(currentTemperatureBtn);
            itemView.AddChidren(reduceTemperatureBtn);
            //添加温度
            addTemperatureBtn = new Button()
            {
                X = Application.GetRealWidth(472),
                Y = Application.GetRealHeight(268),
                X = Application.GetRealWidth(628),
                Y = Application.GetRealHeight(680),
                Width = Application.GetMinRealAverage(80),
                Height = Application.GetMinRealAverage(80),
                UnSelectedImagePath = "AC/Add.png"
            };
            controlBG.AddChidren(addTemperatureBtn);
            itemView.AddChidren(addTemperatureBtn);
            //扫风
            FanSwingModeBtn = new Button()
@@ -1075,7 +1091,7 @@
            modeBtn.UnSelectedImagePath = ACControlBase.GetModeUnSelectedImagePathByMode(acMode);
            currentModeBtn.Text = ACControlBase.GetModeNameByMode(acMode);
            ac.currentSystemMode = (int)acMode;
            currentTemperatureBtn.Text = $"{ACControlBase.GetCurrentModeTemperature(ac)} °C";
            mArcScaleSeekBar.Progress = ACControlBase.GetCurrentModeTemperature(ac);
            ac.SetSystemModeAsync(acMode);
@@ -1325,7 +1341,8 @@
                }
                ac.currentCoolingSetpoint += 1;
                ac.SetCoolingTemperatureAsync(ac.currentCoolingSetpoint * 100);
                currentTemperatureBtn.Text = $"{ac.currentCoolingSetpoint} °C";
                //currentTemperatureBtn.Text = $"{ac.currentCoolingSetpoint} °C";
                mArcScaleSeekBar.Progress = ac.currentCoolingSetpoint;
            }
            //heat
            else if (ac.currentSystemMode == 4)
@@ -1336,7 +1353,8 @@
                }
                ac.currentHeatingSetpoint += 1;
                ac.SetHeatingTemperatureAsync(ac.currentHeatingSetpoint * 100);
                currentTemperatureBtn.Text = $"{ac.currentHeatingSetpoint} °C";
                //currentTemperatureBtn.Text = $"{ac.currentHeatingSetpoint} °C";
                mArcScaleSeekBar.Progress = ac.currentHeatingSetpoint;
            }
            //auto
            else if (ac.currentSystemMode == 1)
@@ -1347,9 +1365,9 @@
                }
                ac.currentAutoSetpoint += 1;
                ac.SetAutoTemperatureAsync(ac.currentAutoSetpoint * 100);
                currentTemperatureBtn.Text = $"{ac.currentAutoSetpoint} °C";
                //currentTemperatureBtn.Text = $"{ac.currentAutoSetpoint} °C";
                mArcScaleSeekBar.Progress = ac.currentAutoSetpoint;
            }
        }
@@ -1379,7 +1397,8 @@
                ac.currentCoolingSetpoint -= 1;
                ac.SetCoolingTemperatureAsync(ac.currentCoolingSetpoint * 100);
                currentTemperatureBtn.Text = $"{ac.currentCoolingSetpoint} °C";
                //currentTemperatureBtn.Text = $"{ac.currentCoolingSetpoint} °C";
                mArcScaleSeekBar.Progress = ac.currentCoolingSetpoint;
            }
            //heat
            else if (ac.currentSystemMode == 4)
@@ -1391,7 +1410,8 @@
                ac.currentHeatingSetpoint -= 1;
                ac.SetHeatingTemperatureAsync(ac.currentHeatingSetpoint * 100);
                currentTemperatureBtn.Text = $"{ac.currentHeatingSetpoint} °C";
                //currentTemperatureBtn.Text = $"{ac.currentHeatingSetpoint} °C";
                mArcScaleSeekBar.Progress = ac.currentHeatingSetpoint;
            }
            //auto
            else if (ac.currentSystemMode == 1)
@@ -1403,7 +1423,8 @@
                ac.currentAutoSetpoint -= 1;
                ac.SetAutoTemperatureAsync(ac.currentAutoSetpoint * 100);
                currentTemperatureBtn.Text = $"{ac.currentAutoSetpoint} °C";
                //currentTemperatureBtn.Text = $"{ac.currentAutoSetpoint} °C";
                mArcScaleSeekBar.Progress = ac.currentAutoSetpoint;
            }
        }