JLChen
2020-03-16 7a951ecdc084ea8643e29e1ade59c1877fd7fbe5
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;
@@ -22,6 +23,7 @@
import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.DeviceStateEvent;
import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.LightFeedBackEvent;
import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.LogicFeedBackEvent;
import com.hdl.sdk.hdl_core.Util.TransformUtil.HDLUtlis;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
@@ -62,7 +64,7 @@
        initView();
        initClickOnEvent();
        HDLCommand.getDeviceState(appliancesInfo);
    }
@@ -125,8 +127,9 @@
                sensorText.setVisibility(View.GONE);
                if (appliancesInfo.getCurState() != null) {
                    int curLightState = (int) appliancesInfo.getCurState();
                if (appliancesInfo.getCurStateObject() != null) {
                    int curLightState = HDLUtlis.getIntegerByObject(appliancesInfo.getCurStateObject());
                    lightText.setText("当前灯光亮度:" + curLightState);
                    lightBtn.setText("当前灯光亮度:" + curLightState);
@@ -162,9 +165,9 @@
                    curtainBtn4.setVisibility(View.GONE);
                    curtainBtn5.setVisibility(View.GONE);
                    if (appliancesInfo.getCurState() != null) {
                    if (appliancesInfo.getCurStateObject() != null) {
                        String stringCurtainState = "";
                        int curCurtainState = (int) appliancesInfo.getCurState();
                        int curCurtainState = HDLUtlis.getIntegerByObject(appliancesInfo.getCurStateObject());
                        Log.i("djl", "curCurtainState = " + curCurtainState);
                        switch (curCurtainState) {
                            case CurtainCtrlParser.TYPE_STATE_PAUSE:
@@ -196,8 +199,8 @@
                    curText1.setVisibility(View.GONE);
                    curtainBtn.setVisibility(View.GONE);
                    if (appliancesInfo.getCurState() != null) {
                        curText2.setText("当前窗帘状态:" + appliancesInfo.getCurState());
                    if (appliancesInfo.getCurStateObject() != null) {
                        curText2.setText("当前窗帘状态:" + HDLUtlis.getIntegerByObject(appliancesInfo.getCurStateObject()));
                    } else {
                        curText2.setText("未获取到窗帘模块状态");
                    }
@@ -409,8 +412,8 @@
                lightText.setVisibility(View.GONE);
                logicBtn.setVisibility(View.GONE);
                logicText.setVisibility(View.GONE);
                if (appliancesInfo.getCurState() != null) {
                    float value = (float) appliancesInfo.getCurState();
                if (appliancesInfo.getCurStateObject() != null) {
                    float value = (float) appliancesInfo.getCurStateObject();
                    sensorBtn.setText("传感器数值:" + value);
                }
                break;
@@ -628,26 +631,38 @@
        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, 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;
@@ -688,10 +703,13 @@
        if (event.getLightCtrlBackInfo().getAppliancesInfo().getDeviceDeviceID() == appliancesInfo.getDeviceDeviceID()
                && event.getLightCtrlBackInfo().getAppliancesInfo().getDeviceSubnetID() == appliancesInfo.getDeviceSubnetID()
                && event.getLightCtrlBackInfo().getChannelNum() == appliancesInfo.getChannelNum()
                && event.getLightCtrlBackInfo().getPhysicsChannelNum() == appliancesInfo.getPhysicsChannelNum()
                && event.getLightCtrlBackInfo().getAppliancesInfo().getDeviceType() == appliancesInfo.getDeviceType()
                ) {
            //        先判断是否超时
            if (!event.isSuccess()) {
                ToastUtil("灯光控制超时,请重新再试");
                showToast("灯光控制超时,请重新再试");
                lightBtn.setText("灯光控制超时,请重新再试");
                return;
            }
@@ -704,7 +722,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 +736,7 @@
                ) {
            if (!event.isSuccess()) {
                ToastUtil("窗帘控制超时,请重新再试");
                showToast("窗帘控制超时,请重新再试");
                return;
            }
@@ -730,7 +748,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 +787,7 @@
                ) {
            //        先判断是否超时
            if (!event.isSuccess()) {
                ToastUtil("空调控制超时,请重新再试");
                showToast("空调控制超时,请重新再试");
                return;
            }
@@ -780,13 +798,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 +818,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 +848,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 +883,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 +929,10 @@
                && event.getLogicCtrlBackInfo().getAppliancesInfo().getChannelNum() == appliancesInfo.getChannelNum()
                ) {
            if (!event.isSuccess()) {
                ToastUtil("场景控制超时,请重新再试");
                showToast("场景控制超时,请重新再试");
                return;
            }
            ToastUtil("场景控制成功");
            showToast("场景控制成功");
        }
    }
@@ -930,12 +948,12 @@
                case HDLApConfig.TYPE_LIGHT_RELAY:
                case HDLApConfig.TYPE_LIGHT_MIX_DIMMER:
                case HDLApConfig.TYPE_LIGHT_MIX_RELAY:
                    if (appliancesInfo.getChannelNum() == event.getAppliancesInfo().getChannelNum()) {
                    if (appliancesInfo.getChannelNum() == event.getAppliancesInfo().getChannelNum() && appliancesInfo.getPhysicsChannelNum() == event.getAppliancesInfo().getPhysicsChannelNum()) {
                        if (!event.isSuccess()) {
                            ToastUtil("获取灯光状态失败,请重新再试");
                            showToast("获取灯光状态失败,请重新再试");
                            return;
                        }
                        lightBtn.setText("亮度 = " + event.getAppliancesInfo().getCurState());
                        lightBtn.setText("亮度 = " + HDLUtlis.getIntegerByObject(event.getAppliancesInfo().getCurStateObject()));
                    }
                    break;
                case HDLApConfig.TYPE_CURTAIN_GLYSTRO:
@@ -943,12 +961,12 @@
                case HDLApConfig.TYPE_CURTAIN_MODULE:
                    if (appliancesInfo.getChannelNum() == event.getAppliancesInfo().getChannelNum()) {
                        if (!event.isSuccess()) {
                            ToastUtil("获取窗帘状态失败,请重新再试");
                            showToast("获取窗帘状态失败,请重新再试");
                            return;
                        }
                        //窗帘模块:curState:0=停止,1=打开,2=关闭。
                        //开合帘电机,卷帘电机:curState:1-100开合度。
                        int curState = (int) event.getAppliancesInfo().getCurState();
                        int curState = HDLUtlis.getIntegerByObject(event.getAppliancesInfo().getCurStateObject());
                        if (event.getAppliancesInfo().getDeviceType() == HDLApConfig.TYPE_CURTAIN_MODULE) {//判断是否为窗帘模块,否则为开合帘或卷帘电机
                            switch (curState) {
                                case CurtainCtrlParser.curtainOff:
@@ -973,7 +991,7 @@
                case HDLApConfig.TYPE_AC_PANEL:
                    if (appliancesInfo.getChannelNum() == event.getAppliancesInfo().getChannelNum()) {
                        if (!event.isSuccess()) {
                            ToastUtil("获取空调状态失败,请重新再试");
                            showToast("获取空调状态失败,请重新再试");
                            return;
                        }
@@ -984,13 +1002,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 +1022,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 +1052,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 +1086,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 +1125,276 @@
                case HDLApConfig.TYPE_SENSOR_DRY_CONTACT:
                    //传感器 干接点 。只有开关状态
                    if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) {
                        ToastUtil("获取传感器---干接点状态失败,请重新再试");
                        showToast("获取传感器---干接点状态失败,请重新再试");
                        return;
                    }
                    float dryContactValue = (float) event.getAppliancesInfo().getCurState();
                    float dryContactValue = (float) event.getAppliancesInfo().getCurStateObject();
                    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();
                    float mdValue = (float) event.getAppliancesInfo().getCurStateObject();
                    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();
                    float tempValue = (float) event.getAppliancesInfo().getCurStateObject();
                    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();
                    float humidityValue = (float) event.getAppliancesInfo().getCurStateObject();
                    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();
                    float illuminaceValue = (float) event.getAppliancesInfo().getCurStateObject();
                    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();
                    float vocValue = (float) event.getAppliancesInfo().getCurStateObject();
                    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();
                    float pm2_5Value = (float) event.getAppliancesInfo().getCurStateObject();
                    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();
                    float co2Value = (float) event.getAppliancesInfo().getCurStateObject();
                    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();
                    float lpgValue = (float) event.getAppliancesInfo().getCurStateObject();
                    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();
                    float coh2Value = (float) event.getAppliancesInfo().getCurStateObject();
                    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();
                    float ch4Value = (float) event.getAppliancesInfo().getCurStateObject();
                    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();
                    float smogValue = (float) event.getAppliancesInfo().getCurStateObject();
                    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();
                    float windSpeedValue = (float) event.getAppliancesInfo().getCurStateObject();
                    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();
                    float windPressureValue = (float) event.getAppliancesInfo().getCurStateObject();
                    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();
                    float liquidFlowValue = (float) event.getAppliancesInfo().getCurStateObject();
                    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();
                    float liquidPressureValue = (float) event.getAppliancesInfo().getCurStateObject();
                    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();
                    float liquidDepthValue = (float) event.getAppliancesInfo().getCurStateObject();
                    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();
                    float rainFallValue = (float) event.getAppliancesInfo().getCurStateObject();
                    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();
                    float weightValue = (float) event.getAppliancesInfo().getCurStateObject();
                    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();
                    float height_lengthValue = (float) event.getAppliancesInfo().getCurStateObject();
                    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();
                    float objectSpeedValue = (float) event.getAppliancesInfo().getCurStateObject();
                    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();
                    float shakeValue = (float) event.getAppliancesInfo().getCurStateObject();
                    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();
                    float voltageValue = (float) event.getAppliancesInfo().getCurStateObject();
                    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();
                    float electricityValue = (float) event.getAppliancesInfo().getCurStateObject();
                    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();
                    float powerValue = (float) event.getAppliancesInfo().getCurStateObject();
                    String powerValueUnite = ((SensorStateBackInfo) event).getUnite();//数值单位
                    ToastUtil("传感器---功率:" + powerValue + powerValueUnite);
                    showToast("传感器---功率:" + powerValue + powerValueUnite);
                    Log.i("djl", "传感器---功率:" + powerValue + powerValueUnite);
                    break;
@@ -1386,8 +1404,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();
    }
}