diff --git a/editoast/Cargo.lock b/editoast/Cargo.lock index 2103747545b..1053fbb33c4 100644 --- a/editoast/Cargo.lock +++ b/editoast/Cargo.lock @@ -502,6 +502,21 @@ version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" +[[package]] +name = "bit-set" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08807e080ed7f9d5433fa9b275196cfc35414f66a0c79d864dc51a0d825231a3" +dependencies = [ + "bit-vec", +] + +[[package]] +name = "bit-vec" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e764a1d40d510daf35e07be9eb06e75770908c27d411ee6c92109c9840eaaf7" + [[package]] name = "bitflags" version = "2.11.1" @@ -2607,7 +2622,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "525e9ff3e1a4be2fbea1fdf0e98686a6d98b4d8f937e1bf7402245af1909e8c3" dependencies = [ "byteorder-lite", - "quick-error", + "quick-error 2.0.1", ] [[package]] @@ -3743,6 +3758,25 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "proptest" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b45fcc2344c680f5025fe57779faef368840d0bd1f42f216291f0dc4ace4744" +dependencies = [ + "bit-set", + "bit-vec", + "bitflags", + "num-traits", + "rand 0.9.4", + "rand_chacha", + "rand_xorshift", + "regex-syntax", + "rusty-fork", + "tempfile", + "unarray", +] + [[package]] name = "prost" version = "0.14.3" @@ -3838,6 +3872,12 @@ version = "0.1.29" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e0c5ccf5294c6ccd63a74f1565028353830a9c2f5eb0c682c355c471726a6e3f" +[[package]] +name = "quick-error" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" + [[package]] name = "quick-error" version = "2.0.1" @@ -3995,6 +4035,15 @@ version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "63b8176103e19a2643978565ca18b50549f6101881c443590420e4dc998a3c69" +[[package]] +name = "rand_xorshift" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "513962919efc330f829edb2535844d1b912b0fbe2ca165d613e4e8788bb05a5a" +dependencies = [ + "rand_core 0.9.5", +] + [[package]] name = "rangemap" version = "1.7.1" @@ -4380,6 +4429,18 @@ version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" +[[package]] +name = "rusty-fork" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc6bf79ff24e648f6da1f8d1f011e9cac26491b619e6b9280f2b47f1774e6ee2" +dependencies = [ + "fnv", + "quick-error 1.2.3", + "tempfile", + "wait-timeout", +] + [[package]] name = "ryu" version = "1.0.23" @@ -4415,6 +4476,7 @@ dependencies = [ "enum-map", "geos", "iso8601", + "proptest", "rand 0.10.1", "regex", "rstest", @@ -4918,7 +4980,7 @@ dependencies = [ "fax", "flate2", "half", - "quick-error", + "quick-error 2.0.1", "weezl", "zune-jpeg", ] @@ -5364,6 +5426,12 @@ dependencies = [ "syn", ] +[[package]] +name = "unarray" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eaea85b334db583fe3274d12b4cd1880032beab409c0d774be044d4480ab9a94" + [[package]] name = "unicase" version = "2.9.0" @@ -5508,6 +5576,15 @@ version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" +[[package]] +name = "wait-timeout" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ac3b126d3914f9849036f826e054cbabdc8519970b8998ddaf3b5bd3c65f11" +dependencies = [ + "libc", +] + [[package]] name = "walkdir" version = "2.5.0" diff --git a/editoast/Cargo.toml b/editoast/Cargo.toml index 00ecca16ab0..9df3501100f 100644 --- a/editoast/Cargo.toml +++ b/editoast/Cargo.toml @@ -113,6 +113,7 @@ postgis_diesel = { version = "3.1.0", features = ["serde"] } postgres-openssl = "0.5.3" pretty_assertions = "1.4.1" proc-macro2 = "1.0" +proptest = "1.11.0" quote = "1.0" rand = "0.10.1" rangemap = "1.7.1" diff --git a/editoast/core_client/src/pathfinding.rs b/editoast/core_client/src/pathfinding.rs index e2ec58ad76e..496b14a63b9 100644 --- a/editoast/core_client/src/pathfinding.rs +++ b/editoast/core_client/src/pathfinding.rs @@ -1,10 +1,13 @@ use std::collections::BTreeSet; +use std::collections::HashSet; use ordered_float::OrderedFloat; use schemas::infra::Direction; use schemas::infra::TrackOffset; use schemas::primitives::Identifier; use schemas::rolling_stock::LoadingGaugeType; +use schemas::rolling_stock::SupportedSignalingSystemVariant; +use schemas::rolling_stock::hashing_supported_signaling_systems_variant; use schemas::train_schedule::PathItemLocation; use serde::Deserialize; use serde::Serialize; @@ -15,7 +18,8 @@ use crate::Json; use crate::RawError; use crate::WorkerKey; -#[derive(Debug, Hash, Serialize)] +#[derive(Debug, educe::Educe, Serialize)] +#[educe(Hash)] pub struct PathfindingRequest { /// Infrastructure id pub infra: i64, @@ -31,7 +35,8 @@ pub struct PathfindingRequest { /// Empty if does not support any electrification pub rolling_stock_supported_electrifications: BTreeSet, /// List of supported signaling systems - pub rolling_stock_supported_signaling_systems: BTreeSet, + #[educe(Hash(method(hashing_supported_signaling_systems_variant)))] + pub rolling_stock_supported_signaling_systems: HashSet, /// Maximum speed of the rolling stock pub rolling_stock_maximum_speed: OrderedFloat, /// Rolling stock length in meters: diff --git a/editoast/core_client/src/stdcm.rs b/editoast/core_client/src/stdcm.rs index 7e66b6e7af2..764108be329 100644 --- a/editoast/core_client/src/stdcm.rs +++ b/editoast/core_client/src/stdcm.rs @@ -1,9 +1,10 @@ -use std::collections::BTreeSet; use std::collections::HashSet; use chrono::DateTime; use chrono::Utc; use schemas::rolling_stock::LoadingGaugeType; +use schemas::rolling_stock::SupportedSignalingSystem; +use schemas::rolling_stock::hashing_supported_signaling_systems; use schemas::train_schedule::Comfort; use schemas::train_schedule::MarginValue; use serde::Deserialize; @@ -123,11 +124,13 @@ pub struct UndirectedTrackRange { } /// Represents a physics consist. -#[derive(Serialize, Deserialize, Clone, Debug, ToSchema, Hash, PartialEq, Eq)] +#[derive(Serialize, Deserialize, Clone, Debug, ToSchema, educe::Educe, PartialEq, Eq)] +#[educe(Hash)] #[schema(as = CoreConsistConfiguration)] pub struct ConsistConfiguration { /// List of supported signaling systems - pub supported_signaling_systems: BTreeSet, + #[educe(Hash(method(hashing_supported_signaling_systems)))] + pub supported_signaling_systems: HashSet, pub speed_limit_tag: Option, /// The loading gauge of the rolling stock pub loading_gauge_type: LoadingGaugeType, diff --git a/editoast/core_task/src/envs/pathfinding.rs b/editoast/core_task/src/envs/pathfinding.rs index 3dbe78628a3..e94c62b677a 100644 --- a/editoast/core_task/src/envs/pathfinding.rs +++ b/editoast/core_task/src/envs/pathfinding.rs @@ -1,5 +1,6 @@ use std::collections::BTreeSet; use std::collections::HashMap; +use std::collections::HashSet; use std::hash::DefaultHasher; use std::hash::Hash; use std::hash::Hasher as _; @@ -14,6 +15,8 @@ use itertools::Itertools; use ordered_float::OrderedFloat; use schemas::infra::TrackOffset; use schemas::rolling_stock::LoadingGaugeType; +use schemas::rolling_stock::SupportedSignalingSystemVariant; +use schemas::rolling_stock::hashing_supported_signaling_systems_variant; use tokio::sync::Mutex; use crate::CoreEnv; @@ -152,7 +155,8 @@ where } } -#[derive(Debug, Hash, PartialEq, Eq)] +#[derive(Debug, educe::Educe, PartialEq, Eq)] +#[educe(Hash)] #[cfg_attr(test, derive(Clone))] pub struct PathfindingConsist { pub loading_gauge: LoadingGaugeType, @@ -161,7 +165,8 @@ pub struct PathfindingConsist { /// Supported electrification modes (leave empty for unelectrified consists) pub supported_electrifications: BTreeSet, /// A list of supported signaling systems - pub supported_signaling_systems: BTreeSet, + #[educe(Hash(method(hashing_supported_signaling_systems_variant)))] + pub supported_signaling_systems: HashSet, pub maximum_speed: OrderedFloat, /// Consist length in meters pub length: OrderedFloat, @@ -457,7 +462,7 @@ pub(crate) mod test_data { loading_gauge: LoadingGaugeType::GB, thermal: true, supported_electrifications: BTreeSet::new(), - supported_signaling_systems: BTreeSet::from(["BAPR".to_owned()]), + supported_signaling_systems: HashSet::from([SupportedSignalingSystemVariant::BAPR]), maximum_speed: OrderedFloat::from(100.0), length: OrderedFloat::from(id as f64), speed_limit_tag: Some("MA100".to_owned()), diff --git a/editoast/openapi.yaml b/editoast/openapi.yaml index 279df70719d..418316f5891 100644 --- a/editoast/openapi.yaml +++ b/editoast/openapi.yaml @@ -12167,7 +12167,7 @@ components: rolling_stock_supported_signaling_systems: type: array items: - type: string + $ref: '#/components/schemas/SupportedSignalingSystemVariant' description: List of supported signaling systems uniqueItems: true speed_limit_tag: @@ -15210,6 +15210,15 @@ components: type: string enum: - ETCS_LEVEL2 + SupportedSignalingSystemVariant: + type: string + description: Auto-generated discriminant enum variants + enum: + - BAL + - BAPR + - TVM300 + - TVM430 + - ETCS_LEVEL2 Switch: type: object required: diff --git a/editoast/schemas/Cargo.toml b/editoast/schemas/Cargo.toml index 33faf5cb0b4..739493eddc4 100644 --- a/editoast/schemas/Cargo.toml +++ b/editoast/schemas/Cargo.toml @@ -27,6 +27,7 @@ utoipa.workspace = true uuid.workspace = true [dev-dependencies] +proptest.workspace = true rstest.workspace = true [lints] diff --git a/editoast/schemas/src/rolling_stock.rs b/editoast/schemas/src/rolling_stock.rs index 37a26e25c81..04e0f9badc3 100644 --- a/editoast/schemas/src/rolling_stock.rs +++ b/editoast/schemas/src/rolling_stock.rs @@ -20,6 +20,9 @@ pub use etcs_brake_params::EtcsBrakeParams; mod supported_signaling_system; pub use supported_signaling_system::SupportedSignalingSystem; +pub use supported_signaling_system::SupportedSignalingSystemVariant; +pub use supported_signaling_system::hashing_supported_signaling_systems; +pub use supported_signaling_system::hashing_supported_signaling_systems_variant; mod rolling_stock_metadata; pub use rolling_stock_metadata::RollingStockMetadata; @@ -55,7 +58,6 @@ use serde::Deserialize; use serde::Deserializer; use serde::Serialize; use serde::Serializer; -use std::collections::BTreeSet; use std::collections::HashMap; use std::collections::HashSet; use utoipa::ToSchema; @@ -121,11 +123,8 @@ pub struct RollingStock { } impl RollingStock { - pub fn supported_signaling_systems(&self) -> BTreeSet { - self.supported_signaling_systems - .iter() - .map(|s| s.to_string()) - .collect() + pub fn supported_signaling_systems(&self) -> HashSet { + self.supported_signaling_systems.clone() } pub fn get_etcs_brake_params(&self) -> Option<&EtcsBrakeParams> { diff --git a/editoast/schemas/src/rolling_stock/supported_signaling_system.rs b/editoast/schemas/src/rolling_stock/supported_signaling_system.rs index 2839e857b7a..4c5c50b2741 100644 --- a/editoast/schemas/src/rolling_stock/supported_signaling_system.rs +++ b/editoast/schemas/src/rolling_stock/supported_signaling_system.rs @@ -1,3 +1,7 @@ +use std::collections::HashSet; +use std::hash::Hash; +use std::hash::Hasher; + use educe::Educe; use serde::Deserialize; use serde::Serialize; @@ -6,11 +10,25 @@ use utoipa::ToSchema; use crate::rolling_stock::EtcsBrakeParams; -#[derive(Clone, Debug, Deserialize, Serialize, Display, Educe, ToSchema, strum::IntoStaticStr)] +#[derive( + Clone, + Debug, + Deserialize, + Serialize, + Display, + Educe, + ToSchema, + strum::IntoStaticStr, + strum::EnumDiscriminants, +)] #[educe(Hash, Eq, PartialEq)] #[serde(tag = "type")] #[schema(title_variants)] #[allow(clippy::large_enum_variant)] +#[strum_discriminants( + name(SupportedSignalingSystemVariant), + derive(Deserialize, Serialize, Display, Hash, ToSchema, strum::IntoStaticStr) +)] pub enum SupportedSignalingSystem { BAL, BAPR, @@ -18,8 +36,154 @@ pub enum SupportedSignalingSystem { TVM430, #[strum(to_string = "ETCS_LEVEL2")] #[serde(rename = "ETCS_LEVEL2")] + #[strum_discriminants(strum(to_string = "ETCS_LEVEL2"))] + #[strum_discriminants(serde(rename = "ETCS_LEVEL2"))] EtcsLevel2 { #[educe(Hash(ignore), PartialEq(ignore))] brake_params: EtcsBrakeParams, }, } + +impl SupportedSignalingSystem { + const fn discriminant(&self) -> u32 { + match self { + SupportedSignalingSystem::BAL => 0, + SupportedSignalingSystem::BAPR => 1, + SupportedSignalingSystem::TVM300 => 2, + SupportedSignalingSystem::TVM430 => 3, + SupportedSignalingSystem::EtcsLevel2 { .. } => 4, + } + } +} + +impl SupportedSignalingSystemVariant { + const fn discriminant(&self) -> u32 { + match self { + SupportedSignalingSystemVariant::BAL => 0, + SupportedSignalingSystemVariant::BAPR => 1, + SupportedSignalingSystemVariant::TVM300 => 2, + SupportedSignalingSystemVariant::TVM430 => 3, + SupportedSignalingSystemVariant::EtcsLevel2 => 4, + } + } +} + +pub fn hashing_supported_signaling_systems( + iter: &HashSet, + state: &mut H, +) where + H: Hasher, +{ + let hash: u64 = iter + .iter() + .map(SupportedSignalingSystem::discriminant) + // Each discriminant correspond to one specific bit of a `u64` + .map(|discriminant| 1u64.wrapping_shl(discriminant)) + // Create a unique bitmask + .reduce(std::ops::BitOr::bitor) + .unwrap_or(0); + Hash::hash(&hash, state) +} + +pub fn hashing_supported_signaling_systems_variant( + iter: &HashSet, + state: &mut H, +) where + H: Hasher, +{ + let hash: u64 = iter + .iter() + .map(SupportedSignalingSystemVariant::discriminant) + // Each discriminant correspond to one specific bit of a `u64` + .map(|discriminant| 1u64.wrapping_shl(discriminant)) + // Create a unique bitmask + .reduce(std::ops::BitOr::bitor) + .unwrap_or(0); + Hash::hash(&hash, state) +} + +#[cfg(test)] +mod tests { + use super::*; + + mod hash { + use super::*; + use SupportedSignalingSystemVariant::*; + + use proptest::prelude::*; + + fn supported_signaling_system_strategy_variant() + -> impl Strategy { + prop_oneof![ + Just(BAL), + Just(BAPR), + Just(TVM300), + Just(TVM430), + Just(EtcsLevel2) + ] + .boxed() + } + + fn hash(iter: &HashSet) -> u64 { + let mut state = std::hash::DefaultHasher::new(); + hashing_supported_signaling_systems_variant(iter, &mut state); + state.finish() + } + + proptest! { + #[test] + fn remove_element_has_different_hash( + mut a in proptest::collection::hash_set(supported_signaling_system_strategy_variant(), 0..10), + s in supported_signaling_system_strategy_variant(), + ) { + let hash_before = hash(&a); + let is_removed = a.remove(&s); + let hash_after = hash(&a); + if is_removed { + assert_ne!(hash_before, hash_after); + } else { + assert_eq!(hash_before, hash_after); + } + } + + #[test] + fn same_hashset_has_same_hash( + a in proptest::collection::hash_set(supported_signaling_system_strategy_variant(), 0..10), + b in proptest::collection::hash_set(supported_signaling_system_strategy_variant(), 0..10) + ) { + if a == b { + assert_eq!(hash(&a), hash(&b)); + } else { + assert_ne!(hash(&a), hash(&b)); + } + } + + #[test] + fn same_hash_has_an_empty_difference( + a in proptest::collection::hash_set(supported_signaling_system_strategy_variant(), 0..10), + b in proptest::collection::hash_set(supported_signaling_system_strategy_variant(), 0..10) + ) { + if hash(&a) == hash(&b) { + assert!(a.symmetric_difference(&b).count() == 0); + } else { + assert!(a.symmetric_difference(&b).count() > 0); + } + } + + #[test] + fn different_signaling_system_has_different_hash( + a in supported_signaling_system_strategy_variant(), + b in supported_signaling_system_strategy_variant(), + ) { + let same_signaling_system= a == b; + let hash_a = hash(&HashSet::from([a])); + let hash_b = hash(&HashSet::from([b])); + if same_signaling_system { + assert_eq!(hash_a, hash_b); + } else { + assert_ne!(hash_a , hash_b); + } + } + } + } +} diff --git a/editoast/src/views/path/pathfinding.rs b/editoast/src/views/path/pathfinding.rs index f5b2cc90a89..9ea25f2e119 100644 --- a/editoast/src/views/path/pathfinding.rs +++ b/editoast/src/views/path/pathfinding.rs @@ -1,5 +1,6 @@ use std::collections::BTreeSet; use std::collections::HashMap; +use std::collections::HashSet; use std::collections::hash_map::DefaultHasher; use std::hash::Hash; use std::hash::Hasher; @@ -20,8 +21,11 @@ use core_client::pathfinding::PathfindingRequest; use core_client::pathfinding::PathfindingResultSuccess; use database::DbConnection; use educe::Educe; +use itertools::Itertools; use ordered_float::OrderedFloat; use schemas::rolling_stock::LoadingGaugeType; +use schemas::rolling_stock::SupportedSignalingSystemVariant; +use schemas::rolling_stock::hashing_supported_signaling_systems_variant; use schemas::train_schedule::PathItemLocation; use schemas::train_schedule::TrainScheduleLike; use serde::Deserialize; @@ -43,7 +47,8 @@ use editoast_models::rolling_stock::RollingStock; /// Path input is described by some rolling stock information /// and a list of path waypoints -#[derive(Deserialize, Clone, Debug, Hash, ToSchema)] +#[derive(Deserialize, Clone, Debug, educe::Educe, ToSchema)] +#[educe(Hash)] #[cfg_attr(test, derive(Serialize))] pub(in crate::views) struct PathfindingInput { /// The loading gauge of the rolling stock @@ -54,7 +59,8 @@ pub(in crate::views) struct PathfindingInput { /// Empty if does not support any electrification rolling_stock_supported_electrifications: BTreeSet, /// List of supported signaling systems - rolling_stock_supported_signaling_systems: BTreeSet, + #[educe(Hash(method(hashing_supported_signaling_systems_variant)))] + rolling_stock_supported_signaling_systems: HashSet, /// List of waypoints given to the pathfinding path_items: Vec, /// Rolling stock maximum speed @@ -84,7 +90,10 @@ impl PathfindingInput { .supported_electrification(), rolling_stock_supported_signaling_systems: consist .traction_engine - .supported_signaling_systems(), + .supported_signaling_systems + .iter() + .map_into() + .collect(), rolling_stock_maximum_speed: OrderedFloat(units::meter_per_second::from( consist.compute_max_speed(), )), @@ -517,6 +526,7 @@ pub async fn pathfinding_from_train_batch( #[cfg(test)] pub mod tests { use std::collections::BTreeSet; + use std::collections::HashSet; use axum::http::StatusCode; use core_client::mocking::MockingClient; @@ -526,6 +536,7 @@ pub mod tests { use core_client::pathfinding::TrainPath; use pretty_assertions::assert_eq; use schemas::rolling_stock::LoadingGaugeType; + use schemas::rolling_stock::SupportedSignalingSystemVariant; use schemas::train_schedule::OperationalPointPartReference; use schemas::train_schedule::OperationalPointReference; use schemas::train_schedule::PathItemLocation; @@ -541,9 +552,9 @@ pub mod tests { rolling_stock_loading_gauge: LoadingGaugeType::G1, rolling_stock_is_thermal: true, rolling_stock_supported_electrifications: BTreeSet::new(), - rolling_stock_supported_signaling_systems: BTreeSet::from([ - "BAL".into(), - "BAPR".into(), + rolling_stock_supported_signaling_systems: HashSet::from([ + SupportedSignalingSystemVariant::BAL, + SupportedSignalingSystemVariant::BAPR, ]), rolling_stock_maximum_speed: 22.0.into(), rolling_stock_length: 26.0.into(), diff --git a/editoast/src/views/rolling_stock.rs b/editoast/src/views/rolling_stock.rs index fed28c9985f..05be61c4f80 100644 --- a/editoast/src/views/rolling_stock.rs +++ b/editoast/src/views/rolling_stock.rs @@ -746,11 +746,14 @@ pub mod tests { rolling_stock.startup_time ); let rolling_stock: schemas::RollingStock = rolling_stock.into(); - assert_eq!( + assert!( rolling_stock .supported_signaling_systems() - .contains("ETCS_LEVEL2"), - false + .iter() + .all(|sss| !matches!( + sss, + schemas::rolling_stock::SupportedSignalingSystem::EtcsLevel2 { .. } + )) ); } @@ -1012,11 +1015,14 @@ pub mod tests { let rolling_stock: schemas::RollingStock = rolling_stock.into(); // THEN - assert_eq!( + assert!( rolling_stock .supported_signaling_systems() - .contains("ETCS_LEVEL2"), - true + .iter() + .any(|sss| matches!( + sss, + schemas::rolling_stock::SupportedSignalingSystem::EtcsLevel2 { .. } + )) ); assert_eq!(rolling_stock.name, rolling_stock_form.name); diff --git a/editoast/src/views/timetable/simulation.rs b/editoast/src/views/timetable/simulation.rs index b3e9d7e5dfa..532217865be 100644 --- a/editoast/src/views/timetable/simulation.rs +++ b/editoast/src/views/timetable/simulation.rs @@ -626,7 +626,10 @@ fn build_pathfinding_consist( .supported_electrification(), supported_signaling_systems: physics_consist_parameters .traction_engine - .supported_signaling_systems(), + .supported_signaling_systems + .iter() + .map_into() + .collect(), maximum_speed: OrderedFloat( physics_consist_parameters .compute_max_speed() diff --git a/front/src/common/api/generatedEditoastApi.ts b/front/src/common/api/generatedEditoastApi.ts index 55d4f3850d8..e2c65dc3be3 100644 --- a/front/src/common/api/generatedEditoastApi.ts +++ b/front/src/common/api/generatedEditoastApi.ts @@ -3740,6 +3740,7 @@ export type PathfindingResult = | (PathfindingFailure & { status: 'failure'; }); +export type SupportedSignalingSystemVariant = 'BAL' | 'BAPR' | 'TVM300' | 'TVM430' | 'ETCS_LEVEL2'; export type PathfindingInput = { /** List of waypoints given to the pathfinding */ path_items: PathItemLocation[]; @@ -3755,7 +3756,7 @@ export type PathfindingInput = { Empty if does not support any electrification */ rolling_stock_supported_electrifications: string[]; /** List of supported signaling systems */ - rolling_stock_supported_signaling_systems: string[]; + rolling_stock_supported_signaling_systems: SupportedSignalingSystemVariant[]; /** Speed limit tag, used to estimate the travel time */ speed_limit_tag?: string | null; /** Stop the train at the next block-delimiting signal, diff --git a/osrd_schemas_auto/osrd_schemas_auto/models.py b/osrd_schemas_auto/osrd_schemas_auto/models.py index b192e642a74..8f4279fbcdc 100644 --- a/osrd_schemas_auto/osrd_schemas_auto/models.py +++ b/osrd_schemas_auto/osrd_schemas_auto/models.py @@ -3620,6 +3620,18 @@ class SupportedSignalingSystemTVM430(BaseModel): type: Literal["TVM430"] +class SupportedSignalingSystemVariant(Enum): + """ + Auto-generated discriminant enum variants + """ + + BAL = "BAL" + BAPR = "BAPR" + TVM300 = "TVM300" + TVM430 = "TVM430" + ETCS_LEVEL2 = "ETCS_LEVEL2" + + class SwitchPortConnection(BaseModel): model_config = ConfigDict( extra="forbid", @@ -4925,7 +4937,7 @@ class PathfindingInput(BaseModel): List of supported electrification modes. Empty if does not support any electrification """ - rolling_stock_supported_signaling_systems: list[str] + rolling_stock_supported_signaling_systems: list[SupportedSignalingSystemVariant] """ List of supported signaling systems """