| | |
| | | import com.zy.core.cache.MessageQueue; |
| | | import com.zy.core.cache.OutputQueue; |
| | | import com.zy.core.enums.SlaveType; |
| | | import com.zy.core.enums.SteStatusType; |
| | | import com.zy.core.model.SteSlave; |
| | | import com.zy.core.model.Task; |
| | | import com.zy.core.model.command.SteCommand; |
| | |
| | | OutputQueue.CRN.offer(MessageFormat.format("【{0}】[id:{1}] <<<<< 实时数据更新成功",DateUtils.convert(new Date()), slave.getId())); |
| | | |
| | | // 复位信号 |
| | | if (steProtocol.getStatusType().equals(SteStatusType.WAITING)) { |
| | | if (steProtocol.getWaiting()) { |
| | | if (resetFlag) { |
| | | SteCommand steCommand = new SteCommand(); |
| | | // steCommand.setAckFinish((short)1); |
| | | steCommand.setComplete(true); |
| | | if (write(steCommand) && confirmPos()) { |
| | | resetFlag = false; |
| | | } |
| | |
| | | return false; |
| | | } |
| | | command.setSteNo(slave.getId()); |
| | | short[] array = new short[10]; |
| | | // array[0] = command.getAckFinish(); |
| | | // array[1] = command.getTaskNo(); |
| | | // array[2] = command.getTaskMode(); |
| | | // array[3] = command.getSourcePosX(); |
| | | OperateResult result = null; |
| | | // 开始任务 |
| | | if (!command.getComplete()) { |
| | | OperateResult result0 = siemensS7Net.Write("D0", command.getTaskNo()); |
| | | short[] array = new short[10]; |
| | | array[0] = command.getTaskMode(); |
| | | // 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 = siemensS7Net.Write("D0", array); |
| | | |
| | | // if (command.getAckFinish() == 0) { |
| | | // short commandFinish = 1; |
| | | // result = siemensS7Net.Write("D9", commandFinish); |
| | | // } |
| | | OperateResult result1 = siemensS7Net.Write("D0", array); |
| | | // 确认开始任务 |
| | | if (result0.IsSuccess) { |
| | | result = siemensS7Net.Write("D0", true); |
| | | } |
| | | // 任务完成 |
| | | } else { |
| | | result = siemensS7Net.Write("D0", true); |
| | | } |
| | | |
| | | try { |
| | | // 日志记录 |
| | |
| | | // bean.insert(basSteOpt); |
| | | } catch (Exception ignore) {} |
| | | |
| | | if (result.IsSuccess) { |
| | | if (result != null && result.IsSuccess) { |
| | | // 维护数据库排列层 |
| | | // this.modifyPos(); |
| | | if (!steProtocol.getWaiting()) { |
| | | this.lastRow = command.getRow().intValue(); |
| | | this.lastBay = command.getBay().intValue(); |
| | | this.lastLev = command.getLev().intValue(); |
| | | } |
| | | |
| | | |
| | | log.info("穿梭车命令下发[id:{}] >>>>> {}", slave.getId(), JSON.toJSON(command)); |
| | | OutputQueue.CRN.offer(MessageFormat.format("【{0}】[id:{1}] >>>>> 命令下发: {2}", DateUtils.convert(new Date()), slave.getId(), JSON.toJSON(command))); |
| | |
| | | BasSteService service = SpringUtils.getBean(BasSteService.class); |
| | | BasSte basSte = service.selectById(slave.getId()); |
| | | if (basSte != null) { |
| | | if (service.updatePos(this.lastRow, this.lastBay, this.lastLev) > 0) { |
| | | return true; |
| | | } else { |
| | | log.error("{}号穿梭车修改数据库定位失败!!!", slave.getId()); |
| | | // 更新plc数据块 |
| | | short[] arr = new short[] {this.lastRow.shortValue(), this.lastBay.shortValue(), this.lastLev.shortValue()}; |
| | | OperateResult result = siemensS7Net.Write("D0", arr); |
| | | if (result.IsSuccess) { |
| | | // 更新数据库 |
| | | if (service.updatePos(this.lastRow, this.lastBay, this.lastLev) > 0) { |
| | | this.lastRow = null; |
| | | this.lastBay = null; |
| | | this.lastLev = null; |
| | | return true; |
| | | } else { |
| | | log.error("{}号穿梭车修改数据库定位失败!!!", slave.getId()); |
| | | } |
| | | } |
| | | } |
| | | |