-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathTargetForm.pas
97 lines (82 loc) · 2.39 KB
/
TargetForm.pas
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
unit TargetForm;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Graphics, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.StdCtrls,
Base, FMX.Controls.Presentation, Miscellaneous, Source;
type
TPositions = record
Position: THABPosition;
Changed: Boolean;
end;
type
TfrmTarget = class(TfrmBase)
tmrUpdates: TTimer;
procedure tmrUpdatesTimer(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
protected
SelectedIndex: Integer;
Positions: Array[0..3] of TPositions;
function ProcessNewPosition(Index: Integer): Boolean; virtual;
procedure ProcessNewDirection(Index: Integer); virtual;
public
{ Public declarations }
procedure UpdatePayloadID(Index: Integer; PayloadID: String); virtual;
procedure NewSelection(Index: Integer); virtual;
procedure NewPosition(Index: Integer; Position: THABPosition); virtual;
end;
implementation
{$R *.fmx}
procedure TfrmTarget.FormCreate(Sender: TObject);
begin
SelectedIndex := 1;
end;
procedure TfrmTarget.NewPosition(Index: Integer; Position: THABPosition);
begin
// virtual
Positions[Index].Position := Position;
Positions[Index].Changed := True;
end;
procedure TfrmTarget.NewSelection(Index: Integer);
begin
// virtual
SelectedIndex := Index;
if Positions[0].Position.InUse and Positions[SelectedIndex].Position.InUse then begin
ProcessNewDirection(SelectedIndex);
end;
end;
procedure TfrmTarget.tmrUpdatesTimer(Sender: TObject);
var
Index: Integer;
begin
if SelectedIndex > 0 then begin
if Positions[0].Position.InUse and Positions[SelectedIndex].Position.InUse then begin
if Positions[0].Changed or Positions[SelectedIndex].Changed then begin
ProcessNewDirection(SelectedIndex);
end;
end;
end;
for Index := 0 to 3 do begin
if Positions[Index].Changed then begin
if ProcessNewPosition(Index) then begin
Positions[Index].Changed := False;
end;
end;
end;
end;
function TfrmTarget.ProcessNewPosition(Index: Integer): Boolean;
begin
// virtual
Result := True;
end;
procedure TfrmTarget.ProcessNewDirection(Index: Integer);
begin
// virtual
end;
procedure TfrmTarget.UpdatePayloadID(Index: Integer; PayloadID: String);
begin
// virtual
end;
end.