JLChen
2020-03-05 bdec7373b358239521703995c5220e995dee289c
app/src/main/java/com/hdl/sdk/hdl_sdk/activity/CtrlActivity.java
@@ -23,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;
@@ -126,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);
@@ -163,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:
@@ -197,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("未获取到窗帘模块状态");
                    }
@@ -410,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;
@@ -630,16 +632,16 @@
            @Override
            public void onClick(View view) {
                String tempStr = airTempEd.getText().toString();
                if (TextUtils.isEmpty(tempStr) || TextUtils.isEmpty(tempStr)) {
                if (TextUtils.isEmpty(tempStr)) {
                    showToast("设置的温度不能为空");
                    return;
                }
                int tempInt = Integer.parseInt(tempStr);
                if (tempInt < 16 || tempInt > 30) {
                    showToast("温度设置范围为:16~30摄氏度(℃)");
                    return;
                }
//                if (tempInt < 16 || tempInt > 30) {
//                    showToast("温度设置范围为:16~30摄氏度(℃)");
//                    return;
//                }
                switch (airModeState) {
                    case 0:
@@ -701,6 +703,9 @@
        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()) {
@@ -943,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()) {
                            showToast("获取灯光状态失败,请重新再试");
                            return;
                        }
                        lightBtn.setText("亮度 = " + event.getAppliancesInfo().getCurState());
                        lightBtn.setText("亮度 = " + HDLUtlis.getIntegerByObject(event.getAppliancesInfo().getCurStateObject()));
                    }
                    break;
                case HDLApConfig.TYPE_CURTAIN_GLYSTRO:
@@ -961,7 +966,7 @@
                        }
                        //窗帘模块: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:
@@ -1123,7 +1128,7 @@
                        showToast("获取传感器---干接点状态失败,请重新再试");
                        return;
                    }
                    float dryContactValue = (float) event.getAppliancesInfo().getCurState();
                    float dryContactValue = (float) event.getAppliancesInfo().getCurStateObject();
                    String dryContactUnit = ((SensorStateBackInfo) event).getUnite();
                    showToast("传感器---干接点状态:" + dryContactValue + dryContactUnit);
                    Log.i("djl", "传感器---干接点状态:" + dryContactValue + dryContactUnit);
@@ -1134,7 +1139,7 @@
                        showToast("获取传感器---移动探测灵敏度状态失败,请重新再试");
                        return;
                    }
                    float mdValue = (float) event.getAppliancesInfo().getCurState();
                    float mdValue = (float) event.getAppliancesInfo().getCurStateObject();
                    String mdValueUnit = ((SensorStateBackInfo) event).getUnite();
                    showToast("传感器---移动探测灵敏度:" + mdValue + mdValueUnit);
                    Log.i("djl", "传感器---移动探测灵敏度:" + mdValue + mdValueUnit);
@@ -1145,7 +1150,7 @@
                        showToast("获取传感器---温度状态失败,请重新再试");
                        return;
                    }
                    float tempValue = (float) event.getAppliancesInfo().getCurState();
                    float tempValue = (float) event.getAppliancesInfo().getCurStateObject();
                    String tempValueUnit = ((SensorStateBackInfo) event).getUnite();
                    showToast("传感器---温度:" + tempValue + tempValueUnit);
                    Log.i("djl", "传感器---温度:" + tempValue + tempValueUnit);
@@ -1156,7 +1161,7 @@
                        showToast("获取传感器---湿度状态失败,请重新再试");
                        return;
                    }
                    float humidityValue = (float) event.getAppliancesInfo().getCurState();
                    float humidityValue = (float) event.getAppliancesInfo().getCurStateObject();
                    String humidityValueUnit = ((SensorStateBackInfo) event).getUnite();
                    showToast("传感器---湿度:" + humidityValue + humidityValueUnit);
                    Log.i("djl", "传感器---湿度:" + humidityValue + humidityValueUnit);
