Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor - introduce contest-specific message handling logic #184

Closed
w7sst opened this issue Feb 13, 2023 · 0 comments · Fixed by #185
Closed

refactor - introduce contest-specific message handling logic #184

w7sst opened this issue Feb 13, 2023 · 0 comments · Fixed by #185
Assignees
Labels
technical debt code cleanup, refactoring, improve comments and/or design

Comments

@w7sst
Copy link
Owner

w7sst commented Feb 13, 2023

The current implementation uses many case statements to handle contest-specific messaging. This issue will introduce a virtual function into TContest class hierarchy to allow each derived contests to define their own messages (e.g. CQ will be different for some contests, the exchange is different, etc.)

The class diagram below shows a new virtual method added to the TContest base class. A new method, SendMsg will be added to handle contest-specific message generation.

classDiagram
TMainForm *-- Contest
TMainForm: +TSimContest SimContest
TMainForm: +string Sent Exchange
TMainForm: +RecvExchTypes TExchTypes
TMainForm: +SetContest(TSimContest)
   Contest<|-- Wpx Contest
   Contest<|-- ARRL Field Day Contest
   Contest<|-- CWOPS CWT Contest
   Contest<|-- ARRL DX Contest
   Contest*-- MyStation
   Contest: +LoadCallHistory(filename, user_callsign)
 Contest: +GetCallHistoryFileName() string
 Contest: +GetRecvExchTypes() TExchTypes
 Contest: +GetSentExchTypes() TExchTypes
 Contest: +SendMsg(station, TStationMessage)

class Station{
 +TExchTypes SentExchTypes
 +SendMsg(TStationMessage)
 +SendText(AMsg : string)
}

Station<|--MyStation
MyStation:   +SendText(AMsg string)

Station<|--DxStation

   class Wpx Contest{
       +GetCallHistoryFileName() string
       +SendMsg(station, TStationMessage)
   }
   class ARRL Field Day Contest{
       +GetCallHistoryFileName() string
       +SendMsg(station, TStationMessage)
   }
   class CWOPS CWT Contest{
       +GetCallHistoryFileName() string
       +SendMsg(station, TStationMessage)
   }
   class ARRL DX Contest{
       +GetCallHistoryFileName() string
       +GetRecvExchTypes() TExchTypes
       +GetSentExchTypes() TExchTypes
       +SendMsg(station, TStationMessage)
   }
Loading
@w7sst w7sst added the technical debt code cleanup, refactoring, improve comments and/or design label Feb 13, 2023
@w7sst w7sst self-assigned this Feb 13, 2023
@w7sst w7sst linked a pull request Feb 13, 2023 that will close this issue
w7sst added a commit that referenced this issue Feb 15, 2023
Added new virtual method to TContest.SendMsg(). This is derived by those
contests with contest-specific messaging. Codes was moved from its old
location into the new methods. No functionality was changed - only code
movement. This fixes #184.

I like this change. It removes lots of case statements. Here is an
example from ARRL Field Day...
```
{
  Overrides TContest.SendMsg() to send contest-specific messages.

  Adding a contest: TContest.SendMsg(AMsg): send contest-specfic messages
}
procedure TArrlFieldDay.SendMsg(const AStn: TStation; const AMsg: TStationMessage);
begin
  case AMsg of
    msgCQ: SendText(AStn, 'CQ FD <my>');
    msgNrQm:
      case Random(5) of
        0,1: SendText(AStn, 'NR?');
        2: SendText(AStn, 'SECT?');
        3: SendText(AStn, 'CLASS?');
        4: SendText(AStn, 'CL?');
      end;
    msgLongCQ: SendText(AStn, 'CQ CQ FD <my> <my> FD');  // QrmStation only
    else
      inherited SendMsg(AStn, AMsg);
  end;
end;
```

Note - I added many people to this review to keep people informed of the
design change. My next step is to integrate the SST Contest.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
technical debt code cleanup, refactoring, improve comments and/or design
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant