Skip to content

Commit

Permalink
editoast: add max speed to towed rs
Browse files Browse the repository at this point in the history
Signed-off-by: Egor Berezovskiy <[email protected]>
  • Loading branch information
Wadjetz committed Dec 3, 2024
1 parent 89c8fb0 commit 674edc9
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 7 deletions.
1 change: 1 addition & 0 deletions editoast/editoast_models/src/tables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,7 @@ diesel::table! {
locked -> Bool,
mass -> Float8,
length -> Float8,
max_speed -> Nullable<Float8>,
comfort_acceleration -> Float8,
startup_acceleration -> Float8,
inertia_coefficient -> Float8,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ pub struct TowedRollingStock {
/// The constant gamma braking coefficient used when NOT circulating
/// under ETCS/ERTMS signaling system in m/s^2
pub const_gamma: f64,
pub max_speed: Option<f64>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE towed_rolling_stock
DROP max_speed;
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE towed_rolling_stock
ADD max_speed FLOAT8;
11 changes: 5 additions & 6 deletions editoast/src/core/simulation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,12 @@ impl PhysicsConsistParameters {
}

pub fn compute_max_speed(&self) -> f64 {
match self.max_speed {
Some(0.0) => self.traction_engine.max_speed,
Some(max_speed_parameter) => {
self.max_speed
.filter(|max_speed_parameter| *max_speed_parameter != 0.0)
.map(|max_speed_parameter| {
f64::min(self.traction_engine.max_speed, max_speed_parameter)
}
None => self.traction_engine.max_speed,
}
})
.unwrap_or(self.traction_engine.max_speed)
}

pub fn compute_startup_acceleration(&self) -> f64 {
Expand Down
1 change: 1 addition & 0 deletions editoast/src/models/fixtures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ pub fn create_towed_rolling_stock() -> TowedRollingStock {
C: 0.0002, // In N/(m/s)²
},
const_gamma: 1.0,
max_speed: Some(35.0),
railjson_version: "3.4".to_string(),
}
}
Expand Down
3 changes: 3 additions & 0 deletions editoast/src/models/towed_rolling_stock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ pub struct TowedRollingStockModel {
pub mass: f64,
/// In m
pub length: f64,
/// In km/h
pub max_speed: Option<f64>,
pub comfort_acceleration: f64,
pub startup_acceleration: f64,
pub inertia_coefficient: f64,
Expand All @@ -48,6 +50,7 @@ impl From<TowedRollingStockModel> for TowedRollingStock {
inertia_coefficient: model.inertia_coefficient,
rolling_resistance: model.rolling_resistance,
const_gamma: model.const_gamma,
max_speed: model.max_speed,
}
}
}
Expand Down
6 changes: 5 additions & 1 deletion editoast/src/views/timetable/stdcm/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use itertools::Itertools;
use serde::Deserialize;
use serde::Serialize;
use utoipa::ToSchema;
use validator::Validate;

use crate::core::pathfinding::PathfindingInputError;
use crate::error::Result;
Expand Down Expand Up @@ -65,7 +66,7 @@ struct StepTimingData {
}

/// An STDCM request
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, ToSchema)]
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Validate, ToSchema)]
pub(super) struct Request {
/// Deprecated, first step arrival time should be used instead
pub(super) start_time: Option<DateTime<Utc>>,
Expand Down Expand Up @@ -102,10 +103,13 @@ pub(super) struct Request {
#[schema(value_type = Option<String>, example = json!(["5%", "2min/100km"]))]
pub(super) margin: Option<MarginValue>,
/// Total mass of the consist in kg
#[validate(range(exclusive_min = 0.0))]
pub(super) total_mass: Option<f64>,
/// Total length of the consist in meters
#[validate(range(exclusive_min = 0.0))]
pub(super) total_length: Option<f64>,
/// Maximum speed of the consist in km/h
#[validate(range(exclusive_min = 0.0))]
pub(super) max_speed: Option<f64>,
pub(super) loading_gauge_type: Option<LoadingGaugeType>,
}
Expand Down

0 comments on commit 674edc9

Please sign in to comment.