|
1 |
| -using CoordinateConverter.DCS.Communication; |
2 |
| -using Newtonsoft.Json; |
| 1 | +using Newtonsoft.Json; |
3 | 2 | using System;
|
4 | 3 | using System.Collections.Generic;
|
5 | 4 | using System.Linq;
|
@@ -49,6 +48,13 @@ private void Init()
|
49 | 48 | AH64RadioPresetData presetData = new AH64RadioPresetData();
|
50 | 49 | presetDataDictionary.Add(preset, presetData);
|
51 | 50 | }
|
| 51 | + |
| 52 | + var ps1 = presetDataDictionary[EPreset.Preset1]; |
| 53 | + vhfManualFrequency = new RadioFrequency(ps1.VHFFrequency, ps1.VHFFrequencyMinimum, ps1.VHFFrequencyMaximum, ps1.VHFFrequencyIncrement); |
| 54 | + uhfManualFrequency = new RadioFrequency(ps1.UHFFrequency, ps1.UHFFrequencyMinimum, ps1.UHFFrequencyMaximum, ps1.UHFFrequencyIncrement); |
| 55 | + fm1ManualFrequency = new RadioFrequency(ps1.FM1Frequency, ps1.FM1FrequencyMinimum, ps1.FM1FrequencyMaximum, ps1.FM1FrequencyIncrement); |
| 56 | + fm2ManualFrequency = new RadioFrequency(ps1.FM2Frequency, ps1.FM2FrequencyMinimum, ps1.FM2FrequencyMaximum, ps1.FM2FrequencyIncrement); |
| 57 | + hfrxManualFrequency = new RadioFrequency(ps1.HFRXFrequency, ps1.HFRXFrequencyMinimum, ps1.HFRXFrequencyMaximum, ps1.HFRXFrequencyIncrement); |
52 | 58 | }
|
53 | 59 |
|
54 | 60 | /// <summary>
|
@@ -139,6 +145,241 @@ public void SetAH64RadioPresetData(EPreset preset, AH64RadioPresetData presetDat
|
139 | 145 |
|
140 | 146 | #endregion
|
141 | 147 |
|
| 148 | + #region Tune |
| 149 | + /// <summary> |
| 150 | + /// A Radio Tune Setting |
| 151 | + /// </summary> |
| 152 | + public enum ETuneSetting |
| 153 | + { |
| 154 | + /// <summary> |
| 155 | + /// Don't tune the radio |
| 156 | + /// </summary> |
| 157 | + No_Change, |
| 158 | + /// <summary> |
| 159 | + /// Tune a radio to a preset |
| 160 | + /// </summary> |
| 161 | + Preset, |
| 162 | + /// <summary> |
| 163 | + /// Tune a radio to a manual frequency |
| 164 | + /// </summary> |
| 165 | + Manual |
| 166 | + } |
| 167 | + |
| 168 | + /// <summary> |
| 169 | + /// Gets a value indicating whether any radio is to be tuned. |
| 170 | + /// </summary> |
| 171 | + /// <value> |
| 172 | + /// <c>true</c> if any radio is to be tuned; otherwise, <c>false</c>. |
| 173 | + /// </value> |
| 174 | + [JsonIgnore] |
| 175 | + public bool ContainsTuningData |
| 176 | + { |
| 177 | + get |
| 178 | + { |
| 179 | + return VHFTuneSetting != ETuneSetting.No_Change |
| 180 | + || UHFTuneSetting != ETuneSetting.No_Change |
| 181 | + || FM1TuneSetting != ETuneSetting.No_Change |
| 182 | + || FM2TuneSetting != ETuneSetting.No_Change |
| 183 | + || HFTuneSetting != ETuneSetting.No_Change; |
| 184 | + } |
| 185 | + } |
| 186 | + |
| 187 | + /// <summary> |
| 188 | + /// Gets a value indicating whether any one radio will be tuned manually. |
| 189 | + /// </summary> |
| 190 | + /// <value> |
| 191 | + /// <c>true</c> if any one radio will be tuned manually; otherwise, <c>false</c>. |
| 192 | + /// </value> |
| 193 | + [JsonIgnore] |
| 194 | + public bool ContainsManualTune |
| 195 | + { |
| 196 | + get |
| 197 | + { |
| 198 | + return VHFTuneSetting == ETuneSetting.Manual |
| 199 | + || UHFTuneSetting == ETuneSetting.Manual |
| 200 | + || FM1TuneSetting == ETuneSetting.Manual |
| 201 | + || FM2TuneSetting == ETuneSetting.Manual |
| 202 | + || HFTuneSetting == ETuneSetting.Manual; |
| 203 | + } |
| 204 | + } |
| 205 | + |
| 206 | + // VHF |
| 207 | + |
| 208 | + /// <summary> |
| 209 | + /// Gets or sets the VHF tune setting. |
| 210 | + /// </summary> |
| 211 | + /// <value> |
| 212 | + /// The VHF tune setting. |
| 213 | + /// </value> |
| 214 | + public ETuneSetting VHFTuneSetting { get; set; } = ETuneSetting.No_Change; |
| 215 | + /// <summary> |
| 216 | + /// Gets or sets the VHF tune preset. |
| 217 | + /// </summary> |
| 218 | + /// <value> |
| 219 | + /// The VHF tune preset. |
| 220 | + /// </value> |
| 221 | + public EPreset VHFTunePreset { get; set; } = EPreset.Preset1; |
| 222 | + private RadioFrequency vhfManualFrequency = null; |
| 223 | + /// <summary> |
| 224 | + /// Gets or sets the VHF manual frequency. |
| 225 | + /// </summary> |
| 226 | + /// <value> |
| 227 | + /// The VHF manual frequency. |
| 228 | + /// </value> |
| 229 | + public decimal VHFManualFrequency |
| 230 | + { |
| 231 | + get |
| 232 | + { |
| 233 | + return vhfManualFrequency.Frequency; |
| 234 | + } |
| 235 | + set |
| 236 | + { |
| 237 | + vhfManualFrequency.Frequency = value; |
| 238 | + } |
| 239 | + } |
| 240 | + |
| 241 | + // UHF |
| 242 | + |
| 243 | + /// <summary> |
| 244 | + /// Gets or sets the uhf tune setting. |
| 245 | + /// </summary> |
| 246 | + /// <value> |
| 247 | + /// The uhf tune setting. |
| 248 | + /// </value> |
| 249 | + public ETuneSetting UHFTuneSetting { get; set; } = ETuneSetting.No_Change; |
| 250 | + /// <summary> |
| 251 | + /// Gets or sets the uhf tune preset. |
| 252 | + /// </summary> |
| 253 | + /// <value> |
| 254 | + /// The uhf tune preset. |
| 255 | + /// </value> |
| 256 | + public EPreset UHFTunePreset { get; set; } = EPreset.Preset2; |
| 257 | + private RadioFrequency uhfManualFrequency = null; |
| 258 | + /// <summary> |
| 259 | + /// Gets or sets the uhf manual frequency. |
| 260 | + /// </summary> |
| 261 | + /// <value> |
| 262 | + /// The uhf manual frequency. |
| 263 | + /// </value> |
| 264 | + public decimal UHFManualFrequency |
| 265 | + { |
| 266 | + get |
| 267 | + { |
| 268 | + return uhfManualFrequency.Frequency; |
| 269 | + } |
| 270 | + set |
| 271 | + { |
| 272 | + uhfManualFrequency.Frequency = value; |
| 273 | + } |
| 274 | + } |
| 275 | + |
| 276 | + // FM 1 |
| 277 | + |
| 278 | + /// <summary> |
| 279 | + /// Gets or sets the f m1 tune setting. |
| 280 | + /// </summary> |
| 281 | + /// <value> |
| 282 | + /// The f m1 tune setting. |
| 283 | + /// </value> |
| 284 | + public ETuneSetting FM1TuneSetting { get; set; } = ETuneSetting.No_Change; |
| 285 | + /// <summary> |
| 286 | + /// Gets or sets the fm 1 tune preset. |
| 287 | + /// </summary> |
| 288 | + /// <value> |
| 289 | + /// The fm 1 tune preset. |
| 290 | + /// </value> |
| 291 | + public EPreset FM1TunePreset { get; set; } = EPreset.Preset3; |
| 292 | + private RadioFrequency fm1ManualFrequency = null; |
| 293 | + /// <summary> |
| 294 | + /// Gets or sets the f m1 manual frequency. |
| 295 | + /// </summary> |
| 296 | + /// <value> |
| 297 | + /// The f m1 manual frequency. |
| 298 | + /// </value> |
| 299 | + public decimal FM1ManualFrequency |
| 300 | + { |
| 301 | + get |
| 302 | + { |
| 303 | + return fm1ManualFrequency.Frequency; |
| 304 | + } |
| 305 | + set |
| 306 | + { |
| 307 | + fm1ManualFrequency.Frequency = value; |
| 308 | + } |
| 309 | + } |
| 310 | + |
| 311 | + // FM 2 |
| 312 | + |
| 313 | + /// <summary> |
| 314 | + /// Gets or sets the fm 2 tune setting. |
| 315 | + /// </summary> |
| 316 | + /// <value> |
| 317 | + /// The fm 2 tune setting. |
| 318 | + /// </value> |
| 319 | + public ETuneSetting FM2TuneSetting { get; set; } = ETuneSetting.No_Change; |
| 320 | + /// <summary> |
| 321 | + /// Gets or sets the fm 2 tune preset. |
| 322 | + /// </summary> |
| 323 | + /// <value> |
| 324 | + /// The fm 2 tune preset. |
| 325 | + /// </value> |
| 326 | + public EPreset FM2TunePreset { get; set; } = EPreset.Preset4; |
| 327 | + private RadioFrequency fm2ManualFrequency = null; |
| 328 | + /// <summary> |
| 329 | + /// Gets or sets the fm 2 manual frequency. |
| 330 | + /// </summary> |
| 331 | + /// <value> |
| 332 | + /// The fm 2 manual frequency. |
| 333 | + /// </value> |
| 334 | + public decimal FM2ManualFrequency |
| 335 | + { |
| 336 | + get |
| 337 | + { |
| 338 | + return fm2ManualFrequency.Frequency; |
| 339 | + } |
| 340 | + set |
| 341 | + { |
| 342 | + fm2ManualFrequency.Frequency = value; |
| 343 | + } |
| 344 | + } |
| 345 | + |
| 346 | + // HF |
| 347 | + |
| 348 | + /// <summary> |
| 349 | + /// Gets or sets the hf tune setting. |
| 350 | + /// </summary> |
| 351 | + /// <value> |
| 352 | + /// The hf tune setting. |
| 353 | + /// </value> |
| 354 | + public ETuneSetting HFTuneSetting { get; set; } = ETuneSetting.No_Change; |
| 355 | + /// <summary> |
| 356 | + /// Gets or sets the hf tune preset. |
| 357 | + /// </summary> |
| 358 | + /// <value> |
| 359 | + /// The hf tune preset. |
| 360 | + /// </value> |
| 361 | + public EPreset HFTunePreset { get; set; } = EPreset.Preset5; |
| 362 | + private RadioFrequency hfrxManualFrequency = null; |
| 363 | + /// <summary> |
| 364 | + /// Gets or sets the HF RX manual frequency. |
| 365 | + /// </summary> |
| 366 | + /// <value> |
| 367 | + /// The HF RX manual frequency. |
| 368 | + /// </value> |
| 369 | + public decimal HFRXManualFrequency |
| 370 | + { |
| 371 | + get |
| 372 | + { |
| 373 | + return hfrxManualFrequency.Frequency; |
| 374 | + } |
| 375 | + set |
| 376 | + { |
| 377 | + hfrxManualFrequency.Frequency = value; |
| 378 | + } |
| 379 | + } |
| 380 | + |
| 381 | + #endregion |
| 382 | + |
142 | 383 | #region XPNDR
|
143 | 384 | /// <summary>
|
144 | 385 | /// Gets a value indicating whether [this DTC contains transponder data].
|
@@ -511,7 +752,7 @@ protected override List<DCSCommand> GenerateCommands(object items)
|
511 | 752 | protected override List<DCSCommand> GetActions(object item)
|
512 | 753 | {
|
513 | 754 | var commands = new List<DCSCommand>();
|
514 |
| - // var commands = new DebugCommandList(); |
| 755 | + // var commands = new Communication.DebugCommandList(); |
515 | 756 |
|
516 | 757 | if (ContainsTransponderData)
|
517 | 758 | {
|
@@ -739,6 +980,84 @@ protected override List<DCSCommand> GetActions(object item)
|
739 | 980 | commands.AddRange(kvp.Value.GenerateCommands(kvp.Key, IsPilot));
|
740 | 981 | }
|
741 | 982 |
|
| 983 | + // Tune |
| 984 | + if (ContainsTuningData) |
| 985 | + { |
| 986 | + commands.Add(new DCSCommand(DeviceRMFD, (int)AH64.EKeyCode.MFD_COM)); |
| 987 | + // Presets first |
| 988 | + int presetKey = -1; |
| 989 | + if (VHFTuneSetting == ETuneSetting.Preset) |
| 990 | + { |
| 991 | + presetKey = AH64RadioPresetData.GetKeyForPreset(VHFTunePreset); |
| 992 | + commands.Add(new DCSCommand(DeviceRMFD, presetKey)); |
| 993 | + commands.Add(new DCSCommand(DeviceRMFD, (int)AH64.EKeyCode.MFD_T1)); |
| 994 | + commands.Add(new DCSCommand(DeviceRMFD, (int)AH64.EKeyCode.MFD_B6)); |
| 995 | + commands.Add(new DCSCommand(DeviceRMFD, presetKey)); |
| 996 | + } |
| 997 | + if (UHFTuneSetting == ETuneSetting.Preset) |
| 998 | + { |
| 999 | + presetKey = AH64RadioPresetData.GetKeyForPreset(UHFTunePreset); |
| 1000 | + commands.Add(new DCSCommand(DeviceRMFD, presetKey)); |
| 1001 | + commands.Add(new DCSCommand(DeviceRMFD, (int)AH64.EKeyCode.MFD_T2)); |
| 1002 | + commands.Add(new DCSCommand(DeviceRMFD, (int)AH64.EKeyCode.MFD_B6)); |
| 1003 | + commands.Add(new DCSCommand(DeviceRMFD, presetKey)); |
| 1004 | + } |
| 1005 | + if (FM1TuneSetting == ETuneSetting.Preset) |
| 1006 | + { |
| 1007 | + presetKey = AH64RadioPresetData.GetKeyForPreset(FM1TunePreset); |
| 1008 | + commands.Add(new DCSCommand(DeviceRMFD, presetKey)); |
| 1009 | + commands.Add(new DCSCommand(DeviceRMFD, (int)AH64.EKeyCode.MFD_T3)); |
| 1010 | + commands.Add(new DCSCommand(DeviceRMFD, (int)AH64.EKeyCode.MFD_B6)); |
| 1011 | + commands.Add(new DCSCommand(DeviceRMFD, presetKey)); |
| 1012 | + } |
| 1013 | + if (FM2TuneSetting == ETuneSetting.Preset) |
| 1014 | + { |
| 1015 | + presetKey = AH64RadioPresetData.GetKeyForPreset(FM2TunePreset); |
| 1016 | + commands.Add(new DCSCommand(DeviceRMFD, presetKey)); |
| 1017 | + commands.Add(new DCSCommand(DeviceRMFD, (int)AH64.EKeyCode.MFD_T4)); |
| 1018 | + commands.Add(new DCSCommand(DeviceRMFD, (int)AH64.EKeyCode.MFD_B6)); |
| 1019 | + commands.Add(new DCSCommand(DeviceRMFD, presetKey)); |
| 1020 | + } |
| 1021 | + if (HFTuneSetting == ETuneSetting.Preset) |
| 1022 | + { |
| 1023 | + presetKey = AH64RadioPresetData.GetKeyForPreset(HFTunePreset); |
| 1024 | + commands.Add(new DCSCommand(DeviceRMFD, presetKey)); |
| 1025 | + commands.Add(new DCSCommand(DeviceRMFD, (int)AH64.EKeyCode.MFD_T5)); |
| 1026 | + commands.Add(new DCSCommand(DeviceRMFD, (int)AH64.EKeyCode.MFD_B6)); |
| 1027 | + commands.Add(new DCSCommand(DeviceRMFD, presetKey)); |
| 1028 | + } |
| 1029 | + |
| 1030 | + if (ContainsManualTune) |
| 1031 | + { |
| 1032 | + commands.Add(new DCSCommand(DeviceRMFD, (int)AH64.EKeyCode.MFD_B2)); |
| 1033 | + if (VHFTuneSetting == ETuneSetting.Manual) |
| 1034 | + { |
| 1035 | + commands.Add(new DCSCommand(DeviceRMFD, (int)AH64.EKeyCode.MFD_L1)); |
| 1036 | + commands.AddRange(AH64.GetCommandsForKUText(VHFManualFrequency.ToString() + '\n', true, IsPilot)); |
| 1037 | + } |
| 1038 | + if (UHFTuneSetting == ETuneSetting.Manual) |
| 1039 | + { |
| 1040 | + commands.Add(new DCSCommand(DeviceRMFD, (int)AH64.EKeyCode.MFD_L2)); |
| 1041 | + commands.AddRange(AH64.GetCommandsForKUText(UHFManualFrequency.ToString() + '\n', true, IsPilot)); |
| 1042 | + } |
| 1043 | + if (FM1TuneSetting == ETuneSetting.Manual) |
| 1044 | + { |
| 1045 | + commands.Add(new DCSCommand(DeviceRMFD, (int)AH64.EKeyCode.MFD_L3)); |
| 1046 | + commands.AddRange(AH64.GetCommandsForKUText(FM1ManualFrequency.ToString() + '\n', true, IsPilot)); |
| 1047 | + } |
| 1048 | + if (FM2TuneSetting == ETuneSetting.Manual) |
| 1049 | + { |
| 1050 | + commands.Add(new DCSCommand(DeviceRMFD, (int)AH64.EKeyCode.MFD_L4)); |
| 1051 | + commands.AddRange(AH64.GetCommandsForKUText(FM2ManualFrequency.ToString() + '\n', true, IsPilot)); |
| 1052 | + } |
| 1053 | + if (HFTuneSetting == ETuneSetting.Manual) |
| 1054 | + { |
| 1055 | + commands.Add(new DCSCommand(DeviceRMFD, (int)AH64.EKeyCode.MFD_R1)); |
| 1056 | + commands.AddRange(AH64.GetCommandsForKUText(HFRXManualFrequency.ToString() + '\n', true, IsPilot)); |
| 1057 | + } |
| 1058 | + } |
| 1059 | + } |
| 1060 | + |
742 | 1061 | // WPN
|
743 | 1062 | if (ContainsWeaponData)
|
744 | 1063 | {
|
|
0 commit comments