Giter Club home page Giter Club logo

wsjtxutils.searchlight's People

Contributors

dependabot[bot] avatar kc3pib avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

wsjtxutils.searchlight's Issues

Parsing special operating activity messages

WsjtxQsoParser is a useful class that should probably be included in the WsjtxUtils library. However, it fails to parse some Special Operating Activity (such as ARRL Field Day) messages, e.g. VE3NEA VE3RYI R 1D GTA . My current work around is to just look for anything that is a valid callsign or grid square:

var wsjtxQso = WsjtxQsoParser.ParseDecode(message);
if (string.IsNullOrEmpty(wsjtxQso.DECallsign)) ParseSpecialMessage(wsjtxQso);

where

        private void ParseSpecialMessage(WsjtxQso wsjtxQso)
        {
            var parts = wsjtxQso.RawMessage
                .Replace("<", "")
                .Replace(">", "")
                .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
                .Where(part => part != "?")
                .ToArray();

            if (parts.Any() && parts[0] == MyCall)
                wsjtxQso.DXCallsign = parts[0];

            int idx = FindSenderCallsign(parts);
            if (idx == -1) return;
            wsjtxQso.DECallsign = parts[idx];

            if (++idx < parts.Length && parts[idx] == "R") idx++;
            if (idx < parts.Length && Utils.GridSquareRegex.IsMatch(parts[idx]))
                wsjtxQso.GridSquare = parts[idx];
        }

        private int FindSenderCallsign(string[] parts)
        {
            for (int i = parts.Length - 1; i > 0; i--)
                if (Utils.CallsignRegex.IsMatch(parts[i]))
                    return i;

            return -1;
        }

The regular expressions to match the callsign and grid square are as follows:

    internal static class Utils
    {
        public static Regex CallsignRegex = new Regex(
            // portable prefix
            @"^((?:(?:[A-NPR-Z](?:(?:[A-Z](?:\d[A-Z]?)?)|(?:\d[\dA-Z]?))?)|(?:[2-9][A-Z]{1,2}\d?))\/)?" +
            // prefix
            @"((?:(?:[A-NPR-Z][A-Z]?)|(?:[2-9][A-Z]{1,2}))\d)" +
            // suffix
            @"(\d{0,3}[A-Z]{1,6})" +
            // modifier
            @"(\/[\dA-Z]{1,4})?$",
            RegexOptions.Compiled
        );

        public static Regex GridSquareRegex = new Regex(@"^(?!RR73)[A-R]{2}\d{2}$", RegexOptions.Compiled);
}

It would be nice to add support of Special Activities message formats, and perhaps optionally validate the grid square and callsigns.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.