in render-wallboard.py [0:0]
def RenderCell(WallboardName, Row, Column):
global AgentStates,Thresholds,Logger,Data,Calculations
#
# Given a particular cell, figure out the right colours and cell contents.
# A cell may contain static text, a number or agent state derived directly
# from the data read from the DDB table, or it may be a calculation we need
# to perform. Also need to ensure that thresholds are checked for numerical
# values where present.
#
Address = "R"+str(Row)+"C"+str(Column)
HTML = ""
AgentDetails = ""
if Address not in Cells[WallboardName]: return(HTML)
Cell = Cells[WallboardName][Address]
LocalStates = AgentStates[WallboardName]
Style = []
Style.append("border: 1px solid black; padding: 5px;")
if "TextColour" in Cell: Style.append("color: "+Cell["TextColour"]+";")
if "TextSize" in Cell: Style.append("font-size: "+Cell["TextSize"]+"px;")
Background = ""
if "Reference" in Cell:
State = ""
if Cell["Reference"] in Calculations[WallboardName]: # We need to calculate this one
Data[Cell["Reference"]] = DoCalculation(WallboardName, Cell["Reference"])
elif Cell["Reference"].lower() in Data: # Data already exists
State = Data[Cell["Reference"]]
elif Cell["Reference"] == "=allagents": # Any agent at all
(AgentDetails, State) = GetNextAgent(False)
elif Cell["Reference"] == "=activeagents": # Active agents only
(AgentDetails, State) = GetNextAgent(True)
if len(State) > 0:
State = State.lower()
if State in LocalStates:
Background = LocalStates[State]
if "ThresholdReference" in Cell:
NewBackground = CheckThreshold(WallboardName, Cell["ThresholdReference"])
if len(NewBackground) > 0: Background = NewBackground
if len(Background) == 0:
if "BackgroundColour" in Cell: Background = Cell["BackgroundColour"]
if len(Background) > 0: Style.append("background: "+Background+";")
Tag = "R"+str(Row)+"C"+str(Column)
HTML += "<td label=\""+Tag+"\" class=\""+Tag+"\""
if "Rows" in Cell: HTML += " rowspan=\""+Cell["Rows"]+"\""
if "Columns" in Cell: HTML += " colspan=\""+Cell["Columns"]+"\""
if len(Style) > 0: HTML += " style=\""+" ".join(Style)+"\""
HTML += ">"
if "Text" in Cell: HTML += "<div class=\"text\">"+Cell["Text"]+"</div>"
if "Reference" in Cell:
if Cell["Reference"] in Data:
HTML += "<div class=\"data\">"+Data[Cell["Reference"]]+"</div>"
elif Cell["Reference"] == "=allagents" or Cell["Reference"] == "=activeagents":
HTML += AgentDetails
else:
Logger.warning("Data reference "+Cell["Reference"]+" in cell "+Address+" does not exist for wallboard "+WallboardName)
HTML += "</td>"
return(HTML)