Skip to content

Commit

Permalink
editoast: add simulation summary and simulation endpoints for paced t…
Browse files Browse the repository at this point in the history
…rain

Signed-off-by: Youness CHRIFI ALAOUI <[email protected]>
  • Loading branch information
younesschrifi committed Mar 5, 2025
1 parent 260405e commit 422d56e
Show file tree
Hide file tree
Showing 9 changed files with 287 additions and 90 deletions.
33 changes: 29 additions & 4 deletions editoast/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5139,7 +5139,8 @@ components:
- $ref: '#/components/schemas/EditoastOperationErrorObjectNotFound'
- $ref: '#/components/schemas/EditoastPacedTrainErrorBatchPacedTrainNotFound'
- $ref: '#/components/schemas/EditoastPacedTrainErrorDatabase'
- $ref: '#/components/schemas/EditoastPacedTrainErrorPacedTrainNotFound'
- $ref: '#/components/schemas/EditoastPacedTrainErrorInfraNotFound'
- $ref: '#/components/schemas/EditoastPacedTrainErrorNotFound'
- $ref: '#/components/schemas/EditoastPaginationErrorInvalidPage'
- $ref: '#/components/schemas/EditoastPaginationErrorInvalidPageSize'
- $ref: '#/components/schemas/EditoastPathfindingErrorInfraNotFound'
Expand Down Expand Up @@ -5677,7 +5678,31 @@ components:
type: string
enum:
- editoast:paced_train:Database
EditoastPacedTrainErrorPacedTrainNotFound:
EditoastPacedTrainErrorInfraNotFound:
type: object
required:
- type
- status
- message
properties:
context:
type: object
required:
- infra_id
properties:
infra_id:
type: integer
message:
type: string
status:
type: integer
enum:
- 404
type:
type: string
enum:
- editoast:paced_train:InfraNotFound
EditoastPacedTrainErrorNotFound:
type: object
required:
- type
Expand All @@ -5700,7 +5725,7 @@ components:
type:
type: string
enum:
- editoast:paced_train:PacedTrainNotFound
- editoast:paced_train:NotFound
EditoastPaginationErrorInvalidPage:
type: object
required:
Expand Down Expand Up @@ -8567,7 +8592,7 @@ components:
timetable_id:
type: integer
format: int64
description: Timetable attached to the train schedule
description: Timetable attached to the paced train
nullable: true
PacedTrainResult:
allOf:
Expand Down
23 changes: 23 additions & 0 deletions editoast/src/models/paced_train.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::models::train_schedule::TrainSchedule;
use chrono::DateTime;
use chrono::Duration as ChronoDuration;
use chrono::Utc;
Expand Down Expand Up @@ -101,3 +102,25 @@ impl From<PacedTrain> for PacedTrainBase {
}
}
}

impl From<PacedTrain> for TrainSchedule {
fn from(paced_train: PacedTrain) -> Self {
Self {
id: paced_train.id,
train_name: paced_train.train_name,
labels: paced_train.labels.into(),
rolling_stock_name: paced_train.rolling_stock_name,
timetable_id: paced_train.timetable_id,
path: paced_train.path,
start_time: paced_train.start_time,
schedule: paced_train.schedule,
margins: paced_train.margins,
initial_speed: paced_train.initial_speed,
comfort: paced_train.comfort,
constraint_distribution: paced_train.constraint_distribution,
speed_limit_tag: paced_train.speed_limit_tag,
power_restrictions: paced_train.power_restrictions,
options: paced_train.options,
}
}
}
2 changes: 1 addition & 1 deletion editoast/src/views/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ pub struct InfraIdQueryParam {

#[derive(Debug, Serialize, ToSchema)]
#[serde(tag = "status", rename_all = "snake_case")]
enum SimulationSummaryResult {
pub enum SimulationSummaryResult {
/// Minimal information on a simulation's result
Success {
/// Length of a path in mm
Expand Down
Loading

0 comments on commit 422d56e

Please sign in to comment.