To V0.0.4.0 48-hour history graph added

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5581 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
gbamber
2017-01-02 09:34:00 +00:00
parent 587ea10dc8
commit 0bcf146bf0
10 changed files with 467 additions and 222 deletions

View File

@ -145,7 +145,10 @@ var
sFoobotName: string; sFoobotName: string;
begin begin
if SaveLoadHighLows = False then if SaveLoadHighLows = False then
Exit(False); begin
ShowMessage('Unable to load All-Time stats');
Exit(False);
end;
sFoobotName := FoobotIdentityObject.FoobotIdentityList[TheCurrentFoobot].Name; sFoobotName := FoobotIdentityObject.FoobotIdentityList[TheCurrentFoobot].Name;
if not Assigned(HLINI) then if not Assigned(HLINI) then
HLINI := TIniFile.Create(ChangeFileExt(GetAppConfigFile(False), '.ini')); HLINI := TIniFile.Create(ChangeFileExt(GetAppConfigFile(False), '.ini'));

View File

@ -19,8 +19,8 @@
</General> </General>
<VersionInfo> <VersionInfo>
<UseVersionInfo Value="True"/> <UseVersionInfo Value="True"/>
<RevisionNr Value="3"/> <RevisionNr Value="4"/>
<StringTable ProductVersion="0.0.1.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">
<Item1 Name="Debug" Default="True"/> <Item1 Name="Debug" Default="True"/>
@ -78,6 +78,11 @@
</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">
@ -179,16 +184,19 @@
<FormatVersion Value="1"/> <FormatVersion Value="1"/>
</local> </local>
</RunParams> </RunParams>
<RequiredPackages Count="3"> <RequiredPackages Count="4">
<Item1> <Item1>
<PackageName Value="industrial"/> <PackageName Value="TAChartLazarusPkg"/>
</Item1> </Item1>
<Item2> <Item2>
<PackageName Value="cryptini"/> <PackageName Value="industrial"/>
</Item2> </Item2>
<Item3> <Item3>
<PackageName Value="LCL"/> <PackageName Value="cryptini"/>
</Item3> </Item3>
<Item4>
<PackageName Value="LCL"/>
</Item4>
</RequiredPackages> </RequiredPackages>
<Units Count="7"> <Units Count="7">
<Unit0> <Unit0>
@ -262,6 +270,13 @@
</Win32> </Win32>
</Options> </Options>
</Linking> </Linking>
<Other>
<CustomOptions Value="-FcUTF8
-dDEBUGMODE"/>
<OtherDefines Count="1">
<Define0 Value="DEBUGMODE"/>
</OtherDefines>
</Other>
</CompilerOptions> </CompilerOptions>
<Debugging> <Debugging>
<Exceptions Count="3"> <Exceptions Count="3">

View File

@ -15,7 +15,7 @@ uses
cthreads, cthreads,
{$ENDIF}{$ENDIF} {$ENDIF}{$ENDIF}
Interfaces, // this includes the LCL widgetset Interfaces, // this includes the LCL widgetset
Forms, umainform, uconfigform Forms, tachartlazaruspkg, umainform, uconfigform
{ you can add units after this }; { you can add units after this };
{$R *.res} {$R *.res}

View File

