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.
133 lines (89 sloc)
3.23 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'; | |
import {LoginService} from '../services/login.service'; | |
import { GeneratorState } from '../generator-object'; | |
import { GeneratorService } from '../services/generator.service'; | |
@Component({ | |
selector: 'app-statistics', | |
templateUrl: './statistics.component.html', | |
styleUrls: ['./statistics.component.css'] | |
}) | |
export class StatisticsComponent implements OnInit { | |
constructor(public data: MetricsService, public data2: GeneratorService, private http: HttpClient, private router: Router, private login: LoginService) { | |
} | |
public fuelTemp: any; | |
public oilTemp: any; | |
public pACurrent: any; | |
public pBCurrent: any; | |
public pCCurrent: any; | |
public engineSpeed: any; | |
public fuelPressure: 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 generator : GeneratorState; | |
goToGraphGen() | |
{ | |
this.router.navigateByUrl('/visualize-one'); | |
} | |
goToGraphSpec(dataType) | |
{ | |
this.router.navigateByUrl('/visualize-one'); | |
localStorage.setItem('data_type', dataType); | |
} | |
async ngOnInit() { | |
localStorage.removeItem('data_type'); | |
localStorage.removeItem('fault_type'); | |
const jsonToken = await this.login.getToken(); | |
const gen_id = parseInt(localStorage.getItem('gen_id'),10); | |
try { | |
this.data.getDevMetrics(jsonToken).subscribe((data) => { | |
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]; | |
this.pCCurrent = this.metric.outputs[4].dps[0][1]; | |
this.engineSpeed = this.metric.outputs[5].dps[0][1]; | |
this.fuelPressure = 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]; | |
}); | |
this.generator = await this.data2.getGeneratorState(gen_id,jsonToken); | |
} 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; | |
} | |
} | |
} |