| | |
| | | import java.text.MessageFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.LinkedHashSet; |
| | | import java.util.List; |
| | | |
| | | public class StationV5StatusReader { |
| | |
| | | private final RedisUtil redisUtil; |
| | | private final RecentStationArrivalTracker recentArrivalTracker; |
| | | private final List<StationProtocol> statusList = new ArrayList<>(); |
| | | private volatile List<Integer> taskNoList = new ArrayList<>(); |
| | | private boolean initialized = false; |
| | | private long deviceDataLogTime = System.currentTimeMillis(); |
| | | |
| | |
| | | |
| | | int deviceLogCollectTime = initialized ? Utils.getDeviceLogCollectTime() : 200; |
| | | List<ZyStationStatusEntity> zyStationStatusEntities = zyStationConnectDriver.getStatus(); |
| | | LinkedHashSet<Integer> taskNoSet = new LinkedHashSet<>(); |
| | | for (ZyStationStatusEntity statusEntity : zyStationStatusEntities) { |
| | | for (StationProtocol stationProtocol : statusList) { |
| | | if (stationProtocol.getStationId().equals(statusEntity.getStationId())) { |
| | |
| | | stationProtocol.setTaskWriteIdx(statusEntity.getTaskWriteIdx()); |
| | | stationProtocol.setTaskBufferItems(statusEntity.getTaskBufferItems()); |
| | | stationProtocol.setIoMode(statusEntity.getIoMode()); |
| | | if (statusEntity.getTaskNo() != null && statusEntity.getTaskNo() > 0) { |
| | | taskNoSet.add(statusEntity.getTaskNo()); |
| | | } |
| | | if (statusEntity.getTaskBufferItems() != null) { |
| | | statusEntity.getTaskBufferItems().forEach(item -> { |
| | | Integer bufferTaskNo = item == null ? null : item.getTaskNo(); |
| | | if (bufferTaskNo != null && bufferTaskNo > 0) { |
| | | taskNoSet.add(bufferTaskNo); |
| | | } |
| | | }); |
| | | } |
| | | recentArrivalTracker.observe(statusEntity.getStationId(), statusEntity.getTaskNo(), statusEntity.isLoading()); |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | } |
| | | taskNoList = new ArrayList<>(taskNoSet); |
| | | |
| | | OutputQueue.DEVP.offer(MessageFormat.format("【{0}】[id:{1}] <<<<< 实时数据更新成功", |
| | | DateUtils.convert(new Date()), deviceConfig.getDeviceNo())); |
| | |
| | | public List<StationProtocol> getStatusList() { |
| | | return statusList; |
| | | } |
| | | |
| | | public List<Integer> getTaskNoList() { |
| | | return taskNoList; |
| | | } |
| | | } |