@ -4,13 +4,13 @@
<PathDelim Value="\"/> <PathDelim Value="\"/>
<Version Value="10"/> <Version Value="10"/>
<BuildModes Active="linux64"/> <BuildModes Active="linux64"/>
<Units Count="18"> <Units Count="25">
<Unit0> <Unit0>
<Filename Value="foobotmonitor.lpr"/> <Filename Value="foobotmonitor.lpr"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<EditorIndex Value="6"/> <EditorIndex Value="8"/>
<CursorPos X="33" Y="25"/> <CursorPos X="33" Y="25"/>
<UsageCount Value="40"/> <UsageCount Value="72"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit0> </Unit0>
<Unit1> <Unit1>
@ -20,9 +20,9 @@
<HasResources Value="True"/> <HasResources Value="True"/>
<ResourceBaseClass Value="Form"/> <ResourceBaseClass Value="Form"/>
<IsVisibleTab Value="True"/> <IsVisibleTab Value="True"/>
<TopLine Value="18"/> <TopLine Value="23"/>
<CursorPos X="13" Y="26"/> <CursorPos X="72" Y="39"/>
<UsageCount Value="40"/> <UsageCount Value="72"/>
<Loaded Value="True"/> <Loaded Value="True"/>
<LoadedDesigner Value="True"/> <LoadedDesigner Value="True"/>
</Unit1> </Unit1>
@ -32,9 +32,9 @@
<ComponentName Value="configform"/> <ComponentName Value="configform"/>
<HasResources Value="True"/> <HasResources Value="True"/>
<ResourceBaseClass Value="Form"/> <ResourceBaseClass Value="Form"/>
<EditorIndex Value="1"/> <EditorIndex Value="2"/>
<CursorPos X="2" Y="20"/> <CursorPos X="2" Y="20"/>
<UsageCount Value="30"/> <UsageCount Value="62"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit2> </Unit2>
<Unit3> <Unit3>
@ -44,7 +44,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="22"/> <UsageCount Value="54"/>
</Unit3> </Unit3>
<Unit4> <Unit4>
<Filename Value="..\foobot_objects.pas"/> <Filename Value="..\foobot_objects.pas"/>
@ -53,14 +53,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="22"/> <UsageCount Value="54"/>
</Unit4> </Unit4>
<Unit5> <Unit5>
<Filename Value="..\foobot_utility.pas"/> <Filename Value="..\foobot_utility.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<EditorIndex Value="4"/> <EditorIndex Value="5"/>
<CursorPos Y="27"/> <TopLine Value="65"/>
<UsageCount Value="40"/> <CursorPos X="18" Y="83"/>
<UsageCount Value="72"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit5> </Unit5>
<Unit6> <Unit6>
@ -70,21 +71,21 @@
<WindowIndex Value="-1"/> <WindowIndex Value="-1"/>
<TopLine Value="-1"/> <TopLine Value="-1"/>
<CursorPos X="-1" Y="-1"/> <CursorPos X="-1" Y="-1"/>
<UsageCount Value="22"/> <UsageCount Value="54"/>
</Unit6> </Unit6>
<Unit7> <Unit7>
<Filename Value="..\latest_stable\foobot_httpclient.pas"/> <Filename Value="..\latest_stable\foobot_httpclient.pas"/>
<EditorIndex Value="2"/> <EditorIndex Value="3"/>
<TopLine Value="43"/> <TopLine Value="43"/>
<CursorPos X="47" Y="13"/> <CursorPos X="47" Y="13"/>
<UsageCount Value="39"/> <UsageCount Value="53"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit7> </Unit7>
<Unit8> <Unit8>
<Filename Value="..\latest_stable\foobot_objects.pas"/> <Filename Value="..\latest_stable\foobot_objects.pas"/>
<EditorIndex Value="5"/> <EditorIndex Value="7"/>
<CursorPos X="32" Y="61"/> <CursorPos X="32" Y="61"/>
<UsageCount Value="39"/> <UsageCount Value="53"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit8> </Unit8>
<Unit9> <Unit9>
@ -93,12 +94,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="38"/> <UsageCount Value="36"/>
</Unit9> </Unit9>
<Unit10> <Unit10>
<Filename Value="..\latest_stable\umainform.lfm"/> <Filename Value="..\latest_stable\umainform.lfm"/>
<EditorIndex Value="-1"/> <EditorIndex Value="-1"/>
<UsageCount Value="10"/> <UsageCount Value="8"/>
<DefaultSyntaxHighlighter Value="LFM"/> <DefaultSyntaxHighlighter Value="LFM"/>
</Unit10> </Unit10>
<Unit11> <Unit11>
@ -106,21 +107,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="10"/> <UsageCount Value="8"/>
</Unit11> </Unit11>
<Unit12> <Unit12>
<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="18"/> <UsageCount Value="16"/>
</Unit12> </Unit12>
<Unit13> <Unit13>
<Filename Value="..\umainform.pas"/> <Filename Value="..\umainform.pas"/>
<EditorIndex Value="3"/> <EditorIndex Value="4"/>
<TopLine Value="134"/> <TopLine Value="284"/>
<CursorPos X="25" Y="154"/> <CursorPos X="38" Y="313"/>
<UsageCount Value="19"/> <UsageCount Value="33"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit13> </Unit13>
<Unit14> <Unit14>
@ -129,148 +130,203 @@
<EditorIndex Value="-1"/> <EditorIndex Value="-1"/>
<TopLine Value="93"/> <TopLine Value="93"/>
<CursorPos Y="114"/> <CursorPos Y="114"/>
<UsageCount Value="10"/> <UsageCount Value="8"/>
</Unit14> </Unit14>
<Unit15> <Unit15>
<Filename Value="..\ulogin.pas"/> <Filename Value="..\ulogin.pas"/>
<EditorIndex Value="-1"/> <EditorIndex Value="-1"/>
<CursorPos Y="108"/> <CursorPos Y="108"/>
<UsageCount Value="13"/> <UsageCount Value="11"/>
</Unit15> </Unit15>
<Unit16> <Unit16>
<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="11"/> <UsageCount Value="9"/>
</Unit16> </Unit16>
<Unit17> <Unit17>
<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="10"/> <UsageCount Value="8"/>
</Unit17> </Unit17>
<Unit18>
<Filename Value="C:\trunklatest\lazarus\components\IndustrialStuff\source\sensors.pas"/>
<UnitName Value="Sensors"/>
<EditorIndex Value="-1"/>
<TopLine Value="237"/>
<CursorPos Y="265"/>
<UsageCount Value="9"/>
</Unit18>
<Unit19>
<Filename Value="C:\trunklatest\lazarus\ide\lazarus.pp"/>
<UnitName Value="Lazarus"/>
<EditorIndex Value="-1"/>
<TopLine Value="111"/>
<CursorPos X="18" Y="144"/>
<UsageCount Value="9"/>
</Unit19>
<Unit20>
<Filename Value="C:\trunklatest\fpc\rtl\objpas\objpas.pp"/>
<EditorIndex Value="-1"/>
<TopLine Value="11"/>
<CursorPos X="8" Y="33"/>
<UsageCount Value="9"/>
</Unit20>
<Unit21>
<Filename Value="D:\Lazarusprojects\healthmonitor\svn\healthanalysis\healthanalysis\umainform.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="540"/>
<CursorPos X="55" Y="593"/>
<UsageCount Value="9"/>
</Unit21>
<Unit22>
<Filename Value="C:\trunklatest\fpc\rtl\objpas\sysutils\datih.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="109"/>
<CursorPos X="10" Y="128"/>
<UsageCount Value="8"/>
</Unit22>
<Unit23>
<Filename Value="C:\trunklatest\fpc\packages\rtl-objpas\src\inc\dateutil.inc"/>
<EditorIndex Value="6"/>
<TopLine Value="93"/>
<CursorPos X="19" Y="110"/>
<UsageCount Value="22"/>
<Loaded Value="True"/>
</Unit23>
<Unit24>
<Filename Value="..\latest_stable\udataform.pas"/>
<EditorIndex Value="1"/>
<TopLine Value="70"/>
<UsageCount Value="22"/>
<Loaded Value="True"/>
</Unit24>
</Units> </Units>
<OtherDefines Count="1">
<Define0 Value="DEBUGMODE"/>
</OtherDefines>
<JumpHistory Count="30" HistoryIndex="29"> <JumpHistory Count="30" HistoryIndex="29">
<Position1> <Position1>
<Filename Value="umainform.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="165" Column="48" TopLine="145"/> <Caret Line="128" Column="7" TopLine="106"/>
</Position1> </Position1>
<Position2> <Position2>
<Filename Value="umainform.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="153" Column="47" TopLine="132"/> <Caret Line="129" Column="7" TopLine="107"/>
</Position2> </Position2>
<Position3> <Position3>
<Filename Value="umainform.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="105" Column="54" TopLine="80"/> <Caret Line="166" Column="83" TopLine="143"/>
</Position3> </Position3>
<Position4> <Position4>
<Filename Value="umainform.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="106" Column="54" TopLine="81"/> <Caret Line="279" Column="3" TopLine="277"/>
</Position4> </Position4>
<Position5> <Position5>
<Filename Value="umainform.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="107" Column="54" TopLine="82"/> <Caret Line="299" Column="57" TopLine="294"/>
</Position5> </Position5>
<Position6> <Position6>
<Filename Value="umainform.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="127" Column="37" TopLine="93"/> <Caret Line="300" Column="57" TopLine="295"/>
</Position6> </Position6>
<Position7> <Position7>
<Filename Value="umainform.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="202" Column="22" TopLine="197"/> <Caret Line="301" Column="57" TopLine="296"/>
</Position7> </Position7>
<Position8> <Position8>
<Filename Value="umainform.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="127" Column="17" TopLine="105"/> <Caret Line="302" Column="57" TopLine="297"/>
</Position8> </Position8>
<Position9> <Position9>
<Filename Value="umainform.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="207" Column="44" TopLine="184"/> <Caret Line="303" Column="57" TopLine="298"/>
</Position9> </Position9>
<Position10> <Position10>
<Filename Value="umainform.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="289" Column="22" TopLine="286"/> <Caret Line="304" Column="57" TopLine="299"/>
</Position10> </Position10>
<Position11> <Position11>
<Filename Value="umainform.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="216" Column="38" TopLine="194"/> <Caret Line="508" Column="30" TopLine="472"/>
</Position11> </Position11>
<Position12> <Position12>
<Filename Value="umainform.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="130" Column="22" TopLine="107"/> <Caret Line="515" Column="30" TopLine="479"/>
</Position12> </Position12>
<Position13> <Position13>
<Filename Value="umainform.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="131" Column="22" TopLine="108"/> <Caret Line="287" Column="66" TopLine="243"/>
</Position13> </Position13>
<Position14> <Position14>
<Filename Value="umainform.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="132" Column="22" TopLine="109"/> <Caret Line="529" Column="32" TopLine="487"/>
</Position14> </Position14>
<Position15> <Position15>
<Filename Value="umainform.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="134" Column="22" TopLine="111"/> <Caret Line="532" Column="27" TopLine="489"/>
</Position15> </Position15>
<Position16> <Position16>
<Filename Value="umainform.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="216" Column="17" TopLine="205"/> <Caret Line="535" Column="25" TopLine="494"/>
</Position16> </Position16>
<Position17> <Position17>
<Filename Value="umainform.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="134" TopLine="113"/> <Caret Line="531" Column="26" TopLine="494"/>
</Position17> </Position17>
<Position18> <Position18>
<Filename Value="umainform.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="208" Column="10" TopLine="201"/> <Caret Line="530" Column="5" TopLine="495"/>
</Position18> </Position18>
<Position19> <Position19>
<Filename Value="umainform.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="209" Column="10" TopLine="202"/> <Caret Line="529" Column="5" TopLine="494"/>
</Position19> </Position19>
<Position20> <Position20>
<Filename Value="umainform.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="226" TopLine="203"/> <Caret Line="509" Column="22" TopLine="488"/>
</Position20> </Position20>
<Position21> <Position21>
<Filename Value="umainform.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="271" Column="5" TopLine="251"/> <Caret Line="530" Column="25" TopLine="490"/>
</Position21> </Position21>
<Position22> <Position22>
<Filename Value="umainform.pas"/> <Filename Value="..\foobot_utility.pas"/>
<Caret Line="289" Column="57" TopLine="284"/> <Caret Line="243" Column="47" TopLine="218"/>
</Position22> </Position22>
<Position23> <Position23>
<Filename Value="umainform.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="280" Column="3" TopLine="278"/> <Caret Line="527" Column="68" TopLine="486"/>
</Position23> </Position23>
<Position24> <Position24>
<Filename Value="umainform.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="286" Column="3" TopLine="284"/> <Caret Line="523" Column="17" TopLine="488"/>
</Position24> </Position24>
<Position25> <Position25>
<Filename Value="umainform.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="287" Column="3" TopLine="285"/> <Caret Line="245" TopLine="243"/>
</Position25> </Position25>
<Position26> <Position26>
<Filename Value="umainform.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="286" Column="3" TopLine="284"/> <Caret Line="244" TopLine="242"/>
</Position26> </Position26>
<Position27> <Position27>
<Filename Value="umainform.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="287" Column="3" TopLine="285"/> <Caret Line="264" Column="31" TopLine="242"/>
</Position27> </Position27>
<Position28> <Position28>
<Filename Value="umainform.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="294" Column="3" TopLine="292"/> <Caret Line="532" Column="43" TopLine="497"/>
</Position28> </Position28>
<Position29> <Position29>
<Filename Value="umainform.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="283" Column="15" TopLine="281"/> <Caret Line="188" Column="16" TopLine="176"/>
</Position29> </Position29>
<Position30> <Position30>
<Filename Value="umainform.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="11" Column="19" TopLine="7"/> <Caret Line="572" Column="44" TopLine="551"/>
</Position30> </Position30>
</JumpHistory> </JumpHistory>
</ProjectSession> </ProjectSession>

