-
Notifications
You must be signed in to change notification settings - Fork 0
Connect to dynamic simulation API with full parameters #37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
5c34298
6c867ae
35b9c7a
bde07d2
fcb3e52
8544af0
4f77201
9a60a2b
84bee70
56ac185
58d35d2
1c607ae
7ecc52b
0bb81e5
ea64d49
c462ada
1ca560d
33d6035
7f769f8
36567fe
29d805b
fc6b904
a1cd783
59cdac8
6acb303
6bfccce
2adf501
e2b29c0
59f2e73
1d9c7ec
c7b425f
6461108
59d3f33
1897a59
426f8ed
285f29c
4b7cc11
81e53f3
d2d91b1
0b52864
81f23a6
13a9940
15ab5cc
20dc599
5b4ab3b
c06e198
89b02dc
99d33f0
b06b615
d889815
7bc3083
e4092da
92caf98
f9ab2c0
886ca6f
2de1581
3143c41
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/** | ||
* Copyright (c) 2020, RTE (http://www.rte-france.com) | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
package com.powsybl.dynamicsimulation.groovy; | ||
|
||
import com.powsybl.dsl.ExpressionDslLoader; | ||
import com.powsybl.dsl.GroovyScripts; | ||
import com.powsybl.dynamicsimulation.Curve; | ||
import com.powsybl.dynamicsimulation.CurvesSupplier; | ||
import com.powsybl.iidm.network.Network; | ||
import groovy.lang.Binding; | ||
import groovy.lang.GroovyCodeSource; | ||
import groovy.lang.GroovyShell; | ||
import org.codehaus.groovy.control.CompilerConfiguration; | ||
|
||
import java.io.InputStream; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
/** | ||
* TODO: remove and use core one when switching to 5.1.0 | ||
* @author Mathieu Bague <[email protected]> | ||
*/ | ||
public class GroovyCurvesSupplier implements CurvesSupplier { | ||
|
||
private final GroovyCodeSource codeSource; | ||
|
||
private final List<CurveGroovyExtension> extensions; | ||
|
||
public GroovyCurvesSupplier(InputStream is, List<CurveGroovyExtension> extensions) { | ||
this.codeSource = GroovyScripts.load(is); | ||
this.extensions = Objects.requireNonNull(extensions); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public List<Curve> get(Network network) { | ||
List<Curve> curves = new ArrayList<>(); | ||
|
||
Binding binding = new Binding(); | ||
binding.setVariable("network", network); | ||
|
||
ExpressionDslLoader.prepareClosures(binding); | ||
extensions.forEach(e -> e.load(binding, curves::add)); | ||
|
||
GroovyShell shell = new GroovyShell(binding, new CompilerConfiguration()); | ||
shell.evaluate(codeSource); | ||
|
||
return curves; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/** | ||
* Copyright (c) 2020, RTE (http://www.rte-france.com) | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
package com.powsybl.dynamicsimulation.groovy; | ||
|
||
import com.powsybl.dsl.ExpressionDslLoader; | ||
import com.powsybl.dsl.GroovyScripts; | ||
import com.powsybl.dynamicsimulation.EventModel; | ||
import com.powsybl.dynamicsimulation.EventModelsSupplier; | ||
import com.powsybl.iidm.network.Network; | ||
import groovy.lang.Binding; | ||
import groovy.lang.GroovyCodeSource; | ||
import groovy.lang.GroovyShell; | ||
import org.codehaus.groovy.control.CompilerConfiguration; | ||
|
||
import java.io.InputStream; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
/** | ||
* TODO: remove and use core one when switching to 5.1.0 | ||
* @author Marcos de Miguel <demiguelm at aia.es> | ||
*/ | ||
public class GroovyEventModelsSupplier implements EventModelsSupplier { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To remove and use core one when switching to 5.1.0 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Noted by add comment into code |
||
|
||
private final GroovyCodeSource codeSource; | ||
|
||
private final List<EventModelGroovyExtension> extensions; | ||
|
||
public GroovyEventModelsSupplier(InputStream is, List<EventModelGroovyExtension> extensions) { | ||
this.codeSource = GroovyScripts.load(is); | ||
this.extensions = Objects.requireNonNull(extensions); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public List<EventModel> get(Network network) { | ||
List<EventModel> eventModels = new ArrayList<>(); | ||
|
||
Binding binding = new Binding(); | ||
binding.setVariable("network", network); | ||
|
||
ExpressionDslLoader.prepareClosures(binding); | ||
extensions.forEach(e -> e.load(binding, eventModels::add)); | ||
|
||
GroovyShell shell = new GroovyShell(binding, new CompilerConfiguration()); | ||
shell.evaluate(codeSource); | ||
|
||
return eventModels; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,8 @@ | |
* @author Abdelsalem Hedhili <abdelsalem.hedhili at rte-france.com> | ||
*/ | ||
public enum DynamicSimulationStatus { | ||
NOT_DONE, | ||
RUNNING, | ||
COMPLETED | ||
CONVERGED, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To check but I think SUCCEED and FAILED is more accurate than CONVERGED and DIVERGED for a dynamic simulation. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But we can see that later There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In my opinion, CONVERGED and DIVERGED are two sub-states of SUCCEED. In contrast, FAILED is another state which relates to a technical issue. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok to discuss later |
||
DIVERGED | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/** | ||
* Copyright (c) 2022, RTE (http://www.rte-france.com) | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
package org.gridsuite.ds.server.dto.dynamicmapping; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
import java.util.Date; | ||
|
||
/** | ||
* @author Thang PHAM <quyet-thang.pham at rte-france.com> | ||
*/ | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Getter | ||
@Setter | ||
public class Script { | ||
|
||
private String name; | ||
|
||
// name of the original mapping | ||
private String parentName; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What are the purposes of parentName and current? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This Dto is from the one in dynamic-mapping-server, so may be some fields are not really useful in dynamic-simulation-server. The field 'current', as I see in the implementation ScriptServiceImpl#isScriptCurrent(Script) in dynamic-mapping-server, is used to say that the script generated at some moment is out of date or not (in comparing to the modified date of the mapping). This field is not used in dynamic-simulation-server since the script is always generated on-demand. I will remove this field in this Dto in dynamic-simulation-server |
||
|
||
private String script; | ||
|
||
private Date createdDate; | ||
|
||
private String parametersFile; | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* Copyright (c) 2023, RTE (http://www.rte-france.com) | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
package org.gridsuite.ds.server.dto.timeseries; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
import java.util.UUID; | ||
|
||
/** | ||
* @author Thang PHAM <quyet-thang.pham at rte-france.com> | ||
*/ | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Getter | ||
@Setter | ||
public class TimeSeriesGroupInfos { | ||
|
||
private UUID id; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To remove and use core one when switching to 5.1.0
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noted by add comment into code