Skip to content

Commit

Permalink
refactor - Add TContest.SaveEnteredExchToQso
Browse files Browse the repository at this point in the history
- moves code from Log.pas into Contest.pas
- allows contest-specific exchange information to be handled
  by derived contests (e.g. ARRL Sweepstakes).
  • Loading branch information
w7sst committed Jun 25, 2024
1 parent 7e34fa3 commit 799bd9a
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 31 deletions.
43 changes: 43 additions & 0 deletions Contest.pas
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ TContest = class
procedure SendText(const AStn: TStation; const AMsg: string); virtual;

function ValidateEnteredQsoData(const ACall, AExch1, AExch2: string) : boolean; virtual;
procedure SaveEnteredExchToQso(var Qso: TQso; const AExch1, AExch2: string); virtual;
procedure FindQsoErrors(var Qso: TQso; var ACorrections: TStringList);
function ExtractMultiplier(Qso: PQso) : string; virtual;
function Minute: Single;
Expand Down Expand Up @@ -424,6 +425,48 @@ function TContest.ValidateEnteredQsoData(const ACall, AExch1, AExch2: string) :
end;


{
SaveEnteredExchToQso will save contest-specific exchange values into a QSO.
This is called to enter the completed QSO into the log.
This virtual function can be overriden by specialized contests as needed
(see ARRL Sweepstakes).
}
procedure TContest.SaveEnteredExchToQso(var Qso: TQso; const AExch1, AExch2: string);
begin
// Adding a contest: save contest-specific exchange values into QsoList
//save Exchange 1 (Edit2)
case Mainform.RecvExchTypes.Exch1 of
etRST: Qso.Rst := StrToInt(AExch1);
etOpName: Qso.Exch1 := AExch1;
etFdClass: Qso.Exch1 := AExch1;
else
assert(false, 'missing case');
end;

//save Exchange2 (Edit3)
case Mainform.RecvExchTypes.Exch2 of
etSerialNr: Qso.Nr := StrToInt(AExch2);
etGenericField:Qso.Exch2 := AExch2;
etArrlSection: Qso.Exch2 := AExch2;
etStateProv: Qso.Exch2 := AExch2;
etCqZone: Qso.NR := StrToInt(AExch2);
etItuZone: Qso.Exch2 := AExch2;
//etAge:
etPower: Qso.Exch2 := AExch2;
etJaPref: Qso.Exch2 := AExch2;
etJaCity: Qso.Exch2 := AExch2;
etNaQpExch2: Qso.Exch2 := AExch2;
etNaQpNonNaExch2:
if AExch2 = '' then
Qso.Exch2 := 'DX'
else
Qso.Exch2 := AExch2;
else
assert(false, 'missing case');
end;
end;


{
Extract multiplier string for a given contest. Default behavior will
return the QSO.Pfx string (which implies this method must be called
Expand Down
33 changes: 2 additions & 31 deletions Log.pas
Original file line number Diff line number Diff line change
Expand Up @@ -680,37 +680,8 @@ procedure SaveQso;
Qso.T := BlocksToSeconds(Tst.BlockNumber) / 86400;
Qso.Call := Call;

// Adding a contest: save contest-specific exchange values into QsoList
//save Exchange 1 (Edit2)
case Mainform.RecvExchTypes.Exch1 of
etRST: Qso.Rst := StrToInt(Edit2.Text);
etOpName: Qso.Exch1 := Edit2.Text;
etFdClass: Qso.Exch1 := Edit2.Text;
else
assert(false, 'missing case');
end;

//save Exchange2 (Edit3)
case Mainform.RecvExchTypes.Exch2 of
etSerialNr: Qso.Nr := StrToInt(Edit3.Text);
etGenericField:Qso.Exch2 := Edit3.Text;
etArrlSection: Qso.Exch2 := Edit3.Text;
etStateProv: Qso.Exch2 := Edit3.Text;
etCqZone: Qso.NR := StrToInt(Edit3.Text);
etItuZone: Qso.Exch2 := Edit3.Text;
//etAge:
etPower: Qso.Exch2 := Edit3.Text;
etJaPref: Qso.Exch2 := Edit3.Text;
etJaCity: Qso.Exch2 := Edit3.Text;
etNaQpExch2: Qso.Exch2 := Edit3.Text;
etNaQpNonNaExch2:
if Edit3.Text = '' then
Qso.Exch2 := 'DX'
else
Qso.Exch2 := Edit3.Text;
else
assert(false, 'missing case');
end;
//save contest-specific exchange values into QSO
Tst.SaveEnteredExchToQso(Qso^, Edit2.Text, Edit3.Text);

Qso.Points := 1; // defaults to 1; override in ExtractMultiplier()
Qso.RawCallsign:= ExtractCallsign(Qso.Call);
Expand Down

0 comments on commit 799bd9a

Please sign in to comment.