Skip to content

Commit

Permalink
#156 - basic data set up for fault abstraction
Browse files Browse the repository at this point in the history
  • Loading branch information
bracyw committed Oct 8, 2024
1 parent 54febe4 commit b3c0f6c
Show file tree
Hide file tree
Showing 10 changed files with 191 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { Fault } from '../indiv-fault/fault.model';
import { FaultType, FaultTypeModel } from './fault-type.model';

export class BMSFaultType implements FaultTypeModel {
subscribeToFaults(): Fault<FaultTypeModel> {
subscribeToFaults(): Fault<BMSFaultType> {
// TODO
throw new Error('Method not implemented.');
}
name = FaultType.BMS;
recordedFaults: Fault<FaultTypeModel>[] = [];
recordedFaults: Fault<BMSFaultType>[] = [];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Fault } from '../indiv-fault/fault.model';
import { FaultType, FaultTypeModel } from './fault-type.model';

export class ChargerFaultType implements FaultTypeModel {
subscribeToFaults(): Fault<ChargerFaultType> {
// TODO
throw new Error('Method not implemented.');
}
name = FaultType.Charger;
recordedFaults: Fault<ChargerFaultType>[] = [];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Fault } from '../indiv-fault/fault.model';
import { FaultType, FaultTypeModel } from './fault-type.model';

export class DTIFaultType implements FaultTypeModel {
subscribeToFaults(): Fault<DTIFaultType> {
// TODO
throw new Error('Method not implemented.');
}
name = FaultType.DTI;
recordedFaults: Fault<DTIFaultType>[] = [];
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,7 @@ export interface FaultTypeModel {

export enum FaultType {
BMS = 'BMS',
Charger = 'Charger'
Charger = 'Charger',
DTI = 'DTI',
MPU = 'MPU'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Fault } from '../indiv-fault/fault.model';
import { FaultType, FaultTypeModel } from './fault-type.model';

export class MPUFaultType implements FaultTypeModel {
subscribeToFaults(): Fault<MPUFaultType> {
// TODO
throw new Error('Method not implemented.');
}
name = FaultType.MPU;
recordedFaults: Fault<MPUFaultType>[] = [];
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,44 @@
import { Node } from 'src/utils/types.utils';
import { BMSFaultType } from '../fault-type/bms-fault-type.model';
import { Fault } from './fault.model';

export enum BMS_FAULTS_VALUES {
CELLS_NOT_BALANCING = 1,
CELL_VOLTAGE_TOO_LOW = 2,
CELL_VOLTAGE_TOO_HIGH = 4,
PACK_TOO_HOT = 8,
OPEN_WIRING_FAULT = 16,
INTERNAL_SOFTWARE_FAULT = 32,
INTERNAL_THERMAL_ERROR = 64,
INTERNAL_CELL_COMM_FAULT = 128,
CURRENT_SENSOR_FAULT = 256,
CHARGE_READING_MISMATCH = 512,
LOW_CELL_VOLTAGE = 1024,
WEAK_PACK_FAULT = 2048,
EXTERNAL_CAN_FAULT = 4096,
DISCHARGE_LIMIT_ENFORCEMENT_FAULT = 8192,
CHARGER_SAFETY_RELAY = 16384,
BATTERY_THERMISTOR = 32768,
CHARGER_CAN_FAULT = 65536,
CHARGER_LIMIT_ENFORCEMENT_FAULT = 131072
}

export class BMSFault implements Fault<BMSFaultType> {
name: String;
name: BMS_FAULTS_VALUES;
timeTriggered: number;
format(): { type: String; name: String; timeTriggered: number } {
throw new Error('Method not implemented.');
}
constructor() {
this.name = 'hello';
this.timeTriggered = 101011;
/**
* Constructs a new BMS fault base on a valid faultValue
* @param faultValue
* @param timeTriggered
*/
constructor(faultValue: BMS_FAULTS_VALUES, timeTriggered: number) {
this.name = faultValue;
this.timeTriggered = timeTriggered;
}
getRelevantNodes(timeFrame: number): Node[] {
throw new Error('Method not implemented.');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { Node } from 'src/utils/types.utils';
import { ChargerFaultType } from '../fault-type/charger-fault-type.model';
import { Fault } from './fault.model';

export enum CHARGER_FAULT_VALUES {
COMM_TIMEOUT_FAULT = 'Comm Timeout',
HARDWARE_FAILURE_FAULT = 'Hardware Failure',
OVER_TEMP_FAULT = 'Over Temp',
VOLTAGE_WRONG_FAULT = 'Voltage Wrong',
WRONG_BAT_CONNECT_FAULT = 'Wrong Battery Connect'
}

export class ChargerFault implements Fault<ChargerFaultType> {
name: CHARGER_FAULT_VALUES;
timeTriggered: number;
format(): { type: String; name: CHARGER_FAULT_VALUES; timeTriggered: number } {
throw new Error('Method not implemented.');
}
/**
* Constructs a new Charger fault base on a valid faultValue
* @param faultValue
* @param timeTriggered
*/
constructor(faultValue: CHARGER_FAULT_VALUES, timeTriggered: number) {
this.name = faultValue;
this.timeTriggered = timeTriggered;
}
getRelevantNodes(timeFrame: number): Node[] {
throw new Error('Method not implemented.');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { Node } from 'src/utils/types.utils';
import { DTIFaultType } from '../fault-type/dti-fault-type.model';
import { Fault } from './fault.model';

export enum DTI_FAULTS_VALUES {
OVER_VOLTAGE = 1,
UNDER_VOLTAGE = 2,
DRV = 3,
ABS_OVER_CURRENT = 4,
CTLR_OVER_TEMP = 5,
MOTOR_OVER_TEMP = 6,
SENSOR_WIRE_FAULT = 7,
SENSOR_GENERAL_FAULT = 8,
CAN_COMMAND_ERROR = 9,
ANALOG_INPUT_ERROR = 10
}

export class DTIFault implements Fault<DTIFaultType> {
name: DTI_FAULTS_VALUES;
timeTriggered: number;
format(): { type: String; name: String; timeTriggered: number } {
throw new Error('Method not implemented.');
}
/**
* Constructs a new DTI fault base on a valid
* @param faultValue
* @param timeTriggered
*/
constructor(faultValue: DTI_FAULTS_VALUES, timeTriggered: number) {
this.name = faultValue;
this.timeTriggered = timeTriggered;
}
getRelevantNodes(timeFrame: number): Node[] {
throw new Error('Method not implemented.');
}
}
Original file line number Diff line number Diff line change
@@ -1,38 +1,15 @@
import { Node } from 'src/utils/types.utils';
import { FaultTypeModel } from '../fault-type/fault-type.model';
import { BMS_FAULTS_VALUES } from './bms-fault.model';
import { CHARGER_FAULT_VALUES } from './charger-fault.model';
import { DTI_FAULTS_VALUES } from './dti-fault.model';
import { MPU_FAULTS_VALUES } from './mpu-fault.model';

export interface Fault<T extends FaultTypeModel> {

Check warning on line 8 in angular-client/src/pages/fault-page/shared/indiv-fault/fault.model.ts

View workflow job for this annotation

GitHub Actions / run-linting-check

'T' is defined but never used
name: String;
name: AllFaultEnums;
timeTriggered: number;
format(): { type: String; name: String; timeTriggered: number };
getRelevantNodes(timeFrame: number): Node[];
}

export type AllFaultEnums = BMS_FAULTS_VALUES;

enum BMS_FAULTS_VALUES {
CELLS_NOT_BALANCING = 1,
CELL_VOLTAGE_TOO_LOW = 2,
CELL_VOLTAGE_TOO_HIGH = 4,
PACK_TOO_HOT = 8,
OPEN_WIRING_FAULT = 16,
INTERNAL_SOFTWARE_FAULT = 32,
INTERNAL_THERMAL_ERROR = 64,
INTERNAL_CELL_COMM_FAULT = 128,
CURRENT_SENSOR_FAULT = 256,
CHARGE_READING_MISMATCH = 512,
LOW_CELL_VOLTAGE = 1024,
WEAK_PACK_FAULT = 2048,
EXTERNAL_CAN_FAULT = 4096,
DISCHARGE_LIMIT_ENFORCEMENT_FAULT = 8192,
CHARGER_SAFETY_RELAY = 16384,
BATTERY_THERMISTOR = 32768,
CHARGER_CAN_FAULT = 65536,
CHARGER_LIMIT_ENFORCEMENT_FAULT = 131072
}

enum CHARGER_FAULT_VALUES {
COMM_TIMEOUT_FAULT = 'Comm Timeout',
HARDWARE_FAILURE_FAULT = 'Hardware Failure',
OVER_TEMP_FAULT = 'Over Temp',
VOLTAGE_WRONG_FAULT = 'Voltage Wrong',
WRONG_BAT_CONNECT_FAULT = 'Wrong Battery Connect'
}
export type AllFaultEnums = BMS_FAULTS_VALUES | CHARGER_FAULT_VALUES | DTI_FAULTS_VALUES | MPU_FAULTS_VALUES;
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { Node } from 'src/utils/types.utils';
import { DTIFaultType } from '../fault-type/dti-fault-type.model';

Check warning on line 2 in angular-client/src/pages/fault-page/shared/indiv-fault/mpu-fault.model.ts

View workflow job for this annotation

GitHub Actions / run-linting-check

'DTIFaultType' is defined but never used
import { Fault } from './fault.model';
import { MPUFaultType } from '../fault-type/mpu-fault-type.model';

export enum MPU_FAULTS_VALUES {
ONBOARD_TEMP_FAULT = 1,
ONBOARD_PEDAL_FAULT = 2,
IMU_FAULT = 4,
CAN_DISPATCH_FAULT = 8,
CAN_ROUTING_FAULT = 16,
FUSE_MONITOR_FAULT = 32,
SHUTDOWN_MONITOR_FAULT = 64,
DTI_ROUTING_FAULT = 128,
STEERINGIO_ROUTING_FAULT = 256,
STATE_RECEIVED_FAULT = 512,
INVALID_TRANSITION_FAULT = 1024,
BMS_CAN_MONITOR_FAULT = 2048,
BUTTONS_MONITOR_FAULT = 4096,
BSPD_PREFAULT = 8192,
LV_MONITOR_FAULT = 16384,
BATTERY_THERMISTOR = 32768,
RTDS_FAULT = 65536
}

export class MPUFault implements Fault<MPUFaultType> {
name: MPU_FAULTS_VALUES;
timeTriggered: number;
format(): { type: String; name: String; timeTriggered: number } {
throw new Error('Method not implemented.');
}
/**
* Constructs a new MPU fault base on a valid faultValue
* @param faultValue
* @param timeTriggered
*/
constructor(faultValue: MPU_FAULTS_VALUES, timeTriggered: number) {
this.name = faultValue;
this.timeTriggered = timeTriggered;
}
getRelevantNodes(timeFrame: number): Node[] {
throw new Error('Method not implemented.');
}
}

0 comments on commit b3c0f6c

Please sign in to comment.