AK.F1.Timing.Live.LiveMessageReader.ReadSpeedCaptureMessage C# (CSharp) Method

ReadSpeedCaptureMessage() private method

private ReadSpeedCaptureMessage ( LiveMessageHeader header ) : Message
header LiveMessageHeader
return Message
        private Message ReadSpeedCaptureMessage(LiveMessageHeader header)
        {
            ReadAndDecryptBytes(header.Value);
            var location = Buffer[0] - 1;
            if(location < 0 || location > 3)
            {
                // The fastest lap is also published as an apex speed but we ignore them as they
                // can easily be computed by a model.
                return Message.Empty;
            }
            var speeds = new List<KeyValuePair<string, int>>(6);
            foreach(Match match in Regex.Matches(DecodeLatin1(1, header.Value - 1), "([^\r]+)(?:\r)([^\r]+)(?:\r)?"))
            {
                speeds.Add(new KeyValuePair<string, int>(match.Groups[1].Value, LiveData.ParseInt32(match.Groups[2].Value)));
            }
            return new SpeedCaptureMessage((SpeedCaptureLocation)location, speeds.ToArray());
        }