Skip to content

Commit

Permalink
Merge pull request #261 from Northeastern-Electric-Racing/#260-update…
Browse files Browse the repository at this point in the history
…-client-for-new-scylla

#260 update client for new scylla
  • Loading branch information
RChandler234 authored Dec 22, 2024
2 parents 2517000 + acfcf5f commit 2b4a982
Show file tree
Hide file tree
Showing 48 changed files with 253 additions and 212 deletions.
4 changes: 2 additions & 2 deletions angular-client/src/api/node.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ import { urls } from './urls';
* Fetches all nodes from the server
* @returns A promise containing the response from the server
*/
export const getAllNodes = (): Promise<Response> => {
return fetch(urls.getAllNodes());
export const getAllDatatypes = (): Promise<Response> => {
return fetch(urls.getAllDatatypes());
};
6 changes: 3 additions & 3 deletions angular-client/src/api/urls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { environment } from 'src/environment/environment';
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const baseURL = (environment as any).url || 'http://localhost:8000';

/* Nodes */
const getAllNodes = () => `${baseURL}/nodes`;
/* Datatypes */
const getAllDatatypes = () => `${baseURL}/datatypes`;

/* Systems */
const getAllSystems = () => `${baseURL}/systems`;
Expand All @@ -18,7 +18,7 @@ const getAllRuns = () => `${baseURL}/runs`;
const startNewRun = () => `${baseURL}/runs/new`;

export const urls = {
getAllNodes,
getAllDatatypes,

getAllSystems,

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, OnInit, inject } from '@angular/core';
import Storage from 'src/services/storage.service';
import { IdentifierDataType } from 'src/utils/enumerations/identifier-data-type';
import { DataTypeEnum } from 'src/data-type.enum';
import { decimalPipe } from 'src/utils/pipes.utils';
import { GraphData } from 'src/utils/types.utils';

Expand All @@ -26,7 +26,7 @@ export class AccelerationGraphsComponent implements OnInit {
maxDataPoints = 400;

ngOnInit() {
this.storage.get(IdentifierDataType.XYZAccel).subscribe((value) => {
this.storage.get(DataTypeEnum.XYZAccel).subscribe((value) => {
const x1 = decimalPipe(value.values[0]);
const y1 = decimalPipe(value.values[1]);
const time = +value.time;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, OnInit, inject } from '@angular/core';
import Storage from 'src/services/storage.service';
import { IdentifierDataType } from 'src/utils/enumerations/identifier-data-type';
import { DataTypeEnum } from 'src/data-type.enum';
import { GraphData } from 'src/utils/types.utils';

@Component({
Expand All @@ -13,7 +13,7 @@ export default class AccelerationOverTimeDisplayComponent implements OnInit {
data: GraphData[] = [];

ngOnInit() {
this.storage.get(IdentifierDataType.ACCELERATION).subscribe((value) => {
this.storage.get(DataTypeEnum.ACCELERATION).subscribe((value) => {
this.data.push({ x: new Date().getTime(), y: parseInt(value.values[0]) });
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, OnInit, inject } from '@angular/core';
import Storage from 'src/services/storage.service';
import { IdentifierDataType } from 'src/utils/enumerations/identifier-data-type';
import { DataTypeEnum } from 'src/data-type.enum';

@Component({
selector: 'brake-pressure-display',
Expand All @@ -12,7 +12,7 @@ export default class BrakePressureDisplayComponent implements OnInit {
brakePressure: number = 0;

ngOnInit() {
this.storage.get(IdentifierDataType.BRAKE_PRESSURE).subscribe((value) => {
this.storage.get(DataTypeEnum.BRAKE_PRESSURE).subscribe((value) => {
this.brakePressure = parseInt(value.values[0]);
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, OnInit, inject } from '@angular/core';
import Storage from 'src/services/storage.service';
import { IdentifierDataType } from 'src/utils/enumerations/identifier-data-type';
import { DataTypeEnum } from 'src/data-type.enum';

@Component({
selector: 'driver-component',
Expand All @@ -12,7 +12,7 @@ export class DriverComponent implements OnInit {
driver: string = 'No Driver';

ngOnInit() {
this.storage.get(IdentifierDataType.DRIVER).subscribe((value) => {
this.storage.get(DataTypeEnum.DRIVER).subscribe((value) => {
[this.driver] = value.values || ['No Driver'];
});
console.log(this.driver);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, Input, OnInit, inject } from '@angular/core';
import Storage from 'src/services/storage.service';
import { IdentifierDataType } from 'src/utils/enumerations/identifier-data-type';
import { DataTypeEnum } from 'src/data-type.enum';

@Component({
selector: 'latency-display',
Expand All @@ -16,10 +16,10 @@ export default class LatencyDisplayComponent implements OnInit {
newLatency: number = 0;

ngOnInit(): void {
this.storage.get(IdentifierDataType.LATENCY).subscribe((value) => {
this.storage.get(DataTypeEnum.LATENCY).subscribe((value) => {
this.latency = parseInt(value.values[0]);
});
this.storage.get(IdentifierDataType.NEW_LATENCY).subscribe((value) => {
this.storage.get(DataTypeEnum.NEW_LATENCY).subscribe((value) => {
this.newLatency = parseInt(value.values[0]);
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, OnInit, inject } from '@angular/core';
import Storage from 'src/services/storage.service';
import { IdentifierDataType } from 'src/utils/enumerations/identifier-data-type';
import { DataTypeEnum } from 'src/data-type.enum';
import { floatPipe } from 'src/utils/pipes.utils';

// need access motor temp, motor consumption, and motor cooling
Expand All @@ -19,13 +19,13 @@ export default class MotorInfoComponent implements OnInit {
piechartData: { value: number; name: string }[] = [];

ngOnInit() {
this.storage.get(IdentifierDataType.MOTOR_TEMP).subscribe((value) => {
this.storage.get(DataTypeEnum.MOTOR_TEMP).subscribe((value) => {
this.motorTemp = floatPipe(value.values[0]);
});
this.storage.get(IdentifierDataType.MOTOR_USAGE).subscribe((value) => {
this.storage.get(DataTypeEnum.MOTOR_USAGE).subscribe((value) => {
this.motorUsage = floatPipe(value.values[0]);
});
this.storage.get(IdentifierDataType.COOL_USAGE).subscribe((value) => {
this.storage.get(DataTypeEnum.COOL_USAGE).subscribe((value) => {
this.coolUsage = floatPipe(value.values[0]);
});
this.piechartData = [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, HostListener, OnInit, inject } from '@angular/core';
import Storage from 'src/services/storage.service';
import { IdentifierDataType } from 'src/utils/enumerations/identifier-data-type';
import { DataTypeEnum } from 'src/data-type.enum';
import { floatPipe } from 'src/utils/pipes.utils';

@Component({
Expand All @@ -20,19 +20,19 @@ export default class RasberryPiComponent implements OnInit {
isMobile = window.innerWidth < this.mobileThreshold;

ngOnInit() {
this.storage.get(IdentifierDataType.CPUUsage).subscribe((value) => {
this.storage.get(DataTypeEnum.CPUUsage).subscribe((value) => {
this.cpuUsage = floatPipe(value.values[0]);
});
this.storage.get(IdentifierDataType.CPUTemp).subscribe((value) => {
this.storage.get(DataTypeEnum.CPUTemp).subscribe((value) => {
this.cpuTemp = floatPipe(value.values[0]);
});
this.storage.get(IdentifierDataType.RAMUsage).subscribe((value) => {
this.storage.get(DataTypeEnum.RAMUsage).subscribe((value) => {
this.ramUsage = Math.round((1 - floatPipe(value.values[0]) / 8000) * 100);
});
this.storage.get(IdentifierDataType.WIFIRSSI).subscribe((value) => {
this.storage.get(DataTypeEnum.WIFIRSSI).subscribe((value) => {
this.wifiRSSI = floatPipe(value.values[0]);
});
this.storage.get(IdentifierDataType.MCS).subscribe((value) => {
this.storage.get(DataTypeEnum.MCS).subscribe((value) => {
this.mcs = floatPipe(value.values[0]);
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, OnInit, inject } from '@angular/core';
import Storage from 'src/services/storage.service';
import { IdentifierDataType } from 'src/utils/enumerations/identifier-data-type';
import { DataTypeEnum } from 'src/data-type.enum';

@Component({
selector: 'speed-display',
Expand All @@ -12,7 +12,7 @@ export default class SpeedDisplayComponent implements OnInit {
speed: number = 0;

ngOnInit() {
this.storage.get(IdentifierDataType.SPEED).subscribe((value) => {
this.storage.get(DataTypeEnum.SPEED).subscribe((value) => {
this.speed = parseInt(value.values[0]);
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, OnInit, inject } from '@angular/core';
import Storage from 'src/services/storage.service';
import { IdentifierDataType } from 'src/utils/enumerations/identifier-data-type';
import { DataTypeEnum } from 'src/data-type.enum';
import { GraphData } from 'src/utils/types.utils';

@Component({
Expand All @@ -13,7 +13,7 @@ export default class SpeedOverTimeDisplayComponent implements OnInit {
data: GraphData[] = [];

ngOnInit() {
this.storage.get(IdentifierDataType.SPEED).subscribe((value) => {
this.storage.get(DataTypeEnum.SPEED).subscribe((value) => {
this.data.push({ x: new Date().getTime(), y: parseInt(value.values[0]) });
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, OnInit, inject } from '@angular/core';
import Storage from 'src/services/storage.service';
import { IdentifierDataType } from 'src/utils/enumerations/identifier-data-type';
import { DataTypeEnum } from 'src/data-type.enum';
import { floatPipe } from 'src/utils/pipes.utils';

/**
Expand All @@ -18,7 +18,7 @@ export class SteeringAngleDisplayComponent implements OnInit {
steeringAngle: number = 0;

ngOnInit() {
this.storage.get(IdentifierDataType.STEERING_ANGLE).subscribe((value) => {
this.storage.get(DataTypeEnum.STEERING_ANGLE).subscribe((value) => {
this.steeringAngle = floatPipe(value.values[0]);
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, OnInit, inject } from '@angular/core';
import Storage from 'src/services/storage.service';
import { IdentifierDataType } from 'src/utils/enumerations/identifier-data-type';
import { DataTypeEnum } from 'src/data-type.enum';

@Component({
selector: 'torque-display',
Expand All @@ -12,7 +12,7 @@ export default class TorqueDisplayComponent implements OnInit {
torque: number = 0;

ngOnInit() {
this.storage.get(IdentifierDataType.TORQUE).subscribe((value) => {
this.storage.get(DataTypeEnum.TORQUE).subscribe((value) => {
this.torque = parseInt(value.values[0]);
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, Input, OnInit } from '@angular/core';
import Theme from 'src/services/theme.service';
import { StyleVariant } from 'src/utils/enumerations/style-variant';
import { StyleVariant } from 'src/utils/style-variant';

/**
* Custom typography component that allows for the use of different styles of text.
Expand Down
74 changes: 74 additions & 0 deletions angular-client/src/data-type.enum.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
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',

// 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',
VOLTS_HIGH = 'BMS/Cells/Volts_High_Value',
VOLTS_LOW = 'BMS/Cells/Volts_Low_Value',
CHARGING = 'BMS/Charging/Control',
PACK_VOLTAGE = 'BMS/Pack/Voltage',
CELL_TEMP_HIGH = 'BMS/Cells/Temp_High_Value',
CELL_TEMP_AVG = 'BMS/Cells/Temp_Avg_Value',

// 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',
CELL_UNDERVOLTAGE = 'BMS/Status/F/Cell_Undervoltage',
CELL_OVERVOLTAGE = 'BMS/Status/F/Cell_Overvoltage',
CELLS_NOT_BALANCING = 'BMS/Status/F/Cells_Not_Balancing'
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, HostListener, Input, OnInit, inject } from '@angular/core';
import Storage from 'src/services/storage.service';
import { IdentifierDataType } from 'src/utils/enumerations/identifier-data-type';
import { DataTypeEnum } from 'src/data-type.enum';

@Component({
selector: 'charging-page-mobile',
Expand All @@ -19,7 +19,7 @@ export default class ChargingPageMobileComponent implements OnInit {
this.time = new Date();
}, 1000);

this.storage.get(IdentifierDataType.LOCATION).subscribe((value) => {
this.storage.get(DataTypeEnum.LOCATION).subscribe((value) => {
[this.location] = value.values || ['No Location Set'];
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, HostListener, OnInit, inject } from '@angular/core';
import Storage from 'src/services/storage.service';
import { IdentifierDataType } from 'src/utils/enumerations/identifier-data-type';
import { DataTypeEnum } from 'src/data-type.enum';

/**
* Container for the Charging page, obtains data from the storage service.
Expand All @@ -22,7 +22,7 @@ export default class ChargingPageComponent implements OnInit {
this.time = new Date();
}, 1000);

this.storage.get(IdentifierDataType.LOCATION).subscribe((value) => {
this.storage.get(DataTypeEnum.LOCATION).subscribe((value) => {
[this.location] = value.values || ['No Location Set'];
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, OnInit, inject } from '@angular/core';
import Storage from 'src/services/storage.service';
import { IdentifierDataType } from 'src/utils/enumerations/identifier-data-type';
import { DataTypeEnum } from 'src/data-type.enum';
import { floatPipe } from 'src/utils/pipes.utils';

enum BMSMODE {
Expand Down Expand Up @@ -28,7 +28,7 @@ export default class BMSModeDisplayComponent implements OnInit {
};

ngOnInit() {
this.storage.get(IdentifierDataType.BMS_MODE).subscribe((value) => {
this.storage.get(DataTypeEnum.BMS_MODE).subscribe((value) => {
this.bmsMode = floatPipe(value.values[0]) as BMSMODE;
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component, OnInit, inject } from '@angular/core';
import Storage from 'src/services/storage.service';
import Theme from 'src/services/theme.service';
import { IdentifierDataType } from 'src/utils/enumerations/identifier-data-type';
import { DataTypeEnum } from 'src/data-type.enum';
import { floatPipe } from 'src/utils/pipes.utils';

@Component({
Expand All @@ -17,7 +17,7 @@ export default class ActiveStatusComponent implements OnInit {
intervalId!: NodeJS.Timeout;

ngOnInit() {
this.storage.get(IdentifierDataType.BMS_MODE).subscribe((value) => {
this.storage.get(DataTypeEnum.BMS_MODE).subscribe((value) => {
const statusStateValue = floatPipe(value.values[0]);
if (this.isActive) {
if (!(statusStateValue === 2)) {
Expand Down
Loading

0 comments on commit 2b4a982

Please sign in to comment.