You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.3 KiB
50 lines
1.3 KiB
7 years ago
|
import { IObservableArray, observable } from "mobx";
|
||
|
import { Duration } from "./Duration";
|
||
|
import { SprinklersDevice } from "./SprinklersDevice";
|
||
|
|
||
|
export class SectionRun {
|
||
|
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 {
|
||
|
device: SprinklersDevice;
|
||
|
|
||
|
@observable
|
||
|
queue: IObservableArray<SectionRun> = observable([]);
|
||
|
|
||
|
@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}}`;
|
||
|
}
|
||
|
}
|