HDL Home App 第二版本 旧平台金堂用 正在使用
wjc
2022-12-01 351bdda734832d821a9764b0cde8be5d83c4ec50
ZigbeeApp/Shared/Phone/MainPage/ControlForm/Base/DeviceDetailCardCommonForm.cs
@@ -26,6 +26,10 @@
        /// </summary>
        public Common.Room nowSelectRoom = null;
        /// <summary>
        /// 标记它是由哪个控件调起的
        /// </summary>
        public ViewGroup RowOrCardControl = null;
        /// <summary>
        /// 状态控件
        /// </summary>
        private NormalViewControl btnStatu = null;
@@ -40,7 +44,7 @@
        /// <summary>
        /// 是否获取网关反馈的结果  0:没有获取得到  1:已经获取得到
        /// </summary>
        private int ResponeResult = 0;
        public int ResponeResult = 0;
        /// <summary>
        /// 当前端点的功能类型
        /// </summary>
@@ -83,8 +87,19 @@
            btnMore.InitControl();
            btnMore.ButtonClickEvent += (sender, e) =>
            {
                var detailInfo = new DeviceDetailInfoForm();
                detailInfo.AddForm(device, nowSelectRoom);
                //获取设备属于【晾衣架】
                var deviceEnumInfo = Common.LocalDevice.Current.GetMyDeviceEnumInfo(new List<CommonDevice> { device });
                if (deviceEnumInfo.ConcreteType == Common.DeviceConcreteType.Airer)
                {
                    var form = new Shared.Phone.UserCenter.Device.DeviceFunctionSettionForm();
                    form.AddForm(device, true);
                }
                else
                {
                    var detailInfo = new DeviceDetailInfoForm();
                    detailInfo.AddForm(device, nowSelectRoom);
                }
            };
            //初始化中部信息
@@ -117,6 +132,17 @@
            frameWhiteBack.Gravity = Gravity.CenterHorizontal;
            bodyFrameLayout.AddChidren(frameWhiteBack);
            if (this.device.Type == DeviceType.TemperatureSensor)
            {
                //获取设备类型
                var deviceEnumInfo = Common.LocalDevice.Current.GetMyDeviceEnumInfo(new List<CommonDevice>() { device });
                //空气质量传感器 ,卡片比较大
                if (deviceEnumInfo.ConcreteType == Common.DeviceConcreteType.AirQualitySensor)
                {
                    frameWhiteBack.Y = Application.GetRealHeight(98);
                }
            }
            //设备名称
            this.btnDeviceName = new NormalViewControl(100, 60, true);
            btnDeviceName.Y = Application.GetRealHeight(46);
@@ -142,7 +168,7 @@
            frameRoomBlack.Height = Application.GetRealHeight(138);
            frameRoomBlack.Width = frameWhiteBack.Width;
            frameRoomBlack.BackgroundColor = 0xff232323;
            frameRoomBlack.Radius= (uint)Application.GetRealHeight(17);
            frameRoomBlack.Radius = (uint)Application.GetRealHeight(17);
            frameRoomBlack.Gravity = Gravity.BottomCenter;
            frameWhiteBack.AddChidren(frameRoomBlack);
