-
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathRigSettings.cs
More file actions
201 lines (146 loc) · 8.51 KB
/
Copy pathRigSettings.cs
File metadata and controls
201 lines (146 loc) · 8.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
namespace OscarWatch.Core.Models;
public sealed class RigSettings
{
/// <summary>Factory / Hamlib-style default CAT rate for FT-817 and FT-818 (menu #14).</summary>
public const int Ft817818DefaultBaudRate = 4800;
/// <summary>Factory CI-V USB default baud for IC-705 (must match radio menu).</summary>
public const int Ic705DefaultBaudRate = 115200;
/// <summary>Factory CI-V USB default baud for IC-7300 (must match radio menu).</summary>
public const int Ic7300DefaultBaudRate = 115200;
/// <summary>Factory CI-V USB default baud for IC-905 (must match radio Set mode).</summary>
public const int Ic905DefaultBaudRate = 115200;
/// <summary>Typical menu 031 CAT RATE for FT-991 / FT-991A (4800–38400 supported).</summary>
public const int Ft991DefaultBaudRate = 38400;
/// <summary>Typical menu CAT-1 RATE for FTX-1 series (4800–115200 supported).</summary>
public const int Ftx1DefaultBaudRate = 38400;
public static bool IsYaesuNewCatDualEndpoint(RigType type) =>
type is RigType.YaesuFt991 or RigType.YaesuFt991a or RigType.YaesuFtx1;
/// <summary>Typical CI-V baud for IC-706 series (must match radio menu).</summary>
public const int Ic706SeriesDefaultBaudRate = 19200;
/// <summary>Default lead time (ms) when lead Doppler is enabled (0 = automatic half CAT delay).</summary>
public const int DefaultDopplerCatLeadMs = 40;
/// <summary>Default lead strength (%); many operators use 70–85 on fast birds.</summary>
public const int DefaultDopplerCatLeadGainPercent = 70;
public static bool IsIc706SeriesEndpoint(RigType type) =>
type is RigType.IcomIc706 or RigType.IcomIc706Mkii or RigType.IcomIc706MkiiG;
public bool Enabled { get; set; }
/// <summary>When true, downlink and uplink use separate radios (<see cref="Downlink"/> / <see cref="Uplink"/>).</summary>
public bool DualRadioEnabled { get; set; }
public RigEndpointSettings Downlink { get; set; } = new();
public RigEndpointSettings Uplink { get; set; } = new();
public const int FlexSmartSdrDefaultPort = 4992;
public RigType Type { get; set; } = RigType.None;
public string Port { get; set; } = "";
public int BaudRate { get; set; } = 19200;
/// <summary>
/// When true, Kenwood TS-2000 CAT asserts hardware RTS (required for replies on full cables).
/// Ignored for non-Kenwood rig types. Turn off for CAT cables that do not pass RTS/CTS.
/// </summary>
public bool KenwoodHardwareRtsEnabled { get; set; } = true;
/// <summary>
/// When true, SATL SA commands enable TRACE/TRACE REV on the radio.
/// Ignored for non-Kenwood rig types. Turn off to leave Doppler entirely to OscarWatch.
/// </summary>
public bool KenwoodTraceEnabled { get; set; } = true;
/// <summary>TCP host when <see cref="Type"/> is <see cref="RigType.FlexSmartSdr"/>.</summary>
public string NetworkHost { get; set; } = "";
/// <summary>TCP port when <see cref="Type"/> is <see cref="RigType.FlexSmartSdr"/> (default 4992).</summary>
public int NetworkPort { get; set; } = FlexSmartSdrDefaultPort;
/// <summary>Optional Flex radio serial from discovery, used to re-select the same radio.</summary>
public string FlexRadioSerial { get; set; } = "";
/// <summary>SmartSDR RX antenna for VHF downlink/uplink (ANT1, ANT2, RX_A, RX_B, XVTR; empty = leave unchanged).</summary>
public string FlexVhfRxAnt { get; set; } = "";
/// <summary>SmartSDR RX antenna for UHF and above (empty = leave unchanged).</summary>
public string FlexUhfRxAnt { get; set; } = "";
/// <summary>SmartSDR TX antenna for VHF uplink (empty = leave unchanged).</summary>
public string FlexVhfTxAnt { get; set; } = "";
/// <summary>SmartSDR TX antenna for UHF and above (empty = leave unchanged).</summary>
public string FlexUhfTxAnt { get; set; } = "";
/// <summary>CI-V address as hex string (factory default for most ICOM rigs is 60).</summary>
public string CivAddress { get; set; } = "60";
public RigRegion Region { get; set; } = RigRegion.EU;
public int DopplerThresholdFmHz { get; set; } = 350;
public int DopplerThresholdLinearHz { get; set; } = 50;
public int CatDelayMs { get; set; } = 50;
/// <summary>When true, CAT Doppler uses range rate at utc + half Receive/Transmit CatDelayMs on steep legs only.</summary>
public bool DopplerCatLeadEnabled { get; set; } = true;
/// <summary>
/// When true, linear Doppler threshold is lowered while downlink slew is fast (TCA vicinity).
/// Base threshold from <see cref="DopplerThresholdLinearHz"/> is never exceeded.
/// </summary>
public bool DopplerAdaptiveThresholdEnabled { get; set; } = true;
/// <summary>When true, write a CSV pass log for Doppler tuning (CAT writes, lead, adaptive threshold).</summary>
public bool DopplerPassLogEnabled { get; set; }
/// <summary>
/// Lead time in ms (0 = automatic: half CAT delay, capped internally).
/// Does not change CAT pacing delay.
/// </summary>
public int DopplerCatLeadMs { get; set; } = DefaultDopplerCatLeadMs;
/// <summary>Scales computed lead strength (0–100). 100 = full blend; 0 = snapshot rate only.</summary>
public int DopplerCatLeadGainPercent { get; set; } = DefaultDopplerCatLeadGainPercent;
/// <summary>When true, automatic CAT frequency updates are suspended (SatPC32-style).</summary>
public bool CatUpdatesPaused { get; set; }
/// <summary>
/// When the frequency panel CW style is active: keep receive in USB/LSB from the database
/// instead of setting downlink to CW.
/// </summary>
public bool CwKeepSidebandDownlink { get; set; }
public bool IsDualRadio => DualRadioEnabled;
public bool IsDualRadioConfigured =>
DualRadioEnabled && Downlink.IsConfigured && Uplink.IsConfigured;
public static bool IsDualCapableEndpoint(RigType type) =>
IsDualCapableSerialEndpoint(type) || IsSdrDownlinkEndpoint(type);
public static bool IsDualCapableSerialEndpoint(RigType type) =>
type is RigType.YaesuFt817 or RigType.YaesuFt818 or RigType.YaesuFtx1
or RigType.YaesuFt991 or RigType.YaesuFt991a
or RigType.IcomIc705 or RigType.IcomIc7300 or RigType.IcomIc905
or RigType.IcomIc706 or RigType.IcomIc706Mkii or RigType.IcomIc706MkiiG;
public static bool IsSdrDownlinkEndpoint(RigType type) => type == RigType.SdrRigCtlTcp;
public static bool IsFlexNetworkRadio(RigType type) => type == RigType.FlexSmartSdr;
public static bool IsDummyUplinkEndpoint(RigType type) => type == RigType.Dummy;
public bool IsFlexNetworkConfigured =>
IsFlexNetworkRadio(Type)
&& NetworkPort is > 0 and <= 65535
&& !string.IsNullOrWhiteSpace(NetworkHost);
/// <summary>FT-817/818 are dual-radio only; move legacy single-radio config to the downlink endpoint.</summary>
public void MigrateFt817818ToDualOnly()
{
if (DualRadioEnabled || Type is not (RigType.YaesuFt817 or RigType.YaesuFt818))
return;
DualRadioEnabled = true;
Downlink.Type = Type;
Downlink.Port = Port;
Downlink.BaudRate = BaudRate > 0 ? BaudRate : Ft817818DefaultBaudRate;
Downlink.Region = Region;
Downlink.CatDelayMs = CatDelayMs;
Type = RigType.None;
Port = "";
}
/// <summary>Region for RX pass-init tone clear (dual downlink) or single-radio.</summary>
public RigRegion ReceiveRegion() =>
DualRadioEnabled ? Downlink.Region : Region;
/// <summary>Region for uplink CTCSS (dual uplink) or single-radio.</summary>
public RigRegion TransmitRegion() =>
DualRadioEnabled ? Uplink.Region : Region;
/// <summary>CAT delay for downlink / RX writes.</summary>
public int ReceiveCatDelayMs() =>
DualRadioEnabled ? Downlink.CatDelayMs : CatDelayMs;
/// <summary>CAT delay for uplink / TX writes.</summary>
public int TransmitCatDelayMs() =>
DualRadioEnabled ? Uplink.CatDelayMs : CatDelayMs;
/// <summary>Factory CI-V address defaults (9700=A2, 9100/910=7C). User may still use 60.</summary>
public static string DefaultCivAddressFor(RigType type) => type switch
{
RigType.IcomIc9700 => "A2",
RigType.IcomIc9100 => "7C",
RigType.IcomIc910 => "7C",
RigType.IcomIc821h => "4C",
RigType.IcomIc705 => "A4",
RigType.IcomIc7300 => "94",
RigType.IcomIc905 => "AC",
RigType.IcomIc706 => "48",
RigType.IcomIc706Mkii => "4C",
RigType.IcomIc706MkiiG => "58",
_ => "60"
};
}