-
Notifications
You must be signed in to change notification settings - Fork 0
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
Refactor bus models #261
Refactor bus models #261
Conversation
- connection point for equipment connection (use static id for macro connect with default bus) - measurement point for automaton (replace default bus model) - bus of equipment for omegaref (use equipment id instead of bus id for macro connect) Signed-off-by: lisrte <[email protected]>
Signed-off-by: lisrte <[email protected]>
I need to look a bit more into this but I like the Connection/Measurement concepts |
dynawaltz/src/main/java/com/powsybl/dynawaltz/models/buses/StaticDefaultBusModel.java
Outdated
Show resolved
Hide resolved
Signed-off-by: lisrte <[email protected]>
Kudos, SonarCloud Quality Gate passed! |
Signed-off-by: lisrte <[email protected]>
Signed-off-by: lisrte <[email protected]>
Signed-off-by: lisrte <[email protected]>
Signed-off-by: lisrte <[email protected]>
Use 'eager initialized singleton' implementation for DefaultBus Signed-off-by: lisrte <[email protected]>
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.
Nice refactor
dynawaltz/src/main/java/com/powsybl/dynawaltz/models/buses/DefaultBusOfEquipment.java
Outdated
Show resolved
Hide resolved
dynawaltz/src/main/java/com/powsybl/dynawaltz/models/buses/MeasurementPoint.java
Outdated
Show resolved
Hide resolved
dynawaltz/src/main/java/com/powsybl/dynawaltz/models/buses/ConnectionPoint.java
Outdated
Show resolved
Hide resolved
Signed-off-by: lisrte <[email protected]>
Signed-off-by: Florian Dupuy <[email protected]>
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.
Sorry, some more comments/questions to discuss!
super(staticId); | ||
public final class DefaultBus implements EquipmentConnectionPoint { | ||
|
||
private static final DefaultBus INSTANCE = new DefaultBus(); |
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.
I'm wondering if we really should use the singleton pattern here. You're using it as an optimization, but I think the memory waste doesn't matter that much regarding the loss of readability and logic. There is one class for all the buses, which might be a bit confusing. It doesn't inherit AbstractDefaultModel, which is also unexpected. And it isn't handled with DefaultModelsHandler, but that's the limit of this PR, as you may have 3 models for the same bus.
@@ -20,7 +20,7 @@ | |||
/** | |||
* @author Laurent Issertial <laurent.issertial at rte-france.com> | |||
*/ | |||
public abstract class AbstractBus extends AbstractEquipmentBlackBoxModel<Bus> implements BusModel { | |||
public abstract class AbstractBus extends AbstractEquipmentBlackBoxModel<Bus> implements EquipmentConnectionPoint, ActionConnectionPoint { |
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.
I think you can remove ActionConnectionPoint here, it's not needed anymore
|
||
Optional<String> getNumCCVarName(); | ||
String getTerminalVarName(); | ||
|
||
Optional<String> getUImpinVarName(); |
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.
And then it could be String getUImpinVarName();
and String getUpuImpinVarName();
instead of the optional
} | ||
|
||
@Override | ||
public void createMacroConnections(DynaWaltzContext context) throws PowsyblException { | ||
int index = 0; | ||
for (FrequencySynchronizedModel eq : synchronizedEquipments) { | ||
createMacroConnections(eq, getVarConnectionsWith(eq), context, MacroConnectAttribute.ofIndex1(index)); | ||
createMacroConnections(eq.getConnectedBusId(), BusModel.class, this::getVarConnectionsWith, context, MacroConnectAttribute.ofIndex1(index)); | ||
BusOfFrequencySynchronizedModel busOf = new DefaultBusOfFrequencySynchronized(eq.getStaticId()); |
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.
You're using a default ("network") model here even if there is a specific bus model on the corresponding bs, I'm not sure that's ok for dynawo, could you confirm that @gautierbureau?
So in the dyd we might have
<dyn:macroConnector id="MC1">
<dyn:connect var1="numcc_node_@INDEX@" var2="@@NAME@@@NODE@_numcc"/>
</dyn:macroConnector>
<dyn:macroConnect connector="MC1" id1="FREQ_SYNC" index1="0" id2="NETWORK" name2="GEN"/>
And the node mentioned in var2 would be a bus which has got a StandardBus or InfiniteBus model mapped on it.
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.
We need to have a default bus model other types of models would not work with OmegaRef
@@ -53,7 +53,7 @@ public DefaultModelsHandler() { | |||
StaticVarCompensatorModel.class, new DefaultModelFactory<StaticVarCompensatorModel>(DefaultStaticVarCompensator::new), | |||
TransformerModel.class, new DefaultModelFactory<TransformerModel>(DefaultTransformer::new)); | |||
|
|||
powSyBlTypeToModel.put(IdentifiableType.BUS, BusModel.class); | |||
powSyBlTypeToModel.put(IdentifiableType.BUS, ActionConnectionPoint.class); |
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.
So a bus is always a ActionConnectionPoint once you're here, you were forced to bypass this handler for the two other bus interfaces. Ok about that, at least to move on, but could you put a comment here mentioning the two others default bus models being bypassed?
Signed-off-by: lisrte <[email protected]>
…nt getName method Signed-off-by: lisrte <[email protected]>
Kudos, SonarCloud Quality Gate passed! |
Please check if the PR fulfills these requirements
What kind of change does this PR introduce?
Bug fix
What is the new behavior (if this is a feature change)?
Split Bus model in three based on use case :
Does this PR introduce a breaking change or deprecate an API?