Skip to content

Commit 2227bf2

Browse files
Add the possibility to launch a state estimation on a network (#578)
* Add the possibility to launch a state estimation on a network Signed-off-by: Franck LECUYER <[email protected]> Co-authored-by: David BRAQUART <[email protected]>
1 parent fb41203 commit 2227bf2

34 files changed

+936
-72
lines changed

src/main/java/org/gridsuite/study/server/RestResponseEntityExceptionHandler.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ protected ResponseEntity<Object> handleStudyException(StudyException exception)
4343
VOLTAGE_INIT_PARAMETERS_NOT_FOUND,
4444
SECURITY_ANALYSIS_PARAMETERS_NOT_FOUND,
4545
LOADFLOW_PARAMETERS_NOT_FOUND,
46-
SENSITIVITY_ANALYSIS_PARAMETERS_NOT_FOUND
46+
SENSITIVITY_ANALYSIS_PARAMETERS_NOT_FOUND,
47+
STATE_ESTIMATION_NOT_FOUND
4748
-> ResponseEntity.status(HttpStatus.NOT_FOUND).body(exception.getType());
4849
case CASE_NOT_FOUND -> ResponseEntity.status(HttpStatus.FAILED_DEPENDENCY).body(exception.getMessage());
4950
case STUDY_ALREADY_EXISTS -> ResponseEntity.status(HttpStatus.CONFLICT).body(type);
@@ -54,7 +55,8 @@ protected ResponseEntity<Object> handleStudyException(StudyException exception)
5455
NON_EVACUATED_ENERGY_RUNNING,
5556
DYNAMIC_SIMULATION_RUNNING,
5657
SHORT_CIRCUIT_ANALYSIS_RUNNING,
57-
VOLTAGE_INIT_RUNNING
58+
VOLTAGE_INIT_RUNNING,
59+
STATE_ESTIMATION_RUNNING
5860
-> ResponseEntity.status(HttpStatus.FORBIDDEN).body(type);
5961
case NOT_ALLOWED,
6062
BAD_NODE_TYPE,

src/main/java/org/gridsuite/study/server/StudyConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ private StudyConstants() {
3434
public static final String TIME_SERIES_API_VERSION = "v1";
3535
public static final String DYNAMIC_MAPPING_API_VERSION = ""; // mapping server is now without version, must be v1 in the next time
3636
public static final String FILTER_API_VERSION = "v1";
37+
public static final String STATE_ESTIMATION_API_VERSION = "v1";
3738

3839
public static final String NETWORK_UUID = "networkUuid";
3940
public static final String CASE_UUID = "caseUuid";

src/main/java/org/gridsuite/study/server/StudyController.java

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ public class StudyController {
7777
private final LoadFlowService loadflowService;
7878
private final CaseService caseService;
7979
private final RemoteServicesInspector remoteServicesInspector;
80+
private final StateEstimationService stateEstimationService;
8081

8182
public StudyController(StudyService studyService,
8283
NetworkService networkStoreService,
@@ -90,7 +91,8 @@ public StudyController(StudyService studyService,
9091
VoltageInitService voltageInitService,
9192
LoadFlowService loadflowService,
9293
CaseService caseService,
93-
RemoteServicesInspector remoteServicesInspector) {
94+
RemoteServicesInspector remoteServicesInspector,
95+
StateEstimationService stateEstimationService) {
9496
this.studyService = studyService;
9597
this.networkModificationTreeService = networkModificationTreeService;
9698
this.networkStoreService = networkStoreService;
@@ -104,6 +106,7 @@ public StudyController(StudyService studyService,
104106
this.loadflowService = loadflowService;
105107
this.caseService = caseService;
106108
this.remoteServicesInspector = remoteServicesInspector;
109+
this.stateEstimationService = stateEstimationService;
107110
}
108111

109112
@InitBinder
@@ -1905,4 +1908,47 @@ public ResponseEntity<String> exportFilter(
19051908
@Parameter(description = "Filter uuid to be applied") @PathVariable("filterUuid") UUID filterUuid) {
19061909
return ResponseEntity.ok().contentType(MediaType.APPLICATION_JSON).body(studyService.exportFilter(studyUuid, filterUuid));
19071910
}
1911+
1912+
@PostMapping(value = "/studies/{studyUuid}/nodes/{nodeUuid}/state-estimation/run")
1913+
@Operation(summary = "run state estimation on study")
1914+
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The state estimation has started")})
1915+
public ResponseEntity<Void> runStateEstimation(@Parameter(description = "studyUuid") @PathVariable("studyUuid") UUID studyUuid,
1916+
@Parameter(description = "nodeUuid") @PathVariable("nodeUuid") UUID nodeUuid,
1917+
@RequestHeader(HEADER_USER_ID) String userId) {
1918+
studyService.assertIsNodeNotReadOnly(nodeUuid);
1919+
studyService.runStateEstimation(studyUuid, nodeUuid, userId);
1920+
return ResponseEntity.ok().build();
1921+
}
1922+
1923+
@GetMapping(value = "/studies/{studyUuid}/nodes/{nodeUuid}/state-estimation/result")
1924+
@Operation(summary = "Get a state estimation result on study")
1925+
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The state estimation result"),
1926+
@ApiResponse(responseCode = "204", description = "No state estimation has been done yet"),
1927+
@ApiResponse(responseCode = "404", description = "The state estimation has not been found")})
1928+
public ResponseEntity<String> getStateEstimationResult(@Parameter(description = "study UUID") @PathVariable("studyUuid") UUID studyUuid,
1929+
@Parameter(description = "nodeUuid") @PathVariable("nodeUuid") UUID nodeUuid) {
1930+
String result = stateEstimationService.getStateEstimationResult(nodeUuid);
1931+
return result != null ? ResponseEntity.ok().body(result) :
1932+
ResponseEntity.noContent().build();
1933+
}
1934+
1935+
@GetMapping(value = "/studies/{studyUuid}/nodes/{nodeUuid}/state-estimation/status")
1936+
@Operation(summary = "Get the state estimation status on study")
1937+
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The state estimation status"),
1938+
@ApiResponse(responseCode = "204", description = "No state estimation has been done yet"),
1939+
@ApiResponse(responseCode = "404", description = "The state estimation status has not been found")})
1940+
public ResponseEntity<String> getStateEstimationStatus(@Parameter(description = "Study UUID") @PathVariable("studyUuid") UUID studyUuid,
1941+
@Parameter(description = "nodeUuid") @PathVariable("nodeUuid") UUID nodeUuid) {
1942+
String status = stateEstimationService.getStateEstimationStatus(nodeUuid);
1943+
return status != null ? ResponseEntity.ok().body(status) : ResponseEntity.noContent().build();
1944+
}
1945+
1946+
@PutMapping(value = "/studies/{studyUuid}/nodes/{nodeUuid}/state-estimation/stop")
1947+
@Operation(summary = "stop state estimation on study")
1948+
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The state estimation has been stopped")})
1949+
public ResponseEntity<Void> stopStateEstimation(@Parameter(description = "Study uuid") @PathVariable("studyUuid") UUID studyUuid,
1950+
@Parameter(description = "nodeUuid") @PathVariable("nodeUuid") UUID nodeUuid) {
1951+
stateEstimationService.stopStateEstimation(studyUuid, nodeUuid);
1952+
return ResponseEntity.ok().build();
1953+
}
19081954
}

