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

original commit #3

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
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
70 changes: 68 additions & 2 deletions CallLst.pas
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,20 @@
//------------------------------------------------------------------------------
unit CallLst;

{$MODE Delphi}

interface

uses
SysUtils, Classes, Ini;
SysUtils, Classes, Ini, FileUtil, Logerrorx;

procedure LoadCallList;
function PickCall: string;
function PickCallAndZone: string;

var
Calls: TStringList;
Zones: TStringList;



Expand All @@ -28,6 +32,55 @@ function CompareCalls(Item1, Item2: Pointer): Integer;
end;

procedure LoadCallList;

var
tfIn: TextFile;
s: string;
stringlist: TStringList;
numparsed: integer;
call: string;
zone: string;
FileName: string;
begin
stringlist := TStringList.Create;
stringlist.Delimiter := ';';
Calls.Clear;
Zones.Clear;
Calls.Capacity := 20000;
Zones.Capacity := 20000;
FileName := ExtractFilePath(ParamStr(0)) + 'mr_db.txt';
// Set the name of the file that will be read
AssignFile(tfIn, FileName);

// Open the file for reading
reset(tfIn);

// Keep reading lines until the end of the file is reached
while not eof(tfIn) do
begin
readln(tfIn, s);
stringlist.DelimitedText := s;
numparsed := stringlist.Count;
if numparsed >= 2 then
begin
call := stringlist[0];
zone := stringlist[1];
if call <> '' then
begin
Calls.Add(call);
Zones.Add(zone);
end;
end;

// LogError(intToStr(numparsed));
end;

// Done so close the file
CloseFile(tfIn);

end;

procedure OldLoadCallList;
const
Chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789/';
CHRCOUNT = Length(Chars);
Expand All @@ -47,7 +100,7 @@ procedure LoadCallList;
Calls.Clear;

FileName := ExtractFilePath(ParamStr(0)) + 'Master.dta';
if not FileExists(FileName) then Exit;
if not FileExists(FileName) { *Converted from FileExists* } then Exit;

with TFileStream.Create(FileName, fmOpenRead) do
try
Expand Down Expand Up @@ -101,13 +154,26 @@ function PickCall: string;

if Ini.RunMode = rmHst then Calls.Delete(Idx);
end;
function PickCallAndZone: string;
var
Idx: integer;
begin
if Calls.Count = 0 then begin Result := 'P29SX'; Exit; end;

Idx := Random(Calls.Count);
Result := Calls[Idx] + ';' + Zones[Idx];

if Ini.RunMode = rmHst then Calls.Delete(Idx);
end;


initialization
Calls := TStringList.Create;
Zones := TStringList.Create;

finalization
Calls.Free;
Zones.Free;

end.

20 changes: 16 additions & 4 deletions Contest.pas
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
//------------------------------------------------------------------------------
unit Contest;

{$MODE Delphi}

interface

uses
SysUtils, SndTypes, Station, StnColl, MyStn, Math, Ini,
MovAvg, Mixers, VolumCtl, RndFunc, TypInfo, DxStn, DxOper, Log;
MovAvg, Mixers, VolumCtl, RndFunc, TypInfo, DxStn, DxOper, Log, Logerrorx;

type
TContest = class
Expand Down Expand Up @@ -104,6 +106,7 @@ function TContest.GetAudio: TSingleArray;
i, Stn: integer;
Bfo: Single;
Smg, Rfg: Single;
Temp: Single;
begin
//minimize audio output delay
SetLength(Result, 1);
Expand Down Expand Up @@ -157,6 +160,7 @@ function TContest.GetAudio: TSingleArray;
begin
Blk := Me.GetBlock;
//self-mon. gain
Temp := MainForm.VolumeSlider1.Value;
Smg := Power(10, (MainForm.VolumeSlider1.Value - 0.75) * 4);
Rfg := 1;
for i:=0 to High(Blk) do
Expand Down Expand Up @@ -285,9 +289,17 @@ procedure TContest.OnMeFinishedSending;
//the stations heard my CQ and want to call
if (not (RunMode in [rmSingle, RmHst])) then
if (msgCQ in Me.Msg) or
((QsoList <> nil) and (msgTU in Me.Msg) and (msgMyCall in Me.Msg))then
for i:=1 to RndPoisson(Activity / 2) do Stations.AddCaller;

