| | |
| | | import HslCommunication.Profinet.Siemens.SiemensPLCS; |
| | | import HslCommunication.Profinet.Siemens.SiemensS7Net; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.core.common.Cools; |
| | | import com.core.common.DateUtils; |
| | | import com.core.common.SpringUtils; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.entity.param.TaskOverToWms; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.common.utils.HttpHandler; |
| | | import com.zy.core.CrnThread; |
| | | import com.zy.core.cache.MessageQueue; |
| | | import com.zy.core.cache.OutputQueue; |
| | | import com.zy.core.enums.*; |
| | | import com.zy.core.model.CrnSlave; |
| | | import com.zy.core.model.Task; |
| | | import com.zy.core.model.command.CommandPackage; |
| | | import com.zy.core.model.command.CrnCommand; |
| | | import com.zy.core.model.protocol.CrnProtocol; |
| | | import lombok.Data; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | |
| | | import java.text.MessageFormat; |
| | | import java.util.*; |
| | | |
| | |
| | | private CrnSlave slave; |
| | | private CrnProtocol crnProtocol; |
| | | private boolean resetFlag = false; |
| | | |
| | | @Value("${wms.url}") |
| | | private String wmsUrl; |
| | | public static final List<Short> rowOne = new ArrayList<Short>() {{ |
| | | add((short) 1);add((short) 5);add((short) 7);add((short) 11);add((short) 15);add((short) 19); |
| | | }}; |
| | | public static final List<Short> rowTwo = new ArrayList<Short>() {{ |
| | | add((short) 2);add((short) 6);add((short) 8);add((short) 12);add((short) 16);add((short) 20); |
| | | }}; |
| | | public static final List<Short> rowThree = new ArrayList<Short>() {{ |
| | | add((short) 3);add((short) 9);add((short) 13);add((short) 17);add((short) 21); |
| | | }}; |
| | | public static final List<Short> rowFour = new ArrayList<Short>() {{ |
| | | add((short) 4);add((short) 10);add((short) 14);add((short) 18); |
| | | }}; |
| | | |
| | | |
| | | public SiemensCrnThread(CrnSlave slave) { |
| | | this.slave = slave; |
| | |
| | | break; |
| | | // 写入数据 |
| | | case 2: |
| | | write2((CrnCommand) task.getData()); |
| | | write5((CrnCommand) task.getData()); |
| | | break; |
| | | // 复位 |
| | | case 3: |
| | |
| | | crnCommand.setAckFinish((short)1); |
| | | if (write(crnCommand)) { |
| | | resetFlag = false; |
| | | |
| | | //堆垛机任务完成后访问wms请求任务完成 locationDone 货位处理完成 |
| | | TaskWrkService taskWrkService = SpringUtils.getBean(TaskWrkService.class); |
| | | TaskWrk taskWrk = taskWrkService.selectOne(new EntityWrapper<TaskWrk>().eq("wrk_no",crnProtocol.getTaskNo())); |
| | | String tasktype = null; |
| | | switch (taskWrk.getIoType()){ |
| | | case 1: |
| | | tasktype= "RK"; |
| | | break; |
| | | case 2: |
| | | tasktype= "CK"; |
| | | break; |
| | | case 3: |
| | | tasktype= "YK"; |
| | | break; |
| | | default: |
| | | tasktype= "未知"; |
| | | } |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("x-api-key","7a15b5db-29b6-552c-8cff-0cfec3756da2"); |
| | | TaskOverToWms taskOverToWms = new TaskOverToWms(); |
| | | taskOverToWms.setFeedbackFrom("WCS"); //来源 |
| | | taskOverToWms.setWarehouseId("1688469798893297665"); //仓库标识 |
| | | taskOverToWms.setTaskNo(taskWrk.getTaskNo()); //任务号 |
| | | taskOverToWms.setTaskType(tasktype); // 任务类型 |
| | | taskOverToWms.setContainerCode(taskWrk.getBarcode()); // 容器编码 |
| | | if (taskWrk.getIoType() ==1){ |
| | | taskOverToWms.setEquipmentCode(String.valueOf(taskWrk.getCrnNo())); //设备编码 |
| | | taskOverToWms.setTargetLocationCode(taskWrk.getOriginTargetPoint()); //目标库位 |
| | | }else if (taskWrk.getIoType() ==2){ |
| | | Map<Integer,String> map1 = new HashMap<>(); |
| | | map1.put(102,"J-1101"); |
| | | map1.put(106,"J-1103"); |
| | | map1.put(110,"J-1105"); |
| | | map1.put(114,"J-1107"); |
| | | map1.put(118,"J-1109"); |
| | | map1.put(122,"J-1111"); |
| | | map1.put(305,"H-1101"); |
| | | map1.put(405,"G-1101"); |
| | | taskOverToWms.setEquipmentCode(map1.get(taskWrk.getTargetPoint())); //设备编码 |
| | | taskOverToWms.setSourceLocationCode(taskWrk.getOriginStartPoint()); //源库位 |
| | | } else if (taskWrk.getIoType() == 3) { |
| | | taskOverToWms.setEquipmentCode(String.valueOf(taskWrk.getCrnNo())); //设备编码 |
| | | taskOverToWms.setSourceLocationCode(taskWrk.getOriginStartPoint()); |
| | | taskOverToWms.setTargetLocationCode(taskWrk.getOriginTargetPoint()); //目标库位 |
| | | } |
| | | taskOverToWms.setTaskStatus("location_done"); //任务状态 |
| | | String response = null; |
| | | try { |
| | | response = new HttpHandler.Builder() |
| | | .setHeaders(map) |
| | | .setUri("10.32.53.195:8080") |
| | | .setPath("wcsManager/wcsInterface/taskStatusFeedback") |
| | | .setJson(JSON.toJSONString(taskOverToWms)) |
| | | .build() |
| | | .doPost(); |
| | | }catch (Exception e){ |
| | | log.error("堆垛机任务完成,请求wms任务完成接口失败"); |
| | | } |
| | | ApiLogService apiLogService = SpringUtils.getBean(ApiLogService.class); |
| | | apiLogService.save("Wms任务完成接口" |
| | | ,"10.32.53.195:8080"+"/wcsManager/wcsInterface/taskStatusFeedback" |
| | | ,null |
| | | ,"127.0.0.1" |
| | | ,JSON.toJSONString(taskOverToWms) |
| | | ,response |
| | | ,true |
| | | ); |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | if (jsonObject.getInteger("code").equals(200)){ |
| | | if (taskWrk.getIoType() == 3){ |
| | | taskWrk.setWrkSts(4); |
| | | } |
| | | taskWrk.setStatus(5); |
| | | if (!taskWrkService.update(taskWrk,new EntityWrapper<TaskWrk>().eq("wrk_no",crnProtocol.getTaskNo()))){ |
| | | log.error("堆垛机任务完成,改变任务状态失败"); |
| | | } |
| | | |
| | | log.info("堆垛机任务完成,请求wms任务完成接口成功"); |
| | | }else { |
| | | log.error("堆垛机任务完成,请求wms任务完成接口完成,但返回失败"); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | command.setCrnNo(slave.getId()); |
| | | short[] array = new short[10]; |
| | | if (Cools.isEmpty(command.getAckFinish())) { |
| | | array[0] = 5; |
| | | } else { |
| | | array[0] = command.getAckFinish(); |
| | | } |
| | | array[0] = command.getAckFinish(); |
| | | array[1] = command.getTaskNo(); |
| | | array[2] = command.getTaskMode(); |
| | | array[3] = command.getSourcePosX(); |
| | |
| | | // 作业信息 |
| | | OperateResult result = siemensNet.Write("DB100.0", array); |
| | | |
| | | if (command.getAckFinish() != 1) { |
| | | |
| | | if (result.IsSuccess) { |
| | | log.warn("堆垛机命令下发[id:{},时间:{}] >>>>> {}", slave.getId(), DateUtils.convert(new Date(), DateUtils.yyyyMMddHHmmsssss_F), JSON.toJSON(command)); |
| | | OutputQueue.CRN.offer(MessageFormat.format("【{0}】[id:{1}] >>>>> 命令下发: {2}", DateUtils.convert(new Date()), slave.getId(), JSON.toJSON(command))); |
| | | return true; |
| | | } else { |
| | | OutputQueue.CRN.offer(MessageFormat.format("【{0}】写入堆垛机plc数据失败 ===>> [id:{1}] [ip:{2}] [port:{3}] [rack:{4}] [slot:{5}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot())); |
| | | log.error("写入堆垛机plc数据失败 ===>> [id:{}] [ip:{}] [port:{}] [rack:{}] [slot:{}]", slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot()); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 写入数据 |
| | | */ |
| | | private synchronized boolean write5(CrnCommand command) throws InterruptedException { |
| | | String methodName = Thread.currentThread().getStackTrace()[1].getMethodName(); |
| | | |
| | | if (null == command) { |
| | | log.error("堆垛机写入命令为空"); |
| | | return false; |
| | | } |
| | | // convertRow(command); |
| | | command.setCrnNo(slave.getId()); |
| | | short[] array = new short[10]; |
| | | array[0] = command.getAckFinish(); |
| | | 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.getSourceStaNo(); |
| | | // array[10] = command.getDestinationStaNo(); |
| | | array[9] = command.getCommand(); |
| | | OperateResult result18 = siemensNet.Write("DB100.18", (short)0); |
| | | Thread.sleep(100L); |
| | | OperateResult result = siemensNet.Write("DB100.0", array); |
| | | |
| | | int i=0; |
| | | do{ |
| | | //堆垛机任务写入后,回读一次,看是否成功 |
| | | Thread.sleep(100); |
| | | OperateResultExOne<byte[]> resultRead = siemensNet.Read("DB100.0", (short) 20); |
| | | if (resultRead.IsSuccess) { |
| | | CrnCommand one = new CrnCommand(); |
| | | one.setTaskNo(siemensNet.getByteTransform().TransInt16(resultRead.Content, 2)); |
| | | one.setTaskMode(siemensNet.getByteTransform().TransInt16(resultRead.Content, 4)); |
| | | one.setSourcePosX(siemensNet.getByteTransform().TransInt16(resultRead.Content, 6)); |
| | | one.setSourcePosY(siemensNet.getByteTransform().TransInt16(resultRead.Content, 8)); |
| | | one.setSourcePosZ(siemensNet.getByteTransform().TransInt16(resultRead.Content, 10)); |
| | | one.setDestinationPosX(siemensNet.getByteTransform().TransInt16(resultRead.Content, 12)); |
| | | one.setDestinationPosY(siemensNet.getByteTransform().TransInt16(resultRead.Content, 14)); |
| | | one.setDestinationPosZ(siemensNet.getByteTransform().TransInt16(resultRead.Content, 16)); |
| | | if (!command.getTaskNo().equals(one.getTaskNo()) || !command.getTaskMode().equals(one.getTaskMode()) |
| | | || !command.getSourcePosX().equals(one.getSourcePosX()) || !command.getSourcePosY().equals(one.getSourcePosY()) |
| | | || !command.getSourcePosZ().equals(one.getSourcePosZ()) || !command.getDestinationPosX().equals(one.getDestinationPosX()) |
| | | || !command.getDestinationPosY().equals(one.getDestinationPosY()) || !command.getDestinationPosZ().equals(one.getDestinationPosZ()) |
| | | ){ |
| | | i++; |
| | | log.error("堆垛机命令地址写入后回读失败[id:{}]>>>>重写[{}] >>>>> 写入[{}],===>>回读[{}]", slave.getId(), i,JSON.toJSON(command),JSON.toJSON(one)); |
| | | result = siemensNet.Write("DB100.0", array); |
| | | }else{ |
| | | break; |
| | | } |
| | | } |
| | | }while(i<5); |
| | | |
| | | if (command.getAckFinish() == 0) { |
| | | short commandFinish = 1; |
| | | Thread.sleep(100L); |
| | | result = siemensNet.Write("DB100.18", commandFinish); |
| | | int signFinish = 1; |
| | | while (signFinish<5){ |
| | | OperateResultExOne<byte[]> result10018 = siemensNet.Read("DB100.18", (short) 2); |
| | | short transInt16 = siemensNet.getByteTransform().TransInt16(result10018.Content, 0); |
| | | if (transInt16 != commandFinish){ |
| | | log.info("下发DB100.18 回读失败" + "commandFinish:"+commandFinish); |
| | | log.info("下发DB100.18 回读失败" + "array:"+ JSON.toJSONString(array)); |
| | | result = siemensNet.Write("DB100.18", commandFinish); |
| | | signFinish++; |
| | | }else { |
| | | log.info("下发DB100.18" + "commandFinish:"+commandFinish); |
| | | log.info("下发DB100.18" + "array:"+ JSON.toJSONString(array)); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | try { |
| | | // 日志记录 |
| | | BasCrnOptService bean = SpringUtils.getBean(BasCrnOptService.class); |
| | | BasCrnOpt basCrnOpt = new BasCrnOpt( |
| | | command.getTaskNo().intValue(), // 任务号 |
| | | command.getCrnNo(), // 堆垛机[非空] |
| | | new Date(), // 下发时间 |
| | | command.getTaskModeType() == null ? null : command.getTaskModeType().toString(), // 模式 |
| | | command.getSourcePosZ().intValue(), // 源排 |
| | | command.getSourcePosX().intValue(), // 源列 |
| | | command.getSourcePosY().intValue(), // 源层 |
| | | command.getTaskModeType().toString(), // 模式 |
| | | command.getSourcePosX().intValue(), // 源排 |
| | | command.getSourcePosY().intValue(), // 源列 |
| | | command.getSourcePosZ().intValue(), // 源层 |
| | | null, // 源站 |
| | | command.getDestinationPosZ().intValue(), // 目标排 |
| | | command.getDestinationPosX().intValue(), // 目标列 |
| | | command.getDestinationPosY().intValue(), // 目标层 |
| | | command.getDestinationPosX().intValue(), // 目标排 |
| | | command.getDestinationPosY().intValue(), // 目标列 |
| | | command.getDestinationPosZ().intValue(), // 目标层 |
| | | null, // 目标站 |
| | | null, // 响应结果 |
| | | null, // 修改时间 |
| | | null // 修改人员 |
| | | ); |
| | | bean.insert(basCrnOpt); |
| | | } |
| | | } catch (Exception ignore) {} |
| | | |
| | | if (result.IsSuccess) { |
| | | // log.warn("堆垛机命令下发[id:{},时间:{}] >>>>> {}", slave.getId(), DateUtils.convert(new Date(), DateUtils.yyyyMMddHHmmsssss_F), JSON.toJSON(command)); |
| | | // OutputQueue.CRN.offer(MessageFormat.format("【{0}】[id:{1}] >>>>> 命令下发: {2}", DateUtils.convert(new Date()), slave.getId(), JSON.toJSON(command))); |
| | | // return true; |
| | | if (result != null && result.IsSuccess) { |
| | | Thread.sleep(300); |
| | | this.readStatus(); |
| | | log.info(methodName + ":堆垛机命令下发[id:{}] >>>>> {}", slave.getId(), JSON.toJSON(command)); |
| | | OutputQueue.CRN.offer(MessageFormat.format("【{0}】[id:{1}] >>>>> 命令下发: {2}", DateUtils.convert(new Date()), slave.getId(), JSON.toJSON(command))); |
| | | return true; |
| | | } else { |
| | | OutputQueue.CRN.offer(MessageFormat.format("【{0}】写入堆垛机plc数据失败 ===>> [id:{1}] [ip:{2}] [port:{3}] [rack:{4}] [slot:{5}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot())); |
| | | log.error("写入堆垛机plc数据失败 ===>> [id:{}] [ip:{}] [port:{}] [rack:{}] [slot:{}]", slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot()); |
| | | OutputQueue.CRN.offer(MessageFormat.format("【{0}】写入堆垛机plc数据失败 ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort())); |
| | | log.error(methodName + ":写入堆垛机plc数据失败 ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort()); |
| | | return false; |
| | | } |
| | | |
| | | |
| | | try{ |
| | | //堆垛机任务写入后,回读一次,看是否成功 |
| | | Thread.sleep(500); |
| | | OperateResultExOne<byte[]> resultRead = siemensNet.Read("DB100.0", (short) 24); |
| | | if (resultRead.IsSuccess) { |
| | | CrnCommand one = new CrnCommand(); |
| | | one.setAckFinish(siemensNet.getByteTransform().TransInt16(resultRead.Content, 0)); |
| | | one.setTaskNo(siemensNet.getByteTransform().TransInt16(resultRead.Content, 2)); |
| | | //one.setTaskMode(siemensNet.getByteTransform().TransInt16(resultRead.Content, 4)); |
| | | one.setSourcePosZ(siemensNet.getByteTransform().TransInt16(resultRead.Content, 6)); |
| | | one.setSourcePosX(siemensNet.getByteTransform().TransInt16(resultRead.Content, 8)); |
| | | one.setSourcePosY(siemensNet.getByteTransform().TransInt16(resultRead.Content, 10)); |
| | | one.setDestinationPosZ(siemensNet.getByteTransform().TransInt16(resultRead.Content, 12)); |
| | | one.setDestinationPosX(siemensNet.getByteTransform().TransInt16(resultRead.Content, 14)); |
| | | one.setDestinationPosY(siemensNet.getByteTransform().TransInt16(resultRead.Content, 16)); |
| | | // one.setSourceStaNo(siemensNet.getByteTransform().TransInt16(resultRead.Content, 18)); |
| | | // one.setDestinationStaNo(siemensNet.getByteTransform().TransInt16(resultRead.Content, 20)); |
| | | if (!crnCommand.getTaskNo().equals(one.getTaskNo()) || !crnCommand.getAckFinish().equals(one.getAckFinish()) |
| | | || !crnCommand.getSourcePosZ().equals(one.getSourcePosZ()) || !crnCommand.getSourcePosX().equals(one.getSourcePosX()) || !crnCommand.getSourcePosY().equals(one.getSourcePosY()) |
| | | || !crnCommand.getDestinationPosZ().equals(one.getDestinationPosZ()) || !crnCommand.getDestinationPosX().equals(one.getDestinationPosX()) || !crnCommand.getDestinationPosY().equals(one.getDestinationPosY()) |
| | | ){ |
| | | log.error("堆垛机命令地址写入后回读失败[id:{}] >>>>> 写入[{}],===>>回读[{}]", slave.getId(), JSON.toJSON(command),JSON.toJSON(one)); |
| | | log.error("堆垛机命令回读失败后,重新添加任务到队列 ===>> [id:{}],{}", slave.getId(), JSON.toJSON(crnCommand)); |
| | | MessageQueue.offer(SlaveType.Crn, slave.getId(), new Task(5, crnCommand)); |
| | | Thread.sleep(100); |
| | | readStatus(); |
| | | return false; |
| | | } else { |
| | | log.info("堆垛机命令地址写入后回读成功[id:{}] >>>>> 写入[{}],===>>回读[{}]", slave.getId(), JSON.toJSON(command),JSON.toJSON(one)); |
| | | OutputQueue.CRN.offer(MessageFormat.format("【{0}】[id:{1}] >>>>> 命令下发: {2}", DateUtils.convert(new Date()), slave.getId(), JSON.toJSON(command))); |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | log.error("堆垛机命令地址写入后回读出错"); |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | CommandInfoLog commandInfoLog = JSON.parseObject(JSON.toJSONString(commandInfo), CommandInfoLog.class); |
| | | commandInfoLog.setId(null); |
| | | // CommandInfoLog commandInfoLog = new CommandInfoLog(); |
| | | // if (commandInfo != null) { |
| | | // commandInfoLog = JSON.parseObject(JSON.toJSONString(commandInfo), CommandInfoLog.class); |
| | | // commandInfoLog.setId(null); |
| | | // }else { |
| | | // Date now = new Date(); |
| | | // commandInfoLog.setCommand(JSON.toJSONString(command)); |
| | | // commandInfoLog.setCommandStatus(3); |
| | | // commandInfoLog.setStartTime(now); |
| | | // commandInfoLog.setExecuteTime(now); |
| | | // commandInfoLog.setCompleteTime(now); |
| | | // commandInfoLog.setDevice(SlaveType.Devp.toString()); |
| | | // commandInfoLog.setWrkNo(9999); |
| | | // commandInfoLog.setTaskNo("9999"); |
| | | // commandInfoLog.setCommandDesc("手动命令"); |
| | | // } |
| | | |
| | | |
| | | if (result.IsSuccess) { |
| | | // log.warn("堆垛机命令下发[id:{},时间:{}] >>>>> {}", slave.getId(), DateUtils.convert(new Date(), DateUtils.yyyyMMddHHmmsssss_F), JSON.toJSON(command)); |
| | | |
| | | Date now = new Date(); |
| | | //更新指令日志 |
| | | commandInfoLog.setDeviceLog("指令下发成功"); |
| | |
| | | } else { |
| | | OutputQueue.CRN.offer(MessageFormat.format("【{0}】写入堆垛机plc数据失败 ===>> [id:{1}] [ip:{2}] [port:{3}] [rack:{4}] [slot:{5}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot())); |
| | | log.error("写入堆垛机plc数据失败 ===>> [id:{}] [ip:{}] [port:{}] [rack:{}] [slot:{}]", slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot()); |
| | | |
| | | //更新指令日志 |
| | | commandInfoLog.setDeviceLog("指令下发失败"); |
| | | commandInfoLogService.insert(commandInfoLog); |
| | | return false; |
| | | } |
| | | try{ |
| | | //堆垛机任务写入后,回读一次,看是否成功 |
| | | Thread.sleep(500); |
| | | OperateResultExOne<byte[]> resultRead = siemensNet.Read("DB100.0", (short) 24); |
| | | if (resultRead.IsSuccess) { |
| | | CrnCommand one = new CrnCommand(); |
| | | one.setAckFinish(siemensNet.getByteTransform().TransInt16(resultRead.Content, 0)); |
| | | one.setTaskNo(siemensNet.getByteTransform().TransInt16(resultRead.Content, 2)); |
| | | //one.setTaskMode(siemensNet.getByteTransform().TransInt16(resultRead.Content, 4)); |
| | | one.setSourcePosZ(siemensNet.getByteTransform().TransInt16(resultRead.Content, 6)); |
| | | one.setSourcePosX(siemensNet.getByteTransform().TransInt16(resultRead.Content, 8)); |
| | | one.setSourcePosY(siemensNet.getByteTransform().TransInt16(resultRead.Content, 10)); |
| | | one.setDestinationPosZ(siemensNet.getByteTransform().TransInt16(resultRead.Content, 12)); |
| | | one.setDestinationPosX(siemensNet.getByteTransform().TransInt16(resultRead.Content, 14)); |
| | | one.setDestinationPosY(siemensNet.getByteTransform().TransInt16(resultRead.Content, 16)); |
| | | // one.setSourceStaNo(siemensNet.getByteTransform().TransInt16(resultRead.Content, 18)); |
| | | // one.setDestinationStaNo(siemensNet.getByteTransform().TransInt16(resultRead.Content, 20)); |
| | | if (!crnCommand.getTaskNo().equals(one.getTaskNo()) && !crnCommand.getAckFinish().equals(one.getAckFinish()) |
| | | && !crnCommand.getSourcePosZ().equals(one.getSourcePosZ()) && !crnCommand.getSourcePosX().equals(one.getSourcePosX()) && !crnCommand.getSourcePosY().equals(one.getSourcePosY()) |
| | | && !crnCommand.getDestinationPosZ().equals(one.getDestinationPosZ()) && !crnCommand.getDestinationPosX().equals(one.getDestinationPosX()) && !crnCommand.getDestinationPosY().equals(one.getDestinationPosY()) |
| | | ){ |
| | | log.error("堆垛机命令地址写入后回读失败[id:{}] >>>>> 写入[{}],===>>回读[{}]", slave.getId(), JSON.toJSON(command),JSON.toJSON(one)); |
| | | log.error("堆垛机命令回读失败后,重新添加任务到队列 ===>> [id:{}],{}", slave.getId(), JSON.toJSON(crnCommand)); |
| | | MessageQueue.offer(SlaveType.Crn, slave.getId(), new Task(5, crnCommand)); |
| | | Thread.sleep(100); |
| | | readStatus(); |
| | | return false; |
| | | } else { |
| | | log.info("堆垛机命令地址写入后回读成功[id:{}] >>>>> 写入[{}],===>>回读[{}]", slave.getId(), JSON.toJSON(command),JSON.toJSON(one)); |
| | | OutputQueue.CRN.offer(MessageFormat.format("【{0}】[id:{1}] >>>>> 命令下发: {2}", DateUtils.convert(new Date()), slave.getId(), JSON.toJSON(command))); |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | log.error("堆垛机命令地址写入后回读出错"); |
| | | } |
| | | return true; |
| | | } |