src/main/java/org/gridsuite/study/server/StudyException.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ public enum Type {
107107
NOT_IMPLEMENTED,
108108
EVALUATE_FILTER_FAILED,
109109
GET_USER_PROFILE_FAILED,
110+
STATE_ESTIMATION_RUNNING,
111+
STATE_ESTIMATION_NOT_FOUND,
112+
STATE_ESTIMATION_ERROR,
110113
}
111114

112115
private final Type type;

src/main/java/org/gridsuite/study/server/SupervisionController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public SupervisionController(SupervisionService supervisionService, StudyService
4949

5050
@DeleteMapping(value = "/computation/results")
5151
@Operation(summary = "delete all results of a given computation")
52-
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "all loadflow results have been deleted")})
52+
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "all computation results have been deleted")})
5353
public ResponseEntity<Integer> deleteComputationResults(@Parameter(description = "Computation type") @RequestParam("type") ComputationType computationType,
5454
@Parameter(description = "Dry run") @RequestParam("dryRun") boolean dryRun) {
5555
return ResponseEntity.ok().contentType(MediaType.APPLICATION_JSON).body(supervisionService.deleteComputationResults(computationType, dryRun));

src/main/java/org/gridsuite/study/server/dto/ComputationType.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ public enum ComputationType {
2828
NotificationService.UPDATE_TYPE_DYNAMIC_SIMULATION_FAILED),
2929
SHORT_CIRCUIT_ONE_BUS("One bus Short circuit analysis", "oneBusShortCircuitAnalysisResultUuid",
3030
NotificationService.UPDATE_TYPE_ONE_BUS_SHORT_CIRCUIT_STATUS, NotificationService.UPDATE_TYPE_ONE_BUS_SHORT_CIRCUIT_RESULT,
31-
NotificationService.UPDATE_TYPE_ONE_BUS_SHORT_CIRCUIT_FAILED);
31+
NotificationService.UPDATE_TYPE_ONE_BUS_SHORT_CIRCUIT_FAILED),
32+
STATE_ESTIMATION("State estimation", "stateEstimationResultUuid",
33+
NotificationService.UPDATE_TYPE_STATE_ESTIMATION_STATUS, NotificationService.UPDATE_TYPE_STATE_ESTIMATION_RESULT,
34+
NotificationService.UPDATE_TYPE_STATE_ESTIMATION_FAILED);
3235

