mirror of
https://github.com/Spythere/stacjownik.git
synced 2026-05-03 13:28:11 +00:00
chore: calculating max train speed based on its mass
This commit is contained in:
@@ -184,14 +184,20 @@
|
|||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineComponent } from 'vue';
|
import { defineComponent } from 'vue';
|
||||||
import styleMixin from '../../mixins/styleMixin';
|
|
||||||
import trainInfoMixin from '../../mixins/trainInfoMixin';
|
|
||||||
import ProgressBar from '../Global/ProgressBar.vue';
|
|
||||||
import { useMainStore } from '../../store/mainStore';
|
import { useMainStore } from '../../store/mainStore';
|
||||||
import { useApiStore } from '../../store/apiStore';
|
import { useApiStore } from '../../store/apiStore';
|
||||||
import StockList from '../Global/StockList.vue';
|
|
||||||
import { Train } from '../../typings/common';
|
import { Train } from '../../typings/common';
|
||||||
|
import speedLimits from '../../data/speedLimits.json';
|
||||||
|
import styleMixin from '../../mixins/styleMixin';
|
||||||
|
import trainInfoMixin from '../../mixins/trainInfoMixin';
|
||||||
import trainCategoryMixin from '../../mixins/trainCategoryMixin';
|
import trainCategoryMixin from '../../mixins/trainCategoryMixin';
|
||||||
|
import ProgressBar from '../Global/ProgressBar.vue';
|
||||||
|
import StockList from '../Global/StockList.vue';
|
||||||
|
|
||||||
|
export type SpeedLimitLocoType = keyof typeof speedLimits;
|
||||||
|
|
||||||
|
const isCompatibleLoco = (locoType: string): locoType is SpeedLimitLocoType =>
|
||||||
|
locoType in speedLimits;
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
mixins: [trainInfoMixin, styleMixin, trainCategoryMixin],
|
mixins: [trainInfoMixin, styleMixin, trainCategoryMixin],
|
||||||
@@ -216,13 +222,36 @@ export default defineComponent({
|
|||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
stockSpeedLimit() {
|
stockSpeedLimit() {
|
||||||
return this.train.stockList.reduce((acc, stockName) => {
|
let isPassenger = true;
|
||||||
const vehicleSpeed =
|
|
||||||
this.apiStore.vehiclesData?.find((v) => v.name == stockName.split(':')[0])?.group.speed ??
|
const vehicleMaxSpeed = this.train.stockList.reduce((acc, stockName) => {
|
||||||
300;
|
const vehicleData = this.apiStore.vehiclesData?.find(
|
||||||
|
(v) => v.name == stockName.split(':')[0]
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!vehicleData) return acc;
|
||||||
|
if (vehicleData.type == 'wagon-freight') isPassenger = false;
|
||||||
|
|
||||||
|
const vehicleSpeed = vehicleData.group.speed;
|
||||||
|
|
||||||
return Math.min(vehicleSpeed, acc);
|
return Math.min(vehicleSpeed, acc);
|
||||||
}, 300);
|
}, Infinity);
|
||||||
|
|
||||||
|
const headLoco = this.train.stockList[0].slice(0, this.train.stockList[0].indexOf('-'));
|
||||||
|
|
||||||
|
if (!isCompatibleLoco(headLoco)) return vehicleMaxSpeed;
|
||||||
|
|
||||||
|
if (this.train.stockList.length == 1) return speedLimits[headLoco]['none'];
|
||||||
|
|
||||||
|
const speedTable = speedLimits[headLoco][isPassenger ? 'passenger' : 'cargo'];
|
||||||
|
|
||||||
|
if (!speedTable) return vehicleMaxSpeed;
|
||||||
|
|
||||||
|
let massKey = Object.keys(speedTable).findLast(
|
||||||
|
(massKey) => this.train.mass >= Number(massKey)
|
||||||
|
);
|
||||||
|
|
||||||
|
return massKey ? ((speedTable as any)[massKey] as number) : vehicleMaxSpeed;
|
||||||
},
|
},
|
||||||
journalRouteLocation() {
|
journalRouteLocation() {
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -0,0 +1,156 @@
|
|||||||
|
{
|
||||||
|
"EU07": {
|
||||||
|
"passenger": {
|
||||||
|
"650000": 125
|
||||||
|
},
|
||||||
|
"cargo": {
|
||||||
|
"2000000": 70
|
||||||
|
},
|
||||||
|
"none": 110
|
||||||
|
},
|
||||||
|
"4E": {
|
||||||
|
"passenger": {
|
||||||
|
"650000": 125
|
||||||
|
},
|
||||||
|
"cargo": {
|
||||||
|
"2000000": 70
|
||||||
|
},
|
||||||
|
"none": 110
|
||||||
|
},
|
||||||
|
"EU07E": {
|
||||||
|
"passenger": {
|
||||||
|
"650000": 125
|
||||||
|
},
|
||||||
|
"cargo": {
|
||||||
|
"2000000": 70
|
||||||
|
},
|
||||||
|
"none": 110
|
||||||
|
},
|
||||||
|
"EP07": {
|
||||||
|
"passenger": {
|
||||||
|
"650000": 125
|
||||||
|
},
|
||||||
|
"cargo": null,
|
||||||
|
"none": 110
|
||||||
|
},
|
||||||
|
"EP08": {
|
||||||
|
"passenger": {
|
||||||
|
"650000": 140
|
||||||
|
},
|
||||||
|
"cargo": null,
|
||||||
|
"none": 110
|
||||||
|
},
|
||||||
|
"EP09": {
|
||||||
|
"passenger": {
|
||||||
|
"650000": 160
|
||||||
|
},
|
||||||
|
"cargo": null,
|
||||||
|
"none": 160
|
||||||
|
},
|
||||||
|
"ET22": {
|
||||||
|
"passenger": {
|
||||||
|
"650000": 125
|
||||||
|
},
|
||||||
|
"cargo": {
|
||||||
|
"1200000": 100,
|
||||||
|
"3100000": 70
|
||||||
|
},
|
||||||
|
"none": 125
|
||||||
|
},
|
||||||
|
"201E": {
|
||||||
|
"passenger": {
|
||||||
|
"650000": 125
|
||||||
|
},
|
||||||
|
"cargo": {
|
||||||
|
"1200000": 100,
|
||||||
|
"3100000": 70
|
||||||
|
},
|
||||||
|
"none": 125
|
||||||
|
},
|
||||||
|
"ET41": {
|
||||||
|
"passenger": {
|
||||||
|
"700000": 125
|
||||||
|
},
|
||||||
|
"cargo": {
|
||||||
|
"4000000": 70,
|
||||||
|
"3500000": 80,
|
||||||
|
"2500000": 90,
|
||||||
|
"2000000": 100
|
||||||
|
},
|
||||||
|
"none": 110
|
||||||
|
},
|
||||||
|
"SM42": {
|
||||||
|
"passenger": {
|
||||||
|
"95000": 90,
|
||||||
|
"200000": 80,
|
||||||
|
"300000": 70,
|
||||||
|
"450000": 60,
|
||||||
|
"750000": 50,
|
||||||
|
"1130000": 40,
|
||||||
|
"1720000": 30,
|
||||||
|
"2400000": 20
|
||||||
|
},
|
||||||
|
"cargo": {
|
||||||
|
"95000": 90,
|
||||||
|
"200000": 80,
|
||||||
|
"300000": 70,
|
||||||
|
"450000": 60,
|
||||||
|
"750000": 50,
|
||||||
|
"1130000": 40,
|
||||||
|
"1720000": 30,
|
||||||
|
"2400000": 20
|
||||||
|
},
|
||||||
|
"none": 90
|
||||||
|
},
|
||||||
|
"M62": {
|
||||||
|
"passenger": {
|
||||||
|
"500000": 100,
|
||||||
|
"800000": 80,
|
||||||
|
"1200000": 60,
|
||||||
|
"2000000": 40,
|
||||||
|
"3000000": 20
|
||||||
|
},
|
||||||
|
"cargo": {
|
||||||
|
"500000": 100,
|
||||||
|
"800000": 80,
|
||||||
|
"1200000": 60,
|
||||||
|
"2000000": 40,
|
||||||
|
"3000000": 20
|
||||||
|
},
|
||||||
|
"none": 100
|
||||||
|
},
|
||||||
|
"ST44": {
|
||||||
|
"passenger": {
|
||||||
|
"500000": 100,
|
||||||
|
"800000": 80,
|
||||||
|
"1200000": 60,
|
||||||
|
"2000000": 40,
|
||||||
|
"3000000": 20
|
||||||
|
},
|
||||||
|
"cargo": {
|
||||||
|
"500000": 100,
|
||||||
|
"800000": 80,
|
||||||
|
"1200000": 60,
|
||||||
|
"2000000": 40,
|
||||||
|
"3000000": 20
|
||||||
|
},
|
||||||
|
"none": 100
|
||||||
|
},
|
||||||
|
"CTLR4C": {
|
||||||
|
"passenger": {
|
||||||
|
"500000": 100,
|
||||||
|
"800000": 80,
|
||||||
|
"1200000": 60,
|
||||||
|
"2000000": 40,
|
||||||
|
"3000000": 20
|
||||||
|
},
|
||||||
|
"cargo": {
|
||||||
|
"500000": 100,
|
||||||
|
"800000": 80,
|
||||||
|
"1200000": 60,
|
||||||
|
"2000000": 40,
|
||||||
|
"3000000": 20
|
||||||
|
},
|
||||||
|
"none": 100
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -385,7 +385,7 @@
|
|||||||
"current-signal": "at signal",
|
"current-signal": "at signal",
|
||||||
"current-track": "on track",
|
"current-track": "on track",
|
||||||
|
|
||||||
"vmax-tooltip": "Maximum train speed based on rolling stock vehicles - braked weight is not included",
|
"vmax-tooltip": "Maximum speed based on vehicles and acceptable train mass",
|
||||||
|
|
||||||
"catenary-tooltip": "Electrified route",
|
"catenary-tooltip": "Electrified route",
|
||||||
"no-catenary-tooltip": "Non-electrified route",
|
"no-catenary-tooltip": "Non-electrified route",
|
||||||
|
|||||||
+1
-1
@@ -372,7 +372,7 @@
|
|||||||
"current-signal": "przy semaforze",
|
"current-signal": "przy semaforze",
|
||||||
"current-track": "na szlaku",
|
"current-track": "na szlaku",
|
||||||
|
|
||||||
"vmax-tooltip": "Maksymalna prędkość na podstawie pojazdów w składzie - nie bierze pod uwagę masy hamowania",
|
"vmax-tooltip": "Maksymalna prędkość obliczona na podstawie pojazdów w składzie i masy dopuszczalnej",
|
||||||
|
|
||||||
"catenary-tooltip": "Szlak zelektryfikowany",
|
"catenary-tooltip": "Szlak zelektryfikowany",
|
||||||
"no-catenary-tooltip": "Szlak niezelektryfikowany",
|
"no-catenary-tooltip": "Szlak niezelektryfikowany",
|
||||||
|
|||||||
Reference in New Issue
Block a user