| | |
| | | import com.zy.core.network.DeviceConnectPool; |
| | | import com.zy.core.network.ZyStationConnectDriver; |
| | | import com.zy.core.network.entity.ZyStationStatusEntity; |
| | | import com.zy.core.thread.impl.v5.StationMoveSegmentExecutor; |
| | | import com.zy.core.thread.support.RecentStationArrivalTracker; |
| | | import com.zy.core.utils.DeviceLogRedisKeyBuilder; |
| | | import com.zy.system.entity.Config; |
| | | import com.zy.system.service.ConfigService; |
| | |
| | | private DeviceConfig deviceConfig; |
| | | private RedisUtil redisUtil; |
| | | private ZyStationConnectDriver zyStationConnectDriver; |
| | | private StationMoveSegmentExecutor segmentExecutor; |
| | | private int deviceLogCollectTime = 200; |
| | | private boolean initStatus = false; |
| | | private long deviceDataLogTime = System.currentTimeMillis(); |
| | | private ExecutorService executor = Executors.newFixedThreadPool(9999); |
| | | private final RecentStationArrivalTracker recentArrivalTracker; |
| | | |
| | | public ZyStationV4Thread(DeviceConfig deviceConfig, RedisUtil redisUtil) { |
| | | this.deviceConfig = deviceConfig; |
| | | this.redisUtil = redisUtil; |
| | | this.recentArrivalTracker = new RecentStationArrivalTracker(redisUtil); |
| | | this.segmentExecutor = new StationMoveSegmentExecutor(deviceConfig, redisUtil, this::sendCommand); |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | if (step == 2) { |
| | | StationCommand cmd = (StationCommand) task.getData(); |
| | | executor.submit(() -> executeMoveWithSeg(cmd)); |
| | | executor.submit(() -> segmentExecutor.execute(cmd)); |
| | | } |
| | | Thread.sleep(100); |
| | | } catch (Exception e) { |
| | |
| | | stationProtocol.setWeight(statusEntity.getWeight()); |
| | | stationProtocol.setTaskWriteIdx(statusEntity.getTaskWriteIdx()); |
| | | stationProtocol.setTaskBufferItems(statusEntity.getTaskBufferItems()); |
| | | recentArrivalTracker.observe(statusEntity.getStationId(), statusEntity.getTaskNo(), statusEntity.isLoading()); |
| | | } |
| | | |
| | | if (!Cools.isEmpty(stationProtocol.getSystemWarning())) { |
| | |
| | | map.put(stationProtocol.getStationId(), stationProtocol); |
| | | } |
| | | return map; |
| | | } |
| | | |
| | | @Override |
| | | public boolean hasRecentArrival(Integer stationId, Integer taskNo) { |
| | | return recentArrivalTracker.hasRecentArrival(stationId, taskNo); |
| | | } |
| | | |
| | | @Override |
| | |
| | | } catch (Exception ignore) { |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public boolean clearPath(Integer taskNo) { |
| | | return false; |
| | | } |
| | | } |