Next generation scoresheet component for Moscore QM¶
The current scoresheet design depends on repeated database reads during state (flag) transitions, and mixes state change events with flag events and race passing events. A new, better design should have the following goals:
- Ability to rewind the scoresheet state without access to the database.
- Yellow and red flags as well as lead car corrections require the scoring to be rewound to the last complete lap, or replayed from the last green flag event. Accessing the data stored in the database is turning into a bottleneck.
- Ability to replay the race as it was scored, including operator corrections.
- this feature would improve post mortem debugging.
- Don't mix state change events with data.
- The race passings should be recorded directly, with no scoring data attached. Scoring data should be stored in other tables as described below.
- Could implement features like 'correct off track status at yellow' to prevent 'last completed lap' problem
RaceStreamState // (container for most recent of) passing state carStateChange // immutable states carStates RaceEntry (db:grids) driver position // used to implement lineup corrections. call/dot corrections (incidentBackOfPack) will cause a rewind, offtrackBackOfPack, lateBackOfPack (flagger/judge discression) corrections won't CarStatus (none, offtrack, incidentBackOfPack, offtrackBackOfPack, lateBackOfPack) CarState // accumulates state for a single car. immutable points int status CarStatus raceEntry RaceStream states // owns all events passings // owns all Passings (can we use copy semantics to avoid having an owner?) stateChanges // ... StateChanges carStateChanges // ... CarStateChanges private next(RaceStreamState) next(Passing) next(StateChange) next(CarStateChange) onPassing onStateChange onCarStateChange Passing (db:passings) transponder, time, time of day, etc // Seq should be incremented when creating any one of the following: RacePassing (db:racePassings) seq passing raceEntry StateChange (db:raceStateChange) seq time (of day) type (statechange, manualLineup, sequenceCorrection) corrects StateChange // previous state change which this correct. (Typically the most recent) // With 'seek' causes scoresheet to rewind back to that time and replay (copying) the race events. seek int // for sequenceCorrection: causes the rewind to 'corrects' and then go forward or back this many RacePassings (correct lead car) raceState (prerace, warmup, pregreen, green, yellow, red, check, done) lineup RaceEntry // record lineup calculated at prerace, yellow, red, done, manualLineup. (may as well record for check/warmup/pregreen also) CarStateChange (db:carStateChange) seq time (of day) raceEntry status CarStatus // novice grid 'backofpack' can be implemented with a CarStateChange immediately after initial 'prerace' StateChange reason string addPoints int (increase strike/call points by this much) lineup RaceEntry // lineup resulting from a backofpack