Skip to content
Open
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
81 changes: 79 additions & 2 deletions editoast/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions editoast/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
9 changes: 7 additions & 2 deletions editoast/core_client/src/pathfinding.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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,
Expand All @@ -31,7 +35,8 @@ pub struct PathfindingRequest {
/// Empty if does not support any electrification
pub rolling_stock_supported_electrifications: BTreeSet<String>,
/// List of supported signaling systems
pub rolling_stock_supported_signaling_systems: BTreeSet<String>,
#[educe(Hash(method(hashing_supported_signaling_systems_variant)))]
pub rolling_stock_supported_signaling_systems: HashSet<SupportedSignalingSystemVariant>,
/// Maximum speed of the rolling stock
pub rolling_stock_maximum_speed: OrderedFloat<f64>,
/// Rolling stock length in meters:
Expand Down
9 changes: 6 additions & 3 deletions editoast/core_client/src/stdcm.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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<String>,
#[educe(Hash(method(hashing_supported_signaling_systems)))]
pub supported_signaling_systems: HashSet<SupportedSignalingSystem>,
pub speed_limit_tag: Option<String>,
/// The loading gauge of the rolling stock
pub loading_gauge_type: LoadingGaugeType,
Expand Down
11 changes: 8 additions & 3 deletions editoast/core_task/src/envs/pathfinding.rs
Original file line number Diff line number Diff line change
@@ -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 _;
Expand All @@ -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;
Expand Down Expand Up @@ -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,
Expand All @@ -161,7 +165,8 @@ pub struct PathfindingConsist {
/// Supported electrification modes (leave empty for unelectrified consists)
pub supported_electrifications: BTreeSet<String>,
/// A list of supported signaling systems
pub supported_signaling_systems: BTreeSet<String>,
#[educe(Hash(method(hashing_supported_signaling_systems_variant)))]
pub supported_signaling_systems: HashSet<SupportedSignalingSystemVariant>,
pub maximum_speed: OrderedFloat<f64>,
/// Consist length in meters
pub length: OrderedFloat<f64>,
Expand Down Expand Up @@ -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()),
Expand Down
11 changes: 10 additions & 1 deletion editoast/openapi.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions editoast/schemas/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ utoipa.workspace = true
uuid.workspace = true

[dev-dependencies]
proptest.workspace = true
rstest.workspace = true

[lints]
Expand Down
11 changes: 5 additions & 6 deletions editoast/schemas/src/rolling_stock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -121,11 +123,8 @@ pub struct RollingStock {
}

impl RollingStock {
pub fn supported_signaling_systems(&self) -> BTreeSet<String> {
self.supported_signaling_systems
.iter()
.map(|s| s.to_string())
.collect()
pub fn supported_signaling_systems(&self) -> HashSet<SupportedSignalingSystem> {
self.supported_signaling_systems.clone()
}

pub fn get_etcs_brake_params(&self) -> Option<&EtcsBrakeParams> {
Expand Down
Loading
Loading