| | |
| | | |
| | | import com.hdl.sdk.ttl.Config.Configuration; |
| | | import com.hdl.sdk.ttl.HDLDeviceManger.Bean.DevicesData; |
| | | import com.hdl.sdk.ttl.HDLDeviceManger.Bean.ListRemarks; |
| | | import com.hdl.sdk.ttl.HDLDeviceManger.Bean.RemarkTimes; |
| | | import com.hdl.sdk.ttl.HDLDeviceManger.Bean.SearchCountBean; |
| | | import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.DevicesInfoEvent; |
| | |
| | | remarkTimer.cancel(); |
| | | remarkTimer = null; |
| | | } |
| | | |
| | | if ((HDLDeviceManager.listRemarks != null && HDLDeviceManager.listRemarks.size() == 0) || isSearching) { |
| | | isRefreshAllDevicesState = false; |
| | | if (HDLDeviceManager.devicesDataList != null && HDLDeviceManager.devicesDataList.size() > 0) { |
| | |
| | | } |
| | | |
| | | //判断是否获取设备备注完全,若完全则返回所有设备列表。 |
| | | if (HDLDeviceManager.listRemarks != null && HDLDeviceManager.listRemarks.size() != 0 && pos == -1) { |
| | | if (pos == -1) { |
| | | if (!isRefreshAllDevicesState) { |
| | | HandleSearch.OnDeviceListGetSuccessCallBack(); |
| | | } else { |
| | |
| | | isRefreshAllDevicesState = false; |
| | | HandleSearch.OnDeviceListGetSuccessCallBack(); |
| | | } |
| | | |
| | | return; |
| | | } |
| | | remarkTimer = new Timer(); |
| | | final int newPos = pos; |
| | | final RemarkTimes remarkTimes = new RemarkTimes(); |
| | | remarkTimes.setCount(0); |
| | | |
| | | if (remarkTimer == null) { |
| | | return; |
| | | } |
| | | ListRemarks listRemark = HDLDeviceManager.listRemarks.get(newPos); |
| | | remarkTimer.schedule(new TimerTask() { |
| | | @Override |
| | | public void run() { |
| | | if (remarkTimes.getCount() < 1) { |
| | | remarkTimes.setCount(remarkTimes.getCount() + 1); |
| | | listRemark.setSendCount(listRemark.getSendCount() + 1); |
| | | if (listRemark.getSendCount() < 3 && !listRemark.isCallBack()) { |
| | | if (newPos < HDLDeviceManager.listRemarks.size()) { |
| | | HDLLog.I("----->发送获取备注命令。共" + HDLDeviceManager.listRemarks.size() + "个模块。第" |
| | | + newPos + "个模块。第 " + (HDLDeviceManager.listRemarks.get(newPos).getAppliancesInfo().getChannelNum()) |
| | | + " 回路,子网号:" + HDLDeviceManager.listRemarks.get(newPos).getAppliancesInfo().getDeviceSubnetID() |
| | | + ",设备号:" + HDLDeviceManager.listRemarks.get(newPos).getAppliancesInfo().getDeviceDeviceID() |
| | | + " 第 " + remarkTimes.getCount() + " 次"); |
| | | HDLLog.I("----->发送获取备注命令。共" + HDLDeviceManager.listRemarks.size() + "个,第" |
| | | + newPos + "个模块。第 " + (listRemark.getAppliancesInfo().getDeviceIndex()) |
| | | + " 序号,子网号:" + listRemark.getAppliancesInfo().getDeviceSubnetID() |
| | | + ",设备号:" + listRemark.getAppliancesInfo().getDeviceDeviceID() |
| | | + " 第 " + listRemark.getSendCount() + " 次"); |
| | | HDLCommand.cusSendCommand(Configuration.DEVICES_READ_FROM_GATEWAY_COMMAND, |
| | | HDLDeviceManager.listRemarks.get(newPos).getAppliancesInfo().getSourceSubnetID() |
| | | , HDLDeviceManager.listRemarks.get(newPos).getAppliancesInfo().getSourceDeviceID(), |
| | | listRemark.getAppliancesInfo().getSourceSubnetID() |
| | | , listRemark.getAppliancesInfo().getSourceDeviceID(), |
| | | new byte[]{ |
| | | (byte) HDLDeviceManager.listRemarks.get(newPos).getAppliancesInfo().getDeviceSubnetID(), |
| | | (byte) HDLDeviceManager.listRemarks.get(newPos).getAppliancesInfo().getDeviceDeviceID(), |
| | | (byte) HDLDeviceManager.listRemarks.get(newPos).getAppliancesInfo().getChannelNum(), |
| | | (byte) HDLDeviceManager.listRemarks.get(newPos).getAppliancesInfo().getBigType(), |
| | | (byte) HDLDeviceManager.listRemarks.get(newPos).getAppliancesInfo().getLittleType(), |
| | | (byte) listRemark.getAppliancesInfo().getDeviceSubnetID(), |
| | | (byte) listRemark.getAppliancesInfo().getDeviceDeviceID(), |
| | | (byte) listRemark.getAppliancesInfo().getDeviceIndex(), |
| | | (byte) listRemark.getAppliancesInfo().getBigType(), |
| | | (byte) listRemark.getAppliancesInfo().getLittleType(), |
| | | }); |
| | | } |
| | | } else { |
| | | |
| | | if (HDLDeviceManager.listRemarks != null |
| | | && HDLDeviceManager.listRemarks.size() != 0 |
| | | && newPos < HDLDeviceManager.listRemarks.size()) { |
| | | HDLDeviceManager.listRemarks.get(newPos).setCallBack(true); |
| | | if (!listRemark.isCallBack()) { |
| | | HDLLog.I("----->获取备注命令超时 第 " + (listRemark.getAppliancesInfo().getDeviceIndex()) + " 序号,子网号:" + listRemark.getAppliancesInfo().getDeviceSubnetID() + ",设备号:" + listRemark.getAppliancesInfo().getDeviceDeviceID()); |
| | | } |
| | | listRemark.setCallBack(true); |
| | | getDevRemarks(); |
| | | } |
| | | } |