diff --git a/applications/foobot/foobot_utility.pas b/applications/foobot/foobot_utility.pas index 758b350e8..7fc195e9e 100644 --- a/applications/foobot/foobot_utility.pas +++ b/applications/foobot/foobot_utility.pas @@ -52,6 +52,13 @@ const // Used in Trigger functions C_HIGH = 0; C_LOW = 1; + // Sensor recommended levels + REC_PM = 25; + REC_TMP = 23; + REC_HUM = 60; + REC_CO2 = 1300; + REC_VOC = 300; + REC_ALLPOLLU = 50; type TDataFetchType = (dfLast, dfStartEnd); // FetchFoobotData @@ -67,6 +74,8 @@ type AlertType: Integer; AlertValue: variant; end; + var + RecommendedLevelsArray:Array[C_PM..C_ALLPOLLU] of Double; function EncodeStringBase64(const s: string): string; function FetchAuthenticationKey(aUsername, aUserPassword: string): boolean; @@ -99,7 +108,8 @@ function SaveHighLows: boolean; function LoadHighLows: boolean; function SaveTriggers: boolean; function LoadTriggers: boolean; - +function SaveRecommendedLevels:boolean; +function LoadRecommendedLevels:boolean; var // Used to fetch server data HttpClient: TFPHTTPClient; @@ -230,6 +240,68 @@ begin end; end; +function SaveRecommendedLevels:boolean; +var + sFoobotName: string; +begin + Result:=FALSE; // assume failure + if FoobotIdentityObject.FoobotIdentityList.Count = 0 then Exit(FALSE); + sFoobotName := FoobotIdentityObject.FoobotIdentityList[TheCurrentFoobot].Name; + if (sFoobotName = '') then + Exit(False); + if not Assigned(HLINI) then + HLINI := TIniFile.Create(ChangeFileExt(GetAppConfigFile(False), '.ini')); + // Make sure the High-Lows are for the current Foobot + if (HLINI.ReadString('Foobot', 'CurrentFoobotName', 'unknown') <> sFoobotName) then + Exit(False); + try + // Save current Foobot recommended levels + with HLINI do + begin + WriteFloat(sFoobotName,'RecPM',RecommendedLevelsArray[C_PM]); + WriteFloat(sFoobotName,'RecTMP',RecommendedLevelsArray[C_TMP]); + WriteFloat(sFoobotName,'RecHUM',RecommendedLevelsArray[C_HUM]); + WriteFloat(sFoobotName,'RecCO2',RecommendedLevelsArray[C_CO2]); + WriteFloat(sFoobotName,'RecVOC',RecommendedLevelsArray[C_VOC]); + WriteFloat(sFoobotName,'RecALLPOLLU',RecommendedLevelsArray[C_ALLPOLLU]); + end; + Result := True; + except + raise Exception.Create('Could not save recommended levels for ' + sFoobotName); + end; +end; + +function LoadRecommendedLevels:boolean; +var + sFoobotName: string; +begin + Result:=FALSE; // assume failure + if FoobotIdentityObject.FoobotIdentityList.Count = 0 then Exit(FALSE); + sFoobotName := FoobotIdentityObject.FoobotIdentityList[TheCurrentFoobot].Name; + if (sFoobotName = '') then + Exit(False); + if not Assigned(HLINI) then + HLINI := TIniFile.Create(ChangeFileExt(GetAppConfigFile(False), '.ini')); + // Make sure the High-Lows are for the current Foobot + if (HLINI.ReadString('Foobot', 'CurrentFoobotName', 'unknown') <> sFoobotName) then + Exit(False); + try + // Load current Foobot recommended levels + with HLINI do + begin + RecommendedLevelsArray[C_PM]:=ReadFloat(sFoobotName,'RecPM',REC_PM); + RecommendedLevelsArray[C_TMP]:=ReadFloat(sFoobotName,'RecTMP',REC_TMP); + RecommendedLevelsArray[C_HUM]:=ReadFloat(sFoobotName,'RecHUM',REC_HUM); + RecommendedLevelsArray[C_CO2]:=ReadFloat(sFoobotName,'RecCO2',REC_CO2); + RecommendedLevelsArray[C_VOC]:=ReadFloat(sFoobotName,'RecVOC',REC_VOC); + RecommendedLevelsArray[C_ALLPOLLU]:=ReadFloat(sFoobotName,'RecALLPOLLU',REC_ALLPOLLU); + end; + Result := True; + except + raise Exception.Create('Could not load recommended levels for ' + sFoobotName); + end; +end; + function SaveHighLows: boolean; // Save values to an INI data file // To foobotmonitor.ini diff --git a/applications/foobot/monitor/foobotmonitor.lps b/applications/foobot/monitor/foobotmonitor.lps index e5dbd1e29..6f22966ea 100644 --- a/applications/foobot/monitor/foobotmonitor.lps +++ b/applications/foobot/monitor/foobotmonitor.lps @@ -3,14 +3,14 @@ - + - + @@ -19,9 +19,9 @@ - - - + + + @@ -34,7 +34,7 @@ - + @@ -44,7 +44,7 @@ - + @@ -54,15 +54,15 @@ - + - - - + + + @@ -72,7 +72,7 @@ - + @@ -80,7 +80,7 @@ - + @@ -90,7 +90,7 @@ - + @@ -102,9 +102,9 @@ - - - + + + @@ -113,7 +113,7 @@ - + @@ -121,7 +121,7 @@ - + @@ -130,12 +130,12 @@ - + - + @@ -143,21 +143,21 @@ - + - + - + @@ -165,26 +165,26 @@ - + - + - + - + @@ -192,7 +192,7 @@ - + @@ -200,35 +200,35 @@ - + - + - + - + - + @@ -236,20 +236,20 @@ - + - + - + @@ -257,14 +257,14 @@ - + - + @@ -272,7 +272,7 @@ - + @@ -280,130 +280,130 @@ - + - + - - + + - - + + - + - + - + - + - + - + - - + + - - + + - - + + - + - + - - + + - + - + - - + + - - + + - - + + - - + + - - + + - + - + - + - - + + - - + + - - + + - + - - + + diff --git a/applications/foobot/monitor/umainform.lfm b/applications/foobot/monitor/umainform.lfm index a093daf52..5ace5a516 100644 --- a/applications/foobot/monitor/umainform.lfm +++ b/applications/foobot/monitor/umainform.lfm @@ -808,7 +808,7 @@ object mainform: Tmainform Caption = 'Display...' object mnu_optionsDisplayGuagesOnly: TMenuItem AutoCheck = True - Caption = 'Guages only' + Caption = 'Minimal view' OnClick = mnu_optionsDisplayGuagesOnlyClick end object mnu_optionsDisplayYellowLines: TMenuItem diff --git a/applications/foobot/monitor/umainform.pas b/applications/foobot/monitor/umainform.pas index 7eac01f2b..7954f8f57 100644 --- a/applications/foobot/monitor/umainform.pas +++ b/applications/foobot/monitor/umainform.pas @@ -74,13 +74,6 @@ const MIN_ALLPOLLU = 0; MAX_ALLPOLLU = 700; - // Sensor recommended levels - REC_PM = 25; - REC_TMP = 23; - REC_HUM = 60; - REC_CO2 = 1300; - REC_VOC = 300; - REC_ALLPOLLU = 50; type @@ -343,6 +336,7 @@ begin LoadTriggers; // This can only be done if we have a Foobot Identity // as each Foobot has its own trigger values SetMinMaxTriggers; // Adjust if necesarry for preset Guage High/Low limits + LoadRecommendedLevels; // into RecommendedLevelsArray for iCount := C_PM to C_ALLPOLLU do SetTrafficLightStats(iCount, C_HIGH); Show; @@ -414,9 +408,9 @@ begin Format('< %.1f %s', [double(FooBotTriggerArray[C_LOW, C_PM]), FoobotDataObject.Units[C_PM]]); lbl_yellowlightpm.Caption := - Format('> %.1f %s', [double(REC_PM), FoobotDataObject.Units[C_PM]]); + Format('> %.1f %s', [RecommendedLevelsArray[C_PM], FoobotDataObject.Units[C_PM]]); lbl_greenlightpm.Caption := - Format('< %.1f %s', [double(REC_PM), FoobotDataObject.Units[C_PM]]); + Format('< %.1f %s', [RecommendedLevelsArray[C_PM], FoobotDataObject.Units[C_PM]]); if iSensorNum = C_TMP then if (HIGHLOW = C_HIGH) then @@ -428,9 +422,9 @@ begin Format('< %.1f %s', [double(FooBotTriggerArray[C_LOW, C_TMP]), FoobotDataObject.Units[C_TMP]]); lbl_yellowlighttmp.Caption := - Format('> %.1f %s', [double(REC_TMP), FoobotDataObject.Units[C_TMP]]); + Format('> %.1f %s', [RecommendedLevelsArray[C_TMP], FoobotDataObject.Units[C_TMP]]); lbl_greenlighttmp.Caption := - Format('< %.1f %s', [double(REC_TMP), FoobotDataObject.Units[C_TMP]]); + Format('< %.1f %s', [RecommendedLevelsArray[C_TMP], FoobotDataObject.Units[C_TMP]]); if iSensorNum = C_HUM then if (HIGHLOW = C_HIGH) then @@ -442,9 +436,9 @@ begin Format('< %.1f %s', [double(FooBotTriggerArray[C_LOW, C_HUM]), FoobotDataObject.Units[C_HUM]]); lbl_yellowlighthum.Caption := - Format('> %.1f %s', [double(REC_HUM), FoobotDataObject.Units[C_HUM]]); + Format('> %.1f %s', [RecommendedLevelsArray[C_HUM], FoobotDataObject.Units[C_HUM]]); lbl_greenlighthum.Caption := - Format('< %.1f %s', [double(REC_HUM), FoobotDataObject.Units[C_HUM]]); + Format('< %.1f %s', [RecommendedLevelsArray[C_HUM], FoobotDataObject.Units[C_HUM]]); if iSensorNum = C_CO2 then if (HIGHLOW = C_HIGH) then @@ -456,9 +450,9 @@ begin Format('< %.0f %s', [double(FooBotTriggerArray[C_LOW, C_CO2]), FoobotDataObject.Units[C_CO2]]); lbl_yellowlightco2.Caption := - Format('> %.0f %s', [double(REC_CO2), FoobotDataObject.Units[C_CO2]]); + Format('> %.0f %s', [RecommendedLevelsArray[C_CO2], FoobotDataObject.Units[C_CO2]]); lbl_greenlightco2.Caption := - Format('< %.0f %s', [double(REC_CO2), FoobotDataObject.Units[C_CO2]]); + Format('< %.0f %s', [RecommendedLevelsArray[C_CO2], FoobotDataObject.Units[C_CO2]]); if iSensorNum = C_VOC then if (HIGHLOW = C_HIGH) then @@ -470,9 +464,9 @@ begin Format('< %.0f %s', [double(FooBotTriggerArray[C_LOW, C_VOC]), FoobotDataObject.Units[C_VOC]]); lbl_yellowlightvoc.Caption := - Format('> %.0f %s', [double(REC_VOC), FoobotDataObject.Units[C_VOC]]); + Format('> %.0f %s', [RecommendedLevelsArray[C_VOC], FoobotDataObject.Units[C_VOC]]); lbl_greenlightvoc.Caption := - Format('< %.0f %s', [double(REC_VOC), FoobotDataObject.Units[C_VOC]]); + Format('< %.0f %s', [RecommendedLevelsArray[C_VOC], FoobotDataObject.Units[C_VOC]]); if iSensorNum = C_ALLPOLLU then if (HIGHLOW = C_HIGH) then @@ -484,9 +478,9 @@ begin Format('< %.1f %s', [double(FooBotTriggerArray[C_LOW, C_ALLPOLLU]), FoobotDataObject.Units[C_ALLPOLLU]]); lbl_yellowlightallpollu.Caption := - Format('> %.1f %s', [double(REC_ALLPOLLU), FoobotDataObject.Units[C_ALLPOLLU]]); + Format('> %.1f %s', [RecommendedLevelsArray[C_ALLPOLLU], FoobotDataObject.Units[C_ALLPOLLU]]); lbl_greenlightallpollu.Caption := - Format('< %.1f %s', [double(REC_ALLPOLLU), FoobotDataObject.Units[C_ALLPOLLU]]); + Format('< %.1f %s', [RecommendedLevelsArray[C_ALLPOLLU], FoobotDataObject.Units[C_ALLPOLLU]]); end; procedure Tmainform.PopulateFoobotMenu; @@ -519,6 +513,7 @@ begin SaveConfig; // to .cfg file if UseTriggers then SaveTriggers; // To .ini file + SaveRecommendedLevels; CloseAction := caFree; end; @@ -881,12 +876,12 @@ procedure Tmainform.SetYellowRecommendedLevels; begin if bDisplayYellowLines = True then begin - as_pm.ValueYellow := REC_PM; - as_tmp.ValueYellow := REC_TMP; - as_hum.ValueYellow := REC_HUM; - as_co2.ValueYellow := REC_CO2; - as_voc.ValueYellow := REC_VOC; - as_allpollu.ValueYellow := REC_ALLPOLLU; + as_pm.ValueYellow := RecommendedLevelsArray[C_PM]; + as_tmp.ValueYellow := RecommendedLevelsArray[C_TMP]; + as_hum.ValueYellow := RecommendedLevelsArray[C_HUM]; + as_co2.ValueYellow := RecommendedLevelsArray[C_CO2]; + as_voc.ValueYellow := RecommendedLevelsArray[C_VOC]; + as_allpollu.ValueYellow := RecommendedLevelsArray[C_ALLPOLLU]; end else begin @@ -1059,32 +1054,32 @@ end; procedure Tmainform.UpdateHealth; begin - if (as_pm.Value >= REC_PM) then + if (as_pm.Value >= RecommendedLevelsArray[C_PM]) then sls_pm.State := slYELLOW else sls_pm.State := slGREEN; - if (as_tmp.Value >= REC_TMP) then + if (as_tmp.Value >= RecommendedLevelsArray[C_TMP]) then sls_tmp.State := slYELLOW else sls_tmp.State := slGREEN; - if (as_hum.Value >= REC_HUM) then + if (as_hum.Value >= RecommendedLevelsArray[C_HUM]) then sls_hum.State := slYELLOW else sls_hum.State := slGREEN; - if (as_co2.Value >= REC_CO2) then + if (as_co2.Value >= RecommendedLevelsArray[C_CO2]) then sls_co2.State := slYELLOW else sls_co2.State := slGREEN; - if (as_voc.Value >= REC_VOC) then + if (as_voc.Value >= RecommendedLevelsArray[C_VOC]) then sls_voc.State := slYELLOW else sls_voc.State := slGREEN; - if (as_allpollu.Value >= REC_ALLPOLLU) then + if (as_allpollu.Value >= RecommendedLevelsArray[C_ALLPOLLU]) then sls_allpollu.State := slYELLOW else sls_allpollu.State := slGREEN; diff --git a/applications/foobot/monitor/utriggersform.lfm b/applications/foobot/monitor/utriggersform.lfm index ebf87eff1..4c32604d3 100644 --- a/applications/foobot/monitor/utriggersform.lfm +++ b/applications/foobot/monitor/utriggersform.lfm @@ -1,7 +1,7 @@ object triggersform: Ttriggersform - Left = 478 + Left = 808 Height = 565 - Top = 162 + Top = 146 Width = 794 ActiveControl = edt_newrec_pm BorderIcons = [biSystemMenu] @@ -114,7 +114,7 @@ object triggersform: Ttriggersform Top = 0 Width = 72 BorderStyle = bsNone - OnKeyPress = OnlyNumericKeyPress + OnKeyPress = OnlyNumericKeyPressFloat ParentFont = False TabOrder = 0 Text = '0.00' @@ -125,7 +125,7 @@ object triggersform: Ttriggersform Top = 20 Width = 72 BorderStyle = bsNone - OnKeyPress = OnlyNumericKeyPress + OnKeyPress = OnlyNumericKeyPressFloat ParentFont = False TabOrder = 1 Text = '0.00' @@ -136,7 +136,7 @@ object triggersform: Ttriggersform Top = 40 Width = 72 BorderStyle = bsNone - OnKeyPress = OnlyNumericKeyPress + OnKeyPress = OnlyNumericKeyPressFloat ParentFont = False TabOrder = 2 Text = '0.00' @@ -251,7 +251,7 @@ object triggersform: Ttriggersform Top = 0 Width = 72 BorderStyle = bsNone - OnKeyPress = OnlyNumericKeyPress + OnKeyPress = OnlyNumericKeyPressFloat ParentFont = False TabOrder = 0 Text = '0.00' @@ -262,7 +262,7 @@ object triggersform: Ttriggersform Top = 20 Width = 72 BorderStyle = bsNone - OnKeyPress = OnlyNumericKeyPress + OnKeyPress = OnlyNumericKeyPressFloat ParentFont = False TabOrder = 1 Text = '0.00' @@ -273,7 +273,7 @@ object triggersform: Ttriggersform Top = 40 Width = 72 BorderStyle = bsNone - OnKeyPress = OnlyNumericKeyPress + OnKeyPress = OnlyNumericKeyPressFloat ParentFont = False TabOrder = 2 Text = '0.00' @@ -388,10 +388,10 @@ object triggersform: Ttriggersform Top = 0 Width = 72 BorderStyle = bsNone - OnKeyPress = OnlyNumericKeyPress + OnKeyPress = OnlyNumericKeyPressInteger ParentFont = False TabOrder = 0 - Text = '0.00' + Text = '0' end object edt_newhightrigger_voc: TEdit Left = 504 @@ -399,10 +399,10 @@ object triggersform: Ttriggersform Top = 20 Width = 72 BorderStyle = bsNone - OnKeyPress = OnlyNumericKeyPress + OnKeyPress = OnlyNumericKeyPressInteger ParentFont = False TabOrder = 1 - Text = '0.00' + Text = '0' end object edt_newlowtrigger_voc: TEdit Left = 504 @@ -410,10 +410,10 @@ object triggersform: Ttriggersform Top = 40 Width = 72 BorderStyle = bsNone - OnKeyPress = OnlyNumericKeyPress + OnKeyPress = OnlyNumericKeyPressInteger ParentFont = False TabOrder = 2 - Text = '0.00' + Text = '0' end object lbl_currentrecunits_voc: TLabel Left = 584 @@ -525,10 +525,10 @@ object triggersform: Ttriggersform Top = 0 Width = 72 BorderStyle = bsNone - OnKeyPress = OnlyNumericKeyPress + OnKeyPress = OnlyNumericKeyPressInteger ParentFont = False TabOrder = 0 - Text = '0.00' + Text = '0' end object edt_newhightrigger_co2: TEdit Left = 504 @@ -536,10 +536,10 @@ object triggersform: Ttriggersform Top = 20 Width = 72 BorderStyle = bsNone - OnKeyPress = OnlyNumericKeyPress + OnKeyPress = OnlyNumericKeyPressInteger ParentFont = False TabOrder = 1 - Text = '0.00' + Text = '0' end object edt_newlowtrigger_co2: TEdit Left = 504 @@ -547,10 +547,10 @@ object triggersform: Ttriggersform Top = 40 Width = 72 BorderStyle = bsNone - OnKeyPress = OnlyNumericKeyPress + OnKeyPress = OnlyNumericKeyPressInteger ParentFont = False TabOrder = 2 - Text = '0.00' + Text = '0' end object lbl_currentrecunits_co2: TLabel Left = 584 @@ -662,7 +662,7 @@ object triggersform: Ttriggersform Top = 0 Width = 72 BorderStyle = bsNone - OnKeyPress = OnlyNumericKeyPress + OnKeyPress = OnlyNumericKeyPressFloat ParentFont = False TabOrder = 0 Text = '0.00' @@ -673,7 +673,7 @@ object triggersform: Ttriggersform Top = 20 Width = 72 BorderStyle = bsNone - OnKeyPress = OnlyNumericKeyPress + OnKeyPress = OnlyNumericKeyPressFloat ParentFont = False TabOrder = 1 Text = '0.00' @@ -684,7 +684,7 @@ object triggersform: Ttriggersform Top = 40 Width = 72 BorderStyle = bsNone - OnKeyPress = OnlyNumericKeyPress + OnKeyPress = OnlyNumericKeyPressFloat ParentFont = False TabOrder = 2 Text = '0.00' @@ -799,7 +799,7 @@ object triggersform: Ttriggersform Top = 0 Width = 72 BorderStyle = bsNone - OnKeyPress = OnlyNumericKeyPress + OnKeyPress = OnlyNumericKeyPressFloat ParentFont = False TabOrder = 0 Text = '0.00' @@ -810,7 +810,7 @@ object triggersform: Ttriggersform Top = 20 Width = 72 BorderStyle = bsNone - OnKeyPress = OnlyNumericKeyPress + OnKeyPress = OnlyNumericKeyPressFloat ParentFont = False TabOrder = 1 Text = '0.00' @@ -821,7 +821,7 @@ object triggersform: Ttriggersform Top = 40 Width = 72 BorderStyle = bsNone - OnKeyPress = OnlyNumericKeyPress + OnKeyPress = OnlyNumericKeyPressFloat ParentFont = False TabOrder = 2 Text = '0.00' diff --git a/applications/foobot/monitor/utriggersform.pas b/applications/foobot/monitor/utriggersform.pas index 12d7ba245..b211d6a9d 100644 --- a/applications/foobot/monitor/utriggersform.pas +++ b/applications/foobot/monitor/utriggersform.pas @@ -98,11 +98,14 @@ type procedure FormCreate(Sender: TObject); procedure FormDestroy(Sender: TObject); procedure FormShow(Sender: TObject); - procedure OnlyNumericKeyPress(Sender: TObject; var Key: char); + procedure OnlyNumericKeyPressFloat(Sender: TObject; var Key: char); + procedure OnlyNumericKeyPressInteger(Sender: TObject; var Key: char); private ErrorList:TStrings; procedure DisplayCurrentValues; procedure SetUpUnits; + function AssignAndSaveTriggers:boolean; + function AssignAndSaveRecommendedLevels:boolean; public end; @@ -137,9 +140,15 @@ end; procedure Ttriggersform.cmd_OKClick(Sender: TObject); begin // VerifyEveryThing then Save to inifiles; + AssignAndSaveTriggers; end; -procedure Ttriggersform.OnlyNumericKeyPress(Sender: TObject; var Key: char); +procedure Ttriggersform.OnlyNumericKeyPressInteger(Sender: TObject; var Key: char); +begin + if not (Key in ['0'..'9', #8, #9]) then Key := #0; +end; + +procedure Ttriggersform.OnlyNumericKeyPressFloat(Sender: TObject; var Key: char); begin if not (Key in ['0'..'9', '.', #8, #9]) then Key := #0; end; @@ -152,6 +161,47 @@ begin ErrorList.Clear; Update; end; +function Ttriggersform.AssignAndSaveTriggers:boolean; +begin + Result:=FALSE; + TRY + FooBotTriggerArray[C_HIGH, C_PM]:=StrToFloat(edt_newhightrigger_pm.text); + FooBotTriggerArray[C_LOW, C_PM]:=StrToFloat(edt_newlowtrigger_pm.text); + FooBotTriggerArray[C_HIGH, C_TMP]:=StrToFloat(edt_newhightrigger_tmp.text); + FooBotTriggerArray[C_LOW, C_TMP]:=StrToFloat(edt_newlowtrigger_tmp.text); + FooBotTriggerArray[C_HIGH, C_HUM]:=StrToFloat(edt_newhightrigger_hum.text); + FooBotTriggerArray[C_LOW, C_HUM]:=StrToFloat(edt_newlowtrigger_hum.text); + FooBotTriggerArray[C_HIGH, C_CO2]:=StrToInt(edt_newhightrigger_co2.text); + FooBotTriggerArray[C_LOW, C_CO2]:=StrToInt(edt_newlowtrigger_co2.text); + FooBotTriggerArray[C_HIGH, C_VOC]:=StrToInt(edt_newhightrigger_voc.text); + FooBotTriggerArray[C_LOW, C_VOC]:=StrToInt(edt_newlowtrigger_voc.text); + FooBotTriggerArray[C_HIGH, C_ALLPOLLU]:=StrToFloat(edt_newhightrigger_allpollu.text); + FooBotTriggerArray[C_LOW, C_ALLPOLLU]:=StrToFloat(edt_newlowtrigger_allpollu.text); + except + raise exception.create('Error in AssignAndSaveTriggers'); + Exit; + end; + If NOT SaveTriggers then ErrorList.Add('Unable to save new triggers to disk') + else Result:=TRUE; +end; + +function Ttriggersform.AssignAndSaveRecommendedLevels:boolean; +begin + Result:=FALSE; + TRY + RecommendedLevelsArray[C_PM]:=StrToFloat(edt_newrec_pm.Text); + RecommendedLevelsArray[C_TMP]:=StrToFloat(edt_newrec_tmp.Text); + RecommendedLevelsArray[C_HUM]:=StrToFloat(edt_newrec_hum.Text); + RecommendedLevelsArray[C_CO2]:=StrToFloat(edt_newrec_co2.Text); + RecommendedLevelsArray[C_VOC]:=StrToFloat(edt_newrec_voc.Text); + RecommendedLevelsArray[C_ALLPOLLU]:=StrToFloat(edt_newrec_allpollu.Text); + except + raise exception.create('Error in AssignAndSaveRecommendedLevels'); + Exit; + end; + If NOT SaveRecommendedLevels then ErrorList.Add('Unable to save new recommended levels to disk') + else Result:=TRUE; +end; procedure Ttriggersform.DisplayCurrentValues; begin @@ -188,10 +238,10 @@ begin Format('Current high trigger: %.1f %s', [double(FooBotTriggerArray[C_HIGH, C_HUM]), FoobotDataObject.Units[C_HUM]]); lbl_currenthightrigger_co2.Caption := - Format('Current high trigger: %.1f %s', + Format('Current high trigger: %.0f %s', [double(FooBotTriggerArray[C_HIGH, C_CO2]), FoobotDataObject.Units[C_CO2]]); lbl_currenthightrigger_voc.Caption := - Format('Current high trigger: %.1f %s', + Format('Current high trigger: %.0f %s', [double(FooBotTriggerArray[C_HIGH, C_VOC]), FoobotDataObject.Units[C_VOC]]); lbl_currenthightrigger_allpollu.Caption := Format('Current high trigger: %.1f %s', @@ -208,10 +258,10 @@ begin Format('Current low trigger: %.1f %s', [double(FooBotTriggerArray[C_LOW, C_HUM]), FoobotDataObject.Units[C_HUM]]); lbl_currentlowtrigger_co2.Caption := - Format('Current low trigger: %.1f %s', + Format('Current low trigger: %.0f %s', [double(FooBotTriggerArray[C_LOW, C_CO2]), FoobotDataObject.Units[C_CO2]]); lbl_currentlowtrigger_voc.Caption := - Format('Current low trigger: %.1f %s', + Format('Current low trigger: %.0f %s', [double(FooBotTriggerArray[C_LOW, C_VOC]), FoobotDataObject.Units[C_VOC]]); lbl_currentlowtrigger_allpollu.Caption := Format('Current low trigger: %.1f %s',