From 644028572af6245f09014a1165993c3fa46043d2 Mon Sep 17 00:00:00 2001 From: Mike Brashler Date: Thu, 23 Feb 2023 23:28:49 -0800 Subject: [PATCH] refactor - rename Wpm to WpmS (sending wpm speed); add TStation.SetWpm --- DxOper.pas | 8 ++++---- DxStn.pas | 2 +- Main.pas | 2 +- MyStn.pas | 14 ++++++++++++-- QrmStn.pas | 2 +- Station.pas | 6 +++--- VCL/MorseKey.pas | 4 ++-- 7 files changed, 24 insertions(+), 14 deletions(-) diff --git a/DxOper.pas b/DxOper.pas index 0ff300e..33ba19a 100644 --- a/DxOper.pas +++ b/DxOper.pas @@ -8,7 +8,7 @@ interface uses - SysUtils, RndFunc, Station, Ini, Math, Log; + Station; const FULL_PATIENCE = 5; @@ -44,7 +44,7 @@ TDxOperator = class implementation uses - Contest; + SysUtils, Ini, Math, RndFunc, Contest, Log; { TDxOperator } @@ -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; @@ -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)); diff --git a/DxStn.pas b/DxStn.pas index 33ac9e7..60666fa 100644 --- a/DxStn.pas +++ b/DxStn.pas @@ -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); diff --git a/Main.pas b/Main.pas index 0938f2c..11fec05 100644 --- a/Main.pas +++ b/Main.pas @@ -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; diff --git a/MyStn.pas b/MyStn.pas index 249ea12..2dd30a4 100644 --- a/MyStn.pas +++ b/MyStn.pas @@ -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; @@ -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(). @@ -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; @@ -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 diff --git a/QrmStn.pas b/QrmStn.pas index fbfd5cf..6a80131 100644 --- a/QrmStn.pas +++ b/QrmStn.pas @@ -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); diff --git a/Station.pas b/Station.pas index 2a772dd..f426b1c 100644 --- a/Station.pas +++ b/Station.pas @@ -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; @@ -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 diff --git a/VCL/MorseKey.pas b/VCL/MorseKey.pas index e3c8680..18d5b3c 100644 --- a/VCL/MorseKey.pas +++ b/VCL/MorseKey.pas @@ -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; @@ -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;