@@ -1167,7 +1172,7 @@
                        showToast("获取传感器---照度状态失败,请重新再试");
                        return;
                    }
                    float illuminaceValue = (float) event.getAppliancesInfo().getCurState();
                    float illuminaceValue = (float) event.getAppliancesInfo().getCurStateObject();
                    String illuminaceValueUnit = ((SensorStateBackInfo) event).getUnite();
                    showToast("传感器---照度:" + illuminaceValue + illuminaceValueUnit);
                    Log.i("djl", "传感器---照度:" + illuminaceValue + illuminaceValueUnit);
@@ -1178,7 +1183,7 @@
                        showToast("获取传感器---当前空气质量等级状态失败,请重新再试");
                        return;
                    }
                    float vocValue = (float) event.getAppliancesInfo().getCurState();
                    float vocValue = (float) event.getAppliancesInfo().getCurStateObject();
                    String vocValueUnit = ((SensorStateBackInfo) event).getUnite();
                    showToast("传感器---当前空气质量等级:" + vocValue + vocValueUnit);
                    Log.i("djl", "传感器---当前空气质量等级:" + vocValue + vocValueUnit);
@@ -1189,7 +1194,7 @@
                        showToast("获取传感器---pm2.5状态失败,请重新再试");
                        return;
                    }
                    float pm2_5Value = (float) event.getAppliancesInfo().getCurState();
                    float pm2_5Value = (float) event.getAppliancesInfo().getCurStateObject();
                    String pm2_5ValueUnit = ((SensorStateBackInfo) event).getUnite();
                    showToast("传感器---pm2.5:" + pm2_5Value + pm2_5ValueUnit);
                    Log.i("djl", "传感器---pm2.5:" + pm2_5Value + pm2_5ValueUnit);
@@ -1200,7 +1205,7 @@
                        showToast("获取传感器---二氧化碳状态失败,请重新再试");
                        return;
                    }
                    float co2Value = (float) event.getAppliancesInfo().getCurState();
                    float co2Value = (float) event.getAppliancesInfo().getCurStateObject();
                    String co2ValueUnit = ((SensorStateBackInfo) event).getUnite();
                    showToast("传感器---二氧化碳:" + co2Value + co2ValueUnit);
                    Log.i("djl", "传感器---二氧化碳:" + co2Value + co2ValueUnit);
@@ -1211,7 +1216,7 @@
                        showToast("获取传感器---液化石油气状态失败,请重新再试");
                        return;
                    }
                    float lpgValue = (float) event.getAppliancesInfo().getCurState();
                    float lpgValue = (float) event.getAppliancesInfo().getCurStateObject();
                    String lpgValueUnit = ((SensorStateBackInfo) event).getUnite();
                    showToast("传感器---液化石油气:" + lpgValue + lpgValueUnit);
                    Log.i("djl", "传感器---液化石油气:" + lpgValue + lpgValueUnit);
@@ -1222,7 +1227,7 @@
                        showToast("获取传感器---人工煤气状态失败,请重新再试");
                        return;
                    }
                    float coh2Value = (float) event.getAppliancesInfo().getCurState();
                    float coh2Value = (float) event.getAppliancesInfo().getCurStateObject();
                    String coh2ValueUnit = ((SensorStateBackInfo) event).getUnite();
                    showToast("传感器---人工煤气:" + coh2Value + coh2ValueUnit);
                    Log.i("djl", "传感器---人工煤气:" + coh2Value + coh2ValueUnit);
@@ -1233,7 +1238,7 @@
                        showToast("获取传感器---天然气状态失败,请重新再试");
                        return;
                    }
                    float ch4Value = (float) event.getAppliancesInfo().getCurState();
                    float ch4Value = (float) event.getAppliancesInfo().getCurStateObject();
                    String ch4ValueUnit = ((SensorStateBackInfo) event).getUnite();
                    showToast("传感器---天然气:" + ch4Value + ch4ValueUnit);
                    Log.i("djl", "传感器---天然气:" + ch4Value + ch4ValueUnit);
