| | |
| | | import com.core.common.SpringUtils; |
| | | import com.zy.asrs.entity.BasCrnOpt; |
| | | import com.zy.asrs.entity.BasCrnp; |
| | | import com.zy.asrs.entity.CommandInfo; |
| | | import com.zy.asrs.service.BasCrnOptService; |
| | | import com.zy.asrs.service.BasCrnpService; |
| | | import com.zy.asrs.service.CommandInfoService; |
| | | import com.zy.asrs.service.DeviceErrorService; |
| | | import com.zy.core.CrnThread; |
| | | import com.zy.core.cache.MessageQueue; |
| | | import com.zy.core.cache.OutputQueue; |
| | |
| | | } 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()); |
| | | DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class); |
| | | deviceErrorService.addDeviceError("crn", slave.getId(), "堆垛机plc连接失败"); |
| | | } |
| | | siemensNet.ConnectClose(); |
| | | return result; |
| | |
| | | } |
| | | } catch (Exception ignore){} |
| | | |
| | | DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class); |
| | | deviceErrorService.deleteDeviceError("crn", slave.getId()); |
| | | } 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()); |
| | | DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class); |
| | | deviceErrorService.addDeviceError("crn", slave.getId(), "读取堆垛机plc状态信息失败"); |
| | | } |
| | | } |
| | | |
| | |
| | | if (command.getTaskNo() == 0 && command.getAckFinish() == 0) { |
| | | command.setTaskNo((short) 9999); |
| | | } |
| | | |
| | | CommandInfoService commandInfoService = SpringUtils.getBean(CommandInfoService.class); |
| | | CommandInfo commandInfo = new CommandInfo(); |
| | | commandInfo.setWrkNo(command.getTaskNo().intValue()); |
| | | commandInfo.setCommandStatus(1); |
| | | commandInfo.setStartTime(new Date()); |
| | | commandInfo.setDevice("crn"); |
| | | commandInfo.setCommand(JSON.toJSONString(command)); |
| | | commandInfoService.insert(commandInfo); |
| | | |
| | | command.setCrnNo(slave.getId()); |
| | | short[] array = new short[9]; |
| | | if (command.getAckFinish() == 0) { |
| | |
| | | } else { |
| | | array[0] = 0; |
| | | } |
| | | array[1] = command.getSourcePosZ(); |
| | | array[2] = command.getSourcePosY(); |
| | | |
| | | if (command.getSourcePosZ()==(short)1 && command.getSourcePosY()==(short)1){ |
| | | array[1] = (short)0; |
| | | array[2] = (short)0; |
| | | }else if (command.getSourcePosZ()==(short)1 && command.getSourcePosY()==(short)41){ |
| | | array[1] = (short)0; |
| | | array[2] = (short)42; |
| | | }else { |
| | | array[1] = command.getSourcePosZ(); |
| | | array[2] = command.getSourcePosY(); |
| | | } |
| | | |
| | | if (command.getSourcePosX()==(short)3){ |
| | | array[3] = (short)1; |
| | | }else if (command.getSourcePosX()==(short)4){ |
| | |
| | | }else { |
| | | array[3] = command.getSourcePosX(); |
| | | } |
| | | array[4] = command.getDestinationPosZ(); |
| | | array[5] = command.getDestinationPosY(); |
| | | |
| | | if (command.getDestinationPosZ()==(short)1 && command.getDestinationPosY()==(short)1){ |
| | | array[4] = (short)0; |
| | | array[5] = (short)0; |
| | | }else if (command.getDestinationPosZ()==(short)1 && command.getDestinationPosY()==(short)41){ |
| | | array[4] = (short)0; |
| | | array[5] = (short)42; |
| | | }else { |
| | | array[4] = command.getDestinationPosZ(); |
| | | array[5] = command.getDestinationPosY(); |
| | | } |
| | | |
| | | if (command.getDestinationPosX()==(short)3){ |
| | | array[6] = (short)1; |
| | | }else if (command.getDestinationPosX()==(short)4){ |
| | |
| | | }else { |
| | | array[6] = command.getDestinationPosX(); |
| | | } |
| | | array[7] = command.getSourceStaNo(); |
| | | array[8] = command.getDestinationStaNo(); |
| | | if ((array[1]==(short)0 && array[2] == (short)0) || (array[1]==(short)0 && array[2] == (short)42)){ |
| | | array[7]=(short)1; |
| | | }else { |
| | | array[7]=(short)0; |
| | | } |
| | | // array[7] = command.getSourceStaNo(); |
| | | |
| | | if ((array[4]==(short)0 && array[5] == (short)0) || (array[4]==(short)0 && array[5] == (short)42)){ |
| | | array[8]=(short)1; |
| | | }else { |
| | | array[8]=(short)0; |
| | | } |
| | | // array[8] = command.getDestinationStaNo(); |
| | | |
| | | // 作业信息 |
| | | OperateResult result = siemensNet.Write("DB10.0", array); |
| | | // 任务号 + 完成位 |
| | |
| | | array2[0] = command.getTaskNo(); |
| | | array2[1] = command.getAckFinish(); |
| | | OperateResult result1 = siemensNet.Write("DB10.24", array2); |
| | | |
| | | // //起始排、目标排 |
| | | // short[] array3 = new short[2]; |
| | | // array3[0] = command.getSourcePosX(); |
| | | // array3[1] = command.getDestinationPosX(); |
| | | // OperateResult result3 = siemensNet.Write("DB10.24", array3); |
| | | |
| | | // 结束位 |
| | | if (command.getAckFinish() == 0) { |