src/main/java/com/zy/asrs/domain/vo/CrnStateTableVo.java
@@ -84,25 +84,25 @@ private String command = ""; // 走行速度(m/min) private Integer xspeed = 0; private Double xspeed = 0D; // 升降速度(m/min) private Integer yspeed = 0; private Double yspeed = 0D; // 叉牙速度(m/min) private Integer zspeed = 0; private Double zspeed = 0D; // 走行距离(Km) private Integer xdistance = 0; private Double xdistance = 0D; // 升降距离(Km) private Integer ydistance = 0; private Double ydistance = 0D; // 走行时长(H) private Integer xduration = 0; private Double xduration = 0D; // 升降时长(H) private Integer yduration = 0; private Double yduration = 0D; // 设备状态-用于前端显示 private String deviceStatus = "OFFLINE"; src/main/java/com/zy/core/MainProcess.java
@@ -2,7 +2,7 @@ import com.core.common.SpringUtils; import com.core.exception.CoolException; import com.zy.core.plugin.MainProcessPluginApi; import com.zy.core.plugin.api.MainProcessPluginApi; import com.zy.core.properties.SystemProperties; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; @@ -35,7 +35,7 @@ try { mainProcessPluginApi = SpringUtils.getBean(clazz); } catch (CoolException coolException) { continue; Thread.sleep(300); } } src/main/java/com/zy/core/model/protocol/CrnProtocol.java
@@ -104,37 +104,37 @@ /** * X行走线速度m/min */ private Integer xSpeed; private Double xSpeed; /** * Y行走线速度m/min */ private Integer ySpeed; private Double ySpeed; /** * Z行走线速度m/min */ private Integer zSpeed; private Double zSpeed; /** * 堆垛机累计走行距离km */ public Integer xDistance; public Double xDistance; /** * 堆垛机累计升降距离km */ public Integer yDistance; public Double yDistance; /** * 堆垛机累计走行时长h */ public Integer xDuration; public Double xDuration; /** * 堆垛机累计升降时长h */ public Integer yDuration; public Double yDuration; /** * 最近一次入出库类型 src/main/java/com/zy/core/model/protocol/DualCrnProtocol.java
@@ -189,6 +189,12 @@ */ public Integer yDuration; //货物类型 private Integer goodsType; //条码 private String barcode; /** * 最近一次入出库类型 * I:入库 src/main/java/com/zy/core/network/entity/ZyCrnStatusEntity.java
@@ -82,37 +82,37 @@ /** * X行走线速度m/min */ private Integer xSpeed; private Double xSpeed; /** * Y行走线速度m/min */ private Integer ySpeed; private Double ySpeed; /** * Z行走线速度m/min */ private Integer zSpeed; private Double zSpeed; /** * 堆垛机累计走行距离km */ public Integer xDistance; public Double xDistance; /** * 堆垛机累计升降距离km */ public Integer yDistance; public Double yDistance; /** * 堆垛机累计走行时长h */ public Integer xDuration; public Double xDuration; /** * 堆垛机累计升降时长h */ public Integer yDuration; public Double yDuration; private Integer temp1; src/main/java/com/zy/core/network/entity/ZyDualCrnStatusEntity.java
@@ -139,4 +139,10 @@ private Integer temp4; //货物类型 private Integer goodsType; //条码 private String barcode; } src/main/java/com/zy/core/network/real/ZyCrnRealConnect.java
@@ -37,10 +37,10 @@ if(connect.IsSuccess){ connected = true; OutputQueue.CRN.offer(MessageFormat.format( "【{0}】堆垛机plc连接成功 ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), deviceConfig.getDeviceNo(), deviceConfig.getIp(), deviceConfig.getPort())); News.info("SiemensCrn 堆垛机plc连接成功 ===>> [id:{}] [ip:{}] [port:{}]", deviceConfig.getDeviceNo(), deviceConfig.getIp(), deviceConfig.getPort()); News.info("堆垛机plc连接成功 ===>> [id:{}] [ip:{}] [port:{}]", deviceConfig.getDeviceNo(), deviceConfig.getIp(), deviceConfig.getPort()); } else { OutputQueue.CRN.offer(MessageFormat.format("【{0}】堆垛机plc连接失败!!! ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), deviceConfig.getDeviceNo(), deviceConfig.getIp(), deviceConfig.getPort())); News.error("SiemensCrn 堆垛机plc连接失败!!! ===>> [id:{}] [ip:{}] [port:{}]", deviceConfig.getDeviceNo(), deviceConfig.getIp(), deviceConfig.getPort()); News.error("堆垛机plc连接失败!!! ===>> [id:{}] [ip:{}] [port:{}]", deviceConfig.getDeviceNo(), deviceConfig.getIp(), deviceConfig.getPort()); } // siemensNet.ConnectClose(); return connected; @@ -69,27 +69,25 @@ crnStatus.setWalkPos((int) siemensNet.getByteTransform().TransInt16(result.Content, 14)); crnStatus.setLoaded((int) siemensNet.getByteTransform().TransInt16(result.Content, 16)); crnStatus.setAlarm((int) siemensNet.getByteTransform().TransInt16(result.Content, 18)); crnStatus.setTemp1((int) siemensNet.getByteTransform().TransInt16(result.Content, 20)); crnStatus.setTemp2((int) siemensNet.getByteTransform().TransInt16(result.Content, 22)); crnStatus.setTemp3((int) siemensNet.getByteTransform().TransInt16(result.Content, 24)); crnStatus.setTemp4((int) siemensNet.getByteTransform().TransInt16(result.Content, 26)); crnStatus.setXSpeed((int) siemensNet.getByteTransform().TransInt16(result.Content, 28)); crnStatus.setYSpeed((int) siemensNet.getByteTransform().TransInt16(result.Content, 32)); crnStatus.setZSpeed((int) siemensNet.getByteTransform().TransInt16(result.Content, 36)); crnStatus.setXDistance((int) siemensNet.getByteTransform().TransInt16(result.Content, 40)); crnStatus.setYDistance((int) siemensNet.getByteTransform().TransInt16(result.Content, 44)); crnStatus.setXDuration((int) siemensNet.getByteTransform().TransInt16(result.Content, 48)); crnStatus.setYDuration((int) siemensNet.getByteTransform().TransInt16(result.Content, 52)); crnStatus.setTemp1((int) siemensNet.getByteTransform().TransInt16(result.Content, 24)); crnStatus.setTemp2((int) siemensNet.getByteTransform().TransInt16(result.Content, 26)); crnStatus.setXSpeed((double) siemensNet.getByteTransform().TransSingle(result.Content, 28)); crnStatus.setYSpeed((double) siemensNet.getByteTransform().TransSingle(result.Content, 32)); crnStatus.setZSpeed((double) siemensNet.getByteTransform().TransSingle(result.Content, 36)); crnStatus.setXDistance((double) siemensNet.getByteTransform().TransSingle(result.Content, 40)); crnStatus.setYDistance((double) siemensNet.getByteTransform().TransSingle(result.Content, 44)); crnStatus.setXDuration((double) siemensNet.getByteTransform().TransSingle(result.Content, 48)); crnStatus.setYDuration((double) siemensNet.getByteTransform().TransSingle(result.Content, 52)); return crnStatus; } else { OutputQueue.CRN.offer(MessageFormat.format("【{0}】读取堆垛机plc状态信息失败 ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), deviceConfig.getDeviceNo(), deviceConfig.getIp(), deviceConfig.getPort())); News.error("SiemensCrn 读取堆垛机plc状态信息失败 ===>> [id:{}] [ip:{}] [port:{}]", deviceConfig.getDeviceNo(), deviceConfig.getIp(), deviceConfig.getPort()); News.error("读取堆垛机plc状态信息失败 ===>> [id:{}] [ip:{}] [port:{}]", deviceConfig.getDeviceNo(), deviceConfig.getIp(), deviceConfig.getPort()); } } catch (Exception e) { e.printStackTrace(); OutputQueue.CRN.offer(MessageFormat.format("【{0}】读取堆垛机plc状态信息失败 ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), deviceConfig.getDeviceNo(), deviceConfig.getIp(), deviceConfig.getPort())); News.error("SiemensCrn 读取垛机plc状态信息失败 ===>> [id:{}] [ip:{}] [port:{}]", deviceConfig.getDeviceNo(), deviceConfig.getIp(), deviceConfig.getPort()); News.error("读取垛机plc状态信息失败 ===>> [id:{}] [ip:{}] [port:{}]", deviceConfig.getDeviceNo(), deviceConfig.getIp(), deviceConfig.getPort()); } return null; } @@ -105,30 +103,26 @@ } int writeAck = 0; boolean ackResult = false; boolean commandResult = false; do { OperateResult resultAck = siemensNet.Write("DB100.0", (short) 0); if (resultAck.IsSuccess) { Thread.sleep(200); OperateResultExOne<byte[]> resultRead = siemensNet.Read("DB100.0", (short) 2); short ack = siemensNet.getByteTransform().TransInt16(resultRead.Content, 0); if (ack != 0) { writeAck++; } else { News.info("堆垛机命令下发[id:{}] >>>>> {}", command.getCrnNo(), "ack复位完成"); ackResult = true; break; OperateResultExOne<byte[]> commandReadResult = siemensNet.Read("DB100.0", (short) 2); if (commandReadResult.IsSuccess) { short commandRead = siemensNet.getByteTransform().TransInt16(commandReadResult.Content, 0); if (commandRead == 1) { Thread.sleep(500); }else { commandResult = true; } } } while (writeAck < 5); if (!ackResult) { response.setMessage("堆垛机命令下发[id:{}] >>>>> {}" + command.getCrnNo() + "ack复位失败"); if (!commandResult) { response.setMessage("堆垛机命令下发[id:{}] >>>>> {}" + command.getCrnNo() + "任务状态位异常"); return response; } short[] array = new short[10]; array[0] = command.getAckFinish(); short[] array = new short[9]; array[0] = (short) 0; array[1] = command.getTaskNo(); array[2] = command.getTaskMode(); array[3] = command.getSourcePosX(); @@ -137,65 +131,49 @@ array[6] = command.getDestinationPosX(); array[7] = command.getDestinationPosY(); array[8] = command.getDestinationPosZ(); array[9] = command.getCommand(); OperateResult result = null; OperateResult result = siemensNet.Write("DB100.0", array); if (!result.IsSuccess) { response.setMessage("堆垛机命令下发[id:{}] >>>>> {}" + command.getCrnNo() + "任务状态位异常"); return response; } int idx = 0; do { OperateResultExOne<byte[]> resultRead = siemensNet.Read("DB100.0", (short) 20); if (resultRead.IsSuccess) { if (command.getAckFinish() == 0) { short taskNo = siemensNet.getByteTransform().TransInt16(resultRead.Content, 2); short taskMode = siemensNet.getByteTransform().TransInt16(resultRead.Content, 4); short sourcePosX = siemensNet.getByteTransform().TransInt16(resultRead.Content, 6); short sourcePosY = siemensNet.getByteTransform().TransInt16(resultRead.Content, 8); short sourcePosZ = siemensNet.getByteTransform().TransInt16(resultRead.Content, 10); short destinationPosX = siemensNet.getByteTransform().TransInt16(resultRead.Content, 12); short destinationPosY = siemensNet.getByteTransform().TransInt16(resultRead.Content, 14); short destinationPosZ = siemensNet.getByteTransform().TransInt16(resultRead.Content, 16); if (taskNo == 0 || taskMode == 0 || sourcePosX == 0 || sourcePosY == 0 || sourcePosZ == 0 || destinationPosX == 0 || destinationPosY == 0 || destinationPosZ == 0) { result = siemensNet.Write("DB100.0", array); } else { break; } short taskNo = siemensNet.getByteTransform().TransInt16(resultRead.Content, 2); short taskMode = siemensNet.getByteTransform().TransInt16(resultRead.Content, 4); short sourcePosX = siemensNet.getByteTransform().TransInt16(resultRead.Content, 6); short sourcePosY = siemensNet.getByteTransform().TransInt16(resultRead.Content, 8); short sourcePosZ = siemensNet.getByteTransform().TransInt16(resultRead.Content, 10); short destinationPosX = siemensNet.getByteTransform().TransInt16(resultRead.Content, 12); short destinationPosY = siemensNet.getByteTransform().TransInt16(resultRead.Content, 14); short destinationPosZ = siemensNet.getByteTransform().TransInt16(resultRead.Content, 16); if (taskNo == 0 || taskMode == 0 || sourcePosX == 0 || sourcePosY == 0 || sourcePosZ == 0 || destinationPosX == 0 || destinationPosY == 0 || destinationPosZ == 0) { result = siemensNet.Write("DB100.0", array); } else { short ackFinish = siemensNet.getByteTransform().TransInt16(resultRead.Content, 0); if (ackFinish != command.getAckFinish()) { result = siemensNet.Write("DB100.0", array); } else { break; } break; } } idx++; Thread.sleep(500); } while (idx < 5); if (command.getAckFinish() == 0) { short commandFinish = 1; int i = 0; do { OperateResultExOne<byte[]> resultRead = siemensNet.Read("DB100.0", (short) 4); OperateResultExOne<byte[]> resultReadConfirm = siemensNet.Read("DB100.18", (short) 2); if (resultRead.IsSuccess && resultReadConfirm.IsSuccess) { short taskNo = siemensNet.getByteTransform().TransInt16(resultRead.Content, 2); short confirm = siemensNet.getByteTransform().TransInt16(resultReadConfirm.Content, 0); if (taskNo != 0 && confirm == 0) { result = siemensNet.Write("DB100.18", commandFinish); } } i++; Thread.sleep(500); } while (i < 5); OperateResult confirmResult = siemensNet.Write("DB100.0", (short) 1); if (!confirmResult.IsSuccess) { News.error("堆垛机写入确认数据失败 ===>> [id:{}]", command.getCrnNo()); response.setMessage("堆垛机写入确认数据失败"); return response; } if (result != null && result.IsSuccess) { News.info("SiemensCrn堆垛机命令下发[id:{}] >>>>> {}", command.getCrnNo(), JSON.toJSON(command)); News.info("堆垛机命令下发[id:{}] >>>>> {}", command.getCrnNo(), JSON.toJSON(command)); OutputQueue.CRN.offer(MessageFormat.format("【{0}】[id:{1}] >>>>> 命令下发: {2}", DateUtils.convert(new Date()), command.getCrnNo(), JSON.toJSON(command))); response.setResult(true); response.setMessage("命令下发成功"); } else { News.error("SiemensCrn写入堆垛机plc数据失败 ===>> [id:{}]", command.getCrnNo()); News.error("写入堆垛机plc数据失败 ===>> [id:{}]", command.getCrnNo()); OutputQueue.CRN.offer(MessageFormat.format("【{0}】写入堆垛机plc数据失败 ===>> [id:{1}]", DateUtils.convert(new Date()), command.getCrnNo())); response.setResult(false); response.setMessage("命令下发失败"); src/main/java/com/zy/core/network/real/ZyDualCrnRealConnect.java
@@ -8,8 +8,11 @@ import com.core.common.DateUtils; import com.core.common.SpringUtils; import com.zy.asrs.entity.BasCrnpOpt; import com.zy.asrs.entity.BasDualCrnp; import com.zy.asrs.entity.BasDualCrnpOpt; import com.zy.asrs.entity.DeviceConfig; import com.zy.asrs.service.BasCrnpOptService; import com.zy.asrs.service.BasDualCrnpOptService; import com.zy.asrs.utils.Utils; import com.zy.core.News; import com.zy.core.cache.OutputQueue; @@ -64,31 +67,37 @@ //工位1 crnStatus.setTaskNo((int) siemensNet.getByteTransform().TransInt16(result.Content, 2)); crnStatus.setStatus((int) siemensNet.getByteTransform().TransInt16(result.Content, 4)); crnStatus.setForkPos((int) siemensNet.getByteTransform().TransInt16(result.Content, 10)); crnStatus.setLoaded((int) siemensNet.getByteTransform().TransInt16(result.Content, 12)); crnStatus.setForkPos((int) siemensNet.getByteTransform().TransInt16(result.Content, 6)); crnStatus.setLoaded((int) siemensNet.getByteTransform().TransInt16(result.Content, 8)); crnStatus.setTaskReceive((int) siemensNet.getByteTransform().TransInt16(result.Content, 10)); //工位2 crnStatus.setTaskNoTwo((int) siemensNet.getByteTransform().TransInt16(result.Content, 14)); crnStatus.setStatusTwo((int) siemensNet.getByteTransform().TransInt16(result.Content, 16)); crnStatus.setForkPosTwo((int) siemensNet.getByteTransform().TransInt16(result.Content, 22)); crnStatus.setLoadedTwo((int) siemensNet.getByteTransform().TransInt16(result.Content, 24)); crnStatus.setTaskNoTwo((int) siemensNet.getByteTransform().TransInt16(result.Content, 12)); crnStatus.setStatusTwo((int) siemensNet.getByteTransform().TransInt16(result.Content, 14)); crnStatus.setForkPosTwo((int) siemensNet.getByteTransform().TransInt16(result.Content, 16)); crnStatus.setLoadedTwo((int) siemensNet.getByteTransform().TransInt16(result.Content, 18)); crnStatus.setTaskReceiveTwo((int) siemensNet.getByteTransform().TransInt16(result.Content, 20)); crnStatus.setBay((int) siemensNet.getByteTransform().TransInt16(result.Content, 6)); crnStatus.setLevel((int) siemensNet.getByteTransform().TransInt16(result.Content, 8)); crnStatus.setWalkPos((int) siemensNet.getByteTransform().TransInt16(result.Content, 26)); crnStatus.setAlarm((int) siemensNet.getByteTransform().TransInt16(result.Content, 18)); crnStatus.setTemp1((int) siemensNet.getByteTransform().TransInt16(result.Content, 20)); crnStatus.setTemp2((int) siemensNet.getByteTransform().TransInt16(result.Content, 22)); crnStatus.setTemp3((int) siemensNet.getByteTransform().TransInt16(result.Content, 24)); crnStatus.setTemp4((int) siemensNet.getByteTransform().TransInt16(result.Content, 26)); crnStatus.setXSpeed((int) siemensNet.getByteTransform().TransInt16(result.Content, 28)); crnStatus.setYSpeed((int) siemensNet.getByteTransform().TransInt16(result.Content, 32)); crnStatus.setZSpeed((int) siemensNet.getByteTransform().TransInt16(result.Content, 36)); crnStatus.setXDistance((int) siemensNet.getByteTransform().TransInt16(result.Content, 40)); crnStatus.setYDistance((int) siemensNet.getByteTransform().TransInt16(result.Content, 44)); crnStatus.setXDuration((int) siemensNet.getByteTransform().TransInt16(result.Content, 48)); crnStatus.setYDuration((int) siemensNet.getByteTransform().TransInt16(result.Content, 52)); crnStatus.setBay((int) siemensNet.getByteTransform().TransInt16(result.Content, 22)); crnStatus.setLevel((int) siemensNet.getByteTransform().TransInt16(result.Content, 24)); crnStatus.setLiftPos((int) siemensNet.getByteTransform().TransInt16(result.Content, 26)); crnStatus.setWalkPos((int) siemensNet.getByteTransform().TransInt16(result.Content, 28)); crnStatus.setAlarm((int) siemensNet.getByteTransform().TransInt16(result.Content, 30)); crnStatus.setTemp1((int) siemensNet.getByteTransform().TransInt16(result.Content, 34)); crnStatus.setTemp2((int) siemensNet.getByteTransform().TransInt16(result.Content, 36)); crnStatus.setTemp3((int) siemensNet.getByteTransform().TransInt16(result.Content, 38)); crnStatus.setTemp4((int) siemensNet.getByteTransform().TransInt16(result.Content, 40)); crnStatus.setXSpeed((int) siemensNet.getByteTransform().TransInt16(result.Content, 42)); crnStatus.setYSpeed((int) siemensNet.getByteTransform().TransInt16(result.Content, 44)); crnStatus.setZSpeed((int) siemensNet.getByteTransform().TransInt16(result.Content, 46)); crnStatus.setXDistance((int) siemensNet.getByteTransform().TransInt16(result.Content, 48)); crnStatus.setYDistance((int) siemensNet.getByteTransform().TransInt16(result.Content, 50)); crnStatus.setXDuration((int) siemensNet.getByteTransform().TransInt16(result.Content, 52)); crnStatus.setYDuration((int) siemensNet.getByteTransform().TransInt16(result.Content, 54)); crnStatus.setGoodsType((int) siemensNet.getByteTransform().TransInt16(result.Content, 56)); String barcode = siemensNet.getByteTransform().TransString(result.Content, 58, 8, "UTF-8"); crnStatus.setBarcode(barcode); return crnStatus; } else { OutputQueue.CRN.offer(MessageFormat.format("【{0}】读取双工位堆垛机plc状态信息失败 ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), deviceConfig.getDeviceNo(), deviceConfig.getIp(), deviceConfig.getPort())); @@ -105,144 +114,116 @@ @Override public CommandResponse sendCommand(DualCrnCommand command) { CommandResponse response = new CommandResponse(false); // try { // if (null == command) { // News.error("双工位堆垛机写入命令为空"); // response.setMessage("双工位堆垛机写入命令为空"); // return response; // } try { if (null == command) { News.error("双工位堆垛机写入命令为空"); response.setMessage("双工位堆垛机写入命令为空"); return response; } // String address = "DB100.0"; // if (command.getStation() == 1) { // //工位1 // address = "DB100.0"; // }else { // //工位2 // address = "DB100.20"; // } String address = "DB100.0"; if (command.getStation() == 1) { //工位1 address = "DB100.0"; }else { //工位2 address = "DB100.18"; } // int writeAck = 0; // boolean ackResult = false; // do { // OperateResult resultAck = siemensNet.Write(address, (short) 0); // if (resultAck.IsSuccess) { // Thread.sleep(200); // OperateResultExOne<byte[]> resultRead = siemensNet.Read(address, (short) 2); // short ack = siemensNet.getByteTransform().TransInt16(resultRead.Content, 0); // if (ack != 0) { // writeAck++; // } else { // News.info("双工位堆垛机命令下发[id:{}] >>>>> {}", command.getCrnNo(), "ack复位完成"); // ackResult = true; // break; // } // } // } while (writeAck < 5); String confirmAddress = "DB100.16"; if (command.getStation() == 1) { //工位1 confirmAddress = "DB100.16"; }else { //工位2 confirmAddress = "DB100.34"; } // if (!ackResult) { // response.setMessage("双工位堆垛机命令下发[id:{}] >>>>> {}" + command.getCrnNo() + "ack复位失败"); // return response; // } short[] array = new short[9]; array[0] = command.getTaskNo().shortValue(); array[1] = command.getTaskMode().shortValue(); array[2] = command.getSourcePosX().shortValue(); array[3] = command.getSourcePosY().shortValue(); array[4] = command.getSourcePosZ().shortValue(); array[5] = command.getDestinationPosX().shortValue(); array[6] = command.getDestinationPosY().shortValue(); array[7] = command.getDestinationPosZ().shortValue(); array[8] = (short) 0; // short[] array = new short[10]; // array[1] = command.getTaskNo(); // array[2] = command.getTaskMode(); // array[3] = command.getSourcePosX(); // array[4] = command.getSourcePosY(); // array[5] = command.getSourcePosZ(); // array[6] = command.getDestinationPosX(); // array[7] = command.getDestinationPosY(); // array[8] = command.getDestinationPosZ(); // array[9] = command.getCommand(); OperateResult result = siemensNet.Write(address, array); if (!result.IsSuccess) { News.error("双工位堆垛机写入堆垛机plc数据失败 ===>> [id:{}]", command.getCrnNo()); response.setMessage("双工位堆垛机写入堆垛机plc数据失败"); return response; } // OperateResult result = null; // int idx = 0; // do { // OperateResultExOne<byte[]> resultRead = siemensNet.Read(address, (short) 20); // if (resultRead.IsSuccess) { // if (command.getAckFinish() == 0) { // short taskNo = siemensNet.getByteTransform().TransInt16(resultRead.Content, 2); // short taskMode = siemensNet.getByteTransform().TransInt16(resultRead.Content, 4); // short sourcePosX = siemensNet.getByteTransform().TransInt16(resultRead.Content, 6); // short sourcePosY = siemensNet.getByteTransform().TransInt16(resultRead.Content, 8); // short sourcePosZ = siemensNet.getByteTransform().TransInt16(resultRead.Content, 10); // short destinationPosX = siemensNet.getByteTransform().TransInt16(resultRead.Content, 12); // short destinationPosY = siemensNet.getByteTransform().TransInt16(resultRead.Content, 14); // short destinationPosZ = siemensNet.getByteTransform().TransInt16(resultRead.Content, 16); // if (taskNo == 0 || taskMode == 0 || sourcePosX == 0 || sourcePosY == 0 || sourcePosZ == 0 || destinationPosX == 0 || destinationPosY == 0 || destinationPosZ == 0) { // result = siemensNet.Write(address, array); // } else { // break; // } // } else { // short ackFinish = siemensNet.getByteTransform().TransInt16(resultRead.Content, 0); // if (ackFinish != command.getAckFinish()) { // result = siemensNet.Write(address, array); // } else { // break; // } // } // } // idx++; // Thread.sleep(500); // } while (idx < 5); int idx = 0; do { OperateResultExOne<byte[]> resultRead = siemensNet.Read(address, (short) 18); if (resultRead.IsSuccess) { short taskNo = siemensNet.getByteTransform().TransInt16(resultRead.Content, 2); short taskMode = siemensNet.getByteTransform().TransInt16(resultRead.Content, 4); short sourcePosX = siemensNet.getByteTransform().TransInt16(resultRead.Content, 6); short sourcePosY = siemensNet.getByteTransform().TransInt16(resultRead.Content, 8); short sourcePosZ = siemensNet.getByteTransform().TransInt16(resultRead.Content, 10); short destinationPosX = siemensNet.getByteTransform().TransInt16(resultRead.Content, 12); short destinationPosY = siemensNet.getByteTransform().TransInt16(resultRead.Content, 14); short destinationPosZ = siemensNet.getByteTransform().TransInt16(resultRead.Content, 16); if (taskNo == 0 || taskMode == 0 || sourcePosX == 0 || sourcePosY == 0 || sourcePosZ == 0 || destinationPosX == 0 || destinationPosY == 0 || destinationPosZ == 0) { result = siemensNet.Write(address, array); } else { break; } } idx++; Thread.sleep(500); } while (idx < 5); // if (command.getAckFinish() == 0) { // short commandFinish = 1; // int i = 0; // do { // OperateResultExOne<byte[]> resultRead = siemensNet.Read(address, (short) 4); // OperateResultExOne<byte[]> resultReadConfirm = siemensNet.Read(address + 18, (short) 2); // if (resultRead.IsSuccess && resultReadConfirm.IsSuccess) { // short taskNo = siemensNet.getByteTransform().TransInt16(resultRead.Content, 2); // short confirm = siemensNet.getByteTransform().TransInt16(resultReadConfirm.Content, 0); // if (taskNo != 0 && confirm == 0) { // result = siemensNet.Write(address + 18, commandFinish); // } // } // i++; // Thread.sleep(500); // } while (i < 5); // } OperateResult confirmResult = siemensNet.Write(confirmAddress, (short) 1); if (!confirmResult.IsSuccess) { News.error("双工位堆垛机写入确认数据失败 ===>> [id:{}]", command.getCrnNo()); response.setMessage("双工位堆垛机写入确认数据失败"); return response; } // if (result != null && result.IsSuccess) { // News.info("SiemensDualCrn 双工位堆垛机命令下发[id:{}] >>>>> {}", command.getCrnNo(), JSON.toJSON(command)); // OutputQueue.CRN.offer(MessageFormat.format("【{0}】[id:{1}] >>>>> 命令下发: {2}", DateUtils.convert(new Date()), command.getCrnNo(), JSON.toJSON(command))); // response.setResult(true); // response.setMessage("命令下发成功"); // } else { // News.error("SiemensDualCrn 双工位堆垛机写入堆垛机plc数据失败 ===>> [id:{}]", command.getCrnNo()); // OutputQueue.CRN.offer(MessageFormat.format("【{0}】写入堆垛机plc数据失败 ===>> [id:{1}]", DateUtils.convert(new Date()), command.getCrnNo())); // response.setResult(false); // response.setMessage("命令下发失败"); // } if (result != null && result.IsSuccess) { News.info("双工位堆垛机命令下发[id:{}] >>>>> {}", command.getCrnNo(), JSON.toJSON(command)); OutputQueue.CRN.offer(MessageFormat.format("【{0}】[id:{1}] >>>>> 命令下发: {2}", DateUtils.convert(new Date()), command.getCrnNo(), JSON.toJSON(command))); response.setResult(true); response.setMessage("命令下发成功"); } else { News.error("双工位堆垛机写入堆垛机plc数据失败 ===>> [id:{}]", command.getCrnNo()); OutputQueue.CRN.offer(MessageFormat.format("【{0}】写入堆垛机plc数据失败 ===>> [id:{1}]", DateUtils.convert(new Date()), command.getCrnNo())); response.setResult(false); response.setMessage("命令下发失败"); } // return response; // } catch (Exception e) { // e.printStackTrace(); // }finally { // String sourceLocNo = Utils.getLocNo(command.getSourcePosX(), command.getSourcePosY(), command.getSourcePosZ()); // String targetLocNo = Utils.getLocNo(command.getDestinationPosX(), command.getDestinationPosY(), command.getDestinationPosZ()); return response; } catch (Exception e) { e.printStackTrace(); }finally { String sourceLocNo = Utils.getLocNo(command.getSourcePosX(), command.getSourcePosY(), command.getSourcePosZ()); String targetLocNo = Utils.getLocNo(command.getDestinationPosX(), command.getDestinationPosY(), command.getDestinationPosZ()); // // 日志记录 // BasCrnpOptService bean = SpringUtils.getBean(BasCrnpOptService.class); // BasCrnpOpt basCrnpOpt = new BasCrnpOpt( // command.getTaskNo().intValue(), // 任务号 // command.getCrnNo(), // 堆垛机[非空] // new Date(), // 下发时间 // String.valueOf(command.getTaskMode()), // 模式 // sourceLocNo, //源库位 // targetLocNo, //目标库位 // null, // 修改时间 // null, // 修改人员 // null, // 备注 // JSON.toJSONString(command), // 指令 // JSON.toJSONString(getStatus()), // 系统状态 // 1, // 下发状态{0:未下发,1:已下发} // JSON.toJSONString(response) // 响应 // ); // bean.insert(basCrnpOpt); // } // 日志记录 BasDualCrnpOptService bean = SpringUtils.getBean(BasDualCrnpOptService.class); BasDualCrnpOpt basDualCrnp = new BasDualCrnpOpt( command.getTaskNo(), // 任务号 command.getCrnNo(), // 堆垛机[非空] new Date(), // 下发时间 String.valueOf(command.getTaskMode()), // 模式 sourceLocNo, //源库位 targetLocNo, //目标库位 null, // 修改时间 null, // 修改人员 null, // 备注 JSON.toJSONString(command), // 指令 JSON.toJSONString(getStatus()), // 系统状态 1, // 下发状态{0:未下发,1:已下发} JSON.toJSONString(response) // 响应 ); bean.insert(basDualCrnp); } return response; } } src/main/java/com/zy/core/plugin/FakeProcess.java
@@ -23,6 +23,7 @@ import com.zy.core.model.protocol.CrnProtocol; import com.zy.core.model.protocol.DualCrnProtocol; import com.zy.core.model.protocol.StationProtocol; import com.zy.core.plugin.api.MainProcessPluginApi; import com.zy.core.properties.SystemProperties; import com.zy.core.thread.CrnThread; import com.zy.core.thread.DualCrnThread; src/main/java/com/zy/core/plugin/NormalProcess.java
@@ -1,5 +1,6 @@ package com.zy.core.plugin; import com.zy.core.plugin.api.MainProcessPluginApi; import com.zy.core.utils.CrnOperateProcessUtils; import com.zy.core.utils.StationOperateProcessUtils; import lombok.extern.slf4j.Slf4j; @@ -8,7 +9,7 @@ @Slf4j @Component public class NormalProcess implements MainProcessPluginApi{ public class NormalProcess implements MainProcessPluginApi { @Autowired private CrnOperateProcessUtils crnOperateUtils; src/main/java/com/zy/core/plugin/api/MainProcessPluginApi.java
File was renamed from src/main/java/com/zy/core/plugin/MainProcessPluginApi.java @@ -1,4 +1,4 @@ package com.zy.core.plugin; package com.zy.core.plugin.api; public interface MainProcessPluginApi { src/main/java/com/zy/core/thread/impl/ZySiemensCrnThread.java
@@ -107,13 +107,34 @@ crnProtocol.setWalkPos(0); crnProtocol.setLoaded(0); crnProtocol.setAlarm(0); crnProtocol.setXSpeed(0); crnProtocol.setYSpeed(0); crnProtocol.setZSpeed(0); crnProtocol.setXDistance(0); crnProtocol.setYDistance(0); crnProtocol.setXDuration(0); crnProtocol.setYDuration(0); crnProtocol.setXSpeed(0D); crnProtocol.setYSpeed(0D); crnProtocol.setZSpeed(0D); crnProtocol.setXDistance(0D); crnProtocol.setYDistance(0D); crnProtocol.setXDuration(0D); crnProtocol.setYDuration(0D); BasCrnpService basCrnpService = null; try { basCrnpService = SpringUtils.getBean(BasCrnpService.class); }catch (Exception e){ } if (basCrnpService != null) { BasCrnp basCrnp = basCrnpService.selectOne(new EntityWrapper<BasCrnp>().eq("crn_no", deviceConfig.getDeviceNo())); if(basCrnp == null) { basCrnp = new BasCrnp(); basCrnp.setCrnNo(deviceConfig.getDeviceNo()); basCrnp.setStatus(1); basCrnp.setInEnable("N"); basCrnp.setOutEnable("N"); basCrnp.setMaxInTask(5); basCrnp.setMaxOutTask(5); basCrnp.setCreateTime(new Date()); basCrnpService.insert(basCrnp); } } } @Override @@ -158,20 +179,6 @@ OutputQueue.CRN.offer(MessageFormat.format("【{0}】[id:{1}] <<<<< 实时数据更新成功",DateUtils.convert(new Date()), deviceConfig.getDeviceNo())); // // 复位信号 // if (!Cools.isEmpty(crnProtocol.getStatusType()) && crnProtocol.getStatusType().equals(CrnStatusType.WAITING)) { // if (resetFlag) { // if(crnProtocol.getTaskNo()==9999){ // backHpFlag = false; // } // CrnCommand crnCommand = new CrnCommand(); // crnCommand.setAckFinish((short)1); // if (write(crnCommand)) { // resetFlag = false; // } // } // } if (crnProtocol.getAlarm() > 0) { crnProtocol.setLastCommandTime(-1L); } @@ -192,27 +199,6 @@ redisUtil.set(RedisKeyType.DEVICE_LOG_KEY.key + System.currentTimeMillis(), deviceDataLog, 60 * 60 * 24); //更新采集时间 crnProtocol.setDeviceDataLog(System.currentTimeMillis()); } BasCrnpService basCrnpService = null; try { basCrnpService = SpringUtils.getBean(BasCrnpService.class); }catch (Exception e){ } if (basCrnpService != null) { BasCrnp basCrnp = basCrnpService.selectOne(new EntityWrapper<BasCrnp>().eq("crn_no", deviceConfig.getDeviceNo())); if(basCrnp == null) { basCrnp = new BasCrnp(); basCrnp.setCrnNo(deviceConfig.getDeviceNo()); basCrnp.setStatus(1); basCrnp.setInEnable("N"); basCrnp.setOutEnable("N"); basCrnp.setMaxInTask(5); basCrnp.setMaxOutTask(5); basCrnp.setCreateTime(new Date()); basCrnpService.insert(basCrnp); } } } src/main/java/com/zy/core/thread/impl/ZySiemensDualCrnThread.java
@@ -9,7 +9,6 @@ import com.zy.asrs.entity.*; import com.zy.asrs.service.BasDualCrnpOptService; import com.zy.asrs.service.BasDualCrnpService; import com.zy.asrs.service.WrkMastService; import com.zy.asrs.utils.Utils; import com.zy.common.utils.RedisUtil; import com.zy.core.News; @@ -257,6 +256,27 @@ crnProtocol.setYDistance(0); crnProtocol.setXDuration(0); crnProtocol.setYDuration(0); BasDualCrnpService basDualCrnpService = null; try { basDualCrnpService = SpringUtils.getBean(BasDualCrnpService.class); }catch (Exception e){ } if (basDualCrnpService != null) { BasDualCrnp basDualCrnp = basDualCrnpService.selectOne(new EntityWrapper<BasDualCrnp>().eq("crn_no", deviceConfig.getDeviceNo())); if(basDualCrnp == null) { basDualCrnp = new BasDualCrnp(); basDualCrnp.setCrnNo(deviceConfig.getDeviceNo()); basDualCrnp.setStatus(1); basDualCrnp.setInEnable("N"); basDualCrnp.setOutEnable("N"); basDualCrnp.setMaxInTask(5); basDualCrnp.setMaxOutTask(5); basDualCrnp.setCreateTime(new Date()); basDualCrnpService.insert(basDualCrnp); } } } @Override @@ -308,6 +328,8 @@ crnProtocol.setYDistance(crnStatus.getYDistance()); crnProtocol.setXDuration(crnStatus.getXDuration()); crnProtocol.setYDuration(crnStatus.getYDuration()); crnProtocol.setGoodsType(crnStatus.getGoodsType()); crnProtocol.setBarcode(crnStatus.getBarcode()); OutputQueue.DUAL_CRN.offer(MessageFormat.format("【{0}】[id:{1}] <<<<< 实时数据更新成功",DateUtils.convert(new Date()), deviceConfig.getDeviceNo())); @@ -331,27 +353,6 @@ redisUtil.set(RedisKeyType.DEVICE_LOG_KEY.key + System.currentTimeMillis(), deviceDataLog, 60 * 60 * 24); //更新采集时间 crnProtocol.setDeviceDataLog(System.currentTimeMillis()); } BasDualCrnpService basDualCrnpService = null; try { basDualCrnpService = SpringUtils.getBean(BasDualCrnpService.class); }catch (Exception e){ } if (basDualCrnpService != null) { BasDualCrnp basDualCrnp = basDualCrnpService.selectOne(new EntityWrapper<BasDualCrnp>().eq("crn_no", deviceConfig.getDeviceNo())); if(basDualCrnp == null) { basDualCrnp = new BasDualCrnp(); basDualCrnp.setCrnNo(deviceConfig.getDeviceNo()); basDualCrnp.setStatus(1); basDualCrnp.setInEnable("N"); basDualCrnp.setOutEnable("N"); basDualCrnp.setMaxInTask(5); basDualCrnp.setMaxOutTask(5); basDualCrnp.setCreateTime(new Date()); basDualCrnpService.insert(basDualCrnp); } } } src/main/java/com/zy/core/thread/impl/ZyStationThread.java
@@ -28,7 +28,6 @@ import java.text.MessageFormat; import java.util.*; import java.util.concurrent.ScheduledExecutorService; import lombok.Data; import lombok.extern.slf4j.Slf4j; src/main/java/com/zy/core/utils/DualCrnOperateProcessUtils.java
@@ -683,6 +683,7 @@ if (dualCrnProtocol.getTaskNo() == 0 && dualCrnProtocol.getLoaded() == 0 && dualCrnProtocol.getStatusType().equals(DualCrnStatusType.IDLE) && dualCrnProtocol.getTaskReceive() == 0 ) { idleStationList.add(1); } @@ -690,6 +691,7 @@ if (dualCrnProtocol.getTaskNoTwo() == 0 && dualCrnProtocol.getLoadedTwo() == 0 && dualCrnProtocol.getStatusTypeTwo().equals(DualCrnStatusType.IDLE) && dualCrnProtocol.getTaskReceiveTwo() == 0 ) { idleStationList.add(2); }