AK.F1.Timing.Live.LiveMessageTranslator.TranslateSetSectorClear C# (CSharp) Method

TranslateSetSectorClear() private method

private TranslateSetSectorClear ( SetGridColumnValueMessage message, int sectorNumber ) : Message
message AK.F1.Timing.Messages.Driver.SetGridColumnValueMessage
sectorNumber int
return Message
        private Message TranslateSetSectorClear(SetGridColumnValueMessage message, int sectorNumber)
        {
            var driver = GetDriver(message);
            var lastSectorTime = driver.GetLastSector(1);
            // The feed will only send a value / colour update for S1 if the value has changed. We
            // can detect this when the S2 time is cleared and we are expecting an S1 update.
            // Note that we do not translate the message when the S1 column is currently cleared,
            // this usually occurs during practice as the driver exits the pits and the previous
            // times are cleared.
            // Also, note that an S2 clear can be received when we do not have a previous S1 time,
            // usually at the start of a session.
            if(driver.IsOnTrack && driver.IsCurrentSectorNumber(1) && sectorNumber == 2 &&
                driver.ColumnHasValue(GridColumn.S1) && lastSectorTime != null)
            {
                return TranslateSetDriverSectorTimeMessage(
                    new SetDriverSectorTimeMessage(driver.Id, 1,
                        new PostedTime(lastSectorTime.Time, lastSectorTime.Type, driver.LapNumber)));
            }

            return null;
        }