protected N2kMessageDecoded(N2kMessageEncoded encodedMessage)
        {
            Priority = encodedMessage.Priority;
            PGN = encodedMessage.PGN;
            Destination = encodedMessage.Destination;
            Source = encodedMessage.Source;
            Milliseconds = encodedMessage.Milliseconds;

            DecodeMessage(encodedMessage.Payload);
        }
예제 #2
0
        protected N2kMessageDecoded(N2kMessageEncoded encodedMessage)
        {
            Priority     = encodedMessage.Priority;
            PGN          = encodedMessage.PGN;
            Destination  = encodedMessage.Destination;
            Source       = encodedMessage.Source;
            Milliseconds = encodedMessage.Milliseconds;

            DecodeMessage(encodedMessage.Payload);
        }
        void OnDeviceMessageReceived(object sender, MessageReceivedEventArgs e)
        {
            // The message has already been converted from Can Id to ISO-11783 by the Actisense device.
            if (e.MessageType == MessageType.NMEA2000)
            {
                var n2kMessage = new N2kMessageEncoded
                {
                    // leave parenthesis to prevent unwanted bitshifting
                    Priority = e.Data[(int) ActisenseN2kMessageFormat.Priority],
                    PGN =   (e.Data[(int) ActisenseN2kMessageFormat.PGNLSB] +
                            (e.Data[(int) ActisenseN2kMessageFormat.PGNMiddle] << 8) +
                            (e.Data[(int) ActisenseN2kMessageFormat.PGNMSB] << 16)),
                    Destination = e.Data[(int) ActisenseN2kMessageFormat.Destination],
                    Source = e.Data[(int) ActisenseN2kMessageFormat.Source],
                    Milliseconds =
                        (e.Data[(int) ActisenseN2kMessageFormat.TimeStampLSB] +
                        (e.Data[(int) ActisenseN2kMessageFormat.TimeStamp2] << 8) +
                        (e.Data[(int) ActisenseN2kMessageFormat.TimeStamp3] << 16) +
                        (e.Data[(int) ActisenseN2kMessageFormat.TimeStampMSB] << 32))
                };

                int payloadLength = e.Data[(int) ActisenseN2kMessageFormat.PayloadLength];
                byte[] payload = new byte[payloadLength];

                // could check there are enough bytes...
                Array.Copy(e.Data, (int)ActisenseN2kMessageFormat.PayloadStart, payload, 0, payloadLength);

                n2kMessage.Payload = payload;

                var handler = N2kMessageParsed;
                if (handler != null)
                {
                    handler(this, new N2kMessageEventArgs(n2kMessage));
                }
            }
        }
예제 #4
0
 public VesselHeading(N2kMessageEncoded encodedMessage)
     : base(encodedMessage)
 {
 }
 public N2kMessageEventArgs(N2kMessageEncoded message)
 {
     Message = message;
 }
예제 #6
0
 public VesselHeading(N2kMessageEncoded encodedMessage) : base(encodedMessage)
 {
 }