To V0.1.2.0

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5592 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
gbamber
2017-01-05 09:17:25 +00:00
parent e7dce54cf8
commit 0f07b81e94
12 changed files with 274 additions and 158 deletions

View File

@ -272,9 +272,11 @@ procedure TSensorPanel.SetValueRed(AValue: Double);
begin
if (AValue <> FValueRed) then
begin
if (AValue < FValueMin) or (AValue > FValueMax) then
{
if (AValue < 0) or (AValue > FValueMax) then
if not (csLoading in ComponentState) then
raise EInvalidOperation.CreateFmt('SOutOfRange', [Round(FValueMin), Round(FValueMax)]);
}
FValueRed := AValue;
Invalidate;
end;
@ -284,9 +286,11 @@ procedure TSensorPanel.SetValueYellow(AValue: Double);
begin
if (AValue <> FValueYellow) then
begin
if (AValue < 1) or (AValue > FValueMax) then
{
if (AValue < 0) or (AValue > FValueMax) then
if not (csLoading in ComponentState) then
raise EInvalidOperation.CreateFmt('SOutOfRange', [Round(FValueRed), Round(FValueMax)]);
}
FValueYellow := AValue;
Invalidate;
end;

View File

@ -20,7 +20,7 @@
<VersionInfo>
<UseVersionInfo Value="True"/>
<MinorVersionNr Value="1"/>
<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"/>
</VersionInfo>
<BuildModes Count="6">
@ -209,7 +209,7 @@
<PackageName Value="LCL"/>
</Item4>
</RequiredPackages>
<Units Count="7">
<Units Count="8">
<Unit0>
<Filename Value="foobotmonitor.lpr"/>
<IsPartOfProject Value="True"/>
@ -244,6 +244,10 @@
<Filename Value="..\ugenericcollection.pas"/>
<IsPartOfProject Value="True"/>
</Unit6>
<Unit7>
<Filename Value="foobot_sensors.pas"/>
<IsPartOfProject Value="True"/>
</Unit7>
</Units>
</ProjectOptions>
<CompilerOptions>

View File

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

View File

