allow single sensor detection, get rid of sensor disabled hardware state == nomessage
This commit is contained in:
@@ -182,7 +182,7 @@ export interface DetectionPlant {
|
||||
sensor_b: boolean
|
||||
}
|
||||
|
||||
export interface DetectionResult {
|
||||
export interface Detection {
|
||||
plant: DetectionPlant[]
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ document.body.innerHTML = require('./main.html') as string;
|
||||
|
||||
|
||||
import {TimeView} from "./timeview";
|
||||
import {PlantViews} from "./plant";
|
||||
import {PlantViews, PLANT_COUNT} from "./plant";
|
||||
import {NetworkConfigView} from "./network";
|
||||
import {NightLampView} from "./nightlightview";
|
||||
import {TankConfigView} from "./tankview";
|
||||
@@ -29,7 +29,7 @@ import {
|
||||
SetTime, SSIDList, TankInfo,
|
||||
TestPump,
|
||||
VersionInfo,
|
||||
FileList, SolarState, PumpTestResult, DetectionResult, CanPower
|
||||
FileList, SolarState, PumpTestResult, Detection, CanPower
|
||||
} from "./api";
|
||||
import {SolarView} from "./solarview";
|
||||
import {toast} from "./toast";
|
||||
@@ -361,7 +361,7 @@ export class Controller {
|
||||
)
|
||||
}
|
||||
|
||||
async detectSensors() {
|
||||
async detectSensors(detection: Detection) {
|
||||
let counter = 0
|
||||
let limit = 5
|
||||
controller.progressview.addProgress("detect_sensors", counter / limit * 100, "Detecting sensors " + (limit - counter) + "s")
|
||||
@@ -376,9 +376,11 @@ export class Controller {
|
||||
|
||||
timerId = setTimeout(updateProgress, 1000);
|
||||
|
||||
fetch(PUBLIC_URL + "/detect_sensors", { method: "POST" })
|
||||
var pretty = JSON.stringify(detection, undefined, 1);
|
||||
|
||||
fetch(PUBLIC_URL + "/detect_sensors", { method: "POST", body: pretty })
|
||||
.then(response => response.json())
|
||||
.then (json => json as DetectionResult)
|
||||
.then (json => json as Detection)
|
||||
.then(json => {
|
||||
clearTimeout(timerId);
|
||||
controller.progressview.removeProgress("detect_sensors");
|
||||
@@ -573,7 +575,15 @@ export class Controller {
|
||||
this.logView = new LogView(this)
|
||||
this.hardwareView = new HardwareConfigView(this)
|
||||
this.detectBtn = document.getElementById("detect_sensors") as HTMLButtonElement
|
||||
this.detectBtn.onclick = () => { controller.detectSensors(); }
|
||||
this.detectBtn.onclick = () => {
|
||||
const detection: Detection = {
|
||||
plant: Array.from({length: PLANT_COUNT}, () => ({
|
||||
sensor_a: true,
|
||||
sensor_b: true,
|
||||
})),
|
||||
};
|
||||
controller.detectSensors(detection);
|
||||
}
|
||||
this.rebootBtn = document.getElementById("reboot") as HTMLButtonElement
|
||||
this.rebootBtn.onclick = () => {
|
||||
controller.reboot();
|
||||
|
||||
@@ -125,6 +125,10 @@
|
||||
<div class="flexcontainer plantSensorEnabledOnly_${plantId}">
|
||||
<div class="subtitle">Live:</div>
|
||||
</div>
|
||||
<div class="flexcontainer plantSensorEnabledOnly_${plantId}">
|
||||
<button class="subtitle" id="plant_${plantId}_test_sensor_a">Test Sensor A</button>
|
||||
<button class="subtitle" id="plant_${plantId}_test_sensor_b">Test Sensor B</button>
|
||||
</div>
|
||||
<div class="flexcontainer plantSensorEnabledOnly_${plantId}">
|
||||
<span class="plantsensorkey">Sensor A:</span>
|
||||
<span class="plantsensorvalue" id="plant_${plantId}_moisture_a">not measured</span>
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Controller } from "./main";
|
||||
import {DetectionResult, TankConfig, TankInfo} from "./api";
|
||||
import {Detection, TankConfig, TankInfo} from "./api";
|
||||
|
||||
export class TankConfigView {
|
||||
private readonly tank_useable_ml: HTMLInputElement;
|
||||
|
||||
Reference in New Issue
Block a user