typescript changes

This commit is contained in:
2024-12-14 01:24:31 +01:00
parent 8bd2cb72d0
commit 92299665b6
5 changed files with 182 additions and 104 deletions

View File

@@ -33,6 +33,7 @@ export class PlantView {
private readonly mode: HTMLSelectElement;
private readonly moistureA: HTMLElement;
private readonly moistureB: HTMLElement;
private readonly maxConsecutivePumpCount: HTMLInputElement;
constructor(plantId: number, parent:HTMLDivElement, controller:Controller) {
@@ -105,6 +106,11 @@ export class PlantView {
this.sensorBInstalled.onchange = function(){
controller.configChanged()
}
this.maxConsecutivePumpCount = document.getElementById("plant_"+plantId+"_max_consecutive_pump_count") as HTMLInputElement;
this.maxConsecutivePumpCount.onchange = function(){
controller.configChanged()
}
console.log(this)
}
@@ -117,17 +123,19 @@ export class PlantView {
this.pumpHourStart.value = plantConfig.pump_hour_start.toString();
this.pumpHourEnd.value = plantConfig.pump_hour_end.toString();
this.sensorBInstalled.checked = plantConfig.sensor_b
this.maxConsecutivePumpCount.value = plantConfig.max_consecutive_pump_count.toString();
}
getConfig() :PlantConfig {
const rv:PlantConfig = {
mode: this.mode.value,
target_moisture: +this.targetMoisture.value,
pump_time_s: +this.pumpTimeS.value,
pump_cooldown_min: +this.pumpCooldown.value,
target_moisture: this.targetMoisture.valueAsNumber,
pump_time_s: this.pumpTimeS.valueAsNumber,
pump_cooldown_min: this.pumpCooldown.valueAsNumber,
pump_hour_start: +this.pumpHourStart.value,
pump_hour_end: +this.pumpHourEnd.value,
sensor_b: this.sensorBInstalled.checked,
max_consecutive_pump_count: this.maxConsecutivePumpCount.valueAsNumber
}
return rv
}