@ -4,13 +4,13 @@
<PathDelim Value="\"/>
<Version Value="10"/>
<BuildModes Active="linux64"/>
<Units Count="27">
<Units Count="29">
<Unit0>
<Filename Value="foobotmonitor.lpr"/>
<IsPartOfProject Value="True"/>
<EditorIndex Value="10"/>
<EditorIndex Value="11"/>
<CursorPos X="33" Y="25"/>
<UsageCount Value="84"/>
<UsageCount Value="86"/>
<Loaded Value="True"/>
</Unit0>
<Unit1>
@ -19,9 +19,9 @@
<ComponentName Value="mainform"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<TopLine Value="59"/>
<CursorPos X="15" Y="79"/>
<UsageCount Value="84"/>
<TopLine Value="417"/>
<CursorPos X="29" Y="424"/>
<UsageCount Value="86"/>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
</Unit1>
@ -31,9 +31,9 @@
<ComponentName Value="configform"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<EditorIndex Value="4"/>
<EditorIndex Value="5"/>
<CursorPos X="2" Y="20"/>
<UsageCount Value="74"/>
<UsageCount Value="76"/>
<Loaded Value="True"/>
</Unit2>
<Unit3>
@ -43,7 +43,7 @@
<WindowIndex Value="-1"/>
<TopLine Value="-1"/>
<CursorPos X="-1" Y="-1"/>
<UsageCount Value="66"/>
<UsageCount Value="68"/>
</Unit3>
<Unit4>
<Filename Value="..\foobot_objects.pas"/>
@ -52,15 +52,15 @@
<WindowIndex Value="-1"/>
<TopLine Value="-1"/>
<CursorPos X="-1" Y="-1"/>
<UsageCount Value="66"/>
<UsageCount Value="68"/>
</Unit4>
<Unit5>
<Filename Value="..\foobot_utility.pas"/>
<IsPartOfProject Value="True"/>
<EditorIndex Value="7"/>
<EditorIndex Value="8"/>
<TopLine Value="34"/>
<CursorPos X="18" Y="83"/>
<UsageCount Value="84"/>
<UsageCount Value="86"/>
<Loaded Value="True"/>
</Unit5>
<Unit6>
@ -70,21 +70,21 @@
<WindowIndex Value="-1"/>
<TopLine Value="-1"/>
<CursorPos X="-1" Y="-1"/>
<UsageCount Value="66"/>
<UsageCount Value="68"/>
</Unit6>
<Unit7>
<Filename Value="..\latest_stable\foobot_httpclient.pas"/>
<EditorIndex Value="5"/>
<EditorIndex Value="6"/>
<TopLine Value="43"/>
<CursorPos X="47" Y="13"/>
<UsageCount Value="58"/>
<UsageCount Value="59"/>
<Loaded Value="True"/>
</Unit7>
<Unit8>
<Filename Value="..\latest_stable\foobot_objects.pas"/>
<EditorIndex Value="9"/>
<EditorIndex Value="10"/>
<CursorPos X="32" Y="61"/>
<UsageCount Value="58"/>
<UsageCount Value="59"/>
<Loaded Value="True"/>
</Unit8>
<Unit9>
@ -117,10 +117,10 @@
</Unit12>
<Unit13>
<Filename Value="..\umainform.pas"/>
<EditorIndex Value="6"/>
<EditorIndex Value="7"/>
<TopLine Value="284"/>
<CursorPos X="38" Y="313"/>
<UsageCount Value="38"/>
<UsageCount Value="39"/>
<Loaded Value="True"/>
</Unit13>
<Unit14>
@ -152,20 +152,19 @@
</Unit17>
<Unit18>
<Filename Value="foobot_sensors.pas"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="1"/>
<TopLine Value="258"/>
<CursorPos X="44" Y="274"/>
<EditorIndex Value="-1"/>
<TopLine Value="251"/>
<CursorPos X="13" Y="16"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</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"/>
<EditorIndex Value="3"/>
<TopLine Value="101"/>
<CursorPos Y="154"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit19>
<Unit20>
<Filename Value="C:\trunklatest\fpc\rtl\objpas\objpas.pp"/>
@ -190,25 +189,25 @@
</Unit22>
<Unit23>
<Filename Value="C:\trunklatest\fpc\packages\rtl-objpas\src\inc\dateutil.inc"/>
<EditorIndex Value="8"/>
<EditorIndex Value="9"/>
<TopLine Value="381"/>
<CursorPos X="24" Y="409"/>
<UsageCount Value="27"/>
<UsageCount Value="28"/>
<Loaded Value="True"/>
</Unit23>
<Unit24>
<Filename Value="..\latest_stable\udataform.pas"/>
<EditorIndex Value="3"/>
<EditorIndex Value="4"/>
<TopLine Value="70"/>
<UsageCount Value="27"/>
<UsageCount Value="28"/>
<Loaded Value="True"/>
</Unit24>
<Unit25>
<Filename Value="D:\lazarustrunk\common_components\cryptini\ucryptini.pas"/>
<EditorIndex Value="2"/>
<EditorIndex Value="1"/>
<TopLine Value="781"/>
<CursorPos X="28" Y="795"/>
<UsageCount Value="12"/>
<UsageCount Value="13"/>
<Loaded Value="True"/>
</Unit25>
<Unit26>
@ -218,131 +217,139 @@
<CursorPos X="19" Y="51"/>
<UsageCount Value="12"/>
</Unit26>
<Unit27>
<Filename Value="C:\trunklatest\lazarus\components\IndustrialStuff\industrial.pas"/>
<EditorIndex Value="-1"/>
<CursorPos X="18" Y="11"/>
<UsageCount Value="10"/>
</Unit27>
<Unit28>
<Filename Value="foobot_sensors.pas"/>
<IsPartOfProject Value="True"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="2"/>
<TopLine Value="310"/>
<CursorPos X="6" Y="292"/>
<UsageCount Value="20"/>
<Loaded Value="True"/>
</Unit28>
</Units>
<OtherDefines Count="1">
<Define0 Value="DEBUGMODE"/>
</OtherDefines>
<JumpHistory Count="30" HistoryIndex="29">
<JumpHistory Count="28" HistoryIndex="27">
<Position1>
<Filename Value="umainform.pas"/>
<Caret Line="529" Column="32" TopLine="487"/>
<Caret Line="374" Column="71" TopLine="344"/>
</Position1>
<Position2>
<Filename Value="umainform.pas"/>
<Caret Line="532" Column="27" TopLine="489"/>
<Caret Line="373" Column="11" TopLine="351"/>
</Position2>
<Position3>
<Filename Value="umainform.pas"/>
<Caret Line="535" Column="25" TopLine="494"/>
<Caret Line="292" Column="24" TopLine="248"/>
</Position3>
<Position4>
<Filename Value="umainform.pas"/>
<Caret Line="531" Column="26" TopLine="494"/>
<Caret Line="286" Column="21" TopLine="283"/>
</Position4>
<Position5>
<Filename Value="umainform.pas"/>
<Caret Line="530" Column="5" TopLine="495"/>
<Caret Line="58" Column="29" TopLine="35"/>
</Position5>
<Position6>
<Filename Value="umainform.pas"/>
<Caret Line="529" Column="5" TopLine="494"/>
<Caret Line="347" Column="40" TopLine="311"/>
</Position6>
<Position7>
<Filename Value="umainform.pas"/>
<Caret Line="509" Column="22" TopLine="488"/>
<Filename Value="D:\lazarustrunk\common_components\cryptini\ucryptini.pas"/>
<Caret Line="795" Column="28" TopLine="781"/>
</Position7>
<Position8>
<Filename Value="umainform.pas"/>
<Caret Line="530" Column="25" TopLine="490"/>
<Caret Line="646" Column="114" TopLine="641"/>
</Position8>
<Position9>
<Filename Value="..\foobot_utility.pas"/>
<Caret Line="243" Column="47" TopLine="218"/>
<Filename Value="umainform.pas"/>
<Caret Line="434" Column="3" TopLine="434"/>
</Position9>
<Position10>
<Filename Value="umainform.pas"/>
<Caret Line="527" Column="68" TopLine="486"/>
<Caret Line="48" Column="11" TopLine="34"/>
</Position10>
<Position11>
<Filename Value="umainform.pas"/>
<Caret Line="523" Column="17" TopLine="488"/>
<Caret Line="79" Column="15" TopLine="59"/>
</Position11>
<Position12>
<Filename Value="umainform.pas"/>
<Caret Line="245" TopLine="243"/>
<Caret Line="434" Column="3" TopLine="432"/>
</Position12>
<Position13>
<Filename Value="umainform.pas"/>
<Caret Line="244" TopLine="242"/>
<Caret Line="435" Column="3" TopLine="433"/>
</Position13>
<Position14>
<Filename Value="umainform.pas"/>
<Caret Line="264" Column="31" TopLine="242"/>
<Caret Line="436" Column="3" TopLine="434"/>
</Position14>
<Position15>
<Filename Value="umainform.pas"/>
<Caret Line="532" Column="43" TopLine="497"/>
<Caret Line="443" TopLine="441"/>
</Position15>
<Position16>
<Filename Value="umainform.pas"/>
<Caret Line="188" Column="16" TopLine="176"/>
<Caret Line="179" Column="43" TopLine="156"/>
</Position16>
<Position17>
<Filename Value="umainform.pas"/>
<Caret Line="572" Column="44" TopLine="551"/>
<Caret Line="180" Column="60" TopLine="167"/>
</Position17>
<Position18>
<Filename Value="umainform.pas"/>
<Caret Line="613" Column="58" TopLine="591"/>
<Caret Line="648" TopLine="627"/>
</Position18>
<Position19>
<Filename Value="umainform.pas"/>
<Caret Line="620" Column="58" TopLine="598"/>
<Caret Line="669" Column="41" TopLine="664"/>
</Position19>
<Position20>
<Filename Value="umainform.pas"/>
<Caret Line="374" Column="71" TopLine="344"/>
<Caret Line="188" Column="29" TopLine="166"/>
</Position20>
<Position21>
<Filename Value="umainform.pas"/>
<Caret Line="373" Column="11" TopLine="351"/>
<Caret Line="425" Column="3" TopLine="423"/>
</Position21>
<Position22>
<Filename Value="umainform.pas"/>
<Caret Line="292" Column="24" TopLine="248"/>
<Caret Line="415" Column="5" TopLine="413"/>
</Position22>
<Position23>
<Filename Value="umainform.pas"/>
<Caret Line="286" Column="21" TopLine="283"/>
<Caret Line="439" Column="3" TopLine="437"/>
</Position23>
<Position24>
<Filename Value="umainform.pas"/>
<Caret Line="58" Column="29" TopLine="35"/>
<Caret Line="548" Column="26" TopLine="546"/>
</Position24>
<Position25>
<Filename Value="umainform.pas"/>
<Caret Line="347" Column="40" TopLine="311"/>
<Caret Line="563" TopLine="534"/>
</Position25>
<Position26>
<Filename Value="D:\lazarustrunk\common_components\cryptini\ucryptini.pas"/>
<Caret Line="795" Column="28" TopLine="781"/>
</Position26>
<Position27>
<Filename Value="umainform.pas"/>
<Caret Line="646" Column="114" TopLine="641"/>
<Filename Value="C:\trunklatest\lazarus\ide\lazarus.pp"/>
<Caret Line="154" TopLine="111"/>
</Position27>
<Position28>
<Filename Value="umainform.pas"/>
<Caret Line="433" Column="3" TopLine="583"/>
<Caret Line="563" Column="28" TopLine="561"/>
</Position28>
<Position29>
<Filename Value="umainform.pas"/>
<Caret Line="434" Column="3" TopLine="434"/>
</Position29>
<Position30>
<Filename Value="umainform.pas"/>
<Caret Line="48" Column="11" TopLine="34"/>
</Position30>
</JumpHistory>
</ProjectSession>
</CONFIG>

