V0.2.2.0: Work-in progress. Load/Save routines done, ToDo: integrate triggerform into app

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5617 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
gbamber
2017-01-10 05:39:06 +00:00
parent a6ba417169
commit fe93b37050
6 changed files with 268 additions and 151 deletions

View File

@ -52,6 +52,13 @@ const
// Used in Trigger functions // Used in Trigger functions
C_HIGH = 0; C_HIGH = 0;
C_LOW = 1; 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 type
TDataFetchType = (dfLast, dfStartEnd); // FetchFoobotData TDataFetchType = (dfLast, dfStartEnd); // FetchFoobotData
@ -67,6 +74,8 @@ type
AlertType: Integer; AlertType: Integer;
AlertValue: variant; AlertValue: variant;
end; end;
var
RecommendedLevelsArray:Array[C_PM..C_ALLPOLLU] of Double;
function EncodeStringBase64(const s: string): string; function EncodeStringBase64(const s: string): string;
function FetchAuthenticationKey(aUsername, aUserPassword: string): boolean; function FetchAuthenticationKey(aUsername, aUserPassword: string): boolean;
@ -99,7 +108,8 @@ function SaveHighLows: boolean;
function LoadHighLows: boolean; function LoadHighLows: boolean;
function SaveTriggers: boolean; function SaveTriggers: boolean;
function LoadTriggers: boolean; function LoadTriggers: boolean;
function SaveRecommendedLevels:boolean;
function LoadRecommendedLevels:boolean;
var var
// Used to fetch server data // Used to fetch server data
HttpClient: TFPHTTPClient; HttpClient: TFPHTTPClient;
@ -230,6 +240,68 @@ begin
end; end;
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; function SaveHighLows: boolean;
// Save values to an INI data file // Save values to an INI data file
// To foobotmonitor.ini // To foobotmonitor.ini

View File

@ -3,14 +3,14 @@
<ProjectSession> <ProjectSession>
<PathDelim Value="\"/> <PathDelim Value="\"/>
<Version Value="10"/> <Version Value="10"/>
<BuildModes Active="win32"/> <BuildModes Active="win64"/>
<Units Count="34"> <Units Count="34">
<Unit0> <Unit0>
<Filename Value="foobotmonitor.lpr"/> <Filename Value="foobotmonitor.lpr"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<EditorIndex Value="12"/> <EditorIndex Value="12"/>
<CursorPos Y="35"/> <CursorPos Y="35"/>
<UsageCount Value="127"/> <UsageCount Value="148"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit0> </Unit0>
<Unit1> <Unit1>
@ -19,9 +19,9 @@
<ComponentName Value="mainform"/> <ComponentName Value="mainform"/>
<HasResources Value="True"/> <HasResources Value="True"/>
<ResourceBaseClass Value="Form"/> <ResourceBaseClass Value="Form"/>
<TopLine Value="774"/> <TopLine Value="511"/>
<CursorPos X="66" Y="776"/> <CursorPos X="25" Y="516"/>
<UsageCount Value="127"/> <UsageCount Value="148"/>
<Loaded Value="True"/> <Loaded Value="True"/>
<LoadedDesigner Value="True"/> <LoadedDesigner Value="True"/>
</Unit1> </Unit1>
@ -34,7 +34,7 @@
<EditorIndex Value="7"/> <EditorIndex Value="7"/>
<TopLine Value="33"/> <TopLine Value="33"/>
<CursorPos X="41" Y="45"/> <CursorPos X="41" Y="45"/>
<UsageCount Value="117"/> <UsageCount Value="138"/>
<Loaded Value="True"/> <Loaded Value="True"/>
<LoadedDesigner Value="True"/> <LoadedDesigner Value="True"/>
</Unit2> </Unit2>
@ -44,7 +44,7 @@
<EditorIndex Value="1"/> <EditorIndex Value="1"/>
<TopLine Value="13"/> <TopLine Value="13"/>
<CursorPos X="49" Y="20"/> <CursorPos X="49" Y="20"/>
<UsageCount Value="109"/> <UsageCount Value="130"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit3> </Unit3>
<Unit4> <Unit4>
@ -54,15 +54,15 @@
<WindowIndex Value="-1"/> <WindowIndex Value="-1"/>
<TopLine Value="-1"/> <TopLine Value="-1"/>
<CursorPos X="-1" Y="-1"/> <CursorPos X="-1" Y="-1"/>
<UsageCount Value="109"/> <UsageCount Value="130"/>
</Unit4> </Unit4>
<Unit5> <Unit5>
<Filename Value="..\foobot_utility.pas"/> <Filename Value="..\foobot_utility.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<EditorIndex Value="9"/> <EditorIndex Value="9"/>
<TopLine Value="129"/> <TopLine Value="241"/>
<CursorPos X="49" Y="212"/> <CursorPos X="31" Y="243"/>
<UsageCount Value="127"/> <UsageCount Value="148"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit5> </Unit5>
<Unit6> <Unit6>
@ -72,7 +72,7 @@
<WindowIndex Value="-1"/> <WindowIndex Value="-1"/>
<TopLine Value="-1"/> <TopLine Value="-1"/>
<CursorPos X="-1" Y="-1"/> <CursorPos X="-1" Y="-1"/>
<UsageCount Value="109"/> <UsageCount Value="130"/>
</Unit6> </Unit6>
<Unit7> <Unit7>
<Filename Value="foobot_sensors.pas"/> <Filename Value="foobot_sensors.pas"/>
@ -80,7 +80,7 @@
<EditorIndex Value="-1"/> <EditorIndex Value="-1"/>
<TopLine Value="299"/> <TopLine Value="299"/>
<CursorPos X="14" Y="321"/> <CursorPos X="14" Y="321"/>
<UsageCount Value="61"/> <UsageCount Value="82"/>
</Unit7> </Unit7>
<Unit8> <Unit8>
<Filename Value="usplash.pas"/> <Filename Value="usplash.pas"/>
@ -90,7 +90,7 @@
<ResourceBaseClass Value="Form"/> <ResourceBaseClass Value="Form"/>
<EditorIndex Value="3"/> <EditorIndex Value="3"/>
<CursorPos X="48" Y="37"/> <CursorPos X="48" Y="37"/>
<UsageCount Value="56"/> <UsageCount Value="77"/>
<Loaded Value="True"/> <Loaded Value="True"/>
<LoadedDesigner Value="True"/> <LoadedDesigner Value="True"/>
</Unit8> </Unit8>
@ -102,9 +102,9 @@
<ResourceBaseClass Value="Form"/> <ResourceBaseClass Value="Form"/>
<IsVisibleTab Value="True"/> <IsVisibleTab Value="True"/>
<EditorIndex Value="2"/> <EditorIndex Value="2"/>
<TopLine Value="137"/> <TopLine Value="151"/>
<CursorPos X="45" Y="139"/> <CursorPos X="44" Y="165"/>
<UsageCount Value="47"/> <UsageCount Value="68"/>
<Loaded Value="True"/> <Loaded Value="True"/>
<LoadedDesigner Value="True"/> <LoadedDesigner Value="True"/>
</Unit9> </Unit9>
@ -113,7 +113,7 @@
<EditorIndex Value="8"/> <EditorIndex Value="8"/>
<TopLine Value="43"/> <TopLine Value="43"/>
<CursorPos X="47" Y="13"/> <CursorPos X="47" Y="13"/>
<UsageCount Value="78"/> <UsageCount Value="89"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit10> </Unit10>
<Unit11> <Unit11>
@ -121,7 +121,7 @@
<EditorIndex Value="11"/> <EditorIndex Value="11"/>
<TopLine Value="141"/> <TopLine Value="141"/>
<CursorPos X="31" Y="148"/> <CursorPos X="31" Y="148"/>
<UsageCount Value="78"/> <UsageCount Value="89"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit11> </Unit11>
<Unit12> <Unit12>
@ -130,12 +130,12 @@
<WindowIndex Value="-1"/> <WindowIndex Value="-1"/>
<TopLine Value="-1"/> <TopLine Value="-1"/>
<CursorPos X="-1" Y="-1"/> <CursorPos X="-1" Y="-1"/>
<UsageCount Value="33"/> <UsageCount Value="31"/>
</Unit12> </Unit12>
<Unit13> <Unit13>
<Filename Value="..\latest_stable\umainform.lfm"/> <Filename Value="..\latest_stable\umainform.lfm"/>
<EditorIndex Value="-1"/> <EditorIndex Value="-1"/>
<UsageCount Value="5"/> <UsageCount Value="3"/>
<DefaultSyntaxHighlighter Value="LFM"/> <DefaultSyntaxHighlighter Value="LFM"/>
</Unit13> </Unit13>
<Unit14> <Unit14>
@ -143,21 +143,21 @@
<EditorIndex Value="-1"/> <EditorIndex Value="-1"/>
<TopLine Value="10"/> <TopLine Value="10"/>
<CursorPos X="57" Y="36"/> <CursorPos X="57" Y="36"/>
<UsageCount Value="5"/> <UsageCount Value="3"/>
</Unit14> </Unit14>
<Unit15> <Unit15>
<Filename Value="..\udataform.pas"/> <Filename Value="..\udataform.pas"/>
<EditorIndex Value="-1"/> <EditorIndex Value="-1"/>
<TopLine Value="74"/> <TopLine Value="74"/>
<CursorPos Y="96"/> <CursorPos Y="96"/>
<UsageCount Value="13"/> <UsageCount Value="11"/>
</Unit15> </Unit15>
<Unit16> <Unit16>
<Filename Value="..\umainform.pas"/> <Filename Value="..\umainform.pas"/>
<EditorIndex Value="-1"/> <EditorIndex Value="-1"/>
<TopLine Value="145"/> <TopLine Value="145"/>
<CursorPos X="81" Y="158"/> <CursorPos X="81" Y="158"/>
<UsageCount Value="41"/> <UsageCount Value="39"/>
</Unit16> </Unit16>
<Unit17> <Unit17>
<Filename Value="C:\trunklatest\lazarus\lcl\lclmessageglue.pas"/> <Filename Value="C:\trunklatest\lazarus\lcl\lclmessageglue.pas"/>
@ -165,26 +165,26 @@
<EditorIndex Value="-1"/> <EditorIndex Value="-1"/>
<TopLine Value="93"/> <TopLine Value="93"/>
<CursorPos Y="114"/> <CursorPos Y="114"/>
<UsageCount Value="5"/> <UsageCount Value="3"/>
</Unit17> </Unit17>
<Unit18> <Unit18>
<Filename Value="..\ulogin.pas"/> <Filename Value="..\ulogin.pas"/>
<EditorIndex Value="-1"/> <EditorIndex Value="-1"/>
<CursorPos Y="108"/> <CursorPos Y="108"/>
<UsageCount Value="8"/> <UsageCount Value="6"/>
</Unit18> </Unit18>
<Unit19> <Unit19>
<Filename Value="..\..\..\components\cryptini\latest_stable\ucryptini.pas"/> <Filename Value="..\..\..\components\cryptini\latest_stable\ucryptini.pas"/>
<EditorIndex Value="-1"/> <EditorIndex Value="-1"/>
<TopLine Value="906"/> <TopLine Value="906"/>
<CursorPos X="8" Y="939"/> <CursorPos X="8" Y="939"/>
<UsageCount Value="6"/> <UsageCount Value="4"/>
</Unit19> </Unit19>
<Unit20> <Unit20>
<Filename Value="..\backup\foobot_utility.pas"/> <Filename Value="..\backup\foobot_utility.pas"/>
<EditorIndex Value="-1"/> <EditorIndex Value="-1"/>
<TopLine Value="7"/> <TopLine Value="7"/>
<UsageCount Value="5"/> <UsageCount Value="3"/>
</Unit20> </Unit20>
<Unit21> <Unit21>
<Filename Value="C:\trunklatest\lazarus\ide\lazarus.pp"/> <Filename Value="C:\trunklatest\lazarus\ide\lazarus.pp"/>
@ -192,7 +192,7 @@
<EditorIndex Value="5"/> <EditorIndex Value="5"/>
<TopLine Value="101"/> <TopLine Value="101"/>
<CursorPos Y="154"/> <CursorPos Y="154"/>
<UsageCount Value="29"/> <UsageCount Value="40"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit21> </Unit21>
<Unit22> <Unit22>
@ -200,35 +200,35 @@
<EditorIndex Value="-1"/> <EditorIndex Value="-1"/>
<TopLine Value="11"/> <TopLine Value="11"/>
<CursorPos X="8" Y="33"/> <CursorPos X="8" Y="33"/>
<UsageCount Value="6"/> <UsageCount Value="4"/>
</Unit22> </Unit22>
<Unit23> <Unit23>
<Filename Value="D:\Lazarusprojects\healthmonitor\svn\healthanalysis\healthanalysis\umainform.pas"/> <Filename Value="D:\Lazarusprojects\healthmonitor\svn\healthanalysis\healthanalysis\umainform.pas"/>
<EditorIndex Value="-1"/> <EditorIndex Value="-1"/>
<TopLine Value="540"/> <TopLine Value="540"/>
<CursorPos X="55" Y="593"/> <CursorPos X="55" Y="593"/>
<UsageCount Value="6"/> <UsageCount Value="4"/>
</Unit23> </Unit23>
<Unit24> <Unit24>
<Filename Value="C:\trunklatest\fpc\rtl\objpas\sysutils\datih.inc"/> <Filename Value="C:\trunklatest\fpc\rtl\objpas\sysutils\datih.inc"/>
<EditorIndex Value="-1"/> <EditorIndex Value="-1"/>
<TopLine Value="109"/> <TopLine Value="109"/>
<CursorPos X="10" Y="128"/> <CursorPos X="10" Y="128"/>
<UsageCount Value="5"/> <UsageCount Value="3"/>
</Unit24> </Unit24>
<Unit25> <Unit25>
<Filename Value="C:\trunklatest\fpc\packages\rtl-objpas\src\inc\dateutil.inc"/> <Filename Value="C:\trunklatest\fpc\packages\rtl-objpas\src\inc\dateutil.inc"/>
<EditorIndex Value="10"/> <EditorIndex Value="10"/>
<TopLine Value="381"/> <TopLine Value="381"/>
<CursorPos X="13" Y="384"/> <CursorPos X="13" Y="384"/>
<UsageCount Value="47"/> <UsageCount Value="58"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit25> </Unit25>
<Unit26> <Unit26>
<Filename Value="..\latest_stable\udataform.pas"/> <Filename Value="..\latest_stable\udataform.pas"/>
<EditorIndex Value="6"/> <EditorIndex Value="6"/>
<TopLine Value="70"/> <TopLine Value="70"/>
<UsageCount Value="47"/> <UsageCount Value="58"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit26> </Unit26>
<Unit27> <Unit27>
@ -236,20 +236,20 @@
<EditorIndex Value="-1"/> <EditorIndex Value="-1"/>
<TopLine Value="781"/> <TopLine Value="781"/>
<CursorPos X="28" Y="795"/> <CursorPos X="28" Y="795"/>
<UsageCount Value="20"/> <UsageCount Value="18"/>
</Unit27> </Unit27>
<Unit28> <Unit28>
<Filename Value="C:\trunklatest\fpc\packages\fcl-base\src\fileinfo.pp"/> <Filename Value="C:\trunklatest\fpc\packages\fcl-base\src\fileinfo.pp"/>
<EditorIndex Value="-1"/> <EditorIndex Value="-1"/>
<TopLine Value="43"/> <TopLine Value="43"/>
<CursorPos X="19" Y="51"/> <CursorPos X="19" Y="51"/>
<UsageCount Value="9"/> <UsageCount Value="7"/>
</Unit28> </Unit28>
<Unit29> <Unit29>
<Filename Value="C:\trunklatest\lazarus\components\IndustrialStuff\industrial.pas"/> <Filename Value="C:\trunklatest\lazarus\components\IndustrialStuff\industrial.pas"/>
<EditorIndex Value="-1"/> <EditorIndex Value="-1"/>
<CursorPos X="18" Y="11"/> <CursorPos X="18" Y="11"/>
<UsageCount Value="7"/> <UsageCount Value="5"/>
</Unit29> </Unit29>
<Unit30> <Unit30>
<Filename Value="..\..\..\components\poweredby\latest_stable\upoweredby.pas"/> <Filename Value="..\..\..\components\poweredby\latest_stable\upoweredby.pas"/>
@ -257,14 +257,14 @@
<EditorIndex Value="-1"/> <EditorIndex Value="-1"/>
<TopLine Value="190"/> <TopLine Value="190"/>
<CursorPos X="33" Y="205"/> <CursorPos X="33" Y="205"/>
<UsageCount Value="17"/> <UsageCount Value="15"/>
</Unit30> </Unit30>
<Unit31> <Unit31>
<Filename Value="C:\trunklatest\lazarus\lcl\include\customform.inc"/> <Filename Value="C:\trunklatest\lazarus\lcl\include\customform.inc"/>
<EditorIndex Value="-1"/> <EditorIndex Value="-1"/>
<TopLine Value="2228"/> <TopLine Value="2228"/>
<CursorPos X="14" Y="2239"/> <CursorPos X="14" Y="2239"/>
<UsageCount Value="7"/> <UsageCount Value="5"/>
</Unit31> </Unit31>
<Unit32> <Unit32>
<Filename Value="C:\trunklatest\lazarus\lcl\graphics.pp"/> <Filename Value="C:\trunklatest\lazarus\lcl\graphics.pp"/>
@ -272,7 +272,7 @@
<EditorIndex Value="4"/> <EditorIndex Value="4"/>
<TopLine Value="1811"/> <TopLine Value="1811"/>
<CursorPos X="13" Y="1834"/> <CursorPos X="13" Y="1834"/>
<UsageCount Value="25"/> <UsageCount Value="36"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit32> </Unit32>
<Unit33> <Unit33>
@ -280,130 +280,130 @@
<EditorIndex Value="-1"/> <EditorIndex Value="-1"/>
<TopLine Value="119"/> <TopLine Value="119"/>
<CursorPos Y="151"/> <CursorPos Y="151"/>
<UsageCount Value="9"/> <UsageCount Value="7"/>
<DefaultSyntaxHighlighter Value="LFM"/> <DefaultSyntaxHighlighter Value="LFM"/>
</Unit33> </Unit33>
</Units> </Units>
<JumpHistory Count="30" HistoryIndex="29"> <JumpHistory Count="30" HistoryIndex="29">
<Position1> <Position1>
<Filename Value="utriggersform.pas"/> <Filename Value="utriggersform.pas"/>
<Caret Line="133" Column="34" TopLine="89"/> <Caret Line="229" TopLine="178"/>
</Position1> </Position1>
<Position2> <Position2>
<Filename Value="utriggersform.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="134" Column="34" TopLine="90"/> <Caret Line="362" Column="22" TopLine="349"/>
</Position2> </Position2>
<Position3> <Position3>
<Filename Value="utriggersform.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="135" Column="34" TopLine="91"/> <Caret Line="539" Column="42" TopLine="524"/>
</Position3> </Position3>
<Position4> <Position4>
<Filename Value="utriggersform.pas"/> <Filename Value="utriggersform.pas"/>
<Caret Line="136" Column="34" TopLine="92"/> <Caret Line="14" Column="5"/>
</Position4> </Position4>
<Position5> <Position5>
<Filename Value="utriggersform.pas"/> <Filename Value="utriggersform.pas"/>
<Caret Line="139" Column="34" TopLine="95"/> <Caret Line="12" Column="15"/>
</Position5> </Position5>
<Position6> <Position6>
<Filename Value="utriggersform.pas"/> <Filename Value="utriggersform.pas"/>
<Caret Line="142" Column="34" TopLine="98"/> <Caret Line="13" Column="26"/>
</Position6> </Position6>
<Position7> <Position7>
<Filename Value="utriggersform.pas"/> <Filename Value="utriggersform.pas"/>
<Caret Line="145" Column="34" TopLine="101"/> <Caret Line="21" Column="18"/>
</Position7> </Position7>
<Position8> <Position8>
<Filename Value="utriggersform.pas"/> <Filename Value="utriggersform.pas"/>
<Caret Line="148" Column="34" TopLine="104"/> <Caret Line="153" Column="20" TopLine="130"/>
</Position8> </Position8>
<Position9> <Position9>
<Filename Value="utriggersform.pas"/> <Filename Value="utriggersform.pas"/>
<Caret Line="151" Column="34" TopLine="107"/> <Caret Line="92" Column="20" TopLine="90"/>
</Position9> </Position9>
<Position10> <Position10>
<Filename Value="utriggersform.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="18" Column="18" TopLine="11"/> <Caret Line="397" Column="17" TopLine="378"/>
</Position10> </Position10>
<Position11> <Position11>
<Filename Value="utriggersform.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="124" Column="6" TopLine="83"/> <Caret Line="745" Column="44" TopLine="698"/>
</Position11> </Position11>
<Position12> <Position12>
<Filename Value="utriggersform.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="101" Column="26" TopLine="74"/> <Caret Line="832" Column="44" TopLine="785"/>
</Position12> </Position12>
<Position13> <Position13>
<Filename Value="utriggersform.pas"/> <Filename Value="utriggersform.pas"/>
<Caret Line="192" Column="36" TopLine="165"/> <Caret Line="138" TopLine="103"/>
</Position13> </Position13>
<Position14> <Position14>
<Filename Value="utriggersform.pas"/> <Filename Value="utriggersform.pas"/>
<Caret Line="229" TopLine="178"/> <Caret Line="137" Column="52" TopLine="110"/>
</Position14> </Position14>
<Position15> <Position15>
<Filename Value="umainform.pas"/> <Filename Value="utriggersform.pas"/>
<Caret Line="362" Column="22" TopLine="349"/> <Caret Line="123" Column="8" TopLine="105"/>
</Position15> </Position15>
<Position16> <Position16>
<Filename Value="umainform.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="539" Column="42" TopLine="524"/> <Caret Line="279" Column="11" TopLine="261"/>
</Position16> </Position16>
<Position17> <Position17>
<Filename Value="utriggersform.pas"/> <Filename Value="utriggersform.pas"/>
<Caret Line="14" Column="5"/> <Caret Line="153" Column="43" TopLine="134"/>
</Position17> </Position17>
<Position18> <Position18>
<Filename Value="utriggersform.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="12" Column="15"/> <Caret Line="78" Column="9" TopLine="45"/>
</Position18> </Position18>
<Position19> <Position19>
<Filename Value="utriggersform.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="13" Column="26"/> <Caret Line="417" Column="39" TopLine="370"/>
</Position19> </Position19>
<Position20> <Position20>
<Filename Value="utriggersform.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="21" Column="18"/> <Caret Line="419" Column="39" TopLine="372"/>
</Position20> </Position20>
<Position21> <Position21>
<Filename Value="utriggersform.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="153" Column="20" TopLine="130"/> <Caret Line="884" Column="32" TopLine="837"/>
</Position21> </Position21>
<Position22> <Position22>
<Filename Value="utriggersform.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="92" Column="20" TopLine="90"/> <Caret Line="1062" Column="28" TopLine="1015"/>
</Position22> </Position22>
<Position23> <Position23>
<Filename Value="umainform.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="397" Column="17" TopLine="378"/> <Caret Line="77" TopLine="51"/>
</Position23> </Position23>
<Position24> <Position24>
<Filename Value="umainform.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="745" Column="44" TopLine="698"/> <Caret Line="3" Column="7"/>
</Position24> </Position24>
<Position25> <Position25>
<Filename Value="umainform.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="832" Column="44" TopLine="785"/> <Caret Line="30" Column="20" TopLine="28"/>
</Position25> </Position25>
<Position26> <Position26>
<Filename Value="utriggersform.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="138" TopLine="103"/> <Caret Line="883" Column="65" TopLine="852"/>
</Position26> </Position26>
<Position27> <Position27>
<Filename Value="utriggersform.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="137" Column="52" TopLine="110"/> <Caret Line="1080" Column="61" TopLine="1036"/>
</Position27> </Position27>
<Position28> <Position28>
<Filename Value="utriggersform.pas"/> <Filename Value="..\foobot_utility.pas"/>
<Caret Line="123" Column="8" TopLine="105"/> <Caret Line="277" TopLine="241"/>
</Position28> </Position28>
<Position29> <Position29>
<Filename Value="umainform.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="279" Column="11" TopLine="261"/> <Caret Line="476" Column="65" TopLine="457"/>
</Position29> </Position29>
<Position30> <Position30>
<Filename Value="utriggersform.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="153" Column="43" TopLine="134"/> <Caret Line="448" Column="8" TopLine="445"/>
</Position30> </Position30>
</JumpHistory> </JumpHistory>
</ProjectSession> </ProjectSession>

