diff --git a/angular-client/src/components/acceleration-graphs/acceleration-graphs.component.ts b/angular-client/src/components/acceleration-graphs/acceleration-graphs.component.ts index f3994a9b..69f172ad 100644 --- a/angular-client/src/components/acceleration-graphs/acceleration-graphs.component.ts +++ b/angular-client/src/components/acceleration-graphs/acceleration-graphs.component.ts @@ -1,6 +1,6 @@ import { Component, OnDestroy, OnInit, inject } from '@angular/core'; import Storage from 'src/services/storage.service'; -import { DataTypeEnum } from 'src/data-type.enum'; +import { topics } from 'src/utils/topic.utils'; import { decimalPipe } from 'src/utils/pipes.utils'; import { GraphData } from 'src/utils/types.utils'; import { InfoBackgroundComponent } from '../info-background/info-background.component'; @@ -36,7 +36,7 @@ export class AccelerationGraphsComponent implements OnInit, OnDestroy { ngOnInit() { this.subscriptions.push( - this.storage.get(DataTypeEnum.XYZAccel).subscribe((value) => { + this.storage.get(topics.xyzAcceleration()).subscribe((value) => { const x1 = decimalPipe(value.values[0]); const y1 = decimalPipe(value.values[1]); const time = +value.time; diff --git a/angular-client/src/components/acceleration-over-time-display/acceleration-over-time-display.component.ts b/angular-client/src/components/acceleration-over-time-display/acceleration-over-time-display.component.ts index fc284cb4..5e98e63d 100644 --- a/angular-client/src/components/acceleration-over-time-display/acceleration-over-time-display.component.ts +++ b/angular-client/src/components/acceleration-over-time-display/acceleration-over-time-display.component.ts @@ -1,6 +1,6 @@ import { Component, OnInit, inject } from '@angular/core'; import Storage from 'src/services/storage.service'; -import { DataTypeEnum } from 'src/data-type.enum'; +import { topics } from 'src/utils/topic.utils'; import { GraphData } from 'src/utils/types.utils'; import { InfoGraphComponent } from '../info-graph/info-graph.component'; @@ -16,7 +16,7 @@ export default class AccelerationOverTimeDisplayComponent implements OnInit { data: GraphData[] = []; ngOnInit() { - this.storage.get(DataTypeEnum.ACCELERATION).subscribe((value) => { + this.storage.get(topics.acceleration()).subscribe((value) => { this.data.push({ x: new Date().getTime(), y: parseInt(value.values[0]) }); }); } diff --git a/angular-client/src/components/brake-pressure-display/brake-pressure-display.component.ts b/angular-client/src/components/brake-pressure-display/brake-pressure-display.component.ts index e62a3bdf..a0021bef 100644 --- a/angular-client/src/components/brake-pressure-display/brake-pressure-display.component.ts +++ b/angular-client/src/components/brake-pressure-display/brake-pressure-display.component.ts @@ -1,6 +1,6 @@ import { Component, OnInit, inject } from '@angular/core'; import Storage from 'src/services/storage.service'; -import { DataTypeEnum } from 'src/data-type.enum'; +import { topics } from 'src/utils/topic.utils'; import { InfoBackgroundComponent } from '../info-background/info-background.component'; import TypographyComponent from '../typography/typography.component'; @@ -16,7 +16,7 @@ export default class BrakePressureDisplayComponent implements OnInit { brakePressure: number = 0; ngOnInit() { - this.storage.get(DataTypeEnum.BRAKE_PRESSURE).subscribe((value) => { + this.storage.get(topics.brakePressure()).subscribe((value) => { this.brakePressure = parseInt(value.values[0]); }); } diff --git a/angular-client/src/components/driver-component/driver-component.ts b/angular-client/src/components/driver-component/driver-component.ts index 7f9638f5..62dd1af5 100644 --- a/angular-client/src/components/driver-component/driver-component.ts +++ b/angular-client/src/components/driver-component/driver-component.ts @@ -1,6 +1,6 @@ import { Component, OnInit, inject } from '@angular/core'; import { getLatestRun } from 'src/api/run.api'; -import { DataTypeEnum } from 'src/data-type.enum'; +import { topics } from 'src/utils/topic.utils'; import APIService from 'src/services/api.service'; import Storage from 'src/services/storage.service'; import { Run } from 'src/utils/types.utils'; @@ -21,7 +21,7 @@ export class DriverComponent implements OnInit { apiService = inject(APIService); ngOnInit() { - this.storage.get(DataTypeEnum.DRIVER).subscribe((value) => { + this.storage.get(topics.driver()).subscribe((value) => { [this.driver] = value.values || ['No Driver']; }); } diff --git a/angular-client/src/components/latency-display/latency-display.ts b/angular-client/src/components/latency-display/latency-display.ts index edf64dde..0949eb2c 100644 --- a/angular-client/src/components/latency-display/latency-display.ts +++ b/angular-client/src/components/latency-display/latency-display.ts @@ -1,6 +1,6 @@ import { Component, Input, OnInit, inject } from '@angular/core'; import Storage from 'src/services/storage.service'; -import { DataTypeEnum } from 'src/data-type.enum'; +import { topics } from 'src/utils/topic.utils'; import { InfoBackgroundComponent } from '../info-background/info-background.component'; import { DividerComponent } from '../divider/divider'; @@ -24,10 +24,10 @@ export default class LatencyDisplayComponent implements OnInit { newLatency: number = 0; ngOnInit(): void { - this.storage.get(DataTypeEnum.LATENCY).subscribe((value) => { + this.storage.get(topics.latency()).subscribe((value) => { this.latency = parseInt(value.values[0]); }); - this.storage.get(DataTypeEnum.NEW_LATENCY).subscribe((value) => { + this.storage.get(topics.newLatency()).subscribe((value) => { this.newLatency = parseInt(value.values[0]); }); } diff --git a/angular-client/src/components/motor-info/motor-info.component.ts b/angular-client/src/components/motor-info/motor-info.component.ts index cdc8223c..9a752fa5 100644 --- a/angular-client/src/components/motor-info/motor-info.component.ts +++ b/angular-client/src/components/motor-info/motor-info.component.ts @@ -1,6 +1,6 @@ import { Component, OnDestroy, OnInit, inject } from '@angular/core'; import Storage from 'src/services/storage.service'; -import { DataTypeEnum } from 'src/data-type.enum'; +import { topics } from 'src/utils/topic.utils'; import { floatPipe } from 'src/utils/pipes.utils'; import { InfoBackgroundComponent } from '../info-background/info-background.component'; @@ -42,31 +42,31 @@ export default class MotorInfoComponent implements OnInit, OnDestroy { ngOnInit() { this.subscriptions.push( - this.storage.get(DataTypeEnum.MOTOR_TEMP).subscribe((value) => { + this.storage.get(topics.motorTemp()).subscribe((value) => { this.motorTemp = floatPipe(value.values[0]); this.updatePieChart(); }), - this.storage.get(DataTypeEnum.MOTOR_USAGE).subscribe((value) => { + this.storage.get(topics.motorUsage()).subscribe((value) => { this.motorUsage = floatPipe(value.values[0]); this.updatePieChart(); }), - this.storage.get(DataTypeEnum.COOL_USAGE).subscribe((value) => { + this.storage.get(topics.coolingUsage()).subscribe((value) => { this.coolUsage = floatPipe(value.values[0]); this.updatePieChart(); }), - this.storage.get(DataTypeEnum.BATTBOX_FANS).subscribe((value) => { + this.storage.get(topics.battboxFans()).subscribe((value) => { this.battboxFans = floatPipe(value.values[0]); this.updatePieChart(); }), - this.storage.get(DataTypeEnum.PUMPS).subscribe((value) => { + this.storage.get(topics.pumps()).subscribe((value) => { this.pumps = floatPipe(value.values[0]); this.updatePieChart(); }), - this.storage.get(DataTypeEnum.MOTOR_CONTROLLER).subscribe((value) => { + this.storage.get(topics.motorController()).subscribe((value) => { this.motorController = floatPipe(value.values[0]); this.updatePieChart(); }), - this.storage.get(DataTypeEnum.LV_BOARDS).subscribe((value) => { + this.storage.get(topics.lvBoards()).subscribe((value) => { this.lvBoards = floatPipe(value.values[0]); this.updatePieChart(); }) @@ -76,9 +76,7 @@ export default class MotorInfoComponent implements OnInit, OnDestroy { } updatePieChart() { - // Calculate total usage of the four components const totalUsed = this.motorController + this.battboxFans + this.pumps + this.lvBoards; - // Calculate the remaining unused portion out of 20 const remainingUnused = Math.max(0, 20 - totalUsed); this.piechartData = [ diff --git a/angular-client/src/components/raspberry-pi/raspberry-pi.component.ts b/angular-client/src/components/raspberry-pi/raspberry-pi.component.ts index e475a656..66e4730d 100644 --- a/angular-client/src/components/raspberry-pi/raspberry-pi.component.ts +++ b/angular-client/src/components/raspberry-pi/raspberry-pi.component.ts @@ -1,6 +1,6 @@ import { Component, HostListener, OnInit, inject } from '@angular/core'; import Storage from 'src/services/storage.service'; -import { DataTypeEnum } from 'src/data-type.enum'; +import { topics } from 'src/utils/topic.utils'; import { floatPipe } from 'src/utils/pipes.utils'; import { InfoBackgroundComponent } from '../info-background/info-background.component'; import RaspberryPiDesktopComponent from './raspberry-pi-desktop-content/raspberry-pi-desktop.component'; @@ -25,19 +25,19 @@ export default class RasberryPiComponent implements OnInit { isMobile = window.innerWidth < this.mobileThreshold; ngOnInit() { - this.storage.get(DataTypeEnum.CPUUsage).subscribe((value) => { + this.storage.get(topics.cpuUsage()).subscribe((value) => { this.cpuUsage = floatPipe(value.values[0]); }); - this.storage.get(DataTypeEnum.CPUTemp).subscribe((value) => { + this.storage.get(topics.cpuTemp()).subscribe((value) => { this.cpuTemp = floatPipe(value.values[0]); }); - this.storage.get(DataTypeEnum.RAMUsage).subscribe((value) => { + this.storage.get(topics.ramUsage()).subscribe((value) => { this.ramUsage = Math.round((1 - floatPipe(value.values[0]) / 8000) * 100); }); - this.storage.get(DataTypeEnum.WIFIRSSI).subscribe((value) => { + this.storage.get(topics.wifiRSSI()).subscribe((value) => { this.wifiRSSI = floatPipe(value.values[0]); }); - this.storage.get(DataTypeEnum.MCS).subscribe((value) => { + this.storage.get(topics.mcs()).subscribe((value) => { this.mcs = floatPipe(value.values[0]); }); } diff --git a/angular-client/src/components/speed-display/speed-display.component.ts b/angular-client/src/components/speed-display/speed-display.component.ts index ae67fad5..4e3e13f3 100644 --- a/angular-client/src/components/speed-display/speed-display.component.ts +++ b/angular-client/src/components/speed-display/speed-display.component.ts @@ -1,6 +1,6 @@ import { Component, OnInit, inject } from '@angular/core'; import Storage from 'src/services/storage.service'; -import { DataTypeEnum } from 'src/data-type.enum'; +import { topics } from 'src/utils/topic.utils'; import { InfoBackgroundComponent } from '../info-background/info-background.component'; import HalfGaugeComponent from '../half-gauge/half-gauge.component'; @@ -16,7 +16,7 @@ export default class SpeedDisplayComponent implements OnInit { speed: number = 0; ngOnInit() { - this.storage.get(DataTypeEnum.SPEED).subscribe((value) => { + this.storage.get(topics.speed()).subscribe((value) => { this.speed = parseInt(value.values[0]); }); } diff --git a/angular-client/src/components/speed-over-time-display/speed-over-time-display.component.ts b/angular-client/src/components/speed-over-time-display/speed-over-time-display.component.ts index c7c24de5..90806644 100644 --- a/angular-client/src/components/speed-over-time-display/speed-over-time-display.component.ts +++ b/angular-client/src/components/speed-over-time-display/speed-over-time-display.component.ts @@ -1,7 +1,7 @@ import { Component, OnDestroy, OnInit, inject } from '@angular/core'; import { Subscription } from 'rxjs'; import Storage from 'src/services/storage.service'; -import { DataTypeEnum } from 'src/data-type.enum'; +import { topics } from 'src/utils/topic.utils'; import { GraphData } from 'src/utils/types.utils'; import { InfoGraphComponent } from '../info-graph/info-graph.component'; @@ -19,7 +19,7 @@ export default class SpeedOverTimeDisplayComponent implements OnInit, OnDestroy ngOnInit() { this.subscriptions.push( - this.storage.get(DataTypeEnum.SPEED).subscribe((value) => { + this.storage.get(topics.speed()).subscribe((value) => { this.data.push({ x: new Date().getTime(), y: parseInt(value.values[0]) }); }) ); diff --git a/angular-client/src/components/steering-angle-display/steering-angle-display.component.ts b/angular-client/src/components/steering-angle-display/steering-angle-display.component.ts index 4ee3d318..6479d9f0 100644 --- a/angular-client/src/components/steering-angle-display/steering-angle-display.component.ts +++ b/angular-client/src/components/steering-angle-display/steering-angle-display.component.ts @@ -1,6 +1,6 @@ import { Component, OnInit, inject } from '@angular/core'; import Storage from 'src/services/storage.service'; -import { DataTypeEnum } from 'src/data-type.enum'; +import { topics } from 'src/utils/topic.utils'; import { floatPipe } from 'src/utils/pipes.utils'; import { InfoBackgroundComponent } from '../info-background/info-background.component'; import TypographyComponent from '../typography/typography.component'; @@ -22,7 +22,7 @@ export class SteeringAngleDisplayComponent implements OnInit { steeringAngle: number = 0; ngOnInit() { - this.storage.get(DataTypeEnum.STEERING_ANGLE).subscribe((value) => { + this.storage.get(topics.steeringAngle()).subscribe((value) => { this.steeringAngle = floatPipe(value.values[0]); }); } diff --git a/angular-client/src/components/torque-display/torque-display.component.ts b/angular-client/src/components/torque-display/torque-display.component.ts index 84b318ca..a144a7a9 100644 --- a/angular-client/src/components/torque-display/torque-display.component.ts +++ b/angular-client/src/components/torque-display/torque-display.component.ts @@ -1,6 +1,6 @@ import { Component, OnInit, inject } from '@angular/core'; import Storage from 'src/services/storage.service'; -import { DataTypeEnum } from 'src/data-type.enum'; +import { topics } from 'src/utils/topic.utils'; import { InfoBackgroundComponent } from '../info-background/info-background.component'; import TypographyComponent from '../typography/typography.component'; import HStackComponent from '../hstack/hstack.component'; @@ -17,7 +17,7 @@ export default class TorqueDisplayComponent implements OnInit { torque: number = 0; ngOnInit() { - this.storage.get(DataTypeEnum.TORQUE).subscribe((value) => { + this.storage.get(topics.torque()).subscribe((value) => { this.torque = parseInt(value.values[0]); }); } diff --git a/angular-client/src/data-type.enum.ts b/angular-client/src/data-type.enum.ts deleted file mode 100644 index 583c8675..00000000 --- a/angular-client/src/data-type.enum.ts +++ /dev/null @@ -1,107 +0,0 @@ -export enum DataTypeEnum { - DRIVER = 'Driver', - LOCATION = 'Location', - VIEWERS = 'Viewers', - - // Special Latency info sent by Scylla - LATENCY = 'Old_Latency', - NEW_LATENCY = 'Latency', - - //Fake Data Points - MOTOR_USAGE = 'Motor Usage', - COOL_USAGE = 'Cooling Usage', - STEERING_ANGLE = 'Steering Angle', - TORQUE = 'Torque', - BRAKE_PRESSURE = 'Brake Pressure', - ACCELERATION = 'Acceleration', - XYZAccel = 'XYZAcceleration', - - // MPU - SPEED = 'MPU/State/Speed', - MOTOR_CONTROLLER = 'MPU/Current/Motor_Controller', - BATTBOX_FANS = 'MPU/Current/Battbox_Fans', - PUMPS = 'MPU/Current/Pumps', - LV_BOARDS = 'MPU/Current/LV_Boards', - - // DTI - MOTOR_TEMP = 'DTI/Temps/Motor_Temperature', - - // TPU - CPUUsage = 'TPU/OnBoard/CpuUsage', - CPUTemp = 'TPU/OnBoard/CpuTemp', - RAMUsage = 'TPU/OnBoard/MemAvailable', - WIFIRSSI = 'TPU/HaLow/RSSI', - MCS = 'TPU/HaLow/ApMCS', - POINTS = 'TPU/GPS/Location', - - // BMS - PACK_TEMP = 'BMS/Status/Temp_Average', - STATE_OF_CHARGE = 'BMS/Pack/SOC', - CURRENT = 'BMS/Charging/Current', - CHARGE_CURRENT_LIMIT = 'BMS/Pack/CCL', - DISCHARGE_CURRENT_LIMIT = 'BMS/Pack/DCL', - STATUS_BALANCING = 'BMS/Status/Balancing', - BMS_MODE = 'BMS/Status/State', - CHARGING = 'BMS/Charging/Control', - PACK_VOLTAGE = 'BMS/Pack/Voltage', - CELL_UNDERVOLTAGE = 'BMS/Status/F/Cell_Undervoltage', - CELL_OVERVOLTAGE = 'BMS/Status/F/Cell_Overvoltage', - CELLS_NOT_BALANCING = 'BMS/Status/F/Cells_Not_Balancing', - - // Charger Faults - COMM_TIMEOUT_FAULT = 'Charger/Box/F_CommTimeout', - HARDWARE_FAILURE_FAULT = 'Charger/Box/F_HardwareFailure', - OVER_TEMP_FAULT = 'Charger/Box/F_OverTemp', - OVER_VOLTAGE_FAULT = 'Charger/Box/F_OverVoltage', - WRONG_BAT_CONNECT_FAULT = 'Charger/Box/F_WrongBatConnect', - - // BMS Faults - OPEN_WIRE = 'BMS/Status/F/Open_Wire', - CHARGER_LIMIT_ENFORCEMENT_FAULT = 'BMS/Status/F/CCL_Enforce', - CHARGER_CAN_FAULT = 'BMS/Status/F/Charger_Can', - BATTERY_THERMISTOR = 'BMS/Status/F/Battery_Therm', - CHARGER_SAFETY_RELAY = 'BMS/Status/F/Charger_Safety', - DISCHARGE_LIMIT_ENFORCEMENT_FAULT = 'BMS/Status/F/DCL_Enforce', - EXTERNAL_CAN_FAULT = 'BMS/Status/F/External_Can', - WEAK_PACK_FAULT = 'BMS/Status/F/Weak_Pack', - LOW_CELL_VOLTAGE = 'BMS/Status/F/Low_Cell_Volts', - CHARGE_READING_MISMATCH = 'BMS/Status/F/Charge_Reading', - CURRENT_SENSOR_FAULT = 'BMS/Status/F/Current_Sense', - INTERNAL_CELL_COMM_FAULT = 'BMS/Status/F/IC_Comm', - INTERNAL_THERMAL_ERROR = 'BMS/Status/F/Thermal_Err', - INTERNAL_SOFTWARE_FAULT = 'BMS/Status/F/Software', - PACK_OVERHEAT = 'BMS/Status/F/Pack_Overheat', - - // BMS Debug - Segment_Temp_1 = 'BMS/Segment_Temp/1', - Segment_Temp_2 = 'BMS/Segment_Temp/2', - Segment_Temp_3 = 'BMS/Segment_Temp/3', - Segment_Temp_4 = 'BMS/Segment_Temp/4', - Segment_Temp_5 = 'BMS/Segment_Temp/5', - - // Segment Voltage - Segment_Voltage_1 = 'BMS/Segment_Voltage/1', - Segment_Voltage_2 = 'BMS/Segment_Voltage/2', - Segment_Voltage_3 = 'BMS/Segment_Voltage/3', - Segment_Voltage_4 = 'BMS/Segment_Voltage/4', - Segment_Voltage_5 = 'BMS/Segment_Voltage/5', - - // BMS Per Cell - // Alpha - PER_CELL_ALPHA_DIE_TEMP_0 = 'BMS/PerCell/Alpha/0/DieTemp', - PER_CELL_ALPHA_DIE_TEMP_1 = 'BMS/PerCell/Alpha/1/DieTemp', - PER_CELL_ALPHA_DIE_TEMP_2 = 'BMS/PerCell/Alpha/2/DieTemp', - PER_CELL_ALPHA_DIE_TEMP_3 = 'BMS/PerCell/Alpha/3/DieTemp', - PER_CELL_ALPHA_DIE_TEMP_4 = 'BMS/PerCell/Alpha/4/DieTemp', - - // Beta - PER_CELL_BETA_DIE_TEMP_0 = 'BMS/PerCell/Beta/0/DieTemp', - PER_CELL_BETA_DIE_TEMP_1 = 'BMS/PerCell/Beta/1/DieTemp', - PER_CELL_BETA_DIE_TEMP_2 = 'BMS/PerCell/Beta/2/DieTemp', - PER_CELL_BETA_DIE_TEMP_3 = 'BMS/PerCell/Beta/3/DieTemp', - PER_CELL_BETA_DIE_TEMP_4 = 'BMS/PerCell/Beta/4/DieTemp', - - // Overflow and CRC - PER_CELL_OVERFLOWID = 'BMS/PerCell/OverflowID', - PER_CELL_CRC = 'BMS/PerCell/PECErrorChip' -} diff --git a/angular-client/src/pages/bms-debug-page/components/bms-at-a-glance/bms-at-a-glance.component.ts b/angular-client/src/pages/bms-debug-page/components/bms-at-a-glance/bms-at-a-glance.component.ts index 36ac1383..045dc13b 100644 --- a/angular-client/src/pages/bms-debug-page/components/bms-at-a-glance/bms-at-a-glance.component.ts +++ b/angular-client/src/pages/bms-debug-page/components/bms-at-a-glance/bms-at-a-glance.component.ts @@ -1,6 +1,5 @@ import { Component, HostListener, inject, OnDestroy, OnInit } from '@angular/core'; import { Subscription } from 'rxjs'; -import { DataTypeEnum } from 'src/data-type.enum'; import Storage from 'src/services/storage.service'; import { Chip, chipToString, getConnectionDotStatusColor } from 'src/utils/bms.utils'; import { topics } from 'src/utils/topic.utils'; @@ -114,13 +113,13 @@ export class BmsAtAGlanceComponent implements OnInit, OnDestroy { ngOnInit(): void { this.subscriptions.push( - this.storage.get(DataTypeEnum.PACK_VOLTAGE).subscribe((value) => { + this.storage.get(topics.packVoltage()).subscribe((value) => { this.voltage = parseInt(value.values[0]); }), - this.storage.get(DataTypeEnum.PACK_TEMP).subscribe((value) => { + this.storage.get(topics.packTemp()).subscribe((value) => { this.temperature = parseInt(value.values[0]); }), - this.storage.get(DataTypeEnum.STATE_OF_CHARGE).subscribe((value) => { + this.storage.get(topics.stateOfCharge()).subscribe((value) => { this.chargeState = parseInt(value.values[0]); }), this.storage.get(topics.accCCL()).subscribe((value) => { diff --git a/angular-client/src/pages/bms-debug-page/components/bms-overflow/bms-overflow.component.ts b/angular-client/src/pages/bms-debug-page/components/bms-overflow/bms-overflow.component.ts index 4a22ec61..69348646 100644 --- a/angular-client/src/pages/bms-debug-page/components/bms-overflow/bms-overflow.component.ts +++ b/angular-client/src/pages/bms-debug-page/components/bms-overflow/bms-overflow.component.ts @@ -1,9 +1,8 @@ import { Component, inject, OnDestroy, OnInit } from '@angular/core'; import { Subscription } from 'rxjs'; -import { DataTypeEnum } from 'src/data-type.enum'; import Storage from 'src/services/storage.service'; +import { topics } from 'src/utils/topic.utils'; import { InfoBackgroundComponent } from '../../../../components/info-background/info-background.component'; - import { ConnectionDotWithMessageComponent } from '../../../../components/connection-dot-with-message/connection-dot-with-message.component'; import TypographyComponent from 'src/components/typography/typography.component'; import VStackComponent from 'src/components/vstack/vstack.component'; @@ -22,7 +21,7 @@ export class BmsOverflowComponent implements OnInit, OnDestroy { ngOnInit(): void { this.subscriptions.push( - this.storage.get(DataTypeEnum.PER_CELL_OVERFLOWID).subscribe((value) => { + this.storage.get(topics.perCellOverflowId()).subscribe((value) => { if (parseFloat(value.time) > Date.now() - 4000) { this.overflowID = parseInt(value.values[0]); } else { diff --git a/angular-client/src/pages/bms-debug-page/components/crc/crc.component.ts b/angular-client/src/pages/bms-debug-page/components/crc/crc.component.ts index 6bc005e3..3bd4579b 100644 --- a/angular-client/src/pages/bms-debug-page/components/crc/crc.component.ts +++ b/angular-client/src/pages/bms-debug-page/components/crc/crc.component.ts @@ -1,8 +1,7 @@ import { Component, inject, OnInit } from '@angular/core'; -import { DataTypeEnum } from 'src/data-type.enum'; import Storage from 'src/services/storage.service'; +import { topics } from 'src/utils/topic.utils'; import { InfoBackgroundComponent } from '../../../../components/info-background/info-background.component'; - import { ConnectionDotWithMessageComponent } from '../../../../components/connection-dot-with-message/connection-dot-with-message.component'; import TypographyComponent from 'src/components/typography/typography.component'; import VStackComponent from 'src/components/vstack/vstack.component'; @@ -19,7 +18,7 @@ export class CRCComponent implements OnInit { pecErrorChip: number | undefined = undefined; ngOnInit(): void { - this.storage.get(DataTypeEnum.PER_CELL_CRC).subscribe((value) => { + this.storage.get(topics.pecErrorChip()).subscribe((value) => { if (parseFloat(value.time) > Date.now() - 4000) { this.pecErrorChip = parseInt(value.values[0]); } else { diff --git a/angular-client/src/pages/charging-page/charging-page-mobile/charging-page-mobile.component.ts b/angular-client/src/pages/charging-page/charging-page-mobile/charging-page-mobile.component.ts index 527b6e82..7a3e4723 100644 --- a/angular-client/src/pages/charging-page/charging-page-mobile/charging-page-mobile.component.ts +++ b/angular-client/src/pages/charging-page/charging-page-mobile/charging-page-mobile.component.ts @@ -1,7 +1,7 @@ import { Component, HostListener, Input, OnDestroy, OnInit, inject } from '@angular/core'; import { Subscription } from 'rxjs'; import Storage from 'src/services/storage.service'; -import { DataTypeEnum } from 'src/data-type.enum'; +import { topics } from 'src/utils/topic.utils'; import { DividerComponent } from '../../../components/divider/divider'; import { DatePipe } from '@angular/common'; @@ -57,7 +57,7 @@ export default class ChargingPageMobileComponent implements OnInit, OnDestroy { }, 1000); this.subscriptions.push( - this.storage.get(DataTypeEnum.LOCATION).subscribe((value) => { + this.storage.get(topics.location()).subscribe((value) => { [this.location] = value.values || ['No Location Set']; }) ); diff --git a/angular-client/src/pages/charging-page/charging-page.component.ts b/angular-client/src/pages/charging-page/charging-page.component.ts index d51a7def..b47cd0bf 100644 --- a/angular-client/src/pages/charging-page/charging-page.component.ts +++ b/angular-client/src/pages/charging-page/charging-page.component.ts @@ -1,7 +1,7 @@ import { Component, HostListener, OnDestroy, OnInit, inject } from '@angular/core'; import { Subscription } from 'rxjs'; import Storage from 'src/services/storage.service'; -import { DataTypeEnum } from 'src/data-type.enum'; +import { topics } from 'src/utils/topic.utils'; import { MatGridList, MatGridTile } from '@angular/material/grid-list'; import PackVoltageDisplayComponent from './components/pack-voltage/pack-voltage-display/pack-voltage-display.component'; @@ -51,7 +51,7 @@ export default class ChargingPageComponent implements OnInit, OnDestroy { }, 1000); this.subscriptions.push( - this.storage.get(DataTypeEnum.LOCATION).subscribe((value) => { + this.storage.get(topics.location()).subscribe((value) => { [this.location] = value.values || ['No Location Set']; }) ); diff --git a/angular-client/src/pages/charging-page/components/BMS-mode/BMS-mode-display.component.ts b/angular-client/src/pages/charging-page/components/BMS-mode/BMS-mode-display.component.ts index d605a680..8f94c412 100644 --- a/angular-client/src/pages/charging-page/components/BMS-mode/BMS-mode-display.component.ts +++ b/angular-client/src/pages/charging-page/components/BMS-mode/BMS-mode-display.component.ts @@ -1,7 +1,7 @@ import { Component, OnDestroy, OnInit, inject } from '@angular/core'; import { Subscription } from 'rxjs'; import Storage from 'src/services/storage.service'; -import { DataTypeEnum } from 'src/data-type.enum'; +import { topics } from 'src/utils/topic.utils'; import { floatPipe } from 'src/utils/pipes.utils'; import { InfoBackgroundComponent } from '../../../../components/info-background/info-background.component'; import TypographyComponent from 'src/components/typography/typography.component'; @@ -26,7 +26,6 @@ export default class BMSModeDisplayComponent implements OnInit, OnDestroy { private subscriptions: Subscription[] = []; bmsMode: BMSMODE = 1; - // Mapping object for colors private colorMap: { [key in BMSMODE]: string } = { [BMSMODE.DEFAULT]: 'grey', [BMSMODE.READY]: 'blue', @@ -36,7 +35,7 @@ export default class BMSModeDisplayComponent implements OnInit, OnDestroy { ngOnInit() { this.subscriptions.push( - this.storage.get(DataTypeEnum.BMS_MODE).subscribe((value) => { + this.storage.get(topics.bmsMode()).subscribe((value) => { this.bmsMode = floatPipe(value.values[0]) as BMSMODE; }) ); diff --git a/angular-client/src/pages/charging-page/components/active-status/active-status.component.ts b/angular-client/src/pages/charging-page/components/active-status/active-status.component.ts index 381be847..31287a01 100644 --- a/angular-client/src/pages/charging-page/components/active-status/active-status.component.ts +++ b/angular-client/src/pages/charging-page/components/active-status/active-status.component.ts @@ -1,7 +1,7 @@ import { Component, Input, OnInit, inject } from '@angular/core'; import Storage from 'src/services/storage.service'; import Theme from 'src/services/theme.service'; -import { DataTypeEnum } from 'src/data-type.enum'; +import { topics } from 'src/utils/topic.utils'; import { InfoBackgroundComponent } from '../../../../components/info-background/info-background.component'; import CurrentTotalTimerComponent from 'src/components/current-total-timer/current-total-timer.component'; import HStackComponent from 'src/components/hstack/hstack.component'; @@ -22,7 +22,7 @@ export default class ActiveStatusComponent implements OnInit { intervalId!: NodeJS.Timeout; ngOnInit() { - this.storage.getTimerData(DataTypeEnum.BMS_MODE).subscribe((value) => { + this.storage.getTimerData(topics.bmsMode()).subscribe((value) => { const statusStateValue = value.last_value; if (this.isActive) { if (!(statusStateValue === 2)) { diff --git a/angular-client/src/pages/charging-page/components/balancing-status/balancing-status.component.ts b/angular-client/src/pages/charging-page/components/balancing-status/balancing-status.component.ts index 1ce238b1..dbb1d266 100644 --- a/angular-client/src/pages/charging-page/components/balancing-status/balancing-status.component.ts +++ b/angular-client/src/pages/charging-page/components/balancing-status/balancing-status.component.ts @@ -2,7 +2,7 @@ import { Component, Input, OnDestroy, OnInit, inject } from '@angular/core'; import { Subscription } from 'rxjs'; import Storage from 'src/services/storage.service'; import Theme from 'src/services/theme.service'; -import { DataTypeEnum } from 'src/data-type.enum'; +import { topics } from 'src/utils/topic.utils'; import { InfoBackgroundComponent } from '../../../../components/info-background/info-background.component'; import CurrentTotalTimerComponent from 'src/components/current-total-timer/current-total-timer.component'; import HStackComponent from 'src/components/hstack/hstack.component'; @@ -25,7 +25,7 @@ export default class BalancingStatusComponent implements OnInit, OnDestroy { ngOnInit() { this.subscriptions.push( - this.storage.getTimerData(DataTypeEnum.STATUS_BALANCING).subscribe((value) => { + this.storage.getTimerData(topics.statusBalancing()).subscribe((value) => { const statusBalancingValue = value.last_value; if (this.isBalancing) { if (!(statusBalancingValue === 1)) { diff --git a/angular-client/src/pages/charging-page/components/battery-current/current-display/current-display.component.ts b/angular-client/src/pages/charging-page/components/battery-current/current-display/current-display.component.ts index d8e13477..df789ec8 100644 --- a/angular-client/src/pages/charging-page/components/battery-current/current-display/current-display.component.ts +++ b/angular-client/src/pages/charging-page/components/battery-current/current-display/current-display.component.ts @@ -1,6 +1,6 @@ import { Component, OnInit, inject } from '@angular/core'; import Storage from 'src/services/storage.service'; -import { DataTypeEnum } from 'src/data-type.enum'; +import { topics } from 'src/utils/topic.utils'; import { InfoBackgroundComponent } from '../../../../../components/info-background/info-background.component'; import TypographyComponent from 'src/components/typography/typography.component'; @@ -16,7 +16,7 @@ export default class CurrentDisplayComponent implements OnInit { amps: number = 0; ngOnInit() { - this.storage.get(DataTypeEnum.CURRENT).subscribe((value) => { + this.storage.get(topics.current()).subscribe((value) => { this.amps = parseFloat(value.values[0]); }); } diff --git a/angular-client/src/pages/charging-page/components/battery-info-display/battery-info-display.ts b/angular-client/src/pages/charging-page/components/battery-info-display/battery-info-display.ts index afb23489..c21d94d3 100644 --- a/angular-client/src/pages/charging-page/components/battery-info-display/battery-info-display.ts +++ b/angular-client/src/pages/charging-page/components/battery-info-display/battery-info-display.ts @@ -1,6 +1,6 @@ import { Component, HostListener, OnDestroy, OnInit, inject } from '@angular/core'; import { Subscription } from 'rxjs'; -import { DataTypeEnum } from 'src/data-type.enum'; +import { topics } from 'src/utils/topic.utils'; import { floatPipe } from 'src/utils/pipes.utils'; import Storage from 'src/services/storage.service'; import { InfoBackgroundComponent } from '../../../../components/info-background/info-background.component'; @@ -27,19 +27,19 @@ export class BatteryInfoDisplayComponent implements OnInit, OnDestroy { ngOnInit() { this.subscriptions.push( - this.storage.get(DataTypeEnum.PACK_TEMP).subscribe((value) => { + this.storage.get(topics.packTemp()).subscribe((value) => { this.packTemp = floatPipe(value.values[0]); }), - this.storage.get(DataTypeEnum.PACK_VOLTAGE).subscribe((value) => { + this.storage.get(topics.packVoltage()).subscribe((value) => { this.voltage = floatPipe(value.values[0]); }), - this.storage.get(DataTypeEnum.STATE_OF_CHARGE).subscribe((value) => { + this.storage.get(topics.stateOfCharge()).subscribe((value) => { this.stateOfCharge = floatPipe(value.values[0]); }), - this.storage.get(DataTypeEnum.CHARGE_CURRENT_LIMIT).subscribe((value) => { + this.storage.get(topics.chargeCurrentLimit()).subscribe((value) => { this.chargeCurrentLimit = floatPipe(value.values[0]); }), - this.storage.get(DataTypeEnum.DISCHARGE_CURRENT_LIMIT).subscribe((value) => { + this.storage.get(topics.dischargeCurrentLimit()).subscribe((value) => { this.dischargeCurrentLimit = floatPipe(value.values[0]); }) ); diff --git a/angular-client/src/pages/charging-page/components/charging-state/charging-status.component.ts b/angular-client/src/pages/charging-page/components/charging-state/charging-status.component.ts index 9d0edc1f..51c70f49 100644 --- a/angular-client/src/pages/charging-page/components/charging-state/charging-status.component.ts +++ b/angular-client/src/pages/charging-page/components/charging-state/charging-status.component.ts @@ -1,7 +1,7 @@ import { Component, Input, OnInit, inject } from '@angular/core'; import Storage from 'src/services/storage.service'; import Theme from 'src/services/theme.service'; -import { DataTypeEnum } from 'src/data-type.enum'; +import { topics } from 'src/utils/topic.utils'; import { InfoBackgroundComponent } from '../../../../components/info-background/info-background.component'; import CurrentTotalTimerComponent from 'src/components/current-total-timer/current-total-timer.component'; import HStackComponent from 'src/components/hstack/hstack.component'; @@ -22,7 +22,7 @@ export default class ChargingStatusComponent implements OnInit { intervalId!: NodeJS.Timeout; ngOnInit() { - this.storage.getTimerData(DataTypeEnum.CHARGING).subscribe((value) => { + this.storage.getTimerData(topics.charging()).subscribe((value) => { const chargingControlValue = value.last_value; if (this.isCharging) { if (chargingControlValue === 1) { diff --git a/angular-client/src/pages/charging-page/components/fault-display/fault-display.component.ts b/angular-client/src/pages/charging-page/components/fault-display/fault-display.component.ts index 9077e37f..a3035184 100644 --- a/angular-client/src/pages/charging-page/components/fault-display/fault-display.component.ts +++ b/angular-client/src/pages/charging-page/components/fault-display/fault-display.component.ts @@ -1,7 +1,7 @@ import { Component, OnDestroy, OnInit, inject } from '@angular/core'; import { Subscription } from 'rxjs'; import Storage from 'src/services/storage.service'; -import { DataTypeEnum } from 'src/data-type.enum'; +import { topics } from 'src/utils/topic.utils'; import { InfoBackgroundComponent } from '../../../../components/info-background/info-background.component'; import TypographyComponent from 'src/components/typography/typography.component'; import VStackComponent from 'src/components/vstack/vstack.component'; @@ -34,26 +34,25 @@ export default class FaultDisplayComponent implements OnInit, OnDestroy { const chargerFaultAndDisplayNames = [ { displayName: 'Comm Timeout', - faultIdentifier: DataTypeEnum.COMM_TIMEOUT_FAULT + faultIdentifier: topics.commTimeoutFault() }, { displayName: 'Hardware Failure', - faultIdentifier: DataTypeEnum.HARDWARE_FAILURE_FAULT + faultIdentifier: topics.hardwareFailureFault() }, { displayName: 'Over Temp', - faultIdentifier: DataTypeEnum.OVER_TEMP_FAULT + faultIdentifier: topics.overTempFault() }, { displayName: 'Over Voltage Fault', - faultIdentifier: DataTypeEnum.OVER_VOLTAGE_FAULT + faultIdentifier: topics.overVoltageFault() }, { displayName: 'Wrong Battery Connect', - faultIdentifier: DataTypeEnum.WRONG_BAT_CONNECT_FAULT + faultIdentifier: topics.wrongBatConnectFault() } ]; - // Subscribe to each charger fault, with a display name (to display when the fault is triggered) chargerFaultAndDisplayNames.forEach((faultAndDisplayName) => { this.faultSubcribe(faultAndDisplayName.displayName, faultAndDisplayName.faultIdentifier, FaultType.Charger); }); @@ -61,75 +60,74 @@ export default class FaultDisplayComponent implements OnInit, OnDestroy { const bmsFaultAndDisplayNames = [ { displayName: 'Open Wire', - faultIdentifier: DataTypeEnum.OPEN_WIRE + faultIdentifier: topics.openWire() }, { displayName: 'Charger Limit Enforcement', - faultIdentifier: DataTypeEnum.CHARGER_LIMIT_ENFORCEMENT_FAULT + faultIdentifier: topics.chargerLimitEnforcementFault() }, { displayName: 'Charger Can Fault', - faultIdentifier: DataTypeEnum.CHARGER_CAN_FAULT + faultIdentifier: topics.chargerCanFault() }, { displayName: 'Battery Thermistor', - faultIdentifier: DataTypeEnum.BATTERY_THERMISTOR + faultIdentifier: topics.batteryThermistor() }, { displayName: 'Charger Safety Relay', - faultIdentifier: DataTypeEnum.CHARGER_SAFETY_RELAY + faultIdentifier: topics.chargerSafetyRelay() }, { displayName: 'Discharge Limit Enforcement', - faultIdentifier: DataTypeEnum.DISCHARGE_LIMIT_ENFORCEMENT_FAULT + faultIdentifier: topics.dischargeLimitEnforcementFault() }, { displayName: 'External Can Fault', - faultIdentifier: DataTypeEnum.EXTERNAL_CAN_FAULT + faultIdentifier: topics.externalCanFault() }, { displayName: 'Weak Pack Fault', - faultIdentifier: DataTypeEnum.WEAK_PACK_FAULT + faultIdentifier: topics.weakPackFault() }, { displayName: 'Low Cell Voltage', - faultIdentifier: DataTypeEnum.LOW_CELL_VOLTAGE + faultIdentifier: topics.lowCellVoltage() }, { displayName: 'Charge Reading Mismatch', - faultIdentifier: DataTypeEnum.CHARGE_READING_MISMATCH + faultIdentifier: topics.chargeReadingMismatch() }, { displayName: 'Current Sensor Fault', - faultIdentifier: DataTypeEnum.CURRENT_SENSOR_FAULT + faultIdentifier: topics.currentSensorFault() }, { displayName: 'Internal Cell Comm Fault', - faultIdentifier: DataTypeEnum.INTERNAL_CELL_COMM_FAULT + faultIdentifier: topics.internalCellCommFault() }, { displayName: 'Internal Software Fault', - faultIdentifier: DataTypeEnum.INTERNAL_SOFTWARE_FAULT + faultIdentifier: topics.internalSoftwareFault() }, { displayName: 'Pack Overheat', - faultIdentifier: DataTypeEnum.PACK_OVERHEAT + faultIdentifier: topics.packOverheat() }, { displayName: 'Cell Undervoltage', - faultIdentifier: DataTypeEnum.CELL_UNDERVOLTAGE + faultIdentifier: topics.cellUndervoltage() }, { displayName: 'Cell Overvoltage', - faultIdentifier: DataTypeEnum.CELL_OVERVOLTAGE + faultIdentifier: topics.cellOvervoltage() }, { displayName: 'Cells Not Balancing', - faultIdentifier: DataTypeEnum.CELLS_NOT_BALANCING + faultIdentifier: topics.cellsNotBalancing() } ]; - // Subscribe to each BMS fault, with a display name (to display when the fault is triggered) bmsFaultAndDisplayNames.forEach((faultAndDisplayName) => { this.faultSubcribe(faultAndDisplayName.displayName, faultAndDisplayName.faultIdentifier, FaultType.BMS); }); @@ -143,7 +141,7 @@ export default class FaultDisplayComponent implements OnInit, OnDestroy { * @param faultIdentifier the identifier for the fault. * @param faultType the type of the fault. */ - private faultSubcribe(displayName: string, faultIdentifier: DataTypeEnum, faultType: FaultType) { + private faultSubcribe(displayName: string, faultIdentifier: string, faultType: FaultType) { let lastFaultValue = 0; this.subscriptions.push( this.storage.get(faultIdentifier).subscribe((value) => { @@ -163,7 +161,6 @@ export default class FaultDisplayComponent implements OnInit, OnDestroy { * @param faultName the name of the fault, to be displayed. */ private addFault(faultValue: number, faultName: string, faultType: FaultType, lastFaultValue: number) { - // only add fault if it is positve for a fault and the last value for this fault was not a fault if (faultValue !== 0 && lastFaultValue === 0) { if (this.faults.length >= 50) { this.faults.pop(); diff --git a/angular-client/src/pages/charging-page/components/faulted-status/faulted-status.component.ts b/angular-client/src/pages/charging-page/components/faulted-status/faulted-status.component.ts index edd3d2b1..62b66784 100644 --- a/angular-client/src/pages/charging-page/components/faulted-status/faulted-status.component.ts +++ b/angular-client/src/pages/charging-page/components/faulted-status/faulted-status.component.ts @@ -1,7 +1,7 @@ import { Component, Input, OnInit, inject } from '@angular/core'; import Storage from 'src/services/storage.service'; import Theme from 'src/services/theme.service'; -import { DataTypeEnum } from 'src/data-type.enum'; +import { topics } from 'src/utils/topic.utils'; import { InfoBackgroundComponent } from '../../../../components/info-background/info-background.component'; import CurrentTotalTimerComponent from 'src/components/current-total-timer/current-total-timer.component'; import HStackComponent from 'src/components/hstack/hstack.component'; @@ -22,7 +22,7 @@ export default class FaultedStatusComponent implements OnInit { intervalId!: NodeJS.Timeout; ngOnInit() { - this.storage.getTimerData(DataTypeEnum.BMS_MODE).subscribe((value) => { + this.storage.getTimerData(topics.bmsMode()).subscribe((value) => { const statusStateValue = value.last_value; if (this.isFaulted) { if (!(statusStateValue === 3)) { diff --git a/angular-client/src/pages/charging-page/components/pack-temp/pack-temp.component.ts b/angular-client/src/pages/charging-page/components/pack-temp/pack-temp.component.ts index 1baf7b9d..e687c34b 100644 --- a/angular-client/src/pages/charging-page/components/pack-temp/pack-temp.component.ts +++ b/angular-client/src/pages/charging-page/components/pack-temp/pack-temp.component.ts @@ -1,6 +1,6 @@ import { Component, OnInit, inject } from '@angular/core'; import Storage from 'src/services/storage.service'; -import { DataTypeEnum } from 'src/data-type.enum'; +import { topics } from 'src/utils/topic.utils'; import { floatPipe } from 'src/utils/pipes.utils'; import { InfoBackgroundComponent } from '../../../../components/info-background/info-background.component'; import TypographyComponent from 'src/components/typography/typography.component'; @@ -19,7 +19,7 @@ export default class PackTempComponent implements OnInit { packTemp: number = 0; ngOnInit() { - this.storage.get(DataTypeEnum.PACK_TEMP).subscribe((value) => { + this.storage.get(topics.packTemp()).subscribe((value) => { this.packTemp = floatPipe(value.values[0]); }); } diff --git a/angular-client/src/pages/charging-page/components/pack-voltage/pack-voltage-display/pack-voltage-display.component.ts b/angular-client/src/pages/charging-page/components/pack-voltage/pack-voltage-display/pack-voltage-display.component.ts index 54213280..562fe8e1 100644 --- a/angular-client/src/pages/charging-page/components/pack-voltage/pack-voltage-display/pack-voltage-display.component.ts +++ b/angular-client/src/pages/charging-page/components/pack-voltage/pack-voltage-display/pack-voltage-display.component.ts @@ -1,6 +1,6 @@ import { Component, HostListener, OnInit, inject } from '@angular/core'; import Storage from 'src/services/storage.service'; -import { DataTypeEnum } from 'src/data-type.enum'; +import { topics } from 'src/utils/topic.utils'; import { floatPipe } from 'src/utils/pipes.utils'; import { GraphData } from 'src/utils/types.utils'; import { InfoBackgroundComponent } from '../../../../../components/info-background/info-background.component'; @@ -41,7 +41,7 @@ export default class PackVoltageDisplayComponent implements OnInit { } ngOnInit() { - this.storage.get(DataTypeEnum.PACK_VOLTAGE).subscribe((value) => { + this.storage.get(topics.packVoltage()).subscribe((value) => { this.voltage = floatPipe(value.values[0]); this.packVoltData.push({ x: +value.time, y: this.voltage }); }); diff --git a/angular-client/src/pages/charging-page/components/starting-soc/starting-soc-timer.component.ts b/angular-client/src/pages/charging-page/components/starting-soc/starting-soc-timer.component.ts index c41371ea..89cdb168 100644 --- a/angular-client/src/pages/charging-page/components/starting-soc/starting-soc-timer.component.ts +++ b/angular-client/src/pages/charging-page/components/starting-soc/starting-soc-timer.component.ts @@ -1,7 +1,7 @@ import { Component, inject } from '@angular/core'; import { take } from 'rxjs'; import Storage from 'src/services/storage.service'; -import { DataTypeEnum } from 'src/data-type.enum'; +import { topics } from 'src/utils/topic.utils'; import { floatPipe } from 'src/utils/pipes.utils'; import { InfoBackgroundComponent } from '../../../../components/info-background/info-background.component'; import TypographyComponent from 'src/components/typography/typography.component'; @@ -18,7 +18,7 @@ export default class StartingSocTimerComponent { startingSoc: number = 0; constructor() { this.storage - .get(DataTypeEnum.STATE_OF_CHARGE) + .get(topics.stateOfCharge()) .pipe(take(1)) .subscribe((value) => { this.startingSoc = floatPipe(value.values[0]); diff --git a/angular-client/src/pages/charging-page/components/state-of-charge/state-of-charge-display/state-of-charge-display.component.ts b/angular-client/src/pages/charging-page/components/state-of-charge/state-of-charge-display/state-of-charge-display.component.ts index d4c87b3a..bc9d66e3 100644 --- a/angular-client/src/pages/charging-page/components/state-of-charge/state-of-charge-display/state-of-charge-display.component.ts +++ b/angular-client/src/pages/charging-page/components/state-of-charge/state-of-charge-display/state-of-charge-display.component.ts @@ -1,9 +1,8 @@ import { Component, OnInit, inject } from '@angular/core'; import Storage from 'src/services/storage.service'; -import { DataTypeEnum } from 'src/data-type.enum'; +import { topics } from 'src/utils/topic.utils'; import { floatPipe } from 'src/utils/pipes.utils'; import { InfoBackgroundComponent } from '../../../../../components/info-background/info-background.component'; - import { BatteryPercentageComponent } from '../../../../../components/battery-percentage/battery-percentage.component'; import TypographyComponent from 'src/components/typography/typography.component'; import HStackComponent from 'src/components/hstack/hstack.component'; @@ -20,7 +19,7 @@ export default class StateOfChargeDisplayComponent implements OnInit { stateOfCharge: number = 0; ngOnInit() { - this.storage.get(DataTypeEnum.STATE_OF_CHARGE).subscribe((value) => { + this.storage.get(topics.stateOfCharge()).subscribe((value) => { this.stateOfCharge = floatPipe(value.values[0]); }); } diff --git a/angular-client/src/pages/landing-page/components/viewer-display/viewer-display.component.ts b/angular-client/src/pages/landing-page/components/viewer-display/viewer-display.component.ts index c9bd1ceb..30c6d7a6 100644 --- a/angular-client/src/pages/landing-page/components/viewer-display/viewer-display.component.ts +++ b/angular-client/src/pages/landing-page/components/viewer-display/viewer-display.component.ts @@ -1,6 +1,6 @@ import { Component, OnInit, inject } from '@angular/core'; import Storage from 'src/services/storage.service'; -import { DataTypeEnum } from 'src/data-type.enum'; +import { topics } from 'src/utils/topic.utils'; import { InfoBackgroundComponent } from '../../../../components/info-background/info-background.component'; import TypographyComponent from 'src/components/typography/typography.component'; @@ -16,7 +16,7 @@ export class ViewerDisplayComponent implements OnInit { numViewers: number = 0; ngOnInit() { - this.storage.get(DataTypeEnum.VIEWERS).subscribe((value) => { + this.storage.get(topics.viewers()).subscribe((value) => { this.numViewers = parseInt(value.values[0]); }); } diff --git a/angular-client/src/pages/map/map.component.ts b/angular-client/src/pages/map/map.component.ts index c0041fab..635d16b0 100644 --- a/angular-client/src/pages/map/map.component.ts +++ b/angular-client/src/pages/map/map.component.ts @@ -3,7 +3,7 @@ import { MapService } from '../../services/map.service'; import { DataValue } from 'src/utils/socket.utils'; import APIService from 'src/services/api.service'; import { getDataByDataTypeNameAndRunId } from 'src/api/data.api'; -import { DataTypeEnum } from 'src/data-type.enum'; +import { topics } from 'src/utils/topic.utils'; import Storage from 'src/services/storage.service'; import { Run } from 'src/utils/types.utils'; @@ -42,21 +42,19 @@ export default class MapComponent implements OnInit { onRunSelected = (run: Run) => { if (run.id === this.storage.getCurrentRunId().value) { this.isLoading = false; - //Allow page to render before building map setTimeout(() => { this.map.buildMap('map'); this.map.addPolyline([]); - this.storage.get(DataTypeEnum.POINTS).subscribe((value) => { + this.storage.get(topics.gpsLocation()).subscribe((value) => { this.map.addCoordinateToPolyline(this.map.transformDataToCoordinate(value)); }); }, 100); } else { const queryResponse = this.apiService.query(() => - getDataByDataTypeNameAndRunId(DataTypeEnum.POINTS, run.id) + getDataByDataTypeNameAndRunId(topics.gpsLocation(), run.id) ); queryResponse.data.subscribe((points) => { if (points) { - //Allow page to render before building map setTimeout(() => { this.map.buildMap('map'); this.map.addPolyline(points.map(this.map.transformDataToCoordinate)); diff --git a/angular-client/src/services/socket.service.ts b/angular-client/src/services/socket.service.ts index f5694b13..9f6dd985 100644 --- a/angular-client/src/services/socket.service.ts +++ b/angular-client/src/services/socket.service.ts @@ -1,7 +1,7 @@ import { Socket } from 'socket.io-client'; import { DataValue, ServerData, TimerData } from 'src/utils/socket.utils'; import Storage from './storage.service'; -import { DataTypeEnum } from 'src/data-type.enum'; +import { topics } from 'src/utils/topic.utils'; import { FaultData } from 'src/utils/types.utils'; import { FaultService } from './fault.service'; @@ -26,18 +26,15 @@ export default class SocketService { receiveData = (storage: Storage, faultService: FaultService) => { this.socket.on('data', (message: string) => { try { - /* Parse the message and store it in the storage service */ - const data = JSON.parse(message) as ServerData; storage.setCurrentRunId(data.runId); - /* Create key based on name and unit for hashmap */ const key = data.name; const newValue: DataValue = { values: data.values, time: data.timestamp.toString(), unit: data.unit }; storage.addValue(key, newValue); if (Date.now() - this.lastLatencyTimestamp > 1000) { const latency = Date.now() - data.timestamp; - storage.addValue(DataTypeEnum.LATENCY, { + storage.addValue(topics.latency(), { values: [latency.toString()], time: data.timestamp.toString(), unit: 'ms' diff --git a/angular-client/src/utils/topic.utils.ts b/angular-client/src/utils/topic.utils.ts index 74e18dc1..5efa0bd3 100644 --- a/angular-client/src/utils/topic.utils.ts +++ b/angular-client/src/utils/topic.utils.ts @@ -38,6 +38,81 @@ export const lowTempChip = () => `BMS/Cells/Temp_Low_Chip`; export const lowTempCell = () => `BMS/Cells/Temp_Low_Cell`; export const tempAvgValue = () => `BMS/Cells/Temp_Avg_Value`; +// General +export const driver = () => `Driver`; +export const location = () => `Location`; +export const viewers = () => `Viewers`; +export const latency = () => `Old_Latency`; +export const newLatency = () => `Latency`; + +// MPU +export const speed = () => `MPU/State/Speed`; +export const motorController = () => `MPU/Current/Motor_Controller`; +export const battboxFans = () => `MPU/Current/Battbox_Fans`; +export const pumps = () => `MPU/Current/Pumps`; +export const lvBoards = () => `MPU/Current/LV_Boards`; + +// DTI +export const motorTemp = () => `DTI/Temps/Motor_Temperature`; + +// TPU +export const cpuUsage = () => `TPU/OnBoard/CpuUsage`; +export const cpuTemp = () => `TPU/OnBoard/CpuTemp`; +export const ramUsage = () => `TPU/OnBoard/MemAvailable`; +export const wifiRSSI = () => `TPU/HaLow/RSSI`; +export const mcs = () => `TPU/HaLow/ApMCS`; +export const gpsLocation = () => `TPU/GPS/Location`; + +// BMS Status / Pack +export const packTemp = () => `BMS/Status/Temp_Average`; +export const stateOfCharge = () => `BMS/Pack/SOC`; +export const current = () => `BMS/Charging/Current`; +export const chargeCurrentLimit = () => `BMS/Pack/CCL`; +export const dischargeCurrentLimit = () => `BMS/Pack/DCL`; +export const statusBalancing = () => `BMS/Status/Balancing`; +export const bmsMode = () => `BMS/Status/State`; +export const charging = () => `BMS/Charging/Control`; +export const packVoltage = () => `BMS/Pack/Voltage`; +export const cellUndervoltage = () => `BMS/Status/F/Cell_Undervoltage`; +export const cellOvervoltage = () => `BMS/Status/F/Cell_Overvoltage`; +export const cellsNotBalancing = () => `BMS/Status/F/Cells_Not_Balancing`; + +// Charger Faults +export const commTimeoutFault = () => `Charger/Box/F_CommTimeout`; +export const hardwareFailureFault = () => `Charger/Box/F_HardwareFailure`; +export const overTempFault = () => `Charger/Box/F_OverTemp`; +export const overVoltageFault = () => `Charger/Box/F_OverVoltage`; +export const wrongBatConnectFault = () => `Charger/Box/F_WrongBatConnect`; + +// BMS Faults +export const openWire = () => `BMS/Status/F/Open_Wire`; +export const chargerLimitEnforcementFault = () => `BMS/Status/F/CCL_Enforce`; +export const chargerCanFault = () => `BMS/Status/F/Charger_Can`; +export const batteryThermistor = () => `BMS/Status/F/Battery_Therm`; +export const chargerSafetyRelay = () => `BMS/Status/F/Charger_Safety`; +export const dischargeLimitEnforcementFault = () => `BMS/Status/F/DCL_Enforce`; +export const externalCanFault = () => `BMS/Status/F/External_Can`; +export const weakPackFault = () => `BMS/Status/F/Weak_Pack`; +export const lowCellVoltage = () => `BMS/Status/F/Low_Cell_Volts`; +export const chargeReadingMismatch = () => `BMS/Status/F/Charge_Reading`; +export const currentSensorFault = () => `BMS/Status/F/Current_Sense`; +export const internalCellCommFault = () => `BMS/Status/F/IC_Comm`; +export const internalThermalError = () => `BMS/Status/F/Thermal_Err`; +export const internalSoftwareFault = () => `BMS/Status/F/Software`; +export const packOverheat = () => `BMS/Status/F/Pack_Overheat`; + +// Fake / Mock Data +export const motorUsage = () => `Motor Usage`; +export const coolingUsage = () => `Cooling Usage`; +export const steeringAngle = () => `Steering Angle`; +export const torque = () => `Torque`; +export const brakePressure = () => `Brake Pressure`; +export const acceleration = () => `Acceleration`; +export const xyzAcceleration = () => `XYZAcceleration`; + +// BMS Debug / Per Cell +export const perCellOverflowId = () => `BMS/PerCell/OverflowID`; + export const topics = { alphaTemp, betaTemp, @@ -72,7 +147,64 @@ export const topics = { tempAvgValue, accCCL, accDCL, - msgsPerSecond + msgsPerSecond, + driver, + location, + viewers, + latency, + newLatency, + speed, + motorController, + battboxFans, + pumps, + lvBoards, + motorTemp, + cpuUsage, + cpuTemp, + ramUsage, + wifiRSSI, + mcs, + gpsLocation, + packTemp, + stateOfCharge, + current, + chargeCurrentLimit, + dischargeCurrentLimit, + statusBalancing, + bmsMode, + charging, + packVoltage, + cellUndervoltage, + cellOvervoltage, + cellsNotBalancing, + commTimeoutFault, + hardwareFailureFault, + overTempFault, + overVoltageFault, + wrongBatConnectFault, + openWire, + chargerLimitEnforcementFault, + chargerCanFault, + batteryThermistor, + chargerSafetyRelay, + dischargeLimitEnforcementFault, + externalCanFault, + weakPackFault, + lowCellVoltage, + chargeReadingMismatch, + currentSensorFault, + internalCellCommFault, + internalThermalError, + internalSoftwareFault, + packOverheat, + perCellOverflowId, + motorUsage, + coolingUsage, + steeringAngle, + torque, + brakePressure, + acceleration, + xyzAcceleration }; /* Dynamically generated cell-index arrays derived from BMS_CONFIG */