Skip to content

Commit

Permalink
#172 added support for BMS faults + proxy client multi vals not random
Browse files Browse the repository at this point in the history
  • Loading branch information
bracyw committed Aug 12, 2024
1 parent c1e59eb commit ee25cd0
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default class BatteryStatusDisplay {
constructor(private storage: Storage) {}

ngOnInit() {
this.storage.get(IdentifierDataType.STATUS).subscribe((value) => {
this.storage.get(IdentifierDataType.STATUS_BALANCING).subscribe((value) => {
this.isBalancing = floatPipe(value.values[0]) === 1;
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
<ng-container *ngFor="let fault of faults; index as i">
<div
[style]="
i % 2 == 0
(i % 2 == 0) === faultsShifted
? 'background-color: #d4760b ; width: 100%; border-radius: 2px'
: 'background-color: #4d453c; width: 100%; border-radius: 2px'
"
>
<typography variant="info-subtitle" [content]="fault.faultName"></typography>
<typography variant="info-subtitle" [content]="fault.type" additionalStyles="font-weight: bold;"></typography>
<typography variant="info-subtitle" [content]="fault.name"></typography>
<typography variant="info-subtitle" [content]="fault.time"></typography>
</div>
<div style="height: 2px"></div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ enum BMS_FAULTS_TYPES {
}

enum FaultType {
BMS,
Charger
BMS = 'BMS',
Charger = 'Charger'
}

@Component({
Expand All @@ -34,7 +34,8 @@ enum FaultType {
styleUrls: ['./fault-display.component.css']
})
export default class FaultDisplay {
faults: { faultName: string; time: string }[] = [];
faults: { type: string; name: string; time: string }[] = [];
faultsShifted: boolean = false;
resetButton = {
onClick: () => {
this.faults.shift();
Expand Down Expand Up @@ -90,7 +91,9 @@ export default class FaultDisplay {
if (this.faults.length >= 50) {
this.faults.pop();
}
this.faults.unshift({ faultName, time: new Date().toLocaleTimeString() });
this.faultsShifted = !this.faultsShifted;

this.faults.unshift({ type: faultType, name: faultName, time: new Date().toLocaleTimeString() });
}
}

Expand Down
15 changes: 10 additions & 5 deletions scylla-server/src/socket/mock-proxy-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,11 +304,16 @@ export default class MockProxyClient implements ProxyClient {
index = this.getRandomIndex(this.mockData.length);
numericalData = this.mockData[index];

for (const val in numericalData.vals) {
if (numericalData.vals.hasOwnProperty(val)) {
let newVal = numericalData.vals[val] + Math.random() * 2 - 1;
newVal = Math.max(numericalData.min, Math.min(numericalData.max, newVal));
numericalData.vals[val] = newVal;
// IF MORE THAN ONE VALUE IS GIVEN in the numerical data, it is assumed that only those values should be choosen from.
if (numericalData.vals.length > 1) {
numericalData.vals[0] = numericalData.vals[this.getRandomIndex(numericalData.vals.length)];
} else {
for (const val in numericalData.vals) {
if (numericalData.vals.hasOwnProperty(val)) {
let newVal = numericalData.vals[val] + Math.random() * 2 - 1;
newVal = Math.max(numericalData.min, Math.min(numericalData.max, newVal));
numericalData.vals[val] = newVal;
}
}
}

Expand Down

0 comments on commit ee25cd0

Please sign in to comment.