View File

@ -808,7 +808,7 @@ object mainform: Tmainform
Caption = 'Display...' Caption = 'Display...'
object mnu_optionsDisplayGuagesOnly: TMenuItem object mnu_optionsDisplayGuagesOnly: TMenuItem
AutoCheck = True AutoCheck = True
Caption = 'Guages only' Caption = 'Minimal view'
OnClick = mnu_optionsDisplayGuagesOnlyClick OnClick = mnu_optionsDisplayGuagesOnlyClick
end end
object mnu_optionsDisplayYellowLines: TMenuItem object mnu_optionsDisplayYellowLines: TMenuItem

View File

@ -74,13 +74,6 @@ const
MIN_ALLPOLLU = 0; MIN_ALLPOLLU = 0;
MAX_ALLPOLLU = 700; 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 type
@ -343,6 +336,7 @@ begin
LoadTriggers; // This can only be done if we have a Foobot Identity LoadTriggers; // This can only be done if we have a Foobot Identity
// as each Foobot has its own trigger values // as each Foobot has its own trigger values
SetMinMaxTriggers; // Adjust if necesarry for preset Guage High/Low limits SetMinMaxTriggers; // Adjust if necesarry for preset Guage High/Low limits
LoadRecommendedLevels; // into RecommendedLevelsArray
for iCount := C_PM to C_ALLPOLLU do for iCount := C_PM to C_ALLPOLLU do
SetTrafficLightStats(iCount, C_HIGH); SetTrafficLightStats(iCount, C_HIGH);
Show; Show;
@ -414,9 +408,9 @@ begin
Format('< %.1f %s', [double(FooBotTriggerArray[C_LOW, C_PM]), Format('< %.1f %s', [double(FooBotTriggerArray[C_LOW, C_PM]),
FoobotDataObject.Units[C_PM]]); FoobotDataObject.Units[C_PM]]);
lbl_yellowlightpm.Caption := 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 := 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 iSensorNum = C_TMP then
if (HIGHLOW = C_HIGH) then if (HIGHLOW = C_HIGH) then
@ -428,9 +422,9 @@ begin
Format('< %.1f %s', [double(FooBotTriggerArray[C_LOW, C_TMP]), Format('< %.1f %s', [double(FooBotTriggerArray[C_LOW, C_TMP]),
FoobotDataObject.Units[C_TMP]]); FoobotDataObject.Units[C_TMP]]);
lbl_yellowlighttmp.Caption := 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 := 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 iSensorNum = C_HUM then
if (HIGHLOW = C_HIGH) then if (HIGHLOW = C_HIGH) then
@ -442,9 +436,9 @@ begin
Format('< %.1f %s', [double(FooBotTriggerArray[C_LOW, C_HUM]), Format('< %.1f %s', [double(FooBotTriggerArray[C_LOW, C_HUM]),
FoobotDataObject.Units[C_HUM]]); FoobotDataObject.Units[C_HUM]]);
lbl_yellowlighthum.Caption := 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 := 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 iSensorNum = C_CO2 then
if (HIGHLOW = C_HIGH) then if (HIGHLOW = C_HIGH) then
@ -456,9 +450,9 @@ begin
Format('< %.0f %s', [double(FooBotTriggerArray[C_LOW, C_CO2]), Format('< %.0f %s', [double(FooBotTriggerArray[C_LOW, C_CO2]),
FoobotDataObject.Units[C_CO2]]); FoobotDataObject.Units[C_CO2]]);
lbl_yellowlightco2.Caption := 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 := 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 iSensorNum = C_VOC then
if (HIGHLOW = C_HIGH) then if (HIGHLOW = C_HIGH) then
@ -470,9 +464,9 @@ begin
Format('< %.0f %s', [double(FooBotTriggerArray[C_LOW, C_VOC]), Format('< %.0f %s', [double(FooBotTriggerArray[C_LOW, C_VOC]),
FoobotDataObject.Units[C_VOC]]); FoobotDataObject.Units[C_VOC]]);
lbl_yellowlightvoc.Caption := 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 := 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 iSensorNum = C_ALLPOLLU then
if (HIGHLOW = C_HIGH) then if (HIGHLOW = C_HIGH) then
@ -484,9 +478,9 @@ begin
Format('< %.1f %s', [double(FooBotTriggerArray[C_LOW, C_ALLPOLLU]), Format('< %.1f %s', [double(FooBotTriggerArray[C_LOW, C_ALLPOLLU]),
FoobotDataObject.Units[C_ALLPOLLU]]); FoobotDataObject.Units[C_ALLPOLLU]]);
lbl_yellowlightallpollu.Caption := 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 := lbl_greenlightallpollu.Caption :=
Format('< %.1f %s', [double(REC_ALLPOLLU), FoobotDataObject.Units[C_ALLPOLLU]]); Format('< %.1f %s', [RecommendedLevelsArray[C_ALLPOLLU], FoobotDataObject.Units[C_ALLPOLLU]]);
end; end;
procedure Tmainform.PopulateFoobotMenu; procedure Tmainform.PopulateFoobotMenu;
@ -519,6 +513,7 @@ begin
SaveConfig; // to .cfg file SaveConfig; // to .cfg file
if UseTriggers then if UseTriggers then
SaveTriggers; // To .ini file SaveTriggers; // To .ini file
SaveRecommendedLevels;
CloseAction := caFree; CloseAction := caFree;
end; end;
@ -881,12 +876,12 @@ procedure Tmainform.SetYellowRecommendedLevels;
begin begin
if bDisplayYellowLines = True then if bDisplayYellowLines = True then
begin begin
as_pm.ValueYellow := REC_PM; as_pm.ValueYellow := RecommendedLevelsArray[C_PM];
as_tmp.ValueYellow := REC_TMP; as_tmp.ValueYellow := RecommendedLevelsArray[C_TMP];
as_hum.ValueYellow := REC_HUM; as_hum.ValueYellow := RecommendedLevelsArray[C_HUM];
as_co2.ValueYellow := REC_CO2; as_co2.ValueYellow := RecommendedLevelsArray[C_CO2];
as_voc.ValueYellow := REC_VOC; as_voc.ValueYellow := RecommendedLevelsArray[C_VOC];
as_allpollu.ValueYellow := REC_ALLPOLLU; as_allpollu.ValueYellow := RecommendedLevelsArray[C_ALLPOLLU];
end end
else else
begin begin
@ -1059,32 +1054,32 @@ end;
procedure Tmainform.UpdateHealth; procedure Tmainform.UpdateHealth;
begin begin
if (as_pm.Value >= REC_PM) then if (as_pm.Value >= RecommendedLevelsArray[C_PM]) then
sls_pm.State := slYELLOW sls_pm.State := slYELLOW
else else
sls_pm.State := slGREEN; sls_pm.State := slGREEN;
if (as_tmp.Value >= REC_TMP) then if (as_tmp.Value >= RecommendedLevelsArray[C_TMP]) then
sls_tmp.State := slYELLOW sls_tmp.State := slYELLOW
else else
sls_tmp.State := slGREEN; sls_tmp.State := slGREEN;
if (as_hum.Value >= REC_HUM) then if (as_hum.Value >= RecommendedLevelsArray[C_HUM]) then
sls_hum.State := slYELLOW sls_hum.State := slYELLOW
else else
sls_hum.State := slGREEN; sls_hum.State := slGREEN;
if (as_co2.Value >= REC_CO2) then if (as_co2.Value >= RecommendedLevelsArray[C_CO2]) then
sls_co2.State := slYELLOW sls_co2.State := slYELLOW
else else
sls_co2.State := slGREEN; sls_co2.State := slGREEN;
if (as_voc.Value >= REC_VOC) then if (as_voc.Value >= RecommendedLevelsArray[C_VOC]) then
sls_voc.State := slYELLOW sls_voc.State := slYELLOW
else else
sls_voc.State := slGREEN; sls_voc.State := slGREEN;
if (as_allpollu.Value >= REC_ALLPOLLU) then if (as_allpollu.Value >= RecommendedLevelsArray[C_ALLPOLLU]) then
sls_allpollu.State := slYELLOW sls_allpollu.State := slYELLOW
else else
sls_allpollu.State := slGREEN; sls_allpollu.State := slGREEN;

