HDL Home App 第二版本 旧平台金堂用 正在使用
黄学彪
2020-05-06 ae7c46bda98a987d170a9b8419fc014564790359
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
using Shared.Phone.UserCenter;
using System;
using System.Collections.Generic;
using System.Text;
using ZigBee.Device;
 
namespace Shared.Phone.Category.Controls
{
    /// <summary>
    /// 分类界面的空气开关设备行控件
    /// </summary>
    public class DeviceAirSwitchRowControl : DeviceRowCommon
    {
        #region ■ 初始化_____________________________
 
        /// <summary>
        /// 初始化控件
        /// </summary>
        /// <param name="i_device"></param>
        public override void InitControl(CommonDevice i_device)
        {
            base.InitControl(i_device);
 
            //添加跳转深度卡片信息事件
            this.AddDetailInfoEvent(i_device);
 
            //添加开关控件
            var btnSwitch = this.AddSwitchControl();
            btnSwitch.ButtonClickEvent += (sender, e) =>
            {
                //如果住宅为虚拟住宅
                if (Common.Config.Instance.Home.IsVirtually == true)
                {
                    //直接变更缓存
                    ((LightBase)i_device).OnOffStatus = btnSwitch.IsSelected == true ? 0 : 1;
                    this.RefreshControlInfo(this.device);
                    return;
                }
                bool setStatu = !btnSwitch.IsSelected;
                //变更卡片状态
                this.SetRowOpenStatu(setStatu);
                //检测是否获取网关反馈的结果,如果网关没有回复,则会弹出消息
                this.StartCheckResponeResult(!setStatu);
 
                if (setStatu == true)
                {
                    //打开
                    this.SetDeviceStatuText(Language.StringByID(R.MyInternationalizationString.uOpen1));
                    i_device.SwitchControl(1);
                }
                else
                {
                    //关闭
                    this.SetDeviceStatuText(Language.StringByID(R.MyInternationalizationString.Close));
                    i_device.SwitchControl(0);
                }
            };
        }
 
        #endregion
 
        #region ■ 深度卡片信息_______________________
 
        /// <summary>
        /// 添加跳转深度卡片信息事件
        /// </summary>
        private void AddDetailInfoEvent(CommonDevice i_device)
        {
            //深度卡片信息
            this.frameTable.ButtonClickEvent += (sender, e) =>
            {
                int backHeight = 0;
                if (i_device.DfunctionType == DeviceFunctionType.A开关)
                {
                    backHeight = 1290;
                }
                else if (i_device.DfunctionType == DeviceFunctionType.A插座)
                {
                    backHeight = 1290;
                }
                else
                {
                    backHeight = 1316;
                }
 
                //继电器类型的深度卡片界面(含空气开关)
                var form = new MainPage.ControlForm.DeviceRelayDetailCardForm();
                form.AddForm(i_device, UserCenter.HdlRoomLogic.Current.CurrentRoom, 965, backHeight);
                form.FormCloseEvent += this.CardDetailInfoBackEvent;
            };
        }
 
        #endregion
 
        #region ■ 检测设备打开状态___________________
 
        /// <summary>
        /// 检测设备打开状态
        /// </summary>
        /// <param name="i_device"></param>
        /// <returns></returns>
        public override bool CheckIsOpenStatu(CommonDevice i_device)
        {
            return ((LightBase)i_device).OnOffStatus == 1;
        }
 
        #endregion
 
        #region ■ 发送获取状态命令___________________
 
        /// <summary>
        /// 发送获取状态命令
        /// </summary>
        public override void SendStatuComand()
        {
            //如果住宅为虚拟住宅,此功能无效
            if (Common.Config.Instance.Home.IsVirtually == true)
            {
                return;
            }
            //检测能否发送获取状态命令
            if (this.CheckCanSendStatuComand() == true)
            {
                HdlDeviceAttributeLogic.Current.SendLightStatuComand(this.device);
            }
        }
 
        #endregion
    }
}