src/server/server.py
def check_team_laps_win(t_laps_dict, num_laps_win, pilot_team_dict, pass_node_index=-1):
    '''Checks if a team has completed enough laps to win.'''
    global RACE
         # make sure there's not a pilot in the process of crossing for a winning lap
    if RACE.laps_winner_name is None and pilot_team_dict:
        profile_freqs = None
                                  # dict for current heat with key=node_index, value=pilot_id
        node_pilot_dict = dict(Database.HeatNode.query.with_entities(Database.HeatNode.node_index, Database.HeatNode.pilot_id). \
                          filter(Database.HeatNode.heat_id==RACE.current_heat, Database.HeatNode.pilot_id!=Database.PILOT_ID_NONE).all())

        for node in INTERFACE.nodes:  # check if (other) pilot node is crossing gate
            if node.pass_crossing_flag and node.index != pass_node_index:
                if not profile_freqs:
                    profile_freqs = json.loads(getCurrentProfile().frequencies)
                if profile_freqs["f"][node.index] != RHUtils.FREQUENCY_ID_NONE:  # node is enabled
                    pilot_id = node_pilot_dict.get(node.index)
                    if pilot_id:  # node has pilot assigned to it
                        team_name = pilot_team_dict[pilot_id]
                        if team_name:
                            ent = t_laps_dict[team_name]  # entry for team [lapCount,timestamp]
                                        # if pilot crossing for possible winning lap then wait
                                        #  in case lap time turns out to be earliest:
                            if ent and ent[0] == num_laps_win - 1:
                                logger.info('check_team_laps_win waiting for crossing, Node {0}'.format(node.index+1))
                                return
    win_name = None
    win_tstamp = -1
    win_item = None
         # for each team, check if team has enough laps to win (and, if more
         #  than one has enough laps, pick team with earliest timestamp)
    for team_name in t_laps_dict.keys():
        ent = t_laps_dict[team_name]  # entry for team [lapCount,timestamp]
        if ent[0] >= num_laps_win and (win_tstamp < 0 or ent[1] < win_tstamp):
            win_name = team_name
            win_tstamp = ent[1]
            win_item = ent[2]
    logger.debug('check_team_laps_win win_name={0} tstamp={1}, win_item: {2}'.format(win_name, win_tstamp, win_item))
    RACE.laps_winner_name = win_name
Checks if a team has completed enough laps to win.
Checks if a team has completed enough laps to win.
Checks if a team has completed enough laps to win .
def check_team_laps_win(t_laps_dict, num_laps_win, pilot_team_dict, pass_node_index=-1):
    global RACE
    if RACE.laps_winner_name is None and pilot_team_dict:
        profile_freqs = None
        node_pilot_dict = dict(Database.HeatNode.query.with_entities(Database.HeatNode.node_index, Database.HeatNode.pilot_id). \
                          filter(Database.HeatNode.heat_id==RACE.current_heat, Database.HeatNode.pilot_id!=Database.PILOT_ID_NONE).all())
        for node in INTERFACE.nodes:  
            if node.pass_crossing_flag and node.index != pass_node_index:
                if not profile_freqs:
                    profile_freqs = json.loads(getCurrentProfile().frequencies)
                if profile_freqs["f"][node.index] != RHUtils.FREQUENCY_ID_NONE:  
                    pilot_id = node_pilot_dict.get(node.index)
                    if pilot_id:  
                        team_name = pilot_team_dict[pilot_id]
                        if team_name:
                            ent = t_laps_dict[team_name]  
                            if ent and ent[0] == num_laps_win - 1:
                                logger.info('check_team_laps_win waiting for crossing, Node {0}'.format(node.index+1))
                                return
    win_name = None
    win_tstamp = -1
    win_item = None
    for team_name in t_laps_dict.keys():
        ent = t_laps_dict[team_name]  
        if ent[0] >= num_laps_win and (win_tstamp < 0 or ent[1] < win_tstamp):
            win_name = team_name
            win_tstamp = ent[1]
            win_item = ent[2]
    logger.debug('check_team_laps_win win_name={0} tstamp={1}, win_item: {2}'.format(win_name, win_tstamp, win_item))
    RACE.laps_winner_name = win_name
def check_team_laps_win ( t_laps_dict , num_laps_win , pilot_team_dict , pass_node_index = - 1 ) : global RACE if RACE . laps_winner_name is None and pilot_team_dict : profile_freqs = None node_pilot_dict = dict ( Database . HeatNode . query . with_entities ( Database . HeatNode . node_index , Database . HeatNode . pilot_id ) . filter ( Database . HeatNode . heat_id == RACE . current_heat , Database . HeatNode . pilot_id != Database . PILOT_ID_NONE ) . all ( ) ) for node in INTERFACE . nodes : if node . pass_crossing_flag and node . index != pass_node_index : if not profile_freqs : profile_freqs = json . loads ( getCurrentProfile ( ) . frequencies ) if profile_freqs [ "f" ] [ node . index ] != RHUtils . FREQUENCY_ID_NONE : pilot_id = node_pilot_dict . get ( node . index ) if pilot_id : team_name = pilot_team_dict [ pilot_id ] if team_name : ent = t_laps_dict [ team_name ] if ent and ent [ 0 ] == num_laps_win - 1 : logger . info ( 'check_team_laps_win waiting for crossing, Node {0}' . format ( node . index + 1 ) ) return win_name = None win_tstamp = - 1 win_item = None for team_name in t_laps_dict . keys ( ) : ent = t_laps_dict [ team_name ] if ent [ 0 ] >= num_laps_win and ( win_tstamp < 0 or ent [ 1 ] < win_tstamp ) : win_name = team_name win_tstamp = ent [ 1 ] win_item = ent [ 2 ] logger . debug ( 'check_team_laps_win win_name={0} tstamp={1}, win_item: {2}' . format ( win_name , win_tstamp , win_item ) ) RACE . laps_winner_name = win_name
Checks if a team has completed enough laps to win.
Checks if a team has completed enough laps to win .
'''Checks if a team has completed enough laps to win.''' # make sure there's not a pilot in the process of crossing for a winning lap # dict for current heat with key=node_index, value=pilot_id # check if (other) pilot node is crossing gate # node is enabled # node has pilot assigned to it # entry for team [lapCount,timestamp] # if pilot crossing for possible winning lap then wait #  in case lap time turns out to be earliest: # for each team, check if team has enough laps to win (and, if more #  than one has enough laps, pick team with earliest timestamp) # entry for team [lapCount,timestamp]
t_laps_dict
num_laps_win
pilot_team_dict
pass_node_index