View File

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

View File

@ -0,0 +1,7 @@
Foobot Monitor
==============
Notes:
Requirements are CryptINI, Industrial, TAChart
Note unit in Industrial package 'sensors.pas' has been modified to 'foobot_sensors.pas'

Binary file not shown.

View File

@ -63,7 +63,7 @@ object mainform: Tmainform
ValueMin = 0
ValueMax = 40
ValueRed = 0
ValueYellow = 30
ValueYellow = 1
AnalogKind = akAnalog
end
object as_hum: TAnalogSensor
@ -452,10 +452,24 @@ object mainform: Tmainform
object mnu_optionsSeperator1: TMenuItem
Caption = '-'
end
object mnu_optionsShowMinimalDisplay: TMenuItem
object mnu_optionsDisplay: TMenuItem
Caption = 'Display...'
OnClick = mnu_optionsDisplayClick
object mnu_optionsDisplayGuagesOnly: TMenuItem
AutoCheck = True
Caption = 'Only show guages'
OnClick = mnu_optionsShowMinimalDisplayClick
Caption = 'Guages only'
OnClick = mnu_optionsDisplayGuagesOnlyClick
end
object mnu_optionsDisplayYellowLines: TMenuItem
AutoCheck = True
Caption = 'Recommended values'
OnClick = mnu_optionsDisplayYellowLinesClick
end
object mnu_optionsDisplayRedLines: TMenuItem
AutoCheck = True
Caption = 'Session maximums'
OnClick = mnu_optionsDisplayRedLinesClick
end
end
object mnu_optionsSaveHighLows: TMenuItem
AutoCheck = True

