JLChen
2019-08-02 425b2352c57a377b1594097a69aabcc87207b683
app/src/main/java/com/hdl/sdk/hdl_sdk/activity/CtrlActivity.java
@@ -2,6 +2,7 @@
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.Button;
@@ -628,26 +629,38 @@
        airBtnTemp.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String tempStr = airTempEd.getText().toString();
                if (TextUtils.isEmpty(tempStr) || 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, Integer.parseInt(airTempEd.getText().toString()));//制冷温度
                        HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.refTem, tempInt);//制冷温度
                        break;
                    case 1:
                        //当前空调模式为制热
                        HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.heatTem, Integer.parseInt(airTempEd.getText().toString()));//制热温度
                        HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.heatTem, tempInt);//制热温度
                        break;
                    case 2:
                        //当前空调模式为通风
                        ToastUtil("通风模式不能控制温度");
                        showToast("通风模式不能控制温度");
                        break;
                    case 3:
                        //当前空调模式为自动
                        HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.autoTem, Integer.parseInt(airTempEd.getText().toString()));//自动温度 范围0-84
                        HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.autoTem, tempInt);//自动温度
                        break;
                    case 4:
                        //当前空调模式为抽湿
                        HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.dehumTem, Integer.parseInt(airTempEd.getText().toString()));//抽湿温度 范围0-84
                        HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.dehumTem, tempInt);//抽湿温度
                        break;
                    default:
                        break;
@@ -691,7 +704,7 @@
                ) {
            //        先判断是否超时
            if (!event.isSuccess()) {
                ToastUtil("灯光控制超时,请重新再试");
                showToast("灯光控制超时,请重新再试");
                lightBtn.setText("灯光控制超时,请重新再试");
                return;
            }
@@ -704,7 +717,7 @@
            String remarks = event.getLightCtrlBackInfo().getRemarks();//获取返回的灯光备注。如果每个灯光回路备注都唯一,可以直接通过备注判断
            String parentRemarks = event.getLightCtrlBackInfo().getParentRemarks();//获取继电器或调光灯备注。这里可以知道是哪个设备返回的
            int num = event.getLightCtrlBackInfo().getChannelNum();//获取回路号。这里可以获取到这个继电器或调光灯的回路号
            ToastUtil(parentRemarks + " 的 " + remarks + " 回路号:" + num + " 返回" + " 亮度为:" + brightness);
            showToast(parentRemarks + " 的 " + remarks + " 回路号:" + num + " 返回" + " 亮度为:" + brightness);
        }
    }
@@ -718,7 +731,7 @@
                ) {
            if (!event.isSuccess()) {
                ToastUtil("窗帘控制超时,请重新再试");
                showToast("窗帘控制超时,请重新再试");
                return;
            }
@@ -730,7 +743,7 @@
            String remarks = event.getCurtainCtrlBackInfo().getRemarks();
            String parentRemarks = event.getCurtainCtrlBackInfo().getParentRemarks();
            int num = event.getCurtainCtrlBackInfo().getNum();
//            ToastUtil(parentRemarks+" 的 "+remarks+" 回路号:"+num+" 返回"+" 状态为:"+curState);
//            showToast(parentRemarks+" 的 "+remarks+" 回路号:"+num+" 返回"+" 状态为:"+curState);
            Log.i("djl", parentRemarks + " 的 " + remarks + " 回路号:" + num + " 返回" + " 状态为:" + curState);
            if (event.getCurtainCtrlBackInfo().getAppliancesInfo().getDeviceType() == HDLApConfig.TYPE_CURTAIN_MODULE) {
                //判断是否为窗帘模块
@@ -769,7 +782,7 @@
                ) {
            //        先判断是否超时
            if (!event.isSuccess()) {
                ToastUtil("空调控制超时,请重新再试");
                showToast("空调控制超时,请重新再试");
                return;
            }
@@ -780,13 +793,13 @@
                        case AirCtrlParser.airOff:
                            airSwitchState = 0;
                            airText.setText("空调关");
                            ToastUtil("空调关");
                            showToast("空调关");
                            Log.i("djl", "空调关");
                            break;
                        case AirCtrlParser.airOn:
                            airSwitchState = 1;
                            airText.setText("空调开");
                            ToastUtil("空调开");
                            showToast("空调开");
                            Log.i("djl", "空调开");
                            break;
                        default:
@@ -800,25 +813,25 @@
                        case AirCtrlParser.airSpeedAuto:
                            airSpeedState = 0;
                            airText.setText("空调风速,风速模式为:airSpeedAuto自动风速");
                            ToastUtil("空调风速,风速模式为:airSpeedAuto自动风速");
                            showToast("空调风速,风速模式为:airSpeedAuto自动风速");
                            Log.i("djl", "空调风速,风速模式为:airSpeedAuto自动风速");
                            break;
                        case AirCtrlParser.airSpeedHigh:
                            airSpeedState = 1;
                            airText.setText("空调风速,风速模式为:airSpeedHigh风速高");
                            ToastUtil("空调风速,风速模式为:airSpeedHigh风速高");
                            showToast("空调风速,风速模式为:airSpeedHigh风速高");
                            Log.i("djl", "空调风速,风速模式为:airSpeedHigh风速高");
                            break;
                        case AirCtrlParser.airSpeedMid:
                            airSpeedState = 2;
                            airText.setText("空调风速,风速模式为:airSpeedMid风速中");
                            ToastUtil("空调风速,风速模式为:airSpeedMid风速中");
                            showToast("空调风速,风速模式为:airSpeedMid风速中");
                            Log.i("djl", "空调风速,风速模式为:airSpeedMid风速中");
                            break;
                        case AirCtrlParser.airSpeedLow:
                            airSpeedState = 3;
                            airText.setText("空调风速,风速模式为:airSpeedLow风速低");
                            ToastUtil("空调风速,风速模式为:airSpeedLow风速低");
                            showToast("空调风速,风速模式为:airSpeedLow风速低");
                            Log.i("djl", "空调风速,风速模式为:airSpeedLow风速低");
                            break;
                        default:
@@ -830,31 +843,31 @@
                        case AirCtrlParser.airModeRefTem:
                            airModeState = 0;
                            airText.setText("空调模式,模式为:制冷");
                            ToastUtil("空调模式,模式为:制冷");
                            showToast("空调模式,模式为:制冷");
                            Log.i("djl", "空调模式,模式为:制冷");
                            break;
                        case AirCtrlParser.airModeHeatTem:
                            airModeState = 1;
                            airText.setText("空调模式,模式为:制热");
                            ToastUtil("空调模式,模式为:制热");
                            showToast("空调模式,模式为:制热");
                            Log.i("djl", "空调模式,模式为:制热");
                            break;
                        case AirCtrlParser.airModeVen:
                            airModeState = 2;
                            airText.setText("空调模式,模式为:通风");
                            ToastUtil("空调模式,模式为:通风");
                            showToast("空调模式,模式为:通风");
                            Log.i("djl", "空调模式,模式为:通风");
                            break;
                        case AirCtrlParser.airModeAuto:
                            airModeState = 3;
                            airText.setText("空调模式,模式为:自动");
                            ToastUtil("空调模式,模式为:自动");
                            showToast("空调模式,模式为:自动");
                            Log.i("djl", "空调模式,模式为:自动");
                            break;
                        case AirCtrlParser.airModeDehum:
                            airModeState = 4;
                            airText.setText("空调模式,模式为:抽湿");
                            ToastUtil("空调模式,模式为:抽湿");
                            showToast("空调模式,模式为:抽湿");
                            Log.i("djl", "空调模式,模式为:抽湿");
                            break;
                        default:
@@ -865,37 +878,37 @@
                case AirCtrlParser.refTem:
                    airTempState = curState[1] & 0xFF;
                    airText.setText("空调制冷,温度为:" + (curState[1] & 0xFF));
                    ToastUtil("空调制冷,温度为:" + (curState[1] & 0xFF));
                    showToast("空调制冷,温度为:" + (curState[1] & 0xFF));
                    Log.i("djl", "空调制冷,温度为:" + (curState[1] & 0xFF));
                    break;
                case AirCtrlParser.heatTem:
                    airTempState = curState[1] & 0xFF;
                    airText.setText("空调制热,制热温度为" + (curState[1] & 0xFF));
                    ToastUtil("空调制热,制热温度为" + (curState[1] & 0xFF));
                    showToast("空调制热,制热温度为" + (curState[1] & 0xFF));
                    Log.i("djl", "空调制热,制热温度为" + (curState[1] & 0xFF));
                    break;
                case AirCtrlParser.autoTem:
                    airTempState = -1;
                    airText.setText("空调自动,自动温度为" + (curState[1] & 0xFF));
                    ToastUtil("空调自动,自动温度为" + (curState[1] & 0xFF));
                    showToast("空调自动,自动温度为" + (curState[1] & 0xFF));
                    Log.i("djl", "空调自动,自动温度为" + (curState[1] & 0xFF));
                    break;
                case AirCtrlParser.dehumTem:
                    airTempState = curState[1] & 0xFF;
                    airText.setText("空调抽湿,抽湿温度为" + (curState[1] & 0xFF));
                    ToastUtil("空调抽湿,抽湿温度为" + (curState[1] & 0xFF));
                    showToast("空调抽湿,抽湿温度为" + (curState[1] & 0xFF));
                    Log.i("djl", "空调抽湿,抽湿温度为" + (curState[1] & 0xFF));
                    break;
                case AirCtrlParser.upTem:
                    airTempState = curState[1] & 0xFF;
                    airText.setText("空调调温,上升温度:" + (curState[1] & 0xFF));
                    ToastUtil("空调调温,上升温度:" + (curState[1] & 0xFF));
                    showToast("空调调温,上升温度:" + (curState[1] & 0xFF));
                    Log.i("djl", "空调调温,上升温度:" + (curState[1] & 0xFF));
                    break;
                case AirCtrlParser.downTem:
                    airTempState = curState[1] & 0xFF;
                    airText.setText("空调调温,下降温度:" + (curState[1] & 0xFF));
                    ToastUtil("空调调温,下降温度:" + (curState[1] & 0xFF));
                    showToast("空调调温,下降温度:" + (curState[1] & 0xFF));
                    Log.i("djl", "空调调温,下降温度:" + (curState[1] & 0xFF));
                    break;
@@ -911,10 +924,10 @@
                && event.getLogicCtrlBackInfo().getAppliancesInfo().getChannelNum() == appliancesInfo.getChannelNum()
                ) {
            if (!event.isSuccess()) {
                ToastUtil("场景控制超时,请重新再试");
                showToast("场景控制超时,请重新再试");
                return;
            }
            ToastUtil("场景控制成功");
            showToast("场景控制成功");
        }
    }
