So I've found a resolution to my issue (and it took a while)...
I created a maths channel called 'invalid lap' with the following expression:
- Code: Select all
stat_max(flip_flop('Num Tires Off Track'==4,'Num Tires Off Track'<4),1,range_change("Outings:Laps"))
This will return '1' when all 4 tyres are registered outside track limits but reset to '0' at the start of the next lap, which is important for using derivative in the next part.
I then created another maths channel 'Total invalid laps' as follows:
- Code: Select all
integrate(derivative('invalid lap'),'invalid lap'==1)
Using the flipflop function and stat_max, the condition is false, until it becomes true (which it remains for the remainder of the lap) and then reverts to false at the start of the next lap. This allows the nested integrate & derivative functions to work correctly.
Originally, for say... lap 9 & 10, If there were track limits violations in consecutive laps, invalid lap would become '1' for lap 9 and then remain as '1' for the duration of lap 10, before resetting for lap 11 if no further violations were received. This would be registered incorrectly (in the invalid lap channel) as a single violation and not two separate violations.
With the flipflop, the value only changes during the lap (at the point the violation takes place) and therefore registers a false to true change and not one continuous true, which didn't trigger the count.
There is one potential pitfall though - if you were to cross the start/finish line with all four wheels off the track, this would probably (to be tested) register as a single track violation over both laps and only count it once. I don't actually know how this would be perceived or punished in the rules but for the sake of practice and qualifying, it's unlikely to happen. Plus if someone wants to do this, I think the lap time penalty will be greater than any track limits violation penalty!
So there it is - I've found a way to use a counter that reports on how many times a condition was met during a session.