View File

@ -1,7 +1,7 @@
object triggersform: Ttriggersform object triggersform: Ttriggersform
Left = 478 Left = 808
Height = 565 Height = 565
Top = 162 Top = 146
Width = 794 Width = 794
ActiveControl = edt_newrec_pm ActiveControl = edt_newrec_pm
BorderIcons = [biSystemMenu] BorderIcons = [biSystemMenu]
@ -114,7 +114,7 @@ object triggersform: Ttriggersform
Top = 0 Top = 0
Width = 72 Width = 72
BorderStyle = bsNone BorderStyle = bsNone
OnKeyPress = OnlyNumericKeyPress OnKeyPress = OnlyNumericKeyPressFloat
ParentFont = False ParentFont = False
TabOrder = 0 TabOrder = 0
Text = '0.00' Text = '0.00'
@ -125,7 +125,7 @@ object triggersform: Ttriggersform
Top = 20 Top = 20
Width = 72 Width = 72
BorderStyle = bsNone BorderStyle = bsNone
OnKeyPress = OnlyNumericKeyPress OnKeyPress = OnlyNumericKeyPressFloat
ParentFont = False ParentFont = False
TabOrder = 1 TabOrder = 1
Text = '0.00' Text = '0.00'
@ -136,7 +136,7 @@ object triggersform: Ttriggersform
Top = 40 Top = 40
Width = 72 Width = 72
BorderStyle = bsNone BorderStyle = bsNone
OnKeyPress = OnlyNumericKeyPress OnKeyPress = OnlyNumericKeyPressFloat
ParentFont = False ParentFont = False
TabOrder = 2 TabOrder = 2
Text = '0.00' Text = '0.00'
@ -251,7 +251,7 @@ object triggersform: Ttriggersform
Top = 0 Top = 0
Width = 72 Width = 72
BorderStyle = bsNone BorderStyle = bsNone
OnKeyPress = OnlyNumericKeyPress OnKeyPress = OnlyNumericKeyPressFloat
ParentFont = False ParentFont = False
TabOrder = 0 TabOrder = 0
Text = '0.00' Text = '0.00'
@ -262,7 +262,7 @@ object triggersform: Ttriggersform
Top = 20 Top = 20
Width = 72 Width = 72
BorderStyle = bsNone BorderStyle = bsNone
OnKeyPress = OnlyNumericKeyPress OnKeyPress = OnlyNumericKeyPressFloat
ParentFont = False ParentFont = False
TabOrder = 1 TabOrder = 1
Text = '0.00' Text = '0.00'
@ -273,7 +273,7 @@ object triggersform: Ttriggersform
Top = 40 Top = 40
Width = 72 Width = 72
BorderStyle = bsNone BorderStyle = bsNone
OnKeyPress = OnlyNumericKeyPress OnKeyPress = OnlyNumericKeyPressFloat
ParentFont = False ParentFont = False
TabOrder = 2 TabOrder = 2
Text = '0.00' Text = '0.00'
@ -388,10 +388,10 @@ object triggersform: Ttriggersform
Top = 0 Top = 0
Width = 72 Width = 72
BorderStyle = bsNone BorderStyle = bsNone
OnKeyPress = OnlyNumericKeyPress OnKeyPress = OnlyNumericKeyPressInteger
ParentFont = False ParentFont = False
TabOrder = 0 TabOrder = 0
Text = '0.00' Text = '0'
end end
object edt_newhightrigger_voc: TEdit object edt_newhightrigger_voc: TEdit
Left = 504 Left = 504
@ -399,10 +399,10 @@ object triggersform: Ttriggersform
Top = 20 Top = 20
Width = 72 Width = 72
BorderStyle = bsNone BorderStyle = bsNone
OnKeyPress = OnlyNumericKeyPress OnKeyPress = OnlyNumericKeyPressInteger
ParentFont = False ParentFont = False
TabOrder = 1 TabOrder = 1
Text = '0.00' Text = '0'
end end
object edt_newlowtrigger_voc: TEdit object edt_newlowtrigger_voc: TEdit
Left = 504 Left = 504
@ -410,10 +410,10 @@ object triggersform: Ttriggersform
Top = 40 Top = 40
Width = 72 Width = 72
BorderStyle = bsNone BorderStyle = bsNone
OnKeyPress = OnlyNumericKeyPress OnKeyPress = OnlyNumericKeyPressInteger
ParentFont = False ParentFont = False
TabOrder = 2 TabOrder = 2
Text = '0.00' Text = '0'
end end
object lbl_currentrecunits_voc: TLabel object lbl_currentrecunits_voc: TLabel
Left = 584 Left = 584
@ -525,10 +525,10 @@ object triggersform: Ttriggersform
Top = 0 Top = 0
Width = 72 Width = 72
BorderStyle = bsNone BorderStyle = bsNone
OnKeyPress = OnlyNumericKeyPress OnKeyPress = OnlyNumericKeyPressInteger
ParentFont = False ParentFont = False
TabOrder = 0 TabOrder = 0
Text = '0.00' Text = '0'
end end
object edt_newhightrigger_co2: TEdit object edt_newhightrigger_co2: TEdit
Left = 504 Left = 504
@ -536,10 +536,10 @@ object triggersform: Ttriggersform
Top = 20 Top = 20
Width = 72 Width = 72
BorderStyle = bsNone BorderStyle = bsNone
OnKeyPress = OnlyNumericKeyPress OnKeyPress = OnlyNumericKeyPressInteger
ParentFont = False ParentFont = False
TabOrder = 1 TabOrder = 1
Text = '0.00' Text = '0'
end end
object edt_newlowtrigger_co2: TEdit object edt_newlowtrigger_co2: TEdit
Left = 504 Left = 504
@ -547,10 +547,10 @@ object triggersform: Ttriggersform
Top = 40 Top = 40
Width = 72 Width = 72
BorderStyle = bsNone BorderStyle = bsNone
OnKeyPress = OnlyNumericKeyPress OnKeyPress = OnlyNumericKeyPressInteger
ParentFont = False ParentFont = False
TabOrder = 2 TabOrder = 2
Text = '0.00' Text = '0'
end end
object lbl_currentrecunits_co2: TLabel object lbl_currentrecunits_co2: TLabel
Left = 584 Left = 584
@ -662,7 +662,7 @@ object triggersform: Ttriggersform
Top = 0 Top = 0
Width = 72 Width = 72
BorderStyle = bsNone BorderStyle = bsNone
OnKeyPress = OnlyNumericKeyPress OnKeyPress = OnlyNumericKeyPressFloat
ParentFont = False ParentFont = False
TabOrder = 0 TabOrder = 0
Text = '0.00' Text = '0.00'
@ -673,7 +673,7 @@ object triggersform: Ttriggersform
Top = 20 Top = 20
Width = 72 Width = 72
BorderStyle = bsNone BorderStyle = bsNone
OnKeyPress = OnlyNumericKeyPress OnKeyPress = OnlyNumericKeyPressFloat
ParentFont = False ParentFont = False
TabOrder = 1 TabOrder = 1
Text = '0.00' Text = '0.00'
@ -684,7 +684,7 @@ object triggersform: Ttriggersform
Top = 40 Top = 40
Width = 72 Width = 72
BorderStyle = bsNone BorderStyle = bsNone
OnKeyPress = OnlyNumericKeyPress OnKeyPress = OnlyNumericKeyPressFloat
ParentFont = False ParentFont = False
TabOrder = 2 TabOrder = 2
Text = '0.00' Text = '0.00'
@ -799,7 +799,7 @@ object triggersform: Ttriggersform
Top = 0 Top = 0
Width = 72 Width = 72
BorderStyle = bsNone BorderStyle = bsNone
OnKeyPress = OnlyNumericKeyPress OnKeyPress = OnlyNumericKeyPressFloat
ParentFont = False ParentFont = False
TabOrder = 0 TabOrder = 0
Text = '0.00' Text = '0.00'
@ -810,7 +810,7 @@ object triggersform: Ttriggersform
Top = 20 Top = 20
Width = 72 Width = 72
BorderStyle = bsNone BorderStyle = bsNone
OnKeyPress = OnlyNumericKeyPress OnKeyPress = OnlyNumericKeyPressFloat
ParentFont = False ParentFont = False
TabOrder = 1 TabOrder = 1
Text = '0.00' Text = '0.00'
@ -821,7 +821,7 @@ object triggersform: Ttriggersform
Top = 40 Top = 40
Width = 72 Width = 72
BorderStyle = bsNone BorderStyle = bsNone
OnKeyPress = OnlyNumericKeyPress OnKeyPress = OnlyNumericKeyPressFloat
ParentFont = False ParentFont = False
TabOrder = 2 TabOrder = 2
Text = '0.00' Text = '0.00'

