Skip to content

Commit

Permalink
Add more branch method
Browse files Browse the repository at this point in the history
  • Loading branch information
yichen88 committed Dec 4, 2018
1 parent 90c4b06 commit bad2fc7
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 6 deletions.
5 changes: 4 additions & 1 deletion py-powsybl/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
32 changes: 30 additions & 2 deletions py-powsybl/pypowsybl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,21 +426,49 @@ 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())

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):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public final class PythonCodeGenerator {

private static final Set<String> SIMPLE_TYPE = new HashSet<>(Arrays.asList("int", "boolean", "float", "double", "long", "class java.lang.String"));
private static final Set<String> SKIP_METHODS_NAME = new HashSet<>(Arrays.asList("export", "merge", "visit", "remove"));
private static final Set<String> 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 ";
Expand Down Expand Up @@ -225,8 +226,8 @@ static boolean skip(Method m, Class clazz) {
}
List<Class> 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;
}
}
Expand All @@ -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++) {
Expand Down

0 comments on commit bad2fc7

Please sign in to comment.