| | |
| | | import com.core.common.SpringUtils; |
| | | import com.zy.asrs.entity.BasCrnOpt; |
| | | import com.zy.asrs.entity.BasCrnp; |
| | | import com.zy.asrs.entity.BasErrLog; |
| | | import com.zy.asrs.service.BasCrnOptService; |
| | | import com.zy.asrs.service.BasCrnpService; |
| | | import com.zy.asrs.service.BasErrLogService; |
| | | import com.zy.asrs.service.DeviceErrorService; |
| | | import com.zy.core.CrnThread; |
| | | import com.zy.core.cache.CrnErrCache; |
| | |
| | | command.setDestinationPosZ((short)0); // 目标库位层 |
| | | write(command); |
| | | break; |
| | | // 复位 |
| | | case 4: |
| | | CrnCommand command4 = (CrnCommand) task.getData(); |
| | | write(command4); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | |
| | | crnProtocol.setyDistance((short) 0); |
| | | crnProtocol.setxDuration((short) 0); |
| | | crnProtocol.setyDuration((short) 0); |
| | | try{ |
| | | CrnErrCache.updateCrnErr(crnProtocol.getCrnNo(), "离线"); |
| | | } catch (Exception e1){ |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |
| | |
| | | if(crnProtocol.getTaskNo()==9999){ |
| | | backHpFlag = false; |
| | | } |
| | | CrnCommand crnCommand = new CrnCommand(); |
| | | crnCommand.setAckFinish((short)1); |
| | | if (write(crnCommand)) { |
| | | resetFlag = false; |
| | | |
| | | if (!Cools.isEmpty(crnProtocol.getLaneNo()) && crnProtocol.getLaneNo()!=0){ |
| | | CrnCommand crnCommand = new CrnCommand(); |
| | | crnCommand.setAckFinish((short)1); |
| | | // crnCommand.setTaskNo(crnProtocol.getTaskNo()); |
| | | crnCommand.setLaneNo(crnProtocol.getLaneNo()); |
| | | crnCommand.setTaskMode(CrnTaskModeType.NONE); // 任务模式 |
| | | if (write(crnCommand)) { |
| | | resetFlag = false; |
| | | } |
| | | } else { |
| | | CrnErrCache.updateCrnErr(crnProtocol.getCrnNo(), "巷道号为0"); |
| | | } |
| | | } |
| | | } |
| | |
| | | if (System.currentTimeMillis()-currentTimeMilliConnectCrn>1000*60*10){ |
| | | try{ |
| | | DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class); |
| | | deviceErrorService.addDeviceError("Crn", slave.getId(), "读取堆垛机plc状态信息失败"); |
| | | deviceErrorService.addDeviceError("CrnErr", slave.getId(), "读取堆垛机plc状态信息失败"); |
| | | } catch (Exception e2){ |
| | | Thread.sleep(1000); |
| | | // log.error("e2:"+e2.getMessage()); |
| | |
| | | return false; |
| | | } |
| | | CrnErrCache.updateCrnErr(slave.getId(), "-"); |
| | | |
| | | // try{ |
| | | // BasErrLogService basErrLogService = SpringUtils.getBean(BasErrLogService.class); |
| | | // BasErrLog basErrLog = new BasErrLog(command,"","任务下发记录"); |
| | | // if (!basErrLogService.insert(basErrLog)) { |
| | | // log.error("堆垛机plc异常记录失败 ===>> [id:{}] [error:{}]", slave.getId(), "任务下发记录失败"); |
| | | // } |
| | | // } catch (Exception e3){ |
| | | // } |
| | | // convertRow(command); |
| | | command.setCrnNo(slave.getId()); |
| | | short[] array = new short[10]; |
| | |
| | | array[6] = command.getDestinationPosX(); |
| | | array[7] = command.getDestinationPosY(); |
| | | array[8] = command.getDestinationPosZ(); |
| | | array[9] = command.getCommand(); |
| | | // array[9] = command.getCommand(); |
| | | array[9] = (short)0; |
| | | OperateResult result18 = siemensNet.Write("DB100.18", (short)0); |
| | | |
| | | if (command.getAckFinish() == 0) { |
| | | OperateResult result100 = siemensNet.Write("DB100.0", (short)0); |
| | | } |
| | | |
| | | try{ |
| | | Thread.sleep(50L); |
| | | } catch (Exception e){} |
| | |
| | | try{ |
| | | Thread.sleep(100L); |
| | | } catch (Exception e){} |
| | | OperateResultExOne<byte[]> resultRead = siemensNet.Read("DB101.0", (short) 4); |
| | | 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++; |
| | | CrnErrCache.updateCrnErr(slave.getId(), "堆垛机命令地址写入后回读失败"); |
| | | |
| | | log.error("堆垛机命令地址写入后回读失败[id:{}]>>>>重写[{}] >>>>> 写入[{}],===>>回读[{}]", slave.getId(), i,JSON.toJSON(command),JSON.toJSON(one)); |
| | | |
| | | try{ |
| | | DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class); |
| | | deviceErrorService.addDeviceError("CrnErr", slave.getId(), "巷道号"+command.getLaneNo()+";写入次数"+i+";堆垛机命令地址写入后回读失败:"+JSON.toJSONString(command.getNowTask())); |
| | | } catch (Exception e2){ |
| | | } |
| | | try{ |
| | | BasErrLogService basErrLogService = SpringUtils.getBean(BasErrLogService.class); |
| | | BasErrLog basErrLog = new BasErrLog(command,"堆垛机命令地址写入后回读失败",""); |
| | | if (!basErrLogService.insert(basErrLog)) { |
| | | log.error("堆垛机plc异常记录失败 ===>> [id:{}] [error:{}]", slave.getId(), "堆垛机命令地址写入后回读失败记录失败"); |
| | | } |
| | | } catch (Exception e3){ |
| | | } |
| | | result = siemensNet.Write("DB100.0", array); |
| | | }else{ |
| | | try{ |
| | | DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class); |
| | | deviceErrorService.addDeviceError("crnWrite", slave.getId(), "巷道号"+command.getLaneNo()+";堆垛机指令下发:"+JSON.toJSONString(command.getNowTask())); |
| | | } catch (Exception e2){ |
| | | } |
| | | break; |
| | | } |
| | | } |
| | |
| | | log.info("下发DB100.18 回读失败" + "commandFinish:"+commandFinish); |
| | | log.info("下发DB100.18 回读失败" + "array:"+ JSON.toJSONString(array)); |
| | | CrnErrCache.updateCrnErr(slave.getId(), "下发DB100.18 回读失败"); |
| | | |
| | | try{ |
| | | DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class); |
| | | deviceErrorService.addDeviceError("CrnErr", slave.getId(), "巷道号"+command.getLaneNo()+";写入次数"+signFinish+";下发DB100.18 回读失败:"+JSON.toJSONString(command.getNowTask())); |
| | | } catch (Exception e2){ |
| | | } |
| | | try{ |
| | | BasErrLogService basErrLogService = SpringUtils.getBean(BasErrLogService.class); |
| | | BasErrLog basErrLog = new BasErrLog(command,"下发DB100.18 回读失败",""); |
| | | if (!basErrLogService.insert(basErrLog)) { |
| | | log.error("堆垛机plc异常记录失败 ===>> [id:{}] [error:{}]", slave.getId(), "下发DB100.18 回读失败记录失败"); |
| | | } |
| | | } catch (Exception e3){ |
| | | } |
| | | result = siemensNet.Write("DB100.18", commandFinish); |
| | | signFinish++; |
| | | }else { |
| | |
| | | isRunning = false; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 清除作业启动中 |
| | | */ |
| | | @Override |
| | | public void setWrkSign() { |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 清除作业启动中 |
| | | */ |
| | | @Override |
| | | public void setResetFlag(boolean flag) { |
| | | this.resetFlag = flag; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 清除作业启动中 |
| | | */ |
| | | @Override |
| | | public boolean getResetFlag() { |
| | | return resetFlag; |
| | | } |
| | | |
| | | } |