| | |
| | | import com.zy.asrs.service.BasRgvOptService; |
| | | import com.zy.asrs.service.BasRgvService; |
| | | import com.zy.asrs.utils.RouteUtils; |
| | | import com.zy.asrs.utils.TrackRangeUtils; |
| | | import com.zy.core.ThreadHandler; |
| | | import com.zy.core.cache.*; |
| | | import com.zy.core.enums.RgvModeType; |
| | |
| | | |
| | | private SiemensS7Net siemensNet; |
| | | private RgvSlave slave; |
| | | // private RgvProtocol rgvProtocol; |
| | | // private RgvProtocol rgvProtocol; |
| | | private TaskProtocolCache taskProtocolCache = new TaskProtocolCache(); |
| | | // # 轨道总长 |
| | | private Long trackEntireLength = 100L; |
| | |
| | | @SuppressWarnings("InfiniteLoopStatement") |
| | | public void run() { |
| | | boolean connect = this.connect(); |
| | | if (connect){ |
| | | if (connect) { |
| | | |
| | | // 启动读数据线程 |
| | | new Thread(this::readStatusRgv).start(); |
| | |
| | | } |
| | | } |
| | | |
| | | private void readStatusRgv(){ |
| | | private void readStatusRgv() { |
| | | while (true) { |
| | | try { |
| | | Thread.sleep(100); |
| | |
| | | readStatus(); |
| | | |
| | | } catch (Exception e) { |
| | | log.error("RGV数据读取线程异常!!!"+e.getMessage()); |
| | | log.error("RGV数据读取线程异常!!!" + e.getMessage()); |
| | | initRgv(); |
| | | // e.printStackTrace(); |
| | | } |
| | |
| | | // 休眠 1 秒 |
| | | Thread.sleep(100); |
| | | |
| | | if (!deviceDetection()){ |
| | | if (!deviceDetection()) { |
| | | continue; |
| | | } |
| | | RgvTaskProtocol rgvTaskProtocol = RgvTaskCache.getRgvStatus(slave.getId()); |
| | |
| | | RgvTaskCache.updateRgvStatus(rgvTaskProtocol); |
| | | |
| | | } catch (Exception e) { |
| | | log.error("RGV行走任务下发线程异常!!!"+e.getMessage()); |
| | | log.error("RGV行走任务下发线程异常!!!" + e.getMessage()); |
| | | // e.printStackTrace(); |
| | | } |
| | | } |
| | |
| | | try { |
| | | // 休眠 1 秒 |
| | | Thread.sleep(100); |
| | | if (!deviceDetection()){ |
| | | if (!deviceDetection()) { |
| | | continue; |
| | | } |
| | | RgvProtocol rgvProtocol = RgvStatusCache.getRgvStatus(slave.getId()); |
| | |
| | | } |
| | | |
| | | List<TaskProtocol> allTakeTaskProtocol = taskProtocolCache.getTakeOrPutTaskProtocol(rgvProtocol.getLoaded()); |
| | | for(TaskProtocol taskProtocol: allTakeTaskProtocol){ |
| | | if (taskProtocol.getIsRunning() == 1){//准备下发 |
| | | for (TaskProtocol taskProtocol : allTakeTaskProtocol) { |
| | | if (taskProtocol.getIsRunning() == 1) {//准备下发 |
| | | RgvProtocol rgvProtocolOther = RgvStatusCache.getRgvStatus(slave.getOtherId()); |
| | | //双车 |
| | | if (rgvOtherStatusEnable()){ |
| | | if (rgvOtherStatusEnable()) { |
| | | //另一台车是否允许此台车执行 |
| | | if (!otherRgvAvoid(taskProtocol.getTargetPosition())){ |
| | | if (!otherRgvAvoid(taskProtocol.getTargetPosition())) { |
| | | continue; |
| | | } |
| | | } |
| | | Thread.sleep(200); |
| | | Thread.sleep(100); |
| | | TaskProtocol issued = new TaskProtocol(taskProtocol); |
| | | write(issued); |
| | | taskProtocol.setIsRunning(taskProtocol.getIsRunning() +1); |
| | | taskProtocol.setIsRunning(taskProtocol.getIsRunning() + 1); |
| | | taskProtocolCache.updateTaskProtocol(taskProtocol); |
| | | break; |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("RGV取货任务下发线程异常!!!"+e.getMessage()); |
| | | log.error("RGV取货任务下发线程异常!!!" + e.getMessage()); |
| | | // e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | public boolean deviceDetection(){ |
| | | public boolean deviceDetection() { |
| | | RgvProtocol rgvProtocol = RgvStatusCache.getRgvStatus(slave.getId()); |
| | | RgvTaskProtocol rgvTaskProtocol = RgvTaskCache.getRgvStatus(slave.getId()); |
| | | |
| | | if (rgvProtocol == null || rgvTaskProtocol ==null) { |
| | | if (rgvProtocol == null || rgvTaskProtocol == null) { |
| | | return false; |
| | | } |
| | | if (!rgvProtocol.getModeType().equals(RgvModeType.AUTO) || rgvProtocol.getRgvPos().equals(0L) || rgvTaskProtocol.getAvoid() == -1 || rgvProtocol.getRgvPosDestination() == 0L |
| | |
| | | if (rgvProtocolOther == null) { |
| | | return false; |
| | | } |
| | | if (rgvProtocolOther.statusEnable){ |
| | | if (!rgvProtocolOther.getModeType().equals(RgvModeType.AUTO) || rgvProtocolOther.getRgvPos().equals(0L) || rgvTaskProtocolOther.getAvoid() == -1 || rgvProtocolOther.getRgvPosDestination() == 0L) { |
| | | if (rgvProtocolOther.statusEnable) { |
| | | if (!rgvProtocolOther.getModeType().equals(RgvModeType.AUTO) || rgvProtocolOther.getRgvPos().equals(0L) || rgvTaskProtocolOther.getAvoid() == -1 || rgvProtocolOther.getRgvPosDestination() == 0L) { |
| | | return false; |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | public boolean rgvOtherStatusEnable(){ |
| | | public boolean rgvOtherStatusEnable() { |
| | | RgvProtocol rgvProtocolOther = RgvStatusCache.getRgvStatus(slave.getOtherId()); |
| | | if (rgvProtocolOther == null) { |
| | | return true; |
| | | } |
| | | if (rgvProtocolOther.statusEnable){ |
| | | if (rgvProtocolOther.statusEnable) { |
| | | // if (!rgvProtocolOther.getModeType().equals(RgvModeType.AUTO) || rgvProtocolOther.getRgvPos().equals(0L)) { |
| | | return true; |
| | | // } |
| | |
| | | return false; |
| | | } |
| | | |
| | | public boolean otherRgvAvoid(Long targetPosition){ |
| | | public boolean otherRgvAvoid(Long targetPosition) { |
| | | RgvProtocol rgvProtocol = RgvStatusCache.getRgvStatus(slave.getId()); |
| | | RgvTaskProtocol rgvTaskProtocol = RgvTaskCache.getRgvStatus(slave.getId()); |
| | | |
| | | RgvProtocol rgvProtocolOther = RgvStatusCache.getRgvStatus(slave.getOtherId()); |
| | | RgvTaskProtocol rgvTaskProtocolOther = RgvTaskCache.getRgvStatus(slave.getOtherId()); |
| | | Long[][] avoidRange = new TrackRangeUtils().avoidRange(slave, trackEntireLength, trackBenchmark, avoidDistance); |
| | | |
| | | if (rgvProtocol.getRgvPos()<rgvProtocolOther.getRgvPos()){ |
| | | if (rgvProtocolOther.getStatusType().equals(RgvStatusType.IDLE)){ |
| | | if ((rgvProtocolOther.getRgvPos()-rgvProtocolOther.getCarBodyJiaoMing()) |
| | | - (targetPosition+rgvProtocol.getCarBodyKunPeng()) |
| | | > avoidDistance){//无需避让 |
| | | if (new TrackRangeUtils().IsItSmall(slave)) { |
| | | |
| | | if (rgvProtocolOther.getStatusType().equals(RgvStatusType.IDLE)) { |
| | | if ((rgvProtocolOther.getRgvPos() - rgvProtocolOther.getCarBodyJiaoMing()) |
| | | - (targetPosition + rgvProtocol.getCarBodyKunPeng()) |
| | | > avoidDistance) {//无需避让 |
| | | return true; |
| | | } else { |
| | | long avoid = targetPosition + rgvProtocol.getCarBodyKunPeng() + avoidDistance + rgvProtocolOther.getCarBodyJiaoMing(); |
| | | if (avoid > trackEntireLength-rgvProtocolOther.getCarBodyKunPeng()){ |
| | | log.error("避让超出范围!!!任务异常 联系管理员!!!"); |
| | | if (!new TrackRangeUtils().avoidRange(avoid, avoidRange[0])) { |
| | | log.error("行走超出范围!!!任务异常 联系管理员!!!"); |
| | | return false; |
| | | } |
| | | rgvTaskProtocol.setAvoid(1); |
| | | rgvTaskProtocol.setAvoidingTheDestination(avoid); |
| | | RgvTaskCache.updateRgvStatus(rgvTaskProtocol); |
| | | rgvTaskProtocolOther.setAvoid(1); |
| | | rgvTaskProtocolOther.setAvoidingTheDestination(avoid); |
| | | RgvTaskCache.updateRgvStatus(rgvTaskProtocolOther); |
| | | return true; |
| | | } |
| | | } else if (rgvProtocolOther.getStatusType().equals(RgvStatusType.ROAM)){ |
| | | if ((rgvProtocolOther.getRgvPosDestination()-rgvProtocolOther.getCarBodyJiaoMing()) |
| | | - (targetPosition+rgvProtocol.getCarBodyKunPeng()) |
| | | > avoidDistance){//无需避让 |
| | | } else if (rgvProtocolOther.getStatusType().equals(RgvStatusType.ROAM)) { |
| | | if ((rgvProtocolOther.getRgvPosDestination() - rgvProtocolOther.getCarBodyJiaoMing()) |
| | | - (targetPosition + rgvProtocol.getCarBodyKunPeng()) |
| | | > avoidDistance) {//无需避让 |
| | | return true; |
| | | } else { |
| | | long avoid = targetPosition + rgvProtocol.getCarBodyKunPeng() + avoidDistance + rgvProtocolOther.getCarBodyJiaoMing(); |
| | | if (avoid > trackEntireLength-rgvProtocolOther.getCarBodyKunPeng()){ |
| | | log.error("避让超出范围!!!任务异常 联系管理员!!!"); |
| | | if (!new TrackRangeUtils().avoidRange(avoid, avoidRange[0])) { |
| | | log.error("行走超出范围!!!任务异常 联系管理员!!!"); |
| | | return false; |
| | | } |
| | | rgvTaskProtocol.setAvoid(1); |
| | | rgvTaskProtocol.setAvoidingTheDestination(avoid); |
| | | RgvTaskCache.updateRgvStatus(rgvTaskProtocol); |
| | | rgvTaskProtocolOther.setAvoid(1); |
| | | rgvTaskProtocolOther.setAvoidingTheDestination(avoid); |
| | | RgvTaskCache.updateRgvStatus(rgvTaskProtocolOther); |
| | | return true; |
| | | } |
| | | } else if (rgvProtocolOther.getStatusType().equals(RgvStatusType.WORKING)){ |
| | | if ((rgvProtocolOther.getRgvPosDestination()-rgvProtocolOther.getCarBodyJiaoMing()) |
| | | - (targetPosition+rgvProtocol.getCarBodyKunPeng()) |
| | | > avoidDistance){//无需避让 |
| | | } else if (rgvProtocolOther.getStatusType().equals(RgvStatusType.WORKING)) { |
| | | if ((rgvProtocolOther.getRgvPosDestination() - rgvProtocolOther.getCarBodyJiaoMing()) |
| | | - (targetPosition + rgvProtocol.getCarBodyKunPeng()) |
| | | > avoidDistance) {//无需避让 |
| | | return true; |
| | | } else { |
| | | RgvThread rgvThreadOther = (RgvThread) SlaveConnection.get(SlaveType.Rgv, rgvProtocolOther.getRgvNo()); |
| | | TaskProtocolCache taskProtocolCacheOther = rgvThreadOther.getTaskProtocolCache(); |
| | | List<TaskProtocol> allPutTaskProtocol = taskProtocolCacheOther.getAllPutTaskProtocol(); |
| | | if (allPutTaskProtocol.size() > 1){ |
| | | return false; |
| | | } |
| | | for (TaskProtocol taskProtocol : allPutTaskProtocol){ |
| | | if (taskProtocol.getTargetPosition()>=rgvProtocolOther.getRgvPos()){ |
| | | long avoid = rgvProtocolOther.getRgvPos()-rgvProtocolOther.getCarBodyJiaoMing()-avoidDistance-rgvProtocol.getCarBodyKunPeng(); |
| | | if (avoid > trackEntireLength-rgvProtocolOther.getCarBodyKunPeng()){ |
| | | log.error("行走超出范围!!!任务异常 联系管理员!!!"); |
| | | return false; |
| | | } |
| | | rgvTaskProtocol.setAvoid(1); |
| | | rgvTaskProtocol.setAvoidingTheDestination(avoid); |
| | | RgvTaskCache.updateRgvStatus(rgvTaskProtocol); |
| | | return false; |
| | | } else { |
| | | if (rgvProtocolOther.getRgvPosDestination() >= rgvProtocolOther.getRgvPos()) { |
| | | long avoid = rgvProtocolOther.getRgvPos() - rgvProtocolOther.getCarBodyJiaoMing() - avoidDistance - rgvProtocol.getCarBodyKunPeng(); |
| | | if (!new TrackRangeUtils().avoidRange(avoid, avoidRange[1])) { |
| | | log.error("行走超出范围!!!任务异常 联系管理员!!!"); |
| | | return false; |
| | | } |
| | | rgvTaskProtocol.setAvoid(1); |
| | | rgvTaskProtocol.setAvoidingTheDestination(avoid); |
| | | RgvTaskCache.updateRgvStatus(rgvTaskProtocol); |
| | | return false; |
| | | } |
| | | return false; |
| | | } |
| | | } |
| | | } else { |
| | | if (rgvProtocolOther.getStatusType().equals(RgvStatusType.IDLE)){ |
| | | if ((targetPosition-rgvProtocol.getCarBodyJiaoMing()) |
| | | - (rgvProtocolOther.getRgvPos()+rgvProtocolOther.getCarBodyKunPeng()) |
| | | > avoidDistance){//无需避让 |
| | | if (rgvProtocolOther.getStatusType().equals(RgvStatusType.IDLE)) { |
| | | if ((targetPosition - rgvProtocol.getCarBodyJiaoMing()) |
| | | - (rgvProtocolOther.getRgvPos() + rgvProtocolOther.getCarBodyKunPeng()) |
| | | > avoidDistance) {//无需避让 |
| | | return true; |
| | | } else { |
| | | long avoid = targetPosition -rgvProtocol.getCarBodyJiaoMing() - avoidDistance - rgvProtocolOther.getCarBodyKunPeng(); |
| | | if (avoid < trackBenchmark + rgvProtocolOther.getCarBodyJiaoMing()){ |
| | | log.error("避让超出范围!!!任务异常 联系管理员!!!"); |
| | | long avoid = targetPosition - rgvProtocol.getCarBodyJiaoMing() - avoidDistance - rgvProtocolOther.getCarBodyKunPeng(); |
| | | if (!new TrackRangeUtils().avoidRange(avoid, avoidRange[1])) { |
| | | log.error("行走超出范围!!!任务异常 联系管理员!!!"); |
| | | return false; |
| | | } |
| | | rgvTaskProtocol.setAvoid(1); |
| | | rgvTaskProtocol.setAvoidingTheDestination(avoid); |
| | | RgvTaskCache.updateRgvStatus(rgvTaskProtocol); |
| | | rgvTaskProtocolOther.setAvoid(1); |
| | | rgvTaskProtocolOther.setAvoidingTheDestination(avoid); |
| | | RgvTaskCache.updateRgvStatus(rgvTaskProtocolOther); |
| | | return true; |
| | | } |
| | | } else if (rgvProtocolOther.getStatusType().equals(RgvStatusType.ROAM)){ |
| | | if ((targetPosition-rgvProtocol.getCarBodyJiaoMing()) |
| | | - (rgvProtocolOther.getRgvPosDestination()+rgvProtocolOther.getCarBodyKunPeng()) |
| | | > avoidDistance){//无需避让 |
| | | } else if (rgvProtocolOther.getStatusType().equals(RgvStatusType.ROAM)) { |
| | | if ((targetPosition - rgvProtocol.getCarBodyJiaoMing()) |
| | | - (rgvProtocolOther.getRgvPosDestination() + rgvProtocolOther.getCarBodyKunPeng()) |
| | | > avoidDistance) {//无需避让 |
| | | return true; |
| | | } else { |
| | | long avoid = targetPosition -rgvProtocol.getCarBodyJiaoMing() - avoidDistance - rgvProtocolOther.getCarBodyKunPeng(); |
| | | if (avoid < trackBenchmark + rgvProtocolOther.getCarBodyJiaoMing()){ |
| | | log.error("避让超出范围!!!任务异常 联系管理员!!!"); |
| | | long avoid = targetPosition - rgvProtocol.getCarBodyJiaoMing() - avoidDistance - rgvProtocolOther.getCarBodyKunPeng(); |
| | | if (!new TrackRangeUtils().avoidRange(avoid, avoidRange[1])) { |
| | | log.error("行走超出范围!!!任务异常 联系管理员!!!"); |
| | | return false; |
| | | } |
| | | rgvTaskProtocol.setAvoid(1); |
| | | rgvTaskProtocol.setAvoidingTheDestination(avoid); |
| | | RgvTaskCache.updateRgvStatus(rgvTaskProtocol); |
| | | rgvTaskProtocolOther.setAvoid(1); |
| | | rgvTaskProtocolOther.setAvoidingTheDestination(avoid); |
| | | RgvTaskCache.updateRgvStatus(rgvTaskProtocolOther); |
| | | return true; |
| | | } |
| | | } else if (rgvProtocolOther.getStatusType().equals(RgvStatusType.WORKING)){ |
| | | if ((targetPosition-rgvProtocol.getCarBodyJiaoMing()) |
| | | - (rgvProtocolOther.getRgvPosDestination()+rgvProtocolOther.getCarBodyKunPeng()) |
| | | > avoidDistance){//无需避让 |
| | | |
| | | } else if (rgvProtocolOther.getStatusType().equals(RgvStatusType.WORKING)) { |
| | | if ((targetPosition - rgvProtocol.getCarBodyJiaoMing()) |
| | | - (rgvProtocolOther.getRgvPosDestination() + rgvProtocolOther.getCarBodyKunPeng()) |
| | | > avoidDistance) {//无需避让 |
| | | return true; |
| | | } else { |
| | | RgvThread rgvThreadOther = (RgvThread) SlaveConnection.get(SlaveType.Rgv, rgvProtocolOther.getRgvNo()); |
| | | TaskProtocolCache taskProtocolCacheOther = rgvThreadOther.getTaskProtocolCache(); |
| | | List<TaskProtocol> allPutTaskProtocol = taskProtocolCacheOther.getAllPutTaskProtocol(); |
| | | if (allPutTaskProtocol.size() > 1){ |
| | | return false; |
| | | } |
| | | for (TaskProtocol taskProtocol : allPutTaskProtocol){ |
| | | if (taskProtocol.getTargetPosition()<=rgvProtocolOther.getRgvPos()){ |
| | | long avoid = rgvProtocolOther.getRgvPos()+rgvProtocolOther.getCarBodyKunPeng()+avoidDistance+rgvProtocol.getCarBodyJiaoMing(); |
| | | if (avoid < trackBenchmark + rgvProtocolOther.getCarBodyJiaoMing()){ |
| | | log.error("行走超出范围!!!任务异常 联系管理员!!!"); |
| | | return false; |
| | | } |
| | | rgvTaskProtocol.setAvoid(1); |
| | | rgvTaskProtocol.setAvoidingTheDestination(avoid); |
| | | RgvTaskCache.updateRgvStatus(rgvTaskProtocol); |
| | | return false; |
| | | } else { |
| | | if (rgvProtocolOther.getRgvPosDestination() <= rgvProtocolOther.getRgvPos()) { |
| | | long avoid = rgvProtocolOther.getRgvPos() + rgvProtocolOther.getCarBodyKunPeng() + avoidDistance + rgvProtocol.getCarBodyJiaoMing(); |
| | | if (!new TrackRangeUtils().avoidRange(avoid, avoidRange[0])) { |
| | | log.error("行走超出范围!!!任务异常 联系管理员!!!"); |
| | | return false; |
| | | } |
| | | rgvTaskProtocol.setAvoid(1); |
| | | rgvTaskProtocol.setAvoidingTheDestination(avoid); |
| | | RgvTaskCache.updateRgvStatus(rgvTaskProtocol); |
| | | return false; |
| | | } |
| | | return false; |
| | | } |
| | |
| | | rgvProtocol.setRgvNo(slave.getId()); |
| | | } |
| | | rgvProtocol.setMode((short) -1); |
| | | rgvProtocol.setStatus((short)-1); |
| | | rgvProtocol.setWalkPos((short)0); |
| | | rgvProtocol.setStatus((short) -1); |
| | | rgvProtocol.setWalkPos((short) 0); |
| | | rgvProtocol.setRgvPos(0L); |
| | | rgvProtocol.setAlarm((short)0); |
| | | rgvProtocol.setAlarm((short) 0); |
| | | rgvProtocol.setxSpeed((short) 0); |
| | | rgvProtocol.setxDistance((short) 0); |
| | | rgvProtocol.setxDuration((short) 0); |
| | | rgvProtocol.setCarBodyJiaoMing(0L); |
| | | rgvProtocol.setCarBodyKunPeng(0L); |
| | | try{ |
| | | try { |
| | | BasRgvService basRgvService = SpringUtils.getBean(BasRgvService.class); |
| | | BasRgv rgv = basRgvService.selectById(slave.getId()); |
| | | if (!Cools.isEmpty(rgv)){ |
| | | if (!Cools.isEmpty(rgv)) { |
| | | rgvProtocol.setStatusEnable(rgv.getStatus() == 1); |
| | | } else { |
| | | rgvProtocol.setStatusEnable(false); |
| | | } |
| | | } catch (Exception e){ |
| | | log.error("RGV异常!!!"+e.getMessage()); |
| | | } catch (Exception e) { |
| | | log.error("RGV异常!!!" + e.getMessage()); |
| | | rgvProtocol.setStatusEnable(true); |
| | | } |
| | | |
| | |
| | | siemensNet.setRack(slave.getRack().byteValue()); |
| | | siemensNet.setSlot(slave.getSlot().byteValue()); |
| | | OperateResult connect = siemensNet.ConnectServer(); |
| | | if(connect.IsSuccess){ |
| | | if (connect.IsSuccess) { |
| | | result = true; |
| | | // OutputQueue.RGV.offer(MessageFormat.format( "【{0}】RGV 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.info("RGV plc连接成功 ===>> [id:{}] [ip:{}] [port:{}] [rack:{}] [slot:{}]", slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot()); |
| | |
| | | /** |
| | | * 读取状态 |
| | | */ |
| | | private void readStatus(){ |
| | | private void readStatus() { |
| | | try { |
| | | OperateResultExOne<byte[]> result = siemensNet.Read("DB101.0", (short) 34); |
| | | if (result.IsSuccess) { |
| | |
| | | // rgvProtocol.setxDistance(siemensNet.getByteTransform().TransInt16(result.Content, 40)); |
| | | // rgvProtocol.setxDuration(siemensNet.getByteTransform().TransInt16(result.Content, 48)); |
| | | |
| | | OutputQueue.RGV.offer(MessageFormat.format("【{0}】[id:{1}] <<<<< 实时数据更新成功",DateUtils.convert(new Date()), slave.getId())); |
| | | OutputQueue.RGV.offer(MessageFormat.format("【{0}】[id:{1}] <<<<< 实时数据更新成功", DateUtils.convert(new Date()), slave.getId())); |
| | | // // 工位1复位信号 |
| | | // if (rgvProtocol.getStatusType().equals(RgvStatusType.WAITING) |
| | | // || rgvProtocol.getStatusType().equals(RgvStatusType.FETCHWAITING)) { |
| | |
| | | // 根据实时信息更新数据库 |
| | | BasRgvService basRgvService = SpringUtils.getBean(BasRgvService.class); |
| | | BasRgv basRgv = basRgvService.selectById(slave.getId()); |
| | | if (!Cools.isEmpty(basRgv)){ |
| | | if (!Cools.isEmpty(basRgv)) { |
| | | rgvProtocol.setStatusEnable(basRgv.getStatus() == 1); |
| | | } else { |
| | | rgvProtocol.setStatusEnable(false); |
| | | } |
| | | // BasRgv basRgv = new BasRgv(); |
| | | basRgv.setRgvNo(slave.getId()); |
| | | basRgv.setRgvSts((int)rgvProtocol.getMode()); |
| | | if (!basRgvService.updateById(rgvProtocol.toSqlModel(basRgv))){ |
| | | basRgv.setRgvSts((int) rgvProtocol.getMode()); |
| | | if (!basRgvService.updateById(rgvProtocol.toSqlModel(basRgv))) { |
| | | log.error("RGV plc数据库更新失败 ===>> [id:{}] [ip:{}] [port:{}] [rack:{}] [slot:{}]", slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot()); |
| | | } |
| | | } catch (Exception ignore){ |
| | | } catch (Exception ignore) { |
| | | |
| | | } |
| | | |
| | |
| | | // array[4] = command.getDestinationStaNo(); |
| | | // array[10] = taskProtocol.getCommand(); |
| | | OperateResult result = siemensNet.Write("DB100.0", taskProtocol.getTaskNo()); |
| | | OperateResult result1 = siemensNet.Write("DB100.1", taskProtocol.isDirection()); // 执行方向(面朝轨道 定位值左小右大) true:左 false:右 |
| | | |
| | | // if (taskProtocol.getAckFinish1() == 0) { |
| | | // short commandFinish = 3; //工位1、2任务同时写入 |
| | |
| | | null, |
| | | null, |
| | | null, |
| | | result.IsSuccess? 1 : 0, |
| | | result.IsSuccess ? 1 : 0, |
| | | null, |
| | | new Date(), |
| | | null |
| | | ); |
| | | bean.insert(basRgvOpt); |
| | | } catch (Exception ignore) {} |
| | | } catch (Exception ignore) { |
| | | } |
| | | |
| | | if (result != null && result.IsSuccess) { |
| | | Thread.sleep(200); |