You've already forked lazarus-ccr
Updates and Bugfixes
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5583 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -3,14 +3,14 @@
|
||||
<ProjectSession>
|
||||
<PathDelim Value="\"/>
|
||||
<Version Value="10"/>
|
||||
<BuildModes Active="linux64"/>
|
||||
<BuildModes Active="win32GTK2"/>
|
||||
<Units Count="25">
|
||||
<Unit0>
|
||||
<Filename Value="foobotmonitor.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<EditorIndex Value="8"/>
|
||||
<CursorPos X="33" Y="25"/>
|
||||
<UsageCount Value="72"/>
|
||||
<UsageCount Value="74"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit0>
|
||||
<Unit1>
|
||||
@ -20,9 +20,9 @@
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<IsVisibleTab Value="True"/>
|
||||
<TopLine Value="23"/>
|
||||
<CursorPos X="72" Y="39"/>
|
||||
<UsageCount Value="72"/>
|
||||
<TopLine Value="591"/>
|
||||
<CursorPos X="58" Y="613"/>
|
||||
<UsageCount Value="74"/>
|
||||
<Loaded Value="True"/>
|
||||
<LoadedDesigner Value="True"/>
|
||||
</Unit1>
|
||||
@ -34,7 +34,7 @@
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<EditorIndex Value="2"/>
|
||||
<CursorPos X="2" Y="20"/>
|
||||
<UsageCount Value="62"/>
|
||||
<UsageCount Value="64"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit2>
|
||||
<Unit3>
|
||||
@ -44,7 +44,7 @@
|
||||
<WindowIndex Value="-1"/>
|
||||
<TopLine Value="-1"/>
|
||||
<CursorPos X="-1" Y="-1"/>
|
||||
<UsageCount Value="54"/>
|
||||
<UsageCount Value="56"/>
|
||||
</Unit3>
|
||||
<Unit4>
|
||||
<Filename Value="..\foobot_objects.pas"/>
|
||||
@ -53,7 +53,7 @@
|
||||
<WindowIndex Value="-1"/>
|
||||
<TopLine Value="-1"/>
|
||||
<CursorPos X="-1" Y="-1"/>
|
||||
<UsageCount Value="54"/>
|
||||
<UsageCount Value="56"/>
|
||||
</Unit4>
|
||||
<Unit5>
|
||||
<Filename Value="..\foobot_utility.pas"/>
|
||||
@ -61,7 +61,7 @@
|
||||
<EditorIndex Value="5"/>
|
||||
<TopLine Value="65"/>
|
||||
<CursorPos X="18" Y="83"/>
|
||||
<UsageCount Value="72"/>
|
||||
<UsageCount Value="74"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit5>
|
||||
<Unit6>
|
||||
@ -71,21 +71,21 @@
|
||||
<WindowIndex Value="-1"/>
|
||||
<TopLine Value="-1"/>
|
||||
<CursorPos X="-1" Y="-1"/>
|
||||
<UsageCount Value="54"/>
|
||||
<UsageCount Value="56"/>
|
||||
</Unit6>
|
||||
<Unit7>
|
||||
<Filename Value="..\latest_stable\foobot_httpclient.pas"/>
|
||||
<EditorIndex Value="3"/>
|
||||
<TopLine Value="43"/>
|
||||
<CursorPos X="47" Y="13"/>
|
||||
<UsageCount Value="53"/>
|
||||
<UsageCount Value="54"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit7>
|
||||
<Unit8>
|
||||
<Filename Value="..\latest_stable\foobot_objects.pas"/>
|
||||
<EditorIndex Value="7"/>
|
||||
<CursorPos X="32" Y="61"/>
|
||||
<UsageCount Value="53"/>
|
||||
<UsageCount Value="54"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit8>
|
||||
<Unit9>
|
||||
@ -121,7 +121,7 @@
|
||||
<EditorIndex Value="4"/>
|
||||
<TopLine Value="284"/>
|
||||
<CursorPos X="38" Y="313"/>
|
||||
<UsageCount Value="33"/>
|
||||
<UsageCount Value="34"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit13>
|
||||
<Unit14>
|
||||
@ -191,16 +191,16 @@
|
||||
<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"/>
|
||||
<TopLine Value="381"/>
|
||||
<CursorPos X="24" Y="409"/>
|
||||
<UsageCount Value="23"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit23>
|
||||
<Unit24>
|
||||
<Filename Value="..\latest_stable\udataform.pas"/>
|
||||
<EditorIndex Value="1"/>
|
||||
<TopLine Value="70"/>
|
||||
<UsageCount Value="22"/>
|
||||
<UsageCount Value="23"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit24>
|
||||
</Units>
|
||||
|
@ -59,10 +59,10 @@ object mainform: Tmainform
|
||||
ShowText = True
|
||||
ShowLevel = True
|
||||
Value = 10
|
||||
ValueMin = 10
|
||||
ValueMin = 0
|
||||
ValueMax = 40
|
||||
ValueRed = 10
|
||||
ValueYellow = 10
|
||||
ValueRed = 0
|
||||
ValueYellow = 30
|
||||
AnalogKind = akAnalog
|
||||
end
|
||||
object as_hum: TAnalogSensor
|
||||
@ -132,7 +132,7 @@ object mainform: Tmainform
|
||||
ShowLevel = True
|
||||
Value = 0
|
||||
ValueMin = 0
|
||||
ValueMax = 1000
|
||||
ValueMax = 700
|
||||
ValueRed = 0
|
||||
ValueYellow = 0
|
||||
AnalogKind = akAnalog
|
||||
@ -382,6 +382,7 @@ object mainform: Tmainform
|
||||
end
|
||||
object lineseries_allpollu: TLineSeries
|
||||
LinePen.Color = clBlue
|
||||
LinePen.Width = 2
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -36,7 +36,7 @@ V0.0.5.0: ??
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, FileUtil, TAGraph, TAIntervalSources, TASeries, //TASources,
|
||||
Classes, SysUtils, FileUtil, TAGraph, TAIntervalSources, TASeries,
|
||||
Sensors, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls, Menus,
|
||||
lclIntf, foobot_utility, uCryptIni, Variants, dateutils, uconfigform;
|
||||
|
||||
@ -50,12 +50,27 @@ const
|
||||
TWENTYFOURHOURS = ONEHOUR * 24;
|
||||
|
||||
// Colours for guages and graph lines
|
||||
COL_PM = clMaroon;
|
||||
COL_PM = clGreen;
|
||||
COL_TMP = clRed;
|
||||
COL_HUM = clGreen;
|
||||
COL_HUM = clMaroon;
|
||||
COL_CO2 = clLime;
|
||||
COL_VOC = clNavy;
|
||||
COL_ALLPOLLU = clBlue;
|
||||
COL_VOC = clBlue;
|
||||
COL_ALLPOLLU = clFuchsia;
|
||||
|
||||
// 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;
|
||||
|
||||
|
||||
type
|
||||
|
||||
@ -143,12 +158,13 @@ type
|
||||
sSecretKey, sFoobotUserName, sUUID: string;
|
||||
bShowMinimalDisplay: boolean;
|
||||
iFudgeFactor: integer;
|
||||
procedure SetUpColours;
|
||||
procedure SetUpSensorColours;
|
||||
procedure SetUpSensorMinMax;
|
||||
procedure DisplayReadings;
|
||||
procedure UpdateGuage(Sender: TAnalogSensor; SensorNumber: integer);
|
||||
procedure UpdateHighLow(SensorNumber: integer);
|
||||
procedure DrawGraphHistory;
|
||||
procedure DrawGraph;
|
||||
procedure GraphHistory;
|
||||
procedure GraphCurrentReading;
|
||||
public
|
||||
INI: TCryptINIfile;
|
||||
end;
|
||||
@ -186,7 +202,8 @@ begin
|
||||
TrayIcon1.Icon := Application.Icon;
|
||||
TrayIcon1.Hint := Application.Title;
|
||||
DateTimeIntervalChartSource1.DateTimeFormat := 'hh:nn';
|
||||
SetUpColours;
|
||||
SetUpSensorMinMax;
|
||||
SetUpSensorColours;
|
||||
end;
|
||||
|
||||
procedure Tmainform.FormActivate(Sender: TObject);
|
||||
@ -194,8 +211,7 @@ var
|
||||
sTempFoobotUserName, sTempSecretKey: string;
|
||||
|
||||
begin
|
||||
ClientHeight := grp_sensorDisplay.Height + grp_highlow.Height +
|
||||
grp_chart.Height;
|
||||
ClientHeight := grp_sensorDisplay.Height + grp_highlow.Height + grp_chart.Height;
|
||||
|
||||
// Allow user to enter values in INIFile
|
||||
sTempFoobotUserName := INI.ReadUnencryptedString('Config', 'Foobot User', 'unknown');
|
||||
@ -222,7 +238,7 @@ begin
|
||||
mnu_optionsSaveHighLows.Checked := SaveLoadHighLows;
|
||||
if SaveLoadHighLows then
|
||||
LoadHighLows;
|
||||
DrawGraphHistory;
|
||||
GraphHistory;
|
||||
{$IFNDEF DEBUGMODE}
|
||||
mnu_optionsTakeReadingNow.Click;
|
||||
{$ENDIF}
|
||||
@ -264,7 +280,7 @@ begin
|
||||
FreeAndNil(INI);
|
||||
end;
|
||||
|
||||
procedure Tmainform.SetUpColours;
|
||||
procedure Tmainform.SetUpSensorColours;
|
||||
begin
|
||||
as_pm.ColorFore := COL_PM;
|
||||
lineSeries_pm.SeriesColor := COL_PM;
|
||||
@ -280,6 +296,22 @@ begin
|
||||
lineSeries_allpollu.SeriesColor := COL_ALLPOLLU;
|
||||
end;
|
||||
|
||||
procedure Tmainform.SetUpSensorMinMax;
|
||||
begin
|
||||
as_pm.ValueMin := MIN_PM;
|
||||
as_pm.ValueMax := MAX_PM;
|
||||
as_tmp.ValueMin := MIN_TMP;
|
||||
as_tmp.ValueMax := MAX_TMP;
|
||||
as_hum.ValueMin := MIN_HUM;
|
||||
as_hum.ValueMax := MAX_HUM;
|
||||
as_co2.ValueMin := MIN_CO2;
|
||||
as_co2.ValueMax := MAX_CO2;
|
||||
as_voc.ValueMin := MIN_VOC;
|
||||
as_voc.ValueMax := MAX_VOC;
|
||||
as_allpollu.ValueMin := MIN_ALLPOLLU;
|
||||
as_allpollu.ValueMax := MAX_ALLPOLLU;
|
||||
end;
|
||||
|
||||
procedure Tmainform.FormWindowStateChange(Sender: TObject);
|
||||
begin
|
||||
if mainform.WindowState = wsMinimized then
|
||||
@ -542,30 +574,35 @@ begin
|
||||
for iCount := 1 to 6 do
|
||||
UpdateHighLow(iCount);
|
||||
end;
|
||||
DrawGraph;
|
||||
GraphCurrentReading;
|
||||
end;
|
||||
end;
|
||||
|
||||
function AsPercent(aValue, aMax: double): double;
|
||||
function AsPercent(aValue, aMin, aMax: double): double;
|
||||
begin
|
||||
if aMax > 0 then
|
||||
Result := aValue / aMax * 100
|
||||
Result := aValue / (aMax - aMin) * 100
|
||||
else
|
||||
Result := 0;
|
||||
end;
|
||||
|
||||
procedure Tmainform.DrawGraph;
|
||||
procedure Tmainform.GraphCurrentReading;
|
||||
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_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));
|
||||
lineseries_allpollu.AddXY(FoobotData_time[0],
|
||||
AsPercent(FoobotData_allpollu[0], as_allpollu.ValueMax));
|
||||
AsPercent(FoobotData_allpollu[0], as_allpollu.ValueMin, as_allpollu.ValueMax));
|
||||
end;
|
||||
|
||||
procedure Tmainform.DrawGraphHistory;
|
||||
procedure Tmainform.GraphHistory;
|
||||
// Fetch Hourly readings for the previous 2 days (AverageBy=3600)
|
||||
// Populate FoobotDataObjectToArrays
|
||||
var
|
||||
@ -573,7 +610,8 @@ var
|
||||
iStartSeconds, iEndSeconds: int64;
|
||||
begin
|
||||
iEndSeconds := DateTimeToUnix(Now) - 3600;
|
||||
iStartSeconds := iEndSeconds - (2 * (24 * 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))]);
|
||||
if FetchFoobotData(dfStartEnd, 0, 0, 3600, iStartSeconds, iEndSeconds, sSecretKey) =
|
||||
False then
|
||||
exit;
|
||||
@ -581,17 +619,18 @@ begin
|
||||
for iCount := 0 to Pred(High(FoobotData_time)) do
|
||||
begin
|
||||
lineseries_pm.AddXY(FoobotData_time[iCount],
|
||||
AsPercent(FoobotData_pm[iCount], as_pm.ValueMax));
|
||||
AsPercent(FoobotData_pm[iCount], as_pm.ValueMin, as_pm.ValueMax));
|
||||
lineseries_tmp.AddXY(FoobotData_time[iCount],
|
||||
AsPercent(FoobotData_tmp[iCount], as_tmp.ValueMax));
|
||||
AsPercent(FoobotData_tmp[iCount], as_tmp.ValueMin, as_tmp.ValueMax));
|
||||
lineseries_hum.AddXY(FoobotData_time[iCount],
|
||||
AsPercent(FoobotData_hum[iCount], as_hum.ValueMax));
|
||||
AsPercent(FoobotData_hum[iCount], as_hum.ValueMin, as_hum.ValueMax));
|
||||
lineseries_co2.AddXY(FoobotData_time[iCount],
|
||||
AsPercent(FoobotData_co2[iCount], as_co2.ValueMax));
|
||||
AsPercent(FoobotData_co2[iCount], as_co2.ValueMin, as_co2.ValueMax));
|
||||
lineseries_voc.AddXY(FoobotData_time[iCount],
|
||||
AsPercent(FoobotData_voc[iCount], as_voc.ValueMax));
|
||||
AsPercent(FoobotData_voc[iCount], as_voc.ValueMin, as_voc.ValueMax));
|
||||
lineseries_allpollu.AddXY(FoobotData_time[iCount],
|
||||
AsPercent(FoobotData_allpollu[iCount], as_allpollu.ValueMax));
|
||||
AsPercent(FoobotData_allpollu[iCount], as_allpollu.ValueMin,
|
||||
as_allpollu.ValueMax));
|
||||
end;
|
||||
ResetArrays; // at end
|
||||
end;
|
||||
|
Reference in New Issue
Block a user