private void OnIncomingMessage(MessageBase message, DateTime messagetime) { // ReSharper disable once SwitchStatementMissingSomeCases switch (message.Name) { case MessageName.RMC: { var rmc = (RMC)message; if (rmc.SOG > MINIMUM_SPEED_FOR_VALID_CALCULATIONS) { Cog = rmc.TMG; Cog.Source = SourceType.External; PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Cog")); Sog = rmc.SOG; Sog.Source = SourceType.External; PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Sog")); OnUpdateCog(); } } break; case MessageName.HDG: { var hdg = (HDG)message; if (null != hdg.MagneticContext) { _magneticContext = hdg.MagneticContext; } } break; } if (message is IHaveHeading) { Heading = new QuantityWithMetadata <IMessageCompassValue>(_magneticContext.Magnetic((message as IHaveHeading).Heading)); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Heading")); } if (message is IHasPosition) { QuantityWithMetadata <Coordinate> c = (Coordinate)(message as IHasPosition).Position; c.Source = SourceType.External; c.Updated = messagetime; OnUpdatePosition(c); } UpdateLastMessageDictionary(message); }
protected override IMessageCompassValue Convert(IMessageCompassValue compassValue) { return (MagneticContext.Magnetic(compassValue)); }