| | |
| | | |
| | | import com.hdl.sdk.hdl_core.Config.Configuration; |
| | | import com.hdl.sdk.hdl_core.HDLAppliances.Config.HDLApConfig; |
| | | import com.hdl.sdk.hdl_core.HDLAppliances.HDLLogic.LogicMode; |
| | | import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.AppliancesInfo; |
| | | import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.DevicesData; |
| | | import com.hdl.sdk.hdl_core.HDLDeviceManger.Core.HDLDeviceManager; |
| | |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | import static com.hdl.sdk.hdl_core.HDLDeviceManger.Core.HDLDeviceManager.devicesDataList; |
| | | |
| | | /** |
| | | * Created by djl on 2017/3/29. |
| | |
| | | case Configuration.FRESH_AIR_LITTLE_TYPE_0: |
| | | isWant = true; |
| | | break; |
| | | default: |
| | | isWant = false; |
| | | break; |
| | | } |
| | | break; |
| | | case Configuration.COMMON_SWITCH_BIG_TYPE://2020-06-23 通用开关设备 |
| | | switch (littleType) { |
| | | case 0: |
| | | isWant = true; |
| | | break; |
| | | default: |
| | | isWant = false; |
| | | break; |
| | | } |
| | | break; |
| | | case Configuration.SECURITY_BIG_TYPE: |
| | | switch (littleType) { |
| | | case 0: |
| | | isWant = true; |
| | | break; |
| | | // case 2: |
| | | // isWant = true; |
| | | // break; |
| | | default: |
| | | isWant = false; |
| | | break; |
| | |
| | | |
| | | if (bWantData) { |
| | | devicesData.setAppliancesInfoList(appliancesInfoList); |
| | | HDLDeviceManager.devicesDataList.add(devicesData); |
| | | devicesDataList.add(devicesData); |
| | | |
| | | HandleSearch.OnDeviceListGetSuccessCallBack(); |
| | | }else { |
| | |
| | | case Configuration.FRESH_AIR_BIG_TYPE: |
| | | parseFreshAirData(littleType, appliancesInfo, devicesData, parentRemarks, curChannelNum, port, ""); |
| | | break; |
| | | case Configuration.COMMON_SWITCH_BIG_TYPE://2020-06-23 通用开关 |
| | | parseCommonSwitchData(littleType, appliancesInfo, devicesData, parentRemarks, curChannelNum, 0, ""); |
| | | break; |
| | | case Configuration.SECURITY_BIG_TYPE://2020-06-23 新增 |
| | | parseSecurityData(littleType, appliancesInfo, devicesData, parentRemarks, curChannelNum, 0, ""); |
| | | break; |
| | | default: |
| | | // appliancesInfo.setDeviceName(Configuration.UNKNOW_TYPE); |
| | | break; |
| | |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 2020-06-23 |
| | | * 新增通用开关 |
| | | * @param littleType |
| | | * @param appliancesInfo |
| | | * @param devicesData |
| | | * @param parentRemarks |
| | | * @param channelNum |
| | | * @param port |
| | | * @param ipAddress |
| | | */ |
| | | private static void parseCommonSwitchData(int littleType, AppliancesInfo appliancesInfo, DevicesData devicesData, String parentRemarks, int channelNum, int port, String ipAddress) { |
| | | switch (littleType) { |
| | | case 0: |
| | | appliancesInfo.setDeviceName("通用开关"); |
| | | appliancesInfo.setDeviceType(HDLApConfig.TYPE_COMMON_SWITCH); |
| | | break; |
| | | default: |
| | | appliancesInfo.setDeviceName(Configuration.UNKNOW_TYPE); |
| | | break; |
| | | |
| | | } |
| | | if (devicesData != null) { |
| | | appliancesInfo.setChannelNum(channelNum); |
| | | appliancesInfo.setBigType(Configuration.COMMON_SWITCH_BIG_TYPE); |
| | | appliancesInfo.setLittleType(littleType); |
| | | appliancesInfo.setDeviceSubnetID(devicesData.getSourceSubnetID()); |
| | | appliancesInfo.setDeviceDeviceID(devicesData.getSourceDeviceID()); |
| | | appliancesInfo.setParentRemarks(parentRemarks); |
| | | |
| | | appliancesInfo.setCtrlCommand(Configuration.COMMON_SWITCH_CTRL_COMMAND);// |
| | | appliancesInfo.setCtrlBackCommand(Configuration.COMMON_SWITCH_CTRL_BACK_COMMAND);// |
| | | appliancesInfo.setStateCommand(Configuration.COMMON_SWITCH_STATE_COMMAND);// |
| | | appliancesInfo.setStateBackCommand(Configuration.COMMON_SWITCH_STATE_BACK_COMMAND);// |
| | | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 2020-06-23 新增 |
| | | * |
| | | * @param littleType |
| | | * @param appliancesInfo |
| | | * @param devicesData |
| | | * @param parentRemarks |
| | | * @param channelNum |
| | | * @param port |
| | | * @param ipAddress |
| | | */ |
| | | private static void parseSecurityData(int littleType, AppliancesInfo appliancesInfo, DevicesData devicesData, String parentRemarks, int channelNum, int port, String ipAddress) { |
| | | switch (littleType) { |
| | | case 0: |
| | | appliancesInfo.setDeviceName("安防模块"); |
| | | appliancesInfo.setDeviceType(HDLApConfig.TYPE_SECURITY_MODULE); |
| | | break; |
| | | // case 2: |
| | | // appliancesInfo.setDeviceName("安防控制面板"); |
| | | // appliancesInfo.setDeviceType(HDLApConfig.SECURITY_CONTROL_PANEL); |
| | | // break; |
| | | default: |
| | | appliancesInfo.setDeviceName(Configuration.UNKNOW_TYPE); |
| | | break; |
| | | |
| | | } |
| | | if (devicesData != null) { |
| | | appliancesInfo.setChannelNum(channelNum); |
| | | appliancesInfo.setBigType(Configuration.SECURITY_BIG_TYPE); |
| | | appliancesInfo.setLittleType(littleType); |
| | | appliancesInfo.setDeviceSubnetID(devicesData.getSourceSubnetID()); |
| | | appliancesInfo.setDeviceDeviceID(devicesData.getSourceDeviceID()); |
| | | appliancesInfo.setParentRemarks(parentRemarks); |
| | | // appliancesInfo.setPort(port); |
| | | // appliancesInfo.setIpAddress(ipAddress); |
| | | appliancesInfo.setCtrlCommand(Configuration.SECURITY_ARMING_CTRL_COMMAND);//布防 |
| | | appliancesInfo.setCtrlBackCommand(Configuration.SECURITY_ARMING_CTRL_BACK_COMMAND);//布防设置反馈 |
| | | appliancesInfo.setStateCommand(Configuration.SECURITY_STATE_COMMAND);//读取安防设置 |
| | | appliancesInfo.setStateBackCommand(Configuration.SECURITY_STATE_BACK_COMMAND);//读取安防设置反馈 |
| | | |
| | | |
| | | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 添加设备回路 |
| | | * 如果存在相同子网号 设备号,则当成混合模块添加到该回路下,不存在则新添加模块 |
| | | * @param port 发送UDP包 端口号 |
| | | * @param bigType |
| | | * @param littleType |
| | | * @param mSubnetID |
| | | * @param mDeviceID |
| | | * @param mChannelNum |
| | | * @param mChannelRemark |
| | | * @param parentRemarks |
| | | * @param bSaveAndCallBack 是否马上保存本地并且推送DevicesInfoEvent 事件 |
| | | * @return |
| | | */ |
| | | public static DevicesData addDevicesListWithoutSearching(int port, int bigType, int littleType, int mSubnetID, int mDeviceID, int mChannelNum, String mChannelRemark, String parentRemarks, boolean bSaveAndCallBack) { |
| | | // boolean bWantData = false; |
| | | if (isWantData(bigType, littleType)) { |
| | | DevicesData devicesData = new DevicesData(); |
| | | devicesData.setSourceSubnetID(mSubnetID); |
| | | devicesData.setSourceDeviceID(mDeviceID); |
| | | devicesData.setRemark(parentRemarks); |
| | | |
| | | Boolean isFindDevicesData = false; |
| | | int index = 0; |
| | | for (int i = 0; i < devicesDataList.size(); i++) { |
| | | if (devicesDataList.get(i).getSourceSubnetID() == mSubnetID && devicesDataList.get(i).getSourceDeviceID() == mDeviceID) { |
| | | index = i; |
| | | isFindDevicesData = true; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | |
| | | if (isFindDevicesData) { |
| | | AppliancesInfo mAppliancesInfo = getDevicesInfo(devicesData, bigType, littleType, mChannelNum, port, parentRemarks, mChannelRemark); |
| | | devicesDataList.get(index).getAppliancesInfoList().add(mAppliancesInfo); |
| | | devicesData = devicesDataList.get(index); |
| | | if(bSaveAndCallBack){ |
| | | HandleSearch.OnDeviceListGetSuccessCallBack();} |
| | | } else { |
| | | List<AppliancesInfo> appliancesInfoList = new ArrayList<>(); |
| | | appliancesInfoList.add(getDevicesInfo(devicesData, bigType, littleType, mChannelNum, port, parentRemarks, mChannelRemark)); |
| | | devicesData.setAppliancesInfoList(appliancesInfoList); |
| | | devicesDataList.add(devicesData); |
| | | if(bSaveAndCallBack){ |
| | | HandleSearch.OnDeviceListGetSuccessCallBack();} |
| | | |
| | | } |
| | | |
| | | |
| | | return devicesData; |
| | | |
| | | } else { |
| | | return null; |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 添加场景设备回路 |
| | | * 如果存在相同子网号 设备号,则当成混合模块添加到该回路下,不存在则新添加模块 |
| | | * @param mSubnetID |
| | | * @param mDeviceID |
| | | * @param mAreaNum //场景 区域号 |
| | | * @param mAreaSceneNum //场景 当前区域场景号 |
| | | * @param mChannelRemark |
| | | * @param parentRemarks |
| | | * @param bSaveAndCallBack 是否马上保存本地并且推送DevicesInfoEvent 事件 |
| | | * @return |
| | | */ |
| | | public static DevicesData addScenesDevicesListWithoutSearching(int port, int mSubnetID, int mDeviceID, int mAreaNum, int mAreaSceneNum, String mChannelRemark, String parentRemarks, boolean bSaveAndCallBack) { |
| | | // boolean bWantData = false; |
| | | |
| | | int bigType = Configuration.GLOBAL_LOGIC_BIG_TYPE; |
| | | int littleType = 0; |
| | | if (isWantData(bigType, littleType)) { |
| | | DevicesData devicesData = new DevicesData(); |
| | | devicesData.setSourceSubnetID(mSubnetID); |
| | | devicesData.setSourceDeviceID(mDeviceID); |
| | | devicesData.setRemark(parentRemarks); |
| | | |
| | | Boolean isFindDevicesData = false; |
| | | int index = 0; |
| | | for (int i = 0; i < devicesDataList.size(); i++) { |
| | | if (devicesDataList.get(i).getSourceSubnetID() == mSubnetID && devicesDataList.get(i).getSourceDeviceID() == mDeviceID) { |
| | | index = i; |
| | | isFindDevicesData = true; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | |
| | | if (isFindDevicesData) { |
| | | AppliancesInfo mAppliancesInfo = getDevicesInfo(devicesData, bigType, littleType, mAreaNum, port, parentRemarks, mChannelRemark); |
| | | LogicMode mLogicMode = new LogicMode(); |
| | | mLogicMode.setAreaNum(mAreaNum); |
| | | mLogicMode.setAreaSceneNum(mAreaSceneNum); |
| | | mAppliancesInfo.setLogicMode(mLogicMode); |
| | | devicesDataList.get(index).getAppliancesInfoList().add(mAppliancesInfo); |
| | | devicesData = devicesDataList.get(index); |
| | | if(bSaveAndCallBack){ |
| | | HandleSearch.OnDeviceListGetSuccessCallBack();} |
| | | } else { |
| | | List<AppliancesInfo> appliancesInfoList = new ArrayList<>(); |
| | | AppliancesInfo mAppliancesInfo = getDevicesInfo(devicesData, bigType, littleType, mAreaNum, port, parentRemarks, mChannelRemark); |
| | | LogicMode mLogicMode = new LogicMode(); |
| | | mLogicMode.setAreaNum(mAreaNum); |
| | | mLogicMode.setAreaSceneNum(mAreaSceneNum); |
| | | mAppliancesInfo.setLogicMode(mLogicMode); |
| | | appliancesInfoList.add(mAppliancesInfo); |
| | | devicesData.setAppliancesInfoList(appliancesInfoList); |
| | | devicesDataList.add(devicesData); |
| | | if(bSaveAndCallBack){ |
| | | HandleSearch.OnDeviceListGetSuccessCallBack();} |
| | | } |
| | | |
| | | |
| | | return devicesData; |
| | | |
| | | } else { |
| | | return null; |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | } |