| | |
| | | import com.zy.asrs.entity.BasRgvOpt; |
| | | import com.zy.asrs.service.BasRgvOptService; |
| | | import com.zy.asrs.service.BasRgvService; |
| | | import com.zy.asrs.service.DeviceErrorService; |
| | | import com.zy.asrs.utils.RouteUtils; |
| | | import com.zy.asrs.utils.TrackRangeUtils; |
| | | import com.zy.core.DevpThread; |
| | |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("RGV数据读取线程异常!!!" + e.getMessage()); |
| | | log.error("rgv连接失败!!! ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort()); |
| | | try{ |
| | | DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class); |
| | | deviceErrorService.addDeviceError("rgv", slave.getId(), "rgv连接失败"+e.getMessage()); |
| | | } catch (Exception e2){ |
| | | log.error("e2:"+e2.getMessage()); |
| | | } |
| | | initRgv(); |
| | | // e.printStackTrace(); |
| | | } |
| | |
| | | readStatus(); |
| | | |
| | | } catch (Exception e) { |
| | | log.error("RGV数据读取线程异常!!!" + e.getMessage()); |
| | | log.error("RGV数据读取线程异常!!! ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort()); |
| | | try{ |
| | | DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class); |
| | | deviceErrorService.addDeviceError("rgv", slave.getId(), "RGV数据读取线程异常"+e.getMessage()); |
| | | } catch (Exception e2){ |
| | | log.error("e2:"+e2.getMessage()); |
| | | } |
| | | initRgv(); |
| | | // e.printStackTrace(); |
| | | } |
| | |
| | | OperateResult result4 = siemensNet.Write("DB100.12.0", false); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("RGV数据读取线程异常!!!" + e.getMessage()); |
| | | log.error("RGV数据任务下发复位线程异常!!! ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort()); |
| | | try{ |
| | | DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class); |
| | | deviceErrorService.addDeviceError("rgv", slave.getId(), "RGV数据任务下发复位线程异常"+e.getMessage()); |
| | | } catch (Exception e2){ |
| | | log.error("e2:"+e2.getMessage()); |
| | | } |
| | | initRgv(); |
| | | // e.printStackTrace(); |
| | | } |
| | |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("RGV取货任务下发线程异常!!!" + e.getMessage()); |
| | | log.error("RGV任务下发线程异常!!! ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort()); |
| | | try{ |
| | | DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class); |
| | | deviceErrorService.addDeviceError("rgv", slave.getId(), "RGV任务下发线程异常"+e.getMessage()); |
| | | } catch (Exception e2){ |
| | | log.error("e2:"+e2.getMessage()); |
| | | } |
| | | // e.printStackTrace(); |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("RGV取货任务下发线程异常!!!" + e.getMessage()); |
| | | log.error("RGV任务下发线程异常!!! ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort()); |
| | | try{ |
| | | DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class); |
| | | deviceErrorService.addDeviceError("rgv", slave.getId(), "RGV任务下发线程异常"+e.getMessage()); |
| | | } catch (Exception e2){ |
| | | log.error("e2:"+e2.getMessage()); |
| | | } |
| | | // e.printStackTrace(); |
| | | } |
| | | } |
| | |
| | | if (rgvProtocolOther.getStatusType().equals(RgvStatusType.IDLE)) { |
| | | if ((rgvProtocolOther.getRgvPos() - rgvProtocolOther.getCarBodyJiaoMing()) |
| | | - (targetPosition + rgvProtocol.getCarBodyKunPeng()) |
| | | > avoidDistance) {//无需避让 |
| | | > avoidDistance - 50) {//无需避让 |
| | | return true; |
| | | } else { |
| | | long avoid = targetPosition + rgvProtocol.getCarBodyKunPeng() + avoidDistance + rgvProtocolOther.getCarBodyJiaoMing(); |
| | | if (!new TrackRangeUtils().avoidRange(avoid, avoidRange[0])) { |
| | | log.error("行走超出范围!!!任务异常 联系管理员!!!"); |
| | | log.error("RGV行走超出范围!!! ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort()); |
| | | try{ |
| | | DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class); |
| | | deviceErrorService.addDeviceError("rgv", slave.getId(), "RGV行走超出范围"); |
| | | } catch (Exception e2){ |
| | | log.error("e2:"+e2.getMessage()); |
| | | } |
| | | return false; |
| | | } |
| | | long avoidAbs = Math.abs(avoid - rgvProtocolOther.getRgvPos()); |
| | |
| | | rgvTaskProtocolOther.setAvoid(1); |
| | | rgvTaskProtocolOther.setAvoidingTheDestination(avoid); |
| | | RgvTaskCache.updateRgvStatus(rgvTaskProtocolOther); |
| | | return true; |
| | | return false; |
| | | } |
| | | } else if (rgvProtocolOther.getStatusType().equals(RgvStatusType.ROAM)) { |
| | | if ((rgvProtocolOther.getRgvPosDestination() - rgvProtocolOther.getCarBodyJiaoMing()) |
| | | - (targetPosition + rgvProtocol.getCarBodyKunPeng()) |
| | | > avoidDistance) {//无需避让 |
| | | > avoidDistance - 50) {//无需避让 |
| | | return true; |
| | | } else { |
| | | long avoid = targetPosition + rgvProtocol.getCarBodyKunPeng() + avoidDistance + rgvProtocolOther.getCarBodyJiaoMing(); |
| | | if (!new TrackRangeUtils().avoidRange(avoid, avoidRange[0])) { |
| | | log.error("行走超出范围!!!任务异常 联系管理员!!!"); |
| | | log.error("RGV行走超出范围!!! ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort()); |
| | | try{ |
| | | DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class); |
| | | deviceErrorService.addDeviceError("rgv", slave.getId(), "RGV行走超出范围"); |
| | | } catch (Exception e2){ |
| | | log.error("e2:"+e2.getMessage()); |
| | | } |
| | | return false; |
| | | } |
| | | long avoidAbs = Math.abs(avoid - rgvProtocolOther.getRgvPos()); |
| | |
| | | rgvTaskProtocolOther.setAvoid(1); |
| | | rgvTaskProtocolOther.setAvoidingTheDestination(avoid); |
| | | RgvTaskCache.updateRgvStatus(rgvTaskProtocolOther); |
| | | return true; |
| | | return false; |
| | | } |
| | | } else if (rgvProtocolOther.getStatusType().equals(RgvStatusType.WORKING)) { |
| | | if ((rgvProtocolOther.getRgvPosDestination() - rgvProtocolOther.getCarBodyJiaoMing()) |
| | | - (targetPosition + rgvProtocol.getCarBodyKunPeng()) |
| | | > avoidDistance) {//无需避让 |
| | | > avoidDistance - 50) {//无需避让 |
| | | return true; |
| | | } else { |
| | | if (rgvProtocolOther.getRgvPosDestination() >= rgvProtocolOther.getRgvPos()-50) { |
| | | long avoid = rgvProtocolOther.getRgvPos() - rgvProtocolOther.getCarBodyJiaoMing() - avoidDistance - rgvProtocol.getCarBodyKunPeng(); |
| | | if (!new TrackRangeUtils().avoidRange(avoid, avoidRange[1])) { |
| | | log.error("行走超出范围!!!任务异常 联系管理员!!!"); |
| | | log.error("RGV行走超出范围!!! ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort()); |
| | | try{ |
| | | DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class); |
| | | deviceErrorService.addDeviceError("rgv", slave.getId(), "RGV行走超出范围"); |
| | | } catch (Exception e2){ |
| | | log.error("e2:"+e2.getMessage()); |
| | | } |
| | | return false; |
| | | } |
| | | long avoidAbs = Math.abs(avoid - rgvProtocol.getRgvPos()); |
| | |
| | | } else { |
| | | if ((rgvProtocolOther.getRgvPosDestinationOrPos(true) - rgvProtocolOther.getCarBodyJiaoMing()) |
| | | - (targetPosition + rgvProtocol.getCarBodyKunPeng()) |
| | | > avoidDistance) {//无需避让 |
| | | > avoidDistance - 50) {//无需避让 |
| | | return true; |
| | | } |
| | | } |
| | |
| | | if (rgvProtocolOther.getStatusType().equals(RgvStatusType.IDLE)) { |
| | | if ((targetPosition - rgvProtocol.getCarBodyJiaoMing()) |
| | | - (rgvProtocolOther.getRgvPos() + rgvProtocolOther.getCarBodyKunPeng()) |
| | | > avoidDistance) {//无需避让 |
| | | > avoidDistance - 50) {//无需避让 |
| | | return true; |
| | | } else { |
| | | long avoid = targetPosition - rgvProtocol.getCarBodyJiaoMing() - avoidDistance - rgvProtocolOther.getCarBodyKunPeng(); |
| | | if (!new TrackRangeUtils().avoidRange(avoid, avoidRange[1])) { |
| | | log.error("行走超出范围!!!任务异常 联系管理员!!!"); |
| | | log.error("RGV行走超出范围!!! ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort()); |
| | | try{ |
| | | DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class); |
| | | deviceErrorService.addDeviceError("rgv", slave.getId(), "RGV行走超出范围"); |
| | | } catch (Exception e2){ |
| | | log.error("e2:"+e2.getMessage()); |
| | | } |
| | | return false; |
| | | } |
| | | long avoidAbs = Math.abs(avoid - rgvProtocolOther.getRgvPos()); |
| | |
| | | rgvTaskProtocolOther.setAvoid(1); |
| | | rgvTaskProtocolOther.setAvoidingTheDestination(avoid); |
| | | RgvTaskCache.updateRgvStatus(rgvTaskProtocolOther); |
| | | return true; |
| | | return false; |
| | | } |
| | | } else if (rgvProtocolOther.getStatusType().equals(RgvStatusType.ROAM)) { |
| | | if ((targetPosition - rgvProtocol.getCarBodyJiaoMing()) |
| | | - (rgvProtocolOther.getRgvPosDestination() + rgvProtocolOther.getCarBodyKunPeng()) |
| | | > avoidDistance) {//无需避让 |
| | | > avoidDistance - 50) {//无需避让 |
| | | return true; |
| | | } else { |
| | | long avoid = targetPosition - rgvProtocol.getCarBodyJiaoMing() - avoidDistance - rgvProtocolOther.getCarBodyKunPeng(); |
| | | if (!new TrackRangeUtils().avoidRange(avoid, avoidRange[1])) { |
| | | log.error("行走超出范围!!!任务异常 联系管理员!!!"); |
| | | log.error("RGV行走超出范围!!! ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort()); |
| | | try{ |
| | | DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class); |
| | | deviceErrorService.addDeviceError("rgv", slave.getId(), "RGV行走超出范围"); |
| | | } catch (Exception e2){ |
| | | log.error("e2:"+e2.getMessage()); |
| | | } |
| | | return false; |
| | | } |
| | | long avoidAbs = Math.abs(avoid - rgvProtocolOther.getRgvPos()); |
| | |
| | | rgvTaskProtocolOther.setAvoid(1); |
| | | rgvTaskProtocolOther.setAvoidingTheDestination(avoid); |
| | | RgvTaskCache.updateRgvStatus(rgvTaskProtocolOther); |
| | | return true; |
| | | return false; |
| | | } |
| | | |
| | | } else if (rgvProtocolOther.getStatusType().equals(RgvStatusType.WORKING)) { |
| | | if ((targetPosition - rgvProtocol.getCarBodyJiaoMing()) |
| | | - (rgvProtocolOther.getRgvPosDestination() + rgvProtocolOther.getCarBodyKunPeng()) |
| | | > avoidDistance) {//无需避让 |
| | | > avoidDistance-50) {//无需避让 |
| | | return true; |
| | | } else { |
| | | if (rgvProtocolOther.getRgvPosDestination() <= rgvProtocolOther.getRgvPos() + 50) { |
| | | long avoid = rgvProtocolOther.getRgvPos() + rgvProtocolOther.getCarBodyKunPeng() + avoidDistance + rgvProtocol.getCarBodyJiaoMing(); |
| | | if (!new TrackRangeUtils().avoidRange(avoid, avoidRange[0])) { |
| | | log.error("行走超出范围!!!任务异常 联系管理员!!!"); |
| | | log.error("RGV行走超出范围!!! ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort()); |
| | | try{ |
| | | DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class); |
| | | deviceErrorService.addDeviceError("rgv", slave.getId(), "RGV行走超出范围"); |
| | | } catch (Exception e2){ |
| | | log.error("e2:"+e2.getMessage()); |
| | | } |
| | | return false; |
| | | } |
| | | long avoidAbs = Math.abs(avoid - rgvProtocol.getRgvPos()); |
| | |
| | | } else { |
| | | if ((rgvProtocolOther.getRgvPosDestinationOrPos(false) - rgvProtocolOther.getCarBodyJiaoMing()) |
| | | - (targetPosition + rgvProtocol.getCarBodyKunPeng()) |
| | | > avoidDistance) {//无需避让 |
| | | > avoidDistance - 50) {//无需避让 |
| | | return true; |
| | | } |
| | | } |
| | |
| | | rgvProtocol.setStatusEnable(false); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("RGV异常!!!" + e.getMessage()); |
| | | log.error("RGV异常!!! ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort()); |
| | | try{ |
| | | DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class); |
| | | deviceErrorService.addDeviceError("rgv", slave.getId(), "RGV异常"+e.getMessage()); |
| | | } catch (Exception e2){ |
| | | log.error("e2:"+e2.getMessage()); |
| | | } |
| | | rgvProtocol.setStatusEnable(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.error("RGV plc连接失败!!! ===>> [id:{}] [ip:{}] [port:{}] [rack:{}] [slot:{}]", slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot()); |
| | | |
| | | try{ |
| | | DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class); |
| | | deviceErrorService.addDeviceError("rgv", slave.getId(), "RGVplc连接失败"); |
| | | } catch (Exception e2){ |
| | | log.error("e2:"+e2.getMessage()); |
| | | } |
| | | } |
| | | initRgv(); |
| | | // siemensNet.ConnectClose(); |
| | |
| | | */ |
| | | private void readStatus() { |
| | | try { |
| | | OperateResultExOne<byte[]> result = siemensNet.Read("DB101.0", (short) 19); |
| | | OperateResultExOne<byte[]> result = siemensNet.Read("DB101.0", (short) 20); |
| | | if (result.IsSuccess) { |
| | | // 构建设备状态对象 |
| | | RgvProtocol rgvProtocol = RgvStatusCache.getRgvStatus(slave.getId()); |
| | |
| | | // rgvProtocol.setxDuration(siemensNet.getByteTransform().TransInt16(result.Content, 48)); |
| | | |
| | | // OperateResultExOne<byte[]> result11 = siemensNet.Read("DB100.12", (short) 1); |
| | | boolean[] status = siemensNet.getByteTransform().TransBool(result.Content, 18, 1); |
| | | boolean[] status = siemensNet.getByteTransform().TransBool(result.Content, 18, 2); |
| | | rgvProtocol.setLoaded(status[0]? (short)1:(short)0); |
| | | rgvProtocol.setErr1(status[8]); |
| | | rgvProtocol.setErr2(status[9]); |
| | | rgvProtocol.setErr3(status[10]); |
| | | rgvProtocol.setErr4(status[11]); |
| | | rgvProtocol.setErr5(status[12]); |
| | | rgvProtocol.setErr6(status[13]); |
| | | |
| | | OutputQueue.RGV.offer(MessageFormat.format("【{0}】[id:{1}] <<<<< 实时数据更新成功", DateUtils.convert(new Date()), slave.getId())); |
| | | // // 工位1复位信号 |
| | |
| | | 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()); |
| | | |
| | | try{ |
| | | DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class); |
| | | deviceErrorService.addDeviceError("rgv", slave.getId(), "RGV plc数据库更新失败"); |
| | | } catch (Exception e2){ |
| | | log.error("e2:"+e2.getMessage()); |
| | | } |
| | | } |
| | | } catch (Exception ignore) { |
| | | |
| | |
| | | connectRgv = false; |
| | | // 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.error("读取RGV plc状态信息失败 ===>> [id:{}] [ip:{}] [port:{}] [rack:{}] [slot:{}]", slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot()); |
| | | |
| | | try{ |
| | | DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class); |
| | | deviceErrorService.addDeviceError("rgv", slave.getId(), "读取RGV plc状态信息失败"); |
| | | } catch (Exception e2){ |
| | | log.error("e2:"+e2.getMessage()); |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | // e.printStackTrace(); |
| | | // OutputQueue.RGV.offer(MessageFormat.format("【{0}】读取RGV plc状态信息失败 ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort())); |
| | | log.error("读取RGV plc状态信息失败 ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort()); |
| | | |
| | | try{ |
| | | DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class); |
| | | deviceErrorService.addDeviceError("rgv", slave.getId(), "读取RGV plc状态信息失败"); |
| | | } catch (Exception e2){ |
| | | log.error("e2:"+e2.getMessage()); |
| | | } |
| | | initRgv(); |
| | | } |
| | | } |
| | |
| | | */ |
| | | private boolean write(TaskProtocol taskProtocol) throws InterruptedException { |
| | | if (null == taskProtocol) { |
| | | log.error("RGV写入命令为空"); |
| | | log.error("RGV写入命令为空 ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort()); |
| | | |
| | | try{ |
| | | DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class); |
| | | deviceErrorService.addDeviceError("rgv", slave.getId(), "RGV写入命令为空"); |
| | | } catch (Exception e2){ |
| | | log.error("e2:"+e2.getMessage()); |
| | | } |
| | | return false; |
| | | } |
| | | // convertRow(command); |
| | |
| | | Thread.sleep(200); |
| | | this.readStatus(); |
| | | log.info("RGV 命令下发[id:{}] >>>>> {}", slave.getId(), JSON.toJSON(taskProtocol)); |
| | | log.error("RGV 命令下发 ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort()); |
| | | |
| | | try{ |
| | | DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class); |
| | | deviceErrorService.addDeviceError("rgv", slave.getId(), "RGV 命令下发"+JSON.toJSON(taskProtocol)); |
| | | } catch (Exception e2){ |
| | | log.error("e2:"+e2.getMessage()); |
| | | } |
| | | OutputQueue.RGV.offer(MessageFormat.format("【{0}】[id:{1}] >>>>> 命令下发: {2}", DateUtils.convert(new Date()), slave.getId(), JSON.toJSON(taskProtocol))); |
| | | return true; |
| | | } else { |