Skip to content
Permalink
Browse files

Increasing state refresh for more responsive demo

  • Loading branch information
Evan Langlais
Evan Langlais committed Apr 30, 2019
1 parent 828a466 commit bcb206ddf6c01c725cdf073460715ae15cc6f774
Showing with 19 additions and 6 deletions.
  1. +19 −6 src/app/statistics/statistics.component.ts
@@ -27,7 +27,8 @@ export class StatisticsComponent implements OnInit {
public radial_metrics = ['l1.current', 'l2.current', 'l3.current', 'engine.rpm', 'fuel.pressure',
'l1.l0.voltage', 'l2.l0.voltage', 'l3.l0.voltage', 'total.kw'];
public slide_metrics = ['coolant.temp', 'fuel.temp', 'oil.temp', 'oil.pressure'];
public timer$;
public datatimer$;
public statetimer$;

getMajorTicks(metric: GeneratorMetric) {
const total = (metric.max - metric.min);
@@ -65,9 +66,6 @@ export class StatisticsComponent implements OnInit {
loadData() {
const gen_id = parseInt(localStorage.getItem('gen_id'), 10);
this.login.getToken().then((jsonToken) => {
this.data2.getGeneratorState(gen_id, jsonToken).then((state) => {
this.generator_state = state;
});
this.data2.getGeneratorStatistics(gen_id, jsonToken).then((statistics) => {
this.generator_statistics = statistics;
});
@@ -76,17 +74,32 @@ export class StatisticsComponent implements OnInit {
});
}

loadState() {
const gen_id = parseInt(localStorage.getItem('gen_id'), 10);
this.login.getToken().then((jsonToken) => {
this.data2.getGeneratorState(gen_id, jsonToken).then((state) => {
this.generator_state = state;
});
}, (error) => {
// todo go to logout
});
}

reloadLoop() {

}

ngOnInit() {
localStorage.removeItem('data_type');
localStorage.removeItem('fault_type');
this.timer$ = timer(0, 60000);
this.timer$.subscribe(() => {
this.datatimer$ = timer(0, 60000);
this.datatimer$.subscribe(() => {
this.loadData();
});
this.statetimer$ = timer(0, 5000);
this.statetimer$.subscribe(() => {
this.loadState();
});
// this.loadData();
}

0 comments on commit bcb206d

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