Skip to content
Permalink
15f19daf0a
Switch branches/tags

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?
Go to file
 
 
Cannot retrieve contributors at this time
134 lines (90 sloc) 3.28 KB
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.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.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;
}
}
}