To V0.2.2.0: Traffic light health added. ToDo: Trigger config form

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5613 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
gbamber
2017-01-09 11:34:34 +00:00
parent e60239a6cc
commit c4ef4f5db2
6 changed files with 658 additions and 175 deletions

View File

@ -354,15 +354,31 @@ begin
end; end;
end; end;
// Function to make the Foobot data accessible // Use FoobotDataObjectToArrays function to make the Foobot data accessible
// Also sets the HighLow array values // after a call to FetchFoobotData
// Also sets triggers // * Sets the HighLow array values
// * Sets triggers
{ {
TAlertRec = Record Here's calling code to use the triggers:
Triggered:Boolean; // Process Trigger Alerts on each call to FoobotDataObjectToArrays
AlertTime:TDateTime; if UseTriggers then
AlertType:TAlertType; // Look for alerts in each sensor
AlertValue:Variant; for iCount := C_PM to C_ALLPOLLU do
begin
if (AlertRec[iCount].AlertTriggered=TRUE) then
begin
// Alert found. High or low?
if (AlertRec[iCount].AlertType = C_HIGH) then
begin
// A high alert - do something
DoHighTriggerAlert(iCount,AlertRec[iCount].AlertValue);
end
else
begin
// A low alert - do something
DoLowTriggerAlert(iCount,AlertRec[iCount].AlertValue);
end;
end;
end; end;
} }
function FoobotDataObjectToArrays: boolean; function FoobotDataObjectToArrays: boolean;

View File

