JLChen
2021-08-10 498c442cd1be3a53364b42660a8eee9ffe34051a
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
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
package com.hdl.sdk.hdl_sdk.activity;
 
 
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RelativeLayout;
import android.widget.TextView;
 
 
import com.hdl.sdk.hdl_core.HDLAppliances.Config.HDLApConfig;
import com.hdl.sdk.hdl_core.HDLAppliances.HDLAirCondition.Parser.AirCtrlParser;
import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.AppliancesInfo;
import com.hdl.sdk.hdl_core.HDLDeviceManger.Core.HDLCommand;
import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.AirFeedBackEvent;
import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.DeviceStateEvent;
import com.hdl.sdk.hdl_sdk.R;
import com.hdl.sdk.hdl_sdk.base.BaseActivity;
import com.hdl.sdk.hdl_sdk.utlis.HDLLog;
 
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
 
 
/**
 * Created by JLChen on 2019/7/4
 * 空调类模块控制页面
 * PANEL 类型空调模块
 * 16~30摄氏度(℃)
 */
public class CtrlAirActivity extends BaseActivity {
//    /**Topbar*/
//    private RelativeLayout topBarBack;
//    private TextView topBarTitle;
 
    private Button airBtnSwitch, airBtnMode, airBtnTemp, airBtnSpeed;
    private TextView airText;
    private TextView tv_switch, tv_mode, tv_speed, tv_tempet;
    private EditText airTempEd;
    private AppliancesInfo appliancesInfo;
 
 
    private int airSwitchState;//Demo仅以此作为演示,实际请根据需求开发设计
    private int airModeState;
    private int airTempState;
    private int airSpeedState;
//    /**
//     * true为设置摄氏度 false为设置华氏度
//     * 参数范围 16~30摄氏度(℃)
//     * ~86华氏度(℉)
//     */
//    private boolean bCelsius = true;
 
    /**
     * 复写isRegisterEventBus()  要注册使用EventBus,这里要设置返回true
     *
     * @return true
     */
    @Override
    protected boolean isRegisterEventBus() {
        return true;
    }
 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_ctrl_air);
        initToolbar();
        initView();
        initOnClick();
        initcurState();
        displayStateView();
 
