wxr
2020-09-11 8df24b0a3dfd5b6f39c5393ef24eab25b70ab858
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
using System;
using System.Collections.Generic;
 
namespace HDL_ON.Entity
{
    public class FloorHeating : Function
    {
        /*
        *地热:trait: [switch, mode, temperature, lock]
        *属性 描述
        *switch    on/off
        *mode    day, night,away, vacation, timer
        *temperature value(只读)
        *lock    boolean(Lock锁定控制)
        *set_ point    up,down,value
        */
        public FloorHeating()
        {
        }
        /// <summary>
        /// 当前温度模式
        /// 0:摄氏度
        /// 1:华氏度
        /// </summary>
        [Newtonsoft.Json.JsonIgnore]
        public int curTempType = 0;
 
        /// <summary>
        /// 工作模式
        /// 0:地热模式;1:地冷模式;
        /// 2:地热功率模式;3:地冷功率模式;
        /// </summary>
        public int workMode = 0;
        /// <summary>
        /// 当前温度模式字符
        /// </summary>
        public string tempUnitString
        {
            get
            {
                if (curTempType == 0)
                {
                    return "°C";
                }
                else
                {
                    return "°F";
                }
            }
        }
        Trait _trait_mode;
        /// <summary>
        /// 模式属性
        /// </summary>
        [Newtonsoft.Json.JsonIgnore]
        public Trait trait_mode
        {
            get
            {
                if (_trait_mode == null)
                {
                    _trait_mode = function.Find((obj) => obj.name == "mode");
                    //找不到属性需要声明一个,防止报错闪退
                    if (_trait_mode == null)
                    {
                        _trait_mode = new Trait()
                        {
                            name = "mode",
                            value_key = new List<string> { "day", "night", "away", "vacation", "timer" },
                            max = 4,
                            min = 0,
                        };
                    }
                    _trait_mode.value = _trait_mode.value_key.Count > 0 ? _trait_mode.value_key[0] : "";
                }
                return _trait_mode;
            }
        }
 
        /// <summary>
        /// 工作模式对应的工作温度
        /// </summary>
        [Newtonsoft.Json.JsonIgnore]
        public Dictionary<string, byte> modeTemp = new Dictionary<string, byte>();
 
        /// <summary>
        /// 当前模式索引
        /// bus控制命令使用
        /// </summary>
        [Newtonsoft.Json.JsonIgnore]
        public byte curModeIndex
        {
            get
            {
                try
                {
                    byte index = 0;
                    switch (trait_mode.value.ToString())
                    {
                        case "day":
                            index = 2;
                            break;
                        case "night":
                            index = 3;
                            break;
                        case "away":
                            index = 4;
                            break;
                        case "normal":
                            index = 1;
                            break;
                        case "timer":
                            index = 5;
                            break;
                        default:
                            index = 0;
                            break;
                    }
                    return index;
                }
                catch (Exception ex)
                {
                    MainPage.Log($"get curModeIndex error : {ex.Message}");
                    return 0;
                }
            }
            set
            {
                switch (value)
                {
                    case 5:
                        trait_mode.value = "timer";
                        break;
                    case 1:
                        trait_mode.value = "normal";
                        break;
                    case 2:
                        trait_mode.value = "day";
                        break;
                    case 3:
                        trait_mode.value = "night";
                        break;
                    case 4:
                        trait_mode.value = "away";
                        break;
                    default:
                        trait_mode.value = "cool";
                        break;
 
                }
            }
        }
 
        /// <summary>
        /// 时间标记
        /// 0:白天;1:夜晚
        /// </summary>
        public byte timeFlag = 0;
 
        /// <summary>
        /// 室内温度
        /// </summary>
        [Newtonsoft.Json.JsonIgnore]
        public int indoorTemp = 20;
 
 
        Trait _trait_temperature;
        /// <summary>
        /// 当前温度
        /// </summary>
        [Newtonsoft.Json.JsonIgnore]
        public double curTemp
        {
            get
            {
                try
                {
                    if (_trait_temperature == null)
                    {
                        _trait_temperature = function.Find((obj) => obj.name == "temperature");
                        //找不到属性需要声明一个,防止报错闪退
                        if (_trait_temperature == null)
                        {
                            _trait_temperature = new Trait()
                            {
                                name = "temperature",
                                value_key = new List<string>(),
                                max = 32,
                                min = 5,
                            };
                        }
                        _trait_temperature.value = 5;
                    }
                    return 5;
                }
                catch (Exception ex)
                {
                    MainPage.Log($"ac get temp error : {ex.Message}");
                    return 5;
                }
            }
            set
            {
                if (_trait_temperature == null)
                {
                    _trait_temperature = function.Find((obj) => obj.name == "temperature");
                    //找不到属性需要声明一个,防止报错闪退
                    if (_trait_temperature == null)
                    {
                        _trait_temperature = new Trait()
                        {
                            name = "temperature",
                            value_key = new List<string>(),
                            max = 4,
                            min = 0,
                        };
                    }
                    _trait_temperature.value = _trait_temperature.value_key[_trait_temperature.min];
                }
                _trait_temperature.value = value;
            }
        }
 
        /// <summary>
        /// 当前模式的icon路径
        /// </summary>
        [Newtonsoft.Json.JsonIgnore]
        public string curModeImage
        {
            get
            {
                try
                {
                    var imagePath = "FunctionIcon/AC/HeatingIcon.png";
                    switch (trait_mode.value)
                    {
                        case "day":
                            imagePath = "FunctionIcon/AC/HeatingIcon.png";
                            break;
                        case "night":
                            imagePath = "FunctionIcon/FloorHeating/NightIcon.png";
                            break;
                        case "away":
                            imagePath = "FunctionIcon/FloorHeating/AwayIcon.png";
                            break;
                        case "timer":
                            imagePath = "FunctionIcon/AC/AutoIcon.png";
                            break;
                        case "normal":
                            imagePath = "FunctionIcon/FloorHeating/OrdinaryIcon.png";
                            break;
                        default:
                            imagePath = "FunctionIcon/AC/HeatingIcon.png";
                            break;
                    }
                    return imagePath;
                }
                catch (Exception ex)
                {
                    MainPage.Log($"ac ge curModeImage error : {ex.Message}");
                    return "FunctionIcon/AC/CoolIcon.png";
                }
            }
        }
 
    }
}