@@ -932,7 +945,7 @@
                case HDLApConfig.TYPE_LIGHT_MIX_RELAY:
                    if (appliancesInfo.getChannelNum() == event.getAppliancesInfo().getChannelNum()) {
                        if (!event.isSuccess()) {
                            ToastUtil("获取灯光状态失败,请重新再试");
                            showToast("获取灯光状态失败,请重新再试");
                            return;
                        }
                        lightBtn.setText("亮度 = " + event.getAppliancesInfo().getCurState());
@@ -943,7 +956,7 @@
                case HDLApConfig.TYPE_CURTAIN_MODULE:
                    if (appliancesInfo.getChannelNum() == event.getAppliancesInfo().getChannelNum()) {
                        if (!event.isSuccess()) {
                            ToastUtil("获取窗帘状态失败,请重新再试");
                            showToast("获取窗帘状态失败,请重新再试");
                            return;
                        }
                        //窗帘模块:curState:0=停止,1=打开,2=关闭。
@@ -973,7 +986,7 @@
                case HDLApConfig.TYPE_AC_PANEL:
                    if (appliancesInfo.getChannelNum() == event.getAppliancesInfo().getChannelNum()) {
                        if (!event.isSuccess()) {
                            ToastUtil("获取空调状态失败,请重新再试");
                            showToast("获取空调状态失败,请重新再试");
                            return;
                        }
@@ -984,13 +997,13 @@
                                    case AirCtrlParser.airOff:
                                        airSwitchState = 0;
                                        airText.setText("空调关");
                                        ToastUtil("空调关");
                                        showToast("空调关");
                                        Log.i("djl", "空调关");
                                        break;
                                    case AirCtrlParser.airOn:
                                        airSwitchState = 1;
                                        airText.setText("空调开");
                                        ToastUtil("空调开");
                                        showToast("空调开");
                                        Log.i("djl", "空调开");
                                        break;
                                    default:
@@ -1004,25 +1017,25 @@
                                    case AirCtrlParser.airSpeedAuto:
                                        airSpeedState = 0;
                                        airText.setText("空调风速,风速模式为:airSpeedAuto自动风速");
                                        ToastUtil("空调风速,风速模式为:airSpeedAuto自动风速");
                                        showToast("空调风速,风速模式为:airSpeedAuto自动风速");
                                        Log.i("djl", "空调风速,风速模式为:airSpeedAuto自动风速");
                                        break;
                                    case AirCtrlParser.airSpeedHigh:
                                        airSpeedState = 1;
                                        airText.setText("空调风速,风速模式为:airSpeedHigh风速高");
                                        ToastUtil("空调风速,风速模式为:airSpeedHigh风速高");
                                        showToast("空调风速,风速模式为:airSpeedHigh风速高");
                                        Log.i("djl", "空调风速,风速模式为:airSpeedHigh风速高");
                                        break;
                                    case AirCtrlParser.airSpeedMid:
                                        airSpeedState = 2;
                                        airText.setText("空调风速,风速模式为:airSpeedMid风速中");
                                        ToastUtil("空调风速,风速模式为:airSpeedMid风速中");
                                        showToast("空调风速,风速模式为:airSpeedMid风速中");
                                        Log.i("djl", "空调风速,风速模式为:airSpeedMid风速中");
                                        break;
                                    case AirCtrlParser.airSpeedLow:
                                        airSpeedState = 3;
                                        airText.setText("空调风速,风速模式为:airSpeedLow风速低");
                                        ToastUtil("空调风速,风速模式为:airSpeedLow风速低");
                                        showToast("空调风速,风速模式为:airSpeedLow风速低");
                                        Log.i("djl", "空调风速,风速模式为:airSpeedLow风速低");
                                        break;
                                    default:
@@ -1034,31 +1047,31 @@
                                    case AirCtrlParser.airModeRefTem:
                                        airModeState = 0;
                                        airText.setText("空调模式,模式为:制冷");
                                        ToastUtil("空调模式,模式为:制冷");
                                        showToast("空调模式,模式为:制冷");
                                        Log.i("djl", "空调模式,模式为:制冷");
                                        break;
                                    case AirCtrlParser.airModeHeatTem:
                                        airModeState = 1;
                                        airText.setText("空调模式,模式为:制热");
                                        ToastUtil("空调模式,模式为:制热");
                                        showToast("空调模式,模式为:制热");
                                        Log.i("djl", "空调模式,模式为:制热");
                                        break;
                                    case AirCtrlParser.airModeVen:
                                        airModeState = 2;
                                        airText.setText("空调模式,模式为:通风");
                                        ToastUtil("空调模式,模式为:通风");
                                        showToast("空调模式,模式为:通风");
                                        Log.i("djl", "空调模式,模式为:通风");
                                        break;
                                    case AirCtrlParser.airModeAuto:
                                        airModeState = 3;
                                        airText.setText("空调模式,模式为:自动");
                                        ToastUtil("空调模式,模式为:自动");
                                        showToast("空调模式,模式为:自动");
                                        Log.i("djl", "空调模式,模式为:自动");
                                        break;
                                    case AirCtrlParser.airModeDehum:
                                        airModeState = 4;
                                        airText.setText("空调模式,模式为:抽湿");
                                        ToastUtil("空调模式,模式为:抽湿");
                                        showToast("空调模式,模式为:抽湿");
                                        Log.i("djl", "空调模式,模式为:抽湿");
                                        break;
                                    default:
@@ -1068,37 +1081,37 @@
                            case AirCtrlParser.refTem:
                                airTempState = curState[1] & 0xFF;
                                airText.setText("空调制冷,温度为:" + (curState[1] & 0xFF));
                                ToastUtil("空调制冷,温度为:" + (curState[1] & 0xFF));
                                showToast("空调制冷,温度为:" + (curState[1] & 0xFF));
                                Log.i("djl", "空调制冷,温度为:" + (curState[1] & 0xFF));
                                break;
                            case AirCtrlParser.heatTem:
                                airTempState = curState[1] & 0xFF;
                                airText.setText("空调制热,制热温度为" + (curState[1] & 0xFF));
                                ToastUtil("空调制热,制热温度为" + (curState[1] & 0xFF));
                                showToast("空调制热,制热温度为" + (curState[1] & 0xFF));
                                Log.i("djl", "空调制热,制热温度为" + (curState[1] & 0xFF));
                                break;
                            case AirCtrlParser.autoTem:
                                airTempState = curState[1] & 0xFF;
                                airText.setText("空调自动,自动温度为" + (curState[1] & 0xFF));
                                ToastUtil("空调自动,自动温度为" + (curState[1] & 0xFF));
                                showToast("空调自动,自动温度为" + (curState[1] & 0xFF));
                                Log.i("djl", "空调自动,自动温度为" + (curState[1] & 0xFF));
                                break;
                            case AirCtrlParser.dehumTem:
                                airTempState = curState[1] & 0xFF;
                                airText.setText("空调抽湿,抽湿温度为" + (curState[1] & 0xFF));
                                ToastUtil("空调抽湿,抽湿温度为" + (curState[1] & 0xFF));
                                showToast("空调抽湿,抽湿温度为" + (curState[1] & 0xFF));
                                Log.i("djl", "空调抽湿,抽湿温度为" + (curState[1] & 0xFF));
                                break;
                            case AirCtrlParser.upTem:
                                airTempState = curState[1] & 0xFF;
                                airText.setText("空调调温,上升温度:" + (curState[1] & 0xFF));
                                ToastUtil("空调调温,上升温度:" + (curState[1] & 0xFF));
                                showToast("空调调温,上升温度:" + (curState[1] & 0xFF));
                                Log.i("djl", "空调调温,上升温度:" + (curState[1] & 0xFF));
                                break;
                            case AirCtrlParser.downTem:
                                airTempState = curState[1] & 0xFF;
                                airText.setText("空调调温,下降温度:" + (curState[1] & 0xFF));
                                ToastUtil("空调调温,下降温度:" + (curState[1] & 0xFF));
                                showToast("空调调温,下降温度:" + (curState[1] & 0xFF));
                                Log.i("djl", "空调调温,下降温度:" + (curState[1] & 0xFF));
                                break;
                        }
@@ -1107,276 +1120,276 @@
                case HDLApConfig.TYPE_SENSOR_DRY_CONTACT:
                    //传感器 干接点 。只有开关状态
                    if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) {
                        ToastUtil("获取传感器---干接点状态失败,请重新再试");
                        showToast("获取传感器---干接点状态失败,请重新再试");
                        return;
                    }
                    float dryContactValue = (float) event.getAppliancesInfo().getCurState();
                    String dryContactUnit = ((SensorStateBackInfo) event).getUnite();
                    ToastUtil("传感器---干接点状态:" + dryContactValue + dryContactUnit);
                    showToast("传感器---干接点状态:" + dryContactValue + dryContactUnit);
                    Log.i("djl", "传感器---干接点状态:" + dryContactValue + dryContactUnit);
                    break;
                case HDLApConfig.TYPE_SENSOR_MOVEMENT_DETECTOR:
                    //传感器 移动探测 。灵敏度
                    if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) {
                        ToastUtil("获取传感器---移动探测灵敏度状态失败,请重新再试");
                        showToast("获取传感器---移动探测灵敏度状态失败,请重新再试");
                        return;
                    }
                    float mdValue = (float) event.getAppliancesInfo().getCurState();
                    String mdValueUnit = ((SensorStateBackInfo) event).getUnite();
                    ToastUtil("传感器---移动探测灵敏度:" + mdValue + mdValueUnit);
                    showToast("传感器---移动探测灵敏度:" + mdValue + mdValueUnit);
                    Log.i("djl", "传感器---移动探测灵敏度:" + mdValue + mdValueUnit);
                    break;
                case HDLApConfig.TYPE_SENSOR_TEMP:
                    //传感器 温度
                    if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) {
                        ToastUtil("获取传感器---温度状态失败,请重新再试");
                        showToast("获取传感器---温度状态失败,请重新再试");
                        return;
                    }
                    float tempValue = (float) event.getAppliancesInfo().getCurState();
                    String tempValueUnit = ((SensorStateBackInfo) event).getUnite();
                    ToastUtil("传感器---温度:" + tempValue + tempValueUnit);
                    showToast("传感器---温度:" + tempValue + tempValueUnit);
                    Log.i("djl", "传感器---温度:" + tempValue + tempValueUnit);
                    break;
                case HDLApConfig.TYPE_SENSOR_HUMIDITY:
                    //传感器 湿度
                    if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) {
                        ToastUtil("获取传感器---湿度状态失败,请重新再试");
                        showToast("获取传感器---湿度状态失败,请重新再试");
                        return;
                    }
                    float humidityValue = (float) event.getAppliancesInfo().getCurState();
                    String humidityValueUnit = ((SensorStateBackInfo) event).getUnite();
                    ToastUtil("传感器---湿度:" + humidityValue + humidityValueUnit);
                    showToast("传感器---湿度:" + humidityValue + humidityValueUnit);
                    Log.i("djl", "传感器---湿度:" + humidityValue + humidityValueUnit);
                    break;
                case HDLApConfig.TYPE_SENSOR_ILLUMINACE:
                    //传感器 照度
                    if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) {
                        ToastUtil("获取传感器---照度状态失败,请重新再试");
                        showToast("获取传感器---照度状态失败,请重新再试");
                        return;
                    }
                    float illuminaceValue = (float) event.getAppliancesInfo().getCurState();
                    String illuminaceValueUnit = ((SensorStateBackInfo) event).getUnite();
                    ToastUtil("传感器---照度:" + illuminaceValue + illuminaceValueUnit);
                    showToast("传感器---照度:" + illuminaceValue + illuminaceValueUnit);
                    Log.i("djl", "传感器---照度:" + illuminaceValue + illuminaceValueUnit);
                    break;
                case HDLApConfig.TYPE_SENSOR_VOC:
                    //传感器 当前空气质量等级
                    if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) {
                        ToastUtil("获取传感器---当前空气质量等级状态失败,请重新再试");
                        showToast("获取传感器---当前空气质量等级状态失败,请重新再试");
                        return;
                    }
                    float vocValue = (float) event.getAppliancesInfo().getCurState();
                    String vocValueUnit = ((SensorStateBackInfo) event).getUnite();
                    ToastUtil("传感器---当前空气质量等级:" + vocValue + vocValueUnit);
                    showToast("传感器---当前空气质量等级:" + vocValue + vocValueUnit);
                    Log.i("djl", "传感器---当前空气质量等级:" + vocValue + vocValueUnit);
                    break;
                case HDLApConfig.TYPE_SENSOR_PM_2_POINT_5:
                    //传感器 pm2.5
                    if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) {
                        ToastUtil("获取传感器---pm2.5状态失败,请重新再试");
                        showToast("获取传感器---pm2.5状态失败,请重新再试");
                        return;
                    }
                    float pm2_5Value = (float) event.getAppliancesInfo().getCurState();
                    String pm2_5ValueUnit = ((SensorStateBackInfo) event).getUnite();
                    ToastUtil("传感器---pm2.5:" + pm2_5Value + pm2_5ValueUnit);
                    showToast("传感器---pm2.5:" + pm2_5Value + pm2_5ValueUnit);
                    Log.i("djl", "传感器---pm2.5:" + pm2_5Value + pm2_5ValueUnit);
                    break;
                case HDLApConfig.TYPE_SENSOR_C02:
                    //传感器 二氧化碳
                    if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) {
                        ToastUtil("获取传感器---二氧化碳状态失败,请重新再试");
                        showToast("获取传感器---二氧化碳状态失败,请重新再试");
                        return;
                    }
                    float co2Value = (float) event.getAppliancesInfo().getCurState();
                    String co2ValueUnit = ((SensorStateBackInfo) event).getUnite();
                    ToastUtil("传感器---二氧化碳:" + co2Value + co2ValueUnit);
                    showToast("传感器---二氧化碳:" + co2Value + co2ValueUnit);
                    Log.i("djl", "传感器---二氧化碳:" + co2Value + co2ValueUnit);
                    break;
                case HDLApConfig.TYPE_SENSOR_LPG:
                    //传感器 液化石油气
                    if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) {
                        ToastUtil("获取传感器---液化石油气状态失败,请重新再试");
                        showToast("获取传感器---液化石油气状态失败,请重新再试");
                        return;
                    }
                    float lpgValue = (float) event.getAppliancesInfo().getCurState();
                    String lpgValueUnit = ((SensorStateBackInfo) event).getUnite();
                    ToastUtil("传感器---液化石油气:" + lpgValue + lpgValueUnit);
                    showToast("传感器---液化石油气:" + lpgValue + lpgValueUnit);
                    Log.i("djl", "传感器---液化石油气:" + lpgValue + lpgValueUnit);
                    break;
                case HDLApConfig.TYPE_SENSOR_CO_H2:
                    //传感器 人工煤气
                    if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) {
                        ToastUtil("获取传感器---人工煤气状态失败,请重新再试");
                        showToast("获取传感器---人工煤气状态失败,请重新再试");
                        return;
                    }
                    float coh2Value = (float) event.getAppliancesInfo().getCurState();
                    String coh2ValueUnit = ((SensorStateBackInfo) event).getUnite();
                    ToastUtil("传感器---人工煤气:" + coh2Value + coh2ValueUnit);
                    showToast("传感器---人工煤气:" + coh2Value + coh2ValueUnit);
                    Log.i("djl", "传感器---人工煤气:" + coh2Value + coh2ValueUnit);
                    break;
                case HDLApConfig.TYPE_SENSOR_CH4:
                    //传感器 天然气
                    if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) {
                        ToastUtil("获取传感器---天然气状态失败,请重新再试");
                        showToast("获取传感器---天然气状态失败,请重新再试");
                        return;
                    }
                    float ch4Value = (float) event.getAppliancesInfo().getCurState();
                    String ch4ValueUnit = ((SensorStateBackInfo) event).getUnite();
                    ToastUtil("传感器---天然气:" + ch4Value + ch4ValueUnit);
                    showToast("传感器---天然气:" + ch4Value + ch4ValueUnit);
                    Log.i("djl", "传感器---天然气:" + ch4Value + ch4ValueUnit);
                    break;
                case HDLApConfig.TYPE_SENSOR_SMOG:
                    //传感器 烟雾
                    if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) {
                        ToastUtil("获取传感器---烟雾状态失败,请重新再试");
                        showToast("获取传感器---烟雾状态失败,请重新再试");
                        return;
                    }
                    float smogValue = (float) event.getAppliancesInfo().getCurState();
                    String smogValueUnit = ((SensorStateBackInfo) event).getUnite();
                    ToastUtil("传感器---烟雾:" + smogValue + smogValueUnit);
                    showToast("传感器---烟雾:" + smogValue + smogValueUnit);
                    Log.i("djl", "传感器---烟雾:" + smogValue + smogValueUnit);
                    break;
                case HDLApConfig.TYPE_SENSOR_WIND_SPEED:
                    //传感器 风速
                    if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) {
                        ToastUtil("获取传感器---风速状态失败,请重新再试");
                        showToast("获取传感器---风速状态失败,请重新再试");
                        return;
                    }
                    float windSpeedValue = (float) event.getAppliancesInfo().getCurState();
                    String windSpeedValueUnit = ((SensorStateBackInfo) event).getUnite();
                    ToastUtil("传感器---风速:" + windSpeedValue + windSpeedValueUnit);
                    showToast("传感器---风速:" + windSpeedValue + windSpeedValueUnit);
                    Log.i("djl", "传感器---风速:" + windSpeedValue + windSpeedValueUnit);
                    break;
                case HDLApConfig.TYPE_SENSOR_WIND_PRESSURE:
                    //传感器 风压
                    if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) {
                        ToastUtil("获取传感器---风压状态失败,请重新再试");
                        showToast("获取传感器---风压状态失败,请重新再试");
                        return;
                    }
                    float windPressureValue = (float) event.getAppliancesInfo().getCurState();
                    String windPressureValueUnit = ((SensorStateBackInfo) event).getUnite();
                    ToastUtil("传感器---风压:" + windPressureValue + windPressureValueUnit);
                    showToast("传感器---风压:" + windPressureValue + windPressureValueUnit);
                    Log.i("djl", "传感器---风压:" + windPressureValue + windPressureValueUnit);
                    break;
                case HDLApConfig.TYPE_SENSOR_LIQUID_FLOW:
                    //传感器 液体流量
                    if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) {
                        ToastUtil("获取传感器---液体流量状态失败,请重新再试");
                        showToast("获取传感器---液体流量状态失败,请重新再试");
                        return;
                    }
                    float liquidFlowValue = (float) event.getAppliancesInfo().getCurState();
                    String liquidFlowValueUnit = ((SensorStateBackInfo) event).getUnite();
                    ToastUtil("传感器---液体流量:" + liquidFlowValue + liquidFlowValueUnit);
                    showToast("传感器---液体流量:" + liquidFlowValue + liquidFlowValueUnit);
                    Log.i("djl", "传感器---液体流量:" + liquidFlowValue + liquidFlowValueUnit);
                    break;
                case HDLApConfig.TYPE_SENSOR_LIQUID_PRESSURE:
                    //传感器 液体压力
                    if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) {
                        ToastUtil("获取传感器---液体压力状态失败,请重新再试");
                        showToast("获取传感器---液体压力状态失败,请重新再试");
                        return;
                    }
                    float liquidPressureValue = (float) event.getAppliancesInfo().getCurState();
                    String liquidPressureValueUnit = ((SensorStateBackInfo) event).getUnite();
                    ToastUtil("传感器---液体压力:" + liquidPressureValue + liquidPressureValueUnit);
                    showToast("传感器---液体压力:" + liquidPressureValue + liquidPressureValueUnit);
                    Log.i("djl", "传感器---液体压力:" + liquidPressureValue + liquidPressureValueUnit);
                    break;
                case HDLApConfig.TYPE_SENSOR_LIQUID_DEPTH:
                    //传感器 液体深度
                    if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) {
                        ToastUtil("获取传感器---液体深度状态失败,请重新再试");
                        showToast("获取传感器---液体深度状态失败,请重新再试");
                        return;
                    }
                    float liquidDepthValue = (float) event.getAppliancesInfo().getCurState();
                    String liquidDepthValueUnit = ((SensorStateBackInfo) event).getUnite();
                    ToastUtil("传感器---液体深度:" + liquidDepthValue + liquidDepthValueUnit);
                    showToast("传感器---液体深度:" + liquidDepthValue + liquidDepthValueUnit);
                    Log.i("djl", "传感器---液体深度:" + liquidDepthValue + liquidDepthValueUnit);
                    break;
                case HDLApConfig.TYPE_SENSOR_RAIN_FALL:
                    //传感器 雨量
                    if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) {
                        ToastUtil("获取传感器---雨量状态失败,请重新再试");
                        showToast("获取传感器---雨量状态失败,请重新再试");
                        return;
                    }
                    float rainFallValue = (float) event.getAppliancesInfo().getCurState();
                    String rainFallValueUnit = ((SensorStateBackInfo) event).getUnite();
                    ToastUtil("传感器---雨量:" + rainFallValue + rainFallValueUnit);
                    showToast("传感器---雨量:" + rainFallValue + rainFallValueUnit);
                    Log.i("djl", "传感器---雨量:" + rainFallValue + rainFallValueUnit);
                    break;
                case HDLApConfig.TYPE_SENSOR_WEIGHT:
                    //传感器 重量
                    if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) {
                        ToastUtil("获取传感器---重量状态失败,请重新再试");
                        showToast("获取传感器---重量状态失败,请重新再试");
                        return;
                    }
                    float weightValue = (float) event.getAppliancesInfo().getCurState();
                    String weightValueUnit = ((SensorStateBackInfo) event).getUnite();
                    ToastUtil("传感器---重量:" + weightValue + weightValueUnit);
                    showToast("传感器---重量:" + weightValue + weightValueUnit);
                    Log.i("djl", "传感器---重量:" + weightValue + weightValueUnit);
                    break;
                case HDLApConfig.TYPE_SENSOR_HEIGHT_LENGTH:
                    //传感器 重量
                    if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) {
                        ToastUtil("获取传感器---重量状态失败,请重新再试");
                        showToast("获取传感器---重量状态失败,请重新再试");
                        return;
                    }
                    float height_lengthValue = (float) event.getAppliancesInfo().getCurState();
                    String height_lengthValueUnit = ((SensorStateBackInfo) event).getUnite();
                    ToastUtil("传感器---重量:" + height_lengthValue + height_lengthValueUnit);
                    showToast("传感器---重量:" + height_lengthValue + height_lengthValueUnit);
                    Log.i("djl", "传感器---重量:" + height_lengthValue + height_lengthValueUnit);
                    break;
                case HDLApConfig.TYPE_SENSOR_OBJECT_SPEED:
                    //传感器 物体速度
                    if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) {
                        ToastUtil("获取传感器---物体速度状态失败,请重新再试");
                        showToast("获取传感器---物体速度状态失败,请重新再试");
                        return;
                    }
                    float objectSpeedValue = (float) event.getAppliancesInfo().getCurState();
                    String objectSpeedUnite = ((SensorStateBackInfo) event).getUnite();//数值单位
                    ToastUtil("传感器---物体速度:" + objectSpeedValue + objectSpeedUnite);
                    showToast("传感器---物体速度:" + objectSpeedValue + objectSpeedUnite);
                    Log.i("djl", "传感器---物体速度:" + objectSpeedValue + objectSpeedUnite);
                    break;
                case HDLApConfig.TYPE_SENSOR_SHAKE:
                    //传感器 震动
                    if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) {
                        ToastUtil("获取传感器---震动状态失败,请重新再试");
                        showToast("获取传感器---震动状态失败,请重新再试");
                        return;
                    }
                    float shakeValue = (float) event.getAppliancesInfo().getCurState();
                    String shakeValueUnite = ((SensorStateBackInfo) event).getUnite();//数值单位
                    ToastUtil("传感器---震动:" + shakeValue + shakeValueUnite);
                    showToast("传感器---震动:" + shakeValue + shakeValueUnite);
                    Log.i("djl", "传感器---震动:" + shakeValue + shakeValueUnite);
                    break;
                case HDLApConfig.TYPE_SENSOR_VOLTAGE:
                    //传感器 电压
                    if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) {
                        ToastUtil("获取传感器---电压状态失败,请重新再试");
                        showToast("获取传感器---电压状态失败,请重新再试");
                        return;
                    }
                    float voltageValue = (float) event.getAppliancesInfo().getCurState();
                    String voltageValueUnite = ((SensorStateBackInfo) event).getUnite();//数值单位
                    ToastUtil("传感器---电压:" + voltageValue + voltageValueUnite);
                    showToast("传感器---电压:" + voltageValue + voltageValueUnite);
                    Log.i("djl", "传感器---电压:" + voltageValue + voltageValueUnite);
                    break;
                case HDLApConfig.TYPE_SENSOR_ELECTRICITY:
                    //传感器 电流
                    if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) {
                        ToastUtil("获取传感器---电流状态失败,请重新再试");
                        showToast("获取传感器---电流状态失败,请重新再试");
                        return;
                    }
                    float electricityValue = (float) event.getAppliancesInfo().getCurState();
                    String electricityValueUnite = ((SensorStateBackInfo) event).getUnite();//数值单位
                    ToastUtil("传感器---电流:" + electricityValue + electricityValueUnite);
                    showToast("传感器---电流:" + electricityValue + electricityValueUnite);
                    Log.i("djl", "传感器---电流:" + electricityValue + electricityValueUnite);
                    break;
                case HDLApConfig.TYPE_SENSOR_POWER:
                    //传感器 功率
                    if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) {
                        ToastUtil("获取传感器---功率状态失败,请重新再试");
                        showToast("获取传感器---功率状态失败,请重新再试");
                        return;
                    }
                    float powerValue = (float) event.getAppliancesInfo().getCurState();
                    String powerValueUnite = ((SensorStateBackInfo) event).getUnite();//数值单位
                    ToastUtil("传感器---功率:" + powerValue + powerValueUnite);
                    showToast("传感器---功率:" + powerValue + powerValueUnite);
                    Log.i("djl", "传感器---功率:" + powerValue + powerValueUnite);
                    break;
@@ -1386,8 +1399,8 @@
    }
    public void ToastUtil(String text) {
        Toast.makeText(CtrlActivity.this, text, Toast.LENGTH_SHORT).show();
    }
    public void showToast(String text) {
        Toast.makeText(this, text, Toast.LENGTH_SHORT).show();
    }
}