@ -23,7 +23,7 @@
<VersionInfo> <VersionInfo>
<UseVersionInfo Value="True"/> <UseVersionInfo Value="True"/>
<MinorVersionNr Value="2"/> <MinorVersionNr Value="2"/>
<RevisionNr Value="1"/> <RevisionNr Value="2"/>
<StringTable Comments="Uses Foobot public API to query Foobot #1" FileDescription="Monitor for Foobot" InternalName="foobotmonitor" LegalCopyright="(c)2016 minesadorada@charcodelvalle.com" LegalTrademarks="Foobot" ProductName="Foobot" ProductVersion="0.0.0.0"/> <StringTable Comments="Uses Foobot public API to query Foobot #1" FileDescription="Monitor for Foobot" InternalName="foobotmonitor" LegalCopyright="(c)2016 minesadorada@charcodelvalle.com" LegalTrademarks="Foobot" ProductName="Foobot" ProductVersion="0.0.0.0"/>
</VersionInfo> </VersionInfo>
<BuildModes Count="6"> <BuildModes Count="6">
@ -97,11 +97,6 @@
</Win32> </Win32>
</Options> </Options>
</Linking> </Linking>
<Other>
<OtherDefines Count="1">
<Define0 Value="DEBUGMODE"/>
</OtherDefines>
</Other>
</CompilerOptions> </CompilerOptions>
</Item3> </Item3>
<Item4 Name="linux32"> <Item4 Name="linux32">

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="33"> <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="114"/> <UsageCount Value="119"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit0> </Unit0>
<Unit1> <Unit1>
@ -19,9 +19,10 @@
<ComponentName Value="mainform"/> <ComponentName Value="mainform"/>
<HasResources Value="True"/> <HasResources Value="True"/>
<ResourceBaseClass Value="Form"/> <ResourceBaseClass Value="Form"/>
<TopLine Value="245"/> <IsVisibleTab Value="True"/>
<CursorPos X="37" Y="264"/> <TopLine Value="1113"/>
<UsageCount Value="114"/> <CursorPos X="86" Y="1135"/>
<UsageCount Value="119"/>
<Loaded Value="True"/> <Loaded Value="True"/>
<LoadedDesigner Value="True"/> <LoadedDesigner Value="True"/>
</Unit1> </Unit1>
@ -34,7 +35,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="104"/> <UsageCount Value="109"/>
<Loaded Value="True"/> <Loaded Value="True"/>
<LoadedDesigner Value="True"/> <LoadedDesigner Value="True"/>
</Unit2> </Unit2>
@ -44,7 +45,7 @@
<EditorIndex Value="-1"/> <EditorIndex Value="-1"/>
<TopLine Value="380"/> <TopLine Value="380"/>
<CursorPos X="35" Y="387"/> <CursorPos X="35" Y="387"/>
<UsageCount Value="96"/> <UsageCount Value="101"/>
</Unit3> </Unit3>
<Unit4> <Unit4>
<Filename Value="..\foobot_objects.pas"/> <Filename Value="..\foobot_objects.pas"/>
@ -53,16 +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="96"/> <UsageCount Value="101"/>
</Unit4> </Unit4>
<Unit5> <Unit5>
<Filename Value="..\foobot_utility.pas"/> <Filename Value="..\foobot_utility.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="9"/> <EditorIndex Value="9"/>
<TopLine Value="395"/> <TopLine Value="123"/>
<CursorPos X="21" Y="426"/> <CursorPos X="49" Y="212"/>
<UsageCount Value="114"/> <UsageCount Value="119"/>
<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="96"/> <UsageCount Value="101"/>
</Unit6> </Unit6>
<Unit7> <Unit7>
<Filename Value="foobot_sensors.pas"/> <Filename Value="foobot_sensors.pas"/>
@ -80,7 +80,7 @@
<EditorIndex Value="4"/> <EditorIndex Value="4"/>
<TopLine Value="299"/> <TopLine Value="299"/>
<CursorPos X="14" Y="321"/> <CursorPos X="14" Y="321"/>
<UsageCount Value="48"/> <UsageCount Value="53"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit7> </Unit7>
<Unit8> <Unit8>
@ -91,7 +91,7 @@
<ResourceBaseClass Value="Form"/> <ResourceBaseClass Value="Form"/>
<EditorIndex Value="2"/> <EditorIndex Value="2"/>
<CursorPos X="42" Y="25"/> <CursorPos X="42" Y="25"/>
<UsageCount Value="43"/> <UsageCount Value="48"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit8> </Unit8>
<Unit9> <Unit9>
@ -101,8 +101,8 @@
<HasResources Value="True"/> <HasResources Value="True"/>
<ResourceBaseClass Value="Form"/> <ResourceBaseClass Value="Form"/>
<EditorIndex Value="1"/> <EditorIndex Value="1"/>
<CursorPos X="57" Y="24"/> <CursorPos X="41" Y="7"/>
<UsageCount Value="34"/> <UsageCount Value="39"/>
<Loaded Value="True"/> <Loaded Value="True"/>
<LoadedDesigner Value="True"/> <LoadedDesigner Value="True"/>
</Unit9> </Unit9>
@ -111,7 +111,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="72"/> <UsageCount Value="74"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit10> </Unit10>
<Unit11> <Unit11>
@ -119,7 +119,7 @@
<EditorIndex Value="11"/> <EditorIndex Value="11"/>
<TopLine Value="143"/> <TopLine Value="143"/>
<CursorPos X="35" Y="59"/> <CursorPos X="35" Y="59"/>
<UsageCount Value="72"/> <UsageCount Value="74"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit11> </Unit11>
<Unit12> <Unit12>
@ -190,7 +190,7 @@
<EditorIndex Value="5"/> <EditorIndex Value="5"/>
<TopLine Value="101"/> <TopLine Value="101"/>
<CursorPos Y="154"/> <CursorPos Y="154"/>
<UsageCount Value="23"/> <UsageCount Value="25"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit21> </Unit21>
<Unit22> <Unit22>
@ -219,14 +219,14 @@
<EditorIndex Value="10"/> <EditorIndex Value="10"/>
<TopLine Value="381"/> <TopLine Value="381"/>
<CursorPos X="13" Y="384"/> <CursorPos X="13" Y="384"/>
<UsageCount Value="41"/> <UsageCount Value="43"/>
<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="41"/> <UsageCount Value="43"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit26> </Unit26>
<Unit27> <Unit27>
@ -270,130 +270,138 @@
<EditorIndex Value="3"/> <EditorIndex Value="3"/>
<TopLine Value="1811"/> <TopLine Value="1811"/>
<CursorPos X="13" Y="1834"/> <CursorPos X="13" Y="1834"/>
<UsageCount Value="19"/> <UsageCount Value="21"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit32> </Unit32>
<Unit33>
<Filename Value="umainform.lfm"/>
<EditorIndex Value="-1"/>
<TopLine Value="119"/>
<CursorPos Y="151"/>
<UsageCount Value="10"/>
<DefaultSyntaxHighlighter Value="LFM"/>
</Unit33>
</Units> </Units>
<JumpHistory Count="30" HistoryIndex="29"> <JumpHistory Count="30" HistoryIndex="29">
<Position1> <Position1>
<Filename Value="umainform.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="634" Column="46" TopLine="606"/> <Caret Line="953" TopLine="920"/>
</Position1> </Position1>
<Position2> <Position2>
<Filename Value="umainform.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="2" Column="59"/> <Caret Line="929" Column="17" TopLine="921"/>
</Position2> </Position2>
<Position3> <Position3>
<Filename Value="umainform.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="364" Column="58" TopLine="317"/> <Caret Line="930" Column="17" TopLine="922"/>
</Position3> </Position3>
<Position4> <Position4>
<Filename Value="umainform.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="633" Column="48" TopLine="586"/> <Caret Line="932" Column="17" TopLine="924"/>
</Position4> </Position4>
<Position5> <Position5>
<Filename Value="umainform.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="824" Column="48" TopLine="777"/> <Caret Line="931" Column="17" TopLine="923"/>
</Position5> </Position5>
<Position6> <Position6>
<Filename Value="umainform.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="404" TopLine="383"/> <Caret Line="932" Column="17" TopLine="924"/>
</Position6> </Position6>
<Position7> <Position7>
<Filename Value="umainform.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="614" Column="23" TopLine="596"/> <Caret Line="934" Column="17" TopLine="926"/>
</Position7> </Position7>
<Position8> <Position8>
<Filename Value="umainform.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="202" Column="32" TopLine="159"/> <Caret Line="936" Column="17" TopLine="928"/>
</Position8> </Position8>
<Position9> <Position9>
<Filename Value="umainform.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="302" Column="26" TopLine="276"/> <Caret Line="938" Column="17" TopLine="930"/>
</Position9> </Position9>
<Position10> <Position10>
<Filename Value="..\foobot_utility.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="157" Column="35" TopLine="137"/> <Caret Line="940" Column="17" TopLine="932"/>
</Position10> </Position10>
<Position11> <Position11>
<Filename Value="..\foobot_utility.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="158" Column="43" TopLine="137"/> <Caret Line="942" Column="17" TopLine="934"/>
</Position11> </Position11>
<Position12> <Position12>
<Filename Value="..\foobot_utility.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="203" Column="40" TopLine="181"/> <Caret Line="287" TopLine="250"/>
</Position12> </Position12>
<Position13> <Position13>
<Filename Value="..\foobot_utility.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="157" Column="37" TopLine="140"/> <Caret Line="580" Column="32" TopLine="574"/>
</Position13> </Position13>
<Position14> <Position14>
<Filename Value="..\foobot_utility.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="159" Column="36" TopLine="140"/> <Caret Line="581" Column="32" TopLine="575"/>
</Position14> </Position14>
<Position15> <Position15>
<Filename Value="..\foobot_utility.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="157" Column="36" TopLine="140"/> <Caret Line="580" Column="32" TopLine="574"/>
</Position15> </Position15>
<Position16> <Position16>
<Filename Value="umainform.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="929" Column="38" TopLine="909"/> <Caret Line="973" Column="18" TopLine="934"/>
</Position16> </Position16>
<Position17> <Position17>
<Filename Value="..\foobot_utility.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="58" TopLine="41"/> <Caret Line="987" Column="17" TopLine="945"/>
</Position17> </Position17>
<Position18> <Position18>
<Filename Value="..\foobot_utility.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="186" TopLine="144"/> <Caret Line="580" Column="49" TopLine="575"/>
</Position18> </Position18>
<Position19> <Position19>
<Filename Value="..\foobot_utility.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="226" TopLine="189"/> <Caret Line="581" Column="49" TopLine="576"/>
</Position19> </Position19>
<Position20> <Position20>
<Filename Value="umainform.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="985" TopLine="959"/> <Caret Line="582" Column="49" TopLine="577"/>
</Position20> </Position20>
<Position21> <Position21>
<Filename Value="umainform.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="857" TopLine="820"/> <Caret Line="583" Column="49" TopLine="578"/>
</Position21> </Position21>
<Position22> <Position22>
<Filename Value="..\foobot_utility.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="387" Column="13" TopLine="202"/> <Caret Line="586" Column="49" TopLine="581"/>
</Position22> </Position22>
<Position23> <Position23>
<Filename Value="umainform.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="503" Column="88" TopLine="475"/> <Caret Line="589" Column="49" TopLine="584"/>
</Position23> </Position23>
<Position24> <Position24>
<Filename Value="..\foobot_utility.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="404" Column="30" TopLine="368"/> <Caret Line="592" Column="49" TopLine="587"/>
</Position24> </Position24>
<Position25> <Position25>
<Filename Value="umainform.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="945" Column="15" TopLine="919"/> <Caret Line="595" Column="49" TopLine="590"/>
</Position25> </Position25>
<Position26> <Position26>
<Filename Value="umainform.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="936" Column="45" TopLine="915"/> <Caret Line="598" Column="49" TopLine="593"/>
</Position26> </Position26>
<Position27> <Position27>
<Filename Value="umainform.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="934" Column="12" TopLine="907"/> <Caret Line="402" Column="29" TopLine="369"/>
</Position27> </Position27>
<Position28> <Position28>
<Filename Value="umainform.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="264" TopLine="235"/> <Caret Line="438" Column="37" TopLine="401"/>
</Position28> </Position28>
<Position29> <Position29>
<Filename Value="..\foobot_utility.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="427" Column="14" TopLine="358"/> <Caret Line="415" Column="89" TopLine="393"/>
</Position29> </Position29>
<Position30> <Position30>
<Filename Value="..\foobot_utility.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="420" Column="27" TopLine="395"/> <Caret Line="417" Column="66" TopLine="395"/>
</Position30> </Position30>
</JumpHistory> </JumpHistory>
</ProjectSession> </ProjectSession>

