private static Path getConfiguredScript(PlatformConfig platformConfig) { Objects.requireNonNull(platformConfig); Path defaultScript = platformConfig.getConfigDir().resolve(DEFAULT_SCRIPT_NAME); return platformConfig.getOptionalModuleConfig("groovy-post-processor") .map(config -> config.getPathProperty("script", defaultScript)) .orElse(defaultScript); }
public JavaScriptPostProcessor(PlatformConfig platformConfig) { Objects.requireNonNull(platformConfig); Path defaultScript = platformConfig.getConfigDir().resolve(SCRIPT_NAME); printToStdOut = platformConfig.getOptionalModuleConfig("javaScriptPostProcessor") .map(config -> config.getBooleanProperty("printToStdOut", DEFAULT_PRINT_TO_STD_OUT)) .orElse(DEFAULT_PRINT_TO_STD_OUT); script = platformConfig.getOptionalModuleConfig("javaScriptPostProcessor") .map(config -> config.getPathProperty("script", defaultScript)) .orElse(defaultScript); }
public static SimulationDetailedParameters load(String fileName) { SimulationDetailedParameters parameters = null; Path file = PlatformConfig.defaultConfig().getConfigDir().resolve(fileName); if (Files.exists(file)) { parameters = new SimulationDetailedParameters(fileName); try (BufferedReader reader = Files.newBufferedReader(file, StandardCharsets.UTF_8)) { parse(reader, parameters); } catch (IOException e) { throw new UncheckedIOException(e); } } return parameters; }
public Map<String, BoundaryPoint> parseDefault() throws IOException { Path defaultBoundaryPoint = PlatformConfig.defaultConfig().getConfigDir().resolve("BoundaryPoint.xls"); if (!Files.exists(defaultBoundaryPoint)) { throw new PowsyblException("Boundary point sheet " + defaultBoundaryPoint + " not found"); } try (InputStream is = Files.newInputStream(defaultBoundaryPoint)) { return parse(is); } }
private InputStream getEqBoundaryFile(ReadOnlyDataSource dataSource) throws IOException { if (dataSource.exists(EQ_BOUNDARY_FILE_NAME)) { LOGGER.debug("Using custom EQ boundary file"); return dataSource.newInputStream(EQ_BOUNDARY_FILE_NAME); } else { Path path = PlatformConfig.defaultConfig().getConfigDir().resolve(EQ_BOUNDARY_FILE_NAME); if (Files.exists(path)) { return Files.newInputStream(path); } else { throw new CIM1Exception("EQ boundary file not found"); } } }
private InputStream getTpBoundaryFile(ReadOnlyDataSource dataSource) throws IOException { if (dataSource.exists(TP_BOUNDARY_FILE_NAME)) { LOGGER.debug("Using custom TP boundary file"); return dataSource.newInputStream(TP_BOUNDARY_FILE_NAME); } else { Path path = PlatformConfig.defaultConfig().getConfigDir().resolve(TP_BOUNDARY_FILE_NAME); if (Files.exists(path)) { return Files.newInputStream(path); } else { throw new CIM1Exception("TP boundary file not found"); } } }
private void writeWp43Configs(List<Contingency> contingencies, Path workingDir) throws IOException, ConfigurationException { Path baseWp43ConfigFile = PlatformConfig.defaultConfig().getConfigDir().resolve(WP43_CONFIGS_FILE_NAME); // generate one variant of the base config for all the contingency // this allow to add extra variables for some indexes HierarchicalINIConfiguration configuration = new HierarchicalINIConfiguration(baseWp43ConfigFile.toFile()); SubnodeConfiguration node = configuration.getSection("smallsignal"); node.setProperty("f_instant", parameters.getFaultEventInstant()); for (int i = 0; i < contingencies.size(); i++) { Contingency contingency = contingencies.get(i); if (contingency.getElements().isEmpty()) { throw new AssertionError("Empty contingency " + contingency.getId()); } Iterator<ContingencyElement> it = contingency.getElements().iterator(); // compute the maximum fault duration double maxDuration = getFaultDuration(contingency, it.next()); while (it.hasNext()) { maxDuration = Math.max(maxDuration, getFaultDuration(contingency, it.next())); } node.setProperty("f_duration", maxDuration); Path wp43Config = workingDir.resolve(WP43_CONFIGS_PER_FAULT_FILE_NAME.replace(CommandConstants.EXECUTION_NUMBER_PATTERN, Integer.toString(i))); try (Writer writer = Files.newBufferedWriter(wp43Config, StandardCharsets.UTF_8)) { configuration.save(writer); } } }
Path baseWp43ConfigFile = PlatformConfig.defaultConfig().getConfigDir().resolve(WP43_CONFIG_FILE_NAME); HierarchicalINIConfiguration configuration = new HierarchicalINIConfiguration(baseWp43ConfigFile.toFile());