// ((QsoList <> nil) and (msgTU in Me.Msg) and (msgMyCall in Me.Msg))then
//for i:=1 to RndPoisson(Activity / 2) do Stations.AddCaller;
((QsoList <> nil) and ((msgTU in Me.Msg) or (msgMyCall in Me.Msg)))then
begin
if DXCount < Activity/2 then
begin
for i:=1 to RndPoisson(Activity / 2) do Stations.AddCaller;
end;
end;

// logerror('in TContest.OnMeFinishedSending, count = ' + inttostr(Stations.Count));
//tell callers that I finished sending
for i:=Stations.Count-1 downto 0 do
Stations[i].ProcessEvent(evMeFinished);
Expand Down
15 changes: 10 additions & 5 deletions DxOper.pas
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
//------------------------------------------------------------------------------
unit DxOper;

{$MODE Delphi}

interface

uses
Expand Down Expand Up @@ -43,7 +45,7 @@ TDxOperator = class
implementation

uses
Contest;
Contest, Main;

{ TDxOperator }

Expand All @@ -68,12 +70,13 @@ function TDxOperator.GetWpm: integer;
begin
if RunMode = rmHst
then Result := Ini.Wpm
else Result := Round(Ini.Wpm * 0.5 * (1 + Random));
else Result := Round((Ini.Wpm - 10) + Random(12));
end;

function TDxOperator.GetNR: integer;
begin
Result := 1 + Round(Random * Tst.Minute * Skills);
// Result := 1 + Round(Random * Tst.Minute * Skills);
Result := 1 + Round(Random(1000));
end;

function TDxOperator.GetReplyTimeout: integer;
Expand Down Expand Up @@ -231,9 +234,11 @@ procedure TDxOperator.MsgReceived(AMsg: TStationMessages);
case State of
osNeedPrevEnd: ;
osNeedQso: State := osNeedPrevEnd;
osNeedNr: if (Random < 0.9) or (RunMode = rmHst) then SetState(osNeedEnd);
osNeedNr: if (Random < 0.9) or (RunMode = rmHst) Or MainForm.NoRepeats then SetState(osNeedEnd);
// osNeedNr: SetState(osNeedEnd);
osNeedCall: ;
osNeedCallNr: if (Random < 0.9) or (RunMode = rmHst) then SetState(osNeedCall);
osNeedCallNr: if (Random < 0.9) or (RunMode = rmHst) Or MainForm.NoRepeats then SetState(osNeedCall);
// osNeedCallNr: SetState(osNeedEnd);
osNeedEnd: ;
end;

Expand Down
37 changes: 35 additions & 2 deletions DxStn.pas
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
//------------------------------------------------------------------------------
unit DxStn;

{$MODE Delphi}

interface

uses
Expand All @@ -31,12 +33,19 @@ implementation

{ TDxStation }

var callzone: string;
stringlist: TStringList;

constructor TDxStation.CreateStation;
begin
inherited Create(nil);
stringlist := TStringList.Create;
stringlist.Delimiter := ';';

HisCall := Ini.Call;
MyCall := PickCall;
callzone := PickCallAndZone;
stringlist.DelimitedText := callzone;
MyCall := stringlist[0];

Oper := TDxOperator.Create;
Oper.Call := MyCall;
Expand All @@ -45,7 +54,31 @@ constructor TDxStation.CreateStation;
NrWithError := Ini.Lids and (Random < 0.1);

Wpm := Oper.GetWpm;
NR := Oper.GetNR;
If Ini.ContestName = 'cqwpx' then
begin
NR := Oper.GetNR;
end
else
begin
NR := StrToInt(stringlist[1]);
end;
//if LeftStr(Oper.Call, 1) = 'K' then
//begin
//NR := Random(3) + 3;
//end
//else if LeftStr(Oper.Call, 1) = 'W' then
//begin
//NR := Random(3) + 3;
//end
//else if LeftStr(Oper.Call, 1) = 'N' then
//begin
//NR := Random(3) + 3;
//end
//else if LeftStr(Oper.Call, 1) = 'A' then
//begin
//NR := Random(3) + 3;
//end;

if Ini.Lids and (Random < 0.03)
then RST := 559 + 10*Random(4)
else RST := 599;
Expand Down
Loading