@@ -1244,7 +1249,7 @@
                        showToast("获取传感器---烟雾状态失败,请重新再试");
                        return;
                    }
                    float smogValue = (float) event.getAppliancesInfo().getCurState();
                    float smogValue = (float) event.getAppliancesInfo().getCurStateObject();
                    String smogValueUnit = ((SensorStateBackInfo) event).getUnite();
                    showToast("传感器---烟雾:" + smogValue + smogValueUnit);
                    Log.i("djl", "传感器---烟雾:" + smogValue + smogValueUnit);
@@ -1255,7 +1260,7 @@
                        showToast("获取传感器---风速状态失败,请重新再试");
                        return;
                    }
                    float windSpeedValue = (float) event.getAppliancesInfo().getCurState();
                    float windSpeedValue = (float) event.getAppliancesInfo().getCurStateObject();
                    String windSpeedValueUnit = ((SensorStateBackInfo) event).getUnite();
                    showToast("传感器---风速:" + windSpeedValue + windSpeedValueUnit);
                    Log.i("djl", "传感器---风速:" + windSpeedValue + windSpeedValueUnit);
@@ -1266,7 +1271,7 @@
                        showToast("获取传感器---风压状态失败,请重新再试");
                        return;
                    }
                    float windPressureValue = (float) event.getAppliancesInfo().getCurState();
                    float windPressureValue = (float) event.getAppliancesInfo().getCurStateObject();
                    String windPressureValueUnit = ((SensorStateBackInfo) event).getUnite();
                    showToast("传感器---风压:" + windPressureValue + windPressureValueUnit);
                    Log.i("djl", "传感器---风压:" + windPressureValue + windPressureValueUnit);
@@ -1277,7 +1282,7 @@
                        showToast("获取传感器---液体流量状态失败,请重新再试");
                        return;
                    }
                    float liquidFlowValue = (float) event.getAppliancesInfo().getCurState();
                    float liquidFlowValue = (float) event.getAppliancesInfo().getCurStateObject();
                    String liquidFlowValueUnit = ((SensorStateBackInfo) event).getUnite();
                    showToast("传感器---液体流量:" + liquidFlowValue + liquidFlowValueUnit);
                    Log.i("djl", "传感器---液体流量:" + liquidFlowValue + liquidFlowValueUnit);
@@ -1288,7 +1293,7 @@
                        showToast("获取传感器---液体压力状态失败,请重新再试");
                        return;
                    }
                    float liquidPressureValue = (float) event.getAppliancesInfo().getCurState();
                    float liquidPressureValue = (float) event.getAppliancesInfo().getCurStateObject();
                    String liquidPressureValueUnit = ((SensorStateBackInfo) event).getUnite();
                    showToast("传感器---液体压力:" + liquidPressureValue + liquidPressureValueUnit);
                    Log.i("djl", "传感器---液体压力:" + liquidPressureValue + liquidPressureValueUnit);
@@ -1299,7 +1304,7 @@
                        showToast("获取传感器---液体深度状态失败,请重新再试");
                        return;
                    }
                    float liquidDepthValue = (float) event.getAppliancesInfo().getCurState();
                    float liquidDepthValue = (float) event.getAppliancesInfo().getCurStateObject();
                    String liquidDepthValueUnit = ((SensorStateBackInfo) event).getUnite();
                    showToast("传感器---液体深度:" + liquidDepthValue + liquidDepthValueUnit);
                    Log.i("djl", "传感器---液体深度:" + liquidDepthValue + liquidDepthValueUnit);
@@ -1310,7 +1315,7 @@
                        showToast("获取传感器---雨量状态失败,请重新再试");
                        return;
                    }
                    float rainFallValue = (float) event.getAppliancesInfo().getCurState();
                    float rainFallValue = (float) event.getAppliancesInfo().getCurStateObject();
                    String rainFallValueUnit = ((SensorStateBackInfo) event).getUnite();
                    showToast("传感器---雨量:" + rainFallValue + rainFallValueUnit);
                    Log.i("djl", "传感器---雨量:" + rainFallValue + rainFallValueUnit);
