Merge branch 'master' into passband

This commit is contained in:
Petr Hlozek 2022-07-24 13:05:00 +02:00 committed by GitHub
commit e0e235611b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 563 additions and 242 deletions

View File

@ -105,7 +105,7 @@
<MinVersion Major="1" Minor="2" Release="1" Valid="True"/>
</Item10>
</RequiredPackages>
<Units Count="121">
<Units Count="122">
<Unit0>
<Filename Value="cqrlog.lpr"/>
<IsPartOfProject Value="True"/>
@ -895,6 +895,11 @@
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
</Unit120>
<Unit121>
<Filename Value="fDbError.pas"/>
<IsPartOfProject Value="True"/>
<HasResources Value="True"/>
</Unit121>
</Units>
</ProjectOptions>
<CompilerOptions>

View File

@ -26,7 +26,7 @@ uses
fWorkedGrids, fPropDK0WCY, fRemind, fContest, fMonWsjtx, fXfldigi,
dMembership, dSatellite, uRigControl, uRotControl, azidis3, aziloc, fDOKStat,
fCabrilloExport, uDbUtils, dQTHProfile, uConnectionInfo, znacmech, gline2,
fDbSqlSel;
fDbSqlSel, fDbError;
var
Splash : TfrmSplash;

View File

@ -874,7 +874,7 @@ begin
try
prg := cqrini.ReadString('ExtView', 'txt', '');
if prg<>'' then
dmUtils.RunOnBackground(prg + ' ' + OtF)
dmUtils.RunOnBackground(prg + ' ' + AnsiQuotedStr(OtF, '"'))
else ShowMessage('No external text viewer defined!'+#10+'See: prefrences/External viewers');
finally
//done

View File

@ -163,7 +163,7 @@ begin
try
prg := cqrini.ReadString('ExtView', 'txt', '');
if prg<>'' then
dmUtils.RunOnBackground(prg + ' ' + f)
dmUtils.RunOnBackground(prg + ' ' + AnsiQuotedStr(f, '"'))
else ShowMessage('No external text viewer defined!'+#10+'See: prefrences/External viewers');
finally
//done

View File

@ -58,7 +58,7 @@ begin
CurrentDir := GetCurrentDir;
try
SetCurrentDir(flAttach.Directory);
dmUtils.RunOnBackground('/usr/bin/xdg-open' + ' "' + flAttach.FileName + '"');
dmUtils.RunOnBackground('/usr/bin/xdg-open' + ' ' + AnsiQuotedStr(flAttach.FileName, '"'));
finally
SetCurrentDir(CurrentDir)
end;

View File

@ -37,7 +37,7 @@ uses dUtils, dData;
procedure TfrmDbError.btnOpenErrFileClick(Sender : TObject);
begin
dmUtils.RunOnBackground('xdg-open ' + dmData.DataDir + 'mysql.err')
dmUtils.RunOnBackground('xdg-open ' + AnsiQuotedStr(dmData.DataDir + 'mysql.err', '"'))
end;
procedure TfrmDbError.btnVisitFAQClick(Sender : TObject);

View File

@ -159,7 +159,7 @@ begin
try
prg := cqrini.ReadString('ExtView', 'txt', '');
if prg<>'' then
dmUtils.RunOnBackground(prg + ' ' + edtFileName.Text)
dmUtils.RunOnBackground(prg + ' ' + AnsiQuotedStr(edtFileName.Text, '"'))
else ShowMessage('No external text viewer defined!'+#10+'See: prefrences/External viewers');
finally
//done

View File

@ -3158,6 +3158,7 @@ var
ShowMain : Boolean = False;
date : TDate;
RxFreq : Double = 0;
key : word = $24; //Home-key
begin
ShowMain := (fEditQSO or fViewQSO) and (not fromNewQSO);
if not cbOffline.Checked then
@ -3398,7 +3399,7 @@ begin
if not AnyRemoteOn then
UnsetEditLabel;
dmData.qQSOBefore.Close;
fEditQSO := False;
was_call := edtCall.Text;
edtCall.Text := ''; //calls ClearAll
old_ccall := '';
@ -3409,7 +3410,14 @@ begin
frmTRXControl.ClearRIT;
if (cqrini.ReadBool('NewQSO','RefreshAfterSave', True) and frmMain.Showing) then
begin
frmMain.acRefresh.Execute;
if not fEditQso then
frmMain.dbgrdMainKeyUp(nil,key,[ssCtrl]); //shows last logged qso
end;
fEditQSO := False;
UploadAllQSOOnline;
if frmWorkedGrids.Showing then frmWorkedGrids.UpdateMap;
@ -7484,7 +7492,7 @@ begin
btnSave.Enabled := False; //disable manual saving when remote is on
tmrADIF.Interval := 250; //rate to read qsos from UDP (msec)
if run and FileExists(ExtractWord(1,path,[' '])) then
dmUtils.RunOnBackground(path)
dmUtils.RunOnBackground(AnsiQuotedStr(path, '"'))
end;

View File

@ -3828,7 +3828,7 @@ object frmPreferences: TfrmPreferences
ItemHeight = 0
OnChange = cmbModelRot1Change
TabOrder = 6
Text = 'cmbModelRot1'
Text = ''
end
object chkRot1AzMinMax: TCheckBox
AnchorSideLeft.Control = chkRot1RunRotCtld
@ -4276,7 +4276,7 @@ object frmPreferences: TfrmPreferences
ItemHeight = 0
OnChange = cmbModelRot2Change
TabOrder = 6
Text = 'cmbModelRot2'
Text = ''
end
object chkRot2AzMinMax: TCheckBox
AnchorSideLeft.Control = chkRot2RunRotCtld
@ -4335,61 +4335,94 @@ object frmPreferences: TfrmPreferences
end
object tabModes: TTabSheet
Caption = 'Modes'
ClientHeight = 672
ClientWidth = 836
ClientHeight = 621
ClientWidth = 845
object GroupBox35: TGroupBox
Left = 14
AnchorSideLeft.Control = tabModes
AnchorSideTop.Control = GroupBox39
AnchorSideTop.Side = asrBottom
Left = 12
Height = 73
Top = 267
Top = 266
Width = 561
BorderSpacing.Left = 12
BorderSpacing.Top = 24
Caption = ' User defined digital modes (use , as delimitter)'
ClientHeight = 55
ClientWidth = 559
TabOrder = 0
object edtDigiModes: TEdit
Left = 7
AnchorSideLeft.Control = GroupBox35
AnchorSideTop.Control = GroupBox35
Left = 6
Height = 34
Top = 15
Top = 6
Width = 536
BorderSpacing.Left = 6
BorderSpacing.Top = 6
CharCase = ecUppercase
TabOrder = 0
end
end
object GroupBox37: TGroupBox
Left = 14
Height = 224
Top = 11
AnchorSideLeft.Control = tabModes
AnchorSideTop.Control = tabModes
Left = 12
Height = 230
Top = 12
Width = 208
BorderSpacing.Left = 12
BorderSpacing.Top = 12
Caption = ' Radio one '
ClientHeight = 222
ClientHeight = 212
ClientWidth = 206
TabOrder = 1
object Label28: TLabel
Left = 13
AnchorSideLeft.Control = GroupBox37
AnchorSideTop.Control = GroupBox37
Left = 12
Height = 17
Top = 18
Width = 39
Top = 12
Width = 36
BorderSpacing.Left = 12
BorderSpacing.Top = 12
Caption = 'Mode'
ParentColor = False
end
object Label29: TLabel
Left = 77
AnchorSideLeft.Control = Label28
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Label28
Left = 81
Height = 17
Top = 18
Width = 72
Top = 12
Width = 69
BorderSpacing.Left = 33
Caption = 'Bandwidth'
ParentColor = False
end
object Label30: TLabel
Left = 11
AnchorSideLeft.Control = Label28
AnchorSideTop.Control = edtCW1
AnchorSideTop.Side = asrCenter
Left = 12
Height = 17
Top = 43
Width = 23
Top = 45
Width = 22
Caption = 'CW'
ParentColor = False
end
object edtCW1: TSpinEdit
Left = 77
AnchorSideLeft.Control = Label29
AnchorSideTop.Control = Label29
AnchorSideRight.Control = Label29
AnchorSideRight.Side = asrBottom
Left = 81
Height = 34
Top = 39
Width = 81
Top = 36
Width = 69
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 24
Increment = 50
MaxValue = 100000
MinValue = -1
@ -4397,24 +4430,40 @@ object frmPreferences: TfrmPreferences
Value = 500
end
object Label35: TLabel
Left = 169
AnchorSideLeft.Control = edtCW1
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = edtCW1
AnchorSideTop.Side = asrCenter
Left = 156
Height = 17
Top = 43
Top = 45
Width = 17
BorderSpacing.Left = 6
Caption = 'Hz'
ParentColor = False
end
object Label36: TLabel
Left = 169
AnchorSideLeft.Control = Label35
AnchorSideTop.Control = edtSSB1
AnchorSideTop.Side = asrCenter
Left = 156
Height = 17
Top = 75
Top = 79
Width = 17
Caption = 'Hz'
ParentColor = False
end
object edtSSB1: TSpinEdit
Left = 77
AnchorSideLeft.Control = edtCW1
AnchorSideTop.Control = edtCW1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = edtCW1
AnchorSideRight.Side = asrBottom
Left = 81
Height = 34
Top = 71
Width = 81
Top = 70
Width = 69
Anchors = [akTop, akLeft, akRight]
Increment = 50
MaxValue = 100000
MinValue = -1
@ -4422,24 +4471,38 @@ object frmPreferences: TfrmPreferences
Value = 1800
end
object Label31: TLabel
Left = 10
AnchorSideLeft.Control = Label28
AnchorSideTop.Control = edtSSB1
AnchorSideTop.Side = asrCenter
Left = 12
Height = 17
Top = 75
Top = 79
Width = 25
Caption = 'SSB'
ParentColor = False
end
object Label32: TLabel
Left = 11
AnchorSideLeft.Control = Label28
AnchorSideTop.Control = edtRTTY1
AnchorSideTop.Side = asrCenter
Left = 12
Height = 17
Top = 106
Width = 36
Top = 113
Width = 33
Caption = 'RTTY'
ParentColor = False
end
object edtRTTY1: TSpinEdit
Left = 77
AnchorSideLeft.Control = edtCW1
AnchorSideTop.Control = edtSSB1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = edtCW1
AnchorSideRight.Side = asrBottom
Left = 81
Height = 34
Top = 102
Width = 81
Top = 104
Width = 69
Anchors = [akTop, akLeft, akRight]
Increment = 50
MaxValue = 100000
MinValue = -1
@ -4447,24 +4510,38 @@ object frmPreferences: TfrmPreferences
Value = 500
end
object Label37: TLabel
Left = 169
AnchorSideLeft.Control = Label35
AnchorSideTop.Control = edtRTTY1
AnchorSideTop.Side = asrCenter
Left = 156
Height = 17
Top = 106
Top = 104
Width = 17
Caption = 'Hz'
ParentColor = False
end
object Label38: TLabel
Left = 169
AnchorSideLeft.Control = Label35
AnchorSideTop.Control = edtAM1
AnchorSideTop.Side = asrCenter
Left = 156
Height = 17
Top = 139
Top = 147
Width = 17
Caption = 'Hz'
ParentColor = False
end
object edtAM1: TSpinEdit
Left = 77
AnchorSideLeft.Control = edtCW1
AnchorSideTop.Control = edtRTTY1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = edtCW1
AnchorSideRight.Side = asrBottom
Left = 81
Height = 34
Top = 133
Width = 81
Top = 138
Width = 69
Anchors = [akTop, akLeft, akRight]
Increment = 100
MaxValue = 100000
MinValue = -1
@ -4472,24 +4549,38 @@ object frmPreferences: TfrmPreferences
Value = 3000
end
object Label33: TLabel
Left = 11
AnchorSideLeft.Control = Label28
AnchorSideTop.Control = edtAM1
AnchorSideTop.Side = asrCenter
Left = 12
Height = 17
Top = 139
Width = 23
Top = 147
Width = 21
Caption = 'AM'
ParentColor = False
end
object Label34: TLabel
Left = 11
AnchorSideLeft.Control = Label28
AnchorSideTop.Control = edtFM1
AnchorSideTop.Side = asrCenter
Left = 12
Height = 17
Top = 170
Width = 21
Top = 181
Width = 20
Caption = 'FM'
ParentColor = False
end
object edtFM1: TSpinEdit
Left = 77
AnchorSideLeft.Control = edtCW1
AnchorSideTop.Control = edtAM1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = edtCW1
AnchorSideRight.Side = asrBottom
Left = 81
Height = 34
Top = 166
Width = 81
Top = 172
Width = 69
Anchors = [akTop, akLeft, akRight]
Increment = 100
MaxValue = 100000
MinValue = -1
@ -4497,48 +4588,77 @@ object frmPreferences: TfrmPreferences
Value = 2500
end
object Label39: TLabel
Left = 169
AnchorSideLeft.Control = Label35
AnchorSideTop.Control = edtFM1
AnchorSideTop.Side = asrCenter
Left = 156
Height = 17
Top = 170
Top = 181
Width = 17
Caption = 'Hz'
ParentColor = False
end
end
object GroupBox39: TGroupBox
Left = 246
Height = 224
Top = 11
AnchorSideLeft.Control = GroupBox37
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = tabModes
Left = 232
Height = 230
Top = 12
Width = 208
BorderSpacing.Left = 12
BorderSpacing.Top = 12
Caption = ' Radio two '
ClientHeight = 222
ClientHeight = 212
ClientWidth = 206
TabOrder = 2
object Label110: TLabel
Left = 13
AnchorSideLeft.Control = GroupBox39
AnchorSideTop.Control = GroupBox39
Left = 12
Height = 17
Top = 18
Width = 39
Top = 12
Width = 36
BorderSpacing.Left = 12
BorderSpacing.Top = 12
Caption = 'Mode'
ParentColor = False
end
object Label113: TLabel
Left = 77
AnchorSideLeft.Control = Label110
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Label110
Left = 81
Height = 17
Top = 18
Width = 72
Top = 12
Width = 69
BorderSpacing.Left = 33
Caption = 'Bandwidth'
ParentColor = False
end
object Label114: TLabel
Left = 11
AnchorSideLeft.Control = Label110
AnchorSideTop.Control = edtCW2
AnchorSideTop.Side = asrCenter
Left = 12
Height = 17
Top = 43
Width = 23
Top = 45
Width = 22
Caption = 'CW'
ParentColor = False
end
object edtCW2: TSpinEdit
Left = 77
AnchorSideLeft.Control = Label113
AnchorSideTop.Control = Label113
AnchorSideRight.Control = Label113
AnchorSideRight.Side = asrBottom
Left = 81
Height = 34
Top = 39
Width = 81
Top = 36
Width = 69
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 24
Increment = 50
MaxValue = 100000
MinValue = -1
@ -4546,24 +4666,40 @@ object frmPreferences: TfrmPreferences
Value = 500
end
object Label115: TLabel
Left = 169
AnchorSideLeft.Control = edtCW2
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = edtCW2
AnchorSideTop.Side = asrCenter
Left = 156
Height = 17
Top = 43
Top = 45
Width = 17
BorderSpacing.Left = 6
Caption = 'Hz'
ParentColor = False
end
object Label116: TLabel
Left = 169
AnchorSideLeft.Control = Label115
AnchorSideTop.Control = edtSSB2
AnchorSideTop.Side = asrCenter
Left = 156
Height = 17
Top = 75
Top = 79
Width = 17
Caption = 'Hz'
ParentColor = False
end
object edtSSB2: TSpinEdit
Left = 77
AnchorSideLeft.Control = Label113
AnchorSideTop.Control = edtCW2
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Label113
AnchorSideRight.Side = asrBottom
Left = 81
Height = 34
Top = 71
Width = 81
Top = 70
Width = 69
Anchors = [akTop, akLeft, akRight]
Increment = 50
MaxValue = 100000
MinValue = -1
@ -4571,24 +4707,38 @@ object frmPreferences: TfrmPreferences
Value = 1800
end
object Label117: TLabel
Left = 10
AnchorSideLeft.Control = Label110
AnchorSideTop.Control = edtSSB2
AnchorSideTop.Side = asrCenter
Left = 12
Height = 17
Top = 75
Top = 79
Width = 25
Caption = 'SSB'
ParentColor = False
end
object Label118: TLabel
Left = 11
AnchorSideLeft.Control = Label110
AnchorSideTop.Control = edtRTTY2
AnchorSideTop.Side = asrCenter
Left = 12
Height = 17
Top = 106
Width = 36
Top = 113
Width = 33
Caption = 'RTTY'
ParentColor = False
end
object edtRTTY2: TSpinEdit
Left = 77
AnchorSideLeft.Control = Label113
AnchorSideTop.Control = edtSSB2
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Label113
AnchorSideRight.Side = asrBottom
Left = 81
Height = 34
Top = 102
Width = 81
Top = 104
Width = 69
Anchors = [akTop, akLeft, akRight]
Increment = 50
MaxValue = 100000
MinValue = -1
@ -4596,24 +4746,38 @@ object frmPreferences: TfrmPreferences
Value = 500
end
object Label119: TLabel
Left = 169
AnchorSideLeft.Control = Label115
AnchorSideTop.Control = edtRTTY2
AnchorSideTop.Side = asrCenter
Left = 156
Height = 17
Top = 106
Top = 113
Width = 17
Caption = 'Hz'
ParentColor = False
end
object Label120: TLabel
Left = 169
AnchorSideLeft.Control = Label115
AnchorSideTop.Control = edtAM2
AnchorSideTop.Side = asrCenter
Left = 156
Height = 17
Top = 139
Top = 147
Width = 17
Caption = 'Hz'
ParentColor = False
end
object edtAM2: TSpinEdit
Left = 77
AnchorSideLeft.Control = Label113
AnchorSideTop.Control = edtRTTY2
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Label113
AnchorSideRight.Side = asrBottom
Left = 81
Height = 34
Top = 133
Width = 81
Top = 138
Width = 69
Anchors = [akTop, akLeft, akRight]
Increment = 100
MaxValue = 100000
MinValue = -1
@ -4621,24 +4785,38 @@ object frmPreferences: TfrmPreferences
Value = 3000
end
object Label121: TLabel
Left = 11
AnchorSideLeft.Control = Label110
AnchorSideTop.Control = edtAM2
AnchorSideTop.Side = asrCenter
Left = 12
Height = 17
Top = 139
Width = 23
Top = 147
Width = 21
Caption = 'AM'
ParentColor = False
end
object Label122: TLabel
Left = 11
AnchorSideLeft.Control = Label110
AnchorSideTop.Control = edtFM2
AnchorSideTop.Side = asrCenter
Left = 12
Height = 17
Top = 170
Width = 21
Top = 181
Width = 20
Caption = 'FM'
ParentColor = False
end
object edtFM2: TSpinEdit
Left = 77
AnchorSideLeft.Control = Label113
AnchorSideTop.Control = edtAM2
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Label113
AnchorSideRight.Side = asrBottom
Left = 81
Height = 34
Top = 166
Width = 81
Top = 172
Width = 69
Anchors = [akTop, akLeft, akRight]
Increment = 100
MaxValue = 100000
MinValue = -1
@ -4646,11 +4824,15 @@ object frmPreferences: TfrmPreferences
Value = 2500
end
object Label123: TLabel
Left = 169
AnchorSideLeft.Control = Label115
AnchorSideTop.Control = edtFM2
AnchorSideTop.Side = asrCenter
Left = 156
Height = 17
Top = 170
Top = 181
Width = 17
Caption = 'Hz'
ParentColor = False
end
end
end

View File

@ -366,6 +366,8 @@ begin
frmBandMap.CurrentBand := b;
frmBandMap.CurrentFreq := f * 1000;
frmBandMap.CurrentMode := m;
if Assigned(radio) then
pnlPower.Enabled:=radio.Power;
end;
function TfrmTRXControl.GetModeNumber(mode : String) : Cardinal;
@ -669,7 +671,6 @@ begin
end
else begin
pnlPower.Visible := True;
btPonClick(nil); //setting buttons visible sends PwrOn to sync button colors
mnuShowPwr.Checked := True;
end;
cqrini.WriteBool('TRX', 'PowerButtons', pnlPower.Visible);
@ -1087,36 +1088,34 @@ begin
pnlPower.Visible := cqrini.ReadBool('TRX', 'PowerButtons', False);
mnuShowPwr.Checked := pnlPower.Visible;
if pnlPower.Visible then btPonClick(nil);
// all rigs do not support rigctld power switching
//so we just put pwr button ON and send rigctld PWR ON cmd
//if rig does not support it that makes no harm.
//if supports we do know pwr state from now on.
if not radio.Connected then
begin
FreeAndNil(radio);
end
begin
FreeAndNil(radio);
end
else //radio changed, restart CW interface
begin
//we check this again although preferences prevent false setting
if (cqrini.ReadBool('CW', 'NoReset', False) //is set: user does not want reset
and (cqrini.ReadInteger('CW', 'Type1', 0) =
cqrini.ReadInteger('CW', 'Type2', 0)) //both keyers are same
and (cqrini.ReadInteger('CW', 'Type1', 0) <> 4) //type is not HamLib
) then //no restart keyer it is same device for both radios.
begin
if ((dmData.DebugLevel >= 1) or ((abs(dmData.DebugLevel) and 8) = 8)) then
Writeln('User ask: No reset and keyer not Hamlib: No restart by TRControl radio'
+ n + ' change');
end
else begin
frmNewQSO.InitializeCW;
if ((dmData.DebugLevel >= 1) or ((abs(dmData.DebugLevel) and 8) = 8)) then
Writeln('CW keyer reloaded by TRControl radio' + n + ' change');
end;
//we check this again although preferences prevent false setting
if (cqrini.ReadBool('CW', 'NoReset', False) //is set: user does not want reset
and (cqrini.ReadInteger('CW', 'Type1', 0) =
cqrini.ReadInteger('CW', 'Type2', 0)) //both keyers are same
and (cqrini.ReadInteger('CW', 'Type1', 0) <> 4) //type is not HamLib
) then //no restart keyer it is same device for both radios.
begin
if ((dmData.DebugLevel >= 1) or ((abs(dmData.DebugLevel) and 8) = 8)) then
Writeln('User ask: No reset and keyer not Hamlib: No restart by TRControl radio'
+ n + ' change');
end
else
Begin
frmNewQSO.InitializeCW;
if ((dmData.DebugLevel >= 1) or ((abs(dmData.DebugLevel) and 8) = 8)) then
Writeln('CW keyer reloaded by TRControl radio' + n + ' change');
end;
end;
end;
end;
procedure TfrmTRXControl.SetMode(mode : String; bandwidth : Integer);
@ -1425,20 +1424,24 @@ begin
if Assigned(radio) then
begin
case radio.GetCurrVFO of
if radio.CanGetVfo then
begin
case radio.GetCurrVFO of
VFOA: begin
btnVFOA.Font.Color := clRed;
btnVFOB.Font.Color := clDefault;
end;
btnVFOA.Font.Color := clRed;
btnVFOB.Font.Color := clDefault;
end;
VFOB: begin
btnVFOB.Font.Color := clRed;
btnVFOA.Font.Color := clDefault;
btnVFOB.Font.Color := clRed;
btnVFOA.Font.Color := clDefault;
end;
end;
else begin
btnVFOB.Font.Color := clDefault;
btnVFOA.Font.Color := clDefault;
end;
end;
end
else
begin
btnVFOB.Font.Color := clDefault;
btnVFOA.Font.Color := clDefault;
end;
end;
end;

View File

@ -5,11 +5,11 @@ unit uRigControl;
interface
uses
Classes, SysUtils, Process, ExtCtrls, lNetComponents, lnet;
Classes, SysUtils, Process, ExtCtrls, lNetComponents, lnet,Forms;
type TRigMode = record
mode : String[10];
pass : word;
pass : integer; //this can not be word as rigctld uses "-1"="keep as is" IntToStr gives 65535 for word with -1
raw : String[10];
end;
@ -20,7 +20,7 @@ type
TExplodeArray = Array of String;
type TRigControl = class
rcvdFreqMode : TLTCPComponent;
RigctldConnect : TLTCPComponent;
rigProcess : TProcess;
tmrRigPoll : TTimer;
private
@ -40,15 +40,21 @@ type TRigControl = class
RigCommand : TStringList;
fRigSendCWR : Boolean;
fRigChkVfo : Boolean;
BadRcvd : Integer;
fRXOffset : Double;
fTXOffset : Double;
fMorse : boolean;
fPower : boolean;
fGetVfo : boolean;
AllowCommand : integer; //things to do before start polling
function RigConnected : Boolean;
function StartRigctld : Boolean;
function Explode(const cSeparator, vString: String): TExplodeArray;
procedure OnReceivedRcvdFreqMode(aSocket: TLSocket);
procedure OnReceivedRigctldConnect(aSocket: TLSocket);
procedure OnConnectRigctldConnect(aSocket: TLSocket);
procedure OnRigPollTimer(Sender: TObject);
public
@ -82,8 +88,14 @@ public
//poll rate in milliseconds
property RigSendCWR : Boolean read fRigSendCWR write fRigSendCWR;
//send CWR instead of CW
property RigChkVfo : Boolean read fRigChkVfo write fRigChkVfo;
property RigChkVfo : Boolean read fRigChkVfo write fRigChkVfo;
//test if rigctld "--vfo" start parameter is used
property Morse : Boolean read fMorse;
//can rig send CW
property Power : Boolean read fPower;
//can rig switch power
property CanGetVfo : Boolean read fGetVfo;
//can rig show vfo (many Icoms can not)
property LastError : String read fLastError;
//last error during operation
@ -135,15 +147,15 @@ begin
fRigCtldPort := 4532;
fRigPoll := 500;
fRunRigCtld := True;
rcvdFreqMode := TLTCPComponent.Create(nil);
RigctldConnect := TLTCPComponent.Create(nil);
rigProcess := TProcess.Create(nil);
tmrRigPoll := TTimer.Create(nil);
tmrRigPoll.Enabled := False;
VfoStr := ''; //defaults to non-"--vfo" (legacy) mode
if DebugMode then Writeln('All objects created');
tmrRigPoll.OnTimer := @OnRigPollTimer;
BadRcvd := 0;
rcvdFreqMode.OnReceive := @OnReceivedRcvdFreqMode
RigctldConnect.OnReceive := @OnReceivedRigctldConnect;
RigctldConnect.OnConnect := @OnConnectRigctldConnect;
end;
function TRigControl.StartRigctld : Boolean;
@ -192,6 +204,7 @@ end;
function TRigControl.RigConnected : Boolean;
const
ERR_MSG = 'Could not connect to rigctld';
begin
if fDebugMode then
begin
@ -221,34 +234,36 @@ begin
}
if fRunRigCtld then
begin
begin
if not StartRigctld then
begin
if fDebugMode then Writeln('rigctld failed to start!');
Result := False;
exit
end else
if fDebugMode then Writeln('rigctld started!');
end else
if fDebugMode then Writeln('Not started rigctld process. (Run is set FALSE)');
begin
if fDebugMode then Writeln('rigctld failed to start!');
Result := False;
exit
end
else
if fDebugMode then Writeln('rigctld started!');
end
else
if fDebugMode then Writeln('Not started rigctld process. (Run is set FALSE)');
rcvdFreqMode.Host := fRigCtldHost;
rcvdFreqMode.Port := fRigCtldPort;
RigctldConnect.Host := fRigCtldHost;
RigctldConnect.Port := fRigCtldPort;
//rcvdFreqMode.Connect(fRigCtldHost,fRigCtldPort);
if rcvdFreqMode.Connect(fRigCtldHost,fRigCtldPort) then
if RigctldConnect.Connect(fRigCtldHost,fRigCtldPort) then //this does not work as connection indicator, is always true!!
//even when it can not connect rigctld.
begin
if fDebugMode then Writeln('Connected to rigctld @ ',fRigCtldHost,':',fRigCtldPort);
if fDebugMode then Writeln('Waiting for rigctld @ ',fRigCtldHost,':',fRigCtldPort);
result := True;
ParmVfoChkd:= not(RigChkVfo); //default: check of "--vfo" not done is false, assigned by preferences not(RigVfoChk)
AllowCommand:=-1;
ParmHasVfo:=0; //default: "--vfo" is not used as start parameter
tmrRigPoll.Interval := fRigPoll;
tmrRigPoll.Enabled := True;
RigCommand.Clear;
end
else begin
if fDebugMode then Writeln('NOT connected to rigctld @ ',fRigCtldHost,':',fRigCtldPort);
if fDebugMode then Writeln('ERROR: *NOT* connected to rigctld @ ',fRigCtldHost,':',fRigCtldPort);
fLastError := ERR_MSG;
Result := False
end
@ -263,64 +278,77 @@ begin
VFOB : Begin
RigCommand.Add('V VFOB');//sendCommand.SendMessage('V VFOB'+LineEnding);
end;
end //case
end; //case
AllowCommand:=1; //call queue
end;
procedure TRigControl.SetModePass(mode : TRigMode);
begin
if (mode.mode='CW') and fRigSendCWR then
mode.mode := 'CWR';
RigCommand.Add('+M'+VfoStr+' '+mode.mode+' '+IntToStr(mode.pass))
RigCommand.Add('+M'+VfoStr+' '+mode.mode+' '+IntToStr(mode.pass));
AllowCommand:=1; //call queue
end;
procedure TRigControl.SetFreqKHz(freq : Double);
begin
RigCommand.Add('+F'+VfoStr+' '+FloatToStr(freq*1000-TXOffset*1000000))
RigCommand.Add('+F'+VfoStr+' '+FloatToStr(freq*1000-TXOffset*1000000));
AllowCommand:=1; //call queue
end;
procedure TRigControl.ClearRit;
begin
RigCommand.Add('+J'+VfoStr+' 0')
RigCommand.Add('+J'+VfoStr+' 0');
AllowCommand:=1; //call queue
end;
procedure TRigControl.DisableRit;
Begin
RigCommand.Add('+U'+VfoStr+' RIT 0');
AllowCommand:=1; //call queue
end;
procedure TRigControl.SetSplit(up:integer);
Begin
RigCommand.Add('+Z'+VfoStr+' '+IntToStr(up));
RigCommand.Add('+U'+VfoStr+' XIT 1');
AllowCommand:=1; //call queue
end;
procedure TRigControl.ClearXit;
begin
RigCommand.Add('+Z'+VfoStr+' 0')
RigCommand.Add('+Z'+VfoStr+' 0');
AllowCommand:=1; //call queue
end;
procedure TRigControl.DisableSplit;
Begin
RigCommand.Add('+U'+VfoStr+' XIT 0');
AllowCommand:=1; //call queue
end;
procedure TRigControl.PttOn;
begin
RigCommand.Add('+T'+VfoStr+' 1')
RigCommand.Add('+T'+VfoStr+' 1');
AllowCommand:=1; //call queue
end;
procedure TRigControl.PttOff;
begin
RigCommand.Add('+T'+VfoStr+' 0')
RigCommand.Add('+T'+VfoStr+' 0');
AllowCommand:=1; //call queue
end;
procedure TRigControl.PwrOn;
begin
RigCommand.Add(#$87+' 1')
AllowCommand:=8; //high prority passes -1 state
end;
procedure TRigControl.PwrOff;
begin
RigCommand.Add(#$87+' 0')
RigCommand.Add('+\set_powerstat 0');
AllowCommand:=1; //call queue
end;
procedure TRigControl.PwrStBy;
begin
RigCommand.Add(#$87+' 2')
RigCommand.Add('+\set_powerstat 2');
AllowCommand:=1; //call queue
end;
procedure TRigControl.UsrCmd(cmd:String);
begin
RigCommand.Add(cmd)
RigCommand.Add(cmd);
AllowCommand:=1; //call queue
end;
function TRigControl.GetCurrVFO : TVFO;
begin
@ -431,7 +459,7 @@ begin
result := fFreq
end;
procedure TRigControl.OnReceivedRcvdFreqMode(aSocket: TLSocket);
procedure TRigControl.OnReceivedRigctldConnect(aSocket: TLSocket);
var
msg : String;
a,b : TExplodeArray;
@ -440,20 +468,10 @@ var
begin
if aSocket.GetMessage(msg) > 0 then
begin
//Writeln('Whole MSG:|',msg,'|');
msg := upcase(trim(msg)); //note the char case!
msg := StringReplace(upcase(trim(msg)),#$09,' ',[rfReplaceAll]); //note the char case upper for now on! Remove TABs
if DebugMode then
Writeln('Msg from rig: ',msg);
if not ParmVfoChkd then
Begin
ParmVfoChkd:=true;
if (msg[1]='1') then ParmHasVfo := 1; //Hamlib 4.3
if (pos('CHKVFO 1',msg)>0) then ParmHasVfo := 2; //Hamlib 3.3
if DebugMode then Writeln('"--vfo" checked:',ParmHasVfo);
if ParmHasVfo > 0 then VfoStr:=' currVFO'; //note set leading one space to string!
end;
Writeln('Msg from rig:|',msg,'|'+LineEnding);
a := Explode(LineEnding,msg);
for i:=0 to Length(a)-1 do //this handles received message line by line
@ -469,10 +487,10 @@ begin
if TryStrToFloat(b[1],f) then
Begin
fFReq := f;
BadRcvd := 0;
end
else
fFReq := 0;
AllowCommand:=1; //check pending commands
end;
if b[0]='MODE:' then
@ -482,7 +500,8 @@ begin
if (fMode.mode = 'USB') or (fMode.mode = 'LSB') then
fMode.mode := 'SSB';
if fMode.mode = 'CWR' then
fMode.mode := 'CW'
fMode.mode := 'CW';
AllowCommand:=1;
end;
//FT-920 returned VFO as MEM
@ -504,7 +523,65 @@ begin
else
fVFO := VFOA;
end;
AllowCommand:=1;
end;
if b[0]='CHKVFO:' then //Hamlib 4.3
Begin
ParmVfoChkd:=true;
if b[1]='1' then
ParmHasVfo := 1;
if DebugMode then Writeln('"--vfo" checked:',ParmHasVfo);
if ParmHasVfo > 0 then VfoStr:=' currVFO'; //note set leading one space to string!
AllowCommand:=9; //next dump caps
end;
if b[0]='CHKVFO' then //Hamlib 3.1
Begin
ParmVfoChkd:=true;
if b[1]='1' then
ParmHasVfo := 2;
if DebugMode then Writeln('"--vfo" checked:',ParmHasVfo);
if ParmHasVfo > 0 then VfoStr:=' currVFO'; //note set leading one space to string!
AllowCommand:=9; //next dump caps
end;
if pos('CAN SET POWER STAT:',a[i])>0 then
Begin
fPower:= b[4]='Y';
if DebugMode then Writeln('Switch power: ',fPower);
end;
if pos('CAN GET VFO:',a[i])>0 then
Begin
fGetVfo:= b[3]='Y';
if DebugMode then Writeln(LineEnding+'Get VFO: ',fGetVfo);
end;
if pos('CAN SEND MORSE:',a[i])>0 then
Begin
fMorse:= b[3]='Y';
if DebugMode then Writeln('Send Morse: ',fMorse,LineEnding);
if fPower then
AllowCommand:=8 //issue power on
else
AllowCommand:=1 //check pending commands
end;
if pos('SET_POWERSTAT:',a[i])>0 then
Begin
if pos('1',a[i])>0 then //line may have 'STAT: 1' or 'STAT: CURRVFO 1'
Begin
if DebugMode then Writeln('Power on, start polling');
AllowCommand:=93; //check pending commands via delay
end
else
Begin
if DebugMode then Writeln('Power off, stop polling');
AllowCommand:=-1;
end;
end;
end;
end;
@ -515,42 +592,88 @@ var
cmd : String;
i : Integer;
begin
if not ParmVfoChkd then
RigCommand.Clear; // chk must be first thing to do
case AllowCommand of
//delay up to 10 timer rounds with this selecting one of numbers
99: AllowCommand:=98;
98: AllowCommand:=97;
97: AllowCommand:=96;
96: AllowCommand:=95;
95: AllowCommand:=94;
94: AllowCommand:=93;
93: AllowCommand:=92;
92: AllowCommand:=91;
91: AllowCommand:=1;
if (RigCommand.Text<>'') then
begin
for i:=0 to RigCommand.Count-1 do
begin
sleep(100);
cmd := RigCommand.Strings[i]+LineEnding;
rcvdFreqMode.SendMessage(cmd);
if DebugMode then
Writeln('Sending: '+cmd)
//high priority commands
10: Begin
cmd:='+\chk_vfo'+LineEnding;
if DebugMode then
Writeln('Sending: '+cmd);
RigctldConnect.SendMessage(cmd);
AllowCommand:=-1; //waiting for reply
end;
9: Begin
cmd:='+\dump_caps'+LineEnding;
if DebugMode then
Writeln('Sending: '+cmd);
RigctldConnect.SendMessage(cmd);
AllowCommand:=-1; //waiting for reply
end;
8: Begin
cmd:= '+\set_powerstat 1'+LineEnding;
if DebugMode then
Writeln('Sending: '+cmd);
RigctldConnect.SendMessage(cmd);
AllowCommand:=-1; //waiting for reply
end;
//lower priority commands queue handled here
1: Begin
if (RigCommand.Text<>'') then
begin
for i:=0 to RigCommand.Count-1 do
Begin
cmd := RigCommand.Strings[i]+LineEnding;
RigctldConnect.SendMessage(cmd);
if DebugMode then
Writeln('Queue Sending: [',i,'] '+cmd);
end
end;
RigCommand.Clear;
AllowCommand:=0; //polling
end;
//polling has lowest prority, do if there is nothing else to do
0: begin
if ParmHasVfo=2 then
cmd := '+f'+VfoStr+' +m'+VfoStr+' +v'+VfoStr+LineEnding //chk this with rigctld v3.1
else
cmd := '+f'+VfoStr+' +m'+VfoStr+' +v'+LineEnding;
if DebugMode then
Writeln('Poll Sending: '+cmd);
RigctldConnect.SendMessage(cmd);
AllowCommand:=-1; //waiting for reply
end;
end;//case
end;
procedure TRigControl.OnConnectRigctldConnect(aSocket: TLSocket);
Begin
if DebugMode then
Writeln('Connected to rigctld');
if RigChkVfo then
Begin
AllowCommand:=10; //start with chkvfo
ParmVfoChkd:=false;
end
else
Begin
AllowCommand:=9; //otherwise start with dump caps
ParmVfoChkd:=false;
end;
RigCommand.Clear
end
else
begin
if not ParmVfoChkd then
cmd := '\chk_vfo'+LineEnding
else
if ParmHasVfo=2 then
cmd := '+f'+VfoStr+' +m'+VfoStr+' +v'+VfoStr+LineEnding //chk this with rigctld v3.1
else
cmd := '+f'+VfoStr+' +m'+VfoStr+' +v'+LineEnding;
if DebugMode then
Writeln('Poll Sending: '+cmd);
rcvdFreqMode.SendMessage(cmd)
end;
inc(BadRcvd); //we use this now as "no freq reply" counter
if BadRcvd > 10 then // if missed to get frequency during 10 polls, rig connection is dead(?)
Begin
fFReq := 0;
BadRcvd := 10; // prevent overflow
end;
RigCommand.Clear;
end;
procedure TRigControl.Restart;
@ -559,7 +682,7 @@ var
begin
rigProcess.Terminate(excode);
tmrRigPoll.Enabled := False;
rcvdFreqMode.Disconnect();
RigctldConnect.Disconnect();
RigConnected
end;
@ -591,7 +714,7 @@ var
excode : Integer=0;
begin
inherited;
if DebugMode then Writeln(1);
if DebugMode then Writeln('Destroy rigctld'+LineEnding+'1');
if fRunRigCtld then
begin
if rigProcess.Running then
@ -603,13 +726,13 @@ begin
if DebugMode then Writeln(2);
tmrRigPoll.Enabled := False;
if DebugMode then Writeln(3);
rcvdFreqMode.Disconnect();
RigctldConnect.Disconnect();
if DebugMode then Writeln(4);
FreeAndNil(rcvdFreqMode);
FreeAndNil(RigctldConnect);
if DebugMode then Writeln(5);
FreeAndNil(rigProcess);
FreeAndNil(RigCommand);
if DebugMode then Writeln(6)
if DebugMode then Writeln('6'+LineEnding+'Done!')
end;
end.