Skip to content

Commit

Permalink
🐛 [feat/rework-scania] #78 #99 fix some stuff scania dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
JAGFx committed Feb 26, 2022
1 parent ae94e62 commit 5595ee4
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 90 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
},
"scripts": {
"lint": "npm run lint:eslint && npm run lint:prettier",
"lint:eslint": "npx eslint src lib servers --ext .js,.vue --fix",
"lint:prettier": "npx prettier --config .prettierrc src/**/*.{js,vue} lib/**/*.js servers/**/*.js --write",
"lint:eslint": "npx eslint src lib servers test --ext .js,.vue --fix",
"lint:prettier": "npx prettier --config .prettierrc src/**/*.{js,vue} lib/**/*.js servers/**/*.js test/**/*.js --write",
"test": "npm run test:unit",
"test:unit": "npx jest",
"test:coverage": "npx jest --coverage",
Expand Down
4 changes: 1 addition & 3 deletions src/components/dashboards/scania/ScaniaDashboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
<Dashboard v-slot="dashProps" class="scania-dash wrapper">
<div
class="dashboard game-connected"
:class="{ yes: $truckElectricOn }"
:style="{
transform:
'scale(' + dashProps.currentScale + ') translate(-50%, -50%)',
transform: `scale(${dashProps.currentScale}) translate(-50%, -50%)`,
width: dashProps.skinData.size.width + 'px',
height: dashProps.skinData.size.height + 'px'
}"
Expand Down
5 changes: 1 addition & 4 deletions src/components/dashboards/scania/display/ScaniaDisplay.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@
<div class="flex-area justify-content-start w-100 gearbox-wrapper">
<div class="truck-shifterType flex-area">
<span>{{
$truckShifterTypeLetter(
telemetry.truck.transmission,
telemetry.truck.brand
)
$truckShifterTypeLetter(telemetry.truck.transmission)
}}</span>
</div>
<div class="truck-gear flex-area">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
<div>
<!-- Line 1 -->
<div
v-if="$hasErrors || $truckElectricOn"
v-if="$hasErrors() || $truckElectricOn"
class="truck-stopWarning flex-area symbol r1 c1 red"
>
<i class="icon-scania-warning_red" />
</div>
<div
v-if="$hasWarnings || $truckElectricOn"
v-if="$hasWarnings() || $truckElectricOn"
class="truck-checkWarning flex-area symbol r1 c2 yellow"
>
<i class="icon-scania-warning_yellow" />
Expand Down Expand Up @@ -44,7 +44,7 @@

<!-- Line 3 -->
<div
v-if="hasEngineWarning || $truckElectricOn"
v-if="$hasEngineWarning() || $truckElectricOn"
class="engine-failure flex-area symbol r3 c2 yellow"
>
<i class="icon-scania-engine-failure_yellow" />
Expand Down
12 changes: 4 additions & 8 deletions src/components/dashboards/shared/Cadran.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,12 @@ export default {
},
methods: {
angle() {
const minValue = this.min;
const maxValue = this.max;
const minAngle = this.minAngle;
const maxAngle = this.maxAngle;
let value = this.value;
value = Math.min(value, maxValue);
value = Math.max(value, minValue);
const offset = (value - minValue) / (maxValue - minValue);
value = Math.min(value, this.max);
value = Math.max(value, this.min);
const offset = (value - this.min) / (this.max - this.min);
return (maxAngle - minAngle) * offset + minAngle;
return (this.maxAngle - this.minAngle) * offset + this.minAngle;
}
}
};
Expand Down
53 changes: 18 additions & 35 deletions src/mixins/TelemetryMixin.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script>
import { store as telemetryStore } from '@/store/telemetry.store';
import { formatConstants } from '@/utils/_app';
import { dateTimeLocalized, formatConstants } from '@/utils/_app';
import * as telemetryCommon from '@/utils/telemetry/_common.utils';
import * as telemetryGear from '@/utils/telemetry/_grear.utils';
import * as telemetryHelper from '@/utils/telemetry/_helper.utils';
Expand All @@ -14,7 +14,7 @@ export default {
name: 'TelemetryMixin',
filters: {
$dateTimeLocalized: (time, dFormat, tFormat) => {
return app.dateTimeLocalized(time, dFormat, tFormat);
return dateTimeLocalized(time, dFormat, tFormat);
},
$toFixed: (value, decimal) => {
return value.toFixed(decimal);
Expand All @@ -29,26 +29,22 @@ export default {
computed: {
telemetry: () => telemetryStore.telemetry,
receivedData: () => telemetryStore.receivedData,
truckElectricOn() {
$truckElectricOn() {
return this.truckElectricOnValue;
},
haveWarnings() {
return (
(this.telemetry.truck.brakes.airPressure.warning.enabled ||
this.telemetry.truck.fuel.warning.enabled ||
this.telemetry.truck.adBlue.warning.enabled ||
this.telemetry.truck.engine.oilPressure.warning.enabled ||
this.telemetry.truck.engine.waterTemperature.warning.enabled ||
this.telemetry.truck.engine.batteryVoltage.warning.enabled) &&
this.telemetry.truck.electric.enabled
);
},
haveErrors() {
return this.telemetry.truck.brakes.airPressure.emergency.enabled &&
this.telemetry.truck.electric.enabled
},
hasEngineWarning() {
return this.telemetry.truck.engine.damage >= 0.5; // >= 50%
}
//...telemetryGear,
},
watch: {
'telemetry.truck.electric.enabled': function (newValue) {
if (newValue && !this.telemetry.truck.engine.enabled) {
this.truckElectricOnValue = true;
this.truckElectricOnTimer = setTimeout(() => {
this.truckElectricOnValue = false;
}, 1000);
} else {
this.truckElectricOnValue = false;
this.truckElectricOnTimer = null;
}
}
},
created() {
Expand All @@ -66,19 +62,6 @@ export default {
...telemetryTrailer,
...telemetryTruck,
...telemetryUnitConverter
},
watch: {
'telemetry.truck.electric.enabled': function (newValue) {
if (newValue && !this.telemetry.truck.engine.enabled) {
this.truckElectricOnValue = true;
this.truckElectricOnTimer = setTimeout(() => {
this.truckElectricOnValue = false;
}, 1000);
} else {
this.truckElectricOnValue = false;
this.truckElectricOnTimer = null;
}
}
},
}
};
</script>
22 changes: 15 additions & 7 deletions src/utils/telemetry/_common.utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,25 @@ export const $scale = (currentSkin) => {

export const $hasWarnings = () => {
return (
telemetryStore.telemetry.truck.brakes.airPressure.warning.enabled ||
telemetryStore.telemetry.truck.fuel.warning.enabled ||
telemetryStore.telemetry.truck.adBlue.warning.enabled ||
telemetryStore.telemetry.truck.engine.oilPressure.warning.enabled ||
telemetryStore.telemetry.truck.engine.waterTemperature.warning.enabled ||
telemetryStore.telemetry.truck.engine.batteryVoltage.warning.enabled
(telemetryStore.telemetry.truck.brakes.airPressure.warning.enabled ||
telemetryStore.telemetry.truck.fuel.warning.enabled ||
telemetryStore.telemetry.truck.adBlue.warning.enabled ||
telemetryStore.telemetry.truck.engine.oilPressure.warning.enabled ||
telemetryStore.telemetry.truck.engine.waterTemperature.warning.enabled ||
telemetryStore.telemetry.truck.engine.batteryVoltage.warning.enabled) &&
telemetryStore.telemetry.truck.electric.enabled
);
};

export const $hasErrors = () => {
return telemetryStore.telemetry.truck.brakes.airPressure.emergency.enabled;
return (
telemetryStore.telemetry.truck.brakes.airPressure.emergency.enabled &&
telemetryStore.telemetry.truck.electric.enabled
);
};

export const $hasEngineWarning = () => {
return telemetryStore.telemetry.truck.engine.damage >= 0.5; // >= 50%
};

export const $dateTimeLocalized = (time, dFormat, tFormat) => {
Expand Down
36 changes: 12 additions & 24 deletions src/utils/telemetry/_grear.utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,39 +31,27 @@ export const $trukGear = (transmission, brand, withShifterType = true) => {
strGear = gear - crawlingGear;
}

if (withShifterType) {
if (
transmission.shifterType === 'automatic' ||
transmission.shifterType === 'arcade'
)
strGear = 'A' + (gear - crawlingGear);
if (
(transmission.shifterType === 'automatic' ||
transmission.shifterType === 'arcade') &&
withShifterType
)
strGear = 'A' + (gear - crawlingGear);

if (gear <= crawlingGear) strGear = 'C' + Math.abs(gear);
if (gear <= crawlingGear) strGear = 'C' + Math.abs(gear);

if (gear === 0) strGear = 'N';
if (gear === 0) strGear = 'N';

if (gear < 0) strGear = 'R' + Math.abs(transmission.gear.displayed);
}
if (gear < 0) strGear = 'R' + Math.abs(transmission.gear.displayed);

return strGear;
};

export const $truckShifterTypeLetter = (transmission, brand) => {
const gear = $gearInfo(transmission, brand).gear;
const crawlingGear = $gearInfo(transmission, brand).crawlingGear;
let shifterType = 'D';

export const $truckShifterTypeLetter = (transmission) => {
if (
transmission.shifterType === 'automatic' ||
transmission.shifterType === 'arcade'
)
shifterType = 'A';

if (gear <= crawlingGear) shifterType = 'C';

if (gear === 0) shifterType = 'N';

if (gear < 0) shifterType = 'R';

return shifterType;
return 'A';
else return 'M';
};
6 changes: 3 additions & 3 deletions src/utils/telemetry/_helper.utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ import { store as telemetryStore } from '@/store/telemetry.store';

export const $gameTime = () => telemetryStore.telemetry.game.time.unix;

export const $truckElectricOn = () => {
return telemetryStore.telemetry.truck.electric.enabled;
};
//export const $truckElectricOn = () => {
// return telemetryStore.telemetry.truck.electric.enabled;
//};
2 changes: 1 addition & 1 deletion src/utils/telemetry/_navigation.utils.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { store as telemetryStore } from '@/store/telemetry.store';
import { diffDateTimeLocalized } from '@/utils/_app';
import { $gameTime } from '@/utils/telemetry/_common.utils';
import { $gameTime } from '@/utils/telemetry/_helper.utils';

export const $etaDueDate = () => {
const currentGameTime = $gameTime();
Expand Down

0 comments on commit 5595ee4

Please sign in to comment.