Skip to content

Commit

Permalink
editoast: fix pr comments
Browse files Browse the repository at this point in the history
Signed-off-by: Egor Berezovskiy <[email protected]>
  • Loading branch information
Wadjetz committed Nov 20, 2024
1 parent e11aee9 commit e85238a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
11 changes: 5 additions & 6 deletions editoast/src/core/simulation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,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
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::core::stdcm::STDCMPathItem;
Expand Down Expand Up @@ -67,7 +68,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 @@ -104,10 +105,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 e85238a

Please sign in to comment.