| | |
| | | package com.zy.acs.manager.core.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.zy.acs.framework.common.Cools; |
| | | import com.zy.acs.common.utils.Utils; |
| | | import com.zy.acs.framework.common.Cools; |
| | | import com.zy.acs.manager.common.utils.MapDataUtils; |
| | | import com.zy.acs.manager.core.constant.MapDataConstant; |
| | | import com.zy.acs.manager.core.service.astart.DynamicNodeType; |
| | |
| | | |
| | | this.calcDynamicNodeWhenBoot(); |
| | | |
| | | while (!Thread.currentThread().isInterrupted()) { |
| | | |
| | | this.calcWaveScope(); |
| | | |
| | | try { Thread.sleep(500); } catch (InterruptedException ignore) {} |
| | | } |
| | | // while (!Thread.currentThread().isInterrupted()) { |
| | | // |
| | | // this.calcWaveScope(); |
| | | // |
| | | // try { Thread.sleep(500); } catch (InterruptedException ignore) {} |
| | | // } |
| | | |
| | | }); |
| | | } |
| | |
| | | return; |
| | | } |
| | | |
| | | String[][] codeMatrix = mapDataDispatcher.getCodeMatrix(lev); |
| | | String[][] waveMatrix = mapDataDispatcher.initWaveMatrix(lev); |
| | | |
| | | // vehicle |
| | | // for (Agv agv : agvService.list(new LambdaQueryWrapper<>())) { |
| | | // AgvDetail agvDetail = agvDetailService.selectByAgvId(agv.getId()); |
| | | // AgvModel agvModel = agvModelService.getById(agv.getAgvModel()); |
| | | // Code code = codeService.getById(agvDetail.getRecentCode()); |
| | | // 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); |
| | | // List<NavigateNode> includeList = mapService.getWaveScopeByCode(lev, code.getData(), avoidDistance); |
| | | // Double avoidDistance = MapDataUtils.getVehicleWaveSafeDistance(agvModel.getDiameter(), MapDataConstant.MAX_DISTANCE_BETWEEN_ADJACENT_AGV_FACTOR); |
| | | // |
| | | // for (NavigateNode navigateNode : includeList) { |
| | | // String waveNode = waveMatrix[navigateNode.getX()][navigateNode.getY()]; |
| | | // waveMatrix[navigateNode.getX()][navigateNode.getY()] = MapDataUtils.generateWaveNode(waveNode, agv.getUuid()); |
| | | // long startTime = System.currentTimeMillis(); |
| | | // |
| | | // ProcessBuilder processBuilder = new ProcessBuilder("python" |
| | | // , "D:\\tmp\\pyagv\\agv4.py" |
| | | // , String.valueOf(avoidDistance) |
| | | // ); |
| | | // processBuilder.redirectErrorStream(true); |
| | | // |
| | | // try { |
| | | // Process process = processBuilder.start(); |
| | | // |
| | | // // 读取Python脚本的输出 |
| | | // BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); |
| | | // String line; |
| | | // StringBuilder builder = new StringBuilder(); |
| | | // while ((line = reader.readLine()) != null) { |
| | | // builder.append(line); |
| | | // } |
| | | // |
| | | // // 等待Python脚本执行完成 |
| | | // int exitCode = process.waitFor(); |
| | | // if (exitCode != 0) { |
| | | // System.out.println("Python script exited with error code: " + exitCode); |
| | | // return; |
| | | // } |
| | | // reader.close(); |
| | | // |
| | | // if (builder.length() <= 0) { |
| | | // return; |
| | | // } |
| | | // |
| | | // String result = builder.toString(); |
| | | // |
| | | // if (!Cools.isEmpty(result)) { |
| | | // if (!"1".equals(result)) { |
| | | // log.error("Fail python"); |
| | | // } |
| | | // } |
| | | // } catch (IOException | InterruptedException e) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | // log.error("python finish {}", System.currentTimeMillis() - startTime); |
| | | |
| | | // lock path |
| | | String[][] codeMatrix = mapDataDispatcher.getCodeMatrix(lev); |
| | | String[][] waveMatrix = mapDataDispatcher.initWaveMatrix(lev); |
| | | // |
| | | // // lock path |
| | | DynamicNode[][] dynamicMatrix = mapDataDispatcher.getDynamicMatrix(lev); |
| | | for (int i = 0; i < dynamicMatrix.length; i++) { |
| | | for (int j = 0; j < dynamicMatrix[i].length; j++) { |
| | |
| | | } |
| | | |
| | | stopWatch.stop(); |
| | | if (stopWatch.getTime() > 50) { |
| | | if (stopWatch.getTime() > 100) { |
| | | log.info("滤波函数花费时间为:{}毫秒......", stopWatch.getTime()); |
| | | } |
| | | |
| | |
| | | if (null == agvDetail) { |
| | | return; |
| | | } |
| | | if (agvDetail.getPos() == null || agvDetail.getPos() != 1) { |
| | | if (agvDetail.getPos() == null) { |
| | | return; |
| | | } |
| | | Long recentCode = agvDetail.getRecentCode(); |