Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Increasing state refresh for more responsive demo
  • Loading branch information
Evan Langlais committed Apr 30, 2019
1 parent 828a466 commit bcb206d
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions src/app/statistics/statistics.component.ts
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
});
Expand All @@ -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();
}

Expand Down

0 comments on commit bcb206d

Please sign in to comment.