29 lines
686 B
TypeScript
Raw Normal View History

import { observable } from "mobx";
import { SprinklersDevice } from "./SprinklersDevice";
export class Section {
2017-10-05 09:07:07 -06:00
readonly device: SprinklersDevice;
readonly id: number;
2017-10-05 09:07:07 -06:00
@observable name: string = "";
@observable state: boolean = false;
2017-10-05 09:07:07 -06:00
constructor(device: SprinklersDevice, id: number) {
this.device = device;
2017-10-05 09:07:07 -06:00
this.id = id;
}
2017-10-10 16:34:02 -06:00
/** duration is in seconds */
run(duration: number) {
return this.device.runSection({ sectionId: this.id, duration });
}
cancel() {
return this.device.cancelSection({ sectionId: this.id });
}
toString(): string {
return `Section ${this.id}: '${this.name}'`;
}
}