def GetNextAgent()

in render-wallboard.py [0:0]


def GetNextAgent(GetActive):
    global SortedAgentList,NextAgent,FullAgentNames
    
    #
    # When we need to display a list of all agents currently active, this
    # function returns the names one-by-one so that the caller can fill in the
    # cells in the wallboard table.
    #
    AgentName = ""
    HTML      = ""
    
    if NextAgent >= len(SortedAgentList): return(HTML, "") # No more agents - cell is blank

    if not GetActive: # Return the next agent whether active in the system or not
        AgentName = SortedAgentList[NextAgent]
        NextAgent += 1
    else: # Return the next active agent
        while NextAgent < len(SortedAgentList):
            AgentState = Data[SortedAgentList[NextAgent]]
            if len(AgentState) == 0 or AgentState == "Logout":
                NextAgent += 1
                continue
            
            AgentName = SortedAgentList[NextAgent]
            NextAgent += 1
            break
        
    if len(AgentName) == 0: return(HTML, "") # No agent found - cell is blank
    
    if AgentName in FullAgentNames: # Just in case we didn't find a full name for this agent
        HTML += "<div class=\"text\">"+FullAgentNames[AgentName]+"</div>"
    HTML += "<div class=\"data\">"+Data[AgentName]+"</div>"

    return(HTML, Data[AgentName]) # Return the state so we can set the cell background colour