Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#156 fault page #211

Draft
wants to merge 23 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
d2a799d
merge conflict
RChandler234 Aug 19, 2024
7afe86c
#156 - update README
RChandler234 Sep 21, 2024
da928ed
#156 - change graph page range
RChandler234 Sep 21, 2024
055041b
#156 - skeleton of frontend, draft of endpoint, need to test
RChandler234 Sep 22, 2024
48b0d6c
#156 - README Change
RChandler234 Sep 24, 2024
6bce55b
#156 - fix clippy
RChandler234 Sep 24, 2024
faae121
#156 - querying data with datatypename 30 sec before fault
RChandler234 Sep 26, 2024
54febe4
#156 - fault type asbtraction start
bracyw Oct 6, 2024
b3c0f6c
#156 - basic data set up for fault abstraction
bracyw Oct 8, 2024
8457630
#156 - got rid of unnecessary fault-type abstraction
bracyw Oct 26, 2024
73f8c69
Merge branch 'develop' into #156-fault-page
bracyw Oct 26, 2024
62e11be
#156 - querying data with datatypename 30 sec before fault
RChandler234 Sep 26, 2024
1fb4cfa
#156 - fixing stuff up
bracyw Oct 26, 2024
438ac70
#156 - trying to get branch back to normal
bracyw Oct 26, 2024
8dd2905
#156 - trying to get branch back to v3
bracyw Oct 26, 2024
e829a00
"#156 - skeleton of frontend, draft of endpoint, need to test"
RChandler234 Sep 22, 2024
4185c9e
"#156 - fix clippy"
RChandler234 Sep 24, 2024
7770268
"#156 - querying data with datatypename 30 sec before fault"
RChandler234 Sep 26, 2024
b480365
#156 added rough logic for both frontend and backend which should be …
bracyw Oct 27, 2024
485b20b
#156 - temp fix to querying for multiple node data by time
bracyw Oct 27, 2024
76c21ee
Merge branch 'develop' into #156-fault-page
bracyw Oct 27, 2024
bfb83b5
#156 - backend setup (MVP)... frontend abstraction (MVP)
bracyw Nov 3, 2024
5b68edb
#156 - backend setup, fault log working, NO fault info displayed yet.
bracyw Nov 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
# Argos

### Initializing Submodule

To initialize the odyssey submodule run `git submodule update --init`

## Local Development

Setup angular-client and scylla-server:

[Angular Client](./angular-client/README.md)\
[Scylla Server](./scylla-server/README.md)

Once you've sucessfully setup Scylla and the Client, you can either run them separately, or follow the docker commands below to run them together.
Once you've sucessfully setup Scylla and the Client, you can either run them separately, use `npm run start` from the root directory to run them together, or follow the docker commands below to run them together.

## Production

Expand Down
4 changes: 4 additions & 0 deletions angular-client/src/api/data.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@ import { urls } from './urls';
export const getDataByDataTypeNameAndRunId = (dataTypeName: string, runId: number): Promise<Response> => {
return fetch(urls.getDataByDataTypeNameAndRunId(dataTypeName, runId));
};

export const getDataByDatetime = (dateTime: string): Promise<Response> => {
return fetch(urls.getDataByDatetime(dateTime));
};
10 changes: 10 additions & 0 deletions angular-client/src/api/node.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,13 @@ import { urls } from './urls';
export const getAllNodes = (): Promise<Response> => {
return fetch(urls.getAllNodes());
};

/**
* Fetches all nodes with their associated data.
* @param toTime the most recent time you want data for all nodes (in milliseconds since midnight, January 1, 1970 UTC.)
* @param fromTime the time to begin querying from (in milliseconds since midnight, January 1, 1970 UTC.)
* @returns a list of full nodes with data from between from_time and to_time
*/
export const getSingleNodeWithData = (nodeName: string, timeToQueryFrom: number): Promise<Response> => {
return fetch(urls.getSingleNodeWithData(nodeName, timeToQueryFrom));
};
7 changes: 7 additions & 0 deletions angular-client/src/api/urls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,16 @@ const baseURL = (environment as any).url || 'http://localhost:8000';
/* Nodes */
const getAllNodes = () => `${baseURL}/nodes`;

/* Nodes with Data */
const getSingleNodeWithData = (nodeName: string, timeToQueryFrom: number) =>
`${baseURL}/nodesWithData/singleNode/${nodeName}/${timeToQueryFrom}`;

/* Systems */
const getAllSystems = () => `${baseURL}/systems`;

/* Data */
const getDataByDataTypeNameAndRunId = (dataTypeName: string, runId: number) => `${baseURL}/data/${dataTypeName}/${runId}`;
const getDataByDatetime = (dateTime: string) => `${baseURL}/dataByDatetime/${dateTime}`;

/* Runs */
const getRunById = (id: number) => `${baseURL}/runs/${id}`;
Expand All @@ -18,10 +23,12 @@ const startNewRun = () => `${baseURL}/runs/new`;

export const urls = {
getAllNodes,
getSingleNodeWithData,

getAllSystems,

getDataByDataTypeNameAndRunId,
getDataByDatetime,

getAllRuns,
getRunById,
Expand Down
4 changes: 3 additions & 1 deletion angular-client/src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import ChargingPage from 'src/pages/charging-page/charging-page.component';
import FaultPage from 'src/pages/fault-page/fault-page.component';
import GraphPage from 'src/pages/graph-page/graph-page.component';
import LandingPage from 'src/pages/landing-page/landing-page.component';
import Map from 'src/pages/map/map.component';
Expand All @@ -10,7 +11,8 @@ const routes: Routes = [
{ path: 'graph', component: GraphPage },
{ path: '', redirectTo: '/landing', pathMatch: 'full' },
{ path: 'map', component: Map },
{ path: 'charging', component: ChargingPage }
{ path: 'charging', component: ChargingPage },
{ path: 'fault', component: FaultPage }
];

@NgModule({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
<sidebar-chip icon="ev_station" value="Charging" (click)="navigateTo('/charging')" />
<sidebar-chip icon="bar_chart" value="Graph" (click)="navigateTo('/graph')" />
<sidebar-chip icon="map" value="Map" (click)="navigateTo('/map')" />
<sidebar-chip icon="warning" value="Fault" (click)="navigateTo('/fault')" />
</ng-template>
</p-sidebar>
6 changes: 6 additions & 0 deletions angular-client/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,15 @@ import CombinedStatusMobile from 'src/pages/charging-page/components/combined-st
import PackVoltageMobileDisplay from 'src/pages/charging-page/components/pack-voltage/pack-voltage-display/pack-voltage-mobile/pack-voltage-mobile.component';
import HighLowCellMobile from 'src/pages/charging-page/components/high-low-cell/high-low-cell-display/high-low-cell-mobile/high-low-cell-mobile.component';
import CellTempMobile from 'src/pages/charging-page/components/cell-temp/cell-temp-display/cell-temp-mobile/cell-temp-mobile.component';
import FaultPage from 'src/pages/fault-page/fault-page.component';
import FaultLog from 'src/pages/fault-page/components/fault-log/fault-log.component';
import FaultBox from 'src/pages/fault-page/components/fault-display/fault-box.component';

@NgModule({
declarations: [
AppContext,
LandingPage,
FaultPage,
ChargingPage,
ChargingPageMobile,
GraphPage,
Expand Down Expand Up @@ -176,6 +180,8 @@ import CellTempMobile from 'src/pages/charging-page/components/cell-temp/cell-te
CellTempGraph,
CurrentDisplay,
FaultDisplay,
FaultLog,
FaultBox,
SwitchComponent,
BMSModeDisplay,
DoubleLineGraphComponent,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.fault-box-body {
height: 95%;
display: flex;
align-items: left;
justify-content: left;
overflow-y: auto;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<info-background title="Current Fault">
<div style="width: 100%; padding-right: 5px; padding-left: 0px" class="fault-text-body">
@for (node of nodes; track node.name) {
<li>{{ node.name }}</li>
} @empty {
<li>There are no items.</li>
}
</div>
</info-background>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Component, Input } from '@angular/core';
import Storage from 'src/services/storage.service';
import { IdentifierDataType } from 'src/utils/enumerations/identifier-data-type';

Check warning on line 3 in angular-client/src/pages/fault-page/components/fault-display/fault-box.component.ts

View workflow job for this annotation

GitHub Actions / run-linting-check

'IdentifierDataType' is defined but never used
import { NodeWithData } from 'src/utils/types.utils';

@Component({
selector: 'fault-box',
templateUrl: './fault-box.component.html',
styleUrls: ['./fault-box.component.css']
})
export default class FaultBox {
@Input() nodes: NodeWithData[] = [];
constructor(private storage: Storage) {}

ngOnInit() {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.fault-text-body {
height: 95%;
display: flex;
align-items: left;
justify-content: left;
overflow-y: auto;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<info-background title="Fault Log" svgIcon="warning" [button]="resetButton">
<div style="width: 100%; padding-right: 5px; padding-left: 0px" class="fault-text-body">
<vstack style="width: 100%">
<div style="height: 10px"></div>
@for (fault of faults; track fault; let i = $index) {
<div
[style]="
(i % 2 == 0) === faultsShifted
? 'background-color: #d4760b ; width: 100%; border-radius: 2px'
: 'background-color: #4d453c; width: 100%; border-radius: 2px'
"
(click)="setSelectedFault(fault)"
>
<div style="display: flex; flex-direction: row; justify-content: space-between; height: 45px; padding: 10px">
<typography variant="info-subtitle" [content]="fault.format().type" style="align-self: center"></typography>
<typography
variant="info-subtitle"
[content]="fault.format().name"
additionalStyles="font-weight: bold;"
style="align-self: center; padding-left: 5px"
></typography>
<typography variant="info-subtitle" [content]="fault.format().time" style="align-self: center"></typography>
</div>
</div>
} @empty {
<li>There are no items.</li>
}
<ng-container *ngFor="let fault of faults; index as i">
<div style="height: 2px"></div>
</ng-container>
<div style="height: 50px"></div>
</vstack>
</div>
</info-background>
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { Component, Input } from '@angular/core';
import Storage from 'src/services/storage.service';
import { IdentifierDataType } from 'src/utils/enumerations/identifier-data-type';
import { Fault } from '../../shared/fault.model';
import { CHARGER_FAULT_NAMES, ChargerFault } from '../../shared/indiv-fault/charger-fault.model';
import APIService from 'src/services/api.service';
import { BMSFault } from '../../shared/indiv-fault/bms-fault.model';

@Component({
selector: 'fault-log',
templateUrl: './fault-log.component.html',
styleUrls: ['./fault-log.component.css']
})
export default class FaultLog {
@Input() setSelectedFault!: (fault: Fault) => void;
faults: Fault[] = [];
faultsShifted: boolean = false;
resetButton = {
onClick: () => {
this.faults = [];
},
icon: 'restart_alt'
};
constructor(
private serverService: APIService,
private storage: Storage
) {}

ngOnInit() {
this.storage.get(IdentifierDataType.COMM_TIMEOUT_FAULT).subscribe((value) => {
this.faults.unshift(new ChargerFault(this.serverService, CHARGER_FAULT_NAMES.COMM_TIMEOUT_FAULT, value.time));
});

this.storage.get(IdentifierDataType.HARDWARE_FAILURE_FAULT).subscribe((value) => {
this.faults.unshift(new ChargerFault(this.serverService, CHARGER_FAULT_NAMES.HARDWARE_FAILURE_FAULT, value.time));
});

this.storage.get(IdentifierDataType.OVER_TEMP_FAULT).subscribe((value) => {
this.faults.unshift(new ChargerFault(this.serverService, CHARGER_FAULT_NAMES.OVER_TEMP_FAULT, value.time));
});

this.storage.get(IdentifierDataType.VOLTAGE_WRONG_FAULT).subscribe((value) => {
this.faults.unshift(new ChargerFault(this.serverService, CHARGER_FAULT_NAMES.VOLTAGE_WRONG_FAULT, value.time));
});

this.storage.get(IdentifierDataType.WRONG_BAT_CONNECT_FAULT).subscribe((value) => {
this.faults.unshift(new ChargerFault(this.serverService, CHARGER_FAULT_NAMES.WRONG_BAT_CONNECT_FAULT, value.time));
});

this.storage.get(IdentifierDataType.BMS_FAULTS).subscribe((value) => {
const bmsFaultID = parseInt(value.values[0]);
try {
this.faults.unshift(new BMSFault(this.serverService, bmsFaultID, value.time));
} catch (error) {
// do nothing (the value input was not a valid BMS fault, most likely 0)
}
});
}
}
6 changes: 6 additions & 0 deletions angular-client/src/pages/fault-page/fault-page.component.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.image-container {
/* background-image: url(../../assets/images/NERO.jpeg); */
background-size: cover;
background-position: center;
height: 100%;
}
29 changes: 29 additions & 0 deletions angular-client/src/pages/fault-page/fault-page.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<div class="image-container" style="margin-right: 16px; margin-left: 16px">
<sidebar-toggle style="position: absolute; margin-top: 16px; margin-left: 16px" />

<div *ngIf="isMobile; else isDesktop">
<typography style="margin-bottom: -30px; margin-top: -10px" variant="large-header" content="Fault Page Mobile View" />
</div>
<ng-template #isDesktop>
<vstack style="width: 100%" spacing="15px">
<div style="align-self: end; width: 100%; display: flex; justify-content: space-around">
<typography
style="margin-bottom: -30px; margin-top: -10px"
variant="large-header"
[content]="time | date: 'HH:mm:ss'"
/>
<typography
style="margin-bottom: -30px; margin-top: -10px"
variant="large-header"
content="{{ time | date: 'MM/dd/yyyy' }} | {{ location }} "
/>
<latency-display style="margin-bottom: -30px; margin-top: -10px" />
</div>
<div style="align-self: end; width: 100%; display: flex; justify-content: space-around">
<fault-log style="width: 30%" [setSelectedFault]="setSelectedFault" />
<fault-box style="width: 35%" />
<graph-sidebar-desktop style="width: 30%" [nodes]="[]" [selectDataType]="onSelectDataType" />
</div>
</vstack>
</ng-template>
</div>
58 changes: 58 additions & 0 deletions angular-client/src/pages/fault-page/fault-page.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { Component, HostListener, OnInit } from '@angular/core';
import { getDataByDatetime } from 'src/api/data.api';

Check warning on line 2 in angular-client/src/pages/fault-page/fault-page.component.ts

View workflow job for this annotation

GitHub Actions / run-linting-check

'getDataByDatetime' is defined but never used
import APIService from 'src/services/api.service';
import Storage from 'src/services/storage.service';
import { IdentifierDataType } from 'src/utils/enumerations/identifier-data-type';
import { DataValue } from 'src/utils/socket.utils';
import { BMSFault } from './shared/indiv-fault/bms-fault.model';

Check warning on line 7 in angular-client/src/pages/fault-page/fault-page.component.ts

View workflow job for this annotation

GitHub Actions / run-linting-check

'BMSFault' is defined but never used
import { Fault } from './shared/fault.model';

/**
* Container for the Fault page, obtains data from the storage service.
*/
@Component({
selector: 'fault-page',
styleUrls: ['./fault-page.component.css'],
templateUrl: './fault-page.component.html'
})
export default class FaultPage implements OnInit {
time = new Date();
location: string = 'No Location Set';
constructor(
private storage: Storage,
private serverService: APIService
) {}
mobileThreshold = 1070;
isMobile = window.innerWidth < this.mobileThreshold;
selectedFaultDataValuesIsLoading = false;
selectedFaultDataValuesIsError = false;
selectedFaultDataValuesError?: Error;
currentData!: DataValue[];

ngOnInit() {
this.currentData = [];

setInterval(() => {
this.time = new Date();
}, 1000);

this.setSelectedFault = (fault: Fault) => {};

this.storage.get(IdentifierDataType.LOCATION).subscribe((value) => {
[this.location] = value.values || ['No Location Set'];
});
}

@HostListener('window:resize', ['$event'])
onResize() {
this.isMobile = window.innerWidth <= this.mobileThreshold;
}

onSelectDataType() {}

/**
* Sets the selected data type.
* @param dataType The data type to set.
*/
setSelectedFault!: (fault: Fault) => void;
}
15 changes: 15 additions & 0 deletions angular-client/src/pages/fault-page/shared/fault.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { NodeWithData } from 'src/utils/types.utils';
import { BMS_FAULT_NAMES } from './indiv-fault/bms-fault.model';
import { DTI_FAULTS_NAMES } from './indiv-fault/dti-fault.model';
import { MPU_FAULT_NAMES } from './indiv-fault/mpu-fault.model';
import { CHARGER_FAULT_NAMES } from './indiv-fault/charger-fault.model';

export interface Fault {
name: AllFaultNames;
timeTriggered: number; // number in Unix, epoch time in ms since 1970
relvantNodesWithData: NodeWithData[]; // should be made on construction
format(): { type: string; name: string; time: string };
updateRelvantNodes(timeTriggered: number): NodeWithData[];
}

export type AllFaultNames = BMS_FAULT_NAMES | CHARGER_FAULT_NAMES | DTI_FAULTS_NAMES | MPU_FAULT_NAMES;
Loading
Loading