-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
editoast: add call to conflict detection core endpoint
- Handle batch simulation for better performances - Rename signal projection endpoint url
- Loading branch information
1 parent
6a31fd8
commit 73c143f
Showing
15 changed files
with
439 additions
and
226 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
use chrono::DateTime; | ||
use chrono::Utc; | ||
use serde::Deserialize; | ||
use serde::Serialize; | ||
use std::collections::HashMap; | ||
use utoipa::ToSchema; | ||
|
||
use crate::core::{AsCoreRequest, Json}; | ||
|
||
use super::simulation::RoutingRequirement; | ||
use super::simulation::SpacingRequirement; | ||
|
||
editoast_common::schemas! { | ||
ConflictDetectionResponse, | ||
Conflict, | ||
} | ||
|
||
#[derive(Debug, Serialize)] | ||
pub struct ConflictDetectionRequest { | ||
/// List of requirements for each train | ||
pub trains_requirements: HashMap<i64, TrainRequirements>, | ||
} | ||
|
||
#[derive(Debug, Serialize)] | ||
pub struct TrainRequirements { | ||
pub start_time: DateTime<Utc>, | ||
pub spacing_requirements: Vec<SpacingRequirement>, | ||
pub routing_requirements: Vec<RoutingRequirement>, | ||
} | ||
|
||
#[derive(Debug, Deserialize, ToSchema)] | ||
pub struct ConflictDetectionResponse { | ||
/// List of conflicts detected | ||
#[schema(inline)] | ||
pub conflicts: Vec<Conflict>, | ||
} | ||
|
||
#[derive(Debug, Clone, Deserialize, Serialize, ToSchema)] | ||
#[schema(as=ConflictV2)] | ||
pub struct Conflict { | ||
/// List of train ids involved in the conflict | ||
pub train_ids: Vec<i64>, | ||
/// Datetime of the start of the conflict | ||
pub start_time: DateTime<Utc>, | ||
/// Datetime of the end of the conflict | ||
pub end_time: DateTime<Utc>, | ||
/// Type of the conflict | ||
#[schema(inline)] | ||
pub conflict_type: ConflictType, | ||
} | ||
|
||
#[derive(Debug, Clone, Copy, Serialize, Deserialize, ToSchema)] | ||
pub enum ConflictType { | ||
/// Conflict caused by two trains being too close to each other | ||
Spacing, | ||
/// Conflict caused by two trains requiring incompatible routes at the same time | ||
Routing, | ||
} | ||
|
||
impl AsCoreRequest<Json<ConflictDetectionResponse>> for ConflictDetectionRequest { | ||
const METHOD: reqwest::Method = reqwest::Method::POST; | ||
const URL_PATH: &'static str = "/v2/conflict_detection"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
pub mod conflict_detection; | ||
pub mod path_properties; | ||
pub mod pathfinding; | ||
pub mod signal_updates; | ||
pub mod signal_projection; | ||
pub mod simulation; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.