View File

@ -9,7 +9,7 @@
[Setup] [Setup]
AppName=Foobot Monitor AppName=Foobot Monitor
AppVersion=0.0.3.0 AppVersion=0.0.4.0
DefaultDirName={pf}\foobotmonitor DefaultDirName={pf}\foobotmonitor
DefaultGroupName=Foobot DefaultGroupName=Foobot
UninstallDisplayIcon={app}\foobotmonitor.exe UninstallDisplayIcon={app}\foobotmonitor.exe

View File

@ -1,19 +1,18 @@
object mainform: Tmainform object mainform: Tmainform
Left = 614 Left = 583
Height = 262 Height = 451
Top = 109 Top = 174
Width = 782 Width = 784
BorderIcons = [biSystemMenu, biMinimize] BorderIcons = [biSystemMenu, biMinimize]
BorderStyle = bsSingle BorderStyle = bsSingle
Caption = 'mainform' Caption = 'mainform'
ClientHeight = 242 ClientHeight = 431
ClientWidth = 782 ClientWidth = 784
DefaultMonitor = dmDesktop DefaultMonitor = dmDesktop
Menu = MainMenu1 Menu = MainMenu1
OnActivate = FormActivate OnActivate = FormActivate
OnCreate = FormCreate OnCreate = FormCreate
OnDestroy = FormDestroy OnDestroy = FormDestroy
OnShow = FormShow
OnWindowStateChange = FormWindowStateChange OnWindowStateChange = FormWindowStateChange
Position = poWorkAreaCenter Position = poWorkAreaCenter
ShowInTaskBar = stNever ShowInTaskBar = stNever
@ -23,12 +22,12 @@ object mainform: Tmainform
Left = 0 Left = 0
Height = 120 Height = 120
Top = 0 Top = 0
Width = 782 Width = 784
Align = alTop Align = alTop
Caption = 'Current Values' Caption = 'Current Values'
ChildSizing.ControlsPerLine = 6 ChildSizing.ControlsPerLine = 6
ClientHeight = 100 ClientHeight = 100
ClientWidth = 778 ClientWidth = 780
TabOrder = 0 TabOrder = 0
object as_pm: TAnalogSensor object as_pm: TAnalogSensor
Left = 0 Left = 0
@ -43,7 +42,7 @@ object mainform: Tmainform
ShowLevel = True ShowLevel = True
Value = 0 Value = 0
ValueMin = 0 ValueMin = 0
ValueMax = 300 ValueMax = 1000
ValueRed = 0 ValueRed = 0
ValueYellow = 0 ValueYellow = 0
AnalogKind = akAnalog AnalogKind = akAnalog
@ -59,11 +58,11 @@ object mainform: Tmainform
TabOrder = 1 TabOrder = 1
ShowText = True ShowText = True
ShowLevel = True ShowLevel = True
Value = 0 Value = 10
ValueMin = 0 ValueMin = 10
ValueMax = 40 ValueMax = 40
ValueRed = 0 ValueRed = 10
ValueYellow = 0 ValueYellow = 10
AnalogKind = akAnalog AnalogKind = akAnalog
end end
object as_hum: TAnalogSensor object as_hum: TAnalogSensor
@ -77,11 +76,11 @@ object mainform: Tmainform
TabOrder = 2 TabOrder = 2
ShowText = True ShowText = True
ShowLevel = True ShowLevel = True
Value = 0 Value = 10
ValueMin = 0 ValueMin = 10
ValueMax = 100 ValueMax = 100
ValueRed = 0 ValueRed = 10
ValueYellow = 0 ValueYellow = 10
AnalogKind = akAnalog AnalogKind = akAnalog
end end
object as_co2: TAnalogSensor object as_co2: TAnalogSensor
@ -95,11 +94,11 @@ object mainform: Tmainform
TabOrder = 3 TabOrder = 3
ShowText = True ShowText = True
ShowLevel = True ShowLevel = True
Value = 0 Value = 450
ValueMin = 0 ValueMin = 450
ValueMax = 3000 ValueMax = 3000
ValueRed = 0 ValueRed = 450
ValueYellow = 0 ValueYellow = 450
AnalogKind = akAnalog AnalogKind = akAnalog
end end
object as_voc: TAnalogSensor object as_voc: TAnalogSensor
@ -113,11 +112,11 @@ object mainform: Tmainform
TabOrder = 4 TabOrder = 4
ShowText = True ShowText = True
ShowLevel = True ShowLevel = True
Value = 0 Value = 125
ValueMin = 0 ValueMin = 125
ValueMax = 1000 ValueMax = 1000
ValueRed = 0 ValueRed = 125
ValueYellow = 0 ValueYellow = 125
AnalogKind = akAnalog AnalogKind = akAnalog
end end
object as_allpollu: TAnalogSensor object as_allpollu: TAnalogSensor
@ -133,7 +132,7 @@ object mainform: Tmainform
ShowLevel = True ShowLevel = True
Value = 0 Value = 0
ValueMin = 0 ValueMin = 0
ValueMax = 300 ValueMax = 1000
ValueRed = 0 ValueRed = 0
ValueYellow = 0 ValueYellow = 0
AnalogKind = akAnalog AnalogKind = akAnalog
@ -143,14 +142,14 @@ object mainform: Tmainform
Left = 0 Left = 0
Height = 119 Height = 119
Top = 120 Top = 120
Width = 782 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 = 99
ClientWidth = 778 ClientWidth = 780
TabOrder = 1 TabOrder = 1
object grp_pm: TGroupBox object grp_pm: TGroupBox
Left = 0 Left = 0
@ -166,16 +165,16 @@ object mainform: Tmainform
Left = 8 Left = 8
Height = 15 Height = 15
Top = 8 Top = 8
Width = 60 Width = 43
Caption = 'lbl_pmhigh' Caption = 'No stats'
ParentColor = False ParentColor = False
end end
object lbl_pmlow: TLabel object lbl_pmlow: TLabel
Left = 8 Left = 8
Height = 15 Height = 15
Top = 40 Top = 40
Width = 55 Width = 44
Caption = 'lbl_pmlow' Caption = 'No Stats'
ParentColor = False ParentColor = False
end end
end end
@ -193,16 +192,16 @@ object mainform: Tmainform
Left = 8 Left = 8
Height = 15 Height = 15
Top = 8 Top = 8
Width = 64 Width = 44
Caption = 'lbl_tmphigh' Caption = 'No Stats'
ParentColor = False ParentColor = False
end end
object lbl_tmplow: TLabel object lbl_tmplow: TLabel
Left = 8 Left = 8
Height = 15 Height = 15
Top = 40 Top = 40
Width = 59 Width = 44
Caption = 'lbl_tmplow' Caption = 'No Stats'
ParentColor = False ParentColor = False
end end
end end
@ -220,16 +219,16 @@ object mainform: Tmainform
Left = 8 Left = 8
Height = 15 Height = 15
Top = 8 Top = 8
Width = 67 Width = 44
Caption = 'lbl_humhigh' Caption = 'No Stats'
ParentColor = False ParentColor = False
end end
object lbl_humlow: TLabel object lbl_humlow: TLabel
Left = 8 Left = 8
Height = 15 Height = 15
Top = 40 Top = 40
Width = 62 Width = 44
Caption = 'lbl_humlow' Caption = 'No Stats'
ParentColor = False ParentColor = False
end end
end end
@ -247,16 +246,16 @@ object mainform: Tmainform
Left = 8 Left = 8
Height = 15 Height = 15
Top = 8 Top = 8
Width = 61 Width = 44
Caption = 'lbl_co2high' Caption = 'No Stats'
ParentColor = False ParentColor = False
end end
object lbl_co2low: TLabel object lbl_co2low: TLabel
Left = 8 Left = 8
Height = 15 Height = 15
Top = 40 Top = 40
Width = 56 Width = 44
Caption = 'lbl_co2low' Caption = 'No Stats'
ParentColor = False ParentColor = False
end end
end end
@ -274,16 +273,16 @@ object mainform: Tmainform
Left = 8 Left = 8
Height = 15 Height = 15
Top = 8 Top = 8
Width = 61 Width = 44
Caption = 'lbl_vochigh' Caption = 'No Stats'
ParentColor = False ParentColor = False
end end
object lbl_voclow: TLabel object lbl_voclow: TLabel
Left = 8 Left = 8
Height = 15 Height = 15
Top = 40 Top = 40
Width = 56 Width = 44
Caption = 'lbl_voclow' Caption = 'No Stats'
ParentColor = False ParentColor = False
end end
end end
@ -301,20 +300,91 @@ object mainform: Tmainform
Left = 8 Left = 8
Height = 15 Height = 15
Top = 8 Top = 8
Width = 81 Width = 44
Caption = 'lbl_allpolluhigh' Caption = 'No Stats'
ParentColor = False ParentColor = False
end end
object lbl_allpollulow: TLabel object lbl_allpollulow: TLabel
Left = 8 Left = 8
Height = 15 Height = 15
Top = 40 Top = 40
Width = 76 Width = 44
Caption = 'lbl_allpollulow' Caption = 'No Stats'
ParentColor = False ParentColor = False
end end
end end
end end
object grp_chart: TGroupBox
Left = 0
Height = 179
Top = 239
Width = 784
Align = alTop
Caption = 'History'
ClientHeight = 159
ClientWidth = 780
TabOrder = 2
object Chart1: TChart
Left = 0
Height = 159
Top = 0
Width = 780
AxisList = <
item
Marks.Format = '%2:s'
Marks.Style = smsLabel
Minors = <>
Title.LabelFont.Orientation = 900
end
item
Grid.Visible = False
Intervals.Count = 24
Intervals.Options = [aipGraphCoords, aipUseNiceSteps]
Alignment = calBottom
Arrow.Length = 24
Marks.Distance = 0
Marks.Format = '%2:s'
Marks.OverlapPolicy = opHideNeighbour
Marks.Range.Max = 24
Marks.Source = DateTimeIntervalChartSource1
Marks.Style = smsLabel
Minors = <>
Range.Max = 24
Range.UseMax = True
end>
ExtentSizeLimit.UseXMax = True
ExtentSizeLimit.XMax = 24
Foot.Brush.Color = clBtnFace
Foot.Font.Color = clBlue
Foot.Text.Strings = (
'Today'
)
Title.Brush.Color = clBtnFace
Title.Font.Color = clBlue
Title.Text.Strings = (
'Foobot History'
)
Align = alClient
object lineseries_pm: TLineSeries
LinePen.Color = clMaroon
end
object lineseries_tmp: TLineSeries
LinePen.Color = clRed
end
object lineseries_hum: TLineSeries
LinePen.Color = clGreen
end
object lineseries_co2: TLineSeries
LinePen.Color = clLime
end
object lineseries_voc: TLineSeries
LinePen.Color = clNavy
end
object lineseries_allpollu: TLineSeries
LinePen.Color = clBlue
end
end
end
object tmr_foobot: TTimer object tmr_foobot: TTimer
Enabled = False Enabled = False
Interval = 3600 Interval = 3600
@ -375,11 +445,10 @@ object mainform: Tmainform
object mnu_optionsSeperator1: TMenuItem object mnu_optionsSeperator1: TMenuItem
Caption = '-' Caption = '-'
end end
object mnu_optionsShowHighsAndLows: TMenuItem object mnu_optionsShowMinimalDisplay: TMenuItem
AutoCheck = True AutoCheck = True
Caption = 'Show All-time Highs and Lows' Caption = 'Only show guages'
Checked = True OnClick = mnu_optionsShowMinimalDisplayClick
OnClick = mnu_optionsShowHighsAndLowsClick
end end
object mnu_optionsSaveHighLows: TMenuItem object mnu_optionsSaveHighLows: TMenuItem
AutoCheck = True AutoCheck = True
@ -419,4 +488,8 @@ object mainform: Tmainform
OnClick = mnu_fileExitClick OnClick = mnu_fileExitClick
end end
end end
object DateTimeIntervalChartSource1: TDateTimeIntervalChartSource
Left = 174
Top = 325
end
end end

