Skip to content

Commit

Permalink
editoast: add blocks to v2 path projection request
Browse files Browse the repository at this point in the history
  • Loading branch information
flomonster committed Apr 26, 2024
1 parent 13b341e commit 73db534
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 8 deletions.
11 changes: 10 additions & 1 deletion editoast/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4961,6 +4961,14 @@ components:
ProjectPathInput:
description: Project path input is described by a list of routes and a list of track range
properties:
blocks:
description: Path description as block ids
items:
maxLength: 255
minLength: 1
type: string
minItems: 1
type: array
routes:
description: List of route ids
items:
Expand All @@ -4976,8 +4984,9 @@ components:
minItems: 1
type: array
required:
- routes
- track_section_ranges
- routes
- blocks
type: object
ProjectPathTrainResult:
allOf:
Expand Down
2 changes: 2 additions & 0 deletions editoast/src/core/v2/signal_updates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ pub struct SignalUpdatesRequest<'a> {
pub track_section_ranges: &'a Vec<TrackRange>,
/// Path description as route ids
pub routes: &'a Vec<Identifier>,
/// Path description as block ids
pub blocks: &'a Vec<Identifier>,
/// List of signal sightings and zone updates for each train
pub train_simulations: HashMap<i64, TrainSimulation<'a>>,
}
Expand Down
25 changes: 18 additions & 7 deletions editoast/src/views/v2/train_schedule/projection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,15 @@ crate::routes! {
/// Project path input is described by a list of routes and a list of track range
#[derive(Debug, Deserialize, Serialize, ToSchema)]
struct ProjectPathInput {
/// List of route ids
#[schema(inline, min_items = 1)]
routes: Vec<Identifier>,
/// List of track ranges
#[schema(min_items = 1)]
track_section_ranges: Vec<TrackRange>,
/// List of route ids
#[schema(inline, min_items = 1)]
routes: Vec<Identifier>,
/// Path description as block ids
#[schema(inline, min_items = 1)]
blocks: Vec<Identifier>,
}

#[derive(Debug, Clone, Deserialize, Serialize, ToSchema)]
Expand Down Expand Up @@ -128,6 +131,7 @@ async fn project_path(
let ProjectPathInput {
track_section_ranges: path_track_ranges,
routes: path_routes,
blocks: path_blocks,
} = data.into_inner();
let path_projection = PathProjection::new(&path_track_ranges);
let query_props = params.into_inner();
Expand Down Expand Up @@ -208,6 +212,7 @@ async fn project_path(
&train_details,
&path_track_ranges,
&path_routes,
&path_blocks,
);
let projection: Option<CachedProjectPathTrainResult> = redis_conn
.json_get_ex(&hash, CACHE_PROJECTION_EXPIRATION)
Expand All @@ -232,6 +237,7 @@ async fn project_path(
&infra,
&path_track_ranges,
&path_routes,
&path_blocks,
&miss_cache
)
);
Expand All @@ -245,6 +251,7 @@ async fn project_path(
&train_details,
&path_track_ranges,
&path_routes,
&path_blocks,
);
let cached = CachedProjectPathTrainResult {
space_time_curves: space_time_curves
Expand Down Expand Up @@ -308,15 +315,17 @@ struct TrainSimulationDetails {
async fn compute_batch_signal_updates<'a>(
core: Arc<CoreClient>,
infra: &Infra,
track_section_ranges: &'a Vec<TrackRange>,
routes: &'a Vec<Identifier>,
path_track_ranges: &'a Vec<TrackRange>,
path_routes: &'a Vec<Identifier>,
path_blocks: &'a Vec<Identifier>,
trains_details: &'a HashMap<i64, TrainSimulationDetails>,
) -> Result<HashMap<i64, Vec<SignalUpdate>>> {
let request = SignalUpdatesRequest {
infra: infra.id,
expected_version: infra.version.clone(),
track_section_ranges,
routes,
track_section_ranges: path_track_ranges,
routes: path_routes,
blocks: path_blocks,
train_simulations: trains_details
.iter()
.map(|(id, details)| {
Expand Down Expand Up @@ -489,12 +498,14 @@ fn train_projection_input_hash(
project_path_input: &TrainSimulationDetails,
path_projection_tracks: &[TrackRange],
path_routes: &[Identifier],
path_blocks: &[Identifier],
) -> String {
let osrd_version = get_app_version().unwrap_or_default();
let mut hasher = DefaultHasher::new();
project_path_input.hash(&mut hasher);
path_projection_tracks.hash(&mut hasher);
path_routes.hash(&mut hasher);
path_blocks.hash(&mut hasher);
let hash_simulation_input = hasher.finish();
format!("projection_{osrd_version}.{infra_id}.{infra_version}.{hash_simulation_input}")
}
Expand Down
2 changes: 2 additions & 0 deletions front/src/common/api/osrdEditoastApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3300,6 +3300,8 @@ export type ProjectPathTrainResult = {
rolling_stock_length: number;
};
export type ProjectPathInput = {
/** Path description as block ids */
blocks: string[];
/** List of route ids */
routes: string[];
/** List of track ranges */
Expand Down

0 comments on commit 73db534

Please sign in to comment.