diff --git a/dynaflow/pom.xml b/dynaflow/pom.xml index 8bf8cbf88..6ea152520 100644 --- a/dynaflow/pom.xml +++ b/dynaflow/pom.xml @@ -42,6 +42,10 @@ ${project.groupId} powsybl-dynawo-commons + + de.vandermeer + asciitable + diff --git a/dynaflow/src/main/java/com/powsybl/dynaflow/DynaFlowParameters.java b/dynaflow/src/main/java/com/powsybl/dynaflow/DynaFlowParameters.java index fd5cf7eec..78314fe1f 100644 --- a/dynaflow/src/main/java/com/powsybl/dynaflow/DynaFlowParameters.java +++ b/dynaflow/src/main/java/com/powsybl/dynaflow/DynaFlowParameters.java @@ -19,6 +19,10 @@ import com.powsybl.loadflow.LoadFlowParameters; import com.powsybl.dynaflow.DynaFlowConstants.ActivePowerCompensation; import com.powsybl.dynaflow.DynaFlowConstants.StartingPointMode; +import de.vandermeer.asciitable.AsciiTable; +import de.vandermeer.asciitable.CWC_LongestWord; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.IOException; import java.util.*; @@ -33,6 +37,8 @@ */ public class DynaFlowParameters extends AbstractExtension { + private static final Logger LOGGER = LoggerFactory.getLogger(DynaFlowParameters.class); + /** * Inner class dedicated to Security Analysis (SA) namespace */ @@ -353,6 +359,25 @@ private static void load(DynaFlowParameters parameters, ModuleConfig config) { config.getOptionalBooleanProperty(MERGE_LOADS).ifPresent(parameters::setMergeLoads); } + public static void log(LoadFlowParameters parameters, DynaFlowParameters parametersExt) { + if (LOGGER.isInfoEnabled()) { + AsciiTable at = new AsciiTable(); + at.addRule(); + at.addRow("Name", "Value"); + at.addRule(); + for (var e : parameters.toMap().entrySet()) { + at.addRow(e.getKey(), e.getValue()); + } + for (var e : parametersExt.createMapFromParameters().entrySet()) { + at.addRow(e.getKey(), Objects.toString(e.getValue(), "")); + } + at.addRule(); + at.getRenderer().setCWC(new CWC_LongestWord()); + at.setPaddingLeftRight(1, 1); + LOGGER.info("Parameters:\n{}", at.render()); + } + } + public void update(Map properties) { Objects.requireNonNull(properties); Optional.ofNullable(properties.get(SVC_REGULATION_ON)).ifPresent(prop -> setSvcRegulationOn(Boolean.parseBoolean(prop))); diff --git a/dynaflow/src/main/java/com/powsybl/dynaflow/DynaFlowProvider.java b/dynaflow/src/main/java/com/powsybl/dynaflow/DynaFlowProvider.java index e7581daac..1c3064884 100644 --- a/dynaflow/src/main/java/com/powsybl/dynaflow/DynaFlowProvider.java +++ b/dynaflow/src/main/java/com/powsybl/dynaflow/DynaFlowProvider.java @@ -115,6 +115,7 @@ public CompletableFuture run(Network network, ComputationManager Objects.requireNonNull(workingStateId); Objects.requireNonNull(loadFlowParameters); DynaFlowParameters dynaFlowParameters = getParametersExt(loadFlowParameters); + DynaFlowParameters.log(loadFlowParameters, dynaFlowParameters); DynaFlowConfig config = Objects.requireNonNull(configSupplier.get()); ExecutionEnvironment env = new ExecutionEnvironment(config.createEnv(), WORKING_DIR_PREFIX, config.isDebug()); Command versionCmd = getVersionCommand(config); diff --git a/pom.xml b/pom.xml index 99c49ebeb..bf79c56b8 100644 --- a/pom.xml +++ b/pom.xml @@ -58,6 +58,7 @@ 17 6.4.0-RC2 4.0.14 + 0.3.2 ../distribution/target/site/jacoco-aggregate/jacoco.xml, @@ -150,6 +151,11 @@ groovy-json ${groovy.version} + + de.vandermeer + asciitable + ${asciitable.version} +