| | |
| | | import java.util.Collections; |
| | | import java.util.Comparator; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 输送站真实连接(PLC) |
| | |
| | | private List<ZyStationStatusEntity> statusList; |
| | | private List<StationObjModel> barcodeOriginList; |
| | | private List<StationObjModel> inStationOriginList; |
| | | private Map<Integer, Integer> inStationBarcodeStationMap; |
| | | private SiemensS7Net siemensNet; |
| | | private DeviceConfig deviceConfig; |
| | | private RedisUtil redisUtil; |
| | |
| | | } |
| | | barcodeOriginList = basDevp.getBarcodeStationList$(); |
| | | inStationOriginList = sortStationObjModelsByStationId(basDevp.getInStationList$()); |
| | | inStationBarcodeStationMap = buildInStationBarcodeStationMap(inStationOriginList); |
| | | } |
| | | |
| | | if (siemensNet == null) { |
| | |
| | | } |
| | | Integer ioMode = normalizeIoMode((int) siemensNet.getByteTransform().TransInt16(result6.Content, i * 2)); |
| | | inStationEntity.setIoMode(ioMode); |
| | | syncBarcodeStationIoMode(inStationEntity.getStationId(), ioMode); |
| | | } |
| | | } |
| | | |
| | |
| | | return null; |
| | | } |
| | | |
| | | private void syncBarcodeStationIoMode(Integer inStationId, Integer ioMode) { |
| | | Integer barcodeStationId = findBarcodeStationIdByInStationId(inStationBarcodeStationMap, inStationId); |
| | | if (barcodeStationId == null) { |
| | | return; |
| | | } |
| | | ZyStationStatusEntity barcodeStationEntity = findStatusEntityByStationId(barcodeStationId); |
| | | if (barcodeStationEntity == null) { |
| | | return; |
| | | } |
| | | barcodeStationEntity.setIoMode(ioMode); |
| | | } |
| | | |
| | | private ZyStationStatusEntity findStatusEntityByStationId(Integer stationId) { |
| | | if (stationId == null) { |
| | | return null; |
| | | } |
| | | for (ZyStationStatusEntity zyStationStatusEntity : statusList) { |
| | | if (zyStationStatusEntity.getStationId().equals(stationId)) { |
| | | return zyStationStatusEntity; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | private int getTaskWriteIdx(int stationIdx, Integer taskWriteIdx) { |
| | | int useIdx = -1; |
| | | if (stationIdx < 0 || taskWriteIdx == null || taskWriteIdx <= 0) { |
| | |
| | | return stationObjModels; |
| | | } |
| | | |
| | | static Map<Integer, Integer> buildInStationBarcodeStationMap(List<StationObjModel> inStationOriginList) { |
| | | Map<Integer, Integer> map = new HashMap<>(); |
| | | if (inStationOriginList == null) { |
| | | return map; |
| | | } |
| | | for (StationObjModel inStation : inStationOriginList) { |
| | | if (inStation == null || inStation.getStationId() == null) { |
| | | continue; |
| | | } |
| | | StationObjModel barcodeStation = inStation.getBarcodeStation(); |
| | | if (barcodeStation == null || barcodeStation.getStationId() == null) { |
| | | continue; |
| | | } |
| | | map.put(inStation.getStationId(), barcodeStation.getStationId()); |
| | | } |
| | | return map; |
| | | } |
| | | |
| | | static Integer findBarcodeStationIdByInStationId(Map<Integer, Integer> inStationBarcodeStationMap, Integer inStationId) { |
| | | if (inStationBarcodeStationMap == null || inStationId == null) { |
| | | return null; |
| | | } |
| | | return inStationBarcodeStationMap.get(inStationId); |
| | | } |
| | | |
| | | private static void appendConveyorCommonAlarmMessages(StringBuilder sb, boolean[] status, int startIdx) { |
| | | if (status == null) { |
| | | return; |