JLChen
2021-08-10 70658288824174b5ecd8a022ecfc053a19aa292d
2021-08-10 1.更新
5个文件已修改
309 ■■■■ 已修改文件
app/src/main/java/com/hdl/sdk/hdl_sdk/activity/AppliancesActivity.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/com/hdl/sdk/hdl_sdk/activity/CtrlAirActivity.java 148 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/res/layout/activity_ctrl_air.xml 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLAirCondition/Parser/AirCtrlParser.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLDeviceManager.java 128 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/com/hdl/sdk/hdl_sdk/activity/AppliancesActivity.java
@@ -80,12 +80,14 @@
                }
                else  if (appliancesInfos.get(position).getBigType() == Configuration.AIR_BIG_TYPE) {
                    //空调模块
                    if(appliancesInfos.get(position).getDeviceType() == HDLApConfig.TYPE_AC_HVAC){
                        intent.setClass(AppliancesActivity.this, CtrlAirHVACActivity.class);
                    }else {
                        intent.setClass(AppliancesActivity.this, CtrlAirActivity.class);
                    }
//                    //空调模块
//                    if(appliancesInfos.get(position).getDeviceType() == HDLApConfig.TYPE_AC_HVAC){
//                        intent.setClass(AppliancesActivity.this, CtrlAirHVACActivity.class);
//
//                    }else {
//                        intent.setClass(AppliancesActivity.this, CtrlAirActivity.class);
//                    }
                    intent.setClass(AppliancesActivity.this, CtrlAirActivity.class);
                }
                else {
app/src/main/java/com/hdl/sdk/hdl_sdk/activity/CtrlAirActivity.java
@@ -37,7 +37,7 @@
    private Button airBtnSwitch, airBtnMode, airBtnTemp, airBtnSpeed;
    private TextView airText;
    private TextView tv_switch, tv_mode, tv_speed, tv_tempet;
    private TextView tv_switch, tv_mode, tv_speed, tv_tempet, tv_indoorTempet;
    private EditText airTempEd;
    private AppliancesInfo appliancesInfo;
@@ -46,6 +46,7 @@
    private int airModeState;
    private int airTempState;
    private int airSpeedState;
    private int indoorTemp;
//    /**
//     * true为设置摄氏度 false为设置华氏度
//     * 参数范围 16~30摄氏度(℃)
@@ -105,7 +106,9 @@
    private void displayStateView(){
        switch (appliancesInfo.getDeviceType()) {
//            case HDLApConfig.TYPE_AC_HVAC:
            case HDLApConfig.TYPE_AC_HVAC:
                HDLCommand.getHVACDeviceStateFromNetwork(appliancesInfo);
                break;
            case HDLApConfig.TYPE_AC_PANEL:
                loadDeviceData();
                break;
@@ -128,6 +131,8 @@
        tv_mode = findViewById(R.id.tv_mode);
        tv_speed = findViewById(R.id.tv_speed);
        tv_tempet = findViewById(R.id.tv_tempet);
        tv_indoorTempet = findViewById(R.id.tv_indoorTempet);
    }
    private void initOnClick() {
@@ -420,7 +425,7 @@
        ) {
            //这个返回的信息是当前状态的
            switch (event.getAppliancesInfo().getDeviceType()) {
//                case HDLApConfig.TYPE_AC_HVAC:
                case HDLApConfig.TYPE_AC_HVAC:
                case HDLApConfig.TYPE_AC_PANEL:
                    if (appliancesInfo.getChannelNum() == event.getAppliancesInfo().getChannelNum()) {
                        if (!event.isSuccess()) {
@@ -429,132 +434,8 @@
                        }
                        byte[] curState = event.getAppliancesInfo().getArrCurState();
                        readAirState(curState);
//                        switch (curState[0] & 0xFF) {
//                            case AirCtrlParser.airSwich:
//                                switch (curState[1] & 0xFF) {
//                                    case AirCtrlParser.airOff:
//                                        airSwitchState = 0;
//                                        airText.setText("空调关");
//                                        showToast("空调关");
//                                        HDLLog.I("空调关");
//                                        break;
//                                    case AirCtrlParser.airOn:
//                                        airSwitchState = 1;
//                                        airText.setText("空调开");
//                                        showToast("空调开");
//                                        HDLLog.I("空调开");
//                                        break;
//                                    default:
//                                        break;
//                                }
//
//                                break;
//
//                            case AirCtrlParser.airSpeed:
//                                switch (curState[1] & 0xFF) {
//                                    case AirCtrlParser.airSpeedAuto:
//                                        airSpeedState = 0;
//                                        airText.setText("空调风速,风速模式为:airSpeedAuto自动风速");
//                                        showToast("空调风速,风速模式为:airSpeedAuto自动风速");
//                                        HDLLog.I("空调风速,风速模式为:airSpeedAuto自动风速");
//                                        break;
//                                    case AirCtrlParser.airSpeedHigh:
//                                        airSpeedState = 1;
//                                        airText.setText("空调风速,风速模式为:airSpeedHigh风速高");
//                                        showToast("空调风速,风速模式为:airSpeedHigh风速高");
//                                        HDLLog.I("空调风速,风速模式为:airSpeedHigh风速高");
//                                        break;
//                                    case AirCtrlParser.airSpeedMid:
//                                        airSpeedState = 2;
//                                        airText.setText("空调风速,风速模式为:airSpeedMid风速中");
//                                        showToast("空调风速,风速模式为:airSpeedMid风速中");
//                                        HDLLog.I("空调风速,风速模式为:airSpeedMid风速中");
//                                        break;
//                                    case AirCtrlParser.airSpeedLow:
//                                        airSpeedState = 3;
//                                        airText.setText("空调风速,风速模式为:airSpeedLow风速低");
//                                        showToast("空调风速,风速模式为:airSpeedLow风速低");
//                                        HDLLog.I("空调风速,风速模式为:airSpeedLow风速低");
//                                        break;
//                                    default:
//                                        break;
//                                }
//                                break;
//                            case AirCtrlParser.airMode:
//                                switch (curState[1] & 0xFF) {
//                                    case AirCtrlParser.airModeRefTem:
//                                        airModeState = 0;
//                                        airText.setText("空调模式,模式为:制冷");
//                                        showToast("空调模式,模式为:制冷");
//                                        HDLLog.I("空调模式,模式为:制冷");
//                                        break;
//                                    case AirCtrlParser.airModeHeatTem:
//                                        airModeState = 1;
//                                        airText.setText("空调模式,模式为:制热");
//                                        showToast("空调模式,模式为:制热");
//                                        HDLLog.I("空调模式,模式为:制热");
//                                        break;
//                                    case AirCtrlParser.airModeVen:
//                                        airModeState = 2;
//                                        airText.setText("空调模式,模式为:通风");
//                                        showToast("空调模式,模式为:通风");
//                                        HDLLog.I("空调模式,模式为:通风");
//                                        break;
//                                    case AirCtrlParser.airModeAuto:
//                                        airModeState = 3;
//                                        airText.setText("空调模式,模式为:自动");
//                                        showToast("空调模式,模式为:自动");
//                                        HDLLog.I("空调模式,模式为:自动");
//                                        break;
//                                    case AirCtrlParser.airModeDehum:
//                                        airModeState = 4;
//                                        airText.setText("空调模式,模式为:抽湿");
//                                        showToast("空调模式,模式为:抽湿");
//                                        HDLLog.I("空调模式,模式为:抽湿");
//                                        break;
//                                    default:
//                                        break;
//                                }
//                                break;
//                            case AirCtrlParser.refTem:
//                                airTempState = curState[1] & 0xFF;
//                                airText.setText("空调制冷,温度为:" + (curState[1] & 0xFF));
//                                showToast("空调制冷,温度为:" + (curState[1] & 0xFF));
//                                HDLLog.I("空调制冷,温度为:" + (curState[1] & 0xFF));
//                                break;
//                            case AirCtrlParser.heatTem:
//                                airTempState = curState[1] & 0xFF;
//                                airText.setText("空调制热,制热温度为" + (curState[1] & 0xFF));
//                                showToast("空调制热,制热温度为" + (curState[1] & 0xFF));
//                                HDLLog.I("空调制热,制热温度为" + (curState[1] & 0xFF));
//                                break;
//                            case AirCtrlParser.autoTem:
//                                airTempState = curState[1] & 0xFF;
//                                airText.setText("空调自动,自动温度为" + (curState[1] & 0xFF));
//                                showToast("空调自动,自动温度为" + (curState[1] & 0xFF));
//                                HDLLog.I("空调自动,自动温度为" + (curState[1] & 0xFF));
//                                break;
//                            case AirCtrlParser.dehumTem:
//                                airTempState = curState[1] & 0xFF;
//                                airText.setText("空调抽湿,抽湿温度为" + (curState[1] & 0xFF));
//                                showToast("空调抽湿,抽湿温度为" + (curState[1] & 0xFF));
//                                HDLLog.I("空调抽湿,抽湿温度为" + (curState[1] & 0xFF));
//                                break;
//                            case AirCtrlParser.upTem:
//                                airTempState = curState[1] & 0xFF;
//                                airText.setText("空调调温,上升温度:" + (curState[1] & 0xFF));
//                                showToast("空调调温,上升温度:" + (curState[1] & 0xFF));
//                                HDLLog.I("空调调温,上升温度:" + (curState[1] & 0xFF));
//                                break;
//                            case AirCtrlParser.downTem:
//                                airTempState = curState[1] & 0xFF;
//                                airText.setText("空调调温,下降温度:" + (curState[1] & 0xFF));
//                                showToast("空调调温,下降温度:" + (curState[1] & 0xFF));
//                                HDLLog.I("空调调温,下降温度:" + (curState[1] & 0xFF));
//                                break;
//                        }
                    }
                    break;
                default:
@@ -565,6 +446,8 @@
    }
    private void readAirState( byte[] curState ){
        HDLLog.I("readAirState 模式:"+ (curState[0] & 0xFF) + "状态:" +(curState[1] & 0xFF));
        String mes = "";
        switch (curState[0] & 0xFF) {
            case AirCtrlParser.airSwich:
@@ -722,7 +605,6 @@
            case AirCtrlParser.upTem:
                airTempState = curState[1] & 0xFF;
                tv_tempet.setText("" + airTempState);
                mes = "空调调温,上升温度:" + (airTempState);
                tv_mesSetText(mes);
@@ -735,7 +617,13 @@
                tv_mesSetText(mes);
                HDLLog.I(mes);
                break;
            case AirCtrlParser.airIndoorTemp:
                indoorTemp = curState[1] & 0xFF;
                tv_indoorTempet.setText("" + indoorTemp);
                mes = "当前室内温度:" + (indoorTemp);
                tv_mesSetText(mes);
                HDLLog.I(mes);
                break;
        }
    }
app/src/main/res/layout/activity_ctrl_air.xml
@@ -97,6 +97,23 @@
                    android:text="" />
            </LinearLayout>
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="40dp">
                <TextView
                    android:layout_width="80dp"
                    android:layout_height="match_parent"
                    android:gravity="center"
                    android:text="室内温度:" />
                <TextView
                    android:id="@+id/tv_indoorTempet"
                    android:layout_width="80dp"
                    android:layout_height="match_parent"
                    android:gravity="center"
                    android:text="" />
            </LinearLayout>
            <TextView
                android:id="@+id/airText"
                android:textSize="@dimen/ts_20"
hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLAirCondition/Parser/AirCtrlParser.java
@@ -41,6 +41,8 @@
    public static final int dehumTem = 19;//抽湿温度
    public static final int airIndoorTemp = 200;//室内温度 2021-08-10 自定义,用于通知当前设备室内温度
    public static byte[] getAirPanelAddByte(int type, int arg2) {
        byte[] addBytes;
hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLDeviceManager.java
@@ -3129,7 +3129,7 @@
    /**
     * 处理HVAC 控制回调
     * 2019-8-6
     * 2021-08-10
     *
     * @param getDatas
     */
@@ -3146,16 +3146,65 @@
                                && infos.get(j).getDeviceType() == HDLApConfig.TYPE_AC_HVAC
                                && infos.get(j).getChannelNum() == (getDatas.addBytes[0] & 0xFF)) {
//                            //
//                            devicesDataList.get(i).getAppliancesInfoList().get(j).setArrCurState(getDatas.addBytes);
//                            AppliancesInfo mHvacAirInfo = devicesDataList.get(i).getAppliancesInfoList().get(j);
//                            AirHVACBackInfo info = new AirHVACBackInfo(mHvacAirInfo);
//                            setDeviceCtrlSuccessStateWithInfo(infos.get(j), true);
//                            EventBus.getDefault().post(new AirHVACFeedBackEvent(info, true));
                            //2021-08-10 ,改回AirFeedBackEvent通知回调
                            setDeviceCtrlSuccessStateWithInfo(infos.get(j), true);
                            devicesDataList.get(i).getAppliancesInfoList().get(j).setArrCurState(getDatas.addBytes);
                            AppliancesInfo mHvacAirInfo = devicesDataList.get(i).getAppliancesInfoList().get(j);
                            AirHVACBackInfo info = new AirHVACBackInfo(mHvacAirInfo);
                            setDeviceCtrlSuccessStateWithInfo(infos.get(j), true);
                            EventBus.getDefault().post(new AirHVACFeedBackEvent(info, true));
                            if (getDatas.addBytes.length > 12) {
                                //解析最新的状态
                                byte indoorTemp = getDatas.addBytes[2];
                                byte refTemp = getDatas.addBytes[3];//制冷温度点 0-84
                                byte heatTemp = getDatas.addBytes[4];//制热温度点 0-84
                                byte autoTemp = getDatas.addBytes[5];//自动温度点 0-84
                                byte wettedTemp = getDatas.addBytes[6];//抽湿温度点 0-84
                                byte isOn = getDatas.addBytes[8];
                                byte airMode = getDatas.addBytes[9];
                                byte airSpeed = getDatas.addBytes[10];
                                //目前接收到数据 都通知一次最新的状态
                                //1.回调开关状态
                                sendAirFeedBackEvent(mHvacAirInfo,  new byte[]{AirCtrlParser.airSwich, isOn});
                                //2.回调 室内温度状态
                                sendAirFeedBackEvent(mHvacAirInfo,  new byte[]{(byte)AirCtrlParser.airIndoorTemp, indoorTemp});
                                //3.回调 空调模式
                                sendAirFeedBackEvent(mHvacAirInfo,  new byte[]{(byte)AirCtrlParser.airMode, airMode});
                                //4.回调 当前模式对应的温度,也可以改为通知所有模式的温度
                                byte[] curAirInfo = {0,0};
                                switch (airMode) {
                                    case 0:
                                        curAirInfo = new byte[]{AirCtrlParser.refTem, refTemp};
                                        break;
                                    case 1:
                                        curAirInfo = new byte[]{AirCtrlParser.heatTem, heatTemp};
                                        break;
                                    case 2:
                                        //通风模式没有温度
//                                    curAirInfo = new byte[]{AirCtrlParser.airTemp, newAirTem};
                                        break;
                                    case 3:
                                        curAirInfo = new byte[]{AirCtrlParser.autoTem, autoTemp};
                                        break;
                                    case 4:
                                        curAirInfo = new byte[]{AirCtrlParser.dehumTem, wettedTemp};
                                        break;
                                }
                                sendAirFeedBackEvent(mHvacAirInfo, curAirInfo);
                                //5.回调 空调风速
                                sendAirFeedBackEvent(mHvacAirInfo,  new byte[]{(byte)AirCtrlParser.airSpeed, airSpeed});
                            }
                            devicesDataList.get(i).getAppliancesInfoList().get(j).setArrCurState(getDatas.addBytes);
                            break outter;
                        }
//                                else {
//                                    HDLLog.E("控制HVAC状态反馈数据异常");
//                                }
                    }
                }
@@ -3164,9 +3213,20 @@
        }
    }
   /**
    * 2021-08-10
    * 发送通知 空调状态
    */
    private static void sendAirFeedBackEvent(AppliancesInfo mHvacAirInfo, byte[] curStateBytes){
        AirCtrlBackInfo backInfo1 = new AirCtrlBackInfo();
        backInfo1.setAppliancesInfo(mHvacAirInfo);
        backInfo1.setCurState(curStateBytes);
        EventBus.getDefault().post(new AirFeedBackEvent(backInfo1, true));
    }
    /**
     * 读取HVAC状态反馈
     *
     * 2021-08-10
     * 读取HVAC状态反馈也通过AirFeedBackEvent回调
     * @param getDatas
     */
    private static void handleHVACStateData(UdpDataBean getDatas) {
@@ -3181,9 +3241,57 @@
                            && infos.get(j).getDeviceType() == HDLApConfig.TYPE_AC_HVAC
                            && infos.get(j).getChannelNum() == (getDatas.addBytes[0] & 0xFF)) {//2019-8-6
//                        isGetDeviceStateSuccess = true;
//                        devicesDataList.get(i).getAppliancesInfoList().get(j).setArrCurState(getDatas.addBytes);
//                        EventBus.getDefault().post(new DeviceStateEvent(devicesDataList.get(i).getAppliancesInfoList().get(j), true));
                        //改回旧方案 所有状态分开通知
                        isGetDeviceStateSuccess = true;
                        devicesDataList.get(i).getAppliancesInfoList().get(j).setArrCurState(getDatas.addBytes);
                        EventBus.getDefault().post(new DeviceStateEvent(devicesDataList.get(i).getAppliancesInfoList().get(j), true));
                        AppliancesInfo mHvacAirInfo = devicesDataList.get(i).getAppliancesInfoList().get(j);
                        byte[] curAirInfo = new byte[]{0};
                        if (getDatas.addBytes.length > 12) {
                            //解析最新的状态
                            byte indoorTemp = getDatas.addBytes[2];
                            byte refTemp = getDatas.addBytes[3];//制冷温度点 0-84
                            byte heatTemp = getDatas.addBytes[4];//制热温度点 0-84
                            byte autoTemp = getDatas.addBytes[5];//自动温度点 0-84
                            byte wettedTemp = getDatas.addBytes[6];//抽湿温度点 0-84
                            byte isOn = getDatas.addBytes[8];
                            byte airMode = getDatas.addBytes[9];
                            byte airSpeed = getDatas.addBytes[10];
                            //1.回调开关状态
                            sendAirFeedBackEvent(mHvacAirInfo, new byte[]{AirCtrlParser.airSwich, isOn});
                            //2.回调 室内温度状态
                            sendAirFeedBackEvent(mHvacAirInfo, new byte[]{(byte) AirCtrlParser.airIndoorTemp, indoorTemp});
                            //3.回调 空调模式
                            sendAirFeedBackEvent(mHvacAirInfo, new byte[]{(byte) AirCtrlParser.airMode, airMode});
                            //4.回调 当前模式对应的温度
                            switch (airMode) {
                                case 0:
                                    curAirInfo = new byte[]{AirCtrlParser.refTem, refTemp};
                                    break;
                                case 1:
                                    curAirInfo = new byte[]{AirCtrlParser.heatTem, heatTemp};
                                    break;
                                case 2:
                                    //通风模式没有温度
//                                    curAirInfo = new byte[]{AirCtrlParser.airTemp, newAirTem};
                                    break;
                                case 3:
                                    curAirInfo = new byte[]{AirCtrlParser.autoTem, autoTemp};
                                    break;
                                case 4:
                                    curAirInfo = new byte[]{AirCtrlParser.dehumTem, wettedTemp};
                                    break;
                            }
                            sendAirFeedBackEvent(mHvacAirInfo, curAirInfo);
                            //5.回调 空调风速
                            sendAirFeedBackEvent(mHvacAirInfo, new byte[]{(byte) AirCtrlParser.airSpeed, airSpeed});
                        }
                        break outter;
                    } else {
                        HDLLog.info("handleHVACStateData 没有找到匹配类型");