From 0f69561e397093b5165c4aac58530721d5c62178 Mon Sep 17 00:00:00 2001 From: zjj <3272660260@qq.com> Date: 星期一, 25 十一月 2024 11:03:16 +0800 Subject: [PATCH] #led --- zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/SiemensDevpThread.java | 41 ++++++++++++++++++++++++++++++++++++++++- 1 files changed, 40 insertions(+), 1 deletions(-) diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/SiemensDevpThread.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/SiemensDevpThread.java index 9668756..e4f79c6 100644 --- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/SiemensDevpThread.java +++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/SiemensDevpThread.java @@ -17,6 +17,8 @@ import com.zy.asrs.wcs.rcs.News; import com.zy.asrs.wcs.rcs.cache.OutputQueue; import com.zy.asrs.wcs.rcs.entity.Device; +import com.zy.asrs.wcs.rcs.model.dto.WorkModeTypeDto; +import com.zy.asrs.wcs.rcs.model.enums.WorkModeType; import com.zy.asrs.wcs.rcs.model.protocol.StaProtocol; import com.zy.asrs.wcs.rcs.thread.DevpThread; import lombok.extern.slf4j.Slf4j; @@ -44,9 +46,21 @@ */ private int barcodeSize = 2; + /** + * 鍏ュ嚭搴撴ā寮� + * 0锛氭湭鐭� + * 1锛氬叆搴撳惎鍔ㄤ腑 + * 2.鍏ュ簱妯″紡 + * 3.鍑哄簱鍚姩涓� 锛堜笉鑳界敓鎴愬叆搴撳伐浣滄。锛� + * 4.鍑哄簱妯″紡 + */ + private Map<Integer, WorkModeTypeDto> workModeTypes = new ConcurrentHashMap<>(); + public SiemensDevpThread(Device device, RedisUtil redisUtil) { this.device = device; this.redisUtil = redisUtil; + + workModeTypes.put(101, new WorkModeTypeDto(101, WorkModeType.NONE, "DB1001.120")); } private ArrayList<BasConveyorSta> getStaNo() { @@ -237,7 +251,7 @@ } @Override - public boolean writeWorkSta(int siteId, short staNo, short workNo) { + public boolean writeWorkSta(int siteId, short workNo, short staNo) { int index = findStaNosIndex(siteId); OperateResult write1 = siemensS7Net.Write("DB100." + index*6, workNo); // 宸ヤ綔鍙� @@ -287,4 +301,29 @@ staProtocol.setPakMk(pakMk); } } + + private void updateWorkMode() { + for (Map.Entry<Integer, WorkModeTypeDto> entry : workModeTypes.entrySet()) { + WorkModeTypeDto workModeTypeDto = entry.getValue(); + WorkModeType workModeType = workModeTypeDto.getWorkModeType(); + if (workModeType != WorkModeType.NONE) { + if (!siemensS7Net.Write(workModeTypeDto.getAddress(), workModeType.id).IsSuccess) { + OutputQueue.DEVP.offer(MessageFormat.format("鍐欏叆杈撻�佺嚎{1}鍏ュ嚭搴撴ā寮忓け璐ャ�傝緭閫佺嚎缂栧彿={0}", device.getId(), workModeTypeDto.getSiteId())); + log.error("鍐欏叆杈撻�佺嚎{1}鍏ュ嚭搴撴ā寮忓け璐ャ�傝緭閫佺嚎缂栧彿={0}", device.getId(), workModeTypeDto.getSiteId()); + } + } + } + } + + @Override + public boolean switchWorkMode(int siteId, int workMode) { + WorkModeTypeDto workModeTypeDto = workModeTypes.get(siteId); + if(workModeTypeDto == null) { + return false; + } + + workModeTypeDto.setWorkModeType(WorkModeType.get((short) workMode)); + workModeTypes.put(siteId, workModeTypeDto); + return false; + } } -- Gitblit v1.9.1