Skip to content

Commit

Permalink
refactor - rename Wpm to WpmS (sending wpm speed); add TStation.SetWpm (
Browse files Browse the repository at this point in the history
#190)

Renames existing Wpm variable to WpmS and adds TStation.SetWpm() method.

This is done in preparation for adding Farnsworth support in #188. Fixes
#189.
  • Loading branch information
w7sst authored Feb 25, 2023
2 parents de726bf + 6440285 commit eba188f
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 14 deletions.
8 changes: 4 additions & 4 deletions DxOper.pas
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
interface

uses
SysUtils, RndFunc, Station, Ini, Math, Log;
Station;

const
FULL_PATIENCE = 5;
Expand Down Expand Up @@ -44,7 +44,7 @@ TDxOperator = class
implementation

uses
Contest;
SysUtils, Ini, Math, RndFunc, Contest, Log;

{ TDxOperator }

Expand All @@ -60,7 +60,7 @@ function TDxOperator.GetSendDelay: integer;
if State = osNeedPrevEnd then
Result := NEVER
else if RunMode = rmHst then
Result := SecondsToBlocks(0.05 + 0.5*Random * 10/Wpm)
Result := SecondsToBlocks(0.05 + 0.5*Random * 10/Ini.Wpm)
else
Result := SecondsToBlocks(0.1 + 0.5*Random);
end;
Expand Down Expand Up @@ -106,7 +106,7 @@ function TDxOperator.GetName: string;
function TDxOperator.GetReplyTimeout: integer;
begin
if RunMode = rmHst then
Result := SecondsToBlocks(60/Wpm)
Result := SecondsToBlocks(60/Ini.Wpm)
else
Result := SecondsToBlocks(6-Skills);
Result := Round(RndGaussLim(Result, Result/2));
Expand Down
2 changes: 1 addition & 1 deletion DxStn.pas
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ constructor TDxStation.CreateStation;
Oper.SetState(osNeedPrevEnd);
NrWithError := Ini.Lids and (Random < 0.1);

Wpm := Oper.GetWpm;
WpmS := Oper.GetWpm;

// DX's sent exchange types depends on kind-of-station and their callsign
SentExchTypes := Tst.GetSentExchTypes(skDxStation, MyCall);
Expand Down
2 changes: 1 addition & 1 deletion Main.pas
Original file line number Diff line number Diff line change
Expand Up @@ -2007,7 +2007,7 @@ procedure TMainForm.SetWpm(AWpm : integer);
begin
Wpm := Max(10, Min(120, AWpm));
SpinEdit1.Value := Wpm;
Tst.Me.Wpm := Wpm;
Tst.Me.SetWpm(Wpm);
end;


Expand Down
14 changes: 12 additions & 2 deletions MyStn.pas
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ TMyStation = class(TStation)
constructor CreateStation;
destructor Destroy; override;
procedure Init;
procedure SetWpm(const AWpmS : integer);
procedure ProcessEvent(AEvent: TStationEvent); override;
procedure AbortSend;
procedure SendText(AMsg: string); override;
Expand Down Expand Up @@ -58,7 +59,7 @@ procedure TMyStation.Init;
NR := 1;
RST := 599;
Pitch := Ini.Pitch;
Wpm := Ini.Wpm;
WpmS := Ini.Wpm;
Amplitude := 300000;

// invalidate SentExchTypes. Will be set by Tst.OnSetMyCall().
Expand All @@ -72,6 +73,15 @@ procedure TMyStation.Init;
end;


{
Called by TMainForm.SetWpm whenever Wpm is updated via UI.
}
procedure TMyStation.SetWpm(const AWpmS : integer);
begin
WpmS := AWpmS; // set via UI
end;


procedure TMyStation.ProcessEvent(AEvent: TStationEvent);
begin
if AEvent = evMsgSent then Tst.OnMeFinishedSending;
Expand Down Expand Up @@ -176,7 +186,7 @@ function TMyStation.UpdateCallInMessage(ACall: string): boolean;
if Result then
begin
//create new envelope
Keyer.Wpm := Wpm;
Keyer.WpmS := Wpm;
Keyer.MorseMsg := Keyer.Encode(ACall);
NewEnvelope := Keyer.Envelope;
for i:=0 to High(NewEnvelope) do
Expand Down
2 changes: 1 addition & 1 deletion QrmStn.pas
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ constructor TQrmStation.CreateStation;
HisCall := Ini.Call;
Amplitude := 5000 + 25000 * Random;
Pitch := Round(RndGaussLim(0, 300));
Wpm := 30 + Random(20);
WpmS := 30 + Random(20);

// DX's sent exchange types depends on kind-of-station and their callsign
SentExchTypes:= Tst.GetSentExchTypes(skDxStation, MyCall);
Expand Down
6 changes: 3 additions & 3 deletions Station.pas
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ TStation = class (TCollectionItem)
function NrAsText: string;
public
Amplitude: Single;
Wpm: integer;
WpmS: integer; // Words per minute, sending speed (set by UI)
Envelope: TSingleArray; // this station's digitized Envelope being sent
State: TStationState;

Expand Down Expand Up @@ -245,8 +245,8 @@ procedure TStation.SendMorse(AMorse: string);
SendPos := 0;
FBfo := 0;
end;
Keyer.Wpm := Wpm;

Keyer.WpmS := WpmS;
Keyer.MorseMsg := AMorse;
Envelope := Keyer.Envelope;
for i:=0 to High(Envelope) do
Expand Down
4 changes: 2 additions & 2 deletions VCL/MorseKey.pas
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ TKeyer = class
function BlackmanHarrisStepResponse(Len: integer): TSingleArray;
procedure SetRiseTime(const Value: Single);
public
Wpm: integer;
WpmS: integer; // sending speed - Ts (set by UI)
BufSize: integer;
Rate: integer;
MorseMsg: string;
Expand Down Expand Up @@ -192,7 +192,7 @@ function TKeyer.GetEnvelope: TSingleArray;
end;

//calc buffer size
SamplesInUnit := Round(0.1 * Rate * 12 / Wpm);
SamplesInUnit := Round(0.1 * Rate * 12 / WpmS);
TrueEnvelopeLen := UnitCnt * SamplesInUnit + RampLen;
Len := BufSize * Ceil(TrueEnvelopeLen / BufSize);
Result := nil;
Expand Down

0 comments on commit eba188f

Please sign in to comment.