def updateUI(self, weather): global signs, signsWidth, signsHeight try: signIndex = 10 if weather.temperature < 0 else 11 self.sign.setImage(signs[signIndex]) tempHi, tempLo = int(weather.temperature / 10), int( weather.temperature % 10) self.digit1.setImage(signs[tempHi]) self.digit2.setImage(signs[tempLo]) self.labelIP.text = "IP:" + utils.getIPAddress() self.labelLastUpdate.text = "Update:" + weather.lastUpdateStr if len( weather.lastErrorStr) == 0 else weather.lastErrorStr except BaseException as e: print("updateUI error:", str(e), sys.exc_info()[2].tb_lineno)
def updateUI(self): global messages self.headerLeft.text = "PAUSED " if self.pause else "{} messages".format( len(messages)) self.headerRight.text = "IP: {}:{}".format(utils.getIPAddress(), PORT_NUMBER) # If paused, no data update if self.pause: self.draw() return self.dataLock.acquire() line_index = 0 for p in range(self.lines_cnt): try: message = messages[ self.dataPos + p] if self.dataPos + p < len(messages) else None if message is None: # No message: add empty line if line_index < self.lines_cnt: self.dataLabels[ line_index].text = " " * self.lines_width line_index += 1 else: # Group and datetime if line_index < self.lines_cnt: header_str = "{}. {}".format(message.groupid, message.timestamp) self.dataLabels[ line_index].text = self.strExpandToSize( header_str, self.lines_width) self.dataLabels[line_index].textColor = self.tft.BLACK line_index += 1 # Receivers receivers = "To: {}".format(message.groupid, message.receivers) receivers_lines = self.strToStringsListWithSize( receivers, self.lines_width) for s in receivers_lines: if line_index >= self.lines_cnt: break self.dataLabels[ line_index].text = self.strExpandToSize( s, self.lines_width) self.dataLabels[line_index].textColor = self.tft.BLACK line_index += 1 # Body msg_body_lines = self.strToStringsListWithSize( message.body, self.lines_width) msg_color = self.tft.BLACK if message.priority == PRIORITY1: msg_color = self.tft.GREEN elif message.priority == PRIORITY2: msg_color = self.tft.BLUE elif message.priority == PRIORITY3: msg_color = self.tft.RED for s in msg_body_lines: if line_index >= self.lines_cnt: break self.dataLabels[ line_index].text = self.strExpandToSize( s, self.lines_width) self.dataLabels[line_index].textColor = msg_color line_index += 1 # Divider if line_index < self.lines_cnt: self.dataLabels[ line_index].text = self.strExpandToSize( "", self.lines_width) self.dataLabels[line_index].textColor = self.tft.BLACK line_index += 1 except BaseException as e: exc_type, exc_obj, exc_tb = sys.exc_info() fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1] print("updateUI::Error in line: ", exc_type, fname, exc_tb.tb_lineno, str(e)) self.dataLock.release() self.draw()
if capcode in capcodes_ambu: return SENDER_AMBU # Try to analyse the text return SENDER_UNKNOWN if __name__ == "__main__": print("") print("P2000 decoder v0.33 by Dmitrii Eliseev\n") print( "Run:\npython3 p2000.py --lcd=true|false [--filter=filter.txt] [--capcodes=capcodes.txt]" ) print("") print("Server running: http://{}:{}".format(utils.getIPAddress(), PORT_NUMBER)) print("API (GET): http://{}:{}/api/messages".format( utils.getIPAddress(), PORT_NUMBER)) print("Websocket: ws://{}:{}".format(utils.getIPAddress(), PORT_NUMBER_WS)) print("") parser = argparse.ArgumentParser() parser.add_argument("--lcd", dest="lcd", default="false") parser.add_argument("--filter", dest="filter", default="") parser.add_argument("--capcodes", dest="capcodes", default="") args = parser.parse_args() # Set current folder abs_path = os.path.abspath(__file__) dir_path = os.path.dirname(abs_path)
return SENDER_AMBU if capcode in capcodes_lfl: return SENDER_LFL if capcode in capcodes_knrm: retrun SENDER_KNRM # Try to analyse the text return SENDER_UNKNOWN if __name__ == "__main__": print("") print("P2000 decoder v0.33 by Dmitrii Eliseev\n") print("Run:\npython3 p2000.py --lcd=true|false [--filter=filter.txt] [--capcodes=capcodes.txt]") print("") print("Server running: http://{}:{}".format(utils.getIPAddress(), PORT_NUMBER)) print("API (GET): http://{}:{}/api/messages".format(utils.getIPAddress(), PORT_NUMBER)) print("Websocket: ws://{}:{}".format(utils.getIPAddress(), PORT_NUMBER_WS)) print("") parser = argparse.ArgumentParser() parser.add_argument("--lcd", dest="lcd", default="false") parser.add_argument("--filter", dest="filter", default="") parser.add_argument("--capcodes", dest="capcodes", default="") args = parser.parse_args() # Set current folder abs_path = os.path.abspath(__file__) dir_path = os.path.dirname(abs_path) os.chdir(dir_path)