Skip to content
Permalink
Browse files

prepared faults/status state changes, established generatorstatus object

  • Loading branch information
ema14006 committed Apr 12, 2019
1 parent 484e766 commit 564708070f38cd61b40dfed5df9405d9137c40ca
Showing with 77 additions and 21 deletions.
  1. +16 −16 src/app/statistics/statistics.component.html
  2. +61 −5 src/app/statistics/statistics.component.ts
@@ -107,67 +107,67 @@
<h3 class = "p-3">Faults</h3>
</div>
<div class = "col-md-6">
<h5 *ngIf = "1 == 2; else emptyOvercrank"><span class="badge badge-danger">Overcrank</span></h5>
<h5 *ngIf = "isOvercrank; else emptyOvercrank"><span class="badge badge-danger">Overcrank</span></h5>
<ng-template #emptyOvercrank>
<h5><span class="badge badge-secondary">Overcrank</span></h5>
</ng-template>
</div>
<div class = "col-md-6">
<h5 *ngIf = "1 == 2; else emptyEngine"><span class="badge badge-danger">High Engine<br>Temperature</span></h5>
<h5 *ngIf = "isHighEngineTemperature; else emptyEngine"><span class="badge badge-danger">High Engine<br>Temperature</span></h5>
<ng-template #emptyEngine>
<h5><span class="badge badge-secondary">High Engine<br>Temperature</span></h5>
</ng-template>
</div>
<div class = "col-md-6">
<h5 *ngIf = "1 == 2; else emptyOil"><span class="badge badge-danger">Low Oil<br>Pressure</span></h5>
<h5 *ngIf = "isLowOilPressure; else emptyOil"><span class="badge badge-danger">Low Oil<br>Pressure</span></h5>
<ng-template #emptyOil>
<h5><span class="badge badge-secondary">Low Oil<br>Pressure</span></h5>
</ng-template>
</div>
<div class = "col-md-6">
<h5 *ngIf = "1 == 2; else emptyOverspeed"><span class="badge badge-danger">Overspeed</span></h5>
<h5 *ngIf = "isOverspeed; else emptyOverspeed"><span class="badge badge-danger">Overspeed</span></h5>
<ng-template #emptyOverspeed>
<h5><span class="badge badge-secondary">Overspeed</span></h5>
</ng-template>
</div>
<div class = "col-md-6">
<h5 *ngIf = "1 == 2; else emptyEmergency"><span class="badge badge-danger">Emergency Stop</span></h5>
<h5 *ngIf = "isEmergencyStop; else emptyEmergency"><span class="badge badge-danger">Emergency Stop</span></h5>
<ng-template #emptyEmergency>
<h5><span class="badge badge-secondary">Emergency Stop</span></h5>
</ng-template>
</div>
<div class = "col-md-6">
<h5 *ngIf = "1 == 1; else emptyLowFuel"><span class="badge badge-danger">Low Fuel</span></h5>
<h5 *ngIf = "isLowFuel; else emptyLowFuel"><span class="badge badge-danger">Low Fuel</span></h5>
<ng-template #emptyLowFuel>
<h5><span class="badge badge-secondary">Low Fuel</span></h5>
</ng-template>
</div>
<div class = "col-md-6">
<h5 *ngIf = "1 == 2; else emptyLowCoolant"><span class="badge badge-danger">Low Coolant<br>Level/Aux</span></h5>
<h5 *ngIf = "isLowCoolant; else emptyLowCoolant"><span class="badge badge-danger">Low Coolant<br>Level/Aux</span></h5>
<ng-template #emptyLowCoolant>
<h5><span class="badge badge-secondary">Low Coolant<br>Level/Aux</span></h5>
</ng-template>
</div>
<div class = "col-md-6">
<h5 *ngIf = "1 == 1; else emptyLowCranking"><span class="badge badge-danger">Low Cranking<br>Voltage</span></h5>
<h5 *ngIf = "isLowCrankingVoltage; else emptyLowCranking"><span class="badge badge-danger">Low Cranking<br>Voltage</span></h5>
<ng-template #emptyLowCranking>
<h5><span class="badge badge-secondary">Low Cranking<br>Voltage</span></h5>
</ng-template>
</div>
<div class = "col-md-6">
<h5 *ngIf = "1 == 2; else emptyBatteryVolt"><span class="badge badge-danger">Battery Voltage<br>(Hi/Lo)</span></h5>
<h5 *ngIf = "isBatteryVoltage; else emptyBatteryVolt"><span class="badge badge-danger">Battery Voltage<br>(Hi/Lo)</span></h5>
<ng-template #emptyBatteryVolt>
<h5><span class="badge badge-secondary">Battery Voltage<br>(Hi/Lo)</span></h5>
</ng-template>
</div>
<div class = "col-md-6">
<h5 *ngIf = "1 == 2; else emptyBatteryCharger"><span class="badge badge-danger">Battery Charger<br>Fail</span></h5>
<h5 *ngIf = "isBatteryChargerFail; else emptyBatteryCharger"><span class="badge badge-danger">Battery Charger<br>Fail</span></h5>
<ng-template #emptyBatteryCharger>
<h5><span class="badge badge-secondary">Battery Charger<br>Fail</span></h5>
</ng-template>
</div>
<div class = "col-md-6">
<h5 *ngIf = "1 == 1; else emptyCommon"><span class="badge badge-danger">Common Fault</span></h5>
<h5 *ngIf = "isCommonFault; else emptyCommon"><span class="badge badge-danger">Common Fault</span></h5>
<ng-template #emptyCommon>
<h5><span class="badge badge-secondary">Common Fault</span></h5>
</ng-template>
@@ -178,31 +178,31 @@ <h5><span class="badge badge-secondary">Common Fault</span></h5>
<h3 class = "p-3">System Status</h3>
</div>
<div class = "col-md-6">
<h5 *ngIf = "1 == 2; else emptyEPS"><span class="badge badge-success">EPS Supplying<br>Load</span></h5>
<h5 *ngIf = "isEPSSupplying; else emptyEPS"><span class="badge badge-success">EPS Supplying<br>Load</span></h5>
<ng-template #emptyEPS>
<h5><span class="badge badge-secondary">EPS Supplying<br>Load</span></h5>
</ng-template>
</div>
<div class = "col-md-6">
<h5 *ngIf = "1 == 2; else emptyAuto"><span class="badge badge-success">Not-In-Auto</span></h5>
<h5 *ngIf = "isNotInAuto; else emptyAuto"><span class="badge badge-success">Not-In-Auto</span></h5>
<ng-template #emptyAuto>
<h5><span class="badge badge-secondary">Not-In-Auto</span></h5>
</ng-template>
</div>
<div class = "col-md-6">
<h5 *ngIf = "1 == 1; else emptySystem"><span class="badge badge-success">System Running</span></h5>
<h5 *ngIf = "isSystemRunning; else emptySystem"><span class="badge badge-success">System Running</span></h5>
<ng-template #emptySystem>
<h5><span class="badge badge-secondary">System Running</span></h5>
</ng-template>
</div>
<div class = "col-md-6">
<h5 *ngIf = "1 == 1; else emptyGenerator"><span class="badge badge-success">Generator<br>Running</span></h5>
<h5 *ngIf = "isGeneratorRunning; else emptyGenerator"><span class="badge badge-success">Generator<br>Running</span></h5>
<ng-template #emptyGenerator>
<h5><span class="badge badge-secondary">Generator<br>Running</span></h5>
</ng-template>
</div>
<div class = "col-md-6">
<h5 *ngIf = "1 == 2; else emptyCommunication"><span class="badge badge-success">Communication<br>Status</span></h5>
<h5 *ngIf = "isCommunicationStatus; else emptyCommunication"><span class="badge badge-success">Communication<br>Status</span></h5>
<ng-template #emptyCommunication>
<h5><span class="badge badge-secondary">Communication<br>Status</span></h5>
</ng-template>
@@ -3,6 +3,8 @@ 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',
@@ -12,7 +14,7 @@ import {LoginService} from '../services/login.service';
export class StatisticsComponent implements OnInit {


constructor(public data: MetricsService, private http: HttpClient, private router: Router, private login: LoginService) {
constructor(public data: MetricsService, public data2: GeneratorService, private http: HttpClient, private router: Router, private login: LoginService) {



@@ -58,8 +60,30 @@ export class StatisticsComponent implements OnInit {
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()
{
this.router.navigateByUrl('/visualize-one');
@@ -97,27 +121,40 @@ export class StatisticsComponent implements OnInit {
return true;
}
}
statusChange(genStatus)
{

if(genStatus == "overcrank")
{
return this.isOvercrank = true;
}
else if(genStatus == "high_engine_temp")
{
return this.isHighEngineTemperature = true;
}
}


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) => {
//console.log(data.outputs[1].dps[0][1]);
this.metric = data;
console.log(this.metric.outputs[0].dps.length == 0);
//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.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];
@@ -138,6 +175,25 @@ export class StatisticsComponent implements OnInit {


});

this.generator = await this.data2.getGeneratorStatus(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]);

}
console.log(this.isOvercrank);
console.log(this.isOvercrank);
}


} catch (err) {
return err;
}

0 comments on commit 5647080

Please sign in to comment.
You can’t perform that action at this time.