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.
29 lines
716 B
29 lines
716 B
7 years ago
|
import { observable } from "mobx";
|
||
|
import { SprinklersDevice } from "./SprinklersDevice";
|
||
|
|
||
|
export class Section {
|
||
7 years ago
|
readonly device: SprinklersDevice;
|
||
|
readonly id: number;
|
||
7 years ago
|
|
||
7 years ago
|
@observable name: string = "";
|
||
|
@observable state: boolean = false;
|
||
7 years ago
|
|
||
7 years ago
|
constructor(device: SprinklersDevice, id: number) {
|
||
7 years ago
|
this.device = device;
|
||
7 years ago
|
this.id = id;
|
||
7 years ago
|
}
|
||
|
|
||
7 years ago
|
/** duration is in seconds */
|
||
|
run(duration: number) {
|
||
7 years ago
|
return this.device.runSection({ sectionId: this.id, duration });
|
||
|
}
|
||
|
|
||
|
cancel() {
|
||
|
return this.device.cancelSection({ sectionId: this.id });
|
||
7 years ago
|
}
|
||
|
|
||
|
toString(): string {
|
||
7 years ago
|
return `Section{id=${this.id}, name="${this.name}", state=${this.state}}`;
|
||
7 years ago
|
}
|
||
|
}
|