黄学彪
2020-12-17 9f326f4000847e6167d8166fa2f6a66f53cb3734
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
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
using System;
namespace Shared.Phone.MainPage.ControlForm
{
    /// <summary>
    /// 郭雪城的空调深度卡片的各种方法
    /// </summary>
    public class DeviceAcDetailCardMethord
    {
        #region ◆ 变量_____________________________
        /// <summary>
        /// 最低温度 16
        /// </summary>
        public const int Temperature_Low=16;
        /// <summary>
        /// 最高温度 32å
        /// </summary>
        public const int Temperature_High = 32;
        /// <summary>
        /// 默认温度
        /// </summary>
        public const int Temperature_Default = 26;
 
        #endregion
 
        #region ◆ 获取模式名称_______________________
        /// <summary>
        /// 通过模式获取模式名称
        /// </summary>
        /// <returns>The mode name by mode.</returns>
        /// <param name="acMode">Ac mode.</param>
        public static string GetModeNameByMode(ZigBee.Device.AC.AcMode acMode)
        {
            if (acMode == ZigBee.Device.AC.AcMode.Auto)
            {
                return Language.StringByID(R.MyInternationalizationString.Mode_Auto);
            }
            else if (acMode == ZigBee.Device.AC.AcMode.Cool)
            {
                return Language.StringByID(R.MyInternationalizationString.Mode_Cool);
            }
            else if (acMode == ZigBee.Device.AC.AcMode.Heat)
            {
                return Language.StringByID(R.MyInternationalizationString.Mode_Heat);
            }
            else if (acMode == ZigBee.Device.AC.AcMode.Dry)
            {
                return Language.StringByID(R.MyInternationalizationString.Mode_Dry);
            }
            else if (acMode == ZigBee.Device.AC.AcMode.FanOnly)
            {
                return Language.StringByID(R.MyInternationalizationString.Mode_FanOnly);
            }
            return Language.StringByID(R.MyInternationalizationString.Mode_Auto);
        }
 
        /// <summary>
        /// 通过模式id获取模式名称
        /// 
        /// <para>0:Off </para>
        /// <para>1:Auto </para>
        /// <para>3:Cool </para>
        /// <para>4:Heat </para>
        /// <para>5:Emergency heating </para>
        /// <para>6:Precooling</para>
        /// <para>7:Fan only </para>
        /// <para>8:Dry </para>
        /// <para>9:Sleep</para>
        /// </summary>
        /// <returns>The mode name by mode.</returns>
        /// <param name="acMode">Ac mode.</param>
        public static string GetModeNameByModeId(int acMode)
        {
            if (acMode == 1)
            {
                return Language.StringByID(R.MyInternationalizationString.Mode_Auto);
            }
            else if (acMode == 3)
            {
                return Language.StringByID(R.MyInternationalizationString.Mode_Cool);
            }
            else if (acMode == 4)
            {
                return Language.StringByID(R.MyInternationalizationString.Mode_Heat);
            }
            else if (acMode == 8)
            {
                return Language.StringByID(R.MyInternationalizationString.Mode_Dry);
            }
            else if (acMode == 7)
            {
                return Language.StringByID(R.MyInternationalizationString.Mode_FanOnly);
            }
            //
            return Language.StringByID(R.MyInternationalizationString.Mode_Auto);
        }
 
        #endregion
 
        #region ◆ 获取风速名称_______________________
        /// <summary>
        /// 通过风速模式获取风速名称
        /// </summary>
        /// <returns>The fan mode name by fan mode.</returns>
        /// <param name="fanMode">Fan mode.</param>
        public static string GetFanModeNameByFanMode(ZigBee.Device.AC.FanMode fanMode)
        {
            if(fanMode==ZigBee.Device.AC.FanMode.Low)
            {
                return Language.StringByID(R.MyInternationalizationString.Fan_Low);
            }
            else if(fanMode == ZigBee.Device.AC.FanMode.Medium)
            {
                return Language.StringByID(R.MyInternationalizationString.Fan_Middle);
            }
            else
            {
                return Language.StringByID(R.MyInternationalizationString.Fan_Height);
            }
        }
 
        #endregion
 
        #region ◆ 获取模式图片名称_____________________
        /// <summary>
        /// 通过模式id获取选中的图片路径
        /// </summary>
        /// <returns>The mode selected image path by mode identifier.</returns>
        /// <param name="acMode">Ac mode.</param>
        public static string GetModeSelectedImagePathByModeId(int acMode)
        {
            if (acMode == 1)
            {
                return "AC/Mode_AutoSelected.png";
            }
            else if (acMode == 3)
            {
                return "AC/Mode_CoolSelected.png";
            }
            else if (acMode == 4)
            {
                return "AC/Mode_HeatSelected.png";
            }
            else if (acMode == 7)
            {
                return "AC/Mode_FanSelected.png";
            }
            else if (acMode == 8)
            {
                return "AC/Mode_DrySelected.png";
            }
            return  "AC/Mode_AutoSelected.png";
        }
 
        /// <summary>
        /// 通过模式id获取图片路径
        /// </summary>
        /// <returns>The mode selected image path by mode identifier.</returns>
        /// <param name="acMode">Ac mode.</param>
        public static string GetModeUnSelectedImagePathByModeId(int acMode)
        {
            if (acMode == 1)
            {
                return "AC/Mode_Auto.png";
            }
            else if (acMode == 3)
            {
                return "AC/Mode_Cool.png";
            }
            else if (acMode == 4)
            {
                return "AC/Mode_Heat.png";
            }
            else if (acMode == 7)
            {
                return "AC/Mode_Fan.png";
            }
            else if (acMode == 8)
            {
                return "AC/Mode_Dry.png";
            }
            return "AC/Mode_Auto.png";
        }
 
        /// <summary>
        /// 通过模式id获取选中的图片路径
        /// </summary>
        /// <returns>The mode selected image path by mode identifier.</returns>
        /// <param name="acMode">Ac mode.</param>
        public static string GetModeSelectedImagePathByMode(ZigBee.Device.AC.AcMode acMode)
        {
            if (acMode == ZigBee.Device.AC.AcMode.Auto)
            {
                return GetModeSelectedImagePathByModeId(1);
            }
            else if (acMode == ZigBee.Device.AC.AcMode.Cool)
            {
                return GetModeSelectedImagePathByModeId(3);
            }
            else if (acMode == ZigBee.Device.AC.AcMode.Heat)
            {
                return GetModeSelectedImagePathByModeId(4);
            }
            else if (acMode == ZigBee.Device.AC.AcMode.FanOnly)
            {
                return GetModeSelectedImagePathByModeId(7);
            }
            else if (acMode == ZigBee.Device.AC.AcMode.Dry)
            {
                return GetModeSelectedImagePathByModeId(8);
            }
            return GetModeSelectedImagePathByModeId(1);
        }
 
        /// <summary>
        /// 通过模式id获取选中的图片路径
        /// </summary>
        /// <returns>The mode selected image path by mode identifier.</returns>
        /// <param name="acMode">Ac mode.</param>
        public static string GetModeUnSelectedImagePathByMode(ZigBee.Device.AC.AcMode acMode)
        {
            if (acMode == ZigBee.Device.AC.AcMode.Auto)
            {
                return GetModeUnSelectedImagePathByModeId(1);
            }
            else if (acMode == ZigBee.Device.AC.AcMode.Cool)
            {
                return GetModeUnSelectedImagePathByModeId(3);
            }
            else if (acMode == ZigBee.Device.AC.AcMode.Heat)
            {
                return GetModeUnSelectedImagePathByModeId(4);
            }
            else if (acMode == ZigBee.Device.AC.AcMode.FanOnly)
            {
                return GetModeUnSelectedImagePathByModeId(7);
            }
            else if (acMode == ZigBee.Device.AC.AcMode.Dry)
            {
                return GetModeUnSelectedImagePathByModeId(8);
            }
            return GetModeUnSelectedImagePathByModeId(1);
        }
 
        #endregion
 
        #region ◆ 获取扫风模式图片名称_____________________
        /// <summary>
        /// 通过扫风模式获取选中图片
        /// </summary>
        /// <returns>The fan mode selected image path by fan mode identifier.</returns>
        /// <param name="swingMode">Fan mode.</param>
        public static string GetFanSwingModeSelectedImagePathByFanSwingModeId(int swingMode)
        {
            if (swingMode == 0)
            {
                return "AC/Swing_1Selected.png";
            }
            else if (swingMode == 1)
            {
                return "AC/Swing_2Selected.png";
            }
            else if (swingMode == 2)
            {
                return "AC/Swing_3Selected.png";
            }
            else if (swingMode == 3)
            {
                return "AC/Swing_4Selected.png";
            }
            else if (swingMode == 4)
            {
                return "AC/Swing_5Selected.png";
            }
            return "AC/Swing_AutoSelected.png";
        }
 
        /// <summary>
        /// 通过扫风模式获取图片
        /// </summary>
        /// <returns>The fan mode selected image path by fan mode identifier.</returns>
        /// <param name="swingMode">Fan mode.</param>
        public static string GetFanSwingModeUnSelectedImagePathByFanSwingModeId(int swingMode)
        {
            if (swingMode == 0)
            {
                return "AC/Swing_1.png";
            }
            else if (swingMode == 1)
            {
                return "AC/Swing_2.png";
            }
            else if (swingMode == 2)
            {
                return "AC/Swing_3.png";
            }
            else if (swingMode == 3)
            {
                return "AC/Swing_4.png";
            }
            else if (swingMode == 4)
            {
                return "AC/Swing_5.png";
            }
            return "AC/Swing_Auto.png";
        }
 
        /// <summary>
        /// 通过扫风模式获取选中图片
        /// </summary>
        /// <returns>The fan mode selected image path by fan mode identifier.</returns>
        /// <param name="swingMode">Fan mode.</param>
        public static string GetFanSwingModeSelectedImagePathByFanSwingMode(ZigBee.Device.AC.FanSwingMode swingMode)
        {
            return GetFanSwingModeSelectedImagePathByFanSwingModeId((int)swingMode);
        }
 
        /// <summary>
        /// 通过扫风模式获取图片
        /// </summary>
        /// <returns>The fan mode selected image path by fan mode identifier.</returns>
        /// <param name="swingMode">Fan mode.</param>
        public static string GetFanSwingModeUnSelectedImagePathByFanSwingMode(ZigBee.Device.AC.FanSwingMode swingMode)
        {
            return GetFanSwingModeUnSelectedImagePathByFanSwingModeId((int)swingMode);
        }
 
        #endregion
 
 
        #region ◆ 获取风速图片名称_____________________
 
        /// <summary>
        /// 通过风速模式获取风速选中图片
        /// </summary>
        /// <returns>The fan mode selected image path by fan mode identifier.</returns>
        /// <param name="fanMode">Fan mode.</param>
        public static string GetFanModeSelectedImagePathByFanModeId(int fanMode)
        { 
            if(fanMode == 1)
            {
                return "AC/Fan_LowSelected.png";
            }
            else if(fanMode == 2)
            {
                return "AC/Fan_MiddleSelected.png";
            }
            else if(fanMode == 3)
            {
                return "AC/Fan_HeightSelected.png";
            }
            return  "AC/Fan_LowSelected.png";
        }
 
        /// <summary>
        /// 通过风速模式获取风速图片
        /// </summary>
        /// <returns>The fan mode selected image path by fan mode identifier.</returns>
        /// <param name="fanMode">Fan mode.</param>
        public static string GetFanModeUnSelectedImagePathByFanModeId(int fanMode)
        {
            if (fanMode == 1)
            {
                return "AC/Fan_Low.png";
            }
            else if (fanMode == 2)
            {
                return "AC/Fan_Middle.png";
            }
            else if (fanMode == 3)
            {
                return "AC/Fan_Height.png";
            }
            return "AC/Fan_Low.png";
        }
 
        /// <summary>
        /// 通过风速模式获取风速选中图片
        /// </summary>
        /// <returns>The fan mode selected image path by fan mode identifier.</returns>
        /// <param name="fanMode">Fan mode.</param>
        public static string GetFanModeSelectedImagePathByFanMode(ZigBee.Device.AC.FanMode fanMode)
        {
            return GetFanModeSelectedImagePathByFanModeId((int)fanMode);
        }
 
        /// <summary>
        /// 通过风速模式获取风速图片
        /// </summary>
        /// <returns>The fan mode selected image path by fan mode identifier.</returns>
        /// <param name="swingMode">Fan mode.</param>
        public static string GetFanModeUnSelectedImagePathByFanMode(ZigBee.Device.AC.FanMode fanMode)
        {
            return GetFanModeUnSelectedImagePathByFanModeId((int)fanMode);
        }
 
        #endregion
 
        #region ◆ 获取模式__________________________
 
        //public static ZigBee.Device.AC.AcMode GetModeByModeId(int modeId)
        //{
        //if(modeId==)
        //}
 
        #endregion
 
        #region ◆ 获取温度__________________________
 
        public static int GetCurrentModeTemperature(ZigBee.Device.AC ac)
        {
 
            if (ac.currentSystemMode == 3 || ac.currentSystemMode == 8)
            {
                return ac.currentCoolingSetpoint;
            }
            else if (ac.currentSystemMode == 4)
            {
                return ac.currentHeatingSetpoint;
            }
            else if (ac.currentSystemMode == 1)
            {
                return ac.currentAutoSetpoint;
            }
            return ac.currentLocalTemperature;
        }
 
        #endregion
 
        #region ◆ 设置温度__________________________
        /// <summary>
        /// 设置当前模式下的温度
        /// </summary>
        /// <param name="ac">Ac.</param>
        /// <param name="temperature">Temperature.</param>
        public static void SetCurrentModeTemperature(ZigBee.Device.AC ac ,int temperature)
        {
            if (ac.currentSystemMode == 3)
            {
                 ac.currentCoolingSetpoint+=temperature;
            }
            else if (ac.currentSystemMode == 4)
            {
                 ac.currentHeatingSetpoint+=temperature;
            }
        }
        #endregion
 
        #region ◆ 当前空调开关状态____________________
 
        /// <summary>
        /// 当前空调开关状态
        /// </summary>
        /// <returns><c>true</c>, if open was ised, <c>false</c> otherwise.</returns>
        /// <param name="ac">Ac.</param>
        public static bool IsOpen(ZigBee.Device.AC ac)
        {
            if (ac.currentSystemMode == 0)
            {
                return false;
            }
            return true;
        }
 
        #endregion
 
        #region ◆ 提示空调已关________________________
        /// <summary>
        /// 提示空调已关
        /// </summary>
        public static void ShowACIsCloseTip()
        {
            Application.RunOnMainThread(() =>
            {
                string msg = Language.StringByID(R.MyInternationalizationString.TheACIsClose);
                //var tip = new Phone.UserCenter.TipViewControl(msg, 1000, 1);
                //tip.ShowView();
            });
        }
 
        #endregion
    }
}