Skip to content

Commit 422d56e

Browse files
committed
editoast: add simulation summary and simulation endpoints for paced train
Signed-off-by: Youness CHRIFI ALAOUI <[email protected]>
1 parent 260405e commit 422d56e

File tree

9 files changed

+287
-90
lines changed

9 files changed

+287
-90
lines changed

editoast/openapi.yaml

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5139,7 +5139,8 @@ components:
51395139
- $ref: '#/components/schemas/EditoastOperationErrorObjectNotFound'
51405140
- $ref: '#/components/schemas/EditoastPacedTrainErrorBatchPacedTrainNotFound'
51415141
- $ref: '#/components/schemas/EditoastPacedTrainErrorDatabase'
5142-
- $ref: '#/components/schemas/EditoastPacedTrainErrorPacedTrainNotFound'
5142+
- $ref: '#/components/schemas/EditoastPacedTrainErrorInfraNotFound'
5143+
- $ref: '#/components/schemas/EditoastPacedTrainErrorNotFound'
51435144
- $ref: '#/components/schemas/EditoastPaginationErrorInvalidPage'
51445145
- $ref: '#/components/schemas/EditoastPaginationErrorInvalidPageSize'
51455146
- $ref: '#/components/schemas/EditoastPathfindingErrorInfraNotFound'
@@ -5677,7 +5678,31 @@ components:
56775678
type: string
56785679
enum:
56795680
- editoast:paced_train:Database
5680-
EditoastPacedTrainErrorPacedTrainNotFound:
5681+
EditoastPacedTrainErrorInfraNotFound:
5682+
type: object
5683+
required:
5684+
- type
5685+
- status
5686+
- message
5687+
properties:
5688+
context:
5689+
type: object
5690+
required:
5691+
- infra_id
5692+
properties:
5693+
infra_id:
5694+
type: integer
5695+
message:
5696+
type: string
5697+
status:
5698+
type: integer
5699+
enum:
5700+
- 404
5701+
type:
5702+
type: string
5703+
enum:
5704+
- editoast:paced_train:InfraNotFound
5705+
EditoastPacedTrainErrorNotFound:
56815706
type: object
56825707
required:
56835708
- type
@@ -5700,7 +5725,7 @@ components:
57005725
type:
57015726
type: string
57025727
enum:
5703-
- editoast:paced_train:PacedTrainNotFound
5728+
- editoast:paced_train:NotFound
57045729
EditoastPaginationErrorInvalidPage:
57055730
type: object
57065731
required:
@@ -8567,7 +8592,7 @@ components:
85678592
timetable_id:
85688593
type: integer
85698594
format: int64
8570-
description: Timetable attached to the train schedule
8595+
description: Timetable attached to the paced train
85718596
nullable: true
85728597
PacedTrainResult:
85738598
allOf:

editoast/src/models/paced_train.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use crate::models::train_schedule::TrainSchedule;
12
use chrono::DateTime;
23
use chrono::Duration as ChronoDuration;
34
use chrono::Utc;
@@ -101,3 +102,25 @@ impl From<PacedTrain> for PacedTrainBase {
101102
}
102103
}
103104
}
105+
106+
impl From<PacedTrain> for TrainSchedule {
107+
fn from(paced_train: PacedTrain) -> Self {
108+
Self {
109+
id: paced_train.id,
110+
train_name: paced_train.train_name,
111+
labels: paced_train.labels.into(),
112+
rolling_stock_name: paced_train.rolling_stock_name,
113+
timetable_id: paced_train.timetable_id,
114+
path: paced_train.path,
115+
start_time: paced_train.start_time,
116+
schedule: paced_train.schedule,
117+
margins: paced_train.margins,
118+
initial_speed: paced_train.initial_speed,
119+
comfort: paced_train.comfort,
120+
constraint_distribution: paced_train.constraint_distribution,
121+
speed_limit_tag: paced_train.speed_limit_tag,
122+
power_restrictions: paced_train.power_restrictions,
123+
options: paced_train.options,
124+
}
125+
}
126+
}

editoast/src/views/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ pub struct InfraIdQueryParam {
172172

173173
#[derive(Debug, Serialize, ToSchema)]
174174
#[serde(tag = "status", rename_all = "snake_case")]
175-
enum SimulationSummaryResult {
175+
pub enum SimulationSummaryResult {
176176
/// Minimal information on a simulation's result
177177
Success {
178178
/// Length of a path in mm

0 commit comments

Comments
 (0)