-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Csa 25 voltage ra in crac api (#775)
* [CSA-25] Implement voltage remedial actions in crac API * [CSA-25] Removed unused imports * [CSA-25] Fixed indentation level * [CSA-25] Fixed Unit Tests * [CSA-25] Fixed Linter Issues * [CSA-25] Fixed Linter Issues * [CSA-25] Fixed version rule for voltage constraint * [CSA-25] Fixed null pointer exception bug * [CSA-25] Cumulative Fixes following code review on Pull Request #775 by MarthinBelthle * [CSA-25] Fixed Line Feed / Carriage Returns issues on windows hosts * [CSA-25] Added unit test on VoltageConstraintAdder for increased code coverage * [CSA-25] Cumulative enhancements --------- Co-authored-by: Fabrice Buscaylet <fabrice.buscaylet@artelys.com> Co-authored-by: Gabriel Plante <gabriel.plante@artelys.com> Co-authored-by: snoopfab <snoopfab@hotmail.com>
- Loading branch information
1 parent
def548b
commit d2d0e70
Showing
28 changed files
with
1,032 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...community/farao/data/crac_io_json/deserializers/OnVoltageConstraintArrayDeserializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* 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 com.farao_community.farao.data.crac_io_json.deserializers; | ||
|
||
import com.farao_community.farao.commons.FaraoException; | ||
import com.farao_community.farao.data.crac_api.RemedialActionAdder; | ||
import com.farao_community.farao.data.crac_api.usage_rule.OnVoltageConstraintAdder; | ||
import com.fasterxml.jackson.core.JsonParser; | ||
import com.fasterxml.jackson.core.JsonToken; | ||
|
||
import java.io.IOException; | ||
|
||
import static com.farao_community.farao.data.crac_io_json.JsonSerializationConstants.*; | ||
|
||
/** | ||
* @author Fabrice Buscaylet {@literal <fabrice.buscaylet at artelys.com>} | ||
*/ | ||
public final class OnVoltageConstraintArrayDeserializer { | ||
private OnVoltageConstraintArrayDeserializer() { | ||
} | ||
|
||
public static void deserialize(JsonParser jsonParser, RemedialActionAdder<?> ownerAdder) throws IOException { | ||
while (jsonParser.nextToken() != JsonToken.END_ARRAY) { | ||
OnVoltageConstraintAdder<?> adder = ownerAdder.newOnVoltageConstraintUsageRule(); | ||
while (!jsonParser.nextToken().isStructEnd()) { | ||
switch (jsonParser.getCurrentName()) { | ||
case INSTANT: | ||
adder.withInstant(deserializeInstant(jsonParser.nextTextValue())); | ||
break; | ||
case VOLTAGE_CNEC_ID: | ||
adder.withVoltageCnec(jsonParser.nextTextValue()); | ||
break; | ||
default: | ||
throw new FaraoException("Unexpected field in OnVoltageConstraint: " + jsonParser.getCurrentName()); | ||
} | ||
} | ||
adder.add(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
...om/farao_community/farao/data/crac_io_json/serializers/OnVoltageConstraintSerializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* 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 com.farao_community.farao.data.crac_io_json.serializers; | ||
|
||
import com.farao_community.farao.data.crac_api.usage_rule.OnVoltageConstraint; | ||
import com.fasterxml.jackson.core.JsonGenerator; | ||
import com.fasterxml.jackson.databind.SerializerProvider; | ||
|
||
import java.io.IOException; | ||
|
||
import static com.farao_community.farao.data.crac_io_json.JsonSerializationConstants.*; | ||
|
||
/** | ||
* @author Fabrice Buscaylet {@literal <fabrice.buscaylet at artelys.com>} | ||
*/ | ||
public class OnVoltageConstraintSerializer extends AbstractJsonSerializer<OnVoltageConstraint> { | ||
@Override | ||
public void serialize(OnVoltageConstraint value, JsonGenerator gen, SerializerProvider serializers) throws IOException { | ||
gen.writeStartObject(); | ||
gen.writeStringField(INSTANT, serializeInstant(value.getInstant())); | ||
gen.writeStringField(VOLTAGE_CNEC_ID, value.getVoltageCnec().getId()); | ||
gen.writeEndObject(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.