JLChen
2020-01-18 fd78a0c0e444b83f40a9225c98adceb87bbda329
hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLDeviceManager.java
@@ -485,6 +485,116 @@
        }
    }
    /**
     * 处理灯光返回
     * 2020-1-18
     * 修复混合调光混合开关 类模块问题
     * @param getDatas
     */
    private static void handleLightCtrlData(UdpDataBean getDatas){
        if (TextUtils.isEmpty(HandleSearch.rcuIp)) {
            outter:
            for (int i = 0, len = devicesDataList.size(); i < len; i++) {
                if (devicesDataList.get(i).getSourceSubnetID() == getDatas.sourceSubnetID
                        && devicesDataList.get(i).getSourceDeviceID() == getDatas.sourceDeviceID
                ) {
                    List<AppliancesInfo> infos = devicesDataList.get(i).getAppliancesInfoList();
                    for (int j = 0, len2 = infos.size(); j < len2; j++) {
                        if(infos.get(j).getLittleType() == 9 || infos.get(j).getLittleType() == 10 ){
                            if (infos.get(j).getPhysicsChannelNum() == (getDatas.addBytes[0] & 0xFF)) {
                                devicesDataList.get(i).getAppliancesInfoList().get(j).setCurState(getDatas.addBytes[2] & 0xFF);
                                devicesDataList.get(i).getAppliancesInfoList().get(j).setIntCurState(getDatas.addBytes[2] & 0xFF);
                                AppliancesInfo lightInfo1 = infos.get(j);
                                lightInfo1.setCurState(getDatas.addBytes[2] & 0xFF);
                                LightCtrlBackInfo info1 = new LightCtrlBackInfo();
                                info1.setParentRemarks(lightInfo1.getParentRemarks());
                                info1.setAppliancesInfo(lightInfo1);
                                info1.setRemarks(lightInfo1.getRemarks());
                                info1.setChannelNum(lightInfo1.getChannelNum());
                                info1.setPhysicsChannelNum(lightInfo1.getPhysicsChannelNum());
                                info1.setBrightness(getDatas.addBytes[2] & 0xFF);
                                setDeviceCtrlSuccessStateWithInfo(infos.get(j), true);
                                EventBus.getDefault().post(new LightFeedBackEvent(info1, true));
                                break outter;
                            }
                        }else {
                            if (infos.get(j).getChannelNum() == (getDatas.addBytes[0] & 0xFF)) {
                                AppliancesInfo lightInfo = infos.get(j);
                                devicesDataList.get(i).getAppliancesInfoList().get(j).setCurState(getDatas.addBytes[2] & 0xFF);
                                devicesDataList.get(i).getAppliancesInfoList().get(j).setIntCurState(getDatas.addBytes[2] & 0xFF);
                                LightCtrlBackInfo info = new LightCtrlBackInfo();
                                info.setParentRemarks(lightInfo.getParentRemarks());
                                info.setAppliancesInfo(lightInfo);
                                info.setRemarks(lightInfo.getRemarks());
                                info.setChannelNum(getDatas.addBytes[0] & 0xFF);
//                                  info.setIsSuccess(getDatas.AddBytes[1] & 0xFF);
                                info.setBrightness(getDatas.addBytes[2] & 0xFF);
//                                  info.setChannelCount(getDatas.AddBytes[3] & 0xFF);
//                                  info.setDeviceChannelCount(getDatas.AddBytes[4] & 0xFF);
//                                    isLightCtrlSuccess = true;
                                setDeviceCtrlSuccessStateWithInfo(infos.get(j), true);
                                EventBus.getDefault().post(new LightFeedBackEvent(info, true));
                                break outter;
                            }
                        }
                    }
                }
            }
        } else {
            if (getDatas.addBytes.length != 0) {
                outter:
                for (int i = 0, len = devicesDataList.size(); i < len; i++) {
                    if (devicesDataList.get(i).getSourceSubnetID() == getDatas.sourceSubnetID
                            && devicesDataList.get(i).getSourceDeviceID() == getDatas.sourceDeviceID
                    ) {
                        List<AppliancesInfo> infos = devicesDataList.get(i).getAppliancesInfoList();
                        for (int j = 0, len2 = infos.size(); j < len2; j++) {
                            if (infos.get(j).getPhysicsChannelNum() == (getDatas.addBytes[0] & 0xFF)
                            ) {
                                devicesDataList.get(i).getAppliancesInfoList().get(j).setCurState(getDatas.addBytes[2] & 0xFF);
                                devicesDataList.get(i).getAppliancesInfoList().get(j).setIntCurState(getDatas.addBytes[2] & 0xFF);
                                for (int k = 0; k < rcuLightList.size(); k++) {
                                    if (devicesDataList.get(i).getAppliancesInfoList().get(j).getPhysicsChannelNum() == rcuLightList.get(k).getPhysicsChanelNum()
                                    ) {
                                        rcuLightList.get(k).setCurState(getDatas.addBytes[2] & 0xFF);
                                        break;
                                    }
                                }
                                AppliancesInfo lightInfo1 = infos.get(j);
                                lightInfo1.setCurState(getDatas.addBytes[2] & 0xFF);
                                LightCtrlBackInfo info1 = new LightCtrlBackInfo();
                                info1.setParentRemarks(lightInfo1.getParentRemarks());
                                info1.setAppliancesInfo(lightInfo1);
                                info1.setRemarks(lightInfo1.getRemarks());
                                info1.setChannelNum(lightInfo1.getChannelNum());
//                    info1.setIsSuccess(getDatas.AddBytes[1] & 0xFF);
                                info1.setBrightness(getDatas.addBytes[2] & 0xFF);
                                info1.setChannelCount(getDatas.addBytes[3] & 0xFF);
                                info1.setDeviceChannelCount(getDatas.addBytes[4] & 0xFF);
//                                        isLightCtrlSuccess = true;
                                setDeviceCtrlSuccessStateWithInfo(infos.get(j), true);
                                EventBus.getDefault().post(new LightFeedBackEvent(info1, true));
                                break outter;
                            }
                        }
                    }
                }
            }
        }
    }
    /**
     * 处理设备控制数据
     *
@@ -493,79 +603,7 @@
    private static void handleCtrlData(UdpDataBean getDatas) {
        switch (getDatas.command) {
            case Configuration.LIGHT_CTRL_BACK_COMMAND:
                if (TextUtils.isEmpty(HandleSearch.rcuIp)) {
                    outter:
                    for (int i = 0, len = devicesDataList.size(); i < len; i++) {
                        if (devicesDataList.get(i).getSourceSubnetID() == getDatas.sourceSubnetID
                                && devicesDataList.get(i).getSourceDeviceID() == getDatas.sourceDeviceID
                        ) {
                            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)) {
                                    AppliancesInfo lightInfo = infos.get(j);
                                    devicesDataList.get(i).getAppliancesInfoList().get(j).setCurState(getDatas.addBytes[2] & 0xFF);
                                    devicesDataList.get(i).getAppliancesInfoList().get(j).setIntCurState(getDatas.addBytes[2] & 0xFF);
                                    LightCtrlBackInfo info = new LightCtrlBackInfo();
                                    info.setParentRemarks(lightInfo.getParentRemarks());
                                    info.setAppliancesInfo(lightInfo);
                                    info.setRemarks(lightInfo.getRemarks());
                                    info.setChannelNum(getDatas.addBytes[0] & 0xFF);
//                                  info.setIsSuccess(getDatas.AddBytes[1] & 0xFF);
                                    info.setBrightness(getDatas.addBytes[2] & 0xFF);
//                                  info.setChannelCount(getDatas.AddBytes[3] & 0xFF);
//                                  info.setDeviceChannelCount(getDatas.AddBytes[4] & 0xFF);
//                                    isLightCtrlSuccess = true;
                                    setDeviceCtrlSuccessStateWithInfo(infos.get(j), true);
                                    EventBus.getDefault().post(new LightFeedBackEvent(info, true));
                                    break outter;
                                }
                            }
                        }
                    }
                } else {
                    if (getDatas.addBytes.length != 0) {
                        outter:
                        for (int i = 0, len = devicesDataList.size(); i < len; i++) {
                            if (devicesDataList.get(i).getSourceSubnetID() == getDatas.sourceSubnetID
                                    && devicesDataList.get(i).getSourceDeviceID() == getDatas.sourceDeviceID
                            ) {
                                List<AppliancesInfo> infos = devicesDataList.get(i).getAppliancesInfoList();
                                for (int j = 0, len2 = infos.size(); j < len2; j++) {
                                    if (infos.get(j).getPhysicsChannelNum() == (getDatas.addBytes[0] & 0xFF)
                                    ) {
                                        devicesDataList.get(i).getAppliancesInfoList().get(j).setCurState(getDatas.addBytes[2] & 0xFF);
                                        devicesDataList.get(i).getAppliancesInfoList().get(j).setIntCurState(getDatas.addBytes[2] & 0xFF);
                                        for (int k = 0; k < rcuLightList.size(); k++) {
                                            if (devicesDataList.get(i).getAppliancesInfoList().get(j).getPhysicsChannelNum() == rcuLightList.get(k).getPhysicsChanelNum()
                                            ) {
                                                rcuLightList.get(k).setCurState(getDatas.addBytes[2] & 0xFF);
                                                break;
                                            }
                                        }
                                        AppliancesInfo lightInfo1 = infos.get(j);
                                        lightInfo1.setCurState(getDatas.addBytes[2] & 0xFF);
                                        LightCtrlBackInfo info1 = new LightCtrlBackInfo();
                                        info1.setParentRemarks(lightInfo1.getParentRemarks());
                                        info1.setAppliancesInfo(lightInfo1);
                                        info1.setRemarks(lightInfo1.getRemarks());
                                        info1.setChannelNum(lightInfo1.getChannelNum());
//                    info1.setIsSuccess(getDatas.AddBytes[1] & 0xFF);
                                        info1.setBrightness(getDatas.addBytes[2] & 0xFF);
                                        info1.setChannelCount(getDatas.addBytes[3] & 0xFF);
                                        info1.setDeviceChannelCount(getDatas.addBytes[4] & 0xFF);
//                                        isLightCtrlSuccess = true;
                                        setDeviceCtrlSuccessStateWithInfo(infos.get(j), true);
                                        EventBus.getDefault().post(new LightFeedBackEvent(info1, true));
                                        break outter;
                                    }
                                }
                            }
                        }
                    }
                }
                handleLightCtrlData(getDatas);
                break;
            case Configuration.CURTAIN_CTRL_BACK_COMMAND: