src/server/server.py
def on_stop_race():
    '''Stops the race and stops registering laps.'''
    global RACE

    CLUSTER.emit('stop_race')
    if RACE.race_status == RaceStatus.RACING:
        RACE.end_time = monotonic() # Update the race end time stamp
        delta_time = RACE.end_time - RACE.start_time_monotonic
        milli_sec = delta_time * 1000.0
        RACE.duration_ms = milli_sec

        logger.info('Race stopped at {0} ({1:13f}), duration {2}ms'.format(RACE.end_time, monotonic_to_milliseconds(RACE.end_time), RACE.duration_ms))

        min_laps_list = []  # show nodes with laps under minimum (if any)
        for node in INTERFACE.nodes:
            if node.under_min_lap_count > 0:
                min_laps_list.append('Node {0} Count={1}'.format(node.index+1, node.under_min_lap_count))
        if len(min_laps_list) > 0:
            logger.info('Nodes with laps under minimum:  ' + ', '.join(min_laps_list))

        RACE.race_status = RaceStatus.DONE # To stop registering passed laps, waiting for laps to be cleared
        INTERFACE.set_race_status(RaceStatus.DONE)
        Events.trigger(Evt.RACE_STOP)
    else:
        logger.info('No active race to stop')
        RACE.race_status = RaceStatus.READY # Go back to ready state
        INTERFACE.set_race_status(RaceStatus.READY)
        led_manager.clear()

    RACE.timer_running = False # indicate race timer not running
    RACE.scheduled = False # also stop any deferred start

    SOCKET_IO.emit('stop_timer') # Loop back to race page to start the timer counting up
    emit_race_status()
Stops the race and stops registering laps.
Stops the race and stops registering laps.
Stops the race and stops registering laps .
def on_stop_race():
    global RACE
    CLUSTER.emit('stop_race')
    if RACE.race_status == RaceStatus.RACING:
        RACE.end_time = monotonic() 
        delta_time = RACE.end_time - RACE.start_time_monotonic
        milli_sec = delta_time * 1000.0
        RACE.duration_ms = milli_sec
        logger.info('Race stopped at {0} ({1:13f}), duration {2}ms'.format(RACE.end_time, monotonic_to_milliseconds(RACE.end_time), RACE.duration_ms))
        min_laps_list = []  
        for node in INTERFACE.nodes:
            if node.under_min_lap_count > 0:
                min_laps_list.append('Node {0} Count={1}'.format(node.index+1, node.under_min_lap_count))
        if len(min_laps_list) > 0:
            logger.info('Nodes with laps under minimum:  ' + ', '.join(min_laps_list))
        RACE.race_status = RaceStatus.DONE 
        INTERFACE.set_race_status(RaceStatus.DONE)
        Events.trigger(Evt.RACE_STOP)
    else:
        logger.info('No active race to stop')
        RACE.race_status = RaceStatus.READY 
        INTERFACE.set_race_status(RaceStatus.READY)
        led_manager.clear()
    RACE.timer_running = False 
    RACE.scheduled = False 
    SOCKET_IO.emit('stop_timer') 
    emit_race_status()
def on_stop_race ( ) : global RACE CLUSTER . emit ( 'stop_race' ) if RACE . race_status == RaceStatus . RACING : RACE . end_time = monotonic ( ) delta_time = RACE . end_time - RACE . start_time_monotonic milli_sec = delta_time * 1000.0 RACE . duration_ms = milli_sec logger . info ( 'Race stopped at {0} ({1:13f}), duration {2}ms' . format ( RACE . end_time , monotonic_to_milliseconds ( RACE . end_time ) , RACE . duration_ms ) ) min_laps_list = [ ] for node in INTERFACE . nodes : if node . under_min_lap_count > 0 : min_laps_list . append ( 'Node {0} Count={1}' . format ( node . index + 1 , node . under_min_lap_count ) ) if len ( min_laps_list ) > 0 : logger . info ( 'Nodes with laps under minimum:  ' + ', ' . join ( min_laps_list ) ) RACE . race_status = RaceStatus . DONE INTERFACE . set_race_status ( RaceStatus . DONE ) Events . trigger ( Evt . RACE_STOP ) else : logger . info ( 'No active race to stop' ) RACE . race_status = RaceStatus . READY INTERFACE . set_race_status ( RaceStatus . READY ) led_manager . clear ( ) RACE . timer_running = False RACE . scheduled = False SOCKET_IO . emit ( 'stop_timer' ) emit_race_status ( )
Stops the race and stops registering laps.
Stops the race and stops registering laps .
'''Stops the race and stops registering laps.''' # Update the race end time stamp # show nodes with laps under minimum (if any) # To stop registering passed laps, waiting for laps to be cleared # Go back to ready state # indicate race timer not running # also stop any deferred start # Loop back to race page to start the timer counting up