3336
private final String label; // used for logs
3437
private final String resultUuidLabel;

src/main/java/org/gridsuite/study/server/dto/DeleteNodeInfos.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ public class DeleteNodeInfos {
4343
private List<UUID> voltageInitResultUuids = new ArrayList<>();
4444
private List<UUID> dynamicSimulationResultUuids = new ArrayList<>();
4545

46+
private List<UUID> stateEstimationResultUuids = new ArrayList<>();
47+
4648
public void addModificationGroupUuid(UUID modificationGroupUuid) {
4749
modificationGroupUuids.add(modificationGroupUuid);
4850
}
@@ -86,4 +88,8 @@ public void addOneBusShortCircuitAnalysisResultUuid(UUID oneBusShortCircuitAnaly
8688
public void addVoltageInitResultUuid(UUID voltageInitResultUuid) {
8789
voltageInitResultUuids.add(voltageInitResultUuid);
8890
}
91+
92+
public void addStateEstimationResultUuid(UUID stateEstimationResultUuid) {
93+
stateEstimationResultUuids.add(stateEstimationResultUuid);
94+
}
8995
}

src/main/java/org/gridsuite/study/server/dto/InvalidateNodeInfos.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ public class InvalidateNodeInfos {
4646
private List<UUID> voltageInitResultUuids = new ArrayList<>();
4747
private List<UUID> dynamicSimulationResultUuids = new ArrayList<>();
4848

49+
private List<UUID> stateEstimationResultUuids = new ArrayList<>();
50+
4951
public void addReportUuid(UUID reportUuid) {
5052
reportUuids.add(reportUuid);
5153
}
@@ -92,4 +94,8 @@ public void addVoltageInitResultUuid(UUID voltageInitResultUuid) {
9294
public void addDynamicSimulationResultUuid(UUID dynamicSimulationResultUuid) {
9395
dynamicSimulationResultUuids.add(dynamicSimulationResultUuid);
9496
}
97+
98+
public void addStateEstimationResultUuid(UUID stateEstimationResultUuid) {
99+
stateEstimationResultUuids.add(stateEstimationResultUuid);
100+
}
95101
}

src/main/java/org/gridsuite/study/server/dto/NodeModificationInfos.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,6 @@ public class NodeModificationInfos {
4040
private UUID voltageInitUuid;
4141

4242
private UUID dynamicSimulationUuid;
43+
44+
private UUID stateEstimationUuid;
4345
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* Copyright (c) 2024, RTE (http://www.rte-france.com)
3+
* This Source Code Form is subject to the terms of the Mozilla Public
4+
* License, v. 2.0. If a copy of the MPL was not distributed with this
5+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
6+
*/
7+
package org.gridsuite.study.server.dto;
8+
9+
/**
10+
* @author Franck Lecuyer <franck.lecuyer at rte-france.com>
11+
*/
12+
public enum StateEstimationStatus {
13+
NOT_DONE,
14+
RUNNING,
15+
COMPLETED,
16+
}

0 commit comments

Comments
 (0)