|  |  | 
 |  |  | import lombok.extern.slf4j.Slf4j; | 
 |  |  |  | 
 |  |  | import java.text.MessageFormat; | 
 |  |  | import java.util.Calendar; | 
 |  |  | import java.util.Date; | 
 |  |  |  | 
 |  |  | /** | 
 |  |  | 
 |  |  |             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("堆垛机plc连接失败!!! ===>> [id:{}] [ip:{}] [port:{}] ", slave.getId(), slave.getIp(), slave.getPort()); | 
 |  |  |         } | 
 |  |  |         // 命令下发区 -------------------------------------------------------------------------- | 
 |  |  |         /** | 
 |  |  |          *      array[1] = command.getSourcePosY(); // 列 | 
 |  |  |          *         array[2] = command.getSourcePosZ(); // 层 | 
 |  |  |          *         array[3] = command.getSourcePosX(); // 排 | 
 |  |  |          *         array[4] = command.getDestinationPosY(); // 列 | 
 |  |  |          *         array[5] = command.getDestinationPosZ();  // 层 | 
 |  |  |          *         array[6] = command.getDestinationPosX(); // 排 | 
 |  |  |          *         array[7] = command.getTaskNo(); | 
 |  |  |          */ | 
 |  |  |         Date date = new Date(); | 
 |  |  |         Calendar cal = Calendar.getInstance(); | 
 |  |  |         cal.setTime(date); | 
 |  |  |         CrnCommand crnCommand = new CrnCommand(); | 
 |  |  |         crnCommand.setCrnNo(slave.getId()); // 堆垛机编号 | 
 |  |  |         crnCommand.setTaskMode(CrnTaskModeType.TIMING); // 任务模式:  设置时间 | 
 |  |  |         crnCommand.setSourcePosY((short) cal.get(Calendar.YEAR));     // 年:1980~2079 | 
 |  |  |         crnCommand.setSourcePosZ((short) (cal.get(Calendar.MONTH)+1));     // 月:1~12 | 
 |  |  |         crnCommand.setSourcePosX((short) cal.get(Calendar.DATE));     // 日:1~31 | 
 |  |  |         crnCommand.setDestinationPosY((short) cal.get(Calendar.HOUR_OF_DAY));     // 时:0~23 | 
 |  |  |         crnCommand.setDestinationPosZ((short) cal.get(Calendar.MINUTE));     // 分:0~59 | 
 |  |  |         crnCommand.setDestinationPosX((short) cal.get(Calendar.SECOND));     // 秒:0~59 | 
 |  |  |         crnCommand.setTaskNo((short) (cal.get(Calendar.DAY_OF_WEEK) - 1));     // 星期:0(日)~6(六) | 
 |  |  |         crnCommand.setTaskSend((short) 1); | 
 |  |  |         crnCommand.setAckFinish((short) 0); | 
 |  |  |         if (write(crnCommand)) { | 
 |  |  |             log.info("堆垛机plc校对时间成功 ===>> [id:{}] [ip:{}] [port:{}] ", slave.getId(), slave.getIp(), slave.getPort()); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         melsecMcNet.ConnectClose(); | 
 |  |  |         return result; | 
 |  |  |     } |