From 10aa0bb1013447aaeba5fb47c8d1ae819c67d1ba Mon Sep 17 00:00:00 2001 From: Emil Abraham Date: Mon, 15 Apr 2019 16:45:12 -0400 Subject: [PATCH] integrated ngifs with statuses, cleaned up code --- src/app/statistics/statistics.component.html | 43 ++++----- src/app/statistics/statistics.component.ts | 93 ++------------------ 2 files changed, 22 insertions(+), 114 deletions(-) diff --git a/src/app/statistics/statistics.component.html b/src/app/statistics/statistics.component.html index 419ba87..7d4410a 100644 --- a/src/app/statistics/statistics.component.html +++ b/src/app/statistics/statistics.component.html @@ -107,67 +107,61 @@

Faults

-
Overcrank
+
Overcrank
Overcrank
-
High Engine
Temperature
+
High Engine
Temperature
High Engine
Temperature
-
Low Oil
Pressure
+
Low Oil
Pressure
Low Oil
Pressure
-
Overspeed
+
Overspeed
Overspeed
-
Emergency Stop
+
Emergency Stop
Emergency Stop
-
Low Fuel
+
Low Fuel
Low Fuel
-
Low Coolant
Level/Aux
+
Low Coolant
Level/Aux
Low Coolant
Level/Aux
-
Low Cranking
Voltage
+
Low Cranking
Voltage
Low Cranking
Voltage
-
Battery Voltage
(Hi/Lo)
+
Battery Voltage
(Hi/Lo)
Battery Voltage
(Hi/Lo)
-
-
-
Battery Charger
Fail
- -
Battery Charger
Fail
-
-
+
-
Common Fault
+
Common Fault
Common Fault
@@ -178,35 +172,30 @@

System Status

-
EPS Supplying
Load
+
EPS Supplying
Load
EPS Supplying
Load
-
Not-In-Auto
+
Not-In-Auto
Not-In-Auto
-
System Running
+
System Ready
System Running
-
Generator
Running
+
Generator
Running
Generator
Running
-
-
Communication
Status
- -
Communication
Status
-
-
+ diff --git a/src/app/statistics/statistics.component.ts b/src/app/statistics/statistics.component.ts index 58e7664..c9bb285 100644 --- a/src/app/statistics/statistics.component.ts +++ b/src/app/statistics/statistics.component.ts @@ -53,35 +53,9 @@ export class StatisticsComponent implements OnInit { public metricYearAvg: any; public fuelTempYearAvg: any; - public isRecent: boolean = true; - public isHour: boolean = false; - public isDay: boolean = false; - public isWeek: boolean = false; - public isMonth: boolean = false; - public isYear: boolean = false; - - public isOvercrank: boolean = false; - public isHighEngineTemperature: boolean = false; - public isLowOilPressure: boolean = false; - public isOverspeed: boolean = false; - public isEmergencyStop: boolean = false; - public isLowFuel: boolean = false; - public isLowCoolant: boolean = false; - public isLowCrankingVoltage: boolean = false; - public isBatteryVoltage: boolean = false; - public isBatteryChargerFail: boolean = false; - public isCommonFault: boolean = false; - public isEPSSupplying: boolean = false; - public isNotInAuto: boolean = false; - public isSystemRunning: boolean = false; - public isGeneratorRunning: boolean = false; - public isCommunicationStatus: boolean = false; - - public testArray: String[] = ["overcrank", "high_engine_temp"]; - public generator : GeneratorState; goToGraphGen() @@ -95,45 +69,8 @@ export class StatisticsComponent implements OnInit { localStorage.setItem('data_type', dataType); } - lengthCheck(metricArray) - { - if (metricArray.length == 0) - { - return null; - - } - else - { - return metricArray[0][1]; - } - - } - setCheck(metricArray) - { - if(metricArray.length == 0) - { - console.log(false) - return false; - } - else - { - console.log(true); - return true; - } - } - statusChange(genStatus) - { - - if(genStatus == "overcrank") - { - return this.isOvercrank = true; - } - else if(genStatus == "high_engine_temp") - { - return this.isHighEngineTemperature = true; - } - } - + + async ngOnInit() { @@ -146,17 +83,8 @@ export class StatisticsComponent implements OnInit { try { this.data.getDevMetrics(jsonToken).subscribe((data) => { - //console.log(data.outputs[1].dps[0][1]); - this.metric = data; - //console.log(this.metric.outputs[0].dps.length == 0); - - - this.fuelTemp = this.lengthCheck(this.metric.outputs[0].dps); - //this.fuelTempCheck = this.setCheck(this.metric.outputs[0].dps); - //console.log(this.fuelTempCheck); - - //this.fuelTemp = this.metric.outputs[0].dps[0][1]; + this.metric = data; this.oilTemp = this.metric.outputs[1].dps[0][1]; this.pACurrent = this.metric.outputs[2].dps[0][1]; this.pBCurrent = this.metric.outputs[3].dps[0][1]; @@ -176,25 +104,16 @@ export class StatisticsComponent implements OnInit { }); + this.generator = await this.data2.getGeneratorState(gen_id,jsonToken); - if (this.generator.fault_count == 0) - { - console.log("hi"); - } - else - { - for(var i = 0; i< this.testArray.length; i++) - { - this.statusChange(this.testArray[i]); - - } - } + } catch (err) { return err; } + try { this.data.getYearMetrics(jsonToken).subscribe((data) => {