Skip to content

Commit

Permalink
editoast, python: add ts.config 'stop_at_next_signal' new field
Browse files Browse the repository at this point in the history
Signed-off-by: Louis Greiner <[email protected]>
  • Loading branch information
louisgreiner committed Dec 26, 2024
1 parent 6a105bf commit dc7b257
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,22 @@ pub struct TrainScheduleOptions {
#[derivative(Default(value = "true"))]
#[serde(default = "default_use_electrical_profiles")]
use_electrical_profiles: bool,

#[derivative(Default(value = "true"))]
#[serde(default = "default_stop_at_next_signal")] // TODO: try to set default value only at 1 location (struct)
stop_at_next_signal: bool,
}

fn default_use_electrical_profiles() -> bool {
true
}

fn default_stop_at_next_signal() -> bool {
true
}

impl TrainScheduleOptions {
pub fn stops_at_next_signal(&self) -> bool {
self.stop_at_next_signal
}
}
7 changes: 7 additions & 0 deletions editoast/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8160,6 +8160,9 @@ components:
items:
type: string
description: List of supported signaling systems
stop_at_next_signal:
type: boolean
description: Stops the train at next signal instead of on path item
PathfindingInputError:
oneOf:
- type: object
Expand Down Expand Up @@ -11346,6 +11349,8 @@ components:
options:
type: object
properties:
stop_at_next_signal:
type: boolean
use_electrical_profiles:
type: boolean
additionalProperties: false
Expand Down Expand Up @@ -11441,6 +11446,8 @@ components:
TrainScheduleOptions:
type: object
properties:
stop_at_next_signal:
type: boolean
use_electrical_profiles:
type: boolean
additionalProperties: false
Expand Down
3 changes: 3 additions & 0 deletions editoast/src/core/pathfinding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ pub struct PathfindingRequest {
pub rolling_stock_maximum_speed: f64,
/// Rolling stock length in meters:
pub rolling_stock_length: f64,
/// If the train should stop on the next signal instead of on the operational point
// TODO: test if this field is really used
pub stop_at_next_signal: bool,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, ToSchema)]
Expand Down
10 changes: 10 additions & 0 deletions editoast/src/views/path/pathfinding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ struct PathfindingInput {
/// Rolling stock length
#[schema(value_type = f64)]
rolling_stock_length: OrderedFloat<f64>,
/// Stops the train at next signal instead of on path item
// TODO: try to set default value only at 1 location (struct)
#[serde(default = "default_stop_at_next_signal")]
stop_at_next_signal: bool,
}

fn default_stop_at_next_signal() -> bool {
true
}

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, ToSchema)]
Expand Down Expand Up @@ -325,6 +333,7 @@ fn build_pathfinding_request(
.clone(),
rolling_stock_maximum_speed: pathfinding_input.rolling_stock_maximum_speed.0,
rolling_stock_length: pathfinding_input.rolling_stock_length.0,
stop_at_next_signal: pathfinding_input.stop_at_next_signal,
})
}

Expand Down Expand Up @@ -398,6 +407,7 @@ pub async fn pathfinding_from_train_batch(
.into_iter()
.map(|item| item.location)
.collect(),
stop_at_next_signal: train_schedule.options.stops_at_next_signal(),
};
to_compute.push(path_input);
to_compute_index.push(index);
Expand Down
9 changes: 8 additions & 1 deletion python/osrd_schemas/osrd_schemas/train_schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,19 @@ class PowerRestrictionRanges(RootModel):


class TrainScheduleOptions(BaseModel):
"""Optional arguments for the standalone simulation."""
"""Optional arguments :
- `ignore_electrical_profiles` : for the standalone simulation
- `stop_at_next_signal` : for dealing with stopped trains that overflow on switches during imports
"""

ignore_electrical_profiles: bool = Field(
default=False,
description="If true, the electrical profiles are ignored in the standalone simulation",
)
stop_at_next_signal: bool = Field(
default=False,
description="If true, the train will stop at the next signal instead of at the operational point",
)


if __name__ == "__main__":
Expand Down

0 comments on commit dc7b257

Please sign in to comment.