View File

@ -98,11 +98,14 @@ type
procedure FormCreate(Sender: TObject); procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject); procedure FormDestroy(Sender: TObject);
procedure FormShow(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 private
ErrorList:TStrings; ErrorList:TStrings;
procedure DisplayCurrentValues; procedure DisplayCurrentValues;
procedure SetUpUnits; procedure SetUpUnits;
function AssignAndSaveTriggers:boolean;
function AssignAndSaveRecommendedLevels:boolean;
public public
end; end;
@ -137,9 +140,15 @@ end;
procedure Ttriggersform.cmd_OKClick(Sender: TObject); procedure Ttriggersform.cmd_OKClick(Sender: TObject);
begin begin
// VerifyEveryThing then Save to inifiles; // VerifyEveryThing then Save to inifiles;
AssignAndSaveTriggers;
end; 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 begin
if not (Key in ['0'..'9', '.', #8, #9]) then Key := #0; if not (Key in ['0'..'9', '.', #8, #9]) then Key := #0;
end; end;
@ -152,6 +161,47 @@ begin
ErrorList.Clear; ErrorList.Clear;
Update; Update;
end; 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; procedure Ttriggersform.DisplayCurrentValues;
begin begin
@ -188,10 +238,10 @@ begin
Format('Current high trigger: %.1f %s', Format('Current high trigger: %.1f %s',
[double(FooBotTriggerArray[C_HIGH, C_HUM]), FoobotDataObject.Units[C_HUM]]); [double(FooBotTriggerArray[C_HIGH, C_HUM]), FoobotDataObject.Units[C_HUM]]);
lbl_currenthightrigger_co2.Caption := 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]]); [double(FooBotTriggerArray[C_HIGH, C_CO2]), FoobotDataObject.Units[C_CO2]]);
lbl_currenthightrigger_voc.Caption := 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]]); [double(FooBotTriggerArray[C_HIGH, C_VOC]), FoobotDataObject.Units[C_VOC]]);
lbl_currenthightrigger_allpollu.Caption := lbl_currenthightrigger_allpollu.Caption :=
Format('Current high trigger: %.1f %s', Format('Current high trigger: %.1f %s',
@ -208,10 +258,10 @@ begin
Format('Current low trigger: %.1f %s', Format('Current low trigger: %.1f %s',
[double(FooBotTriggerArray[C_LOW, C_HUM]), FoobotDataObject.Units[C_HUM]]); [double(FooBotTriggerArray[C_LOW, C_HUM]), FoobotDataObject.Units[C_HUM]]);
lbl_currentlowtrigger_co2.Caption := 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]]); [double(FooBotTriggerArray[C_LOW, C_CO2]), FoobotDataObject.Units[C_CO2]]);
lbl_currentlowtrigger_voc.Caption := 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]]); [double(FooBotTriggerArray[C_LOW, C_VOC]), FoobotDataObject.Units[C_VOC]]);
lbl_currentlowtrigger_allpollu.Caption := lbl_currentlowtrigger_allpollu.Caption :=
Format('Current low trigger: %.1f %s', Format('Current low trigger: %.1f %s',