allow single sensor detection, get rid of sensor disabled hardware state == nomessage

This commit is contained in:
2026-02-27 23:12:40 +01:00
parent c575fc2c36
commit 9b21d505e6
10 changed files with 92 additions and 32 deletions

View File

@@ -1,6 +1,6 @@
import {DetectionPlant, DetectionResult, PlantConfig, PumpTestResult} from "./api";
import {DetectionPlant, Detection, PlantConfig, PumpTestResult} from "./api";
const PLANT_COUNT = 8;
export const PLANT_COUNT = 8;
import {Controller} from "./main";
@@ -48,7 +48,7 @@ export class PlantViews {
plantView.setTestResult(response)
}
applyDetectionResult(json: DetectionResult) {
applyDetectionResult(json: Detection) {
for (let i = 0; i < PLANT_COUNT; i++) {
var plantResult = json.plant[i];
this.plants[i].setDetectionResult(plantResult);
@@ -65,6 +65,8 @@ export class PlantView {
private readonly plantDiv: HTMLDivElement;
private readonly header: HTMLElement;
private readonly testButton: HTMLButtonElement;
private readonly testSensorAButton: HTMLButtonElement;
private readonly testSensorBButton: HTMLButtonElement;
private readonly targetMoisture: HTMLInputElement;
private readonly minMoisture: HTMLInputElement;
private readonly pumpTimeS: HTMLInputElement;
@@ -119,6 +121,28 @@ export class PlantView {
controller.testPlant(plantId)
}
this.testSensorAButton = document.getElementById("plant_" + plantId + "_test_sensor_a")! as HTMLButtonElement;
this.testSensorAButton.onclick = () => {
const detection: Detection = {
plant: Array.from({length: PLANT_COUNT}, (_v, idx) => ({
sensor_a: idx === plantId,
sensor_b: false,
})),
};
controller.detectSensors(detection);
};
this.testSensorBButton = document.getElementById("plant_" + plantId + "_test_sensor_b")! as HTMLButtonElement;
this.testSensorBButton.onclick = () => {
const detection: Detection = {
plant: Array.from({length: PLANT_COUNT}, (_v, idx) => ({
sensor_a: false,
sensor_b: idx === plantId,
})),
};
controller.detectSensors(detection);
};
this.mode = document.getElementById("plant_" + plantId + "_mode") as HTMLSelectElement
this.mode.onchange = function () {
controller.configChanged()