View File

@ -1,4 +1,5 @@
unit umainform; unit umainform;
{ Foobot Monitor { Foobot Monitor
Copyright (C)2016 Gordon Bamber minsadorada@charcodelvalle.com Copyright (C)2016 Gordon Bamber minsadorada@charcodelvalle.com
@ -23,19 +24,24 @@ VERSION HISTORY
V0.0.1.0: Initial commit V0.0.1.0: Initial commit
V0.0.2.0: Trayicon added V0.0.2.0: Trayicon added
V0.0.3.0: Added Help menu. Updated Options menu V0.0.3.0: Added Help menu. Updated Options menu
V0.0.4.0: ?? V0.0.4.0: Graph added
V0.0.5.0: ??
} }
{$ifopt D+}
// Debug mode
{$ENDIF}
{$mode objfpc}{$H+} {$mode objfpc}{$H+}
interface interface
uses uses
Classes, SysUtils, FileUtil, Sensors, Forms, Controls, Graphics, Dialogs, Classes, SysUtils, FileUtil, TAGraph, TAIntervalSources, TASeries, //TASources,
ExtCtrls, StdCtrls, Menus, lclIntf,foobot_utility, uCryptIni, Variants, dateutils, Sensors, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls, Menus,
uconfigform; lclIntf, foobot_utility, uCryptIni, Variants, dateutils, uconfigform;
CONST const
// Timer milliseconds
ONEMINUTE = 60000; ONEMINUTE = 60000;
ONEHOUR = ONEMINUTE * 60; ONEHOUR = ONEMINUTE * 60;
TWOHOURS = ONEHOUR * 2; TWOHOURS = ONEHOUR * 2;
@ -43,6 +49,13 @@ CONST
EIGHTHOURS = ONEHOUR * 8; EIGHTHOURS = ONEHOUR * 8;
TWENTYFOURHOURS = ONEHOUR * 24; TWENTYFOURHOURS = ONEHOUR * 24;
// Colours for guages and graph lines
COL_PM = clMaroon;
COL_TMP = clRed;
COL_HUM = clGreen;
COL_CO2 = clLime;
COL_VOC = clNavy;
COL_ALLPOLLU = clBlue;
type type
@ -55,6 +68,15 @@ type
as_pm: TAnalogSensor; as_pm: TAnalogSensor;
as_tmp: TAnalogSensor; as_tmp: TAnalogSensor;
as_voc: TAnalogSensor; as_voc: TAnalogSensor;
Chart1: TChart;
DateTimeIntervalChartSource1: TDateTimeIntervalChartSource;
lineseries_allpollu: TLineSeries;
lineseries_voc: TLineSeries;
lineseries_co2: TLineSeries;
lineseries_hum: TLineSeries;
lineseries_tmp: TLineSeries;
lineseries_pm: TLineSeries;
grp_chart: TGroupBox;
grp_pm: TGroupBox; grp_pm: TGroupBox;
grp_tmp: TGroupBox; grp_tmp: TGroupBox;
grp_hum: TGroupBox; grp_hum: TGroupBox;
@ -91,7 +113,7 @@ type
mnu_SampleEvery1Hour: TMenuItem; mnu_SampleEvery1Hour: TMenuItem;
mnu_optionsSampleEvery: TMenuItem; mnu_optionsSampleEvery: TMenuItem;
mnu_optionsTakeReadingNow: TMenuItem; mnu_optionsTakeReadingNow: TMenuItem;
mnu_optionsShowHighsAndLows: TMenuItem; mnu_optionsShowMinimalDisplay: TMenuItem;
mnu_options: TMenuItem; mnu_options: TMenuItem;
mnu_fileExit: TMenuItem; mnu_fileExit: TMenuItem;
mnu_file: TMenuItem; mnu_file: TMenuItem;
@ -101,7 +123,6 @@ type
procedure FormActivate(Sender: TObject); procedure FormActivate(Sender: TObject);
procedure FormCreate(Sender: TObject); procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject); procedure FormDestroy(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure FormWindowStateChange(Sender: TObject); procedure FormWindowStateChange(Sender: TObject);
procedure mnupopup_fileRestoreClick(Sender: TObject); procedure mnupopup_fileRestoreClick(Sender: TObject);
procedure mnu_fileExitClick(Sender: TObject); procedure mnu_fileExitClick(Sender: TObject);
@ -109,7 +130,7 @@ type
procedure mnu_optionsMinimiseToTrayClick(Sender: TObject); procedure mnu_optionsMinimiseToTrayClick(Sender: TObject);
procedure mnu_optionsOnlineHelpClick(Sender: TObject); procedure mnu_optionsOnlineHelpClick(Sender: TObject);
procedure mnu_optionsSaveHighLowsClick(Sender: TObject); procedure mnu_optionsSaveHighLowsClick(Sender: TObject);
procedure mnu_optionsShowHighsAndLowsClick(Sender: TObject); procedure mnu_optionsShowMinimalDisplayClick(Sender: TObject);
procedure mnu_optionsTakeReadingNowClick(Sender: TObject); procedure mnu_optionsTakeReadingNowClick(Sender: TObject);
procedure mnu_SampleEvery1HourClick(Sender: TObject); procedure mnu_SampleEvery1HourClick(Sender: TObject);
procedure mnu_SampleEvery24HoursClick(Sender: TObject); procedure mnu_SampleEvery24HoursClick(Sender: TObject);
@ -120,12 +141,14 @@ type
procedure TrayIcon1Click(Sender: TObject); procedure TrayIcon1Click(Sender: TObject);
private private
sSecretKey, sFoobotUserName, sUUID: string; sSecretKey, sFoobotUserName, sUUID: string;
bShowHighsAndLows: boolean; bShowMinimalDisplay: boolean;
iFudgeFactor: integer; iFudgeFactor: integer;
iSampleInterval:Integer; procedure SetUpColours;
procedure DisplayReadings; procedure DisplayReadings;
procedure UpdateGuage(Sender: TAnalogSensor; SensorNumber: integer); procedure UpdateGuage(Sender: TAnalogSensor; SensorNumber: integer);
procedure UpdateHighLow(SensorNumber: integer); procedure UpdateHighLow(SensorNumber: integer);
procedure DrawGraphHistory;
procedure DrawGraph;
public public
INI: TCryptINIfile; INI: TCryptINIfile;
end; end;
@ -156,28 +179,33 @@ begin
FreeAndNil(INI); FreeAndNil(INI);
Application.Terminate; Application.Terminate;
end; end;
INI.SectionHashing:=FALSE; INI.SectionHashing := False;
ResetHighLows; ResetHighLows;
iFudgeFactor := 20; iFudgeFactor := 20; // only needed if height set here
ClientHeight := grp_sensorDisplay.Height + grp_highlow.Height + iFudgeFactor; bShowMinimalDisplay := False;
bShowHighsAndLows := True; TrayIcon1.Icon := Application.Icon;
TrayIcon1.Icon:=Application.Icon; TrayIcon1.Hint := Application.Title;
TrayIcon1.Hint:=Application.Title; DateTimeIntervalChartSource1.DateTimeFormat := 'hh:nn';
SetUpColours;
end; end;
procedure Tmainform.FormActivate(Sender: TObject); procedure Tmainform.FormActivate(Sender: TObject);
Var sTempFoobotUserName,sTempSecretKey:String; var
sTempFoobotUserName, sTempSecretKey: string;
begin begin
ClientHeight := grp_sensorDisplay.Height + grp_highlow.Height +
grp_chart.Height;
// 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');
sTempSecretKey:=INI.ReadUnencryptedString('Config', 'Secret Key', 'unknown'); sTempSecretKey := INI.ReadUnencryptedString('Config', 'Secret Key', 'unknown');
if ((sTempFoobotUserName <> 'unknown') and (sTempSecretKey <> 'unknown')) then if ((sTempFoobotUserName <> 'unknown') and (sTempSecretKey <> 'unknown')) then
begin begin
INI.WriteString('Foobot', 'Foobot User', sTempFoobotUserName); INI.WriteString('Foobot', 'Foobot User', sTempFoobotUserName);
INI.DeleteKey('Config','Foobot User'); INI.DeleteKey('Config', 'Foobot User');
INI.WriteString('Foobot', 'Secret Key', sTempSecretKey); INI.WriteString('Foobot', 'Secret Key', sTempSecretKey);
INI.DeleteKey('Config','Secret Key'); INI.DeleteKey('Config', 'Secret Key');
end; end;
// Fetch Username and API_KEY // Fetch Username and API_KEY
sFoobotUserName := INI.ReadString('Foobot', 'Foobot User', 'unknown'); sFoobotUserName := INI.ReadString('Foobot', 'Foobot User', 'unknown');
@ -190,17 +218,24 @@ begin
if FoobotIdentityObject.FoobotIdentityList.Count > 0 then if FoobotIdentityObject.FoobotIdentityList.Count > 0 then
begin begin
sUUID := FoobotIdentityObject.FoobotIdentityList.Items[0].uuid; sUUID := FoobotIdentityObject.FoobotIdentityList.Items[0].uuid;
SaveLoadHighLows:=INI.ReadBool('Foobot','SaveLoadHighLows',TRUE); SaveLoadHighLows := INI.ReadBool('Foobot', 'SaveLoadHighLows', True);
mnu_optionsSaveHighLows.Checked:=SaveLoadHighLows; mnu_optionsSaveHighLows.Checked := SaveLoadHighLows;
If SaveLoadHighLows then LoadHighLows; if SaveLoadHighLows then
LoadHighLows;
DrawGraphHistory;
{$IFNDEF DEBUGMODE}
mnu_optionsTakeReadingNow.Click; mnu_optionsTakeReadingNow.Click;
{$ENDIF}
// Switch off for testing // Switch off for testing
tmr_foobot.Interval:=ONEHOUR; tmr_foobot.Interval := ONEHOUR;
tmr_foobot.Enabled:=TRUE; {$IFNDEF DEBUGMODE}
tmr_foobot.Enabled := True;
{$ENDIF}
Show; Show;
end; end;
end end
else Close; else
Close;
end end
else else
begin begin
@ -209,7 +244,7 @@ begin
Application.ProcessMessages; Application.ProcessMessages;
configform.ShowModal; configform.ShowModal;
// If user quit without data, then bail out // If user quit without data, then bail out
If NOT configform.bValid then if not configform.bValid then
begin begin
Close; Close;
end; end;
@ -218,7 +253,8 @@ begin
INI.WriteString('Foobot', 'Secret Key', configform.FoobotSecretKey); INI.WriteString('Foobot', 'Secret Key', configform.FoobotSecretKey);
//sFoobotUserName := INI.ReadString('Foobot', 'Foobot User', 'unknown'); //sFoobotUserName := INI.ReadString('Foobot', 'Foobot User', 'unknown');
//sSecretKey := INI.ReadString('Foobot', 'Secret Key', 'unknown'); //sSecretKey := INI.ReadString('Foobot', 'Secret Key', 'unknown');
ShowMessage('Click OK to store settings and close the app.' + LineEnding + 'New settings are applied on resart.'); ShowMessage('Click OK to store settings and close the app.' +
LineEnding + 'New settings are applied on resart.');
Close; Close;
end; end;
end; end;
@ -228,23 +264,35 @@ begin
FreeAndNil(INI); FreeAndNil(INI);
end; end;
procedure Tmainform.FormShow(Sender: TObject); procedure Tmainform.SetUpColours;
begin begin
as_pm.ColorFore := COL_PM;
lineSeries_pm.SeriesColor := COL_PM;
as_tmp.ColorFore := COL_TMP;
lineSeries_tmp.SeriesColor := COL_TMP;
as_hum.ColorFore := COL_HUM;
lineSeries_hum.SeriesColor := COL_HUM;
as_co2.ColorFore := COL_CO2;
lineSeries_co2.SeriesColor := COL_CO2;
as_voc.ColorFore := COL_VOC;
lineSeries_voc.SeriesColor := COL_VOC;
as_allpollu.ColorFore := COL_ALLPOLLU;
lineSeries_allpollu.SeriesColor := COL_ALLPOLLU;
end; end;
procedure Tmainform.FormWindowStateChange(Sender: TObject); procedure Tmainform.FormWindowStateChange(Sender: TObject);
begin begin
if mainform.WindowState = wsMinimized then if mainform.WindowState = wsMinimized then
begin begin
mainform.WindowState := wsNormal; mainform.WindowState := wsNormal;
mainform.Hide; mainform.Hide;
mainform.ShowInTaskBar := stNever; mainform.ShowInTaskBar := stNever;
end; end;
end; end;
procedure Tmainform.mnupopup_fileRestoreClick(Sender: TObject); procedure Tmainform.mnupopup_fileRestoreClick(Sender: TObject);
begin begin
mainform.show; mainform.Show;
end; end;
procedure Tmainform.mnu_fileExitClick(Sender: TObject); procedure Tmainform.mnu_fileExitClick(Sender: TObject);
@ -273,9 +321,10 @@ begin
MessageDlg('About ' + Application.Title, s, MessageDlg('About ' + Application.Title, s,
mtInformation, [mbOK], 0); mtInformation, [mbOK], 0);
end; end;
procedure Tmainform.mnu_optionsMinimiseToTrayClick(Sender: TObject); procedure Tmainform.mnu_optionsMinimiseToTrayClick(Sender: TObject);
begin begin
mainform.WindowState:=wsMinimized; mainform.WindowState := wsMinimized;
mainform.FormWindowStateChange(Self); mainform.FormWindowStateChange(Self);
end; end;
@ -286,17 +335,18 @@ end;
procedure Tmainform.mnu_optionsSaveHighLowsClick(Sender: TObject); procedure Tmainform.mnu_optionsSaveHighLowsClick(Sender: TObject);
begin begin
SaveLoadHighLows:=mnu_optionsSaveHighLows.Checked; SaveLoadHighLows := mnu_optionsSaveHighLows.Checked;
INI.WriteBool('Foobot','SaveLoadHighLows',SaveLoadHighLows); INI.WriteBool('Foobot', 'SaveLoadHighLows', SaveLoadHighLows);
end; end;
procedure Tmainform.mnu_optionsShowHighsAndLowsClick(Sender: TObject); procedure Tmainform.mnu_optionsShowMinimalDisplayClick(Sender: TObject);
begin begin
if mnu_optionsShowHighsAndLows.Checked then if mnu_optionsShowMinimalDisplay.Checked then
mainform.ClientHeight := grp_sensorDisplay.Height + grp_highlow.Height + iFudgeFactor mainform.ClientHeight := grp_sensorDisplay.Height// + iFudgeFactor
else else
mainform.ClientHeight := grp_sensorDisplay.Height;// + iFudgeFactor; mainform.ClientHeight := grp_sensorDisplay.Height + grp_chart.Height +
bShowHighsAndLows := mnu_optionsShowHighsAndLows.Checked; grp_highlow.Height;// + iFudgeFactor;
bShowMinimalDisplay := mnu_optionsShowMinimalDisplay.Checked;
end; end;
procedure Tmainform.mnu_optionsTakeReadingNowClick(Sender: TObject); procedure Tmainform.mnu_optionsTakeReadingNowClick(Sender: TObject);
@ -312,37 +362,37 @@ end;
procedure Tmainform.mnu_SampleEvery1HourClick(Sender: TObject); procedure Tmainform.mnu_SampleEvery1HourClick(Sender: TObject);
begin begin
tmr_foobot.Enabled:=FALSE; tmr_foobot.Enabled := False;
tmr_foobot.Interval:=ONEHOUR; tmr_foobot.Interval := ONEHOUR;
tmr_foobot.Enabled:=TRUE; tmr_foobot.Enabled := True;
end; end;
procedure Tmainform.mnu_SampleEvery24HoursClick(Sender: TObject); procedure Tmainform.mnu_SampleEvery24HoursClick(Sender: TObject);
begin begin
tmr_foobot.Enabled:=FALSE; tmr_foobot.Enabled := False;
tmr_foobot.Interval:=TWENTYFOURHOURS; tmr_foobot.Interval := TWENTYFOURHOURS;
tmr_foobot.Enabled:=TRUE; tmr_foobot.Enabled := True;
end; end;
procedure Tmainform.mnu_SampleEvery2HoursClick(Sender: TObject); procedure Tmainform.mnu_SampleEvery2HoursClick(Sender: TObject);
begin begin
tmr_foobot.Enabled:=FALSE; tmr_foobot.Enabled := False;
tmr_foobot.Interval:=TWOHOURS; tmr_foobot.Interval := TWOHOURS;
tmr_foobot.Enabled:=TRUE; tmr_foobot.Enabled := True;
end; end;
procedure Tmainform.mnu_SampleEvery4HoursClick(Sender: TObject); procedure Tmainform.mnu_SampleEvery4HoursClick(Sender: TObject);
begin begin
tmr_foobot.Enabled:=FALSE; tmr_foobot.Enabled := False;
tmr_foobot.Interval:=FOURHOURS; tmr_foobot.Interval := FOURHOURS;
tmr_foobot.Enabled:=TRUE; tmr_foobot.Enabled := True;
end; end;
procedure Tmainform.mnu_SampleEvery8HoursClick(Sender: TObject); procedure Tmainform.mnu_SampleEvery8HoursClick(Sender: TObject);
begin begin
tmr_foobot.Enabled:=FALSE; tmr_foobot.Enabled := False;
tmr_foobot.Interval:=EIGHTHOURS; tmr_foobot.Interval := EIGHTHOURS;
tmr_foobot.Enabled:=TRUE; tmr_foobot.Enabled := True;
end; end;
procedure Tmainform.tmr_foobotTimer(Sender: TObject); procedure Tmainform.tmr_foobotTimer(Sender: TObject);
@ -353,7 +403,7 @@ end;
procedure Tmainform.TrayIcon1Click(Sender: TObject); procedure Tmainform.TrayIcon1Click(Sender: TObject);
begin begin
mainform.show; mainform.Show;
end; end;
procedure Tmainform.UpdateHighLow(SensorNumber: integer); procedure Tmainform.UpdateHighLow(SensorNumber: integer);
@ -361,61 +411,56 @@ begin
case SensorNumber of case SensorNumber of
1: 1:
begin begin
lbl_pmhigh.Caption := Format( lbl_pmhigh.Caption := Format('High: %f %s',
'High: %f %s', [double(FoobotDataHighs[SensorNumber]), [double(FoobotDataHighs[SensorNumber]), FoobotDataObject.Units[SensorNumber]]) +
FoobotDataObject.Units[SensorNumber]]) + LineEnding + 'on ' + LineEnding + 'on ' + FormatDateTime('dd/mm tt',
FormatDateTime('dd/mm tt', TDateTime(FoobotDataHighTimes[SensorNumber])); TDateTime(FoobotDataHighTimes[SensorNumber]));
lbl_pmLow.Caption := Format( lbl_pmLow.Caption := Format('Low: %f %s',
'Low: %f %s', [double(FoobotDataLows[SensorNumber]), [double(FoobotDataLows[SensorNumber]), FoobotDataObject.Units[SensorNumber]]) +
FoobotDataObject.Units[SensorNumber]]) +
LineEnding + 'on ' + FormatDateTime('dd/mm tt', TDateTime( LineEnding + 'on ' + FormatDateTime('dd/mm tt', TDateTime(
FoobotDataLowTimes[SensorNumber])); FoobotDataLowTimes[SensorNumber]));
end; end;
2: 2:
begin begin
lbl_tmphigh.Caption := Format( lbl_tmphigh.Caption := Format('High: %f %s',
'High: %f %s', [double(FoobotDataHighs[SensorNumber]), [double(FoobotDataHighs[SensorNumber]), FoobotDataObject.Units[SensorNumber]]) +
FoobotDataObject.Units[SensorNumber]]) + LineEnding + 'on ' + LineEnding + 'on ' + FormatDateTime('dd/mm tt',
FormatDateTime('dd/mm tt', TDateTime(FoobotDataHighTimes[SensorNumber])); TDateTime(FoobotDataHighTimes[SensorNumber]));
lbl_tmpLow.Caption := Format( lbl_tmpLow.Caption := Format('Low: %f %s',
'Low: %f %s', [double(FoobotDataLows[SensorNumber]), [double(FoobotDataLows[SensorNumber]), FoobotDataObject.Units[SensorNumber]]) +
FoobotDataObject.Units[SensorNumber]]) +
LineEnding + 'on ' + FormatDateTime('dd/mm tt', TDateTime( LineEnding + 'on ' + FormatDateTime('dd/mm tt', TDateTime(
FoobotDataLowTimes[SensorNumber])); FoobotDataLowTimes[SensorNumber]));
end; end;
3: 3:
begin begin
lbl_humhigh.Caption := Format( lbl_humhigh.Caption := Format('High: %f %s',
'High: %f %s', [double(FoobotDataHighs[SensorNumber]), [double(FoobotDataHighs[SensorNumber]), FoobotDataObject.Units[SensorNumber]]) +
FoobotDataObject.Units[SensorNumber]]) + LineEnding + 'on ' + LineEnding + 'on ' + FormatDateTime('dd/mm tt',
FormatDateTime('dd/mm tt', TDateTime(FoobotDataHighTimes[SensorNumber])); TDateTime(FoobotDataHighTimes[SensorNumber]));
lbl_humLow.Caption := Format( lbl_humLow.Caption := Format('Low: %f %s',
'Low: %f %s', [double(FoobotDataLows[SensorNumber]), [double(FoobotDataLows[SensorNumber]), FoobotDataObject.Units[SensorNumber]]) +
FoobotDataObject.Units[SensorNumber]]) +
LineEnding + 'on ' + FormatDateTime('dd/mm tt', TDateTime( LineEnding + 'on ' + FormatDateTime('dd/mm tt', TDateTime(
FoobotDataLowTimes[SensorNumber])); FoobotDataLowTimes[SensorNumber]));
end; end;
4: 4:
begin begin
lbl_co2high.Caption := Format( lbl_co2high.Caption := Format('High: %f %s',
'High: %f %s', [double(FoobotDataHighs[SensorNumber]), [double(FoobotDataHighs[SensorNumber]), FoobotDataObject.Units[SensorNumber]]) +
FoobotDataObject.Units[SensorNumber]]) + LineEnding + 'on ' + LineEnding + 'on ' + FormatDateTime('dd/mm tt',
FormatDateTime('dd/mm tt', TDateTime(FoobotDataHighTimes[SensorNumber])); TDateTime(FoobotDataHighTimes[SensorNumber]));
lbl_co2Low.Caption := Format( lbl_co2Low.Caption := Format('Low: %f %s',
'Low: %f %s', [double(FoobotDataLows[SensorNumber]), [double(FoobotDataLows[SensorNumber]), FoobotDataObject.Units[SensorNumber]]) +
FoobotDataObject.Units[SensorNumber]]) +
LineEnding + 'on ' + FormatDateTime('dd/mm tt', TDateTime( LineEnding + 'on ' + FormatDateTime('dd/mm tt', TDateTime(
FoobotDataLowTimes[SensorNumber])); FoobotDataLowTimes[SensorNumber]));
end; end;
5: 5:
begin begin
lbl_vochigh.Caption := Format( lbl_vochigh.Caption := Format('High: %f %s',
'High: %f %s', [double(FoobotDataHighs[SensorNumber]), [double(FoobotDataHighs[SensorNumber]), FoobotDataObject.Units[SensorNumber]]) +
FoobotDataObject.Units[SensorNumber]]) + LineEnding + 'on ' + LineEnding + 'on ' + FormatDateTime('dd/mm tt',
FormatDateTime('dd/mm tt', TDateTime(FoobotDataHighTimes[SensorNumber])); TDateTime(FoobotDataHighTimes[SensorNumber]));
lbl_vocLow.Caption := Format( lbl_vocLow.Caption := Format('Low: %f %s',
'Low: %f %s', [double(FoobotDataLows[SensorNumber]), [double(FoobotDataLows[SensorNumber]), FoobotDataObject.Units[SensorNumber]]) +
FoobotDataObject.Units[SensorNumber]]) +
LineEnding + 'on ' + FormatDateTime('dd/mm tt', TDateTime( LineEnding + 'on ' + FormatDateTime('dd/mm tt', TDateTime(
FoobotDataLowTimes[SensorNumber])); FoobotDataLowTimes[SensorNumber]));
end; end;
@ -483,7 +528,7 @@ var
begin begin
if FoobotDataObjectToArrays = True then if FoobotDataObjectToArrays = True then
begin begin
mainform.Caption := Format('Foobot "%s" - ', mainform.Caption := Format('Foobot "%s" - Last reading: ',
[FoobotIdentityObject.FoobotIdentityList[0].Name]) + [FoobotIdentityObject.FoobotIdentityList[0].Name]) +
FormatDateTime('dd/mm/yyyy - tt', FoobotData_time[0]); FormatDateTime('dd/mm/yyyy - tt', FoobotData_time[0]);
UpdateGuage(as_pm, 1); UpdateGuage(as_pm, 1);
@ -492,10 +537,63 @@ begin
UpdateGuage(as_co2, 4); UpdateGuage(as_co2, 4);
UpdateGuage(as_voc, 5); UpdateGuage(as_voc, 5);
UpdateGuage(as_allpollu, 6); UpdateGuage(as_allpollu, 6);
if bShowHighsAndLows then if not bShowMinimalDisplay then
begin
for iCount := 1 to 6 do for iCount := 1 to 6 do
UpdateHighLow(iCount); UpdateHighLow(iCount);
end;
DrawGraph;
end; end;
end; end;
function AsPercent(aValue, aMax: double): double;
begin
if aMax > 0 then
Result := aValue / aMax * 100
else
Result := 0;
end;
procedure Tmainform.DrawGraph;
begin
lineseries_pm.AddXY(FoobotData_time[0], AsPercent(FoobotData_pm[0], as_pm.ValueMax));
lineseries_tmp.AddXY(FoobotData_time[0], AsPercent(FoobotData_tmp[0], as_tmp.ValueMax));
lineseries_hum.AddXY(FoobotData_time[0], AsPercent(FoobotData_hum[0], as_hum.ValueMax));
lineseries_co2.AddXY(FoobotData_time[0], AsPercent(FoobotData_co2[0], as_co2.ValueMax));
lineseries_voc.AddXY(FoobotData_time[0], AsPercent(FoobotData_voc[0], as_voc.ValueMax));
lineseries_allpollu.AddXY(FoobotData_time[0],
AsPercent(FoobotData_allpollu[0], as_allpollu.ValueMax));
end;
procedure Tmainform.DrawGraphHistory;
// Fetch Hourly readings for the previous 2 days (AverageBy=3600)
// Populate FoobotDataObjectToArrays
var
iCount: integer;
iStartSeconds, iEndSeconds: int64;
begin
iEndSeconds := DateTimeToUnix(Now) - 3600;
iStartSeconds := iEndSeconds - (2 * (24 * 3600));
if FetchFoobotData(dfStartEnd, 0, 0, 3600, iStartSeconds, iEndSeconds, sSecretKey) =
False then
exit;
if FoobotDataObjectToArrays then
for iCount := 0 to Pred(High(FoobotData_time)) do
begin
lineseries_pm.AddXY(FoobotData_time[iCount],
AsPercent(FoobotData_pm[iCount], as_pm.ValueMax));
lineseries_tmp.AddXY(FoobotData_time[iCount],
AsPercent(FoobotData_tmp[iCount], as_tmp.ValueMax));
lineseries_hum.AddXY(FoobotData_time[iCount],
AsPercent(FoobotData_hum[iCount], as_hum.ValueMax));
lineseries_co2.AddXY(FoobotData_time[iCount],
AsPercent(FoobotData_co2[iCount], as_co2.ValueMax));
lineseries_voc.AddXY(FoobotData_time[iCount],
AsPercent(FoobotData_voc[iCount], as_voc.ValueMax));
lineseries_allpollu.AddXY(FoobotData_time[iCount],
AsPercent(FoobotData_allpollu[iCount], as_allpollu.ValueMax));
end;
ResetArrays; // at end
end;
end. end.