| | |
| | | import HslCommunication.Profinet.Siemens.SiemensPLCS; |
| | | import HslCommunication.Profinet.Siemens.SiemensS7Net; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.core.common.Cools; |
| | | import com.core.common.DateUtils; |
| | | import com.core.common.SpringUtils; |
| | | import com.zy.asrs.entity.BasRgv; |
| | |
| | | // commandAvoidanceXY.setDestinationStaNo2((short)0); // 目标站 |
| | | commandAvoidanceXY.setCommand((short)0); |
| | | write(commandAvoidanceXY); |
| | | break; |
| | | case 10: |
| | | write10((String) task.getData()); |
| | | break; |
| | | //单机写入数据 |
| | | case 11: |
| | | write11((RgvCommand) task.getData()); |
| | | break; |
| | | default: |
| | | break; |
| | |
| | | } |
| | | } |
| | | |
| | | //小车强制、复位、报警消音、启动、停止、急停、复位、手动、手动定位、单机、联机、货叉回中 |
| | | private boolean write10(String status) throws InterruptedException { |
| | | if (Cools.isEmpty(status)) { |
| | | log.error("RGV写入命令为空"); |
| | | return false; |
| | | } |
| | | OperateResult result = siemensNet.Write("DB19."+status, true); |
| | | if (result != null && result.IsSuccess) { |
| | | Thread.sleep(200); |
| | | this.readStatus(); |
| | | log.info("RGV 命令下发[id:{}] >>>>> {}", slave.getId(), JSON.toJSON("DB19."+status)); |
| | | OutputQueue.RGV.offer(MessageFormat.format("【{0}】[id:{1}] >>>>> 命令下发: {2}", DateUtils.convert(new Date()), slave.getId(), "DB19."+status)); |
| | | return true; |
| | | } else { |
| | | OutputQueue.RGV.offer(MessageFormat.format("【{0}】写入RGV plc数据失败 ===>> [id:{1}] [ip:{2}] [port:{3}] [DB块:{4}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort(), "DB19."+status)); |
| | | log.error("写入RGV plc数据失败 ===>> [id:{}] [ip:{}] [port:{}] [DB块:{4}]", slave.getId(), slave.getIp(), slave.getPort(), "DB19."+status); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | //单步任务 |
| | | private boolean write11(RgvCommand command) throws InterruptedException { |
| | | if (null == command) { |
| | | log.error("RGV写入命令为空"); |
| | | return false; |
| | | } |
| | | String status = ""; |
| | | command.setRgvNo(slave.getId()); |
| | | short[] array = new short[2]; |
| | | array[0] = command.getDestinationStaNo1(); |
| | | array[1] = command.getSourceStaNo1(); |
| | | |
| | | OperateResult result = siemensNet.Write("DB19.0", array); |
| | | if (command.getTaskMode1().equals(RgvTaskModeType.FETCH.id.shortValue())){ |
| | | status = "4.1"; |
| | | } else if (command.getTaskMode1().equals(RgvTaskModeType.PUT.id.shortValue())){ |
| | | status = "4.2"; |
| | | } else if (command.getTaskMode1().equals(RgvTaskModeType.X_MOVE.id.shortValue())){ |
| | | status = "4.0"; |
| | | } else if (command.getTaskMode1().equals(RgvTaskModeType.FETCH_PUT.id.shortValue())){ |
| | | status = "4.3"; |
| | | } else { |
| | | OutputQueue.RGV.offer(MessageFormat.format("【{0}】写入RGV plc数据失败 ===>> [id:{1}] [ip:{2}] [port:{3}] [DB块:{4}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort(), "DB19."+status)); |
| | | log.error("写入RGV plc数据失败 未知任务类型 ===>> [id:{}] [ip:{}] [port:{}] [DB块:{4}]", slave.getId(), slave.getIp(), slave.getPort(), "DB19."+status); |
| | | return false; |
| | | } |
| | | OperateResult result1 = siemensNet.Write("DB19."+status, true); |
| | | if (result != null && result.IsSuccess && result1 != null && result1.IsSuccess) { |
| | | Thread.sleep(200); |
| | | this.readStatus(); |
| | | log.info("RGV 命令下发[id:{}] >>>>> {}", slave.getId(), JSON.toJSON("DB19."+status)); |
| | | OutputQueue.RGV.offer(MessageFormat.format("【{0}】[id:{1}] >>>>> 命令下发: {2}", DateUtils.convert(new Date()), slave.getId(), "DB19."+status)); |
| | | return true; |
| | | } else { |
| | | OutputQueue.RGV.offer(MessageFormat.format("【{0}】写入RGV plc数据失败 ===>> [id:{1}] [ip:{2}] [port:{3}] [DB块:{4}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort(), "DB19."+status)); |
| | | log.error("写入RGV plc数据失败 ===>> [id:{}] [ip:{}] [port:{}] [DB块:{4}]", slave.getId(), slave.getIp(), slave.getPort(), "DB19."+status); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void close() { |
| | | siemensNet.ConnectClose(); |