Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

editoast: move rolling stock and rs with liveries to schemas to schemas #7128

Merged
merged 5 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 87 additions & 0 deletions editoast/editoast_schemas/src/rolling_stock.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
mod gamma;
pub use gamma::Gamma;

mod effort_curves;
pub use effort_curves::ConditionalEffortCurve;
pub use effort_curves::EffortCurve;
pub use effort_curves::EffortCurveConditions;
pub use effort_curves::EffortCurves;
pub use effort_curves::ModeEffortCurves;
pub use effort_curves::RollingStockComfortType;

mod rolling_resistance;
pub use rolling_resistance::RollingResistance;

mod energy_source;
pub use energy_source::EnergySource;
pub use energy_source::EnergyStorage;
pub use energy_source::RefillLaw;
pub use energy_source::SpeedDependantPower;

mod supported_signaling_systems;
pub use supported_signaling_systems::RollingStockSupportedSignalingSystems;

mod rolling_stock_metadata;
pub use rolling_stock_metadata::RollingStockMetadata;

mod loading_gauge_type;
pub use loading_gauge_type::LoadingGaugeType;

mod rolling_stock_livery;
pub use rolling_stock_livery::RollingStockLivery;
pub use rolling_stock_livery::RollingStockLiveryMetadata;

use serde::Deserialize;
use serde::Serialize;
use std::collections::HashMap;
use utoipa::ToSchema;

editoast_common::schemas! {
RollingStock,
gamma::schemas(),
effort_curves::schemas(),
energy_source::schemas(),
rolling_stock_livery::schemas(),
rolling_resistance::schemas(),
supported_signaling_systems::schemas(),
rolling_stock_metadata::schemas(),
loading_gauge_type::schemas(),
}

pub const ROLLING_STOCK_RAILJSON_VERSION: &str = "3.2";

#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, ToSchema)]
pub struct RollingStock {
pub id: i64,
pub name: String,
pub effort_curves: EffortCurves,
#[schema(example = "5", required)]
pub base_power_class: Option<String>,
pub length: f64,
pub max_speed: f64,
pub startup_time: f64,
pub startup_acceleration: f64,
pub comfort_acceleration: f64,
pub gamma: Gamma,
pub inertia_coefficient: f64,
pub mass: f64,
pub rolling_resistance: RollingResistance,
pub loading_gauge: LoadingGaugeType,
/// Mapping of power restriction code to power class
#[serde(default)]
#[schema(required)]
pub power_restrictions: HashMap<String, String>,
#[serde(default)]
pub energy_sources: Vec<EnergySource>,
/// The time the train takes before actually using electrical power (in seconds). Is null if the train is not electric.
#[schema(example = 5.0)]
pub electrical_power_startup_time: Option<f64>,
/// The time it takes to raise this train's pantograph in seconds. Is null if the train is not electric.
#[schema(example = 15.0)]
pub raise_pantograph_time: Option<f64>,
pub supported_signaling_systems: RollingStockSupportedSignalingSystems,
pub railjson_version: String,
/// Whether the rolling stock can be edited/deleted or not.
pub locked: bool,
pub metadata: RollingStockMetadata,
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ use strum::Display;
use strum::EnumString;
use utoipa::ToSchema;

editoast_common::schemas! {
ConditionalEffortCurve,
EffortCurve,
EffortCurves,
EffortCurveConditions,
ModeEffortCurves,
RollingStockComfortType,
}

#[derive(Clone, Debug, Default, PartialEq, Deserialize, Serialize, ToSchema, Hash)]
#[serde(deny_unknown_fields)]
pub struct EffortCurves {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ use serde::Deserialize;
use serde::Serialize;
use utoipa::ToSchema;

editoast_common::schemas! {
EnergySource,
EnergyStorage,
RefillLaw,
SpeedDependantPower,
}

// Energy sources schema

/// energy source of a rolling stock
Expand Down
4 changes: 4 additions & 0 deletions editoast/editoast_schemas/src/rolling_stock/gamma.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ use serde::Deserialize;
use serde::Serialize;
use utoipa::ToSchema;

editoast_common::schemas! {
Gamma,
}

#[derive(Clone, Debug, Default, PartialEq, Deserialize, Serialize, ToSchema, Derivative)]
#[serde(deny_unknown_fields)]
#[derivative(Hash)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ use serde::Serialize;
use strum::FromRepr;
use utoipa::ToSchema;

editoast_common::schemas! {
LoadingGaugeType,
}

#[derive(Debug, Clone, Copy, Deserialize, Serialize, PartialEq, Eq, ToSchema, Hash, FromRepr)]
pub enum LoadingGaugeType {
G1,
Expand Down
56 changes: 0 additions & 56 deletions editoast/editoast_schemas/src/rolling_stock/mod.rs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ use serde::Deserialize;
use serde::Serialize;
use utoipa::ToSchema;

editoast_common::schemas! {
RollingResistance,
}

#[derive(Clone, Debug, Default, PartialEq, Deserialize, Serialize, ToSchema, Derivative)]
#[derivative(Hash)]
#[serde(deny_unknown_fields)]
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ use serde::Deserialize;
use serde::Serialize;
use utoipa::ToSchema;

editoast_common::schemas! {
RollingStockLivery,
RollingStockLiveryMetadata,
}

#[derive(Debug, Deserialize, Serialize, ToSchema)]
pub struct RollingStockLivery {
pub id: i64,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ use serde::Deserialize;
use serde::Serialize;
use utoipa::ToSchema;

editoast_common::schemas! {
RollingStockMetadata,
}

#[derive(Clone, Debug, Default, PartialEq, Deserialize, Serialize, ToSchema)]
#[serde(deny_unknown_fields)]
pub struct RollingStockMetadata {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ use serde::Deserialize;
use serde::Serialize;
use utoipa::ToSchema;

editoast_common::schemas! {
RollingStockSupportedSignalingSystems,
}

#[derive(Clone, Debug, PartialEq, Deserialize, Serialize, ToSchema)]
pub struct RollingStockSupportedSignalingSystems(pub Vec<String>);

Expand Down
Loading
Loading