2016-12-29 13:18:01 +00:00
|
|
|
unit umainform;
|
2017-01-02 09:34:00 +00:00
|
|
|
|
2016-12-30 07:28:09 +00:00
|
|
|
{ Foobot Monitor
|
|
|
|
|
|
|
|
Copyright (C)2016 Gordon Bamber minsadorada@charcodelvalle.com
|
|
|
|
|
|
|
|
This source is free software; you can redistribute it and/or modify it under
|
|
|
|
the terms of the GNU General Public License as published by the Free
|
|
|
|
Software Foundation; either version 2 of the License, or (at your option)
|
|
|
|
any later version.
|
|
|
|
|
|
|
|
This code is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
|
|
details.
|
|
|
|
|
|
|
|
A copy of the GNU General Public License is available on the World Wide Web
|
|
|
|
at <http://www.gnu.org/copyleft/gpl.html>. You can also obtain it by writing
|
|
|
|
to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
|
|
|
|
MA 02111-1307, USA.
|
|
|
|
|
|
|
|
VERSION HISTORY
|
|
|
|
===============
|
|
|
|
V0.0.1.0: Initial commit
|
|
|
|
V0.0.2.0: Trayicon added
|
2016-12-30 16:24:25 +00:00
|
|
|
V0.0.3.0: Added Help menu. Updated Options menu
|
2017-01-02 09:34:00 +00:00
|
|
|
V0.0.4.0: Graph added
|
2017-01-04 14:23:45 +00:00
|
|
|
V0.1.0.0: Save/Load Alltime High/Lows. Reset values from menu
|
|
|
|
V0.1.1.0: Save/Load Colours, Min and Max values to cfg file
|
|
|
|
V0.1.2.0: ??
|
2016-12-30 07:28:09 +00:00
|
|
|
}
|
2017-01-02 09:34:00 +00:00
|
|
|
{$ifopt D+}
|
2017-01-04 14:23:45 +00:00
|
|
|
// Debug mode does not load data from web
|
2017-01-02 09:34:00 +00:00
|
|
|
{$ENDIF}
|
2016-12-29 13:18:01 +00:00
|
|
|
|
|
|
|
{$mode objfpc}{$H+}
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
uses
|
2017-01-04 14:23:45 +00:00
|
|
|
SysUtils, TAGraph, TAIntervalSources, TASeries,
|
2017-01-02 09:34:00 +00:00
|
|
|
Sensors, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls, Menus,
|
2017-01-04 14:23:45 +00:00
|
|
|
lclIntf, foobot_utility, uCryptIni, dateutils, uconfigform, Classes;
|
2016-12-29 13:18:01 +00:00
|
|
|
|
2017-01-02 09:34:00 +00:00
|
|
|
const
|
|
|
|
// Timer milliseconds
|
2016-12-29 13:18:01 +00:00
|
|
|
ONEMINUTE = 60000;
|
2017-01-04 14:23:45 +00:00
|
|
|
HALFHOUR = ONEMINUTE * 30;
|
2016-12-29 13:18:01 +00:00
|
|
|
ONEHOUR = ONEMINUTE * 60;
|
|
|
|
TWOHOURS = ONEHOUR * 2;
|
|
|
|
FOURHOURS = ONEHOUR * 4;
|
|
|
|
EIGHTHOURS = ONEHOUR * 8;
|
|
|
|
TWENTYFOURHOURS = ONEHOUR * 24;
|
|
|
|
|
2017-01-02 09:34:00 +00:00
|
|
|
// Colours for guages and graph lines
|
2017-01-02 16:33:59 +00:00
|
|
|
COL_PM = 'clGreen';
|
|
|
|
COL_TMP = 'clRed';
|
|
|
|
COL_HUM = 'clMaroon';
|
|
|
|
COL_CO2 = 'clLime';
|
|
|
|
COL_VOC = 'clBlue';
|
|
|
|
COL_ALLPOLLU = 'clFuchsia';
|
2017-01-02 10:55:49 +00:00
|
|
|
|
|
|
|
// Sensor Gauge MINMAX Values
|
|
|
|
MIN_PM = 0;
|
|
|
|
MAX_PM = 1000;
|
|
|
|
MIN_TMP = 0;
|
|
|
|
MAX_TMP = 40;
|
|
|
|
MIN_HUM = 10;
|
|
|
|
MAX_HUM = 100;
|
|
|
|
MIN_CO2 = 450;
|
|
|
|
MAX_CO2 = 3000;
|
|
|
|
MIN_VOC = 125;
|
|
|
|
MAX_VOC = 1000;
|
|
|
|
MIN_ALLPOLLU = 0;
|
|
|
|
MAX_ALLPOLLU = 700;
|
|
|
|
|
2017-01-04 14:23:45 +00:00
|
|
|
// Sensor recommended levels
|
|
|
|
REC_PM = 25;
|
|
|
|
REC_TMP = 23;
|
|
|
|
REC_HUM = 60;
|
|
|
|
REC_CO2 = 1300;
|
|
|
|
REC_VOC = 300;
|
|
|
|
REC_ALLPOLLU = 50;
|
2016-12-29 13:18:01 +00:00
|
|
|
|
|
|
|
type
|
|
|
|
|
|
|
|
{ Tmainform }
|
|
|
|
|
|
|
|
Tmainform = class(TForm)
|
|
|
|
as_allpollu: TAnalogSensor;
|
|
|
|
as_co2: TAnalogSensor;
|
|
|
|
as_hum: TAnalogSensor;
|
|
|
|
as_pm: TAnalogSensor;
|
|
|
|
as_tmp: TAnalogSensor;
|
|
|
|
as_voc: TAnalogSensor;
|
2017-01-02 09:34:00 +00:00
|
|
|
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;
|
2016-12-29 13:18:01 +00:00
|
|
|
grp_pm: TGroupBox;
|
|
|
|
grp_tmp: TGroupBox;
|
|
|
|
grp_hum: TGroupBox;
|
|
|
|
grp_co2: TGroupBox;
|
|
|
|
grp_voc: TGroupBox;
|
|
|
|
grp_allpollu: TGroupBox;
|
|
|
|
grp_highlow: TGroupBox;
|
|
|
|
grp_sensorDisplay: TGroupBox;
|
|
|
|
lbl_pmhigh: TLabel;
|
|
|
|
lbl_tmphigh: TLabel;
|
|
|
|
lbl_humhigh: TLabel;
|
|
|
|
lbl_co2high: TLabel;
|
|
|
|
lbl_vochigh: TLabel;
|
|
|
|
lbl_allpolluhigh: TLabel;
|
|
|
|
lbl_pmlow: TLabel;
|
|
|
|
lbl_tmplow: TLabel;
|
|
|
|
lbl_humlow: TLabel;
|
|
|
|
lbl_co2low: TLabel;
|
|
|
|
lbl_voclow: TLabel;
|
|
|
|
lbl_allpollulow: TLabel;
|
|
|
|
MainMenu1: TMainMenu;
|
2017-01-04 14:23:45 +00:00
|
|
|
mnu_SampleEveryHalfHour: TMenuItem;
|
2017-01-02 12:13:25 +00:00
|
|
|
mnu_optionsResetHighsLows: TMenuItem;
|
2016-12-30 16:24:25 +00:00
|
|
|
mnu_optionsOnlineHelp: TMenuItem;
|
|
|
|
mnu_optionsSeperator1: TMenuItem;
|
|
|
|
mnu_helpAbout: TMenuItem;
|
|
|
|
mnu_help: TMenuItem;
|
2016-12-30 07:28:09 +00:00
|
|
|
mnupopup_fileRestore: TMenuItem;
|
|
|
|
mnu_pupupClose: TMenuItem;
|
|
|
|
mnu_optionsMinimiseToTray: TMenuItem;
|
2016-12-29 13:18:01 +00:00
|
|
|
mnu_optionsSaveHighLows: TMenuItem;
|
|
|
|
mnu_SampleEvery24Hours: TMenuItem;
|
|
|
|
mnu_SampleEvery8Hours: TMenuItem;
|
|
|
|
mnu_SampleEvery4Hours: TMenuItem;
|
|
|
|
mnu_SampleEvery2Hours: TMenuItem;
|
|
|
|
mnu_SampleEvery1Hour: TMenuItem;
|
|
|
|
mnu_optionsSampleEvery: TMenuItem;
|
|
|
|
mnu_optionsTakeReadingNow: TMenuItem;
|
2017-01-02 09:34:00 +00:00
|
|
|
mnu_optionsShowMinimalDisplay: TMenuItem;
|
2016-12-29 13:18:01 +00:00
|
|
|
mnu_options: TMenuItem;
|
|
|
|
mnu_fileExit: TMenuItem;
|
|
|
|
mnu_file: TMenuItem;
|
2016-12-30 07:28:09 +00:00
|
|
|
traypopup: TPopupMenu;
|
2016-12-29 13:18:01 +00:00
|
|
|
tmr_foobot: TTimer;
|
2016-12-30 07:28:09 +00:00
|
|
|
TrayIcon1: TTrayIcon;
|
2016-12-29 13:18:01 +00:00
|
|
|
procedure FormActivate(Sender: TObject);
|
2017-01-02 16:33:59 +00:00
|
|
|
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
2016-12-29 13:18:01 +00:00
|
|
|
procedure FormCreate(Sender: TObject);
|
|
|
|
procedure FormDestroy(Sender: TObject);
|
2016-12-30 07:28:09 +00:00
|
|
|
procedure FormWindowStateChange(Sender: TObject);
|
|
|
|
procedure mnupopup_fileRestoreClick(Sender: TObject);
|
2016-12-29 13:18:01 +00:00
|
|
|
procedure mnu_fileExitClick(Sender: TObject);
|
2016-12-30 16:24:25 +00:00
|
|
|
procedure mnu_helpAboutClick(Sender: TObject);
|
2016-12-30 07:28:09 +00:00
|
|
|
procedure mnu_optionsMinimiseToTrayClick(Sender: TObject);
|
2016-12-30 16:24:25 +00:00
|
|
|
procedure mnu_optionsOnlineHelpClick(Sender: TObject);
|
2017-01-02 12:13:25 +00:00
|
|
|
procedure mnu_optionsResetHighsLowsClick(Sender: TObject);
|
2016-12-29 13:18:01 +00:00
|
|
|
procedure mnu_optionsSaveHighLowsClick(Sender: TObject);
|
2017-01-02 09:34:00 +00:00
|
|
|
procedure mnu_optionsShowMinimalDisplayClick(Sender: TObject);
|
2016-12-29 13:18:01 +00:00
|
|
|
procedure mnu_optionsTakeReadingNowClick(Sender: TObject);
|
|
|
|
procedure mnu_SampleEvery1HourClick(Sender: TObject);
|
|
|
|
procedure mnu_SampleEvery24HoursClick(Sender: TObject);
|
|
|
|
procedure mnu_SampleEvery2HoursClick(Sender: TObject);
|
|
|
|
procedure mnu_SampleEvery4HoursClick(Sender: TObject);
|
|
|
|
procedure mnu_SampleEvery8HoursClick(Sender: TObject);
|
2017-01-04 14:23:45 +00:00
|
|
|
procedure mnu_SampleEveryHalfHourClick(Sender: TObject);
|
2016-12-29 13:18:01 +00:00
|
|
|
procedure tmr_foobotTimer(Sender: TObject);
|
2016-12-30 07:28:09 +00:00
|
|
|
procedure TrayIcon1Click(Sender: TObject);
|
2016-12-29 13:18:01 +00:00
|
|
|
private
|
|
|
|
sSecretKey, sFoobotUserName, sUUID: string;
|
2017-01-02 09:34:00 +00:00
|
|
|
bShowMinimalDisplay: boolean;
|
2016-12-29 13:18:01 +00:00
|
|
|
iFudgeFactor: integer;
|
|
|
|
procedure DisplayReadings;
|
|
|
|
procedure UpdateGuage(Sender: TAnalogSensor; SensorNumber: integer);
|
|
|
|
procedure UpdateHighLow(SensorNumber: integer);
|
2017-01-02 10:55:49 +00:00
|
|
|
procedure GraphHistory;
|
|
|
|
procedure GraphCurrentReading;
|
2017-01-04 14:23:45 +00:00
|
|
|
Procedure SetRecommendedLevels;
|
2017-01-02 16:33:59 +00:00
|
|
|
procedure SaveConfig;
|
|
|
|
procedure LoadConfig;
|
2016-12-29 13:18:01 +00:00
|
|
|
public
|
|
|
|
INI: TCryptINIfile;
|
|
|
|
end;
|
|
|
|
|
|
|
|
var
|
|
|
|
mainform: Tmainform;
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
{$R *.lfm}
|
|
|
|
|
|
|
|
{ Tmainform }
|
|
|
|
|
|
|
|
procedure Tmainform.FormCreate(Sender: TObject);
|
|
|
|
begin
|
|
|
|
Caption := Application.Title;
|
|
|
|
Icon := Application.Icon;
|
|
|
|
INI := TCryptINIfile.Create(GetAppConfigFile(False));
|
|
|
|
if INI.IsVirgin then
|
|
|
|
begin
|
|
|
|
INI.WriteIdent('Gordon Bamber', '(c)2016', 'GPLV2',
|
|
|
|
'minesadorada@charcodelvalle.com', True);
|
|
|
|
end;
|
|
|
|
if not INI.VerifyIdent('41d10218d247980fc5e871b6b7844483') then
|
|
|
|
begin
|
|
|
|
ShowMessage(Application.Title +
|
|
|
|
' has been tampered wth. Please re-install from a trusted source.');
|
|
|
|
FreeAndNil(INI);
|
|
|
|
Application.Terminate;
|
|
|
|
end;
|
2017-01-02 09:34:00 +00:00
|
|
|
INI.SectionHashing := False;
|
2016-12-29 13:18:01 +00:00
|
|
|
ResetHighLows;
|
2017-01-02 09:34:00 +00:00
|
|
|
iFudgeFactor := 20; // only needed if height set here
|
|
|
|
bShowMinimalDisplay := False;
|
|
|
|
TrayIcon1.Icon := Application.Icon;
|
|
|
|
TrayIcon1.Hint := Application.Title;
|
|
|
|
DateTimeIntervalChartSource1.DateTimeFormat := 'hh:nn';
|
2017-01-02 16:33:59 +00:00
|
|
|
LoadConfig;
|
2016-12-29 13:18:01 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure Tmainform.FormActivate(Sender: TObject);
|
2017-01-02 09:34:00 +00:00
|
|
|
var
|
|
|
|
sTempFoobotUserName, sTempSecretKey: string;
|
2016-12-29 13:18:01 +00:00
|
|
|
|
|
|
|
begin
|
2017-01-02 10:55:49 +00:00
|
|
|
ClientHeight := grp_sensorDisplay.Height + grp_highlow.Height + grp_chart.Height;
|
2017-01-02 09:34:00 +00:00
|
|
|
|
2016-12-29 13:18:01 +00:00
|
|
|
// Allow user to enter values in INIFile
|
2017-01-02 09:34:00 +00:00
|
|
|
sTempFoobotUserName := INI.ReadUnencryptedString('Config', 'Foobot User', 'unknown');
|
|
|
|
sTempSecretKey := INI.ReadUnencryptedString('Config', 'Secret Key', 'unknown');
|
2016-12-29 13:18:01 +00:00
|
|
|
if ((sTempFoobotUserName <> 'unknown') and (sTempSecretKey <> 'unknown')) then
|
|
|
|
begin
|
|
|
|
INI.WriteString('Foobot', 'Foobot User', sTempFoobotUserName);
|
2017-01-02 09:34:00 +00:00
|
|
|
INI.DeleteKey('Config', 'Foobot User');
|
2016-12-29 13:18:01 +00:00
|
|
|
INI.WriteString('Foobot', 'Secret Key', sTempSecretKey);
|
2017-01-02 09:34:00 +00:00
|
|
|
INI.DeleteKey('Config', 'Secret Key');
|
2016-12-29 13:18:01 +00:00
|
|
|
end;
|
|
|
|
// Fetch Username and API_KEY
|
|
|
|
sFoobotUserName := INI.ReadString('Foobot', 'Foobot User', 'unknown');
|
|
|
|
sSecretKey := INI.ReadString('Foobot', 'Secret Key', 'unknown');
|
|
|
|
if ((sFoobotUserName <> 'unknown') and (sSecretKey <> 'unknown')) then
|
|
|
|
begin
|
|
|
|
Hide;
|
|
|
|
if FetchFoobotIdentity(sFoobotUserName, sSecretKey) then
|
|
|
|
begin
|
|
|
|
if FoobotIdentityObject.FoobotIdentityList.Count > 0 then
|
|
|
|
begin
|
|
|
|
sUUID := FoobotIdentityObject.FoobotIdentityList.Items[0].uuid;
|
2017-01-02 09:34:00 +00:00
|
|
|
SaveLoadHighLows := INI.ReadBool('Foobot', 'SaveLoadHighLows', True);
|
|
|
|
mnu_optionsSaveHighLows.Checked := SaveLoadHighLows;
|
|
|
|
if SaveLoadHighLows then
|
|
|
|
LoadHighLows;
|
2017-01-02 10:55:49 +00:00
|
|
|
GraphHistory;
|
2017-01-02 09:34:00 +00:00
|
|
|
{$IFNDEF DEBUGMODE}
|
2016-12-29 13:18:01 +00:00
|
|
|
mnu_optionsTakeReadingNow.Click;
|
2017-01-04 14:23:45 +00:00
|
|
|
{$ENDIF}
|
2016-12-29 13:18:01 +00:00
|
|
|
// Switch off for testing
|
2017-01-02 09:34:00 +00:00
|
|
|
tmr_foobot.Interval := ONEHOUR;
|
|
|
|
{$IFNDEF DEBUGMODE}
|
|
|
|
tmr_foobot.Enabled := True;
|
2017-01-04 14:23:45 +00:00
|
|
|
{$ENDIF}
|
2016-12-29 13:18:01 +00:00
|
|
|
Show;
|
|
|
|
end;
|
|
|
|
end
|
2017-01-02 09:34:00 +00:00
|
|
|
else
|
|
|
|
Close;
|
2016-12-29 13:18:01 +00:00
|
|
|
end
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
// No valid cfg. Show config form
|
|
|
|
Hide;
|
|
|
|
Application.ProcessMessages;
|
|
|
|
configform.ShowModal;
|
|
|
|
// If user quit without data, then bail out
|
2017-01-02 09:34:00 +00:00
|
|
|
if not configform.bValid then
|
2016-12-29 13:18:01 +00:00
|
|
|
begin
|
|
|
|
Close;
|
|
|
|
end;
|
|
|
|
// Store encrypted Username and API_KEY
|
|
|
|
INI.WriteString('Foobot', 'Foobot User', configform.FoobotUsername);
|
|
|
|
INI.WriteString('Foobot', 'Secret Key', configform.FoobotSecretKey);
|
|
|
|
//sFoobotUserName := INI.ReadString('Foobot', 'Foobot User', 'unknown');
|
|
|
|
//sSecretKey := INI.ReadString('Foobot', 'Secret Key', 'unknown');
|
2017-01-02 09:34:00 +00:00
|
|
|
ShowMessage('Click OK to store settings and close the app.' +
|
|
|
|
LineEnding + 'New settings are applied on resart.');
|
2016-12-29 13:18:01 +00:00
|
|
|
Close;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2017-01-02 16:33:59 +00:00
|
|
|
procedure Tmainform.FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
|
|
|
begin
|
|
|
|
SaveConfig;
|
|
|
|
CloseAction:=caFree;
|
|
|
|
end;
|
|
|
|
|
2016-12-29 13:18:01 +00:00
|
|
|
procedure Tmainform.FormDestroy(Sender: TObject);
|
|
|
|
begin
|
|
|
|
FreeAndNil(INI);
|
|
|
|
end;
|
2017-01-02 16:33:59 +00:00
|
|
|
procedure Tmainform.SaveConfig;
|
2016-12-29 13:18:01 +00:00
|
|
|
begin
|
2017-01-02 16:33:59 +00:00
|
|
|
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));
|
|
|
|
|
|
|
|
// 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;
|
2016-12-29 13:18:01 +00:00
|
|
|
end;
|
|
|
|
|
2017-01-02 16:33:59 +00:00
|
|
|
procedure Tmainform.LoadConfig;
|
2017-01-02 10:55:49 +00:00
|
|
|
begin
|
2017-01-02 16:33:59 +00:00
|
|
|
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));
|
|
|
|
lineSeries_pm.SeriesColor := as_pm.ColorFore;
|
|
|
|
lineSeries_tmp.SeriesColor := as_tmp.ColorFore;
|
|
|
|
lineSeries_hum.SeriesColor := as_hum.ColorFore;
|
|
|
|
lineSeries_co2.SeriesColor := as_co2.ColorFore;
|
|
|
|
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;
|
2017-01-02 10:55:49 +00:00
|
|
|
end;
|
|
|
|
|
2016-12-30 07:28:09 +00:00
|
|
|
procedure Tmainform.FormWindowStateChange(Sender: TObject);
|
|
|
|
begin
|
|
|
|
if mainform.WindowState = wsMinimized then
|
|
|
|
begin
|
2017-01-02 09:34:00 +00:00
|
|
|
mainform.WindowState := wsNormal;
|
|
|
|
mainform.Hide;
|
|
|
|
mainform.ShowInTaskBar := stNever;
|
2016-12-30 07:28:09 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure Tmainform.mnupopup_fileRestoreClick(Sender: TObject);
|
|
|
|
begin
|
2017-01-02 09:34:00 +00:00
|
|
|
mainform.Show;
|
2016-12-30 07:28:09 +00:00
|
|
|
end;
|
|
|
|
|
2016-12-29 13:18:01 +00:00
|
|
|
procedure Tmainform.mnu_fileExitClick(Sender: TObject);
|
|
|
|
begin
|
|
|
|
Close;
|
|
|
|
end;
|
|
|
|
|
2016-12-30 16:24:25 +00:00
|
|
|
procedure Tmainform.mnu_helpAboutClick(Sender: TObject);
|
|
|
|
var
|
|
|
|
s: string;
|
|
|
|
begin
|
|
|
|
s := Application.Title + LineEnding;
|
|
|
|
s += 'Version: ' + INI.ReadUnencryptedString('ProgramInfo', IDENT_APPVERSION, '') +
|
|
|
|
LineEnding + LineEnding;
|
|
|
|
s += INI.ReadUnencryptedString('ProgramInfo', IDENT_COPYRIGHT, '');
|
|
|
|
s += ' by ' + INI.ReadUnencryptedString('ProgramInfo', IDENT_AUTHOR, '') + LineEnding;
|
|
|
|
s += 'Licence: ' + INI.ReadUnencryptedString('ProgramInfo', IDENT_LICENSE, '') +
|
|
|
|
LineEnding;
|
|
|
|
s += 'Made with LCL v ' + INI.ReadUnencryptedString('ProgramInfo',
|
|
|
|
IDENT_LCLVERSION, '');
|
|
|
|
s += ' FPC v ' + INI.ReadUnencryptedString('ProgramInfo', IDENT_FPCVERSION, '') +
|
|
|
|
LineEnding;
|
|
|
|
s += 'Compiled ' + INI.ReadUnencryptedString('ProgramInfo', IDENT_LASTCOMPILED, '') +
|
|
|
|
LineEnding;
|
|
|
|
s += ' for ' + INI.ReadUnencryptedString('ProgramInfo', IDENT_TARGET, '');
|
|
|
|
MessageDlg('About ' + Application.Title, s,
|
|
|
|
mtInformation, [mbOK], 0);
|
|
|
|
end;
|
2017-01-02 09:34:00 +00:00
|
|
|
|
2016-12-30 07:28:09 +00:00
|
|
|
procedure Tmainform.mnu_optionsMinimiseToTrayClick(Sender: TObject);
|
|
|
|
begin
|
2017-01-02 09:34:00 +00:00
|
|
|
mainform.WindowState := wsMinimized;
|
2016-12-30 07:28:09 +00:00
|
|
|
mainform.FormWindowStateChange(Self);
|
|
|
|
end;
|
|
|
|
|
2016-12-30 16:24:25 +00:00
|
|
|
procedure Tmainform.mnu_optionsOnlineHelpClick(Sender: TObject);
|
|
|
|
begin
|
|
|
|
OpenURL('http://wiki.freepascal.org/Foobot');
|
|
|
|
end;
|
|
|
|
|
2017-01-02 12:13:25 +00:00
|
|
|
procedure Tmainform.mnu_optionsResetHighsLowsClick(Sender: TObject);
|
|
|
|
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;
|
|
|
|
ResetHighLows;
|
|
|
|
SaveHighLows;
|
|
|
|
For iCount:=1 to 6 do
|
|
|
|
UpdateHighLow(iCount);
|
|
|
|
end;
|
|
|
|
|
2016-12-29 13:18:01 +00:00
|
|
|
procedure Tmainform.mnu_optionsSaveHighLowsClick(Sender: TObject);
|
|
|
|
begin
|
2017-01-02 09:34:00 +00:00
|
|
|
SaveLoadHighLows := mnu_optionsSaveHighLows.Checked;
|
|
|
|
INI.WriteBool('Foobot', 'SaveLoadHighLows', SaveLoadHighLows);
|
2016-12-29 13:18:01 +00:00
|
|
|
end;
|
|
|
|
|
2017-01-02 09:34:00 +00:00
|
|
|
procedure Tmainform.mnu_optionsShowMinimalDisplayClick(Sender: TObject);
|
2016-12-29 13:18:01 +00:00
|
|
|
begin
|
2017-01-02 09:34:00 +00:00
|
|
|
if mnu_optionsShowMinimalDisplay.Checked then
|
|
|
|
mainform.ClientHeight := grp_sensorDisplay.Height// + iFudgeFactor
|
2016-12-29 13:18:01 +00:00
|
|
|
else
|
2017-01-02 09:34:00 +00:00
|
|
|
mainform.ClientHeight := grp_sensorDisplay.Height + grp_chart.Height +
|
|
|
|
grp_highlow.Height;// + iFudgeFactor;
|
|
|
|
bShowMinimalDisplay := mnu_optionsShowMinimalDisplay.Checked;
|
2016-12-29 13:18:01 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure Tmainform.mnu_optionsTakeReadingNowClick(Sender: TObject);
|
|
|
|
begin
|
|
|
|
mainform.Cursor := crHourGlass;
|
|
|
|
// Only Foobot #0
|
|
|
|
if FetchFoobotData(dfLast, 0, 0, 0, 0, 0, sSecretKey) then
|
|
|
|
DisplayReadings
|
|
|
|
else
|
|
|
|
ShowMessage('Sorry - no readings available');
|
|
|
|
mainform.Cursor := crDefault;
|
|
|
|
end;
|
2017-01-04 14:23:45 +00:00
|
|
|
procedure Tmainform.mnu_SampleEveryHalfHourClick(Sender: TObject);
|
|
|
|
begin
|
|
|
|
tmr_foobot.Enabled := False;
|
|
|
|
tmr_foobot.Interval := HALFHOUR;
|
|
|
|
tmr_foobot.Enabled := True;
|
|
|
|
end;
|
2016-12-29 13:18:01 +00:00
|
|
|
|
|
|
|
procedure Tmainform.mnu_SampleEvery1HourClick(Sender: TObject);
|
|
|
|
begin
|
2017-01-02 09:34:00 +00:00
|
|
|
tmr_foobot.Enabled := False;
|
|
|
|
tmr_foobot.Interval := ONEHOUR;
|
|
|
|
tmr_foobot.Enabled := True;
|
2016-12-29 13:18:01 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure Tmainform.mnu_SampleEvery24HoursClick(Sender: TObject);
|
|
|
|
begin
|
2017-01-02 09:34:00 +00:00
|
|
|
tmr_foobot.Enabled := False;
|
|
|
|
tmr_foobot.Interval := TWENTYFOURHOURS;
|
|
|
|
tmr_foobot.Enabled := True;
|
2016-12-29 13:18:01 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure Tmainform.mnu_SampleEvery2HoursClick(Sender: TObject);
|
|
|
|
begin
|
2017-01-02 09:34:00 +00:00
|
|
|
tmr_foobot.Enabled := False;
|
|
|
|
tmr_foobot.Interval := TWOHOURS;
|
|
|
|
tmr_foobot.Enabled := True;
|
2016-12-29 13:18:01 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure Tmainform.mnu_SampleEvery4HoursClick(Sender: TObject);
|
|
|
|
begin
|
2017-01-02 09:34:00 +00:00
|
|
|
tmr_foobot.Enabled := False;
|
|
|
|
tmr_foobot.Interval := FOURHOURS;
|
|
|
|
tmr_foobot.Enabled := True;
|
2016-12-29 13:18:01 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure Tmainform.mnu_SampleEvery8HoursClick(Sender: TObject);
|
|
|
|
begin
|
2017-01-02 09:34:00 +00:00
|
|
|
tmr_foobot.Enabled := False;
|
|
|
|
tmr_foobot.Interval := EIGHTHOURS;
|
|
|
|
tmr_foobot.Enabled := True;
|
2016-12-29 13:18:01 +00:00
|
|
|
end;
|
|
|
|
|
2017-01-04 14:23:45 +00:00
|
|
|
|
2016-12-29 13:18:01 +00:00
|
|
|
procedure Tmainform.tmr_foobotTimer(Sender: TObject);
|
|
|
|
begin
|
|
|
|
if FetchFoobotData(dfLast, 0, 0, 0, 0, 0, sSecretKey) then
|
|
|
|
DisplayReadings;
|
|
|
|
end;
|
|
|
|
|
2016-12-30 07:28:09 +00:00
|
|
|
procedure Tmainform.TrayIcon1Click(Sender: TObject);
|
|
|
|
begin
|
2017-01-02 09:34:00 +00:00
|
|
|
mainform.Show;
|
2016-12-30 07:28:09 +00:00
|
|
|
end;
|
|
|
|
|
2017-01-04 14:23:45 +00:00
|
|
|
Procedure Tmainform.SetRecommendedLevels;
|
|
|
|
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;
|
|
|
|
|
2016-12-29 13:18:01 +00:00
|
|
|
procedure Tmainform.UpdateHighLow(SensorNumber: integer);
|
|
|
|
begin
|
|
|
|
case SensorNumber of
|
|
|
|
1:
|
|
|
|
begin
|
2017-01-02 09:34:00 +00:00
|
|
|
lbl_pmhigh.Caption := Format('High: %f %s',
|
|
|
|
[double(FoobotDataHighs[SensorNumber]), FoobotDataObject.Units[SensorNumber]]) +
|
|
|
|
LineEnding + 'on ' + FormatDateTime('dd/mm tt',
|
|
|
|
TDateTime(FoobotDataHighTimes[SensorNumber]));
|
|
|
|
lbl_pmLow.Caption := Format('Low: %f %s',
|
|
|
|
[double(FoobotDataLows[SensorNumber]), FoobotDataObject.Units[SensorNumber]]) +
|
2016-12-29 13:18:01 +00:00
|
|
|
LineEnding + 'on ' + FormatDateTime('dd/mm tt', TDateTime(
|
|
|
|
FoobotDataLowTimes[SensorNumber]));
|
|
|
|
end;
|
|
|
|
2:
|
|
|
|
begin
|
2017-01-02 09:34:00 +00:00
|
|
|
lbl_tmphigh.Caption := Format('High: %f %s',
|
|
|
|
[double(FoobotDataHighs[SensorNumber]), FoobotDataObject.Units[SensorNumber]]) +
|
|
|
|
LineEnding + 'on ' + FormatDateTime('dd/mm tt',
|
|
|
|
TDateTime(FoobotDataHighTimes[SensorNumber]));
|
|
|
|
lbl_tmpLow.Caption := Format('Low: %f %s',
|
|
|
|
[double(FoobotDataLows[SensorNumber]), FoobotDataObject.Units[SensorNumber]]) +
|
2016-12-29 13:18:01 +00:00
|
|
|
LineEnding + 'on ' + FormatDateTime('dd/mm tt', TDateTime(
|
|
|
|
FoobotDataLowTimes[SensorNumber]));
|
|
|
|
end;
|
|
|
|
3:
|
|
|
|
begin
|
2017-01-02 09:34:00 +00:00
|
|
|
lbl_humhigh.Caption := Format('High: %f %s',
|
|
|
|
[double(FoobotDataHighs[SensorNumber]), FoobotDataObject.Units[SensorNumber]]) +
|
|
|
|
LineEnding + 'on ' + FormatDateTime('dd/mm tt',
|
|
|
|
TDateTime(FoobotDataHighTimes[SensorNumber]));
|
|
|
|
lbl_humLow.Caption := Format('Low: %f %s',
|
|
|
|
[double(FoobotDataLows[SensorNumber]), FoobotDataObject.Units[SensorNumber]]) +
|
2016-12-29 13:18:01 +00:00
|
|
|
LineEnding + 'on ' + FormatDateTime('dd/mm tt', TDateTime(
|
|
|
|
FoobotDataLowTimes[SensorNumber]));
|
|
|
|
end;
|
|
|
|
4:
|
|
|
|
begin
|
2017-01-02 09:34:00 +00:00
|
|
|
lbl_co2high.Caption := Format('High: %f %s',
|
|
|
|
[double(FoobotDataHighs[SensorNumber]), FoobotDataObject.Units[SensorNumber]]) +
|
|
|
|
LineEnding + 'on ' + FormatDateTime('dd/mm tt',
|
|
|
|
TDateTime(FoobotDataHighTimes[SensorNumber]));
|
|
|
|
lbl_co2Low.Caption := Format('Low: %f %s',
|
|
|
|
[double(FoobotDataLows[SensorNumber]), FoobotDataObject.Units[SensorNumber]]) +
|
2016-12-29 13:18:01 +00:00
|
|
|
LineEnding + 'on ' + FormatDateTime('dd/mm tt', TDateTime(
|
|
|
|
FoobotDataLowTimes[SensorNumber]));
|
|
|
|
end;
|
|
|
|
5:
|
|
|
|
begin
|
2017-01-02 09:34:00 +00:00
|
|
|
lbl_vochigh.Caption := Format('High: %f %s',
|
|
|
|
[double(FoobotDataHighs[SensorNumber]), FoobotDataObject.Units[SensorNumber]]) +
|
|
|
|
LineEnding + 'on ' + FormatDateTime('dd/mm tt',
|
|
|
|
TDateTime(FoobotDataHighTimes[SensorNumber]));
|
|
|
|
lbl_vocLow.Caption := Format('Low: %f %s',
|
|
|
|
[double(FoobotDataLows[SensorNumber]), FoobotDataObject.Units[SensorNumber]]) +
|
2016-12-29 13:18:01 +00:00
|
|
|
LineEnding + 'on ' + FormatDateTime('dd/mm tt', TDateTime(
|
|
|
|
FoobotDataLowTimes[SensorNumber]));
|
|
|
|
end;
|
|
|
|
6:
|
|
|
|
begin
|
|
|
|
lbl_allpolluhigh.Caption :=
|
|
|
|
Format('High: %f %s', [double(FoobotDataHighs[SensorNumber]),
|
|
|
|
FoobotDataObject.Units[SensorNumber]]) + LineEnding + 'on ' +
|
|
|
|
FormatDateTime('dd/mm tt', TDateTime(FoobotDataHighTimes[SensorNumber]));
|
|
|
|
lbl_allpollulow.Caption :=
|
|
|
|
Format('Low: %f %s', [double(FoobotDataLows[SensorNumber]),
|
|
|
|
FoobotDataObject.Units[SensorNumber]]) + LineEnding + 'on ' +
|
|
|
|
FormatDateTime('dd/mm tt', TDateTime(FoobotDataLowTimes[SensorNumber]));
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure Tmainform.UpdateGuage(Sender: TAnalogSensor; SensorNumber: integer);
|
|
|
|
begin
|
|
|
|
with Sender do
|
|
|
|
begin
|
|
|
|
case SensorNumber of
|
|
|
|
1:
|
|
|
|
begin
|
|
|
|
Value := FoobotData_pm[0];
|
|
|
|
Caption := Format('PM (%s): ', [FoobotDataObject.Units[SensorNumber]]);
|
|
|
|
end;
|
|
|
|
2:
|
|
|
|
begin
|
|
|
|
Value := FoobotData_tmp[0];
|
|
|
|
Caption := Format('Temp (%s): ', [FoobotDataObject.Units[SensorNumber]]);
|
|
|
|
end;
|
|
|
|
3:
|
|
|
|
begin
|
|
|
|
Value := FoobotData_hum[0];
|
|
|
|
Caption := Format('Hum. (%s): ', [FoobotDataObject.Units[SensorNumber]]);
|
|
|
|
end;
|
|
|
|
4:
|
|
|
|
begin
|
|
|
|
Value := FoobotData_co2[0];
|
|
|
|
Caption := Format('CO2 (%s): ', [FoobotDataObject.Units[SensorNumber]]);
|
|
|
|
end;
|
|
|
|
5:
|
|
|
|
begin
|
|
|
|
Value := FoobotData_voc[0];
|
|
|
|
Caption := Format('VOC (%s): ', [FoobotDataObject.Units[SensorNumber]]);
|
|
|
|
end;
|
|
|
|
6:
|
|
|
|
begin
|
|
|
|
Value := FoobotData_allpollu[0];
|
|
|
|
Caption := Format('All (%s): ', [FoobotDataObject.Units[SensorNumber]]);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
if Value > ValueMax then
|
|
|
|
ValueMax := Value;
|
|
|
|
ValueYellow := ValueMax;
|
|
|
|
if Value > ValueRed then
|
|
|
|
ValueRed := Value;
|
2017-01-04 14:23:45 +00:00
|
|
|
SetRecommendedLevels;
|
2016-12-29 13:18:01 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure Tmainform.DisplayReadings;
|
|
|
|
var
|
|
|
|
iCount: integer;
|
|
|
|
begin
|
|
|
|
if FoobotDataObjectToArrays = True then
|
|
|
|
begin
|
2017-01-02 09:34:00 +00:00
|
|
|
mainform.Caption := Format('Foobot "%s" - Last reading: ',
|
2016-12-29 13:18:01 +00:00
|
|
|
[FoobotIdentityObject.FoobotIdentityList[0].Name]) +
|
|
|
|
FormatDateTime('dd/mm/yyyy - tt', FoobotData_time[0]);
|
|
|
|
UpdateGuage(as_pm, 1);
|
|
|
|
UpdateGuage(as_tmp, 2);
|
|
|
|
UpdateGuage(as_hum, 3);
|
|
|
|
UpdateGuage(as_co2, 4);
|
|
|
|
UpdateGuage(as_voc, 5);
|
|
|
|
UpdateGuage(as_allpollu, 6);
|
2017-01-02 09:34:00 +00:00
|
|
|
if not bShowMinimalDisplay then
|
|
|
|
begin
|
2016-12-29 13:18:01 +00:00
|
|
|
for iCount := 1 to 6 do
|
|
|
|
UpdateHighLow(iCount);
|
2017-01-02 09:34:00 +00:00
|
|
|
end;
|
2017-01-02 10:55:49 +00:00
|
|
|
GraphCurrentReading;
|
2016-12-29 13:18:01 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2017-01-02 10:55:49 +00:00
|
|
|
function AsPercent(aValue, aMin, aMax: double): double;
|
2017-01-02 09:34:00 +00:00
|
|
|
begin
|
|
|
|
if aMax > 0 then
|
2017-01-02 10:55:49 +00:00
|
|
|
Result := aValue / (aMax - aMin) * 100
|
2017-01-02 09:34:00 +00:00
|
|
|
else
|
|
|
|
Result := 0;
|
|
|
|
end;
|
|
|
|
|
2017-01-02 10:55:49 +00:00
|
|
|
procedure Tmainform.GraphCurrentReading;
|
2017-01-02 09:34:00 +00:00
|
|
|
begin
|
2017-01-02 10:55:49 +00:00
|
|
|
lineseries_pm.AddXY(FoobotData_time[0],
|
|
|
|
AsPercent(FoobotData_pm[0], as_pm.ValueMin, as_pm.ValueMax));
|
|
|
|
lineseries_tmp.AddXY(FoobotData_time[0], AsPercent(FoobotData_tmp[0],
|
|
|
|
as_tmp.ValueMin, as_tmp.ValueMax));
|
|
|
|
lineseries_hum.AddXY(FoobotData_time[0],
|
|
|
|
AsPercent(FoobotData_hum[0], as_hum.ValueMin, as_hum.ValueMax));
|
|
|
|
lineseries_co2.AddXY(FoobotData_time[0],
|
|
|
|
AsPercent(FoobotData_co2[0], as_co2.ValueMin, as_co2.ValueMax));
|
|
|
|
lineseries_voc.AddXY(FoobotData_time[0],
|
|
|
|
AsPercent(FoobotData_voc[0], as_voc.ValueMin, as_voc.ValueMax));
|
2017-01-02 09:34:00 +00:00
|
|
|
lineseries_allpollu.AddXY(FoobotData_time[0],
|
2017-01-02 10:55:49 +00:00
|
|
|
AsPercent(FoobotData_allpollu[0], as_allpollu.ValueMin, as_allpollu.ValueMax));
|
2017-01-02 09:34:00 +00:00
|
|
|
end;
|
|
|
|
|
2017-01-02 10:55:49 +00:00
|
|
|
procedure Tmainform.GraphHistory;
|
2017-01-02 09:34:00 +00:00
|
|
|
// Fetch Hourly readings for the previous 2 days (AverageBy=3600)
|
|
|
|
// Populate FoobotDataObjectToArrays
|
|
|
|
var
|
|
|
|
iCount: integer;
|
|
|
|
iStartSeconds, iEndSeconds: int64;
|
|
|
|
begin
|
|
|
|
iEndSeconds := DateTimeToUnix(Now) - 3600;
|
2017-01-02 10:55:49 +00:00
|
|
|
iStartSeconds := iEndSeconds - (2 * (24 * 3600)); // 49 hours before Now
|
|
|
|
grp_chart.Caption:=Format('History from %s',[FormatDateTime('dd/mm/yyyy hh:nn',UnixToDateTime(iStartSeconds))]);
|
2017-01-02 09:34:00 +00:00
|
|
|
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],
|
2017-01-02 10:55:49 +00:00
|
|
|
AsPercent(FoobotData_pm[iCount], as_pm.ValueMin, as_pm.ValueMax));
|
2017-01-02 09:34:00 +00:00
|
|
|
lineseries_tmp.AddXY(FoobotData_time[iCount],
|
2017-01-02 10:55:49 +00:00
|
|
|
AsPercent(FoobotData_tmp[iCount], as_tmp.ValueMin, as_tmp.ValueMax));
|
2017-01-02 09:34:00 +00:00
|
|
|
lineseries_hum.AddXY(FoobotData_time[iCount],
|
2017-01-02 10:55:49 +00:00
|
|
|
AsPercent(FoobotData_hum[iCount], as_hum.ValueMin, as_hum.ValueMax));
|
2017-01-02 09:34:00 +00:00
|
|
|
lineseries_co2.AddXY(FoobotData_time[iCount],
|
2017-01-02 10:55:49 +00:00
|
|
|
AsPercent(FoobotData_co2[iCount], as_co2.ValueMin, as_co2.ValueMax));
|
2017-01-02 09:34:00 +00:00
|
|
|
lineseries_voc.AddXY(FoobotData_time[iCount],
|
2017-01-02 10:55:49 +00:00
|
|
|
AsPercent(FoobotData_voc[iCount], as_voc.ValueMin, as_voc.ValueMax));
|
2017-01-02 09:34:00 +00:00
|
|
|
lineseries_allpollu.AddXY(FoobotData_time[iCount],
|
2017-01-02 10:55:49 +00:00
|
|
|
AsPercent(FoobotData_allpollu[iCount], as_allpollu.ValueMin,
|
|
|
|
as_allpollu.ValueMax));
|
2017-01-02 09:34:00 +00:00
|
|
|
end;
|
|
|
|
ResetArrays; // at end
|
|
|
|
end;
|
|
|
|
|
2016-12-29 13:18:01 +00:00
|
|
|
end.
|