-
Notifications
You must be signed in to change notification settings - Fork 0
/
usage-example.txt
34 lines (28 loc) · 1.19 KB
/
usage-example.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
Usage of TMessageGenerator in TInterruptInput = class(TCustomGPIOPort)
TCustomGPIOPort is not declared, yet. It will be a component class, that will
contain most of what a GPIO port provides, so that a modified TGPIOPort class
(see package "raspi") will publish, what it needs, and a TInterruptInput will
extend a binary Input with edge detection by using a TMessageGenerator thread.
Because all TInterruptInput instances can use the same thread, only the first
has to create one for all. This can be done with a class variable that is equal
in all instances. See the following code sketch in addition.
type
TBinaryInput = class(TCustomGPIOPort)
published
property Value;
end;
TInterruptInput = class(TBinaryInput, IMessageReceiver)
private
class var MessageGenerator: TMessageGenerator;
private {This section is only used by MessageGenerator to send messages to the
current TInterruptInput instance}
PriorValue: Boolean;
procedure GenerateEvents;
private
...
procedure SetEdges(AValue: TEdges); {connects to MessageGenerator, if
Value <> [] oder disconnects, if Value = []}
published
property Edges: TEdges read FEdges write SetEdges;
property OnEdge: TNotifyEvent read ... write ...;
end;