View File

@ -39,7 +39,7 @@ interface
uses
SysUtils, TAGraph, TAIntervalSources, TASeries,
Sensors, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls, Menus,
foobot_sensors, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls, Menus,
lclIntf, foobot_utility, uCryptIni, dateutils, uconfigform, Classes;
const
@ -123,6 +123,9 @@ type
lbl_voclow: TLabel;
lbl_allpollulow: TLabel;
MainMenu1: TMainMenu;
mnu_optionsDisplayRedLines: TMenuItem;
mnu_optionsDisplayYellowLines: TMenuItem;
mnu_optionsDisplayGuagesOnly: TMenuItem;
mnu_SampleEveryHalfHour: TMenuItem;
mnu_optionsResetHighsLows: TMenuItem;
mnu_optionsOnlineHelp: TMenuItem;
@ -140,7 +143,7 @@ type
mnu_SampleEvery1Hour: TMenuItem;
mnu_optionsSampleEvery: TMenuItem;
mnu_optionsTakeReadingNow: TMenuItem;
mnu_optionsShowMinimalDisplay: TMenuItem;
mnu_optionsDisplay: TMenuItem;
mnu_options: TMenuItem;
mnu_fileExit: TMenuItem;
mnu_file: TMenuItem;
@ -155,11 +158,14 @@ type
procedure mnupopup_fileRestoreClick(Sender: TObject);
procedure mnu_fileExitClick(Sender: TObject);
procedure mnu_helpAboutClick(Sender: TObject);
procedure mnu_optionsDisplayGuagesOnlyClick(Sender: TObject);
procedure mnu_optionsDisplayRedLinesClick(Sender: TObject);
procedure mnu_optionsDisplayYellowLinesClick(Sender: TObject);
procedure mnu_optionsMinimiseToTrayClick(Sender: TObject);
procedure mnu_optionsOnlineHelpClick(Sender: TObject);
procedure mnu_optionsResetHighsLowsClick(Sender: TObject);
procedure mnu_optionsSaveHighLowsClick(Sender: TObject);
procedure mnu_optionsShowMinimalDisplayClick(Sender: TObject);
procedure mnu_optionsDisplayClick(Sender: TObject);
procedure mnu_optionsTakeReadingNowClick(Sender: TObject);
procedure mnu_SampleEvery1HourClick(Sender: TObject);
procedure mnu_SampleEvery24HoursClick(Sender: TObject);
@ -171,14 +177,15 @@ type
procedure TrayIcon1Click(Sender: TObject);
private
sSecretKey, sFoobotUserName, sUUID: string;
bShowMinimalDisplay: boolean;
bDisplayGuagesOnly, bDisplayYellowLines, bDisplayRedLines: boolean;
iFudgeFactor: integer;
procedure DisplayReadings;
procedure UpdateGuage(Sender: TAnalogSensor; SensorNumber: integer);
procedure UpdateHighLow(SensorNumber: integer);
procedure GraphHistory;
procedure GraphCurrentReading;
Procedure SetRecommendedLevels;
procedure SetYellowRecommendedLevels;
procedure SetRedSessionMax;
procedure SaveConfig;
procedure LoadConfig;
public
@ -214,7 +221,11 @@ begin
INI.SectionHashing := False;
ResetHighLows;
iFudgeFactor := 20; // only needed if height set here
bShowMinimalDisplay := False;
bDisplayGuagesOnly := False;
bDisplayYellowLines := False;
SetYellowRecommendedLevels;
bDisplayRedLines := False;
SetRedSessionMax;
TrayIcon1.Icon := Application.Icon;
TrayIcon1.Hint := Application.Title;
DateTimeIntervalChartSource1.DateTimeFormat := 'hh:nn';
@ -293,50 +304,52 @@ end;
procedure Tmainform.FormClose(Sender: TObject; var CloseAction: TCloseAction);
begin
SaveConfig;
CloseAction:=caFree;
CloseAction := caFree;
end;
procedure Tmainform.FormDestroy(Sender: TObject);
begin
FreeAndNil(INI);
end;
procedure Tmainform.SaveConfig;
begin
INI.PlainTextMode:=TRUE;
INI.PlainTextMode := True;
// Colours
INI.WriteString('Config','pmColour',ColorToString(as_pm.ColorFore));
INI.WriteString('Config','tmpColour',ColorToString(as_tmp.ColorFore));
INI.WriteString('Config','humColour',ColorToString(as_hum.ColorFore));
INI.WriteString('Config','co2Colour',ColorToString(as_co2.ColorFore));
INI.WriteString('Config','vocColour',ColorToString(as_voc.ColorFore));
INI.WriteString('Config','allpolluColour',ColorToString(as_allpollu.ColorFore));
INI.WriteString('Config', 'pmColour', ColorToString(as_pm.ColorFore));
INI.WriteString('Config', 'tmpColour', ColorToString(as_tmp.ColorFore));
INI.WriteString('Config', 'humColour', ColorToString(as_hum.ColorFore));
INI.WriteString('Config', 'co2Colour', ColorToString(as_co2.ColorFore));
INI.WriteString('Config', 'vocColour', ColorToString(as_voc.ColorFore));
INI.WriteString('Config', 'allpolluColour', ColorToString(as_allpollu.ColorFore));
// Max and Min
INI.WriteFloat('Config','pmMinValue',as_pm.ValueMin);
INI.WriteFloat('Config','pmMaxValue',as_pm.ValueMax);
INI.WriteFloat('Config','tmpMinValue',as_tmp.ValueMin);
INI.WriteFloat('Config','tmpMaxValue',as_tmp.ValueMax);
INI.WriteFloat('Config','humMinValue',as_hum.ValueMin);
INI.WriteFloat('Config','humMaxValue',as_hum.ValueMax);
INI.WriteFloat('Config','co2MinValue',as_co2.ValueMin);
INI.WriteFloat('Config','co2MaxValue',as_co2.ValueMax);
INI.WriteFloat('Config','vocMinValue',as_voc.ValueMin);
INI.WriteFloat('Config','vocMaxValue',as_voc.ValueMax);
INI.WriteFloat('Config','allpolluMinValue',as_allpollu.ValueMin);
INI.WriteFloat('Config','allpolluMaxValue',as_allpollu.ValueMax);
INI.PlainTextMode:=FALSE;
INI.WriteFloat('Config', 'pmMinValue', as_pm.ValueMin);
INI.WriteFloat('Config', 'pmMaxValue', as_pm.ValueMax);
INI.WriteFloat('Config', 'tmpMinValue', as_tmp.ValueMin);
INI.WriteFloat('Config', 'tmpMaxValue', as_tmp.ValueMax);
INI.WriteFloat('Config', 'humMinValue', as_hum.ValueMin);
INI.WriteFloat('Config', 'humMaxValue', as_hum.ValueMax);
INI.WriteFloat('Config', 'co2MinValue', as_co2.ValueMin);
INI.WriteFloat('Config', 'co2MaxValue', as_co2.ValueMax);
INI.WriteFloat('Config', 'vocMinValue', as_voc.ValueMin);
INI.WriteFloat('Config', 'vocMaxValue', as_voc.ValueMax);
INI.WriteFloat('Config', 'allpolluMinValue', as_allpollu.ValueMin);
INI.WriteFloat('Config', 'allpolluMaxValue', as_allpollu.ValueMax);
INI.PlainTextMode := False;
end;
procedure Tmainform.LoadConfig;
begin
INI.PlainTextMode:=TRUE;
INI.PlainTextMode := True;
// Colours
as_pm.ColorFore:=StringToColor(INI.ReadString('Config','pmColour',COL_PM));
as_tmp.ColorFore:=StringToColor(INI.ReadString('Config','tmpColour',COL_TMP));
as_hum.ColorFore:=StringToColor(INI.ReadString('Config','humColour',COL_HUM));
as_co2.ColorFore:=StringToColor(INI.ReadString('Config','co2Colour',COL_CO2));
as_voc.ColorFore:=StringToColor(INI.ReadString('Config','vocColour',COL_VOC));
as_allpollu.ColorFore:=StringToColor(INI.ReadString('Config','allpolluColour',COL_ALLPOLLU));
as_pm.ColorFore := StringToColor(INI.ReadString('Config', 'pmColour', COL_PM));
as_tmp.ColorFore := StringToColor(INI.ReadString('Config', 'tmpColour', COL_TMP));
as_hum.ColorFore := StringToColor(INI.ReadString('Config', 'humColour', COL_HUM));
as_co2.ColorFore := StringToColor(INI.ReadString('Config', 'co2Colour', COL_CO2));
as_voc.ColorFore := StringToColor(INI.ReadString('Config', 'vocColour', COL_VOC));
as_allpollu.ColorFore := StringToColor(
INI.ReadString('Config', 'allpolluColour', COL_ALLPOLLU));
lineSeries_pm.SeriesColor := as_pm.ColorFore;
lineSeries_tmp.SeriesColor := as_tmp.ColorFore;
lineSeries_hum.SeriesColor := as_hum.ColorFore;
@ -344,19 +357,19 @@ begin
lineSeries_voc.SeriesColor := as_voc.ColorFore;
lineSeries_allpollu.SeriesColor := as_allpollu.ColorFore;
// Max and Min
as_pm.ValueMin := INI.ReadFloat('Config','pmMinValue',MIN_PM);
as_pm.ValueMax := INI.ReadFloat('Config','pmMaxValue',MAX_PM);
as_tmp.ValueMin := INI.ReadFloat('Config','tmpMinValue',MIN_TMP);
as_tmp.ValueMax := INI.ReadFloat('Config','tmpMaxValue',MAX_TMP);
as_hum.ValueMin := INI.ReadFloat('Config','humMinValue',MIN_HUM);
as_hum.ValueMax := INI.ReadFloat('Config','humMaxValue',MAX_HUM);
as_co2.ValueMin := INI.ReadFloat('Config','co2MinValue',MIN_CO2);
as_co2.ValueMax := INI.ReadFloat('Config','co2MaxValue',MAX_CO2);
as_voc.ValueMin := INI.ReadFloat('Config','vocMinValue',MIN_VOC);
as_voc.ValueMax := INI.ReadFloat('Config','vocMaxValue',MAX_VOC);
as_allpollu.ValueMin := INI.ReadFloat('Config','allpolluMinValue',MIN_ALLPOLLU);
as_allpollu.ValueMax := INI.ReadFloat('Config','allpolluMaxValue',MAX_ALLPOLLU);
INI.PlainTextMode:=FALSE;
as_pm.ValueMin := INI.ReadFloat('Config', 'pmMinValue', MIN_PM);
as_pm.ValueMax := INI.ReadFloat('Config', 'pmMaxValue', MAX_PM);
as_tmp.ValueMin := INI.ReadFloat('Config', 'tmpMinValue', MIN_TMP);
as_tmp.ValueMax := INI.ReadFloat('Config', 'tmpMaxValue', MAX_TMP);
as_hum.ValueMin := INI.ReadFloat('Config', 'humMinValue', MIN_HUM);
as_hum.ValueMax := INI.ReadFloat('Config', 'humMaxValue', MAX_HUM);
as_co2.ValueMin := INI.ReadFloat('Config', 'co2MinValue', MIN_CO2);
as_co2.ValueMax := INI.ReadFloat('Config', 'co2MaxValue', MAX_CO2);
as_voc.ValueMin := INI.ReadFloat('Config', 'vocMinValue', MIN_VOC);
as_voc.ValueMax := INI.ReadFloat('Config', 'vocMaxValue', MAX_VOC);
as_allpollu.ValueMin := INI.ReadFloat('Config', 'allpolluMinValue', MIN_ALLPOLLU);
as_allpollu.ValueMax := INI.ReadFloat('Config', 'allpolluMaxValue', MAX_ALLPOLLU);
INI.PlainTextMode := False;
end;
procedure Tmainform.FormWindowStateChange(Sender: TObject);
@ -401,6 +414,28 @@ begin
mtInformation, [mbOK], 0);
end;
procedure Tmainform.mnu_optionsDisplayGuagesOnlyClick(Sender: TObject);
begin
bDisplayGuagesOnly := mnu_optionsDisplayGuagesOnly.Checked;
if bDisplayGuagesOnly then
mainform.ClientHeight := grp_sensorDisplay.Height// + iFudgeFactor
else
mainform.ClientHeight := grp_sensorDisplay.Height + grp_chart.Height +
grp_highlow.Height;// + iFudgeFactor;
end;
procedure Tmainform.mnu_optionsDisplayRedLinesClick(Sender: TObject);
begin
bDisplayRedLines := mnu_optionsDisplayRedLines.Checked;
SetRedSessionMax;
end;
procedure Tmainform.mnu_optionsDisplayYellowLinesClick(Sender: TObject);
begin
bDisplayYellowLines := mnu_optionsDisplayYellowLines.Checked;
SetYellowRecommendedLevels;
end;
procedure Tmainform.mnu_optionsMinimiseToTrayClick(Sender: TObject);
begin
mainform.WindowState := wsMinimized;
@ -413,13 +448,15 @@ begin
end;
procedure Tmainform.mnu_optionsResetHighsLowsClick(Sender: TObject);
Var iCount:Integer;
var
iCount: integer;
begin
If MessageDlg('This will erase the all-time high/low data permanently. Are you sure?',
mtConfirmation,[MBYES,MBCANCEL],0,MBCANCEL) = mrCancel then exit;
if MessageDlg('This will erase the all-time high/low data permanently. Are you sure?',
mtConfirmation, [mbYes, mbCancel], 0, mbCancel) = mrCancel then
exit;
ResetHighLows;
SaveHighLows;
For iCount:=1 to 6 do
for iCount := 1 to 6 do
UpdateHighLow(iCount);
end;
@ -429,14 +466,8 @@ begin
INI.WriteBool('Foobot', 'SaveLoadHighLows', SaveLoadHighLows);
end;
procedure Tmainform.mnu_optionsShowMinimalDisplayClick(Sender: TObject);
procedure Tmainform.mnu_optionsDisplayClick(Sender: TObject);
begin
if mnu_optionsShowMinimalDisplay.Checked then
mainform.ClientHeight := grp_sensorDisplay.Height// + iFudgeFactor
else
mainform.ClientHeight := grp_sensorDisplay.Height + grp_chart.Height +
grp_highlow.Height;// + iFudgeFactor;
bShowMinimalDisplay := mnu_optionsShowMinimalDisplay.Checked;
end;
procedure Tmainform.mnu_optionsTakeReadingNowClick(Sender: TObject);
@ -449,6 +480,7 @@ begin
ShowMessage('Sorry - no readings available');
mainform.Cursor := crDefault;
end;
procedure Tmainform.mnu_SampleEveryHalfHourClick(Sender: TObject);
begin
tmr_foobot.Enabled := False;
@ -503,14 +535,60 @@ begin
mainform.Show;
end;
Procedure Tmainform.SetRecommendedLevels;
procedure Tmainform.SetRedSessionMax;
begin
as_pm.ValueYellow:=REC_PM;
as_tmp.ValueYellow:=REC_TMP;
as_hum.ValueYellow:=REC_HUM;
as_co2.ValueYellow:=REC_CO2;
as_voc.ValueYellow:=REC_VOC;
as_allpollu.ValueYellow:=REC_ALLPOLLU;
if bDisplayRedLines = True then
begin
with as_pm do
if Value > ValueRed then
ValueRed := Value;
with as_tmp do
if Value > ValueRed then
ValueRed := Value;
with as_hum do
if Value > ValueRed then
ValueRed := Value;
with as_co2 do
if Value > ValueRed then
ValueRed := Value;
with as_voc do
if Value > ValueRed then
ValueRed := Value;
with as_allpollu do
if Value > ValueRed then
ValueRed := Value;
end
else
begin
as_pm.ValueRed := as_pm.ValueMin;
as_tmp.ValueRed := as_tmp.ValueMin;
as_hum.ValueRed := as_hum.ValueMin;
as_co2.ValueRed := as_co2.ValueMin;
as_voc.ValueRed := as_voc.ValueMin;
as_allpollu.ValueRed := as_allpollu.ValueMin;
end;
end;
procedure Tmainform.SetYellowRecommendedLevels;
begin
if bDisplayYellowLines = True then
begin
as_pm.ValueYellow := REC_PM;
as_tmp.ValueYellow := REC_TMP;
as_hum.ValueYellow := REC_HUM;
as_co2.ValueYellow := REC_CO2;
as_voc.ValueYellow := REC_VOC;
as_allpollu.ValueYellow := REC_ALLPOLLU;
end
else
begin
as_pm.ValueYellow := as_pm.ValueMin;
as_tmp.ValueYellow := as_tmp.ValueMin;
as_hum.ValueYellow := as_hum.ValueMin;
as_co2.ValueYellow := as_co2.ValueMin;
as_voc.ValueYellow := as_voc.ValueMin;
as_allpollu.ValueYellow := as_allpollu.ValueMin;
end;
end;
procedure Tmainform.UpdateHighLow(SensorNumber: integer);
@ -623,10 +701,11 @@ begin
end;
if Value > ValueMax then
ValueMax := Value;
ValueYellow := ValueMax;
if bDisplayRedLines then
if Value > ValueRed then
ValueRed := Value;
SetRecommendedLevels;
if bDisplayYellowLines then
SetYellowRecommendedLevels;
end;
end;
@ -645,7 +724,7 @@ begin
UpdateGuage(as_co2, 4);
UpdateGuage(as_voc, 5);
UpdateGuage(as_allpollu, 6);
if not bShowMinimalDisplay then
if not bDisplayGuagesOnly then
begin
for iCount := 1 to 6 do
UpdateHighLow(iCount);
@ -687,7 +766,8 @@ var
begin
iEndSeconds := DateTimeToUnix(Now) - 3600;
iStartSeconds := iEndSeconds - (2 * (24 * 3600)); // 49 hours before Now
grp_chart.Caption:=Format('History from %s',[FormatDateTime('dd/mm/yyyy hh:nn',UnixToDateTime(iStartSeconds))]);
grp_chart.Caption := Format('History from %s',
[FormatDateTime('dd/mm/yyyy hh:nn', UnixToDateTime(iStartSeconds))]);
if FetchFoobotData(dfStartEnd, 0, 0, 3600, iStartSeconds, iEndSeconds, sSecretKey) =
False then
exit;