Skip to content

Commit 1cb3e07

Browse files
committed
Add more branch/busbarsection method
1 parent 90c4b06 commit 1cb3e07

File tree

3 files changed

+46
-12
lines changed

3 files changed

+46
-12
lines changed

py-powsybl/README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ def dump_lines_flow(network):
3838
print(len(network.get_lines()))
3939
for l in network.get_lines():
4040
print(l.get_id() + ";" + str(l.get_terminal_1().get_i()) + ";" + str(l.get_terminal_2().get_i()))
41-
41+
print(l.get_current_limits_1().get_permanent_limit())
42+
print(str(l.check_permanent_limit_1()) + ";" + str(l.check_permanent_limit_2()))
43+
print(str(l.check_permanent_limit_1(0.1)) + ";" + str(l.check_permanent_limit_2(0.1)))
44+
print(str(l.is_overloaded()) + ";" + str(l.is_overloaded(0.1)))
4245
4346
if __name__ == '__main__':
4447
port = 3338

py-powsybl/pypowsybl/__init__.py

+37-8
Original file line numberDiff line numberDiff line change
@@ -426,21 +426,49 @@ def get_terminal(self):
426426
return Terminal(self.j_instance.getTerminal())
427427

428428

429+
# Auto generated python wrapper for java class: com.powsybl.iidm.network.Branch
429430
class Branch(Connectable):
430431

431432
def __init__(self, j_branch):
432433
Connectable.__init__(self, j_branch)
433434
self.j_instance = j_branch
434435

435-
def is_overloaded(self):
436-
return self.j_instance.isOverloaded()
436+
def check_permanent_limit_1(self, var0=None):
437+
if var0 is None:
438+
return self.j_instance.checkPermanentLimit1()
439+
else:
440+
return self.j_instance.checkPermanentLimit1(var0)
441+
442+
def check_permanent_limit_2(self, var0=None):
443+
if var0 is None:
444+
return self.j_instance.checkPermanentLimit2()
445+
else:
446+
return self.j_instance.checkPermanentLimit2(var0)
447+
448+
def get_current_limits_1(self):
449+
return CurrentLimits(self.j_instance.getCurrentLimits1())
450+
451+
def get_current_limits_2(self):
452+
return CurrentLimits(self.j_instance.getCurrentLimits2())
453+
454+
def get_overload_duration(self):
455+
return self.j_instance.getOverloadDuration()
456+
457+
def get_terminal(self, var0):
458+
return Terminal(self.j_instance.getTerminal(var0))
437459

438460
def get_terminal_1(self):
439461
return Terminal(self.j_instance.getTerminal1())
440462

441463
def get_terminal_2(self):
442464
return Terminal(self.j_instance.getTerminal2())
443465

466+
def is_overloaded(self, var0=None):
467+
if var0 is None:
468+
return self.j_instance.isOverloaded()
469+
else:
470+
return self.j_instance.isOverloaded(var0)
471+
444472

445473
# Auto generated python wrapper for java class: com.powsybl.iidm.network.Bus
446474
class Bus(Identifiable):
@@ -843,18 +871,19 @@ def get_substation(self):
843871
return Substation(self.j_instance.getSubstation())
844872

845873

874+
# Auto generated python wrapper for java class: com.powsybl.iidm.network.BusbarSection
846875
class BusbarSection(Injection):
847876

848-
def __init__(self, j_busbar_section):
849-
Injection.__init__(self, j_busbar_section)
850-
self.j_instance = j_busbar_section
851-
852-
def get_v(self):
853-
return self.j_instance.getV()
877+
def __init__(self, j_busbarsection):
878+
Injection.__init__(self, j_busbarsection)
879+
self.j_instance = j_busbarsection
854880

855881
def get_angle(self):
856882
return self.j_instance.getAngle()
857883

884+
def get_v(self):
885+
return self.j_instance.getV()
886+
858887

859888
# Auto generated python wrapper for java class: com.powsybl.iidm.network.VoltageLevel
860889
# TODO container

py-powsybl/src/main/java/com/powsybl/powsybl/PythonCodeGenerator.java

+5-3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public final class PythonCodeGenerator {
2424

2525
private static final Set<String> SIMPLE_TYPE = new HashSet<>(Arrays.asList("int", "boolean", "float", "double", "long", "class java.lang.String"));
2626
private static final Set<String> SKIP_METHODS_NAME = new HashSet<>(Arrays.asList("export", "merge", "visit", "remove"));
27+
private static final Set<String> SKIP_PARA_TYPE = new HashSet<>(Arrays.asList("Country", "Side", "Class"));
2728
private static final String BLANK_LINE = "";
2829
private static final String A1_DEF = " def ";
2930
private static final String A2_RETURN = " return ";
@@ -38,6 +39,7 @@ private PythonCodeGenerator() {
3839
public static void main(String... args) {
3940
// Class clazz = Bus.class;
4041
// Class clazz = Branch.class;
42+
// Class clazz = BusbarSection.class;
4143
// Class clazz = Component.class;
4244
// Class clazz = Connectable.class;
4345
// Class clazz = Container.class;
@@ -225,8 +227,8 @@ static boolean skip(Method m, Class clazz) {
225227
}
226228
List<Class> parameterClass = Arrays.asList(m.getParameterTypes());
227229
for (Class c : parameterClass) {
228-
if (c.getSimpleName().equals("Class") || c.getSimpleName().equals("Country")) {
229-
System.out.println(m + " skipped(parameters with class)");
230+
if (SKIP_PARA_TYPE.contains(c.getSimpleName())) {
231+
System.out.println(m + " skipped(parameters type)");
230232
return true;
231233
}
232234
}
@@ -252,7 +254,7 @@ static String to_python_style(String javaMethodName) {
252254
if (javaMethodName.equals("getbPerSection")) {
253255
return "get_b_per_section";
254256
}
255-
String[] r = javaMethodName.split("(?=\\p{Upper})");
257+
String[] r = javaMethodName.split("(?=\\p{Upper}|\\d)");
256258
// Arrays.asList(r).stream().forEach(l -> System.out.println(l));
257259
String python = "";
258260
for (int i = 0; i < r.length - 1; i++) {

0 commit comments

Comments
 (0)