Skip to content

Commit

Permalink
314 nil when logging a partial callsign (#316)
Browse files Browse the repository at this point in the history
After entering a partial callsign and exchange information, the user
will hit `Enter` to finish the QSO and log the QSO. The QSO is not
logged.

This was caused by the logging module only comparing for a perfect match
against the caller callsign and not considering the common occurrence of
a partially-correct callsign. Code was changed to allow a
partially-correct callsign. This allows these QSO to be included in the
log as expected.

Checkin notes:
```
Improve handling of partial callsign matches

- Report both callsign and exchange errors in QSO log.
- Add argument to IsMyCall to enable random result for lids.
```

Issue #315 will add improved messages for the partially-correct callsign
case. This next review will be posted soon.

Once the second pull request/review is submitted, I will post an
engineering build for testing. Stay tuned...
  • Loading branch information
w7sst authored Jun 9, 2024
2 parents af00a35 + 71643c2 commit 93d5b92
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 18 deletions.
4 changes: 3 additions & 1 deletion Contest.pas
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,9 @@ function TContest.GetAudio: TSingleArray;
for i:=Stations.Count-1 downto 0 do
if Stations[i] is TDxStation then
with Stations[i] as TDxStation do
if (Oper.State = osDone) and (QsoList <> nil) and (MyCall = QsoList[High(QsoList)].Call) then begin
if (Oper.State = osDone) and (QsoList <> nil) and
((MyCall = QsoList[High(QsoList)].Call) or
(Oper.IsMyCall(QsoList[High(QsoList)].Call, False) = mcAlmost)) then begin
// grab Qso's "True" data (e.g. TrueCall, TrueExch1, TrueExch2)
DataToLastQso; // deletes this TDxStation from Stations[]

Expand Down
29 changes: 22 additions & 7 deletions DxOper.pas
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ interface

TDxOperator = class
private
R1: Single; // holds a Random number; used in IsMyCall
procedure DecPatience;
procedure MorePatience(AValue: integer = 0);
function IsMyCall: TCallCheckResult;
public
Call: string;
Skills: integer;
Expand All @@ -95,6 +95,7 @@ TDxOperator = class
// Patience is increased with calls to MorePatience.
RepeatCnt: integer;
State: TOperatorState;
constructor Create(const ACall: string; AState: TOperatorState);
function IsGhosting: boolean;
function GetSendDelay: integer;
function GetReplyTimeout: integer;
Expand All @@ -104,6 +105,7 @@ TDxOperator = class
procedure MsgReceived(AMsg: TStationMessages);
procedure SetState(AState: TOperatorState);
function GetReply: TStationMessage;
function IsMyCall(const ACall: string; ARandomResult: boolean): TCallCheckResult;
end;


Expand All @@ -115,6 +117,17 @@ implementation
{ TDxOperator }


constructor TDxOperator.Create(const ACall: string; AState: TOperatorState);
begin
R1 := Random; // a random value assigned at creation provides consistency
Call := ACall;
Skills := 1 + Random(3); //1..3
Patience := 0;
RepeatCnt := 1;
SetState(AState);
end;


{
The notion of ghosting refers to a DxOperator who has run out of
Patience and is leaving the QSO because the User has failed to respond.
Expand Down Expand Up @@ -306,7 +319,8 @@ procedure TDxOperator.SetState(AState: TOperatorState);
end;


function TDxOperator.IsMyCall: TCallCheckResult;
function TDxOperator.IsMyCall(const ACall: string;
ARandomResult: boolean): TCallCheckResult;
const
W_X = 1; W_Y = 1; W_D = 1;
var
Expand All @@ -318,7 +332,7 @@ function TDxOperator.IsMyCall: TCallCheckResult;
P: integer;
begin
C0 := Call;
C := Tst.Me.HisCall;
C := ACall;

SetLength(M, Length(C)+1, Length(C0)+1);

Expand Down Expand Up @@ -372,10 +386,10 @@ function TDxOperator.IsMyCall: TCallCheckResult;
if Length(StringReplace(C, '?', '', [rfReplaceAll])) < 2 then Result := mcNo;

//accept a wrong call, or reject the correct one
if Ini.Lids and (Length(C) > 3) then
if ARandomResult and Ini.Lids and (Length(C) > 3) then
case Result of
mcYes: if Random < 0.01 then Result := mcAlmost;
mcAlmost: if Random < 0.04 then Result := mcYes;
mcYes: if R1 < 0.01 then Result := mcAlmost;
mcAlmost: if R1 < 0.04 then Result := mcYes;
end;
end;

Expand Down Expand Up @@ -406,7 +420,7 @@ procedure TDxOperator.MsgReceived(AMsg: TStationMessages);
end;

if msgHisCall in AMsg then
case IsMyCall of
case IsMyCall(Tst.Me.HisCall, True) of
mcYes:
if State in [osNeedPrevEnd, osNeedQso] then SetState(osNeedNr)
else if State = osNeedCallNr then SetState(osNeedNr)
Expand All @@ -415,6 +429,7 @@ procedure TDxOperator.MsgReceived(AMsg: TStationMessages);

mcAlmost:
if State in [osNeedPrevEnd, osNeedQso] then SetState(osNeedCallNr)
else if State = osNeedCallNr then MorePatience
else if State = osNeedNr then SetState(osNeedCallNr)
else if State = osNeedEnd then SetState(osNeedCall);

Expand Down
5 changes: 1 addition & 4 deletions DxStn.pas
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,7 @@ constructor TDxStation.CreateStation;
Operid := Tst.PickStation;
MyCall := Tst.GetCall(Operid);

Oper := TDxOperator.Create;
Oper.Call := MyCall;
Oper.Skills := 1 + Random(3); //1..3
Oper.SetState(osNeedPrevEnd);
Oper := TDxOperator.Create(MyCall, osNeedPrevEnd);
NrWithError := Ini.Lids and (Random < 0.1);

// DX's speed, {WpmS,WpmC}, is set once at creation time
Expand Down
11 changes: 5 additions & 6 deletions Log.pas
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ procedure SaveQso;
for i:=Tst.Stations.Count-1 downto 0 do
if Tst.Stations[i] is TDxStation then
with Tst.Stations[i] as TDxStation do
if (MyCall = Qso.Call) then
if ((MyCall = Qso.Call) or (Oper.IsMyCall(Qso.Call, False) = mcAlmost)) then
begin
Qso.TrueWpm := WpmAsText();
Break;
Expand All @@ -770,7 +770,8 @@ procedure SaveQso;
for i:=Tst.Stations.Count-1 downto 0 do
if Tst.Stations[i] is TDxStation then
with Tst.Stations[i] as TDxStation do
if (Oper.State = osDone) and (MyCall = Qso.Call) then
if (Oper.State = osDone) and
((MyCall = Qso.Call) or (Oper.IsMyCall(Qso.Call, False) = mcAlmost)) then
begin
DataToLastQso; //grab "True" data and delete this dx station!
Break;
Expand Down Expand Up @@ -995,12 +996,10 @@ procedure CheckErr;
else if Dupe and not Log.ShowCorrections then
ExchError := leDUP
else
begin
ExchError := leNONE;

// find exchange errors for the current Qso
Tst.FindQsoErrors(QsoList[High(QsoList)], Corrections);
end;
// find exchange errors for the current Qso
Tst.FindQsoErrors(QsoList[High(QsoList)], Corrections);

CallColumnColor := clBlack;
Exch1ColumnColor := clBlack;
Expand Down

0 comments on commit 93d5b92

Please sign in to comment.