//        if(appliancesInfo.getDeviceType() == HDLApConfig.TYPE_AC_HVAC) {
//            HDLCommand.getHVACDeviceStateFromNetwork(appliancesInfo);
//        }
//        //从本地获取空调面板状态
//        HDLCommand.getDeviceStateFromLocal(appliancesInfo);
    }
 
 
 
    /**
     * 初始化Toolbar
     */
    private void initToolbar() {
//        topBarBack = findViewById(R.id.ll_top_b_left);
//        setViewVisible(topBarBack);
//        topBarTitle = findViewById(R.id.tv_top_b_header_title);
//        topBarBack.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View view) {
//                finish();
//            }
//        });
    }
 
    private void initcurState() {
        appliancesInfo = (AppliancesInfo) getIntent().getSerializableExtra("hdl");
        String titleStr = appliancesInfo.getRemarks();
//        topBarTitle.setText(titleStr);
    }
 
    private void displayStateView(){
        switch (appliancesInfo.getDeviceType()) {
//            case HDLApConfig.TYPE_AC_HVAC:
            case HDLApConfig.TYPE_AC_PANEL:
                loadDeviceData();
                break;
            default:
                finish();//设备类型不对结束页面
                break;
        }
        /**根据需求是否发送一次获取刷新状态请求*/
    }
 
    private void initView() {
        airBtnSwitch = findViewById(R.id.airbtn_switch);
        airBtnMode = findViewById(R.id.airbtn_mode);
        airBtnSpeed = findViewById(R.id.airbtn_speed);
        airBtnTemp = findViewById(R.id.airbtn_tempBtn);
        airTempEd = findViewById(R.id.airet_tempet);
        airText = findViewById(R.id.airText);
 
        tv_switch = findViewById(R.id.tv_switch);
        tv_mode = findViewById(R.id.tv_mode);
        tv_speed = findViewById(R.id.tv_speed);
        tv_tempet = findViewById(R.id.tv_tempet);
    }
 
    private void initOnClick() {
        airBtnSwitch.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //演示当前状态为关,设置为开。开,设置为关。
                if (airSwitchState == 0) {
                    HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.airSwich, AirCtrlParser.airOn);//空调开
                } else {
                    HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.airSwich, AirCtrlParser.airOff);//空调关
                }
            }
        });
 
 
        airBtnMode.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                switch (airModeState) {
                    case 0:
                        //若当前空调模式为制冷,则点击按钮设置为制热
                        HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.airMode, AirCtrlParser.airModeHeatTem);//空调模式制热
                        break;
                    case 1:
                        //若当前空调模式为制热,则点击按钮设置为通风
                        HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.airMode, AirCtrlParser.airModeVen);//空调模式通风
                        break;
                    case 2:
                        //若当前空调模式为通风,则点击按钮设置为自动
                        HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.airMode, AirCtrlParser.airModeAuto);//空调模式自动
                        break;
                    case 3:
                        //若当前空调模式为自动,则点击按钮设置为抽湿
                        HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.airMode, AirCtrlParser.airModeDehum);//空调模式抽湿
                        break;
                    case 4:
                        //若当前空调模式为抽湿,则点击按钮设置为制冷
                        HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.airMode, AirCtrlParser.airModeRefTem);//空调模式制冷
                        break;
                    default:
                        HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.airMode, AirCtrlParser.airModeRefTem);//空调模式制冷
                        break;
 
                }
 
 
            }
        });
 
        airBtnSpeed.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                switch (airSpeedState) {
                    case 0:
                        //若当前空调风速为自动,则点击按钮设置为高风
                        HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.airSpeed, AirCtrlParser.airSpeedHigh);//风速高风
                        break;
                    case 1:
                        //若当前空调风速为高风,则点击按钮设置为中风
                        HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.airSpeed, AirCtrlParser.airSpeedMid);//风速中风
                        break;
                    case 2:
                        //若当前空调风速为中风,则点击按钮设置为低风
                        HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.airSpeed, AirCtrlParser.airSpeedLow);//风速低风
                        break;
                    case 3:
                        //若当前空调风速为低风,则点击按钮设置为自动
                        HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.airSpeed, AirCtrlParser.airSpeedAuto);//风速自动
                        break;
 
 
                }
            }
        });
 
        airBtnTemp.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String tempStr = airTempEd.getText().toString();
                if (TextUtils.isEmpty(tempStr)) {
                    showToast("设置的温度不能为空");
                    return;
                }
                int tempInt = Integer.parseInt(tempStr);
 
                if (tempInt < 16 || tempInt > 30) {
                    showToast("温度设置范围为:16~30摄氏度(℃)");
                    return;
                }
 
                switch (airModeState) {
                    case 0:
                        //当前空调模式为制冷
                        HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.refTem, tempInt);//制冷温度
                        break;
                    case 1:
                        //当前空调模式为制热
                        HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.heatTem, tempInt);//制热温度
                        break;
                    case 2:
                        //当前空调模式为通风
                        showToast("通风模式不能控制温度");
                        break;
                    case 3:
                        //当前空调模式为自动
                        HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.autoTem, tempInt);//自动温度 范围16-30
                        break;
                    case 4:
                        //当前空调模式为抽湿
                        HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.dehumTem, tempInt);//抽湿温度 范围16-30
                        break;
                    default:
                        break;
 
                }
 
//                HDLCommand.airCtrl(appliancesInfo,AirCtrlParser.upTem,1);//上升温度 范围0-5
//                HDLCommand.airCtrl(appliancesInfo,AirCtrlParser.downTem,1);//下降温度 范围0-5
            }
        });
 
 
    }
 
 
    private void loadDeviceData() {
        if (appliancesInfo.getArrCurState() != null) {
            String stringACState = "";
            byte[] acCurState = appliancesInfo.getArrCurState();
            for (int index = 0; index < acCurState.length; index++) {
                if (index == 0 && acCurState[index] == 0) {
                    airSwitchState = 0;
                    stringACState += "空调已关闭";
                    //如果空调关闭状态,则无需再遍历
                    break;
                }
                if (index == 0 && acCurState[index] == 1) {
                    airSwitchState = 1;
                    stringACState += "空调正在运行";
                }
 
                switch (index) {
 
                    case 1:
                        switch (acCurState[index]) {
                            case 0:
                                airModeState = 0;
                                stringACState += " 空调模式:制冷";
                                break;
                            case 1:
                                airModeState = 1;
                                stringACState += " 空调模式:制热";
                                break;
                            case 2:
                                airModeState = 2;
                                stringACState += " 空调模式:通风";
                                break;
                            case 3:
                                airModeState = 3;
                                stringACState += " 空调模式:自动";
                                break;
                            case 4:
                                airModeState = 4;
                                stringACState += " 空调模式:抽湿";
                                break;
                            default:
                                airModeState = -1;
                                stringACState += " 未知空调模式";
                                break;
                        }
                        break;
                    case 2:
                        switch (acCurState[1]) {
                            case 0:
                                airTempState = acCurState[index] & 0xff;
                                stringACState += " 制冷温度:" + (acCurState[index] & 0xff);
                                break;
                            case 1:
                                airTempState = acCurState[index] & 0xff;
                                stringACState += " 制热温度:" + (acCurState[index] & 0xff);
                                break;
                            case 2:
                                airTempState = -1;
                                stringACState += " 通风无温度显示";
                                break;
                            case 3:
                                airTempState = acCurState[index] & 0xff;
                                stringACState += " 自动温度:" + (acCurState[index] & 0xff);
                                break;
                            case 4:
                                airTempState = acCurState[index] & 0xff;
                                stringACState += " 抽湿温度:" + (acCurState[index] & 0xff);
                                break;
                            default:
                                airTempState = -2;
                                stringACState += " 未知温度";
                                break;
                        }
                        break;
                    case 3:
                        String curSpeed;
                        switch (appliancesInfo.getArrCurState()[index]) {
                            case 0:
                                airSpeedState = 0;
                                curSpeed = " 风速自动";
                                break;
                            case 1:
                                airSpeedState = 1;
                                curSpeed = " 风速高";
                                break;
                            case 2:
                                airSpeedState = 2;
                                curSpeed = " 风速中";
                                break;
                            case 3:
                                airSpeedState = 3;
                                curSpeed = " 风速低";
                                break;
                            default:
                                airSpeedState = -1;
                                curSpeed = " 未知风速";
                                break;
                        }
                        switch (appliancesInfo.getArrCurState()[1]) {
                            case 0:
                                stringACState += curSpeed;
                                break;
                            case 1:
                                stringACState += curSpeed;
                                break;
                            case 2:
                                stringACState += curSpeed;
                                break;
                            case 3:
                                stringACState += curSpeed;
                                break;
                            case 4:
                                stringACState += " 抽湿无风速";
                                break;
                            default:
                                stringACState += " 未知空调模式";
                                break;
                        }
                        break;
 
                    default:
                        break;
                }
            }
 
            airText.setText(stringACState);
        } else {
            airText.setText("未获取到空调设备状态");
        }
 
    }
 
    /**
     * 空调模块控制回调Event
     *
     * @param event
     */
    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onAirFeedBackInfoEventMain(AirFeedBackEvent event) {
        if (event.getAirCtrlBackInfo().getAppliancesInfo().getDeviceDeviceID() == appliancesInfo.getDeviceDeviceID()
                && event.getAirCtrlBackInfo().getAppliancesInfo().getDeviceSubnetID() == appliancesInfo.getDeviceSubnetID()
                && event.getAirCtrlBackInfo().getAppliancesInfo().getChannelNum() == appliancesInfo.getChannelNum()
        ) {
            //        先判断是否超时
            if (!event.isSuccess()) {
                showToast("空调控制超时,请重新再试");
                return;
            }
            String mes = "";
            byte[] curState = event.getAirCtrlBackInfo().getCurState();
            readAirState(curState);
        }
    }
 
    /**
     * 获取单一设备状态回调Event
     *
     * @param event
     */
    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onDeviceStateEventMain(DeviceStateEvent event) {
        if (event.getAppliancesInfo().getDeviceSubnetID() == appliancesInfo.getDeviceSubnetID()
                && event.getAppliancesInfo().getDeviceDeviceID() == appliancesInfo.getDeviceDeviceID()
        ) {
            //这个返回的信息是当前状态的
            switch (event.getAppliancesInfo().getDeviceType()) {
//                case HDLApConfig.TYPE_AC_HVAC:
                case HDLApConfig.TYPE_AC_PANEL:
                    if (appliancesInfo.getChannelNum() == event.getAppliancesInfo().getChannelNum()) {
                        if (!event.isSuccess()) {
                            showToast("获取空调状态失败,请重新再试");
                            return;
                        }
 
                        byte[] curState = event.getAppliancesInfo().getArrCurState();
 
                        readAirState(curState);
//                        switch (curState[0] & 0xFF) {
//                            case AirCtrlParser.airSwich:
//                                switch (curState[1] & 0xFF) {
//                                    case AirCtrlParser.airOff:
//                                        airSwitchState = 0;
//                                        airText.setText("空调关");
//                                        showToast("空调关");
//                                        HDLLog.I("空调关");
//                                        break;
//                                    case AirCtrlParser.airOn:
//                                        airSwitchState = 1;
//                                        airText.setText("空调开");
//                                        showToast("空调开");
//                                        HDLLog.I("空调开");
//                                        break;
//                                    default:
//                                        break;
//                                }
//
//                                break;
//
//                            case AirCtrlParser.airSpeed:
//                                switch (curState[1] & 0xFF) {
//                                    case AirCtrlParser.airSpeedAuto:
//                                        airSpeedState = 0;
//                                        airText.setText("空调风速,风速模式为:airSpeedAuto自动风速");
//                                        showToast("空调风速,风速模式为:airSpeedAuto自动风速");
//                                        HDLLog.I("空调风速,风速模式为:airSpeedAuto自动风速");
//                                        break;
//                                    case AirCtrlParser.airSpeedHigh:
//                                        airSpeedState = 1;
//                                        airText.setText("空调风速,风速模式为:airSpeedHigh风速高");
//                                        showToast("空调风速,风速模式为:airSpeedHigh风速高");
//                                        HDLLog.I("空调风速,风速模式为:airSpeedHigh风速高");
//                                        break;
//                                    case AirCtrlParser.airSpeedMid:
//                                        airSpeedState = 2;
//                                        airText.setText("空调风速,风速模式为:airSpeedMid风速中");
//                                        showToast("空调风速,风速模式为:airSpeedMid风速中");
//                                        HDLLog.I("空调风速,风速模式为:airSpeedMid风速中");
//                                        break;
//                                    case AirCtrlParser.airSpeedLow:
//                                        airSpeedState = 3;
//                                        airText.setText("空调风速,风速模式为:airSpeedLow风速低");
//                                        showToast("空调风速,风速模式为:airSpeedLow风速低");
//                                        HDLLog.I("空调风速,风速模式为:airSpeedLow风速低");
//                                        break;
//                                    default:
//                                        break;
//                                }
//                                break;
//                            case AirCtrlParser.airMode:
//                                switch (curState[1] & 0xFF) {
//                                    case AirCtrlParser.airModeRefTem:
//                                        airModeState = 0;
//                                        airText.setText("空调模式,模式为:制冷");
//                                        showToast("空调模式,模式为:制冷");
//                                        HDLLog.I("空调模式,模式为:制冷");
//                                        break;
//                                    case AirCtrlParser.airModeHeatTem:
//                                        airModeState = 1;
//                                        airText.setText("空调模式,模式为:制热");
//                                        showToast("空调模式,模式为:制热");
//                                        HDLLog.I("空调模式,模式为:制热");
//                                        break;
//                                    case AirCtrlParser.airModeVen:
//                                        airModeState = 2;
//                                        airText.setText("空调模式,模式为:通风");
//                                        showToast("空调模式,模式为:通风");
//                                        HDLLog.I("空调模式,模式为:通风");
//                                        break;
//                                    case AirCtrlParser.airModeAuto:
//                                        airModeState = 3;
//                                        airText.setText("空调模式,模式为:自动");
//                                        showToast("空调模式,模式为:自动");
//                                        HDLLog.I("空调模式,模式为:自动");
//                                        break;
//                                    case AirCtrlParser.airModeDehum:
//                                        airModeState = 4;
//                                        airText.setText("空调模式,模式为:抽湿");
//                                        showToast("空调模式,模式为:抽湿");
//                                        HDLLog.I("空调模式,模式为:抽湿");
//                                        break;
//                                    default:
//                                        break;
//                                }
//                                break;
//                            case AirCtrlParser.refTem:
//                                airTempState = curState[1] & 0xFF;
//                                airText.setText("空调制冷,温度为:" + (curState[1] & 0xFF));
//                                showToast("空调制冷,温度为:" + (curState[1] & 0xFF));
//                                HDLLog.I("空调制冷,温度为:" + (curState[1] & 0xFF));
//                                break;
//                            case AirCtrlParser.heatTem:
//                                airTempState = curState[1] & 0xFF;
//                                airText.setText("空调制热,制热温度为" + (curState[1] & 0xFF));
//                                showToast("空调制热,制热温度为" + (curState[1] & 0xFF));
//                                HDLLog.I("空调制热,制热温度为" + (curState[1] & 0xFF));
//                                break;
//                            case AirCtrlParser.autoTem:
//                                airTempState = curState[1] & 0xFF;
//                                airText.setText("空调自动,自动温度为" + (curState[1] & 0xFF));
//                                showToast("空调自动,自动温度为" + (curState[1] & 0xFF));
//                                HDLLog.I("空调自动,自动温度为" + (curState[1] & 0xFF));
//                                break;
//                            case AirCtrlParser.dehumTem:
//                                airTempState = curState[1] & 0xFF;
//                                airText.setText("空调抽湿,抽湿温度为" + (curState[1] & 0xFF));
//                                showToast("空调抽湿,抽湿温度为" + (curState[1] & 0xFF));
//                                HDLLog.I("空调抽湿,抽湿温度为" + (curState[1] & 0xFF));
//                                break;
//                            case AirCtrlParser.upTem:
//                                airTempState = curState[1] & 0xFF;
//                                airText.setText("空调调温,上升温度:" + (curState[1] & 0xFF));
//                                showToast("空调调温,上升温度:" + (curState[1] & 0xFF));
//                                HDLLog.I("空调调温,上升温度:" + (curState[1] & 0xFF));
//                                break;
//                            case AirCtrlParser.downTem:
//                                airTempState = curState[1] & 0xFF;
//                                airText.setText("空调调温,下降温度:" + (curState[1] & 0xFF));
//                                showToast("空调调温,下降温度:" + (curState[1] & 0xFF));
//                                HDLLog.I("空调调温,下降温度:" + (curState[1] & 0xFF));
//                                break;
//                        }
                    }
                    break;
                default:
                    //不处理
                    break;
            }
        }
    }
 
    private void readAirState( byte[] curState ){
        String mes = "";
        switch (curState[0] & 0xFF) {
            case AirCtrlParser.airSwich:
                switch (curState[1] & 0xFF) {
                    case AirCtrlParser.airOff:
                        airSwitchState = 0;
 
                        tv_switch.setText("关");
 
                        mes = "空调关";
                        tv_mesSetText(mes);
                        HDLLog.I(mes);
                        break;
                    case AirCtrlParser.airOn:
                        airSwitchState = 1;
//                            airText.setText("空调开");
//                            showToast("空调开");
//                            HDLLog.I("空调开");
                        tv_switch.setText("开");
 
                        mes = "空调开";
                        tv_mesSetText(mes);
                        HDLLog.I(mes);
                        break;
                    default:
                        break;
                }
 
                break;
 
            case AirCtrlParser.airSpeed:
                switch (curState[1] & 0xFF) {
                    case AirCtrlParser.airSpeedAuto:
                        airSpeedState = 0;
                        tv_speed.setText("自动");
 
                        mes = "自动风速";
                        tv_mesSetText(mes);
                        HDLLog.I(mes);
 
                        break;
                    case AirCtrlParser.airSpeedHigh:
                        airSpeedState = 1;
 
                        tv_speed.setText("高速");
                        mes = "风速高";
                        tv_mesSetText(mes);
                        HDLLog.I(mes);
                        break;
                    case AirCtrlParser.airSpeedMid:
                        airSpeedState = 2;
                        tv_speed.setText("中速");
                        mes = "风速中";
                        tv_mesSetText(mes);
                        HDLLog.I(mes);
 
                        break;
                    case AirCtrlParser.airSpeedLow:
                        airSpeedState = 3;
 
                        tv_speed.setText("低速");
                        mes = "风速低";
                        tv_mesSetText(mes);
                        HDLLog.I(mes);
 
                        break;
                    default:
                        break;
                }
                break;
            case AirCtrlParser.airMode:
                switch (curState[1] & 0xFF) {
                    case AirCtrlParser.airModeRefTem:
                        airModeState = 0;
 
                        tv_mode.setText("制冷");
 
                        mes = "模式为:制冷";
                        tv_mesSetText(mes);
                        HDLLog.I(mes);
 
                        break;
                    case AirCtrlParser.airModeHeatTem:
                        airModeState = 1;
                        tv_mode.setText("制热");
 
                        mes = "模式为:制热";
                        tv_mesSetText(mes);
                        HDLLog.I(mes);
                        break;
                    case AirCtrlParser.airModeVen:
                        airModeState = 2;
                        tv_mode.setText("通风");
 
                        mes = "模式为:通风";
                        tv_mesSetText(mes);
                        HDLLog.I(mes);
                        break;
                    case AirCtrlParser.airModeAuto:
                        airModeState = 3;
                        tv_mode.setText("自动");
 
                        mes = "模式为:自动";
                        tv_mesSetText(mes);
                        HDLLog.I(mes);
                        break;
                    case AirCtrlParser.airModeDehum:
                        airModeState = 4;
                        tv_mode.setText("抽湿");
 
                        mes = "模式为:抽湿";
                        tv_mesSetText(mes);
                        HDLLog.I(mes);
                        break;
                    default:
                        airModeState = -1;
                        break;
                }
                break;
            case AirCtrlParser.refTem:
                airTempState = curState[1] & 0xFF;
 
                tv_tempet.setText("" + airTempState);
                mes = "空调制冷,温度为:" + (airTempState);
 
                tv_mesSetText(mes);
                HDLLog.I(mes);
 
                break;
            case AirCtrlParser.heatTem:
                airTempState = curState[1] & 0xFF;
                tv_tempet.setText("" + airTempState);
                mes = "空调制热,制热温度为:" + (airTempState);
 
                tv_mesSetText(mes);
                HDLLog.I(mes);
 
                break;
            case AirCtrlParser.autoTem:
                airTempState = curState[1] & 0xFF;
 
                tv_tempet.setText(""+airTempState);
                mes = "空调自动,自动温度为:" + (airTempState);
                tv_mesSetText(mes);
                HDLLog.I(mes);
                break;
            case AirCtrlParser.dehumTem:
                airTempState = curState[1] & 0xFF;
 
                tv_tempet.setText("" + airTempState);
                mes = "空调抽湿,抽湿温度为:" + (airTempState);
                tv_mesSetText(mes);
                HDLLog.I(mes);
                break;
            case AirCtrlParser.upTem:
                airTempState = curState[1] & 0xFF;
 
 
                tv_tempet.setText("" + airTempState);
                mes = "空调调温,上升温度:" + (airTempState);
                tv_mesSetText(mes);
                HDLLog.I(mes);
                break;
            case AirCtrlParser.downTem:
                airTempState = curState[1] & 0xFF;
                tv_tempet.setText("" + airTempState);
                mes = "空调调温,下降温度:" + (airTempState);
                tv_mesSetText(mes);
                HDLLog.I(mes);
                break;
 
        }
 
    }
 
 
 
 
    /**
     * TextView 显示信息并且showToast提示
     *
     * @param mes
     */
    private void tv_mesSetText(String mes) {
        airText.setText(mes);
        showToast(mes);
    }
}