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 - rename Wpm to WpmS (sending wpm speed); add TStation.SetWpm #190

Merged
merged 1 commit into from
Feb 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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