@@ -228,16 +254,14 @@
            this.ResponeResult = 0;
            //先让指定控件不能点击
            var listSelect = new List<bool>();
            foreach (var myContr in listControl)
            {
                myContr.CanClick = false;
                listSelect.Add(myContr.IsSelected);
            }
            HdlThreadLogic.Current.RunThread(() =>
            {
                int waitime = 30;
                int waitime = 40;
                while (waitime > 0)
                {
                    System.Threading.Thread.Sleep(100);
@@ -247,22 +271,24 @@
                        break;
                    }
                    waitime--;
                    //2秒的时候,还是接受不到的话,强制再次刷新设备状态
                    if (waitime == 20)
                    {
                        //从新发送获取设备的状态(强制)
                        this.device.HadReadDeviceStatu = false;
                        if (this.RowOrCardControl != null)
                        {
                            this.RowOrCardControl.GetType().InvokeMember("SendStatuComand", System.Reflection.BindingFlags.InvokeMethod, null, this.RowOrCardControl, null);
                        }
                    }
                }
                if (waitime <= 0)
                if (waitime <= 0 && this.Parent != null)
                {
                    //没有获取得到结果
                    HdlThreadLogic.Current.RunMain(() =>
                    {
                        var msgContr = new ShowMsgControl(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.FAIL));
                        msgContr.Show();
                        //变更回原来的状态
                        for (int i = 0; i < listSelect.Count; i++)
                        {
                            if (listSelect[i] != listControl[i].IsSelected)
                            {
                                listControl[i].IsSelected = listSelect[i];
                            }
                        }
                    });
                }
                //开关按钮可以再点击
@@ -292,36 +318,35 @@
        private void AddDeviceReportEvent()
        {
            string mainKeys = Common.LocalDevice.Current.GetDeviceMainKeys(this.device);
            //节点反馈
            HdlGatewayReceiveLogic.Current.AddAttributeEvent("DeviceDetailCardControl" + mainKeys, ReceiveComandDiv.A节点控制反馈, (report) =>
            {
                string mainKey2 = Common.LocalDevice.Current.GetDeviceMainKeys(report);
                if (mainKeys != mainKey2)
                {
                    //不是同一个东西
                    return;
                }
                //检测结果
                if (this.CheckResponeResultStatu(ReceiveComandDiv.A节点控制反馈, report) == true)
                {
                    //结果已经接收到
                    this.ResponeResult = 1;
                }
            });
            //属性上报
            HdlGatewayReceiveLogic.Current.AddAttributeEvent("DeviceDetailCardAttribute" + mainKeys, ReceiveComandDiv.A设备属性上报, (report) =>
            {
                string mainKey2 = Common.LocalDevice.Current.GetDeviceMainKeys(report);
                if (mainKeys != mainKey2)
                if (this.device.Type == DeviceType.Airer && this.device.DeviceAddr == report.DeviceAddr)
                {
                    //不是同一个东西
                    return;
                    //晾衣架特殊:5个回路代表不同的功能,但是默认本地只显示了第一个回路
                    //所以条件特殊判断
                    //检测结果
                    if (this.CheckResponeResultStatu(ReceiveComandDiv.A设备属性上报, report) == true)
                    {
                        //结果已经接收到
                        this.ResponeResult = 1;
                    }
                }
                //检测结果
                if (this.CheckResponeResultStatu(ReceiveComandDiv.A设备属性上报, report) == true)
                else
                {
                    //结果已经接收到
                    this.ResponeResult = 1;
                    if (mainKeys != mainKey2)
                    {
                        //不是同一个东西
                        return;
                    }
                    //检测结果
                    if (this.CheckResponeResultStatu(ReceiveComandDiv.A设备属性上报, report) == true)
                    {
                        //结果已经接收到
                        this.ResponeResult = 1;
                    }
                }
            });
        }
@@ -376,7 +401,6 @@
        public override void CloseFormBefore()
        {
            string mainKeys = Common.LocalDevice.Current.GetDeviceMainKeys(this.device);
            HdlGatewayReceiveLogic.Current.RemoveEvent("DeviceDetailCardControl" + mainKeys);
            HdlGatewayReceiveLogic.Current.RemoveEvent("DeviceDetailCardAttribute" + mainKeys);
            //回调函数
@@ -400,6 +424,15 @@
        }
        /// <summary>
        /// 设置PM2.5传感器状态文本(不需要指定【当前两个字】)
        /// </summary>
        /// <param name="text"></param>
        public void SetPmTwoPointFiveStatuText(string text)
        {
            this.btnStatu.Text = text;
        }
        /// <summary>
        /// 重新设置设备名字控件和状态控件的Y轴
        /// </summary>
        /// <param name="i_NameY">设备名字控件的Y轴(真实值)</param>