JLChen
2019-08-02 425b2352c57a377b1594097a69aabcc87207b683
hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLDeviceManager.java
@@ -90,7 +90,6 @@
    public static boolean isGeothermalCtrlSuccess = false; //判断地热模块是否控制成功
    /**
     * 初始化SDK
     *
@@ -1009,7 +1008,9 @@
                    ) {
                        List<AppliancesInfo> infos = devicesDataList.get(i).getAppliancesInfoList();
                        for (int j = 0, len2 = infos.size(); j < len2; j++) {
                            if (infos.get(j).getChannelNum() == (getDatas.addBytes[0] & 0xFF)) {
                            if (infos.get(j).getBigType() == Configuration.FRESH_AIR_BIG_TYPE
                                    && infos.get(j).getDeviceType() == HDLApConfig.TYPE_FRESH_AIR
                                    && infos.get(j).getChannelNum() == (getDatas.addBytes[0] & 0xFF)) {
                                devicesDataList.get(i).getAppliancesInfoList().get(j).setFeedbackState(getDatas.addBytes);
                                AppliancesInfo mFreshAirInfo = devicesDataList.get(i).getAppliancesInfoList().get(j);
@@ -1029,12 +1030,13 @@
    /**
     * 处理地热设备控制数据
     *  20190710
     * 20190710
     *
     * @param getDatas
     */
    private static void handleGeothermalCtrlData(UdpDataBean getDatas) {
        switch (getDatas.command) {
                //2019-07-09 地热模块
            //2019-07-09 地热模块
            case Configuration.GEOTHERMAL_MODULE_CTRL_BACK_COMMAND:
                outter:
                for (int i = 0, len = devicesDataList.size(); i < len; i++) {
@@ -1044,8 +1046,10 @@
                        List<AppliancesInfo> infos = devicesDataList.get(i).getAppliancesInfoList();
                        for (int j = 0, len2 = infos.size(); j < len2; j++) {
                            if(getDatas.addBytes.length > 0) {
                                if (infos.get(j).getChannelNum() == (getDatas.addBytes[0] & 0xFF)) {
                            if (getDatas.addBytes.length > 0) {
                                if (infos.get(j).getBigType() == Configuration.GEOTHERMAL_BIG_TYPE
                                        && infos.get(j).getDeviceType() == HDLApConfig.TYPE_GEOTHERMAL_MODULE
                                        && infos.get(j).getChannelNum() == (getDatas.addBytes[0] & 0xFF)) {
                                    if (getDatas.addBytes.length >= 8) {
                                        byte[] getBytes = devicesDataList.get(i).getAppliancesInfoList().get(j).getFeedbackState();
                                        if (getBytes == null || getBytes.length < 10) {
@@ -1942,7 +1946,7 @@
            ) {
                List<AppliancesInfo> infos = devicesDataList.get(i).getAppliancesInfoList();
                for (int j = 0, len2 = infos.size(); j < len2; j++) {
                    HDLLog.info("HDL big::"+devicesDataList.get(i).getAppliancesInfoList().get(j).getBigType());
                    HDLLog.info("HDL big::" + devicesDataList.get(i).getAppliancesInfoList().get(j).getBigType());
                    switch (devicesDataList.get(i).getAppliancesInfoList().get(j).getBigType()) {
                        case Configuration.LIGTH_BIG_TYPE:
                            isGetDeviceStateSuccess = true;
@@ -2194,7 +2198,7 @@
                            HDLLog.info("handle state 没有找到匹配类型");
                            break;
                    }
//                    break outter;
                }
                break outter;
            }
@@ -2204,6 +2208,7 @@
    /**
     * 处理新风设备状态数据
     * 20190710新增
     *
     * @param getDatas
     */
    private static void handleFreshAirStateData(UdpDataBean getDatas) {
@@ -2214,18 +2219,17 @@
            ) {
                List<AppliancesInfo> infos = devicesDataList.get(i).getAppliancesInfoList();
                for (int j = 0, len2 = infos.size(); j < len2; j++) {
                    switch (devicesDataList.get(i).getAppliancesInfoList().get(j).getDeviceType()) {
                        case HDLApConfig.TYPE_FRESH_AIR:
                            isGetDeviceStateSuccess = true;
                            devicesDataList.get(i).getAppliancesInfoList().get(j).setFeedbackState(getDatas.addBytes);
                            EventBus.getDefault().post(new DeviceStateEvent(devicesDataList.get(i).getAppliancesInfoList().get(j), true));
                    if (infos.get(j).getBigType() == Configuration.FRESH_AIR_BIG_TYPE
                            && infos.get(j).getDeviceType() == HDLApConfig.TYPE_FRESH_AIR
                            && infos.get(j).getChannelNum() == (getDatas.addBytes[0] & 0xFF)) {//2019-07-17
                            break;
                        default:
                            HDLLog.info("handleFreshAirStateData 没有找到匹配类型");
                            break;
                        isGetDeviceStateSuccess = true;
                        devicesDataList.get(i).getAppliancesInfoList().get(j).setFeedbackState(getDatas.addBytes);
                        EventBus.getDefault().post(new DeviceStateEvent(devicesDataList.get(i).getAppliancesInfoList().get(j), true));
                        break outter;
                    }else {
                        HDLLog.info("handleFreshAirStateData 没有找到匹配类型");
                    }
                }
                break outter;
            }
@@ -2236,6 +2240,7 @@
    /**
     * 处理地热设备状态数据
     * 20190710新增
     *
     * @param getDatas
     */
    private static void handleGeothermalStateData(UdpDataBean getDatas) {
@@ -2246,34 +2251,34 @@
            ) {
                List<AppliancesInfo> infos = devicesDataList.get(i).getAppliancesInfoList();
                for (int j = 0, len2 = infos.size(); j < len2; j++) {
                    switch (devicesDataList.get(i).getAppliancesInfoList().get(j).getDeviceType()) {
                        case HDLApConfig.TYPE_GEOTHERMAL_MODULE:
                            if(getDatas.addBytes.length >= 10) {
                                byte[] getBytes = devicesDataList.get(i).getAppliancesInfoList().get(j).getFeedbackState();
                                if (getBytes == null || getBytes.length < 10) {
                                    getBytes = new byte[10];
                                }
                                System.arraycopy(getDatas.addBytes, 0, getBytes, 0, 10);//20190710查询地热状态反馈,只取前10位数据
                                devicesDataList.get(i).getAppliancesInfoList().get(j).setFeedbackState(getBytes);
                                isGetDeviceStateSuccess = true;
                                EventBus.getDefault().post(new DeviceStateEvent(devicesDataList.get(i).getAppliancesInfoList().get(j), true));
                            }else {
                                HDLLog.E("地热状态反馈数据异常");
                    if (infos.get(j).getBigType() == Configuration.GEOTHERMAL_BIG_TYPE
                            && infos.get(j).getDeviceType() == HDLApConfig.TYPE_GEOTHERMAL_MODULE
                            && infos.get(j).getChannelNum() == (getDatas.addBytes[0] & 0xFF)) {//2019-07-17
                        if (getDatas.addBytes.length >= 10) {
                            byte[] getBytes = devicesDataList.get(i).getAppliancesInfoList().get(j).getFeedbackState();
                            if (getBytes == null || getBytes.length < 10) {
                                getBytes = new byte[10];
                            }
                            System.arraycopy(getDatas.addBytes, 0, getBytes, 0, 10);//20190710查询地热状态反馈,只取前10位数据
                            devicesDataList.get(i).getAppliancesInfoList().get(j).setFeedbackState(getBytes);
                            isGetDeviceStateSuccess = true;
                            EventBus.getDefault().post(new DeviceStateEvent(devicesDataList.get(i).getAppliancesInfoList().get(j), true));
                        } else {
                            HDLLog.E("地热状态反馈数据异常");
                        }
                            break;
                        default:
                            HDLLog.info("handleGeothermalStateData 没有找到匹配类型");
                            break;
                        break outter;
                    }else {
                        HDLLog.info("handleFreshAirStateData 没有找到匹配类型");
                    }
                }
                break outter;
            }
        }
    }
    /**
     * 此方法基本没用到,逻辑模块的控制信息已经在handleCtrlData中处理过了
     * <p>