View File

@ -1,12 +1,12 @@
object mainform: Tmainform object mainform: Tmainform
Left = 516 Left = 589
Height = 451 Height = 506
Top = 144 Top = 145
Width = 784 Width = 784
BorderIcons = [biSystemMenu, biMinimize] BorderIcons = [biSystemMenu, biMinimize]
BorderStyle = bsSingle BorderStyle = bsSingle
Caption = 'mainform' Caption = 'mainform'
ClientHeight = 431 ClientHeight = 486
ClientWidth = 784 ClientWidth = 784
DefaultMonitor = dmDesktop DefaultMonitor = dmDesktop
Font.Height = -12 Font.Height = -12
@ -140,27 +140,368 @@ object mainform: Tmainform
AnalogKind = akAnalog AnalogKind = akAnalog
end end
end end
object grp_health: TGroupBox
Left = 0
Height = 72
Top = 120
Width = 784
Align = alTop
Caption = 'Health'
ClientHeight = 52
ClientWidth = 780
TabOrder = 3
object pnl_healthpm: TPanel
Left = 0
Height = 52
Top = 0
Width = 130
Align = alLeft
ClientHeight = 52
ClientWidth = 130
TabOrder = 0
object sls_pm: TStopLightSensor
Left = 4
Height = 43
Top = 4
Width = 23
Picture.Data = {
1754506F727461626C654E6574776F726B47726170686963F400000089504E47
0D0A1A0A0000000D49484452000000150000002B08020000001805541C000000
BB49444154789CED95D10A80200C45FD743FAD3F33D3D2E972F34E7A281A04A2
9CB3619772DB5AB9F8786B85104EDEE115C187F932A785CF9B9EAC01BE81078A
215FE0782C28243EC3C7319902E0FBE10DFDB96296BF5500F7C715F0FBAB0A73
7ED47A47FE7D5D037C0BDF2BB4FCF97C345488F94BF0F179235380F96F3AE3FD
B902CCBF082B7CA7F8F38FF3D7ED91F53C4FE19142C99F4B111614224FF25F14
58FEF90F00EBCF1558FE6558E13BC5F7F3BF99EAE4C342D54BB2D50EA0FED6E2
5B12FB970000000049454E44AE426082
}
State = slUNKNOWN
end
object lbl_redlightpm: TLabel
Left = 32
Height = 15
Top = 4
Width = 96
AutoSize = False
Caption = 'No Stats'
ParentColor = False
end
object lbl_yellowlightpm: TLabel
Left = 32
Height = 15
Top = 18
Width = 96
AutoSize = False
Caption = 'No Stats'
ParentColor = False
end
object lbl_greenlightpm: TLabel
Left = 32
Height = 15
Top = 32
Width = 96
AutoSize = False
Caption = 'No Stats'
ParentColor = False
end
end
object pnl_healthallpollu: TPanel
Left = 650
Height = 52
Top = 0
Width = 130
Align = alLeft
ClientHeight = 52
ClientWidth = 130
TabOrder = 1
object sls_allpollu: TStopLightSensor
Left = 4
Height = 43
Top = 4
Width = 23
Picture.Data = {
1754506F727461626C654E6574776F726B47726170686963F400000089504E47
0D0A1A0A0000000D49484452000000150000002B08020000001805541C000000
BB49444154789CED95D10A80200C45FD743FAD3F33D3D2E972F34E7A281A04A2
9CB3619772DB5AB9F8786B85104EDEE115C187F932A785CF9B9EAC01BE81078A
215FE0782C28243EC3C7319902E0FBE10DFDB96296BF5500F7C715F0FBAB0A73
7ED47A47FE7D5D037C0BDF2BB4FCF97C345488F94BF0F179235380F96F3AE3FD
B902CCBF082B7CA7F8F38FF3D7ED91F53C4FE19142C99F4B111614224FF25F14
58FEF90F00EBCF1558FE6558E13BC5F7F3BF99EAE4C342D54BB2D50EA0FED6E2
5B12FB970000000049454E44AE426082
}
State = slUNKNOWN
end
object lbl_redlightallpollu: TLabel
Left = 32
Height = 15
Top = 4
Width = 96
AutoSize = False
Caption = 'No Stats'
ParentColor = False
end
object lbl_yellowlightallpollu: TLabel
Left = 32
Height = 15
Top = 18
Width = 96
AutoSize = False
Caption = 'No Stats'
ParentColor = False
end
object lbl_greenlightallpollu: TLabel
Left = 32
Height = 15
Top = 32
Width = 96
AutoSize = False
Caption = 'No Stats'
ParentColor = False
end
end
object pnl_healthvoc: TPanel
Left = 520
Height = 52
Top = 0
Width = 130
Align = alLeft
ClientHeight = 52
ClientWidth = 130
TabOrder = 2
object sls_voc: TStopLightSensor
Left = 4
Height = 43
Top = 4
Width = 23
Picture.Data = {
1754506F727461626C654E6574776F726B47726170686963F400000089504E47
0D0A1A0A0000000D49484452000000150000002B08020000001805541C000000
BB49444154789CED95D10A80200C45FD743FAD3F33D3D2E972F34E7A281A04A2
9CB3619772DB5AB9F8786B85104EDEE115C187F932A785CF9B9EAC01BE81078A
215FE0782C28243EC3C7319902E0FBE10DFDB96296BF5500F7C715F0FBAB0A73
7ED47A47FE7D5D037C0BDF2BB4FCF97C345488F94BF0F179235380F96F3AE3FD
B902CCBF082B7CA7F8F38FF3D7ED91F53C4FE19142C99F4B111614224FF25F14
58FEF90F00EBCF1558FE6558E13BC5F7F3BF99EAE4C342D54BB2D50EA0FED6E2
5B12FB970000000049454E44AE426082
}
State = slUNKNOWN
end
object lbl_redlightvoc: TLabel
Left = 32
Height = 15
Top = 4
Width = 96
AutoSize = False
Caption = 'No Stats'
ParentColor = False
end
object lbl_yellowlightvoc: TLabel
Left = 32
Height = 15
Top = 18
Width = 96
AutoSize = False
Caption = 'No Stats'
ParentColor = False
end
object lbl_greenlightvoc: TLabel
Left = 32
Height = 15
Top = 32
Width = 96
AutoSize = False
Caption = 'No Stats'
ParentColor = False
end
end
object pnl_healthco2: TPanel
Left = 390
Height = 52
Top = 0
Width = 130
Align = alLeft
ClientHeight = 52
ClientWidth = 130
TabOrder = 3
object sls_co2: TStopLightSensor
Left = 4
Height = 43
Top = 4
Width = 23
Picture.Data = {
1754506F727461626C654E6574776F726B47726170686963F400000089504E47
0D0A1A0A0000000D49484452000000150000002B08020000001805541C000000
BB49444154789CED95D10A80200C45FD743FAD3F33D3D2E972F34E7A281A04A2
9CB3619772DB5AB9F8786B85104EDEE115C187F932A785CF9B9EAC01BE81078A
215FE0782C28243EC3C7319902E0FBE10DFDB96296BF5500F7C715F0FBAB0A73
7ED47A47FE7D5D037C0BDF2BB4FCF97C345488F94BF0F179235380F96F3AE3FD
B902CCBF082B7CA7F8F38FF3D7ED91F53C4FE19142C99F4B111614224FF25F14
58FEF90F00EBCF1558FE6558E13BC5F7F3BF99EAE4C342D54BB2D50EA0FED6E2
5B12FB970000000049454E44AE426082
}
State = slUNKNOWN
end
object lbl_redlightco2: TLabel
Left = 32
Height = 15
Top = 4
Width = 96
AutoSize = False
Caption = 'No Stats'
ParentColor = False
end
object lbl_yellowlightco2: TLabel
Left = 32
Height = 15
Top = 18
Width = 96
AutoSize = False
Caption = 'No Stats'
ParentColor = False
end
object lbl_greenlightco2: TLabel
Left = 32
Height = 15
Top = 32
Width = 96
AutoSize = False
Caption = 'No Stats'
ParentColor = False
end
end
object pnl_healthhum: TPanel
Left = 260
Height = 52
Top = 0
Width = 130
Align = alLeft
ClientHeight = 52
ClientWidth = 130
TabOrder = 4
object sls_hum: TStopLightSensor
Left = 4
Height = 43
Top = 4
Width = 23
Picture.Data = {
1754506F727461626C654E6574776F726B47726170686963F400000089504E47
0D0A1A0A0000000D49484452000000150000002B08020000001805541C000000
BB49444154789CED95D10A80200C45FD743FAD3F33D3D2E972F34E7A281A04A2
9CB3619772DB5AB9F8786B85104EDEE115C187F932A785CF9B9EAC01BE81078A
215FE0782C28243EC3C7319902E0FBE10DFDB96296BF5500F7C715F0FBAB0A73
7ED47A47FE7D5D037C0BDF2BB4FCF97C345488F94BF0F179235380F96F3AE3FD
B902CCBF082B7CA7F8F38FF3D7ED91F53C4FE19142C99F4B111614224FF25F14
58FEF90F00EBCF1558FE6558E13BC5F7F3BF99EAE4C342D54BB2D50EA0FED6E2
5B12FB970000000049454E44AE426082
}
State = slUNKNOWN
end
object lbl_redlighthum: TLabel
Left = 32
Height = 15
Top = 4
Width = 96
AutoSize = False
Caption = 'No Stats'
ParentColor = False
end
object lbl_yellowlighthum: TLabel
Left = 32
Height = 15
Top = 18
Width = 96
AutoSize = False
Caption = 'No Stats'
ParentColor = False
end
object lbl_greenlighthum: TLabel
Left = 32
Height = 15
Top = 32
Width = 96
AutoSize = False
Caption = 'No Stats'
ParentColor = False
end
end
object pnl_healthtmp: TPanel
Left = 130
Height = 52
Top = 0
Width = 130
Align = alLeft
ClientHeight = 52
ClientWidth = 130
TabOrder = 5
object sls_tmp: TStopLightSensor
Left = 4
Height = 43
Top = 4
Width = 23
Picture.Data = {
1754506F727461626C654E6574776F726B47726170686963F400000089504E47
0D0A1A0A0000000D49484452000000150000002B08020000001805541C000000
BB49444154789CED95D10A80200C45FD743FAD3F33D3D2E972F34E7A281A04A2
9CB3619772DB5AB9F8786B85104EDEE115C187F932A785CF9B9EAC01BE81078A
215FE0782C28243EC3C7319902E0FBE10DFDB96296BF5500F7C715F0FBAB0A73
7ED47A47FE7D5D037C0BDF2BB4FCF97C345488F94BF0F179235380F96F3AE3FD
B902CCBF082B7CA7F8F38FF3D7ED91F53C4FE19142C99F4B111614224FF25F14
58FEF90F00EBCF1558FE6558E13BC5F7F3BF99EAE4C342D54BB2D50EA0FED6E2
5B12FB970000000049454E44AE426082
}
State = slUNKNOWN
end
object lbl_redlighttmp: TLabel
Left = 32
Height = 15
Top = 4
Width = 96
AutoSize = False
Caption = 'No Stats'
ParentColor = False
end
object lbl_yellowlighttmp: TLabel
Left = 32
Height = 15
Top = 18
Width = 96
AutoSize = False
Caption = 'No Stats'
ParentColor = False
end
object lbl_greenlighttmp: TLabel
Left = 32
Height = 15
Top = 32
Width = 96
AutoSize = False
Caption = 'No Stats'
ParentColor = False
end
end
end
object grp_highlow: TGroupBox object grp_highlow: TGroupBox
Left = 0 Left = 0
Height = 119 Height = 112
Top = 120 Top = 192
Width = 784 Width = 784
Align = alTop Align = alTop
Caption = 'All-time Highs and Lows' Caption = 'All-time Highs and Lows'
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
ChildSizing.EnlargeVertical = crsScaleChilds ChildSizing.EnlargeVertical = crsScaleChilds
ChildSizing.ControlsPerLine = 6 ChildSizing.ControlsPerLine = 6
ClientHeight = 99 ClientHeight = 92
ClientWidth = 780 ClientWidth = 780
TabOrder = 1 TabOrder = 1
object grp_pm: TGroupBox object grp_pm: TGroupBox
Left = 0 Left = 0
Height = 99 Height = 92
Top = 0 Top = 0
Width = 130 Width = 130
Align = alLeft Align = alLeft
Caption = 'Particulates' Caption = 'Particulates'
ClientHeight = 79 ClientHeight = 72
ClientWidth = 126 ClientWidth = 126
TabOrder = 0 TabOrder = 0
object lbl_pmhigh: TLabel object lbl_pmhigh: TLabel
@ -182,12 +523,12 @@ object mainform: Tmainform
end end
object grp_tmp: TGroupBox object grp_tmp: TGroupBox
Left = 130 Left = 130
Height = 99 Height = 92
Top = 0 Top = 0
Width = 130 Width = 130
Align = alLeft Align = alLeft
Caption = 'Temperature' Caption = 'Temperature'
ClientHeight = 79 ClientHeight = 72
ClientWidth = 126 ClientWidth = 126
TabOrder = 1 TabOrder = 1
object lbl_tmphigh: TLabel object lbl_tmphigh: TLabel
@ -209,12 +550,12 @@ object mainform: Tmainform
end end
object grp_hum: TGroupBox object grp_hum: TGroupBox
Left = 260 Left = 260
Height = 99 Height = 92
Top = 0 Top = 0
Width = 130 Width = 130
Align = alLeft Align = alLeft
Caption = 'Humidity' Caption = 'Humidity'
ClientHeight = 79 ClientHeight = 72
ClientWidth = 126 ClientWidth = 126
TabOrder = 2 TabOrder = 2
object lbl_humhigh: TLabel object lbl_humhigh: TLabel
@ -236,12 +577,12 @@ object mainform: Tmainform
end end
object grp_co2: TGroupBox object grp_co2: TGroupBox
Left = 390 Left = 390
Height = 99 Height = 92
Top = 0 Top = 0
Width = 130 Width = 130
Align = alLeft Align = alLeft
Caption = 'CO2' Caption = 'CO2'
ClientHeight = 79 ClientHeight = 72
ClientWidth = 126 ClientWidth = 126
TabOrder = 3 TabOrder = 3
object lbl_co2high: TLabel object lbl_co2high: TLabel
@ -263,12 +604,12 @@ object mainform: Tmainform
end end
object grp_voc: TGroupBox object grp_voc: TGroupBox
Left = 520 Left = 520
Height = 99 Height = 92
Top = 0 Top = 0
Width = 130 Width = 130
Align = alLeft Align = alLeft
Caption = 'Volatile VOC' Caption = 'Volatile VOC'
ClientHeight = 79 ClientHeight = 72
ClientWidth = 126 ClientWidth = 126
TabOrder = 4 TabOrder = 4
object lbl_vochigh: TLabel object lbl_vochigh: TLabel
@ -290,12 +631,12 @@ object mainform: Tmainform
end end
object grp_allpollu: TGroupBox object grp_allpollu: TGroupBox
Left = 650 Left = 650
Height = 99 Height = 92
Top = 0 Top = 0
Width = 130 Width = 130
Align = alLeft Align = alLeft
Caption = 'All Pollution' Caption = 'All Pollution'
ClientHeight = 79 ClientHeight = 72
ClientWidth = 126 ClientWidth = 126
TabOrder = 5 TabOrder = 5
object lbl_allpolluhigh: TLabel object lbl_allpolluhigh: TLabel
@ -319,7 +660,7 @@ object mainform: Tmainform
object grp_chart: TGroupBox object grp_chart: TGroupBox
Left = 0 Left = 0
Height = 179 Height = 179
Top = 239 Top = 304
Width = 784 Width = 784
Align = alTop Align = alTop
Caption = 'History' Caption = 'History'
@ -395,8 +736,7 @@ object mainform: Tmainform
Left = 16 Left = 16
end end
object MainMenu1: TMainMenu object MainMenu1: TMainMenu
Left = 56 Left = 200
Top = 8
object mnu_file: TMenuItem object mnu_file: TMenuItem
Caption = '&File' Caption = '&File'
object mnu_fileExit: TMenuItem object mnu_fileExit: TMenuItem

View File

@ -38,9 +38,9 @@ V0.2.1.0: Triggers,Multiple Foobots
interface interface
uses // If Lazarus auto-inserts 'sensors' in the clause then delete it uses // If Lazarus auto-inserts 'sensors' in the clause then delete it
SysUtils, TAGraph, TAIntervalSources, TASeries, foobot_sensors, SysUtils, TAGraph, TAIntervalSources, TASeries,
Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls, Menus, lclIntf, foobot_sensors, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls, Menus,
foobot_utility, uCryptIni, dateutils, uconfigform, utriggersform, Classes; lclIntf, foobot_utility, uCryptIni, dateutils, uconfigform, utriggersform;
const const
// Timer milliseconds // Timer milliseconds
@ -95,6 +95,25 @@ type
as_voc: TAnalogSensor; as_voc: TAnalogSensor;
Chart1: TChart; Chart1: TChart;
DateTimeIntervalChartSource1: TDateTimeIntervalChartSource; DateTimeIntervalChartSource1: TDateTimeIntervalChartSource;
grp_health: TGroupBox;
lbl_greenlighttmp: TLabel;
lbl_greenlighthum: TLabel;
lbl_greenlightco2: TLabel;
lbl_greenlightvoc: TLabel;
lbl_greenlightallpollu: TLabel;
lbl_redlightpm: TLabel;
lbl_redlighttmp: TLabel;
lbl_redlighthum: TLabel;
lbl_redlightco2: TLabel;
lbl_redlightvoc: TLabel;
lbl_redlightallpollu: TLabel;
lbl_yellowlightpm: TLabel;
lbl_greenlightpm: TLabel;
lbl_yellowlighttmp: TLabel;
lbl_yellowlighthum: TLabel;
lbl_yellowlightco2: TLabel;
lbl_yellowlightvoc: TLabel;
lbl_yellowlightallpollu: TLabel;
lineseries_allpollu: TLineSeries; lineseries_allpollu: TLineSeries;
lineseries_voc: TLineSeries; lineseries_voc: TLineSeries;
lineseries_co2: TLineSeries; lineseries_co2: TLineSeries;
@ -152,6 +171,18 @@ type
mnu_options: TMenuItem; mnu_options: TMenuItem;
mnu_fileExit: TMenuItem; mnu_fileExit: TMenuItem;
mnu_file: TMenuItem; mnu_file: TMenuItem;
pnl_healthpm: TPanel;
pnl_healthallpollu: TPanel;
pnl_healthvoc: TPanel;
pnl_healthco2: TPanel;
pnl_healthhum: TPanel;
pnl_healthtmp: TPanel;
sls_pm: TStopLightSensor;
sls_allpollu: TStopLightSensor;
sls_voc: TStopLightSensor;
sls_co2: TStopLightSensor;
sls_hum: TStopLightSensor;
sls_tmp: TStopLightSensor;
traypopup: TPopupMenu; traypopup: TPopupMenu;
tmr_foobot: TTimer; tmr_foobot: TTimer;
TrayIcon1: TTrayIcon; TrayIcon1: TTrayIcon;
@ -196,14 +227,16 @@ type
procedure GraphCurrentReading; procedure GraphCurrentReading;
procedure SetYellowRecommendedLevels; procedure SetYellowRecommendedLevels;
procedure SetRedSessionMax; procedure SetRedSessionMax;
procedure UpdateHealth;
procedure PopulateFoobotMenu; procedure PopulateFoobotMenu;
procedure ChangeCurrentFoobot(Sender: TObject); procedure ChangeCurrentFoobot(Sender: TObject);
procedure SaveConfig; procedure SaveConfig;
procedure LoadConfig; procedure LoadConfig;
procedure SetMinMaxTriggers; procedure SetMinMaxTriggers;
procedure DoHighTriggerAlert(Const iSensorNum:Integer;Const aValue:Variant); procedure SetTrafficLightStats;
procedure DoLowTriggerAlert(Const iSensorNum:Integer;Const aValue:Variant); procedure DoHighTriggerAlert(const iSensorNum: integer; const aValue: variant);
procedure RestoreNormalColour(Const iSensorNum:Integer); procedure DoLowTriggerAlert(const iSensorNum: integer; const aValue: variant);
procedure RestoreNormalColour(const iSensorNum: integer);
public public
INI: TCryptINIfile; INI: TCryptINIfile;
end; end;
@ -257,10 +290,10 @@ begin
{$IFDEF DEBUGMODE} {$IFDEF DEBUGMODE}
UseTriggers := False; UseTriggers := False;
{$ENDIF} {$ENDIF}
If UseTriggers then if UseTriggers then
begin begin
mnu_options_triggersActivateTriggers.Enabled:=TRUE; mnu_options_triggersActivateTriggers.Enabled := True;
mnu_options_triggersActivateTriggers.Checked:=TRUE; mnu_options_triggersActivateTriggers.Checked := True;
mnu_options_triggersActivateTriggers.Caption := 'Set Triggers Off'; mnu_options_triggersActivateTriggers.Caption := 'Set Triggers Off';
end; end;
end; end;
@ -270,7 +303,8 @@ var
sTempFoobotUserName, sTempSecretKey: string; sTempFoobotUserName, sTempSecretKey: string;
begin begin
ClientHeight := grp_sensorDisplay.Height + grp_highlow.Height + grp_chart.Height; ClientHeight := grp_sensorDisplay.Height + grp_highlow.Height +
grp_health.Height + grp_chart.Height;
Application.ProcessMessages; Application.ProcessMessages;
// Allow user to enter values in INIFile // Allow user to enter values in INIFile
sTempFoobotUserName := INI.ReadUnencryptedString('Config', 'Foobot User', 'unknown'); sTempFoobotUserName := INI.ReadUnencryptedString('Config', 'Foobot User', 'unknown');
@ -309,6 +343,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 Guage High/Low limits SetMinMaxTriggers; // Adjust if necesarry for Guage High/Low limits
SetTrafficLightStats;
Show; Show;
{$IFNDEF DEBUGMODE} {$IFNDEF DEBUGMODE}
mnu_optionsTakeReadingNow.Click; mnu_optionsTakeReadingNow.Click;
@ -361,6 +396,52 @@ begin
mnu_optionsTakeReadingNow.Click; mnu_optionsTakeReadingNow.Click;
end; end;
procedure Tmainform.SetTrafficLightStats;
begin
lbl_redlightpm.Caption := Format('> %.1f %s', [double(FooBotTriggerArray[C_HIGH, C_PM]),
FoobotDataObject.Units[C_PM]]);
lbl_yellowlightpm.Caption := Format('> %.1f %s', [double(REC_PM),
FoobotDataObject.Units[C_PM]]);
lbl_greenlightpm.Caption := Format('< %.1f %s', [double(REC_PM),
FoobotDataObject.Units[C_PM]]);
lbl_redlighttmp.Caption := Format('> %.1f %s', [double(FooBotTriggerArray[C_HIGH, C_TMP]),
FoobotDataObject.Units[C_TMP]]);
lbl_yellowlighttmp.Caption :=
Format('> %.1f %s', [double(REC_TMP), FoobotDataObject.Units[C_TMP]]);
lbl_greenlighttmp.Caption := Format('< %.1f %s', [double(REC_TMP),
FoobotDataObject.Units[C_TMP]]);
lbl_redlighthum.Caption := Format('> %.1f %s', [double(FooBotTriggerArray[C_HIGH, C_HUM]),
FoobotDataObject.Units[C_HUM]]);
lbl_yellowlighthum.Caption :=
Format('> %.1f %s', [double(REC_HUM), FoobotDataObject.Units[C_HUM]]);
lbl_greenlighthum.Caption := Format('< %.1f %s', [double(REC_HUM),
FoobotDataObject.Units[C_HUM]]);
lbl_redlightco2.Caption := Format('> %.0f %s', [double(FooBotTriggerArray[C_HIGH, C_CO2]),
FoobotDataObject.Units[C_CO2]]);
lbl_yellowlightco2.Caption :=
Format('> %.0f %s', [double(REC_CO2), FoobotDataObject.Units[C_CO2]]);
lbl_greenlightco2.Caption := Format('< %.0f %s', [double(REC_CO2),
FoobotDataObject.Units[C_CO2]]);
lbl_redlightvoc.Caption := Format('> %.0f %s', [double(FooBotTriggerArray[C_HIGH, C_VOC]),
FoobotDataObject.Units[C_VOC]]);
lbl_yellowlightvoc.Caption :=
Format('> %.0f %s', [double(REC_VOC), FoobotDataObject.Units[C_VOC]]);
lbl_greenlightvoc.Caption := Format('< %.0f %s', [double(REC_VOC),
FoobotDataObject.Units[C_VOC]]);
lbl_redlightallpollu.Caption :=
Format('> %.1f %s', [double(FooBotTriggerArray[C_HIGH, C_ALLPOLLU]),
FoobotDataObject.Units[C_ALLPOLLU]]);
lbl_yellowlightallpollu.Caption :=
Format('> %.1f %s', [double(REC_ALLPOLLU), FoobotDataObject.Units[C_ALLPOLLU]]);
lbl_greenlightallpollu.Caption :=
Format('< %.1f %s', [double(REC_ALLPOLLU), FoobotDataObject.Units[C_ALLPOLLU]]);
end;
procedure Tmainform.PopulateFoobotMenu; procedure Tmainform.PopulateFoobotMenu;
// Uses dynamic foobotmenuarray // Uses dynamic foobotmenuarray
var var
@ -403,7 +484,7 @@ end;
procedure Tmainform.SaveConfig; procedure Tmainform.SaveConfig;
// For all Foobots // For all Foobots
begin begin
With INI do with INI do
begin begin
PlainTextMode := True; PlainTextMode := True;
// Colours // Colours
@ -505,7 +586,8 @@ begin
as_allpollu.ValueMax := INI.ReadFloat('Config', 'allpolluMaxValue', MAX_ALLPOLLU); as_allpollu.ValueMax := INI.ReadFloat('Config', 'allpolluMaxValue', MAX_ALLPOLLU);
// Triggers // Triggers
UseTriggers := INI.ReadBool('Config', 'UseTriggers', False); UseTriggers := INI.ReadBool('Config', 'UseTriggers', False);
HighTriggerColor:=StringToColor(INI.ReadString('Config', 'HighTriggerColour', 'clYellow')); HighTriggerColor := StringToColor(INI.ReadString('Config', 'HighTriggerColour',
'clYellow'));
LowTriggerColor := StringToColor(INI.ReadString('Config', 'LowTriggerColour', 'clAqua')); LowTriggerColor := StringToColor(INI.ReadString('Config', 'LowTriggerColour', 'clAqua'));
INI.PlainTextMode := False; INI.PlainTextMode := False;
end; end;
@ -561,10 +643,10 @@ procedure Tmainform.mnu_optionsDisplayGuagesOnlyClick(Sender: TObject);
begin begin
bDisplayGuagesOnly := mnu_optionsDisplayGuagesOnly.Checked; bDisplayGuagesOnly := mnu_optionsDisplayGuagesOnly.Checked;
if bDisplayGuagesOnly then if bDisplayGuagesOnly then
mainform.ClientHeight := grp_sensorDisplay.Height// + iFudgeFactor mainform.ClientHeight := grp_sensorDisplay.Height + grp_health.Height
else else
mainform.ClientHeight := grp_sensorDisplay.Height + grp_chart.Height + mainform.ClientHeight := grp_sensorDisplay.Height + grp_health.Height +
grp_highlow.Height;// + iFudgeFactor; grp_chart.Height + grp_highlow.Height;
end; end;
procedure Tmainform.mnu_optionsDisplayRedLinesClick(Sender: TObject); procedure Tmainform.mnu_optionsDisplayRedLinesClick(Sender: TObject);
@ -628,7 +710,7 @@ begin
begin begin
mnu_options_triggersActivateTriggers.Caption := 'Set Triggers Off'; mnu_options_triggersActivateTriggers.Caption := 'Set Triggers Off';
LoadTriggers; LoadTriggers;
SetMinMaxTriggers SetMinMaxTriggers;
end end
else else
mnu_options_triggersActivateTriggers.Caption := 'Set Triggers On'; mnu_options_triggersActivateTriggers.Caption := 'Set Triggers On';
@ -796,22 +878,22 @@ begin
C_CO2: C_CO2:
begin begin
lbl_co2high.Caption := Format('High: %d %s', lbl_co2high.Caption := Format('High: %d %s',
[Integer(FoobotDataHighs[SensorNumber]), FoobotDataObject.Units[SensorNumber]]) + [integer(FoobotDataHighs[SensorNumber]), FoobotDataObject.Units[SensorNumber]]) +
LineEnding + 'on ' + FormatDateTime('dd/mm tt', LineEnding + 'on ' + FormatDateTime('dd/mm tt',
TDateTime(FoobotDataHighTimes[SensorNumber])); TDateTime(FoobotDataHighTimes[SensorNumber]));
lbl_co2Low.Caption := Format('Low: %d %s', lbl_co2Low.Caption := Format('Low: %d %s',
[Integer(FoobotDataLows[SensorNumber]), FoobotDataObject.Units[SensorNumber]]) + [integer(FoobotDataLows[SensorNumber]), FoobotDataObject.Units[SensorNumber]]) +
LineEnding + 'on ' + FormatDateTime('dd/mm tt', TDateTime( LineEnding + 'on ' + FormatDateTime('dd/mm tt', TDateTime(
FoobotDataLowTimes[SensorNumber])); FoobotDataLowTimes[SensorNumber]));
end; end;
C_VOC: C_VOC:
begin begin
lbl_vochigh.Caption := Format('High: %d %s', lbl_vochigh.Caption := Format('High: %d %s',
[Integer(FoobotDataHighs[SensorNumber]), FoobotDataObject.Units[SensorNumber]]) + [integer(FoobotDataHighs[SensorNumber]), FoobotDataObject.Units[SensorNumber]]) +
LineEnding + 'on ' + FormatDateTime('dd/mm tt', LineEnding + 'on ' + FormatDateTime('dd/mm tt',
TDateTime(FoobotDataHighTimes[SensorNumber])); TDateTime(FoobotDataHighTimes[SensorNumber]));
lbl_vocLow.Caption := Format('Low: %d %s', lbl_vocLow.Caption := Format('Low: %d %s',
[Integer(FoobotDataLows[SensorNumber]), FoobotDataObject.Units[SensorNumber]]) + [integer(FoobotDataLows[SensorNumber]), FoobotDataObject.Units[SensorNumber]]) +
LineEnding + 'on ' + FormatDateTime('dd/mm tt', TDateTime( LineEnding + 'on ' + FormatDateTime('dd/mm tt', TDateTime(
FoobotDataLowTimes[SensorNumber])); FoobotDataLowTimes[SensorNumber]));
end; end;
@ -876,9 +958,10 @@ begin
SetYellowRecommendedLevels; SetYellowRecommendedLevels;
end; end;
end; end;
procedure Tmainform.DoHighTriggerAlert(Const iSensorNum:Integer;Const aValue:Variant);
procedure Tmainform.DoHighTriggerAlert(const iSensorNum: integer; const aValue: variant);
begin begin
Case iSensorNum of case iSensorNum of
C_PM: as_pm.Color := HighTriggerColor; C_PM: as_pm.Color := HighTriggerColor;
C_TMP: as_tmp.Color := HighTriggerColor; C_TMP: as_tmp.Color := HighTriggerColor;
C_HUM: as_hum.Color := HighTriggerColor; C_HUM: as_hum.Color := HighTriggerColor;
@ -888,9 +971,9 @@ begin
end; end;
end; end;
procedure Tmainform.DoLowTriggerAlert(Const iSensorNum:Integer;Const aValue:Variant); procedure Tmainform.DoLowTriggerAlert(const iSensorNum: integer; const aValue: variant);
begin begin
Case iSensorNum of case iSensorNum of
C_PM: as_pm.Color := LowTriggerColor; C_PM: as_pm.Color := LowTriggerColor;
C_TMP: as_tmp.Color := LowTriggerColor; C_TMP: as_tmp.Color := LowTriggerColor;
C_HUM: as_hum.Color := LowTriggerColor; C_HUM: as_hum.Color := LowTriggerColor;
@ -900,9 +983,9 @@ begin
end; end;
end; end;
procedure Tmainform.RestoreNormalColour(Const iSensorNum:Integer); procedure Tmainform.RestoreNormalColour(const iSensorNum: integer);
begin begin
Case iSensorNum of case iSensorNum of
C_PM: as_pm.Color := clDefault; C_PM: as_pm.Color := clDefault;
C_TMP: as_tmp.Color := clDefault; C_TMP: as_tmp.Color := clDefault;
C_HUM: as_hum.Color := clDefault; C_HUM: as_hum.Color := clDefault;
@ -911,6 +994,41 @@ begin
C_ALLPOLLU: as_allpollu.Color := clDefault; C_ALLPOLLU: as_allpollu.Color := clDefault;
end; end;
end; end;
procedure Tmainform.UpdateHealth;
begin
if (as_pm.Value > REC_PM) then
sls_pm.State := slYELLOW
else
sls_pm.State := slGREEN;
if (as_tmp.Value > REC_TMP) then
sls_tmp.State := slYELLOW
else
sls_tmp.State := slGREEN;
if (as_hum.Value > REC_HUM) then
sls_hum.State := slYELLOW
else
sls_hum.State := slGREEN;
if (as_co2.Value > REC_CO2) then
sls_co2.State := slYELLOW
else
sls_co2.State := slGREEN;
if (as_voc.Value > REC_VOC) then
sls_voc.State := slYELLOW
else
sls_voc.State := slGREEN;
if (as_allpollu.Value > REC_ALLPOLLU) then
sls_allpollu.State := slYELLOW
else
sls_allpollu.State := slGREEN;
end;
procedure Tmainform.DisplayReadings; procedure Tmainform.DisplayReadings;
var var
iCount: integer; iCount: integer;
@ -926,14 +1044,23 @@ begin
UpdateGuage(as_co2, C_CO2); UpdateGuage(as_co2, C_CO2);
UpdateGuage(as_voc, C_VOC); UpdateGuage(as_voc, C_VOC);
UpdateGuage(as_allpollu, C_ALLPOLLU); UpdateGuage(as_allpollu, C_ALLPOLLU);
UpdateHealth;
// Process Trigger Alerts on each call to FoobotDataObjectToArrays // Process Trigger Alerts on each call to FoobotDataObjectToArrays
if UseTriggers then if UseTriggers then
try try
// Look for alerts in each sensor // Look for alerts in each sensor
for iCount := C_PM to C_ALLPOLLU do for iCount := C_PM to C_ALLPOLLU do
begin begin
if (AlertRec[iCount].AlertTriggered=TRUE) then if (AlertRec[iCount].AlertTriggered = True) then
begin begin
case iCount of
C_PM: sls_pm.State := slRED;
C_TMP: sls_tmp.State := slRED;
C_HUM: sls_hum.State := slRED;
C_CO2: sls_co2.State := slRED;
C_VOC: sls_voc.State := slRED;
C_ALLPOLLU: sls_allpollu.State := slRED;
end;
// Alert found. High or low? // Alert found. High or low?
if (AlertRec[iCount].AlertType = C_HIGH) then if (AlertRec[iCount].AlertType = C_HIGH) then
begin begin
@ -944,13 +1071,10 @@ begin
begin begin
// A low alert - do something // A low alert - do something
DoLowTriggerAlert(iCount, AlertRec[iCount].AlertValue); DoLowTriggerAlert(iCount, AlertRec[iCount].AlertValue);
{
ShowMessageFmt('Low alert member %d (value %f) exceeded',
[iCount, double(AlertRec[iCount].AlertValue)]);
}
end; end;
end end
else RestoreNormalColour(iCount); else
RestoreNormalColour(iCount);
end; end;
except except
raise Exception.Create('Unable to process triggers in DisplayReadings'); raise Exception.Create('Unable to process triggers in DisplayReadings');
@ -962,7 +1086,6 @@ begin
end; end;
GraphCurrentReading; GraphCurrentReading;
end end
else else
raise Exception.Create('FoobotDataObjectToArrays error in DisplayReadings'); raise Exception.Create('FoobotDataObjectToArrays error in DisplayReadings');
@ -984,8 +1107,8 @@ begin
try try
lineseries_pm.AddXY(FoobotData_time[iCurrentFoobot], lineseries_pm.AddXY(FoobotData_time[iCurrentFoobot],
AsPercent(FoobotData_pm[iCurrentFoobot], as_pm.ValueMin, as_pm.ValueMax)); AsPercent(FoobotData_pm[iCurrentFoobot], as_pm.ValueMin, as_pm.ValueMax));
lineseries_tmp.AddXY(FoobotData_time[iCurrentFoobot], AsPercent(FoobotData_tmp[iCurrentFoobot], lineseries_tmp.AddXY(FoobotData_time[iCurrentFoobot],
as_tmp.ValueMin, as_tmp.ValueMax)); AsPercent(FoobotData_tmp[iCurrentFoobot], as_tmp.ValueMin, as_tmp.ValueMax));
lineseries_hum.AddXY(FoobotData_time[iCurrentFoobot], lineseries_hum.AddXY(FoobotData_time[iCurrentFoobot],
AsPercent(FoobotData_hum[iCurrentFoobot], as_hum.ValueMin, as_hum.ValueMax)); AsPercent(FoobotData_hum[iCurrentFoobot], as_hum.ValueMin, as_hum.ValueMax));
lineseries_co2.AddXY(FoobotData_time[iCurrentFoobot], lineseries_co2.AddXY(FoobotData_time[iCurrentFoobot],
@ -993,7 +1116,8 @@ begin
lineseries_voc.AddXY(FoobotData_time[iCurrentFoobot], lineseries_voc.AddXY(FoobotData_time[iCurrentFoobot],
AsPercent(FoobotData_voc[iCurrentFoobot], as_voc.ValueMin, as_voc.ValueMax)); AsPercent(FoobotData_voc[iCurrentFoobot], as_voc.ValueMin, as_voc.ValueMax));
lineseries_allpollu.AddXY(FoobotData_time[iCurrentFoobot], lineseries_allpollu.AddXY(FoobotData_time[iCurrentFoobot],
AsPercent(FoobotData_allpollu[iCurrentFoobot], as_allpollu.ValueMin, as_allpollu.ValueMax)); AsPercent(FoobotData_allpollu[iCurrentFoobot], as_allpollu.ValueMin,
as_allpollu.ValueMax));
except except
raise Exception.Create('Unable to update graph in GraphCurrentReading'); raise Exception.Create('Unable to update graph in GraphCurrentReading');
end; end;
@ -1005,14 +1129,14 @@ procedure Tmainform.GraphHistory;
var var
iCount: integer; iCount: integer;
iStartSeconds, iEndSeconds: int64; iStartSeconds, iEndSeconds: int64;
bTempUseTriggers:Boolean; bTempUseTriggers: boolean;
begin begin
{$IFDEF DEBUGMODE} {$IFDEF DEBUGMODE}
Exit; Exit;
{$ENDIF} {$ENDIF}
// Turn off triggers (if on) // Turn off triggers (if on)
bTempUseTriggers := UseTriggers; bTempUseTriggers := UseTriggers;
UseTriggers:=FALSE; UseTriggers := False;
iEndSeconds := DateTimeToUnix(Now) - 3600; iEndSeconds := DateTimeToUnix(Now) - 3600;
iStartSeconds := iEndSeconds - (2 * (24 * 3600)); // 49 hours before Now iStartSeconds := iEndSeconds - (2 * (24 * 3600)); // 49 hours before Now