Fixed some of the math

This commit is contained in:
Zakary Timson 2019-01-01 16:03:40 -05:00
parent 9b244e1d72
commit 7eb85ce630
2 changed files with 7 additions and 1 deletions

View File

@ -1,7 +1,7 @@
<div class="p-3"> <div class="p-3">
<div class="d-flex mb-3"> <div class="d-flex mb-3">
<div class="d-flex flex-grow-1 align-items-center"> <div class="d-flex flex-grow-1 align-items-center">
<h3 class="mb-0 text-white">Powerwall: {{batteryService.total}} V</h3> <h3 class="mb-0 text-white">Powerwall: {{batteryService.total | round}} V</h3>
</div> </div>
<div class="d-flex flex-grow-1 align-content-center justify-content-end"> <div class="d-flex flex-grow-1 align-content-center justify-content-end">
<mat-button-toggle-group (change)="batteryService.setRelayMode($event.value)"> <mat-button-toggle-group (change)="batteryService.setRelayMode($event.value)">

View File

@ -57,6 +57,12 @@ export class BatteryService {
} }
}); });
this.batteries.map((battery, i, arr) => {
if(i % 2 == 1) return battery;
console.log(i, battery.charge);
battery.charge = battery.charge - arr[i + 1].charge;
});
this.total = this.batteries.reduce((acc, battery) => acc + battery.charge, 0) / 2; this.total = this.batteries.reduce((acc, battery) => acc + battery.charge, 0) / 2;
console.log(this.batteries) console.log(this.batteries)