Exemple #1
0
 /// <summary>
 /// Extracts the array of data bytes and stores them in the J1708Message instance.
 /// </summary>
 /// <param name="message"></param>
 public override void ExtractMessage()
 {
     try
     {
         rawMessage = rawMessage.Substring(0, message.Length - 2); //removes the checksum from the end of the message
         Mid        = BinConvert(rawMessage[0], rawMessage[1]);
         var trimmedMessage = rawMessage.Substring(2);             //remove the MID from the message
         while (trimmedMessage.Length > 0)
         {
             var segment = new J1708MessageSegment(trimmedMessage, Mid)
             {
                 TimeReceived = this.timeReceived
             };
             int messageLength = segment.GetTotalMessageBytes() * 2;
             if (messageLength >= trimmedMessage.Length)
             {
                 trimmedMessage = string.Empty;
             }
             else
             {
                 trimmedMessage = trimmedMessage.Substring(messageLength);
             }
             CanMessageSegments.Add(segment);
         }
     }
     catch (Exception ex)
     {
         VMSConsole.PrintLine("Failed to parse " + message);
     }
 }
        public CanMessageSegment DeepCopy()
        {
            CanMessageSegment segment;

            switch (DataSource)
            {
            case VMSDataSource.J1708:
                segment = new J1708MessageSegment(RawMessageSegment, 0);
                break;

            case VMSDataSource.J1939:
                segment = new J1939MessageSegment();
                break;

            default:
                return(null);
            }
            segment.DataSource        = this.DataSource;
            segment.Pid               = this.Pid;
            segment.RawMessageSegment = this.RawMessageSegment;
            segment.RawValue          = this.RawValue;
            segment.RawData           = this.RawData;
            segment.StandardValue     = this.StandardValue;
            segment.MetricValue       = this.MetricValue;
            segment.TimeReceived      = this.TimeReceived;
            segment.TimeParsed        = this.TimeParsed;
            segment.ParseStatus       = this.ParseStatus;
            return(segment);
        }