| | |
| | | import com.zy.core.network.DeviceConnectPool; |
| | | import com.zy.core.thread.StationThread; |
| | | import com.zy.core.thread.support.RecentStationArrivalTracker; |
| | | import com.zy.core.thread.support.StationErrLogSupport; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.core.common.DateUtils; |
| | | import com.core.common.SpringUtils; |
| | |
| | | public class ZyStationThread implements Runnable, StationThread { |
| | | |
| | | private List<StationProtocol> statusList = new ArrayList<>(); |
| | | private volatile List<Integer> taskNoList = new ArrayList<>(); |
| | | private DeviceConfig deviceConfig; |
| | | private RedisUtil redisUtil; |
| | | private ZyStationConnectDriver zyStationConnectDriver; |
| | |
| | | } |
| | | |
| | | 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.setRunBlock(statusEntity.isRunBlock()); |
| | | stationProtocol.setEnableIn(statusEntity.isEnableIn()); |
| | | stationProtocol.setWeight(statusEntity.getWeight()); |
| | | stationProtocol.setIoMode(statusEntity.getIoMode()); |
| | | if (statusEntity.getTaskNo() != null && statusEntity.getTaskNo() > 0) { |
| | | taskNoSet.add(statusEntity.getTaskNo()); |
| | | } |
| | | 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())); |
| | | StationErrLogSupport.sync(deviceConfig, redisUtil, statusList); |
| | | |
| | | if (System.currentTimeMillis() - deviceDataLogTime > deviceLogCollectTime) { |
| | | //保存数据记录 |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<Integer> getAllTaskNoList() { |
| | | return taskNoList; |
| | | } |
| | | |
| | | @Override |
| | | public StationCommand getCommand(StationCommandType commandType, Integer taskNo, Integer stationId, Integer targetStationId, Integer palletSize) { |
| | | StationCommand stationCommand = new StationCommand(); |
| | | stationCommand.setTaskNo(taskNo); |