You've already forked lazarus-ccr
Added OnSample event. V0.0.2
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3530 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
object mainform: Tmainform
|
||||
Left = 1162
|
||||
Left = 1050
|
||||
Height = 264
|
||||
Top = 272
|
||||
Top = 186
|
||||
Width = 437
|
||||
BorderIcons = [biSystemMenu, biMinimize]
|
||||
BorderStyle = bsSingle
|
||||
@ -59,6 +59,7 @@ object mainform: Tmainform
|
||||
ClientHeight = 158
|
||||
ClientWidth = 180
|
||||
TabOrder = 4
|
||||
OnClick = crp_SetTimerClick
|
||||
object Label1: TLabel
|
||||
Left = 16
|
||||
Height = 15
|
||||
@ -146,13 +147,28 @@ object mainform: Tmainform
|
||||
end
|
||||
end
|
||||
object LongTimer1: TLongTimer
|
||||
About.Description.Strings = (
|
||||
'LongTimer is a descendent of TIdleTimer'#13#10'and shares its properties and methods.'#13#10#13#10'Additional properties affect when the'#13#10'OnTimer event is fired.'#13#10#13#10'With LongTimer, the OnTimer event'#13#10'will be fired only ONCE - every time'#13#10'the interval that you set is reached.'
|
||||
)
|
||||
About.Title = 'About TLongTimer Component'
|
||||
About.Height = 380
|
||||
About.Width = 320
|
||||
About.Font.Color = clNavy
|
||||
About.Font.Height = -13
|
||||
About.BackGroundColor = clWindow
|
||||
About.Version = '0.0.1'
|
||||
About.Authorname = 'Gordon Bamber'
|
||||
About.Organisation = 'Public Domain'
|
||||
About.AuthorEmail = 'minesadorada@charcodelvalle.com'
|
||||
About.ComponentName = 'TLongTimer'
|
||||
About.LicenseType = abLGPL
|
||||
Enabled = False
|
||||
OnTimer = LongTimer1Timer
|
||||
OnStartTimer = LongTimer1StartTimer
|
||||
OnStopTimer = LongTimer1StopTimer
|
||||
IntervalType = lt3Monthly
|
||||
Daily24Hour = 10
|
||||
Daily24Hour = 0
|
||||
WeeklyDay = lt3Wednesday
|
||||
OnSample = LongTimer1Sample
|
||||
left = 8
|
||||
top = 8
|
||||
end
|
||||
|
@ -31,7 +31,9 @@ type
|
||||
procedure cmb_Daily24HourChange(Sender: TObject);
|
||||
procedure cmb_IntervalTypeChange(Sender: TObject);
|
||||
procedure cmb_weekordateChange(Sender: TObject);
|
||||
procedure crp_SetTimerClick(Sender: TObject);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure LongTimer1Sample(Sender: TObject);
|
||||
procedure LongTimer1StartTimer(Sender: TObject);
|
||||
procedure LongTimer1StopTimer(Sender: TObject);
|
||||
procedure LongTimer1Timer(Sender: TObject);
|
||||
@ -55,7 +57,7 @@ implementation
|
||||
procedure Tmainform.LongTimer1Timer(Sender: TObject);
|
||||
begin
|
||||
// memo_ReportTimerEvent.Lines.Add('LastFired at ' + FormatDateTime('hh:nn:ss', LongTimer1.LastFired));
|
||||
memo_ReportTimerEvent.Lines.Add('Fired at ' + FormatDateTime('hh:nn:ss', Now));
|
||||
memo_ReportTimerEvent.Lines.Add('Timer fired at ' + FormatDateTime('hh:nn:ss dd-mm-yyyy', Now));
|
||||
end;
|
||||
|
||||
procedure Tmainform.FormCreate(Sender: TObject);
|
||||
@ -81,15 +83,19 @@ begin
|
||||
cmb_SampleInterval.ItemIndex:=2;
|
||||
end;
|
||||
|
||||
procedure Tmainform.LongTimer1Sample(Sender: TObject);
|
||||
begin
|
||||
memo_ReportTimerEvent.Lines.Add('Sampled at ' + FormatDateTime('hh:nn:ss',Now));
|
||||
end;
|
||||
|
||||
procedure Tmainform.LongTimer1StartTimer(Sender: TObject);
|
||||
begin
|
||||
// memo_ReportTimerEvent.Lines.Add('Timer running');
|
||||
Self.Caption:='Timer was started at ' + FormatDateTime('dd/mm/yyyy hh:nn:ss',Now);
|
||||
end;
|
||||
|
||||
procedure Tmainform.LongTimer1StopTimer(Sender: TObject);
|
||||
begin
|
||||
// memo_ReportTimerEvent.Lines.Add('Timer stopped');
|
||||
|
||||
Self.Caption:=Application.Title;
|
||||
end;
|
||||
|
||||
procedure Tmainform.cmd_StopTimerClick(Sender: TObject);
|
||||
@ -114,7 +120,7 @@ procedure Tmainform.cmb_Daily24HourChange(Sender: TObject);
|
||||
begin
|
||||
LongTimer1.Daily24Hour:=cmb_Daily24Hour.ItemIndex;
|
||||
end;
|
||||
procedure Tmainform.PopulateWeekOrDate(Const i:Integer);
|
||||
procedure Tmainform.PopulateWeekOrDate(const i: Integer);
|
||||
// 0=Weekly, 1=Monthly
|
||||
Var iMonthDay:Integer;
|
||||
|
||||
@ -170,5 +176,10 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure Tmainform.crp_SetTimerClick(Sender: TObject);
|
||||
begin
|
||||
|
||||
end;
|
||||
|
||||
end.
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?xml version="1.0"?>
|
||||
<CONFIG>
|
||||
<Package Version="4">
|
||||
<PathDelim Value="\"/>
|
||||
@ -19,8 +19,8 @@
|
||||
</CompilerOptions>
|
||||
<Description Value="TLongTimer is a descendant of TIdleTimer that samples every 30minutes when idle.
|
||||
It is intended for TTrayIcon applications. DailyHour is a 24-hour clock (16 = 4pm) and MonthlyDate is best < 29 "/>
|
||||
<License Value="LGPLv2"/>
|
||||
<Version Release="1"/>
|
||||
<License Value="LGPL"/>
|
||||
<Version Release="2"/>
|
||||
<Files Count="2">
|
||||
<Item1>
|
||||
<Filename Value="ulongtimer.pas"/>
|
||||
@ -35,7 +35,7 @@ It is intended for TTrayIcon applications. DailyHour is a 24-hour clock (16 = 4
|
||||
</Files>
|
||||
<i18n>
|
||||
<EnableI18N Value="True"/>
|
||||
<OutDir Value="lang_longtimer"/>
|
||||
<OutDir Value="locale"/>
|
||||
<EnableI18NForLFM Value="True"/>
|
||||
</i18n>
|
||||
<Type Value="RunAndDesignTime"/>
|
||||
|
@ -44,18 +44,22 @@ type
|
||||
fTday:TDay;
|
||||
fHourDone,fDayDone,fDateDone:Boolean;
|
||||
fSampleInterval:TSampleInterval;
|
||||
fVersion:String;
|
||||
fOnSample:TNotifyEvent;
|
||||
Procedure SetDay(aDay:TDay);
|
||||
Procedure SetDailyHour(aHour:Word);
|
||||
Procedure SetMonthlyDate(ADate:Word);
|
||||
procedure SetSampleInterval(ASampleInterval:TSampleInterval);
|
||||
protected
|
||||
{ Protected declarations }
|
||||
procedure DoOnIdle(Sender: TObject; var Done: Boolean); override;
|
||||
procedure DoOnIdleEnd(Sender: TObject); override;
|
||||
procedure DoOnTimer;override;
|
||||
Procedure SetDay(aDay:TDay);
|
||||
Procedure SetDailyHour(aHour:Word);
|
||||
Procedure SetMonthlyDate(ADate:Word);
|
||||
procedure SetSampleInterval(ASampleInterval:TSampleInterval);
|
||||
public
|
||||
{ Public declarations }
|
||||
constructor Create(TheOwner: TComponent); override;
|
||||
// Until the first Timer event, this will be the component's creation time
|
||||
Property LastFired:TDateTime read fLastFiredDateTime;
|
||||
published
|
||||
{ Published declarations }
|
||||
// Default=false
|
||||
@ -80,10 +84,12 @@ type
|
||||
Property Daily24Hour:Word read fHour write SetDailyHour;
|
||||
// You can also set the Hour as well as the Weekday
|
||||
Property WeeklyDay:TDay read fTDay write SetDay;
|
||||
// You can also set the hour as well as the date
|
||||
// You can also set the Hour as well as the date
|
||||
property MonthlyDate:Word read fDate write SetMonthlyDate default 1;
|
||||
// Until the first Timer event, this will be the component's creation time
|
||||
Property LastFired:TDateTime read fLastFiredDateTime;
|
||||
// Version string of this component
|
||||
property Version:String read fVersion;
|
||||
// Fired every time LongTimer samples
|
||||
Property OnSample:TNotifyEvent read fOnSample write fOnSample;
|
||||
end;
|
||||
|
||||
procedure Register;
|
||||
@ -91,6 +97,12 @@ procedure Register;
|
||||
implementation
|
||||
CONST
|
||||
C_OneMinute = 60000;
|
||||
C_Version='0.0.2';
|
||||
(*
|
||||
V0.0.1: Initial commit
|
||||
V0.0.2: Added OnSample event
|
||||
V0.0.3: ??
|
||||
*)
|
||||
procedure Register;
|
||||
begin
|
||||
RegisterComponents('System',[TLongTimer]);
|
||||
@ -127,10 +139,14 @@ begin
|
||||
fDateDone:=False;
|
||||
fCurrentDateTime:=Now;
|
||||
fLastFiredDateTime:=Now;
|
||||
|
||||
// Set defaults for properties
|
||||
fDate:=1;
|
||||
fSampleInterval:=lt3Every10Minutes;
|
||||
Interval:=10 * C_OneMinute;
|
||||
fIntervalType:=lt1Daily;
|
||||
|
||||
fVersion:=C_Version;
|
||||
end;
|
||||
procedure TLongTimer.DoOnIdle(Sender: TObject; var Done: Boolean);
|
||||
begin
|
||||
@ -155,6 +171,7 @@ begin
|
||||
DecodeTime(fCurrentDateTime,cH,cMi,cS,cmS);
|
||||
cDay:=DayOfTheMonth(fCurrentDateTime);
|
||||
|
||||
// Split LastFired date into parts
|
||||
DecodeDate(fLastFiredDateTime,lY,lM,lD);
|
||||
DecodeTime(fLastFiredDateTime,lH,lMi,lS,lmS);
|
||||
lDay:=DayOfTheMonth(fLastFiredDateTime);
|
||||
@ -177,6 +194,8 @@ begin
|
||||
fHourDone:=FALSE;
|
||||
end;
|
||||
|
||||
// Fire the OnSample event?
|
||||
If Assigned(fOnSample) then fOnSample(Self);
|
||||
|
||||
// Only proceed further at specified interval in specified hour - else exit
|
||||
If (fIntervalType = lt1Daily) and ((fHourDone = TRUE) OR (cH <> fHour)) then Exit;
|
||||
@ -224,6 +243,7 @@ begin
|
||||
fHourDone := TRUE;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TLongTimer.SetSampleInterval(ASampleInterval:TSampleInterval);
|
||||
Var TimerEnabled:Boolean;
|
||||
Begin
|
||||
@ -262,6 +282,7 @@ begin
|
||||
DaySunday = 7;
|
||||
}
|
||||
end;
|
||||
|
||||
Procedure TLongTimer.SetDailyHour(aHour:Word);
|
||||
Var TimerEnabled:Boolean;
|
||||
begin
|
||||
|
Reference in New Issue
Block a user