@@ -1321,7 +1326,7 @@
                        showToast("获取传感器---重量状态失败,请重新再试");
                        return;
                    }
                    float weightValue = (float) event.getAppliancesInfo().getCurState();
                    float weightValue = (float) event.getAppliancesInfo().getCurStateObject();
                    String weightValueUnit = ((SensorStateBackInfo) event).getUnite();
                    showToast("传感器---重量:" + weightValue + weightValueUnit);
                    Log.i("djl", "传感器---重量:" + weightValue + weightValueUnit);
@@ -1332,7 +1337,7 @@
                        showToast("获取传感器---重量状态失败,请重新再试");
                        return;
                    }
                    float height_lengthValue = (float) event.getAppliancesInfo().getCurState();
                    float height_lengthValue = (float) event.getAppliancesInfo().getCurStateObject();
                    String height_lengthValueUnit = ((SensorStateBackInfo) event).getUnite();
                    showToast("传感器---重量:" + height_lengthValue + height_lengthValueUnit);
                    Log.i("djl", "传感器---重量:" + height_lengthValue + height_lengthValueUnit);
@@ -1343,7 +1348,7 @@
                        showToast("获取传感器---物体速度状态失败,请重新再试");
                        return;
                    }
                    float objectSpeedValue = (float) event.getAppliancesInfo().getCurState();
                    float objectSpeedValue = (float) event.getAppliancesInfo().getCurStateObject();
                    String objectSpeedUnite = ((SensorStateBackInfo) event).getUnite();//数值单位
                    showToast("传感器---物体速度:" + objectSpeedValue + objectSpeedUnite);
                    Log.i("djl", "传感器---物体速度:" + objectSpeedValue + objectSpeedUnite);
@@ -1354,7 +1359,7 @@
                        showToast("获取传感器---震动状态失败,请重新再试");
                        return;
                    }
                    float shakeValue = (float) event.getAppliancesInfo().getCurState();
                    float shakeValue = (float) event.getAppliancesInfo().getCurStateObject();
                    String shakeValueUnite = ((SensorStateBackInfo) event).getUnite();//数值单位
                    showToast("传感器---震动:" + shakeValue + shakeValueUnite);
                    Log.i("djl", "传感器---震动:" + shakeValue + shakeValueUnite);
@@ -1365,7 +1370,7 @@
                        showToast("获取传感器---电压状态失败,请重新再试");
                        return;
                    }
                    float voltageValue = (float) event.getAppliancesInfo().getCurState();
                    float voltageValue = (float) event.getAppliancesInfo().getCurStateObject();
                    String voltageValueUnite = ((SensorStateBackInfo) event).getUnite();//数值单位
                    showToast("传感器---电压:" + voltageValue + voltageValueUnite);
                    Log.i("djl", "传感器---电压:" + voltageValue + voltageValueUnite);
@@ -1376,7 +1381,7 @@
                        showToast("获取传感器---电流状态失败,请重新再试");
                        return;
                    }
                    float electricityValue = (float) event.getAppliancesInfo().getCurState();
                    float electricityValue = (float) event.getAppliancesInfo().getCurStateObject();
                    String electricityValueUnite = ((SensorStateBackInfo) event).getUnite();//数值单位
                    showToast("传感器---电流:" + electricityValue + electricityValueUnite);
                    Log.i("djl", "传感器---电流:" + electricityValue + electricityValueUnite);
@@ -1387,7 +1392,7 @@
                        showToast("获取传感器---功率状态失败,请重新再试");
                        return;
                    }
                    float powerValue = (float) event.getAppliancesInfo().getCurState();
                    float powerValue = (float) event.getAppliancesInfo().getCurStateObject();
                    String powerValueUnite = ((SensorStateBackInfo) event).getUnite();//数值单位
                    showToast("传感器---功率:" + powerValue + powerValueUnite);
                    Log.i("djl", "传感器---功率:" + powerValue + powerValueUnite);