| | |
| | | }); |
| | | } |
| | | |
| | | private File pythonFile = null; |
| | | |
| | | private File loadPythonFile() { |
| | | File scriptFile = null; |
| | | try { |
| | | Resource resource = new ClassPathResource("agv.py"); |
| | | |
| | | InputStream is = resource.getInputStream(); |
| | | scriptFile = File.createTempFile("agv", ".py"); |
| | | scriptFile.deleteOnExit(); |
| | | |
| | | Files.copy(is, scriptFile.toPath(), StandardCopyOption.REPLACE_EXISTING); |
| | | |
| | | scriptFile.setExecutable(true); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | return scriptFile; |
| | | } |
| | | |
| | | public void calcWaveScope() { |
| | | Integer lev = MapDataDispatcher.MAP_DEFAULT_LEV; |
| | | boolean lockAcquired = false; |
| | |
| | | AgvModel agvModel = agvModelService.selectByType(AgvModelType.CTU_BOX_TRANSPORT_AGV.toString()); // can be optimized |
| | | Double avoidDistance = MapDataUtils.getVehicleWaveSafeDistance(agvModel.getDiameter(), MapDataConstant.MAX_DISTANCE_BETWEEN_ADJACENT_AGV_FACTOR); |
| | | |
| | | Resource resource = new ClassPathResource("agv.py"); |
| | | |
| | | File tempScript = null; |
| | | |
| | | InputStream is = resource.getInputStream(); |
| | | tempScript = File.createTempFile("agv", ".py"); |
| | | tempScript.deleteOnExit(); |
| | | |
| | | Files.copy(is, tempScript.toPath(), StandardCopyOption.REPLACE_EXISTING); |
| | | tempScript.setExecutable(true); |
| | | if (null == pythonFile) { |
| | | pythonFile = loadPythonFile(); |
| | | } |
| | | |
| | | ProcessBuilder processBuilder = new ProcessBuilder( |
| | | "python" // 或者 "python3" 取决于系统配置 |
| | | , tempScript.getAbsolutePath() |
| | | , pythonFile.getAbsolutePath() |
| | | , String.valueOf(avoidDistance) |
| | | , redisProperties.getHost() |
| | | , redisProperties.getPassword() |