kopia lustrzana https://github.com/M0LTE/ft8spotter
Support band change
rodzic
f8105105a2
commit
a1a1498487
|
@ -1,4 +1,5 @@
|
|||
using M0LTE.WsjtxUdpLib.Client;
|
||||
using AmateurBandLib;
|
||||
using M0LTE.WsjtxUdpLib.Client;
|
||||
using M0LTE.WsjtxUdpLib.Messages.Out;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
@ -19,6 +20,7 @@ namespace ft8spotter
|
|||
private const string urlKey = "cloudlog_url";
|
||||
|
||||
static ClublogCtyXml ctyXml;
|
||||
static int bandMetres;
|
||||
static void Main(string[] args)
|
||||
{
|
||||
httpClient.DefaultRequestHeaders.UserAgent.TryParseAdd("ft8spotter");
|
||||
|
@ -29,15 +31,6 @@ namespace ft8spotter
|
|||
|
||||
bool grids = args.Any(a => a == "--grids");
|
||||
|
||||
string bandArg = args.SingleOrDefault(a => a.EndsWith("m"));
|
||||
|
||||
if (string.IsNullOrWhiteSpace(bandArg) || !int.TryParse(bandArg.Substring(0, bandArg.Length - 1).Replace("--", ""), out int band))
|
||||
{
|
||||
band = 20;
|
||||
}
|
||||
|
||||
Console.WriteLine($"Selected {band}m, specify (e.g.) --6m for another band");
|
||||
|
||||
if (!all)
|
||||
{
|
||||
Console.WriteLine("Only showing needed spots. Pass --all for all spots.");
|
||||
|
@ -124,11 +117,22 @@ it is, it highlights the call in red in the console window.");
|
|||
|
||||
void Callback(WsjtxMessage wsjtxMessage)
|
||||
{
|
||||
if (wsjtxMessage is StatusMessage statusMessage)
|
||||
{
|
||||
ProcessStatusMessage(statusMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(wsjtxMessage is DecodeMessage decodeMessage))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (bandMetres == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var sw = Stopwatch.StartNew();
|
||||
string heardCall = GetHeardCall(decodeMessage.Message);
|
||||
|
||||
|
@ -141,7 +145,7 @@ it is, it highlights the call in red in the console window.");
|
|||
|
||||
string grid = GetGrid(decodeMessage.Datagram);
|
||||
|
||||
var needed = entity == null ? Needed.No : GetNeeded(band, entity.Adif, grids ? grid : null, "ft8");
|
||||
var needed = entity == null ? Needed.No : GetNeeded(bandMetres, entity.Adif, grids ? grid : null, "ft8");
|
||||
|
||||
if (all || !Needed.No.Equals(needed))
|
||||
{
|
||||
|
@ -189,6 +193,23 @@ it is, it highlights the call in red in the console window.");
|
|||
}
|
||||
}
|
||||
|
||||
private static void ProcessStatusMessage(StatusMessage statusMessage)
|
||||
{
|
||||
var band = AmateurBand.FromHz((long)statusMessage.DialFrequency);
|
||||
|
||||
if (band == null)
|
||||
{
|
||||
Console.WriteLine($"Not an amateur band: {statusMessage.DialFrequency / 1000000.0}MHz");
|
||||
return;
|
||||
}
|
||||
|
||||
if (int.TryParse(band.Name.Replace("m", ""), out int bm) && bm != bandMetres)
|
||||
{
|
||||
bandMetres = bm;
|
||||
Console.WriteLine($"Switched to {band.Name}");
|
||||
}
|
||||
}
|
||||
|
||||
private static bool GetAndConsumeArg(string[] args, string v)
|
||||
{
|
||||
bool present = args.Contains(v);
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AmateurBandLib" Version="1.0.0" />
|
||||
<PackageReference Include="WsjtxUdpLib" Version="1.1.5" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue