| | |
| | | |
| | | |
| | | public class HandleSearch { |
| | | public static boolean isSearching = true; |
| | | public static boolean isSearching = false; |
| | | public static int curSearchMode = 0; |
| | | public static String rcuIp = "";//主动传入的rcu ip地址 |
| | | // private static Timer getRcuIpTimer = null;//获取Rcuip Timer |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 返回设备列表 |
| | | * 2019-10-14 |
| | | */ |
| | | public static void deviceListCallBack() { |
| | | byte[] debugBytes = new byte[6 + HDLDeviceManager.devicesDataList.size() * 2]; |
| | | debugBytes[0] = 1; |
| | | debugBytes[1] = 1; |
| | | debugBytes[2] = 1; |
| | | debugBytes[3] = 1; |
| | | debugBytes[4] = 1; |
| | | debugBytes[5] = 1; |
| | | public static void OnDeviceListGetSuccessCallBack() { |
| | | // byte[] debugBytes = new byte[6 + HDLDeviceManager.devicesDataList.size() * 2]; |
| | | // debugBytes[0] = 1; |
| | | // debugBytes[1] = 1; |
| | | // debugBytes[2] = 1; |
| | | // debugBytes[3] = 1; |
| | | // debugBytes[4] = 1; |
| | | // debugBytes[5] = 1; |
| | | // |
| | | // for (int i = 0; i < HDLDeviceManager.devicesDataList.size(); i++) { |
| | | // |
| | | // debugBytes[6 + i + i] = (byte) HDLDeviceManager.devicesDataList.get(i).getSourceSubnetID(); |
| | | // debugBytes[6 + i + i + 1] = (byte) HDLDeviceManager.devicesDataList.get(i).getSourceDeviceID(); |
| | | // String device = "第 " + (i + 1) + " 个模块:模块备注名称:" + HDLDeviceManager.devicesDataList.get(i).getRemark() |
| | | // + ",子网号:" + HDLDeviceManager.devicesDataList.get(i).getSourceSubnetID() |
| | | // + ",设备号:" + HDLDeviceManager.devicesDataList.get(i).getSourceDeviceID() |
| | | // + ",回路数:" + HDLDeviceManager.devicesDataList.get(i).getAppliancesInfoList().size() + "\n"; |
| | | // HDLLog.info(device); |
| | | // } |
| | | |
| | | for (int i = 0; i < HDLDeviceManager.devicesDataList.size(); i++) { |
| | | |
| | | debugBytes[6 + i + i] = (byte) HDLDeviceManager.devicesDataList.get(i).getSourceSubnetID(); |
| | | debugBytes[6 + i + i + 1] = (byte) HDLDeviceManager.devicesDataList.get(i).getSourceDeviceID(); |
| | | String device = "第 " + (i + 1) + " 个模块:模块备注名称:" + HDLDeviceManager.devicesDataList.get(i).getRemark() |
| | | + ",子网号:" + HDLDeviceManager.devicesDataList.get(i).getSourceSubnetID() |
| | | + ",设备号:" + HDLDeviceManager.devicesDataList.get(i).getSourceDeviceID() |
| | | + ",回路数:" + HDLDeviceManager.devicesDataList.get(i).getAppliancesInfoList().size() + "\n"; |
| | | HDLLog.info(device); |
| | | } |
| | | |
| | | // HDLUdpCore.sendTestCMD(debugBytes, HDLTest.SEND_TEST_PORT); |
| | | EventBus.getDefault().post(new DevicesInfoEvent(HDLDeviceManager.devicesDataList, true)); |
| | | |
| | | |
| | | /**搜索设备成功,执行一次保存到本地*/ |
| | | HDLDeviceManager.saveDevicesDataList(); |
| | | } |
| | | |
| | | |
| | | public static void refreshAllDevicesState() { |
| | | // /** |
| | | // * 返回设备列表 |
| | | // */ |
| | | // public static void deviceListCallBack() { |
| | | // byte[] debugBytes = new byte[6 + HDLDeviceManager.devicesDataList.size() * 2]; |
| | | // debugBytes[0] = 1; |
| | | // debugBytes[1] = 1; |
| | | // debugBytes[2] = 1; |
| | | // debugBytes[3] = 1; |
| | | // debugBytes[4] = 1; |
| | | // debugBytes[5] = 1; |
| | | // |
| | | // for (int i = 0; i < HDLDeviceManager.devicesDataList.size(); i++) { |
| | | // |
| | | // debugBytes[6 + i + i] = (byte) HDLDeviceManager.devicesDataList.get(i).getSourceSubnetID(); |
| | | // debugBytes[6 + i + i + 1] = (byte) HDLDeviceManager.devicesDataList.get(i).getSourceDeviceID(); |
| | | // String device = "第 " + (i + 1) + " 个模块:模块备注名称:" + HDLDeviceManager.devicesDataList.get(i).getRemark() |
| | | // + ",子网号:" + HDLDeviceManager.devicesDataList.get(i).getSourceSubnetID() |
| | | // + ",设备号:" + HDLDeviceManager.devicesDataList.get(i).getSourceDeviceID() |
| | | // + ",回路数:" + HDLDeviceManager.devicesDataList.get(i).getAppliancesInfoList().size() + "\n"; |
| | | // HDLLog.info(device); |
| | | // } |
| | | // |
| | | //// HDLUdpCore.sendTestCMD(debugBytes, HDLTest.SEND_TEST_PORT); |
| | | // EventBus.getDefault().post(new DevicesInfoEvent(HDLDeviceManager.devicesDataList, true)); |
| | | // |
| | | // |
| | | // } |
| | | |
| | | /** |
| | | * 刷新所有设备状态和备注 |
| | | * 2019-10-15 |
| | | */ |
| | | public static void refreshAllDevicesStateAndRemarks() { |
| | | |
| | | if (isSearching) { |
| | | isRefreshAllDevicesState = false; |
| | | return; |
| | | } |
| | | isRefreshAllDevicesState = true; |
| | | for (int i = 0; i < HDLDeviceManager.listRemarks.size(); i++) { |
| | | HDLDeviceManager.listRemarks.get(i).setCallBack(false); |
| | | } |
| | | getDevRemarks(); |
| | | } |
| | | |
| | | /** |
| | | * 1S |
| | | * @param delayTime 单位秒 |
| | | */ |
| | | public static void refreshAllDevicesState(int delayTime) { |
| | | if (refreshTimer != null) { |
| | | refreshTimer.cancel(); |
| | | refreshTimer.purge(); |
| | |
| | | } |
| | | getDevRemarks(); |
| | | } |
| | | }, 1000 * 30); |
| | | }, 1000 * delayTime); |
| | | } |
| | | |
| | | |
| | |
| | | //判断是否获取设备备注完全,若完全则返回所有设备列表。 |
| | | if (HDLDeviceManager.listRemarks != null && HDLDeviceManager.listRemarks.size() != 0 && pos == -1) { |
| | | if (!isRefreshAllDevicesState) { |
| | | HandleSearch.deviceListCallBack(); |
| | | |
| | | HandleSearch.OnDeviceListGetSuccessCallBack(); |
| | | } else { |
| | | //刷新完毕 |
| | | // TODO: 2018/12/29 刷新完毕可能要做某些事情 |
| | | // TODO: 刷新完毕可能要做某些事情 |
| | | HDLLog.info("刷新设备状态完毕"); |
| | | isRefreshAllDevicesState = false; |
| | | HandleSearch.OnDeviceListGetSuccessCallBack(); |
| | | // /**刷新设备状态完毕,执行一次保存到本地*/ |
| | | // HDLDeviceManager.saveDevicesDataList(); |
| | | } |
| | | |
| | | return; |
| | |
| | | port = Configuration.RCU_SEND_PORT; |
| | | break; |
| | | case HandleSearch.GET_BUS_DEVICES: |
| | | // ipAddress = NetWorkUtil.getLocalBroadCast(); |
| | | ipAddress = HDLDeviceManager.listRemarks.get(newPos).getAppliancesInfo().getIpAddress(); |
| | | ipAddress = HDLCommand.getLocalBroadCastIp();//2019-10-16 |
| | | // ipAddress = HDLDeviceManager.listRemarks.get(newPos).getAppliancesInfo().getIpAddress(); |
| | | port = Configuration.PORT; |
| | | break; |
| | | } |