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, schemas: add 'freight_compatible' to the rolling stock model #8856

Closed
wants to merge 4 commits into from
Closed
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
2 changes: 1 addition & 1 deletion editoast/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ To make sure it is always valid a CI check has been set up. To update the
OpenApi when a change has been made to an endpoint, run the following command:

```sh
cargo run openapi > openapi.yaml
cargo run -- openapi > openapi.yaml
```

## Batch dependency updates
Expand Down
1 change: 1 addition & 0 deletions editoast/editoast_models/src/tables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,7 @@ diesel::table! {
raise_pantograph_time -> Nullable<Float8>,
version -> Int8,
supported_signaling_systems -> Array<Nullable<Text>>,
freight_compatible -> Bool,
}
}

Expand Down
1 change: 1 addition & 0 deletions editoast/editoast_schemas/src/rolling_stock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,5 @@ pub struct RollingStock {
pub railjson_version: String,
#[serde(default)]
pub metadata: Option<RollingStockMetadata>,
pub freight_compatible: bool,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- This file should undo anything in `up.sql`
ALTER TABLE rolling_stock
DROP COLUMN freight_compatible;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- Your SQL goes here
ALTER TABLE rolling_stock
ADD freight_compatible BOOLEAN NOT NULL DEFAULT FALSE;
9 changes: 9 additions & 0 deletions editoast/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6095,6 +6095,7 @@ components:
- power_restrictions
- energy_sources
- supported_signaling_systems
- freight_compatible
properties:
base_power_class:
type: string
Expand All @@ -6108,6 +6109,8 @@ components:
type: array
items:
$ref: '#/components/schemas/EnergySource'
freight_compatible:
type: boolean
gamma:
$ref: '#/components/schemas/Gamma'
id:
Expand Down Expand Up @@ -7672,6 +7675,7 @@ components:
- raise_pantograph_time
- version
- supported_signaling_systems
- freight_compatible
properties:
base_power_class:
type: string
Expand All @@ -7689,6 +7693,8 @@ components:
type: array
items:
$ref: '#/components/schemas/EnergySource'
freight_compatible:
type: boolean
gamma:
$ref: '#/components/schemas/Gamma'
id:
Expand Down Expand Up @@ -7821,6 +7827,7 @@ components:
- loading_gauge
- power_restrictions
- supported_signaling_systems
- freight_compatible
properties:
base_power_class:
type: string
Expand All @@ -7841,6 +7848,8 @@ components:
type: array
items:
$ref: '#/components/schemas/EnergySource'
freight_compatible:
type: boolean
gamma:
$ref: '#/components/schemas/Gamma'
inertia_coefficient:
Expand Down
3 changes: 3 additions & 0 deletions editoast/src/models/rolling_stock_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ pub struct RollingStockModel {
#[schema(value_type = Vec<String>)]
#[model(remote = "Vec<Option<String>>")]
pub supported_signaling_systems: RollingStockSupportedSignalingSystems,
pub freight_compatible: bool,
}

impl RollingStockModel {
Expand Down Expand Up @@ -167,6 +168,7 @@ impl From<RollingStockModel> for RollingStock {
electrical_power_startup_time: rolling_stock_model.electrical_power_startup_time,
raise_pantograph_time: rolling_stock_model.raise_pantograph_time,
supported_signaling_systems: rolling_stock_model.supported_signaling_systems,
freight_compatible: rolling_stock_model.freight_compatible,
}
}
}
Expand Down Expand Up @@ -194,6 +196,7 @@ impl From<RollingStock> for RollingStockModelChangeset {
.electrical_power_startup_time(rolling_stock.electrical_power_startup_time)
.raise_pantograph_time(rolling_stock.raise_pantograph_time)
.supported_signaling_systems(rolling_stock.supported_signaling_systems)
.freight_compatible(rolling_stock.freight_compatible)
}
}

Expand Down
3 changes: 2 additions & 1 deletion editoast/src/tests/example_rolling_stock_1.json
Original file line number Diff line number Diff line change
Expand Up @@ -982,5 +982,6 @@
"power_restrictions": {"C2":"2", "C5":"5"},
"electrical_power_startup_time": 5.0,
"raise_pantograph_time": 15.0,
"supported_signaling_systems": ["BAL", "BAPR", "TVM300", "TVM430"]
"supported_signaling_systems": ["BAL", "BAPR", "TVM300", "TVM430"],
"freight_compatible": null
}
Original file line number Diff line number Diff line change
Expand Up @@ -209,5 +209,6 @@
"power_restrictions": {},
"electrical_power_startup_time": 6.0,
"raise_pantograph_time": 16.0,
"supported_signaling_systems": ["BAL", "BAPR", "TVM300", "TVM430"]
"supported_signaling_systems": ["BAL", "BAPR", "TVM300", "TVM430"],
"freight_compatible": true
}
3 changes: 2 additions & 1 deletion editoast/src/tests/example_rolling_stock_3.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,6 @@
"power_restrictions": {},
"electrical_power_startup_time": 4.0,
"raise_pantograph_time": 14.0,
"supported_signaling_systems": ["BAL", "BAPR", "TVM300", "TVM430"]
"supported_signaling_systems": ["BAL", "BAPR", "TVM300", "TVM430"],
"freight_compatible": true
}
3 changes: 3 additions & 0 deletions editoast/src/views/rolling_stock/form.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ pub struct RollingStockForm {
pub supported_signaling_systems: RollingStockSupportedSignalingSystems,
pub locked: Option<bool>,
pub metadata: Option<RollingStockMetadata>,
pub freight_compatible: bool,
}

