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 6, 2025
1 parent 164c697 commit 956a5d7
Show file tree
Hide file tree
Showing 9 changed files with 363 additions and 102 deletions.
39 changes: 32 additions & 7 deletions editoast/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5140,9 +5140,10 @@ components:
- $ref: '#/components/schemas/EditoastOperationErrorInvalidPatch'
- $ref: '#/components/schemas/EditoastOperationErrorModifyId'
- $ref: '#/components/schemas/EditoastOperationErrorObjectNotFound'
- $ref: '#/components/schemas/EditoastPacedTrainErrorBatchPacedTrainNotFound'
- $ref: '#/components/schemas/EditoastPacedTrainErrorBatchNotFound'
- $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 @@ -5637,7 +5638,7 @@ components:
type: string
enum:
- editoast:operation:ObjectNotFound
EditoastPacedTrainErrorBatchPacedTrainNotFound:
EditoastPacedTrainErrorBatchNotFound:
type: object
required:
- type
Expand All @@ -5660,7 +5661,7 @@ components:
type:
type: string
enum:
- editoast:paced_train:BatchPacedTrainNotFound
- editoast:paced_train:BatchNotFound
EditoastPacedTrainErrorDatabase:
type: object
required:
Expand All @@ -5680,7 +5681,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 @@ -5703,7 +5728,7 @@ components:
type:
type: string
enum:
- editoast:paced_train:PacedTrainNotFound
- editoast:paced_train:NotFound
EditoastPaginationErrorInvalidPage:
type: object
required:
Expand Down Expand Up @@ -8570,7 +8595,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 @@ -50,6 +51,28 @@ pub struct PacedTrain {
pub step: ChronoDuration,
}

impl PacedTrain {
pub fn into_first_occurrence(self) -> TrainSchedule {
TrainSchedule {
id: self.id,
train_name: self.train_name,
labels: self.labels.into(),
rolling_stock_name: self.rolling_stock_name,
timetable_id: self.timetable_id,
path: self.path,
start_time: self.start_time,
schedule: self.schedule,
margins: self.margins,
initial_speed: self.initial_speed,
comfort: self.comfort,
constraint_distribution: self.constraint_distribution,
speed_limit_tag: self.speed_limit_tag,
power_restrictions: self.power_restrictions,
options: self.options,
}
}
}

impl From<PacedTrainBase> for PacedTrainChangeset {
fn from(
PacedTrainBase {
Expand Down
4 changes: 2 additions & 2 deletions editoast/src/views/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,9 @@ pub struct InfraIdQueryParam {
infra_id: i64,
}

#[derive(Debug, Serialize, ToSchema)]
#[derive(Debug, PartialEq, Serialize, Deserialize, 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 956a5d7

Please sign in to comment.