source: trunk/Packages/Common/UDelay.pas

Last change on this file was 4, checked in by chronos, 9 years ago
  • Modified: Show drive size and I/O speed with proper units.
File size: 1.3 KB
Line 
1unit UDelay;
2
3{$mode delphi}
4
5interface
6
7uses
8 Classes, SysUtils, DateUtils;
9
10type
11 { TDelay }
12
13 TDelay = class
14 private
15 FEnabled: Boolean;
16 function GetEnabled:Boolean;
17 function GetOwerflowed:Boolean;
18 function GetRunning: Boolean;
19 procedure SetEnabled(const AValue: Boolean);
20 public
21 StartTime: TDateTime;
22 Duration: Integer; // ms
23 procedure Start;
24 procedure Stop;
25 constructor Create;
26 property Overflowed: Boolean read GetOwerflowed;
27 property Running: Boolean read GetRunning;
28 property Enabled: Boolean read GetEnabled write SetEnabled;
29 end;
30
31
32implementation
33
34{ TDelay }
35
36function TDelay.GetEnabled: Boolean;
37begin
38 Result := FEnabled;
39end;
40
41function TDelay.GetOwerflowed: Boolean;
42begin
43 Result := ((Now - StartTime) > (Duration * OneMillisecond)) and FEnabled;
44end;
45
46function TDelay.GetRunning: Boolean;
47begin
48 Result := ((Now - StartTime) <= (Duration * OneMillisecond)) and FEnabled;
49end;
50
51procedure TDelay.SetEnabled(const AValue:Boolean);
52begin
53 FEnabled := True;
54end;
55
56procedure TDelay.Start;
57begin
58 StartTime := Now;
59 FEnabled := True;
60end;
61
62procedure TDelay.Stop;
63begin
64 FEnabled := False;
65end;
66
67constructor TDelay.Create;
68begin
69 Duration := 1000;
70 StartTime := 0;
71 FEnabled := False;
72end;
73
74end.
75
Note: See TracBrowser for help on using the repository browser.