diff options
| -rw-r--r-- | CHANGELOG.md | 10 | ||||
| -rw-r--r-- | PagerMessage.cs | 39 | ||||
| -rw-r--r-- | PositionCalculator.cs | 3 | ||||
| -rw-r--r-- | Sites/PagerMon.cs | 2 |
4 files changed, 38 insertions, 16 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e3181e..df35f02 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +# Version 0.2 + +### Bug Fixes +- Fixed bug in which pager messages fetched via PagerMon provider had timestamps that were incorrectly converted to universal time +- Paged emergency services now correctly stored as non-clashing bit-fields in the DB +- Correctly extract fireground radio channel from list of paged services +### Other Improvements +- Added missing Melways pages 109, 134 and 135 +- Improved accuracy of parsing regex + # Version 0.1 Initial release diff --git a/PagerMessage.cs b/PagerMessage.cs index dc30a05..b817d23 100644 --- a/PagerMessage.cs +++ b/PagerMessage.cs @@ -12,11 +12,11 @@ public enum AlertLevel { [Flags] public enum EmergencyService { - Ambulance = 1, - Fire = 2, - Police = 3, - Rescue = 4, - SES = 5 + Ambulance = 0x01, + Fire = 0x02, + Police = 0x04, + Rescue = 0x08, + SES = 0x10 } [Index(nameof(Message))] @@ -68,7 +68,7 @@ public interface IPagerMessageParserService { // service is only used by the fetch service for parsing new messages. public class PagerMessageParserService : IPagerMessageParserService { private const string Pattern = - @"^@@ALERT\s+([A-Z]+[0-9]+)\s+([A-Z&]+)C([13])\s+(.*)\s+M\s+(\d+)\s+([A-Z]\d+)\s+\((\d+)\)\s+(\*\s+[^*]+\*\s+)?([AFPRS]+)\s+((C[A-Z]+)\s+)+FGD(\d+)\s+(P\d+\s+)?F(\d+)\s+\[([A-Z]+)\]$"; + @"^@@ALERT\s+([A-Z]*[0-9]+)\s+([A-Z&]+)C([13])\s+(\*\s+)?(.*)\s+M\s+(\d+)\s+([A-Z]\d+)\s+\((\d+)\)\s+(\*\s+[^*]+\*\s+)?([AFPRS]+)\s+(([A-Z0-9]+\s)+)F([0-9]+)\s+\[([A-Z]+)\]$"; private Regex pageMessageRegex = new Regex(Pattern, RegexOptions.Compiled | RegexOptions.IgnoreCase); @@ -83,16 +83,25 @@ public class PagerMessageParserService : IPagerMessageParserService { // Parse non-optional message components m.AssignmentArea = match.Groups[1].Value; m.JobType = match.Groups[2].Value; - m.Description = match.Groups[4].Value; - m.FirecomJobNo = Int32.Parse(match.Groups[14].Value); - m.PageDestination = match.Groups[15].Value; + m.Description = match.Groups[5].Value; + m.FirecomJobNo = Int32.Parse(match.Groups[13].Value); + m.PageDestination = match.Groups[14].Value; // Parse optional message components - if(match.Groups[5].Success) m.MelwaysMapNo = Int32.Parse(match.Groups[5].Value); - if(match.Groups[6].Success) m.MelwaysGrid = match.Groups[6].Value; - if(match.Groups[7].Success) m.GridReference = Int32.Parse(match.Groups[7].Value); - if(match.Groups[8].Success) m.Note = match.Groups[8].Value; - if(match.Groups[12].Success) m.FireGroundChannel = Int32.Parse(match.Groups[12].Value); + if(match.Groups[6].Success) m.MelwaysMapNo = Int32.Parse(match.Groups[6].Value); + if(match.Groups[7].Success) m.MelwaysGrid = match.Groups[7].Value; + if(match.Groups[8].Success) m.GridReference = Int32.Parse(match.Groups[8].Value); + if(match.Groups[9].Success) m.Note = match.Groups[9].Value; + + // Attempt to extract the fire-ground channel as it can be mixed + // into the list of paged services. + m.FireGroundChannel = match.Groups[11].Value + .Split(" ") + .Select(x => Regex.Match(x, "^FGD([0-9]+)$")) + .Where(m => m.Success) + .Select(m => (int?) int.Parse(m.Groups[1].Value)) + .DefaultIfEmpty(null) + .First(); switch(match.Groups[3].Value) { case "1": m.AlertLevel = AlertLevel.Code1; break; @@ -101,7 +110,7 @@ public class PagerMessageParserService : IPagerMessageParserService { } // Handle each character to construct a bitmap of attending services - foreach(char c in match.Groups[9].Value) { + foreach(char c in match.Groups[10].Value) { switch(c) { case 'A': m.AttendingServices |= EmergencyService.Ambulance; break; case 'F': m.AttendingServices |= EmergencyService.Fire; break; diff --git a/PositionCalculator.cs b/PositionCalculator.cs index 8d8a94f..4344e76 100644 --- a/PositionCalculator.cs +++ b/PositionCalculator.cs @@ -38,12 +38,15 @@ public class PositionCalculator { new MelwaysPage { PageNo = 95, Latitude = -38.0061349929752, Longitude = 145.197873798763 }, new MelwaysPage { PageNo = 96, Latitude = -38.0060458242193, Longitude = 145.242282747795 }, new MelwaysPage { PageNo = 98, Latitude = -38.0501502394990, Longitude = 145.153538108815 }, + new MelwaysPage { PageNo = 109, Latitude = -37.9620542882551, Longitude = 145.330988175988 }, new MelwaysPage { PageNo = 110, Latitude = -38.0059397267576, Longitude = 145.286740799198 }, new MelwaysPage { PageNo = 111, Latitude = -38.0058646642328, Longitude = 145.331164408607 }, new MelwaysPage { PageNo = 128, Latitude = -38.0500712736303, Longitude = 145.197997939698 }, new MelwaysPage { PageNo = 129, Latitude = -38.0499811306888, Longitude = 145.242424322651 }, new MelwaysPage { PageNo = 130, Latitude = -38.0498760059982, Longitude = 145.286857218675 }, new MelwaysPage { PageNo = 131, Latitude = -38.0497905233513, Longitude = 145.331303121527 }, + new MelwaysPage { PageNo = 134, Latitude = -38.0938684113233, Longitude = 145.287035643320 }, + new MelwaysPage { PageNo = 135, Latitude = -38.0938684113233, Longitude = 145.331502355613 }, new MelwaysPage { PageNo = 212, Latitude = -38.0056782419614, Longitude = 145.375580424547 }, new MelwaysPage { PageNo = 213, Latitude = -38.0055063939227, Longitude = 145.419999796841 }, new MelwaysPage { PageNo = 214, Latitude = -38.0496145139129, Longitude = 145.375744441368 }, diff --git a/Sites/PagerMon.cs b/Sites/PagerMon.cs index fb25323..d27d3fe 100644 --- a/Sites/PagerMon.cs +++ b/Sites/PagerMon.cs @@ -29,7 +29,7 @@ public class PagerMon { return Array.Empty<PagerMessage>(); return result.Messages.Select(m => new PagerMessage() { - Timestamp = DateTimeOffset.FromUnixTimeSeconds(m.Timestamp).DateTime.ToUniversalTime(), + Timestamp = DateTimeOffset.FromUnixTimeSeconds(m.Timestamp).UtcDateTime, Message = m.Message }).ToArray(); } |
