Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
PowerPanel-Frontend/src/app/statistics/statistics.component.ts
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
159 lines (119 sloc)
3.64 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Component, OnInit} from '@angular/core'; | |
import {MetricsService} from '../services/metrics.service'; | |
import {HttpClient, HttpHeaders} from '@angular/common/http'; | |
import { Router } from '@angular/router'; | |
@Component({ | |
selector: 'app-statistics', | |
templateUrl: './statistics.component.html', | |
styleUrls: ['./statistics.component.css'] | |
}) | |
export class StatisticsComponent implements OnInit { | |
constructor(public data: MetricsService, private http: HttpClient, private router: Router) { | |
} | |
public fuelTemp: any; | |
public oilTemp: any; | |
public pACurrent: any; | |
public pBCurrent: any; | |
public pCCurrent: any; | |
public engineSpeed: any; | |
public fuelLevel: any; | |
public pAVoltage: any; | |
public pBVoltage: any; | |
public pCVoltage: any; | |
public totalKw: any; | |
public coolantTemp: any; | |
public oilPressure: any; | |
public fuelTempCheck: any; | |
public oilTempCheck: any; | |
public pACurrentCheck: any; | |
public pBCurrentCheck: any; | |
public pCCurrentCheck: any; | |
public engineSpeedCheck: any; | |
public fuelLevelCheck: any; | |
public pAVoltageCheck: any; | |
public pBVoltageCheck: any; | |
public pCVoltageCheck: any; | |
public totalKwCheck: any; | |
public coolantTempCheck: any; | |
public oilPressureCheck: any; | |
public metric: any; | |
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; | |
goToGraphGen() | |
{ | |
this.router.navigateByUrl('/visualize-one'); | |
} | |
goToGraphSpec(dataType) | |
{ | |
this.router.navigateByUrl('/visualize-one'); | |
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; | |
} | |
} | |
ngOnInit() { | |
localStorage.removeItem('data_type'); | |
localStorage.removeItem('fault_type'); | |
const jsonToken = localStorage.getItem('auth_token'); | |
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.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]; | |
this.pCCurrent = this.metric.outputs[4].dps[0][1]; | |
this.engineSpeed = this.metric.outputs[5].dps[0][1]; | |
this.fuelLevel = this.metric.outputs[6].dps[0][1]; | |
this.pAVoltage = this.metric.outputs[7].dps[0][1]; | |
this.pBVoltage = this.metric.outputs[8].dps[0][1]; | |
this.pCVoltage = this.metric.outputs[9].dps[0][1]; | |
this.totalKw = this.metric.outputs[10].dps[0][1]; | |
this.coolantTemp = this.metric.outputs[11].dps[0][1]; | |
this.oilPressure = this.metric.outputs[12].dps[0][1]; | |
}); | |
} catch (err) { | |
return err; | |
} | |
try { | |
this.data.getYearMetrics(jsonToken).subscribe((data) => { | |
this.metricYearAvg = data; | |
this.fuelTempYearAvg = this.metricYearAvg.outputs[0].dps[0][1]; | |
}); | |
} catch (err) { | |
return err; | |
} | |
} | |
} |