diff --git a/py-powsybl/README.md b/py-powsybl/README.md index 6c6283c2..f7b70190 100644 --- a/py-powsybl/README.md +++ b/py-powsybl/README.md @@ -38,7 +38,10 @@ def dump_lines_flow(network): print(len(network.get_lines())) for l in network.get_lines(): print(l.get_id() + ";" + str(l.get_terminal_1().get_i()) + ";" + str(l.get_terminal_2().get_i())) - + print(l.get_current_limits_1().get_permanent_limit()) + print(str(l.check_permanent_limit_1()) + ";" + str(l.check_permanent_limit_2())) + print(str(l.check_permanent_limit_1(0.1)) + ";" + str(l.check_permanent_limit_2(0.1))) + print(str(l.is_overloaded()) + ";" + str(l.is_overloaded(0.1))) if __name__ == '__main__': port = 3338 diff --git a/py-powsybl/pypowsybl/__init__.py b/py-powsybl/pypowsybl/__init__.py index 3df44833..8b8354d8 100644 --- a/py-powsybl/pypowsybl/__init__.py +++ b/py-powsybl/pypowsybl/__init__.py @@ -426,14 +426,36 @@ def get_terminal(self): return Terminal(self.j_instance.getTerminal()) +# Auto generated python wrapper for java class: com.powsybl.iidm.network.Branch class Branch(Connectable): def __init__(self, j_branch): Connectable.__init__(self, j_branch) self.j_instance = j_branch - def is_overloaded(self): - return self.j_instance.isOverloaded() + def check_permanent_limit_1(self, var0=None): + if var0 is None: + return self.j_instance.checkPermanentLimit1() + else: + return self.j_instance.checkPermanentLimit1(var0) + + def check_permanent_limit_2(self, var0=None): + if var0 is None: + return self.j_instance.checkPermanentLimit2() + else: + return self.j_instance.checkPermanentLimit2(var0) + + def get_current_limits_1(self): + return CurrentLimits(self.j_instance.getCurrentLimits1()) + + def get_current_limits_2(self): + return CurrentLimits(self.j_instance.getCurrentLimits2()) + + def get_overload_duration(self): + return self.j_instance.getOverloadDuration() + + def get_terminal(self, var0): + return Terminal(self.j_instance.getTerminal(var0)) def get_terminal_1(self): return Terminal(self.j_instance.getTerminal1()) @@ -441,6 +463,12 @@ def get_terminal_1(self): def get_terminal_2(self): return Terminal(self.j_instance.getTerminal2()) + def is_overloaded(self, var0=None): + if var0 is None: + return self.j_instance.isOverloaded() + else: + return self.j_instance.isOverloaded(var0) + # Auto generated python wrapper for java class: com.powsybl.iidm.network.Bus class Bus(Identifiable): diff --git a/py-powsybl/src/main/java/com/powsybl/powsybl/PythonCodeGenerator.java b/py-powsybl/src/main/java/com/powsybl/powsybl/PythonCodeGenerator.java index 2d1ef30e..b99c87ab 100644 --- a/py-powsybl/src/main/java/com/powsybl/powsybl/PythonCodeGenerator.java +++ b/py-powsybl/src/main/java/com/powsybl/powsybl/PythonCodeGenerator.java @@ -24,6 +24,7 @@ public final class PythonCodeGenerator { private static final Set SIMPLE_TYPE = new HashSet<>(Arrays.asList("int", "boolean", "float", "double", "long", "class java.lang.String")); private static final Set SKIP_METHODS_NAME = new HashSet<>(Arrays.asList("export", "merge", "visit", "remove")); + private static final Set SKIP_PARA_TYPE = new HashSet<>(Arrays.asList("Country", "Side", "Class")); private static final String BLANK_LINE = ""; private static final String A1_DEF = " def "; private static final String A2_RETURN = " return "; @@ -225,8 +226,8 @@ static boolean skip(Method m, Class clazz) { } List parameterClass = Arrays.asList(m.getParameterTypes()); for (Class c : parameterClass) { - if (c.getSimpleName().equals("Class") || c.getSimpleName().equals("Country")) { - System.out.println(m + " skipped(parameters with class)"); + if (SKIP_PARA_TYPE.contains(c.getSimpleName())) { + System.out.println(m + " skipped(parameters type)"); return true; } } @@ -252,7 +253,7 @@ static String to_python_style(String javaMethodName) { if (javaMethodName.equals("getbPerSection")) { return "get_b_per_section"; } - String[] r = javaMethodName.split("(?=\\p{Upper})"); + String[] r = javaMethodName.split("(?=\\p{Upper}|\\d)"); // Arrays.asList(r).stream().forEach(l -> System.out.println(l)); String python = ""; for (int i = 0; i < r.length - 1; i++) {