forked from VE3NEA/MorseRunner
-
Notifications
You must be signed in to change notification settings - Fork 12
/
DualExchContest.pas
95 lines (78 loc) · 2.97 KB
/
DualExchContest.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
//------------------------------------------------------------------------------
//This Source Code Form is subject to the terms of the Mozilla Public
//License, v. 2.0. If a copy of the MPL was not distributed with this
//file, You can obtain one at http://mozilla.org/MPL/2.0/.
//------------------------------------------------------------------------------
unit DualExchContest;
interface
uses
ExchFields,
Contest, Station, Ini;
type
TDualExchContest = class(TContest)
private
protected
HomeCallIsLocal: boolean; // user's callsign is local to this contest
LocalTypes: TExchTypes; // used when station is local-to-contest
DxTypes: TExchTypes; // used when station is dx-to-contest
constructor Create(
ALocalType1 : TExchange1Type;
ALocalType2 : TExchange2Type;
ADxType1 : TExchange1Type;
ADxType2 : TExchange2Type);
public
function GetExchangeTypes(
const AStationKind : TStationKind;
const ARequestedMsgType : TRequestedMsgType;
const AStationCallsign : string) : TExchTypes; override;
end;
implementation
{ TDualExchContest }
constructor TDualExchContest.Create(
ALocalType1 : TExchange1Type;
ALocalType2 : TExchange2Type;
ADxType1 : TExchange1Type;
ADxType2 : TExchange2Type);
begin
inherited Create;
HomeCallIsLocal:= True;
LocalTypes.Exch1:= ALocalType1;
LocalTypes.Exch2:= ALocalType2;
DxTypes.Exch1:= ADxType1;
DxTypes.Exch2:= ADxType2;
end;
{
returns exchange types for this contest. The exchange types are specified
by the derived class and passed to the constructor.
Self.HomeCallIsLocal is set by the derived OnSetMyCall.
There are 3 variables to check:
1) is user's home callsign on the local-side or DX-side of the contest?
2) kind of (simulated) station, either MyStation or DxStation?
3) what message type is requested (sent-type or receive-type)?
The Karnough Map below shows the logic. Carefull study reveals that the
'xor' logical operator can be used to implement this logic.
\ ARequestedMsgType
HomeCall, StationKind \ 0 (mtSendType) | 1 (mtRecvType)
00 (W/VE, MyStation) | etStateProv | etPower
01 (W/VE, DxStation) | etPower | etStateProv
11 (DX, DxStation) | etStateProv | etPower
10 (DX, MyStation) | etPower | etStateProv
}
function TDualExchContest.GetExchangeTypes(
const AStationKind : TStationKind;
const ARequestedMsgType : TRequestedMsgType;
const AStationCallsign : string) : TExchTypes;
var
HomeCallIsDX: Boolean;
IsSimDxStation: Boolean;
IsRecvMsgRequest: Boolean;
begin
HomeCallIsDX:= not Self.HomeCallIsLocal;
IsSimDxStation:= AStationKind = skDxStation;
IsRecvMsgRequest:= ARequestedMsgType = mtRecvMsg;
if HomeCallIsDX xor IsSimDxStation xor IsRecvMsgRequest then
Result := Self.DxTypes // e.g. etPower for ARRL DX Contest
else
Result := Self.LocalTypes; // e.g. etStateProv for ARRL DX Contest
end;
end.