impl From<RollingStockForm> for Changeset<RollingStockModel> {
Expand All @@ -77,6 +78,7 @@ impl From<RollingStockForm> for Changeset<RollingStockModel> {
.electrical_power_startup_time(rolling_stock.electrical_power_startup_time)
.raise_pantograph_time(rolling_stock.raise_pantograph_time)
.supported_signaling_systems(rolling_stock.supported_signaling_systems)
.freight_compatible(rolling_stock.freight_compatible)
}
}

Expand Down Expand Up @@ -115,6 +117,7 @@ impl From<RollingStockModel> for RollingStockForm {
supported_signaling_systems: value.supported_signaling_systems,
locked: Some(value.locked),
metadata: value.metadata,
freight_compatible: value.freight_compatible,
}
}
}
3 changes: 3 additions & 0 deletions editoast/src/views/rolling_stock/light.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ struct LightRollingStock {
power_restrictions: HashMap<String, String>,
energy_sources: Vec<EnergySource>,
supported_signaling_systems: RollingStockSupportedSignalingSystems,
freight_compatible: bool,
}

impl From<RollingStockModel> for LightRollingStock {
Expand All @@ -254,6 +255,7 @@ impl From<RollingStockModel> for LightRollingStock {
energy_sources,
locked,
supported_signaling_systems,
freight_compatible,
..
}: RollingStockModel,
) -> Self {
Expand All @@ -278,6 +280,7 @@ impl From<RollingStockModel> for LightRollingStock {
power_restrictions,
energy_sources,
supported_signaling_systems,
freight_compatible,
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions front/src/common/api/generatedEditoastApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2371,6 +2371,7 @@ export type LightRollingStock = {
comfort_acceleration: number;
effort_curves: LightEffortCurves;
energy_sources: EnergySource[];
freight_compatible: boolean;
gamma: Gamma;
id: number;
inertia_coefficient: number;
Expand Down Expand Up @@ -2560,6 +2561,7 @@ export type RollingStock = {
effort_curves: EffortCurves;
electrical_power_startup_time: number | null;
energy_sources: EnergySource[];
freight_compatible: boolean;
gamma: Gamma;
id: number;
inertia_coefficient: number;
Expand Down Expand Up @@ -2588,6 +2590,7 @@ export type RollingStockForm = {
/** The time the train takes before actually using electrical power (in seconds). Is null if the train is not electric. */
electrical_power_startup_time?: number | null;
energy_sources?: EnergySource[];
freight_compatible: boolean;
gamma: Gamma;
inertia_coefficient: number;
length: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import cx from 'classnames';
import { AiOutlineColumnWidth } from 'react-icons/ai';
import { BsLightningFill } from 'react-icons/bs';
import { FaWeightHanging } from 'react-icons/fa';
import { GoContainer } from 'react-icons/go';
import { IoIosSpeedometer } from 'react-icons/io';
import { MdLocalGasStation } from 'react-icons/md';

Expand Down Expand Up @@ -112,6 +113,11 @@ const RollingStockCard = ({
<div className="row">
<div className="col-5">
<div className="rollingstock-tractionmode text-nowrap">
{rollingStock.freight_compatible && (
<span className="text-black">
<GoContainer />
</span>
)}
{tractionModes.thermal && (
<span className="text-pink">
<MdLocalGasStation />
Expand Down
5 changes: 4 additions & 1 deletion python/osrd_schemas/osrd_schemas/rolling_stock.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from .infra import LoadingGaugeType

RAILJSON_ROLLING_STOCK_VERSION_TYPE = Literal["3.2"]
RAILJSON_ROLLING_STOCK_VERSION_TYPE = Literal["3.3"]
RAILJSON_ROLLING_STOCK_VERSION = get_args(RAILJSON_ROLLING_STOCK_VERSION_TYPE)[0]


Expand Down Expand Up @@ -226,6 +226,9 @@ class RollingStock(BaseModel, extra="forbid"):
ge=0,
)
supported_signaling_systems: List[str] = Field(default_factory=list)
freight_compatible: Optional[bool] = Field(
description="The type of the train, wether it's a locomotive or something else", default=None
)


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion python/osrd_schemas/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "osrd_schemas"
version = "0.8.13"
version = "0.8.14"
description = ""
authors = ["OSRD <[email protected]>"]

Expand Down
3 changes: 2 additions & 1 deletion tests/data/rolling_stocks/electric_rolling_stock.json
Original file line number Diff line number Diff line change
Expand Up @@ -977,5 +977,6 @@
"BAPR",
"TVM300",
"TVM430"
]
],
"freight_compatible": false
shenriotpro marked this conversation as resolved.
Show resolved Hide resolved
}
3 changes: 2 additions & 1 deletion tests/data/rolling_stocks/fast_rolling_stock.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,6 @@
"BAPR",
"TVM300",
"TVM430"
]
],
"freight_compatible": true
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,6 @@
"BAPR",
"TVM300",
"TVM430"
]
],
"freight_compatible": true
}
3 changes: 2 additions & 1 deletion tests/data/rolling_stocks/short_fast_rolling_stock.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,6 @@
"BAPR",
"TVM300",
"TVM430"
]
],
"freight_compatible": true
}
3 changes: 2 additions & 1 deletion tests/data/rolling_stocks/short_slow_rolling_stock.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,6 @@
"BAPR",
"TVM300",
"TVM430"
]
],
"freight_compatible": true
}
3 changes: 2 additions & 1 deletion tests/data/rolling_stocks/slow_rolling_stock.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,6 @@
"BAPR",
"TVM300",
"TVM430"
]
],
"freight_compatible": true
}
Loading