mirror of
https://github.com/Spythere/pojazdownik.git
synced 2026-05-04 12:08:12 +00:00
chore: updated acceptable mass limits
This commit is contained in:
@@ -7,5 +7,12 @@
|
|||||||
"EP08": [650000, 650000],
|
"EP08": [650000, 650000],
|
||||||
"EP09": [800000, 800000],
|
"EP09": [800000, 800000],
|
||||||
"ET41": [700000, 4000000],
|
"ET41": [700000, 4000000],
|
||||||
"SM42": [2400000, 2400000]
|
"SM42": [2400000, 2400000],
|
||||||
|
"ET22": [650000, 3100000],
|
||||||
|
"201E": [650000, 3100000],
|
||||||
|
"ST44": [3000000, 3000000],
|
||||||
|
"M62": [3000000, 3000000],
|
||||||
|
"CTLR4C": [3000000, 3000000],
|
||||||
|
"SU45": [1500000, 1500000],
|
||||||
|
"SP45": [1500000, 1500000]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,5 @@
|
|||||||
import {
|
import { ICarWagon, ILocomotive, IStock, IVehicleData, LocoGroupType, WagonGroupType } from '../types/common.types';
|
||||||
ICarWagon,
|
import { MassLimitLocoType, calculateMassLimit, calculateSpeedLimit } from './vehicleLimitsUtils';
|
||||||
ILocomotive,
|
|
||||||
IStock,
|
|
||||||
IVehicleData,
|
|
||||||
IVehiclesAPIResponse,
|
|
||||||
LocoGroupType,
|
|
||||||
WagonGroupType,
|
|
||||||
} from '../types/common.types';
|
|
||||||
import {
|
|
||||||
MassLimitLocoType,
|
|
||||||
SpeedLimitLocoType,
|
|
||||||
calculateMassLimit,
|
|
||||||
calculateSpeedLimit,
|
|
||||||
} from './vehicleLimitsUtils';
|
|
||||||
|
|
||||||
export function isTractionUnit(vehicle: ILocomotive | ICarWagon): vehicle is ILocomotive {
|
export function isTractionUnit(vehicle: ILocomotive | ICarWagon): vehicle is ILocomotive {
|
||||||
return (vehicle as ILocomotive).cabinType !== undefined;
|
return (vehicle as ILocomotive).cabinType !== undefined;
|
||||||
@@ -79,10 +66,7 @@ export function carDataList(vehiclesData: IVehicleData[] | undefined) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function totalWeight(stockList: IStock[]) {
|
export function totalWeight(stockList: IStock[]) {
|
||||||
return stockList.reduce(
|
return stockList.reduce((acc, stock) => acc + (stock.vehicleRef.weight + (stock.cargo?.weight ?? 0)), 0);
|
||||||
(acc, stock) => acc + (stock.vehicleRef.weight + (stock.cargo?.weight ?? 0)),
|
|
||||||
0
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function totalLength(stockList: IStock[]) {
|
export function totalLength(stockList: IStock[]) {
|
||||||
@@ -98,10 +82,7 @@ export function acceptableWeight(stockList: IStock[]) {
|
|||||||
|
|
||||||
const activeLocomotiveType = stockList[0].vehicleRef.type.split('-')[0];
|
const activeLocomotiveType = stockList[0].vehicleRef.type.split('-')[0];
|
||||||
|
|
||||||
const locoMassLimit = calculateMassLimit(
|
const locoMassLimit = calculateMassLimit(activeLocomotiveType as MassLimitLocoType, isTrainPassenger(stockList));
|
||||||
activeLocomotiveType as MassLimitLocoType,
|
|
||||||
isTrainPassenger(stockList)
|
|
||||||
);
|
|
||||||
|
|
||||||
return locoMassLimit;
|
return locoMassLimit;
|
||||||
}
|
}
|
||||||
@@ -110,23 +91,13 @@ export function isTrainPassenger(stockList: IStock[]) {
|
|||||||
if (stockList.length == 0) return false;
|
if (stockList.length == 0) return false;
|
||||||
if (stockList.every((stock) => isTractionUnit(stock.vehicleRef))) return false;
|
if (stockList.every((stock) => isTractionUnit(stock.vehicleRef))) return false;
|
||||||
|
|
||||||
return stockList
|
return stockList.filter((stock) => !isTractionUnit(stock.vehicleRef)).every((stock) => stock.vehicleRef.group === 'wagon-passenger');
|
||||||
.filter((stock) => !isTractionUnit(stock.vehicleRef))
|
|
||||||
.every((stock) => stock.vehicleRef.group === 'wagon-passenger');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function stockSupportsColdStart(stockList: IStock[]) {
|
export function stockSupportsColdStart(stockList: IStock[]) {
|
||||||
return (
|
return stockList.length == 1 && isTractionUnit(stockList[0].vehicleRef) && stockList[0].vehicleRef.coldStart;
|
||||||
stockList.length == 1 &&
|
|
||||||
isTractionUnit(stockList[0].vehicleRef) &&
|
|
||||||
stockList[0].vehicleRef.coldStart
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function stockSupportsDoubleManning(stockList: IStock[]) {
|
export function stockSupportsDoubleManning(stockList: IStock[]) {
|
||||||
return (
|
return stockList.length != 0 && isTractionUnit(stockList[0].vehicleRef) && stockList[0].vehicleRef.doubleManned;
|
||||||
stockList.length != 0 &&
|
|
||||||
isTractionUnit(stockList[0].vehicleRef) &&
|
|
||||||
stockList[0].vehicleRef.doubleManned
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user