Difference between revisions of "LongTimer"

From Free Pascal wiki
Jump to navigationJump to search
m (Minor additions)
m (Fixed syntax highlighting)
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
==TLongTimer - a visual component==
+
=Summary=
===Summary===
 
 
*TLongTimer is a descendant of TIdleTimer, and keeps all of its properties and methods except the Interval property
 
*TLongTimer is a descendant of TIdleTimer, and keeps all of its properties and methods except the Interval property
 
*The interval has been changed into a set of additional properties, that allow for very long intervals - Daily, Weekly and Monthly
 
*The interval has been changed into a set of additional properties, that allow for very long intervals - Daily, Weekly and Monthly
 
*The intended use is for TrayIcon applications or services like alarms, updaters or notifiers
 
*The intended use is for TrayIcon applications or services like alarms, updaters or notifiers
 
[[File:sc_longtimer.png]]
 
[[File:sc_longtimer.png]]
===Download===
+
=Download=
Download from the lazarus CCR [https://sourceforge.net/p/lazarus-ccr/svn/HEAD/tree/components/ here]
+
Download from the [https://sourceforge.net/p/lazarus-ccr/svn/HEAD/tree/components/longtimer/ Lazarus CCR here]
===Installation===
+
=Installation=
 
*Download the 'longtimer' package from the Lazarus CCR repository and copy the folder to a folder off your lazarus components folder
 
*Download the 'longtimer' package from the Lazarus CCR repository and copy the folder to a folder off your lazarus components folder
 
*Install the package (open it, Compile then Install it) and TLongTimer will appear on your 'System' components tab
 
*Install the package (open it, Compile then Install it) and TLongTimer will appear on your 'System' components tab
 
*Drop onto a form, set properties and you are good to go
 
*Drop onto a form, set properties and you are good to go
 
*Opening the demo application will give you a good idea how to set the additional properties and use the component
 
*Opening the demo application will give you a good idea how to set the additional properties and use the component
===Version===
+
=License=
*As reported in the IDE.  Initial version is 0.0.1
 
===License===
 
 
*LGPLv2
 
*LGPLv2
===Support===
+
=Support=
 
*minesadorada on the Freepascal.org forum
 
*minesadorada on the Freepascal.org forum
 
*Updates will go to the CCR repository when available
 
*Updates will go to the CCR repository when available
===Tips===
+
=Tips=
 
*Initially, AutoEnabled=False, so TLongTimer will act much as a regular timer
 
*Initially, AutoEnabled=False, so TLongTimer will act much as a regular timer
 
*The enumerated properties IntervalType, SampleInterval and WeeklyDay are displayed in the 'correct' order, and you can set them via code by TypeCasting if you don't want to use the lt type literals.
 
*The enumerated properties IntervalType, SampleInterval and WeeklyDay are displayed in the 'correct' order, and you can set them via code by TypeCasting if you don't want to use the lt type literals.
  
 
eg.
 
eg.
<syntaxhighlight>
+
<syntaxhighlight lang=pascal>
 
LongTimer1.WeeklyDay:=TDay(1); // sets the Weekly Day to Tuesday (2nd in the list)
 
LongTimer1.WeeklyDay:=TDay(1); // sets the Weekly Day to Tuesday (2nd in the list)
 
LongTimer1.SampleInterval:=TSampleInterval(1); // sets the interval sample rate to every 5 minutes (2nd in the list)
 
LongTimer1.SampleInterval:=TSampleInterval(1); // sets the interval sample rate to every 5 minutes (2nd in the list)
Line 30: Line 27:
 
</syntaxhighlight>
 
</syntaxhighlight>
 
- this is exactly equivalent to:
 
- this is exactly equivalent to:
<syntaxhighlight>
+
<syntaxhighlight lang=pascal>
 
LongTimer1.WeeklyDay:=lt2Tuesday�; // sets the Weekly Day to Tuesday
 
LongTimer1.WeeklyDay:=lt2Tuesday�; // sets the Weekly Day to Tuesday
 
LongTimer1.SampleInterval:=lt2Every5minutes�; // sets the interval sample rate to every 5 minutes
 
LongTimer1.SampleInterval:=lt2Every5minutes�; // sets the interval sample rate to every 5 minutes
Line 46: Line 43:
  
 
[[File:sc_longtimerdemo.png]]
 
[[File:sc_longtimerdemo.png]]
<br>
+
 
----
+
 
====See Also====
 
* [[Components_and_Code_examples|Components and code examples]]
 
 
[[Category:Components]]
 
[[Category:Components]]
----
+
[[Category:Lazarus-CCR]]
[[User:Minesadorada|Minesadorada]] Sept 2014
 

Latest revision as of 05:47, 19 February 2020

Summary

  • TLongTimer is a descendant of TIdleTimer, and keeps all of its properties and methods except the Interval property
  • The interval has been changed into a set of additional properties, that allow for very long intervals - Daily, Weekly and Monthly
  • The intended use is for TrayIcon applications or services like alarms, updaters or notifiers

sc longtimer.png

Download

Download from the Lazarus CCR here

Installation

  • Download the 'longtimer' package from the Lazarus CCR repository and copy the folder to a folder off your lazarus components folder
  • Install the package (open it, Compile then Install it) and TLongTimer will appear on your 'System' components tab
  • Drop onto a form, set properties and you are good to go
  • Opening the demo application will give you a good idea how to set the additional properties and use the component

License

  • LGPLv2

Support

  • minesadorada on the Freepascal.org forum
  • Updates will go to the CCR repository when available

Tips

  • Initially, AutoEnabled=False, so TLongTimer will act much as a regular timer
  • The enumerated properties IntervalType, SampleInterval and WeeklyDay are displayed in the 'correct' order, and you can set them via code by TypeCasting if you don't want to use the lt type literals.

eg.

LongTimer1.WeeklyDay:=TDay(1); // sets the Weekly Day to Tuesday (2nd in the list)
LongTimer1.SampleInterval:=TSampleInterval(1); // sets the interval sample rate to every 5 minutes (2nd in the list)
LongTimer1.IntervalType:=TIntervalType(1); // sets the interval type to to Weekly (2nd in the list)

- this is exactly equivalent to:

LongTimer1.WeeklyDay:=lt2Tuesday; // sets the Weekly Day to Tuesday
LongTimer1.SampleInterval:=lt2Every5minutes; // sets the interval sample rate to every 5 minutes
LongTimer1.IntervalType:=lt2Weekly; // sets the interval type to to Weekly
  • Every time an interval property is changed, the Timer is temporarily suspended if it is already running
  • Number of days in a month is automatically catered for. If you set the MonthlyDate to 31 for instance, in Sept, Apr Jun, Nov it will fire on day 30, and on the last day of February (according to Leap Year)
  • The SampleInterval property determines the trade-off between CPU use and accuracy. EveryMinute is the most accurate, but checks the time/date etc every minute so uses more CPU than Every45minutes. However, when Sample interval is Every45Minutes,the IntervalType is ltDaily and the time is set to 2pm, the event could fire as late as 2:45 (which may be an acceptable option)
  • If you set AutoEnabled to TRUE then the timer will switch on and off according to Idle status, and could use significant CPU time. Note: This could be desired behaviour if you want to be sure LongTimer won't be working when some time-critical operation in your application is in progress. (This is why TLongTimer was descended from TIdleTimer rather than TTimer)
  • You can change SampleInterval and the Interval properties whilst LongTimer is running and it will update
  • The event OnSample is fired according to SampleInterval property



Demo application for TLongTimer

sc longtimerdemo.png