V 0.2.1.0: work-in-progress. TODO: triggers form

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5610 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
gbamber
2017-01-08 18:49:20 +00:00
parent 6b0464cfcf
commit aad378487c
7 changed files with 522 additions and 301 deletions

View File

@ -40,7 +40,8 @@ const
FOOBOT_DATA_LAST_URL = 'https://api.foobot.io/v2/device/%s/datapoint/%s/%s/%s/'; FOOBOT_DATA_LAST_URL = 'https://api.foobot.io/v2/device/%s/datapoint/%s/%s/%s/';
FOOBOT_DATA_START_FINISH_URL = FOOBOT_DATA_START_FINISH_URL =
'https://api.foobot.io/v2/device/%s/datapoint/%s/%s/%s/'; 'https://api.foobot.io/v2/device/%s/datapoint/%s/%s/%s/';
HIGHLOWMAX = 6;
// Used throughout in arrays, counts etc.
C_TIME = 0; C_TIME = 0;
C_PM = 1; C_PM = 1;
C_TMP = 2; C_TMP = 2;
@ -48,12 +49,11 @@ const
C_CO2 = 4; C_CO2 = 4;
C_VOC = 5; C_VOC = 5;
C_ALLPOLLU = 6; C_ALLPOLLU = 6;
C_NONE = 7;
type type
TDataFetchType = (dfLast, dfStartEnd); TDataFetchType = (dfLast, dfStartEnd); // FetchFoobotData
TSensorType = (st_time, st_pm, st_tmp, st_hum, st_co2, st_voc, st_allpollu); TSensorType = (st_time, st_pm, st_tmp, st_hum, st_co2, st_voc, st_allpollu); // Unused
TAlertType = (at_high, at_low); TAlertType = (at_high, at_low); // TAlertRec
TAlertRec = record TAlertRec = record
AlertTriggered: boolean; AlertTriggered: boolean;
@ -78,6 +78,10 @@ function FetchFoobotData(DataFetchType: TDataFetchType = dfLast;
// - also populates HighLow arrays // - also populates HighLow arrays
function FoobotDataObjectToArrays: boolean; function FoobotDataObjectToArrays: boolean;
// Sets internal FooBotTriggerArray which can be tested against in FoobotDataObjectToArrays
// aSensor use consts: C_PM,C_TMP etc.
function SetHighTrigger(const aSensor: integer; const aValue: variant): boolean;
function SetLowTrigger(const aSensor: integer; const aValue: variant): boolean;
// Utility functions // Utility functions
function ResetArrays: boolean; function ResetArrays: boolean;
@ -85,20 +89,21 @@ function ResetObjects: boolean;
function ResetHighLows: boolean; function ResetHighLows: boolean;
function SaveHighLows: boolean; function SaveHighLows: boolean;
function LoadHighLows: boolean; function LoadHighLows: boolean;
function SaveTriggers: boolean;
function LoadTriggers: boolean;
var var
// Used to fetch server data // Used to fetch server data
HttpClient: TFPHTTPClient; HttpClient: TFPHTTPClient;
// Holds identity values for multiple Foobots // Holds identity values for multiple Foobots (FoobotIdentityObject.FoobotIdentityList)
FoobotIdentityObject: TFoobotIdentityObject; FoobotIdentityObject: TFoobotIdentityObject;
// Holds data for current Foobot // Holds data for current Foobot
FoobotDataObject: TFoobotDataObject; FoobotDataObject: TFoobotDataObject;
// Used in FetchAuthenticationKey
sAuthenticationKey: string; sAuthenticationKey: string;
SensorType: TSensorType; // st_time, st_pm, st_tmp etc.
// Boolean to enable/disable serialisation of HighLows. Default = TRUE // Boolean to enable/disable serialisation of HighLows. Default = TRUE
SaveLoadHighLows: boolean; SaveLoadHighLows: boolean;
// Boolean to enable/disable Trigger functions // Boolean to enable/disable Trigger functions. Default = FALSE
UseTriggers: boolean; UseTriggers: boolean;
// Used in data fetch // Used in data fetch
TheCurrentFoobot: integer; TheCurrentFoobot: integer;
@ -114,10 +119,10 @@ var
FoobotData_voc: array of integer; FoobotData_voc: array of integer;
FoobotData_allpollu: array of double; FoobotData_allpollu: array of double;
// Set in FoobotDataObjectToArrays // Set in FoobotDataObjectToArrays
FoobotDataHighs: array[0..HIGHLOWMAX] of variant; FoobotDataHighs: array[C_TIME..C_ALLPOLLU] of variant;
FoobotDataLows: array[0..HIGHLOWMAX] of variant; FoobotDataLows: array[C_TIME..C_ALLPOLLU] of variant;
FoobotDataHighTimes: array[0..HIGHLOWMAX] of variant; FoobotDataHighTimes: array[C_TIME..C_ALLPOLLU] of variant;
FoobotDataLowTimes: array[0..HIGHLOWMAX] of variant; FoobotDataLowTimes: array[C_TIME..C_ALLPOLLU] of variant;
// [0=Low(at_low)..1=High(at_high), C_PM..C_ALLPOLLU] // [0=Low(at_low)..1=High(at_high), C_PM..C_ALLPOLLU]
// Dynamic in case of future changes (e.g. more triggers) // Dynamic in case of future changes (e.g. more triggers)
@ -128,105 +133,217 @@ var
implementation implementation
function SaveHighLows: boolean; function SaveTriggers: boolean;
// Save values to an INI data file // To foobotmonitor.ini
var var
sFoobotName: string; sFoobotName: string;
begin begin
if SaveLoadHighLows = False then Result:=FALSE; // assume failure
Exit(False); if FoobotIdentityObject.FoobotIdentityList.Count = 0 then Exit(FALSE);
sFoobotName := FoobotIdentityObject.FoobotIdentityList[TheCurrentFoobot].Name; sFoobotName := FoobotIdentityObject.FoobotIdentityList[TheCurrentFoobot].Name;
if (sFoobotName = '') then
Exit(False);
if not Assigned(HLINI) then if not Assigned(HLINI) then
HLINI := TIniFile.Create(ChangeFileExt(GetAppConfigFile(False), '.ini')); HLINI := TIniFile.Create(ChangeFileExt(GetAppConfigFile(False), '.ini'));
// Store current Foobot info try
HLINI.WriteInteger('Foobot', 'CurrentFoobot', TheCurrentFoobot); // Store current Foobot triggers
HLINI.WriteString('Foobot', 'CurrentFoobotName', sFoobotName); with HLINI do
begin
// Particulates WriteInteger('Foobot', 'CurrentFoobot', TheCurrentFoobot);
HLINI.WriteFloat(sFoobotName, 'pmHigh', double(FoobotDataHighs[C_PM])); WriteString('Foobot', 'CurrentFoobotName', sFoobotName);
HLINI.WriteDateTime(sFoobotName, 'pmHighTime', TDateTime(FoobotDataHighTimes[C_PM])); WriteFloat(sFoobotName, 'pmTriggerHigh',
HLINI.WriteFloat(sFoobotName, 'pmLow', double(FoobotDataLows[C_PM])); double(FooBotTriggerArray[Ord(at_high), C_PM]));
HLINI.WriteDateTime(sFoobotName, 'pmLowTime', TDateTime(FoobotDataLowTimes[C_PM])); WriteFloat(sFoobotName, 'pmTriggerLow',
// Temp double(FooBotTriggerArray[Ord(at_Low), C_PM]));
HLINI.WriteFloat(sFoobotName, 'tmpHigh', double(FoobotDataHighs[C_TMP])); WriteFloat(sFoobotName, 'tmpTriggerHigh',
HLINI.WriteDateTime(sFoobotName, 'tmpHighTime', TDateTime(FoobotDataHighTimes[C_TMP])); double(FooBotTriggerArray[Ord(at_high), C_TMP]));
HLINI.WriteFloat(sFoobotName, 'tmpLow', double(FoobotDataLows[C_TMP])); WriteFloat(sFoobotName, 'tmpTriggerLow',
HLINI.WriteDateTime(sFoobotName, 'tmpLowTime', TDateTime(FoobotDataLowTimes[C_TMP])); double(FooBotTriggerArray[Ord(at_Low), C_TMP]));
// Humidity WriteFloat(sFoobotName, 'humTriggerHigh',
HLINI.WriteFloat(sFoobotName, 'humHigh', double(FoobotDataHighs[C_HUM])); double(FooBotTriggerArray[Ord(at_high), C_HUM]));
HLINI.WriteDateTime(sFoobotName, 'humHighTime', TDateTime(FoobotDataHighTimes[C_HUM])); WriteFloat(sFoobotName, 'humTriggerLow',
HLINI.WriteFloat(sFoobotName, 'humLow', double(FoobotDataLows[C_HUM])); double(FooBotTriggerArray[Ord(at_Low), C_HUM]));
HLINI.WriteDateTime(sFoobotName, 'humLowTime', TDateTime(FoobotDataLowTimes[C_HUM])); WriteFloat(sFoobotName, 'co2TriggerHigh',
// CO2 double(FooBotTriggerArray[Ord(at_high), C_CO2]));
HLINI.WriteInteger(sFoobotName, 'co2High', integer(FoobotDataHighs[C_CO2])); WriteFloat(sFoobotName, 'co2TriggerLow',
HLINI.WriteDateTime(sFoobotName, 'co2HighTime', TDateTime(FoobotDataHighTimes[C_CO2])); double(FooBotTriggerArray[Ord(at_Low), C_CO2]));
HLINI.WriteInteger(sFoobotName, 'co2Low', integer(FoobotDataLows[C_CO2])); WriteFloat(sFoobotName, 'vocTriggerHigh',
HLINI.WriteDateTime(sFoobotName, 'co2LowTime', TDateTime(FoobotDataLowTimes[C_CO2])); double(FooBotTriggerArray[Ord(at_high), C_VOC]));
// Volatile Compounds WriteFloat(sFoobotName, 'vocTriggerLow',
HLINI.WriteInteger(sFoobotName, 'vocHigh', integer(FoobotDataHighs[C_VOC])); double(FooBotTriggerArray[Ord(at_Low), C_VOC]));
HLINI.WriteDateTime(sFoobotName, 'vocHighTime', TDateTime(FoobotDataHighTimes[C_VOC])); WriteFloat(sFoobotName, 'allpolluTriggerHigh',
HLINI.WriteInteger(sFoobotName, 'vocLow', integer(FoobotDataLows[C_VOC])); double(FooBotTriggerArray[Ord(at_high), C_ALLPOLLU]));
HLINI.WriteDateTime(sFoobotName, 'vocLowTime', TDateTime(FoobotDataLowTimes[C_VOC])); WriteFloat(sFoobotName, 'allpolluTriggerLow',
// All Pollution double(FooBotTriggerArray[Ord(at_Low), C_ALLPOLLU]));
HLINI.WriteFloat(sFoobotName, 'allpolluHigh', double(FoobotDataHighs[C_ALLPOLLU])); end;
HLINI.WriteDateTime(sFoobotName, 'allpolluHighTime', Result := True;
TDateTime(FoobotDataHighTimes[C_ALLPOLLU])); except
HLINI.WriteFloat(sFoobotName, 'allpolluLow', double(FoobotDataLows[C_ALLPOLLU])); raise Exception.Create('Could not save Triggers');
HLINI.WriteDateTime(sFoobotName, 'allpolluLowTime', end;
TDateTime(FoobotDataLowTimes[C_ALLPOLLU]));
Result := True;
end; end;
function LoadHighLows: boolean; function LoadTriggers: boolean;
// Load values from an INI data file // From foobotmonitor.ini
var var
sFoobotName: string; sFoobotName: string;
begin begin
if SaveLoadHighLows = False then Result:=FALSE; // assume failure
begin if FoobotIdentityObject.FoobotIdentityList.Count = 0 then Exit(FALSE);
ShowMessage('Unable to load All-Time stats');
Exit(False);
end;
sFoobotName := FoobotIdentityObject.FoobotIdentityList[TheCurrentFoobot].Name; sFoobotName := FoobotIdentityObject.FoobotIdentityList[TheCurrentFoobot].Name;
if (sFoobotName = '') then
Exit(False);
if not Assigned(HLINI) then if not Assigned(HLINI) then
HLINI := TIniFile.Create(ChangeFileExt(GetAppConfigFile(False), '.ini')); HLINI := TIniFile.Create(ChangeFileExt(GetAppConfigFile(False), '.ini'));
// Make sure the High-Lows are for the current Foobot // Make sure the High-Lows are for the current Foobot
if (HLINI.ReadString('Foobot', 'CurrentFoobotName', 'unknown') <> sFoobotName) then if (HLINI.ReadString('Foobot', 'CurrentFoobotName', 'unknown') <> sFoobotName) then
Exit(False); Exit(False);
try
// Load current Foobot triggers
with HLINI do
begin
FooBotTriggerArray[Ord(at_high), C_PM] := ReadFloat(sFoobotName, 'pmTriggerHigh', 0);
FooBotTriggerArray[Ord(at_low), C_PM] := ReadFloat(sFoobotName, 'pmTriggerLow', 0);
FooBotTriggerArray[Ord(at_high), C_TMP] := ReadFloat(sFoobotName, 'tmpTriggerHigh', 0);
FooBotTriggerArray[Ord(at_low), C_TMP] := ReadFloat(sFoobotName, 'tmpTriggerLow', 0);
FooBotTriggerArray[Ord(at_high), C_HUM] := ReadFloat(sFoobotName, 'humTriggerHigh', 0);
FooBotTriggerArray[Ord(at_low), C_HUM] := ReadFloat(sFoobotName, 'humTriggerLow', 0);
FooBotTriggerArray[Ord(at_high), C_CO2] := ReadFloat(sFoobotName, 'co2TriggerHigh', 0);
FooBotTriggerArray[Ord(at_low), C_CO2] := ReadFloat(sFoobotName, 'co2TriggerLow', 0);
FooBotTriggerArray[Ord(at_high), C_VOC] := ReadFloat(sFoobotName, 'vocTriggerHigh', 0);
FooBotTriggerArray[Ord(at_low), C_VOC] := ReadFloat(sFoobotName, 'vocTriggerLow', 0);
FooBotTriggerArray[Ord(at_high), C_ALLPOLLU] :=
ReadFloat(sFoobotName, 'allpolluTriggerHigh', 0);
FooBotTriggerArray[Ord(at_low), C_ALLPOLLU] :=
ReadFloat(sFoobotName, 'allpolluTriggerLow', 0);
end;
Result := True;
except
raise Exception.Create('Could not load Triggers');
end;
end;
// Particulates function SaveHighLows: boolean;
FoobotDataHighs[C_PM] := HLINI.ReadFloat(sFoobotName, 'pmHigh', 0); // Save values to an INI data file
FoobotDataHighTimes[C_PM] := HLINI.ReadDateTime(sFoobotName, 'pmHighTime', Now); // To foobotmonitor.ini
FoobotDataLows[C_PM] := HLINI.ReadFloat(sFoobotName, 'pmLow', 0); var
FoobotDataLowTimes[C_PM] := HLINI.ReadDateTime(sFoobotName, 'pmLowTime', Now); sFoobotName: string;
// Temp begin
FoobotDataHighs[C_TMP] := HLINI.ReadFloat(sFoobotName, 'tmpHigh', 0); Result:=FALSE; // assume failure
FoobotDataHighTimes[C_TMP] := HLINI.ReadDateTime(sFoobotName, 'tmpHighTime', Now); if SaveLoadHighLows = False then
FoobotDataLows[C_TMP] := HLINI.ReadFloat(sFoobotName, 'tmpLow', 0); Exit(False);
FoobotDataLowTimes[C_TMP] := HLINI.ReadDateTime(sFoobotName, 'tmpLowTime', Now); if FoobotIdentityObject.FoobotIdentityList.Count = 0 then Exit(FALSE);
// Humidity sFoobotName := FoobotIdentityObject.FoobotIdentityList[TheCurrentFoobot].Name;
FoobotDataHighs[C_HUM] := HLINI.ReadFloat(sFoobotName, 'humHigh', 0); if (sFoobotName = '') then
FoobotDataHighTimes[C_HUM] := HLINI.ReadDateTime(sFoobotName, 'humHighTime', Now); Exit(False);
FoobotDataLows[C_HUM] := HLINI.ReadFloat(sFoobotName, 'humLow', 0); if not Assigned(HLINI) then
FoobotDataLowTimes[C_HUM] := HLINI.ReadDateTime(sFoobotName, 'humLowTime', Now); HLINI := TIniFile.Create(ChangeFileExt(GetAppConfigFile(False), '.ini'));
// CO2 // Store current Foobot info
FoobotDataHighs[C_CO2] := HLINI.ReadInteger(sFoobotName, 'co2High', 0); try
FoobotDataHighTimes[C_CO2] := HLINI.ReadDateTime(sFoobotName, 'co2HighTime', Now); with HLINI do
FoobotDataLows[C_CO2] := HLINI.ReadInteger(sFoobotName, 'co2Low', 0); begin
FoobotDataLowTimes[C_CO2] := HLINI.ReadDateTime(sFoobotName, 'co2LowTime', Now); WriteInteger('Foobot', 'CurrentFoobot', TheCurrentFoobot);
// Volatile Compounds WriteString('Foobot', 'CurrentFoobotName', sFoobotName);
FoobotDataHighs[C_VOC] := HLINI.ReadInteger(sFoobotName, 'vocHigh', 0);
FoobotDataHighTimes[C_VOC] := HLINI.ReadDateTime(sFoobotName, 'vocHighTime', Now); // Particulates
FoobotDataLows[C_VOC] := HLINI.ReadInteger(sFoobotName, 'vocLow', 0); WriteFloat(sFoobotName, 'pmHigh', double(FoobotDataHighs[C_PM]));
FoobotDataLowTimes[C_VOC] := HLINI.ReadDateTime(sFoobotName, 'vocLowTime', Now); WriteDateTime(sFoobotName, 'pmHighTime', TDateTime(FoobotDataHighTimes[C_PM]));
// All Pollution WriteFloat(sFoobotName, 'pmLow', double(FoobotDataLows[C_PM]));
FoobotDataHighs[C_ALLPOLLU] := HLINI.ReadFloat(sFoobotName, 'allpolluHigh', 0); WriteDateTime(sFoobotName, 'pmLowTime', TDateTime(FoobotDataLowTimes[C_PM]));
FoobotDataHighTimes[C_ALLPOLLU] := // Temp
HLINI.ReadDateTime(sFoobotName, 'allpolluHighTime', Now); WriteFloat(sFoobotName, 'tmpHigh', double(FoobotDataHighs[C_TMP]));
FoobotDataLows[C_ALLPOLLU] := HLINI.ReadFloat(sFoobotName, 'allpolluLow', 0); WriteDateTime(sFoobotName, 'tmpHighTime', TDateTime(FoobotDataHighTimes[C_TMP]));
FoobotDataLowTimes[C_ALLPOLLU] := WriteFloat(sFoobotName, 'tmpLow', double(FoobotDataLows[C_TMP]));
HLINI.ReadDateTime(sFoobotName, 'allpolluLowTime', Now); WriteDateTime(sFoobotName, 'tmpLowTime', TDateTime(FoobotDataLowTimes[C_TMP]));
Result := True; // Humidity
WriteFloat(sFoobotName, 'humHigh', double(FoobotDataHighs[C_HUM]));
WriteDateTime(sFoobotName, 'humHighTime', TDateTime(FoobotDataHighTimes[C_HUM]));
WriteFloat(sFoobotName, 'humLow', double(FoobotDataLows[C_HUM]));
WriteDateTime(sFoobotName, 'humLowTime', TDateTime(FoobotDataLowTimes[C_HUM]));
// CO2
WriteInteger(sFoobotName, 'co2High', integer(FoobotDataHighs[C_CO2]));
WriteDateTime(sFoobotName, 'co2HighTime', TDateTime(FoobotDataHighTimes[C_CO2]));
WriteInteger(sFoobotName, 'co2Low', integer(FoobotDataLows[C_CO2]));
WriteDateTime(sFoobotName, 'co2LowTime', TDateTime(FoobotDataLowTimes[C_CO2]));
// Volatile Compounds
WriteInteger(sFoobotName, 'vocHigh', integer(FoobotDataHighs[C_VOC]));
WriteDateTime(sFoobotName, 'vocHighTime', TDateTime(FoobotDataHighTimes[C_VOC]));
WriteInteger(sFoobotName, 'vocLow', integer(FoobotDataLows[C_VOC]));
WriteDateTime(sFoobotName, 'vocLowTime', TDateTime(FoobotDataLowTimes[C_VOC]));
// All Pollution
WriteFloat(sFoobotName, 'allpolluHigh', double(FoobotDataHighs[C_ALLPOLLU]));
WriteDateTime(sFoobotName, 'allpolluHighTime',
TDateTime(FoobotDataHighTimes[C_ALLPOLLU]));
WriteFloat(sFoobotName, 'allpolluLow', double(FoobotDataLows[C_ALLPOLLU]));
WriteDateTime(sFoobotName, 'allpolluLowTime',
TDateTime(FoobotDataLowTimes[C_ALLPOLLU]));
Result := True;
end;
except
raise Exception.Create('Could not save HighLows');
end;
end;
function LoadHighLows: boolean;
// Load values from an INI data file
// From foobotmonitor.ini
var
sFoobotName: string;
begin
Result:=FALSE; // assume failure
if SaveLoadHighLows = False then
begin
ShowMessage('Unable to load All-Time stats');
Exit(False);
end;
if FoobotIdentityObject.FoobotIdentityList.Count = 0 then Exit(FALSE);
sFoobotName := FoobotIdentityObject.FoobotIdentityList[TheCurrentFoobot].Name;
if (sFoobotName = '') then
Exit(False);
if not Assigned(HLINI) then
HLINI := TIniFile.Create(ChangeFileExt(GetAppConfigFile(False), '.ini'));
// Make sure the High-Lows are for the current Foobot
if (HLINI.ReadString('Foobot', 'CurrentFoobotName', 'unknown') <> sFoobotName) then
Exit(False);
try
with HLINI do
begin
// Particulates
FoobotDataHighs[C_PM] := ReadFloat(sFoobotName, 'pmHigh', 0);
FoobotDataHighTimes[C_PM] := ReadDateTime(sFoobotName, 'pmHighTime', Now);
FoobotDataLows[C_PM] := ReadFloat(sFoobotName, 'pmLow', 0);
FoobotDataLowTimes[C_PM] := ReadDateTime(sFoobotName, 'pmLowTime', Now);
// Temp
FoobotDataHighs[C_TMP] := ReadFloat(sFoobotName, 'tmpHigh', 0);
FoobotDataHighTimes[C_TMP] := ReadDateTime(sFoobotName, 'tmpHighTime', Now);
FoobotDataLows[C_TMP] := ReadFloat(sFoobotName, 'tmpLow', 0);
FoobotDataLowTimes[C_TMP] := ReadDateTime(sFoobotName, 'tmpLowTime', Now);
// Humidity
FoobotDataHighs[C_HUM] := ReadFloat(sFoobotName, 'humHigh', 0);
FoobotDataHighTimes[C_HUM] := ReadDateTime(sFoobotName, 'humHighTime', Now);
FoobotDataLows[C_HUM] := ReadFloat(sFoobotName, 'humLow', 0);
FoobotDataLowTimes[C_HUM] := ReadDateTime(sFoobotName, 'humLowTime', Now);
// CO2
FoobotDataHighs[C_CO2] := ReadInteger(sFoobotName, 'co2High', 0);
FoobotDataHighTimes[C_CO2] := ReadDateTime(sFoobotName, 'co2HighTime', Now);
FoobotDataLows[C_CO2] := ReadInteger(sFoobotName, 'co2Low', 0);
FoobotDataLowTimes[C_CO2] := ReadDateTime(sFoobotName, 'co2LowTime', Now);
// Volatile Compounds
FoobotDataHighs[C_VOC] := ReadInteger(sFoobotName, 'vocHigh', 0);
FoobotDataHighTimes[C_VOC] := ReadDateTime(sFoobotName, 'vocHighTime', Now);
FoobotDataLows[C_VOC] := ReadInteger(sFoobotName, 'vocLow', 0);
FoobotDataLowTimes[C_VOC] := ReadDateTime(sFoobotName, 'vocLowTime', Now);
// All Pollution
FoobotDataHighs[C_ALLPOLLU] := ReadFloat(sFoobotName, 'allpolluHigh', 0);
FoobotDataHighTimes[C_ALLPOLLU] :=
ReadDateTime(sFoobotName, 'allpolluHighTime', Now);
FoobotDataLows[C_ALLPOLLU] := ReadFloat(sFoobotName, 'allpolluLow', 0);
FoobotDataLowTimes[C_ALLPOLLU] :=
ReadDateTime(sFoobotName, 'allpolluLowTime', Now);
Result := True;
end;
except
raise Exception.Create('Could not Load HighLows');
end;
end; end;
// Function to make the Foobot data accessible // Function to make the Foobot data accessible
@ -361,15 +478,15 @@ begin
SetHigh(J, FoobotData_allpollu[K], FoobotData_time[K]); SetHigh(J, FoobotData_allpollu[K], FoobotData_time[K]);
SetLow(J, FoobotData_allpollu[K], FoobotData_time[K]); SetLow(J, FoobotData_allpollu[K], FoobotData_time[K]);
end; end;
else raise Exception.Create('Error in FoobotDataObjectToArrays Case'); else
raise Exception.Create('Error in FoobotDataObjectToArrays Case');
end; // of Case end; // of Case
end; end;
end; end;
end; end;
function SetHighTrigger(const aSensor: integer; const aValue: variant): boolean;
function SetHighTrigger(const aSensor: TSensorType; const aValue: variant): boolean;
begin begin
Result := False; Result := False;
if UseTriggers = False then if UseTriggers = False then
@ -381,7 +498,7 @@ begin
end; end;
end; end;
function SetLowTrigger(const aSensor: TSensorType; const aValue: variant): boolean; function SetLowTrigger(const aSensor: integer; const aValue: variant): boolean;
begin begin
Result := False; Result := False;
if UseTriggers = False then if UseTriggers = False then
@ -398,7 +515,7 @@ function ResetHighLows: boolean;
var var
iCount: integer; iCount: integer;
begin begin
for iCount := 0 to HIGHLOWMAX do for iCount := C_TIME to C_ALLPOLLU do
begin begin
FoobotDataHighs[iCount] := 0; FoobotDataHighs[iCount] := 0;
FoobotDataLows[iCount] := 0; FoobotDataLows[iCount] := 0;

View File

@ -1,4 +1,5 @@
unit foobot_objects; unit foobot_objects;
{ Objects for Foobot Lazarus { Objects for Foobot Lazarus
Copyright (C)2016 Gordon Bamber minsadorada@charcodelvalle.com Copyright (C)2016 Gordon Bamber minsadorada@charcodelvalle.com
@ -40,7 +41,7 @@ type
property uuid: string read Fuuid write Fuuid; property uuid: string read Fuuid write Fuuid;
property userId: integer read FuserId write FuserId; property userId: integer read FuserId write FuserId;
property mac: string read FMac write FMac; property mac: string read FMac write FMac;
property name: string read FName write FName; property Name: string read FName write FName;
end; end;
{TFoobotIdentityList} {TFoobotIdentityList}
@ -65,26 +66,24 @@ type
type type
TFoobotDataObject = class(TPersistent) TFoobotDataObject = class(TPersistent)
private private
FDataPoints:Variant; FDataPoints: variant;
FSensors:TStrings; FSensors: TStrings;
FUnits:TStrings; FUnits: TStrings;
Fuuid:String; Fuuid: string;
FStart:Int64; FStart: int64;
FEnd:Int64; FEnd: int64;
public public
constructor Create; constructor Create;
Destructor Destroy; override; destructor Destroy; override;
function SaveToFile(const AFilename: string): boolean; function SaveToFile(const AFilename: string): boolean;
published published
property uuid:String read Fuuid write Fuuid; property uuid: string read Fuuid write Fuuid;
property start:Int64 read FStart write FStart; property start: int64 read FStart write FStart;
property &end:Int64 read FEnd write FEnd; property &end:Int64 read FEnd write FEnd;
property sensors:TStrings property sensors: TStrings read FSensors write FSensors;
read FSensors write FSensors; property units: TStrings read FUnits write FUnits;
property units:TStrings property datapoints: variant read FDataPoints write FDataPoints;
read FUnits write FUnits;
property datapoints : Variant read FDataPoints write FDataPoints;
end; end;
@ -93,11 +92,12 @@ implementation
constructor TFoobotDataObject.Create; constructor TFoobotDataObject.Create;
begin begin
inherited; inherited;
FSensors:=TStringList.Create; FSensors := TStringList.Create;
FUnits:=TstringList.Create; FUnits := TStringList.Create;
end; end;
Destructor TFoobotDataObject.Destroy; destructor TFoobotDataObject.Destroy;
begin begin
FSensors.Free; FSensors.Free;
FUnits.Free; FUnits.Free;

View File

@ -3,14 +3,14 @@
<ProjectSession> <ProjectSession>
<PathDelim Value="\"/> <PathDelim Value="\"/>
<Version Value="10"/> <Version Value="10"/>
<BuildModes Active="Debug"/> <BuildModes Active="win32"/>
<Units Count="33"> <Units Count="33">
<Unit0> <Unit0>
<Filename Value="foobotmonitor.lpr"/> <Filename Value="foobotmonitor.lpr"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<EditorIndex Value="14"/> <EditorIndex Value="12"/>
<CursorPos Y="35"/> <CursorPos Y="35"/>
<UsageCount Value="102"/> <UsageCount Value="108"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit0> </Unit0>
<Unit1> <Unit1>
@ -19,9 +19,9 @@
<ComponentName Value="mainform"/> <ComponentName Value="mainform"/>
<HasResources Value="True"/> <HasResources Value="True"/>
<ResourceBaseClass Value="Form"/> <ResourceBaseClass Value="Form"/>
<TopLine Value="808"/> <IsVisibleTab Value="True"/>
<CursorPos X="54" Y="821"/> <CursorPos X="26" Y="19"/>
<UsageCount Value="102"/> <UsageCount Value="108"/>
<Loaded Value="True"/> <Loaded Value="True"/>
<LoadedDesigner Value="True"/> <LoadedDesigner Value="True"/>
</Unit1> </Unit1>
@ -31,10 +31,10 @@
<ComponentName Value="configform"/> <ComponentName Value="configform"/>
<HasResources Value="True"/> <HasResources Value="True"/>
<ResourceBaseClass Value="Form"/> <ResourceBaseClass Value="Form"/>
<EditorIndex Value="9"/> <EditorIndex Value="7"/>
<TopLine Value="33"/> <TopLine Value="33"/>
<CursorPos X="41" Y="45"/> <CursorPos X="41" Y="45"/>
<UsageCount Value="92"/> <UsageCount Value="98"/>
<Loaded Value="True"/> <Loaded Value="True"/>
<LoadedDesigner Value="True"/> <LoadedDesigner Value="True"/>
</Unit2> </Unit2>
@ -44,7 +44,7 @@
<EditorIndex Value="-1"/> <EditorIndex Value="-1"/>
<TopLine Value="380"/> <TopLine Value="380"/>
<CursorPos X="35" Y="387"/> <CursorPos X="35" Y="387"/>
<UsageCount Value="84"/> <UsageCount Value="90"/>
</Unit3> </Unit3>
<Unit4> <Unit4>
<Filename Value="..\foobot_objects.pas"/> <Filename Value="..\foobot_objects.pas"/>
@ -53,16 +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="84"/> <UsageCount Value="90"/>
</Unit4> </Unit4>
<Unit5> <Unit5>
<Filename Value="..\foobot_utility.pas"/> <Filename Value="..\foobot_utility.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<IsVisibleTab Value="True"/> <EditorIndex Value="9"/>
<EditorIndex Value="11"/> <TopLine Value="88"/>
<TopLine Value="337"/> <CursorPos X="45" Y="108"/>
<CursorPos X="13" Y="364"/> <UsageCount Value="108"/>
<UsageCount Value="102"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit5> </Unit5>
<Unit6> <Unit6>
@ -72,15 +71,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="84"/> <UsageCount Value="90"/>
</Unit6> </Unit6>
<Unit7> <Unit7>
<Filename Value="foobot_sensors.pas"/> <Filename Value="foobot_sensors.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<EditorIndex Value="6"/> <EditorIndex Value="4"/>
<TopLine Value="299"/> <TopLine Value="299"/>
<CursorPos X="14" Y="321"/> <CursorPos X="14" Y="321"/>
<UsageCount Value="36"/> <UsageCount Value="42"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit7> </Unit7>
<Unit8> <Unit8>
@ -91,7 +90,7 @@
<ResourceBaseClass Value="Form"/> <ResourceBaseClass Value="Form"/>
<EditorIndex Value="2"/> <EditorIndex Value="2"/>
<CursorPos X="42" Y="25"/> <CursorPos X="42" Y="25"/>
<UsageCount Value="31"/> <UsageCount Value="37"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit8> </Unit8>
<Unit9> <Unit9>
@ -101,25 +100,25 @@
<HasResources Value="True"/> <HasResources Value="True"/>
<ResourceBaseClass Value="Form"/> <ResourceBaseClass Value="Form"/>
<EditorIndex Value="1"/> <EditorIndex Value="1"/>
<CursorPos X="22" Y="7"/> <CursorPos X="57" Y="24"/>
<UsageCount Value="22"/> <UsageCount Value="28"/>
<Loaded Value="True"/> <Loaded Value="True"/>
<LoadedDesigner Value="True"/> <LoadedDesigner Value="True"/>
</Unit9> </Unit9>
<Unit10> <Unit10>
<Filename Value="..\latest_stable\foobot_httpclient.pas"/> <Filename Value="..\latest_stable\foobot_httpclient.pas"/>
<EditorIndex Value="10"/> <EditorIndex Value="8"/>
<TopLine Value="43"/> <TopLine Value="43"/>
<CursorPos X="47" Y="13"/> <CursorPos X="47" Y="13"/>
<UsageCount Value="68"/> <UsageCount Value="70"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit10> </Unit10>
<Unit11> <Unit11>
<Filename Value="..\latest_stable\foobot_objects.pas"/> <Filename Value="..\latest_stable\foobot_objects.pas"/>
<EditorIndex Value="13"/> <EditorIndex Value="11"/>
<TopLine Value="52"/> <TopLine Value="46"/>
<CursorPos Y="90"/> <CursorPos X="35" Y="59"/>
<UsageCount Value="68"/> <UsageCount Value="70"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit11> </Unit11>
<Unit12> <Unit12>
@ -128,12 +127,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="35"/> <UsageCount Value="34"/>
</Unit12> </Unit12>
<Unit13> <Unit13>
<Filename Value="..\latest_stable\umainform.lfm"/> <Filename Value="..\latest_stable\umainform.lfm"/>
<EditorIndex Value="-1"/> <EditorIndex Value="-1"/>
<UsageCount Value="7"/> <UsageCount Value="6"/>
<DefaultSyntaxHighlighter Value="LFM"/> <DefaultSyntaxHighlighter Value="LFM"/>
</Unit13> </Unit13>
<Unit14> <Unit14>
@ -141,21 +140,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="7"/> <UsageCount Value="6"/>
</Unit14> </Unit14>
<Unit15> <Unit15>
<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="15"/> <UsageCount Value="14"/>
</Unit15> </Unit15>
<Unit16> <Unit16>
<Filename Value="..\umainform.pas"/> <Filename Value="..\umainform.pas"/>
<EditorIndex Value="-1"/> <EditorIndex Value="-1"/>
<TopLine Value="145"/> <TopLine Value="145"/>
<CursorPos X="81" Y="158"/> <CursorPos X="81" Y="158"/>
<UsageCount Value="43"/> <UsageCount Value="42"/>
</Unit16> </Unit16>
<Unit17> <Unit17>
<Filename Value="C:\trunklatest\lazarus\lcl\lclmessageglue.pas"/> <Filename Value="C:\trunklatest\lazarus\lcl\lclmessageglue.pas"/>
@ -163,34 +162,34 @@
<EditorIndex Value="-1"/> <EditorIndex Value="-1"/>
<TopLine Value="93"/> <TopLine Value="93"/>
<CursorPos Y="114"/> <CursorPos Y="114"/>
<UsageCount Value="7"/> <UsageCount Value="6"/>
</Unit17> </Unit17>
<Unit18> <Unit18>
<Filename Value="..\ulogin.pas"/> <Filename Value="..\ulogin.pas"/>
<EditorIndex Value="-1"/> <EditorIndex Value="-1"/>
<CursorPos Y="108"/> <CursorPos Y="108"/>
<UsageCount Value="10"/> <UsageCount Value="9"/>
</Unit18> </Unit18>
<Unit19> <Unit19>
<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="8"/> <UsageCount Value="7"/>
</Unit19> </Unit19>
<Unit20> <Unit20>
<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="7"/> <UsageCount Value="6"/>
</Unit20> </Unit20>
<Unit21> <Unit21>
<Filename Value="C:\trunklatest\lazarus\ide\lazarus.pp"/> <Filename Value="C:\trunklatest\lazarus\ide\lazarus.pp"/>
<UnitName Value="Lazarus"/> <UnitName Value="Lazarus"/>
<EditorIndex Value="7"/> <EditorIndex Value="5"/>
<TopLine Value="101"/> <TopLine Value="101"/>
<CursorPos Y="154"/> <CursorPos Y="154"/>
<UsageCount Value="19"/> <UsageCount Value="21"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit21> </Unit21>
<Unit22> <Unit22>
@ -198,73 +197,71 @@
<EditorIndex Value="-1"/> <EditorIndex Value="-1"/>
<TopLine Value="11"/> <TopLine Value="11"/>
<CursorPos X="8" Y="33"/> <CursorPos X="8" Y="33"/>
<UsageCount Value="8"/> <UsageCount Value="7"/>
</Unit22> </Unit22>
<Unit23> <Unit23>
<Filename Value="D:\Lazarusprojects\healthmonitor\svn\healthanalysis\healthanalysis\umainform.pas"/> <Filename Value="D:\Lazarusprojects\healthmonitor\svn\healthanalysis\healthanalysis\umainform.pas"/>
<EditorIndex Value="-1"/> <EditorIndex Value="-1"/>
<TopLine Value="540"/> <TopLine Value="540"/>
<CursorPos X="55" Y="593"/> <CursorPos X="55" Y="593"/>
<UsageCount Value="8"/> <UsageCount Value="7"/>
</Unit23> </Unit23>
<Unit24> <Unit24>
<Filename Value="C:\trunklatest\fpc\rtl\objpas\sysutils\datih.inc"/> <Filename Value="C:\trunklatest\fpc\rtl\objpas\sysutils\datih.inc"/>
<EditorIndex Value="-1"/> <EditorIndex Value="-1"/>
<TopLine Value="109"/> <TopLine Value="109"/>
<CursorPos X="10" Y="128"/> <CursorPos X="10" Y="128"/>
<UsageCount Value="7"/> <UsageCount Value="6"/>
</Unit24> </Unit24>
<Unit25> <Unit25>
<Filename Value="C:\trunklatest\fpc\packages\rtl-objpas\src\inc\dateutil.inc"/> <Filename Value="C:\trunklatest\fpc\packages\rtl-objpas\src\inc\dateutil.inc"/>
<EditorIndex Value="12"/> <EditorIndex Value="10"/>
<TopLine Value="381"/> <TopLine Value="381"/>
<CursorPos X="13" Y="384"/> <CursorPos X="13" Y="384"/>
<UsageCount Value="37"/> <UsageCount Value="39"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit25> </Unit25>
<Unit26> <Unit26>
<Filename Value="..\latest_stable\udataform.pas"/> <Filename Value="..\latest_stable\udataform.pas"/>
<EditorIndex Value="8"/> <EditorIndex Value="6"/>
<TopLine Value="70"/> <TopLine Value="70"/>
<UsageCount Value="37"/> <UsageCount Value="39"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit26> </Unit26>
<Unit27> <Unit27>
<Filename Value="D:\lazarustrunk\common_components\cryptini\ucryptini.pas"/> <Filename Value="D:\lazarustrunk\common_components\cryptini\ucryptini.pas"/>
<EditorIndex Value="5"/> <EditorIndex Value="-1"/>
<TopLine Value="781"/> <TopLine Value="781"/>
<CursorPos X="28" Y="795"/> <CursorPos X="28" Y="795"/>
<UsageCount Value="22"/> <UsageCount Value="21"/>
<Loaded Value="True"/>
</Unit27> </Unit27>
<Unit28> <Unit28>
<Filename Value="C:\trunklatest\fpc\packages\fcl-base\src\fileinfo.pp"/> <Filename Value="C:\trunklatest\fpc\packages\fcl-base\src\fileinfo.pp"/>
<EditorIndex Value="-1"/> <EditorIndex Value="-1"/>
<TopLine Value="43"/> <TopLine Value="43"/>
<CursorPos X="19" Y="51"/> <CursorPos X="19" Y="51"/>
<UsageCount Value="11"/> <UsageCount Value="10"/>
</Unit28> </Unit28>
<Unit29> <Unit29>
<Filename Value="C:\trunklatest\lazarus\components\IndustrialStuff\industrial.pas"/> <Filename Value="C:\trunklatest\lazarus\components\IndustrialStuff\industrial.pas"/>
<EditorIndex Value="-1"/> <EditorIndex Value="-1"/>
<CursorPos X="18" Y="11"/> <CursorPos X="18" Y="11"/>
<UsageCount Value="9"/> <UsageCount Value="8"/>
</Unit29> </Unit29>
<Unit30> <Unit30>
<Filename Value="..\..\..\components\poweredby\latest_stable\upoweredby.pas"/> <Filename Value="..\..\..\components\poweredby\latest_stable\upoweredby.pas"/>
<UnitName Value="uPoweredby"/> <UnitName Value="uPoweredby"/>
<EditorIndex Value="4"/> <EditorIndex Value="-1"/>
<TopLine Value="190"/> <TopLine Value="190"/>
<CursorPos X="33" Y="205"/> <CursorPos X="33" Y="205"/>
<UsageCount Value="19"/> <UsageCount Value="18"/>
<Loaded Value="True"/>
</Unit30> </Unit30>
<Unit31> <Unit31>
<Filename Value="C:\trunklatest\lazarus\lcl\include\customform.inc"/> <Filename Value="C:\trunklatest\lazarus\lcl\include\customform.inc"/>
<EditorIndex Value="-1"/> <EditorIndex Value="-1"/>
<TopLine Value="2228"/> <TopLine Value="2228"/>
<CursorPos X="14" Y="2239"/> <CursorPos X="14" Y="2239"/>
<UsageCount Value="9"/> <UsageCount Value="8"/>
</Unit31> </Unit31>
<Unit32> <Unit32>
<Filename Value="C:\trunklatest\lazarus\lcl\graphics.pp"/> <Filename Value="C:\trunklatest\lazarus\lcl\graphics.pp"/>
@ -272,130 +269,130 @@
<EditorIndex Value="3"/> <EditorIndex Value="3"/>
<TopLine Value="1811"/> <TopLine Value="1811"/>
<CursorPos X="13" Y="1834"/> <CursorPos X="13" Y="1834"/>
<UsageCount Value="15"/> <UsageCount Value="17"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit32> </Unit32>
</Units> </Units>
<JumpHistory Count="30" HistoryIndex="29"> <JumpHistory Count="30" HistoryIndex="29">
<Position1> <Position1>
<Filename Value="..\foobot_utility.pas"/> <Filename Value="..\foobot_utility.pas"/>
<Caret Line="72" Column="34" TopLine="44"/> <Caret Line="374" Column="51" TopLine="327"/>
</Position1> </Position1>
<Position2> <Position2>
<Filename Value="..\foobot_utility.pas"/> <Filename Value="..\foobot_utility.pas"/>
<Caret Line="339" Column="25" TopLine="289"/> <Caret Line="83" Column="46" TopLine="97"/>
</Position2> </Position2>
<Position3> <Position3>
<Filename Value="..\foobot_utility.pas"/> <Filename Value="..\foobot_utility.pas"/>
<Caret Line="330" Column="40" TopLine="301"/> <Caret Line="100" Column="5" TopLine="93"/>
</Position3> </Position3>
<Position4> <Position4>
<Filename Value="..\foobot_utility.pas"/> <Filename Value="..\foobot_utility.pas"/>
<Caret Line="47" Column="84" TopLine="27"/> <Caret Line="101" Column="28" TopLine="93"/>
</Position4> </Position4>
<Position5> <Position5>
<Filename Value="..\foobot_utility.pas"/> <Filename Value="..\foobot_utility.pas"/>
<Caret Line="233" Column="46" TopLine="213"/> <Caret Line="374" Column="47" TopLine="348"/>
</Position5> </Position5>
<Position6> <Position6>
<Filename Value="..\foobot_utility.pas"/> <Filename Value="..\foobot_utility.pas"/>
<Caret Line="343" TopLine="303"/> <Caret Line="386" Column="46" TopLine="348"/>
</Position6> </Position6>
<Position7> <Position7>
<Filename Value="umainform.pas"/> <Filename Value="..\foobot_utility.pas"/>
<Caret Line="795" Column="55" TopLine="748"/> <Caret Line="55" Column="89" TopLine="28"/>
</Position7> </Position7>
<Position8> <Position8>
<Filename Value="..\foobot_utility.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="80" Column="9" TopLine="68"/> <Caret Line="502" Column="28" TopLine="492"/>
</Position8> </Position8>
<Position9> <Position9>
<Filename Value="umainform.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="43" Column="66" TopLine="23"/> <Caret Line="509" Column="28" TopLine="499"/>
</Position9> </Position9>
<Position10> <Position10>
<Filename Value="usplash.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="38" Column="19"/> <Caret Line="491" Column="12" TopLine="489"/>
</Position10> </Position10>
<Position11> <Position11>
<Filename Value="utriggersform.pas"/> <Filename Value="utriggersform.pas"/>
<Caret Line="26" Column="7"/> <Caret Line="18" Column="57"/>
</Position11> </Position11>
<Position12> <Position12>
<Filename Value="utriggersform.pas"/> <Filename Value="utriggersform.pas"/>
<Caret Line="34" Column="50"/> <Caret Line="19" Column="57"/>
</Position12> </Position12>
<Position13> <Position13>
<Filename Value="utriggersform.pas"/> <Filename Value="utriggersform.pas"/>
<Caret Line="35" Column="50"/> <Caret Line="20" Column="57"/>
</Position13> </Position13>
<Position14> <Position14>
<Filename Value="utriggersform.pas"/> <Filename Value="utriggersform.pas"/>
<Caret Line="37" Column="50"/> <Caret Line="21" Column="57"/>
</Position14> </Position14>
<Position15> <Position15>
<Filename Value="umainform.pas"/> <Filename Value="utriggersform.pas"/>
<Caret Line="30" Column="19" TopLine="23"/> <Caret Line="22" Column="57"/>
</Position15> </Position15>
<Position16> <Position16>
<Filename Value="umainform.pas"/> <Filename Value="utriggersform.pas"/>
<Caret Line="537" Column="25" TopLine="533"/> <Caret Line="23" Column="57"/>
</Position16> </Position16>
<Position17> <Position17>
<Filename Value="umainform.pas"/> <Filename Value="utriggersform.pas"/>
<Caret Line="41" Column="58" TopLine="31"/> <Caret Line="24" Column="57"/>
</Position17> </Position17>
<Position18> <Position18>
<Filename Value="umainform.pas"/> <Filename Value="utriggersform.pas"/>
<Caret Line="538" TopLine="536"/> <Caret Line="25" Column="57"/>
</Position18> </Position18>
<Position19> <Position19>
<Filename Value="umainform.pas"/> <Filename Value="utriggersform.pas"/>
<Caret Line="556" Column="54" TopLine="550"/> <Caret Line="24" Column="57"/>
</Position19> </Position19>
<Position20> <Position20>
<Filename Value="umainform.pas"/> <Filename Value="..\foobot_utility.pas"/>
<Caret Line="10" Column="25"/> <Caret Line="149" Column="77" TopLine="117"/>
</Position20> </Position20>
<Position21> <Position21>
<Filename Value="umainform.pas"/> <Filename Value="..\foobot_utility.pas"/>
<Caret Line="831" Column="18" TopLine="793"/> <Caret Line="139" TopLine="124"/>
</Position21> </Position21>
<Position22> <Position22>
<Filename Value="..\foobot_utility.pas"/> <Filename Value="..\foobot_utility.pas"/>
<Caret Line="637" Column="41" TopLine="604"/> <Caret Line="151" Column="82" TopLine="123"/>
</Position22> </Position22>
<Position23> <Position23>
<Filename Value="..\foobot_utility.pas"/> <Filename Value="..\foobot_utility.pas"/>
<Caret Line="127" Column="45" TopLine="88"/> <Caret Line="181" Column="81" TopLine="140"/>
</Position23> </Position23>
<Position24> <Position24>
<Filename Value="..\foobot_utility.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="639" Column="30" TopLine="606"/> <Caret Line="12" Column="24"/>
</Position24> </Position24>
<Position25> <Position25>
<Filename Value="..\foobot_utility.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="640" Column="9" TopLine="606"/> <Caret Line="630" Column="16" TopLine="613"/>
</Position25> </Position25>
<Position26> <Position26>
<Filename Value="..\foobot_utility.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="86" TopLine="59"/> <Caret Line="634" Column="46" TopLine="606"/>
</Position26> </Position26>
<Position27> <Position27>
<Filename Value="umainform.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="831" Column="40" TopLine="800"/> <Caret Line="2" Column="59"/>
</Position27> </Position27>
<Position28> <Position28>
<Filename Value="..\foobot_utility.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="666" Column="41" TopLine="612"/> <Caret Line="364" Column="58" TopLine="317"/>
</Position28> </Position28>
<Position29> <Position29>
<Filename Value="..\foobot_utility.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="500" Column="13" TopLine="461"/> <Caret Line="633" Column="48" TopLine="586"/>
</Position29> </Position29>
<Position30> <Position30>
<Filename Value="..\foobot_utility.pas"/> <Filename Value="umainform.pas"/>
<Caret Line="364" Column="14" TopLine="337"/> <Caret Line="824" Column="48" TopLine="777"/>
</Position30> </Position30>
</JumpHistory> </JumpHistory>
</ProjectSession> </ProjectSession>

View File

@ -494,7 +494,6 @@ object mainform: Tmainform
end end
object mnu_optionsFoobotTriggers: TMenuItem object mnu_optionsFoobotTriggers: TMenuItem
Caption = 'Foobot Triggers...' Caption = 'Foobot Triggers...'
OnClick = mnu_optionsFoobotTriggersClick
object mnu_options_triggersSetTriggers: TMenuItem object mnu_options_triggersSetTriggers: TMenuItem
Caption = 'Set Trigger Values...' Caption = 'Set Trigger Values...'
OnClick = mnu_options_triggersSetTriggersClick OnClick = mnu_options_triggersSetTriggersClick
@ -516,6 +515,10 @@ object mainform: Tmainform
Caption = 'Online Help' Caption = 'Online Help'
OnClick = mnu_optionsOnlineHelpClick OnClick = mnu_optionsOnlineHelpClick
end end
object mnu_helpFoobotAPIPage: TMenuItem
Caption = 'Foobot API page'
OnClick = mnu_helpFoobotAPIPageClick
end
object mnu_helpAbout: TMenuItem object mnu_helpAbout: TMenuItem
Caption = 'A&bout..' Caption = 'A&bout..'
OnClick = mnu_helpAboutClick OnClick = mnu_helpAboutClick

View File

@ -27,7 +27,7 @@ V0.0.3.0: Added Help menu. Updated Options menu
V0.0.4.0: Graph added V0.0.4.0: Graph added
V0.1.0.0: Save/Load Alltime High/Lows. Reset values from menu 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.1.0: Save/Load Colours, Min and Max values to cfg file
V0.1.2.0: ?? V0.2.1.0: Triggers,Multiple Foobots
} }
{$ifopt D+} {$ifopt D+}
// Debug mode does not load data from web // Debug mode does not load data from web
@ -37,10 +37,10 @@ V0.1.2.0: ??
interface interface
uses uses // If Lazarus auto-inserts 'sensors' in the clause then delete it
SysUtils, TAGraph, TAIntervalSources, TASeries, foobot_sensors, SysUtils, TAGraph, TAIntervalSources, TASeries, foobot_sensors,
Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls, Menus, lclIntf, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls, Menus, lclIntf,
foobot_utility, uCryptIni, dateutils, uconfigform,utriggersform, Classes; foobot_utility, uCryptIni, dateutils, uconfigform, utriggersform, Classes;
const const
// Timer milliseconds // Timer milliseconds
@ -123,6 +123,7 @@ type
lbl_voclow: TLabel; lbl_voclow: TLabel;
lbl_allpollulow: TLabel; lbl_allpollulow: TLabel;
MainMenu1: TMainMenu; MainMenu1: TMainMenu;
mnu_helpFoobotAPIPage: TMenuItem;
mnu_options_triggersActivateTriggers: TMenuItem; mnu_options_triggersActivateTriggers: TMenuItem;
mnu_options_triggersSetTriggers: TMenuItem; mnu_options_triggersSetTriggers: TMenuItem;
mnu_optionsFoobotTriggers: TMenuItem; mnu_optionsFoobotTriggers: TMenuItem;
@ -162,6 +163,7 @@ type
procedure mnupopup_fileRestoreClick(Sender: TObject); procedure mnupopup_fileRestoreClick(Sender: TObject);
procedure mnu_fileExitClick(Sender: TObject); procedure mnu_fileExitClick(Sender: TObject);
procedure mnu_helpAboutClick(Sender: TObject); procedure mnu_helpAboutClick(Sender: TObject);
procedure mnu_helpFoobotAPIPageClick(Sender: TObject);
procedure mnu_optionsDisplayGuagesOnlyClick(Sender: TObject); procedure mnu_optionsDisplayGuagesOnlyClick(Sender: TObject);
procedure mnu_optionsDisplayRedLinesClick(Sender: TObject); procedure mnu_optionsDisplayRedLinesClick(Sender: TObject);
procedure mnu_optionsDisplayYellowLinesClick(Sender: TObject); procedure mnu_optionsDisplayYellowLinesClick(Sender: TObject);
@ -169,7 +171,6 @@ type
procedure mnu_optionsOnlineHelpClick(Sender: TObject); procedure mnu_optionsOnlineHelpClick(Sender: TObject);
procedure mnu_optionsResetHighsLowsClick(Sender: TObject); procedure mnu_optionsResetHighsLowsClick(Sender: TObject);
procedure mnu_optionsSaveHighLowsClick(Sender: TObject); procedure mnu_optionsSaveHighLowsClick(Sender: TObject);
procedure mnu_optionsFoobotTriggersClick(Sender: TObject);
procedure mnu_optionsTakeReadingNowClick(Sender: TObject); procedure mnu_optionsTakeReadingNowClick(Sender: TObject);
procedure mnu_options_triggersActivateTriggersClick(Sender: TObject); procedure mnu_options_triggersActivateTriggersClick(Sender: TObject);
procedure mnu_options_triggersSetTriggersClick(Sender: TObject); procedure mnu_options_triggersSetTriggersClick(Sender: TObject);
@ -246,7 +247,9 @@ begin
TrayIcon1.Hint := Application.Title; TrayIcon1.Hint := Application.Title;
DateTimeIntervalChartSource1.DateTimeFormat := 'hh:nn'; DateTimeIntervalChartSource1.DateTimeFormat := 'hh:nn';
LoadConfig; LoadConfig;
{$IFDEF DEBUGMODE}UseTriggers:=FALSE;{$ENDIF} {$IFDEF DEBUGMODE}
UseTriggers := False;
{$ENDIF}
end; end;
procedure Tmainform.FormActivate(Sender: TObject); procedure Tmainform.FormActivate(Sender: TObject);
@ -293,6 +296,8 @@ begin
// Everything OK - lets go! // Everything OK - lets go!
iCurrentFoobot := 0; iCurrentFoobot := 0;
PopulateFoobotMenu; PopulateFoobotMenu;
LoadTriggers; // This can only be done if we have a Foobot Identity
// as each Foobot has its own trigger values
Show; Show;
grp_sensorDisplay.Refresh; grp_sensorDisplay.Refresh;
grp_highlow.Refresh; grp_highlow.Refresh;
@ -336,17 +341,18 @@ begin
end; end;
procedure Tmainform.ChangeCurrentFoobot(Sender: TObject); procedure Tmainform.ChangeCurrentFoobot(Sender: TObject);
// Called from 'Foobot' TSubmenuitem.click
begin begin
iCurrentFoobot := (Sender as TMenuItem).Tag; iCurrentFoobot := (Sender as TMenuItem).Tag;
mnu_optionsTakeReadingNow.Click; mnu_optionsTakeReadingNow.Click;
end; end;
procedure Tmainform.PopulateFoobotMenu; procedure Tmainform.PopulateFoobotMenu;
// uses foobotmenuarray // Uses dynamic foobotmenuarray
var var
iCount: integer; iCount: integer;
begin begin
if FoobotIdentityObject.FoobotIdentityList.Count = 0 then if (FoobotIdentityObject.FoobotIdentityList.Count = 0) then
Exit; Exit;
SetLength(foobotmenuarray, FoobotIdentityObject.FoobotIdentityList.Count); SetLength(foobotmenuarray, FoobotIdentityObject.FoobotIdentityList.Count);
for iCount := 0 to Pred(FoobotIdentityObject.FoobotIdentityList.Count) do for iCount := 0 to Pred(FoobotIdentityObject.FoobotIdentityList.Count) do
@ -368,7 +374,9 @@ end;
procedure Tmainform.FormClose(Sender: TObject; var CloseAction: TCloseAction); procedure Tmainform.FormClose(Sender: TObject; var CloseAction: TCloseAction);
begin begin
SaveConfig; SaveConfig; // to .cfg file
if (FoobotIdentityObject.FoobotIdentityList.Count > 0) then
SaveTriggers;
CloseAction := caFree; CloseAction := caFree;
end; end;
@ -379,6 +387,7 @@ begin
end; end;
procedure Tmainform.SaveConfig; procedure Tmainform.SaveConfig;
// For all Foobots
begin begin
INI.PlainTextMode := True; INI.PlainTextMode := True;
// Colours // Colours
@ -408,6 +417,7 @@ begin
end; end;
procedure Tmainform.LoadConfig; procedure Tmainform.LoadConfig;
// For all Foobots
begin begin
INI.PlainTextMode := True; INI.PlainTextMode := True;
// Colours // Colours
@ -482,6 +492,11 @@ begin
mtInformation, [mbOK], 0); mtInformation, [mbOK], 0);
end; end;
procedure Tmainform.mnu_helpFoobotAPIPageClick(Sender: TObject);
begin
OpenURL('http://api.foobot.io/apidoc/index.html');
end;
procedure Tmainform.mnu_optionsDisplayGuagesOnlyClick(Sender: TObject); procedure Tmainform.mnu_optionsDisplayGuagesOnlyClick(Sender: TObject);
begin begin
bDisplayGuagesOnly := mnu_optionsDisplayGuagesOnly.Checked; bDisplayGuagesOnly := mnu_optionsDisplayGuagesOnly.Checked;
@ -534,10 +549,6 @@ begin
INI.WriteBool('Foobot', 'SaveLoadHighLows', SaveLoadHighLows); INI.WriteBool('Foobot', 'SaveLoadHighLows', SaveLoadHighLows);
end; end;
procedure Tmainform.mnu_optionsFoobotTriggersClick(Sender: TObject);
begin
end;
procedure Tmainform.mnu_optionsTakeReadingNowClick(Sender: TObject); procedure Tmainform.mnu_optionsTakeReadingNowClick(Sender: TObject);
begin begin
mainform.Cursor := crHourGlass; mainform.Cursor := crHourGlass;
@ -550,21 +561,22 @@ end;
procedure Tmainform.mnu_options_triggersActivateTriggersClick(Sender: TObject); procedure Tmainform.mnu_options_triggersActivateTriggersClick(Sender: TObject);
begin begin
mnu_options_triggersActivateTriggers.Checked:= NOT mnu_options_triggersActivateTriggers.Checked; mnu_options_triggersActivateTriggers.Checked :=
UseTriggers:=mnu_options_triggersActivateTriggers.Checked; not mnu_options_triggersActivateTriggers.Checked;
If UseTriggers then UseTriggers := mnu_options_triggersActivateTriggers.Checked;
mnu_options_triggersActivateTriggers.Caption:='Set Triggers Off' if UseTriggers then
mnu_options_triggersActivateTriggers.Caption := 'Set Triggers Off'
else else
mnu_options_triggersActivateTriggers.Caption:='Set Triggers On'; mnu_options_triggersActivateTriggers.Caption := 'Set Triggers On';
end; end;
procedure Tmainform.mnu_options_triggersSetTriggersClick(Sender: TObject); procedure Tmainform.mnu_options_triggersSetTriggersClick(Sender: TObject);
begin begin
triggersform.ShowModal; triggersform.ShowModal;
If triggersform.ModalResult = mrCancel then if triggersform.ModalResult = mrCancel then
ShowMessage('Cancel') ShowMessage('Cancel')
else else
mnu_options_triggersActivateTriggers.Enabled:=TRUE; mnu_options_triggersActivateTriggers.Enabled := True;
end; end;
procedure Tmainform.mnu_SampleEveryHalfHourClick(Sender: TObject); procedure Tmainform.mnu_SampleEveryHalfHourClick(Sender: TObject);
@ -613,7 +625,11 @@ end;
procedure Tmainform.tmr_foobotTimer(Sender: TObject); procedure Tmainform.tmr_foobotTimer(Sender: TObject);
begin begin
if FetchFoobotData(dfLast, iCurrentFoobot, 0, 0, 0, 0, sSecretKey) then if FetchFoobotData(dfLast, iCurrentFoobot, 0, 0, 0, 0, sSecretKey) then
DisplayReadings; DisplayReadings
else
mainform.Caption := Format('Foobot "%s" - Read failure on %s',
[FoobotIdentityObject.FoobotIdentityList[iCurrentFoobot].Name,
FormatDateTime('dd/mm/yyyy - tt', Now)]);
end; end;
procedure Tmainform.TrayIcon1Click(Sender: TObject); procedure Tmainform.TrayIcon1Click(Sender: TObject);
@ -746,6 +762,8 @@ begin
FoobotDataObject.Units[SensorNumber]]) + LineEnding + 'on ' + FoobotDataObject.Units[SensorNumber]]) + LineEnding + 'on ' +
FormatDateTime('dd/mm tt', TDateTime(FoobotDataLowTimes[SensorNumber])); FormatDateTime('dd/mm tt', TDateTime(FoobotDataLowTimes[SensorNumber]));
end; end;
else
Exception.Create('Error in UpdateHighLow Case statement');
end; end;
end; end;
@ -802,7 +820,7 @@ begin
if FoobotDataObjectToArrays = True then if FoobotDataObjectToArrays = True then
begin begin
mainform.Caption := Format('Foobot "%s" - Last reading: ', mainform.Caption := Format('Foobot "%s" - Last reading: ',
[FoobotIdentityObject.FoobotIdentityList[0].Name]) + [FoobotIdentityObject.FoobotIdentityList[iCurrentFoobot].Name]) +
FormatDateTime('dd/mm/yyyy - tt', FoobotData_time[0]); FormatDateTime('dd/mm/yyyy - tt', FoobotData_time[0]);
UpdateGuage(as_pm, C_PM); UpdateGuage(as_pm, C_PM);
UpdateGuage(as_tmp, C_TMP); UpdateGuage(as_tmp, C_TMP);
@ -817,46 +835,62 @@ begin
end; end;
GraphCurrentReading; GraphCurrentReading;
// Process Trigger Alerts // Process Trigger Alerts on each call to FoobotDataObjectToArrays
If UseTriggers then if UseTriggers then
For iCount:=C_PM to C_ALLPOLLU do try
If AlertRec[iCount].AlertTriggered then // Look for alerts in each sensor
If AlertRec[iCount].AlertType = at_high then for iCount := C_PM to C_ALLPOLLU do
begin if AlertRec[iCount].AlertTriggered then
ShowMessageFmt('High alert member %d (value %f) exceeded', // Alert found. High or low?
[iCount,Double(AlertRec[iCount].AlertValue)]); if AlertRec[iCount].AlertType = at_high then
end begin
else // A high alert - do something
begin ShowMessageFmt('High alert member %d (value %f) exceeded',
ShowMessageFmt('Low alert member %d (value %f) exceeded', [iCount, double(AlertRec[iCount].AlertValue)]);
[iCount,Double(AlertRec[iCount].AlertValue)]); end
end; else
end; begin
// A low alert - do something
ShowMessageFmt('Low alert member %d (value %f) exceeded',
[iCount, double(AlertRec[iCount].AlertValue)]);
end;
except
raise Exception.Create('Unable to process triggers in DisplayReadings');
end;
end
else
raise Exception.Create('FoobotDataObjectToArrays error in DisplayReadings');
end; end;
function AsPercent(aValue, aMin, aMax: double): double; function AsPercent(aValue, aMin, aMax: double): double;
begin begin
if aMax > 0 then if aMax > 0 then
Result := aValue / (aMax - aMin) * 100 Result := (aValue / (aMax - aMin) * 100)
else else
Result := 0; Result := 0;
end; end;
procedure Tmainform.GraphCurrentReading; procedure Tmainform.GraphCurrentReading;
begin begin
{$IFDEF DEBUGMODE}Exit;{$ENDIF} {$IFDEF DEBUGMODE}
lineseries_pm.AddXY(FoobotData_time[0], Exit;
AsPercent(FoobotData_pm[0], as_pm.ValueMin, as_pm.ValueMax)); {$ENDIF}
lineseries_tmp.AddXY(FoobotData_time[0], AsPercent(FoobotData_tmp[0], try
as_tmp.ValueMin, as_tmp.ValueMax)); lineseries_pm.AddXY(FoobotData_time[0],
lineseries_hum.AddXY(FoobotData_time[0], AsPercent(FoobotData_pm[0], as_pm.ValueMin, as_pm.ValueMax));
AsPercent(FoobotData_hum[0], as_hum.ValueMin, as_hum.ValueMax)); lineseries_tmp.AddXY(FoobotData_time[0], AsPercent(FoobotData_tmp[0],
lineseries_co2.AddXY(FoobotData_time[0], as_tmp.ValueMin, as_tmp.ValueMax));
AsPercent(FoobotData_co2[0], as_co2.ValueMin, as_co2.ValueMax)); lineseries_hum.AddXY(FoobotData_time[0],
lineseries_voc.AddXY(FoobotData_time[0], AsPercent(FoobotData_hum[0], as_hum.ValueMin, as_hum.ValueMax));
AsPercent(FoobotData_voc[0], as_voc.ValueMin, as_voc.ValueMax)); lineseries_co2.AddXY(FoobotData_time[0],
lineseries_allpollu.AddXY(FoobotData_time[0], AsPercent(FoobotData_co2[0], as_co2.ValueMin, as_co2.ValueMax));
AsPercent(FoobotData_allpollu[0], as_allpollu.ValueMin, as_allpollu.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.ValueMin, as_allpollu.ValueMax));
except
raise Exception.Create('Unable to update graph in GraphCurrentReading');
end;
end; end;
procedure Tmainform.GraphHistory; procedure Tmainform.GraphHistory;
@ -866,32 +900,37 @@ var
iCount: integer; iCount: integer;
iStartSeconds, iEndSeconds: int64; iStartSeconds, iEndSeconds: int64;
begin begin
{$IFDEF DEBUGMODE}Exit;{$ENDIF} {$IFDEF DEBUGMODE}
Exit;
{$ENDIF}
iEndSeconds := DateTimeToUnix(Now) - 3600; iEndSeconds := DateTimeToUnix(Now) - 3600;
iStartSeconds := iEndSeconds - (2 * (24 * 3600)); // 49 hours before Now iStartSeconds := iEndSeconds - (2 * (24 * 3600)); // 49 hours before Now
grp_chart.Caption := Format('History from %s', grp_chart.Caption := Format('History since %s',
[FormatDateTime('dd/mm/yyyy hh:nn', UnixToDateTime(iStartSeconds))]); [FormatDateTime('dd/mm/yyyy hh:nn', UnixToDateTime(iStartSeconds))]);
if FetchFoobotData(dfStartEnd, iCurrentFoobot, 0, 3600, iStartSeconds, if FetchFoobotData(dfStartEnd, iCurrentFoobot, 0, 3600, iStartSeconds,
iEndSeconds, sSecretKey) = False then iEndSeconds, sSecretKey) = False then
exit; exit;
if FoobotDataObjectToArrays then try
for iCount := 0 to Pred(High(FoobotData_time)) do if FoobotDataObjectToArrays then
begin for iCount := 0 to Pred(High(FoobotData_time)) do
lineseries_pm.AddXY(FoobotData_time[iCount], begin
AsPercent(FoobotData_pm[iCount], as_pm.ValueMin, as_pm.ValueMax)); lineseries_pm.AddXY(FoobotData_time[iCount],
lineseries_tmp.AddXY(FoobotData_time[iCount], AsPercent(FoobotData_pm[iCount], as_pm.ValueMin, as_pm.ValueMax));
AsPercent(FoobotData_tmp[iCount], as_tmp.ValueMin, as_tmp.ValueMax)); lineseries_tmp.AddXY(FoobotData_time[iCount],
lineseries_hum.AddXY(FoobotData_time[iCount], AsPercent(FoobotData_tmp[iCount], as_tmp.ValueMin, as_tmp.ValueMax));
AsPercent(FoobotData_hum[iCount], as_hum.ValueMin, as_hum.ValueMax)); lineseries_hum.AddXY(FoobotData_time[iCount],
lineseries_co2.AddXY(FoobotData_time[iCount], AsPercent(FoobotData_hum[iCount], as_hum.ValueMin, as_hum.ValueMax));
AsPercent(FoobotData_co2[iCount], as_co2.ValueMin, as_co2.ValueMax)); lineseries_co2.AddXY(FoobotData_time[iCount],
lineseries_voc.AddXY(FoobotData_time[iCount], AsPercent(FoobotData_co2[iCount], as_co2.ValueMin, as_co2.ValueMax));
AsPercent(FoobotData_voc[iCount], as_voc.ValueMin, as_voc.ValueMax)); lineseries_voc.AddXY(FoobotData_time[iCount],
lineseries_allpollu.AddXY(FoobotData_time[iCount], AsPercent(FoobotData_voc[iCount], as_voc.ValueMin, as_voc.ValueMax));
AsPercent(FoobotData_allpollu[iCount], as_allpollu.ValueMin, lineseries_allpollu.AddXY(FoobotData_time[iCount],
as_allpollu.ValueMax)); AsPercent(FoobotData_allpollu[iCount], as_allpollu.ValueMin,
end; as_allpollu.ValueMax));
ResetArrays; // at end end;
finally
ResetArrays; // at end
end;
end; end;
end. end.

View File

@ -1,7 +1,7 @@
object triggersform: Ttriggersform object triggersform: Ttriggersform
Left = 546 Left = 686
Height = 484 Height = 484
Top = 142 Top = 279
Width = 794 Width = 794
BorderIcons = [biSystemMenu] BorderIcons = [biSystemMenu]
BorderStyle = bsSingle BorderStyle = bsSingle
@ -17,12 +17,71 @@ object triggersform: Ttriggersform
Scaled = True Scaled = True
object grp_main: TGroupBox object grp_main: TGroupBox
Left = 0 Left = 0
Height = 424 Height = 428
Top = 0 Top = 0
Width = 794 Width = 794
Align = alTop Align = alTop
Caption = 'Foobot Triggers' AutoSize = True
Caption = 'All Foobot Triggers'
ChildSizing.EnlargeVertical = crsScaleChilds
ChildSizing.ControlsPerLine = 1
ClientHeight = 408
ClientWidth = 790
TabOrder = 0 TabOrder = 0
object grp_pm: TGroupBox
Left = 0
Height = 68
Top = 0
Width = 790
Align = alTop
Caption = 'Particulates'
TabOrder = 0
end
object grp_tmp: TGroupBox
Left = 0
Height = 68
Top = 340
Width = 790
Align = alTop
Caption = 'All Pollution'
TabOrder = 1
end
object grp_hum: TGroupBox
Left = 0
Height = 68
Top = 272
Width = 790
Align = alTop
Caption = 'Volatile Componds'
TabOrder = 2
end
object grp_co2: TGroupBox
Left = 0
Height = 68
Top = 204
Width = 790
Align = alTop
Caption = 'Carbon Diaoxide'
TabOrder = 3
end
object grp_voc: TGroupBox
Left = 0
Height = 68
Top = 136
Width = 790
Align = alTop
Caption = 'Humidity'
TabOrder = 4
end
object grp_allpollu: TGroupBox
Left = 0
Height = 68
Top = 68
Width = 790
Align = alTop
Caption = 'Temperature'
TabOrder = 5
end
end end
object cmd_OK: TBitBtn object cmd_OK: TBitBtn
Left = 360 Left = 360

View File

@ -15,6 +15,12 @@ type
Ttriggersform = class(TForm) Ttriggersform = class(TForm)
cmd_cancel: TBitBtn; cmd_cancel: TBitBtn;
cmd_OK: TBitBtn; cmd_OK: TBitBtn;
grp_pm: TGroupBox;
grp_tmp: TGroupBox;
grp_hum: TGroupBox;
grp_co2: TGroupBox;
grp_voc: TGroupBox;
grp_allpollu: TGroupBox;
grp_main: TGroupBox; grp_main: TGroupBox;
procedure FormCreate(Sender: TObject); procedure FormCreate(Sender: TObject);
private private