threshold query api
This commit is contained in:
@ -432,11 +432,11 @@ namespace sensors {
|
||||
|
||||
export class ThresholdDetector {
|
||||
public id: number;
|
||||
private min: number;
|
||||
private max: number;
|
||||
private lowThreshold: number;
|
||||
private highThreshold: number;
|
||||
private level: number;
|
||||
public min: number;
|
||||
public max: number;
|
||||
public lowThreshold: number;
|
||||
public highThreshold: number;
|
||||
public level: number;
|
||||
public state: ThresholdState;
|
||||
|
||||
constructor(id: number, min = 0, max = 100, lowThreshold = 20, highThreshold = 80) {
|
||||
@ -467,6 +467,14 @@ namespace sensors {
|
||||
}
|
||||
}
|
||||
|
||||
public threshold(t: ThresholdState): number {
|
||||
switch(t) {
|
||||
case ThresholdState.High: return this.highThreshold;
|
||||
case ThresholdState.Low: return this.lowThreshold;
|
||||
default: return (this.max - this.min) / 2;
|
||||
}
|
||||
}
|
||||
|
||||
public setLowThreshold(value: number) {
|
||||
this.lowThreshold = this.clampValue(value);
|
||||
this.highThreshold = Math.max(this.lowThreshold + 1, this.highThreshold);
|
||||
|
Reference in New Issue
Block a user