Skip to content

Commit

Permalink
Sort curves and fsv results in DynamicSimulationResultDeserializer (#…
Browse files Browse the repository at this point in the history
…3269)

* Use LinkedHashMap instead of HaskMap for curves and fsv in DynamicSimulationResultDeserializer

Signed-off-by: lisrte <laurent.issertial@rte-france.com>
  • Loading branch information
Lisrte authored Mar 3, 2025
1 parent eb012ba commit 45a0812
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ public class DynamicSimulationResultDeserializer extends StdDeserializer<Dynamic
public DynamicSimulationResult deserialize(JsonParser parser, DeserializationContext ctx) throws IOException {
DynamicSimulationResult.Status status = null;
String error = "";
Map<String, DoubleTimeSeries> curves = new HashMap<>();
Map<String, Double> fsv = new HashMap<>();
Map<String, DoubleTimeSeries> curves = new LinkedHashMap<>();
Map<String, Double> fsv = new LinkedHashMap<>();
List<TimelineEvent> timeLine = new ArrayList<>();

while (parser.nextToken() != JsonToken.END_OBJECT) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.time.Duration;
import java.time.Instant;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

Expand All @@ -45,12 +46,23 @@ public String getStatusText() {

@Override
public Map<String, DoubleTimeSeries> getCurves() {
return Collections.singletonMap("curve1", TimeSeries.createDouble("curve1", new RegularTimeSeriesIndex(Instant.ofEpochMilli(0), Instant.ofEpochMilli(5), Duration.ofMillis(1)), 0.0, 0.1, 0.1, 0.2, 0.1, 0.0));
Map<String, DoubleTimeSeries> curves = new LinkedHashMap<>();
Instant startInstant = Instant.ofEpochMilli(0);
Instant endInstant = Instant.ofEpochMilli(5);
Duration timeStep = Duration.ofMillis(1);
curves.put("curve1", TimeSeries.createDouble("curve1", new RegularTimeSeriesIndex(startInstant, endInstant, timeStep), 0.0, 0.1, 0.1, 0.2, 0.1, 0.0));
curves.put("curve2", TimeSeries.createDouble("curve2", new RegularTimeSeriesIndex(startInstant, endInstant, timeStep), 0.0, 0.3, 0.3, 0.4, 0.5, 1.0));
curves.put("curve3", TimeSeries.createDouble("curve3", new RegularTimeSeriesIndex(startInstant, endInstant, timeStep), 10.0, 10.0, 10.5, 10.2, 10.1, 5.0));
return curves;
}

@Override
public Map<String, Double> getFinalStateValues() {
return Collections.singletonMap("fsv1", 20.0);
Map<String, Double> finalStateValues = new LinkedHashMap<>();
finalStateValues.put("fsv1", 20.0);
finalStateValues.put("fsv2", 30.0);
finalStateValues.put("fsv3", 10.0);
return finalStateValues;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,46 @@
"offset" : 0,
"values" : [ 0.0, 0.1, 0.1, 0.2, 0.1, 0.0 ]
} ]
}, {
"metadata" : {
"name" : "curve2",
"dataType" : "DOUBLE",
"tags" : [ ],
"regularIndex" : {
"startTime" : 0,
"endTime" : 5,
"spacing" : 1
}
},
"chunks" : [ {
"offset" : 0,
"values" : [ 0.0, 0.3, 0.3, 0.4, 0.5, 1.0 ]
} ]
}, {
"metadata" : {
"name" : "curve3",
"dataType" : "DOUBLE",
"tags" : [ ],
"regularIndex" : {
"startTime" : 0,
"endTime" : 5,
"spacing" : 1
}
},
"chunks" : [ {
"offset" : 0,
"values" : [ 10.0, 10.0, 10.5, 10.2, 10.1, 5.0 ]
} ]
} ],
"finalStateValues" : [ {
"name" : "fsv1",
"value" : 20.0
}, {
"name" : "fsv2",
"value" : 30.0
}, {
"name" : "fsv3",
"value" : 10.0
} ],
"timeLine" : [ {
"time" : 0.1,
Expand Down

0 comments on commit 45a0812

Please sign in to comment.