esitarski / CrossMgr

Cyclo Cross Management Application
MIT License
41 stars 21 forks source link

CrossMgr Lap Counter incorrect when fastest group has less laps #56

Closed stuartlynne closed 11 months ago

stuartlynne commented 4 years ago

Describe the bug In a multi category race with different start times and number of laps, when the second start group passed the first start group, the lap counter was not correctly shown for the first group.

The first group was supposed to do six laps, the second group five laps. The second group passed the first on the first lap. They were shown on the record screen and lap counter with the correct number of laps to go (four).

When the first group came through the finish, they were also shown with four laps to go (should have been five) in the record screen and lap counter. The results and chart screen showned auto-correct laps correctly as a total of six.

Changing the number of laps for the first group (e.g. to seven) in Categories did not change anything.

Changing the number of laps for the second group (first group on road) to six "fixed" the issue WRT to the first group. It then showed the correct number of laps everywhere (but with the second group showing an incorrect number of laps!)

That allowed the race to work (with some fudging of the lap board display). I reset the laps for the first group after and all results were correctly published.

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Cat 1/2 is 6, Master 1/2/3 is 5 laps. image

Record screen shows Cat 12 as 5 laps (should be 6) image

Results and charts correctly show 6 laps. image

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context Add any other context about the problem here.

mbuckaway commented 4 years ago

Please attached sample race excel and crossmgr file to the issue.

Belcarra commented 4 years ago

This was, I think, not a bug, but pilot error.

The Race Property field "All categories after Fastest Rider's last lap" was incorrectly set.

I would like to change this to a feature request, that the above field should default to being off, not on.

esitarski commented 3 years ago

We are going to need the Excel file and CrossMgr race file. And the log, if you have it.

According to the code, the "All Categories Finish after Fastest Rider's Last Lap" does nothing if the number of laps is specified for that start wave. It only applies to timed races.

CrossMgr always respects the Wave laps when it is present.

I see in your screen shots that you set the number of laps in Categories, but that is in consistent with what is being shown in your other screen shots. There is something else going on to cause this.

  # If the category num laps is specified, use that.
  if race.getNumLapsFromCategory(c):
      categoryWinningLaps[c] = race.getNumLapsFromCategory(c)
      categoryWinningTime[c] = times[min(len(times)-1, categoryWinningLaps[c])]
  else:
      # Otherwise, set the number of laps by the winner's time closest to the race finish time.
      try:
          if fastestRidersLastLapTime is not None:
              winningLaps = bisect_left( times, fastestRidersLastLapTime, hi=len(times)-1 )
              categoryWinningTime[c] = fastestRidersLastLapTime
              categoryWinningLaps[c] = winningLaps
          else:
              winningLaps = bisect_left( times, raceSeconds, hi=len(times)-1 )
              if winningLaps >= 2:
                  winner = riders[nums[winningLaps]]
                  entries = winner.interpolate()
                  if entries[winningLaps].interp:
                      lastLapTime = times[winningLaps] - times[winningLaps-1]
                      if (times[winningLaps] - raceSeconds) > lastLapTime / 2.0:
                          winningLaps -= 1
              categoryWinningTime[c] = times[winningLaps]
              categoryWinningLaps[c] = winningLaps
      except IndexError:
          categoryWinningTime[c] = raceSeconds
          categoryWinningLaps[c] = None
esitarski commented 3 years ago

I tried to mess this up in the Simulation, but it always worked for me. Here is what I did:

  1. Start the Tools|Simulation/Mass Start
  2. Let it run for a few minutes. It will forecast 9 laps for the Junior category.
  3. Switch to the Category screen and Junior to 5 laps, then quickly change screens to commit the change. This can be a bit tricky.
  4. The Record screen will correctly show 5 laps for the Juniors, even though the Senior Women start later with slower laps.

CrossMgr runs each Category start wave to its specified number of laps. The value of "All Categories Finish after Fastest Rider's Last Lap" doesn't matter when the Race Laps is set.

esitarski commented 11 months ago

Changed CrossMgr so that "All Categories Finish after Faster Rider's Last Lap" is not set by default. This better corresponds to the expectation that all Start Waves should be independent. After all, it is very easy to adjust the number of laps by clicking on the category Progress Bars in the Record screen.