sprinklers3/common/sprinklers/SectionRunner.ts

45 lines
1.2 KiB
TypeScript
Raw Normal View History

2017-10-05 14:31:07 -06:00
import { observable } from "mobx";
import { Duration } from "./Duration";
import { SprinklersDevice } from "./SprinklersDevice";
export class SectionRun {
2017-10-05 09:07:07 -06:00
readonly id: number;
section: number;
duration: Duration;
startTime: Date | null;
pauseTime: Date | null;
constructor(id: number = 0, section: number = 0, duration: Duration = new Duration()) {
this.id = id;
this.section = section;
this.duration = duration;
this.startTime = null;
this.pauseTime = null;
}
toString() {
return `SectionRun{id=${this.id}, section=${this.section}, duration=${this.duration},` +
` startTime=${this.startTime}, pauseTime=${this.pauseTime}}`;
}
}
export class SectionRunner {
2017-10-05 09:07:07 -06:00
readonly device: SprinklersDevice;
2017-10-05 09:07:07 -06:00
@observable queue: SectionRun[] = [];
@observable current: SectionRun | null = null;
@observable paused: boolean = false;
constructor(device: SprinklersDevice) {
this.device = device;
}
cancelRunById(id: number): Promise<{}> {
return this.device.cancelSectionRunById(id);
}
toString(): string {
return `SectionRunner{queue="${this.queue}", current="${this.current}", paused=${this.paused}}`;
}
}