| | |
| | | private RealTimeSimulationConfig rtsConfig; |
| | | private static final long MILLIS_OF_ONE_DAY = 86400000; |
| | | |
| | | public String realTimeSimulate(Simu simu) throws IOException { |
| | | public String startSimulation(Simu simu) throws IOException { |
| | | InputStream stream = RealTimeSimulationService.class.getResourceAsStream("/device_info.json"); |
| | | List<DeviceInfo> deviceInfos = mapper.readValue(stream, |
| | | mapper.getTypeFactory().constructCollectionType(List.class, DeviceInfo.class)); |
| | |
| | | String serviceNameDirPath = serviceNameDir.getAbsolutePath(); |
| | | configVo.setTerrain(serviceNameDirPath + File.separator + DEM_TIF); |
| | | configVo.setLanduse(serviceNameDirPath + File.separator + "Landuse.tif"); |
| | | configVo.setEvaporation(config.getEvaporation()); |
| | | File stationFile = new File(serviceNameDir, "Station.tif"); |
| | | if (stationFile.exists()) { |
| | | configVo.setStation(stationFile.getAbsolutePath()); |
| | | } |
| | | int realTimeSimulateTime = 300; //模拟时间,默认为5min,即300s |
| | | int realTimeInterval = rtsConfig.getRealTimeInterval(); //每帧的间隔时间 |
| | | Double realTimeInterval = rtsConfig.getFrameInterval(); //每帧的间隔时间 |
| | | List<String> rainGauge = new ArrayList<>(); |
| | | rainGauge.add(newDatFile.getAbsolutePath());//raingage file |
| | | rainGauge.add("mm/min"); |
| | | configVo.setRaingage(rainGauge); |
| | | String saveName = serviceNameDir + File.separator + RESULT_ZARR; |
| | | ResultVo result = new ResultVo(saveName, realTimeSimulateTime / realTimeInterval, |
| | | ResultVo result = new ResultVo(saveName, (int) (realTimeSimulateTime / realTimeInterval), |
| | | realTimeInterval,"continue", null); |
| | | result.setSave_interval(realTimeInterval); |
| | | result.setSave_timestamp0(TimeFormatUtil.formatTime(currentTime, YYYY_MM_DD_HH_MM_SS)); |
| | |
| | | configVo.setStation(stationFile.getAbsolutePath()); |
| | | } |
| | | int realTimeSimulateTime = 300; //模拟时间,默认为5min,即300s |
| | | int realTimeInterval = rtsConfig.getRealTimeInterval(); //每帧的间隔时间 |
| | | Double realTimeInterval = rtsConfig.getFrameInterval(); //每帧的间隔时间 |
| | | configVo.getRaingage().set(0, newDatFile.getAbsolutePath()); //raingage file |
| | | ResultVo result = configVo.getResult(); |
| | | Integer lastFrames = result.getLastFrames(); |
| | |
| | | lastFrames = 0; |
| | | } |
| | | Integer saveStart = result.getSave_start(); |
| | | Integer saveInterval = result.getSave_interval(); |
| | | Double saveInterval = result.getSave_interval(); |
| | | Integer saveFrames = result.getSave_frames(); |
| | | int newStartPoint = saveStart + (saveFrames - lastFrames) * saveInterval; |
| | | int newSaveFrames = saveFrames + (realTimeSimulateTime / realTimeInterval); |
| | | int newStartPoint = (int) (saveStart + (saveFrames - lastFrames) * saveInterval); |
| | | int newSaveFrames = (int) (saveFrames + (realTimeSimulateTime / realTimeInterval)); |
| | | result.setSave_start(newStartPoint); //起始时间要在上次时间的基础上开始 |
| | | result.setLastFrames(saveFrames); |
| | | result.setSave_frames(newSaveFrames); //保留5帧,在原来的基础上增加5帧 |