def __init__(self): """ Constructor """ pygame.init() pygame.mouse.set_visible(False) # seems to suit RPi self._color_depth = 16 if platform.system() == "Linux": pygame.display.set_mode((0, 0), pygame.FULLSCREEN, self._color_depth) else: pygame.display.set_mode((320, 240), 0, self._color_depth) self._surface = pygame.display.get_surface() self._clock = pygame.time.Clock() self._width = self._surface.get_width() self._height = self._surface.get_height() self._subwindow_alpha = 200 self._font_size = int(self._height / 14) self._font = pygame.font.SysFont(pygame.font.get_default_font(), self._font_size) self._font_aa = 0 self._fg_color = pygame.Color(255, 191, 0) self._bg_color = pygame.Color(0, 0, 0) self._dim_color = pygame.Color(200, 140, 0) self._log_lines = 4 self._log_msg_id = 0 self._log_surface = pygame.Surface( (self._width / 2, self._font_size * self._log_lines), 0, self._color_depth) self._log_surface.set_alpha(self._subwindow_alpha) self._log_queue = [] logger = PM() logger.set(self.log) self._fps_log_id = 0 self._frame_no = 0 self.load_resources() pygame.time.set_timer(PMScreen.LOG_FPS_EVENT, 10000) pygame.time.set_timer(PMScreen.LOG_STATS_EVENT, 30000) pygame.time.set_timer(PMScreen.ONE_SEC_EVENT, 1000) self._window = None self._windows = [] self._pos_log_id = 0 self._mouse_down_pos = (0, 0) self._mouse_down_mark_timeout = 0
def __init__(self): """ Constructor """ pygame.init() pygame.mouse.set_visible(False) # seems to suit RPi self._color_depth = 16 if platform.system() == "Linux": pygame.display.set_mode((0, 0), pygame.FULLSCREEN, self._color_depth) else: pygame.display.set_mode((320, 240), 0, self._color_depth) self._surface = pygame.display.get_surface() self._clock = pygame.time.Clock() self._width = self._surface.get_width() self._height = self._surface.get_height() self._subwindow_alpha = 200 self._font_size = int(self._height / 14) self._font = pygame.font.SysFont(pygame.font.get_default_font(), self._font_size) self._font_aa = 0 self._fg_color = pygame.Color(255, 191, 0) self._bg_color = pygame.Color(0, 0, 0) self._dim_color = pygame.Color(200, 140, 0) self._log_lines = 4 self._log_msg_id = 0 self._log_surface = pygame.Surface((self._width / 2, self._font_size * self._log_lines), 0, self._color_depth) self._log_surface.set_alpha(self._subwindow_alpha) self._log_queue = [] logger = PM() logger.set(self.log) self._fps_log_id = 0 self._frame_no = 0 self.load_resources() pygame.time.set_timer(PMScreen.LOG_FPS_EVENT, 10000) pygame.time.set_timer(PMScreen.LOG_STATS_EVENT, 30000) pygame.time.set_timer(PMScreen.ONE_SEC_EVENT, 1000) self._window = None self._windows = [] self._pos_log_id = 0 self._mouse_down_pos = (0, 0) self._mouse_down_mark_timeout = 0
def setUp(self): self._ecu_packet = None self._tcu_packet = None self._connection = None self._parameters = None self._ecu_context = None self._tcu_context = None self._ecu_parameters = None self._ecu_switch_parameters = None self._ecu_calculated_parameters = None self._tcu_parameters = None self._tcu_calculated_parameters = None self._tcu_switch_parameters = None logger = PM() logger.set(self.log)
log_and_csv_name_ts = time.time() logFormatter = logging.Formatter("%(asctime)s [%(threadName)-12.12s] [%(levelname)-5.5s] %(message)s") logger = logging.getLogger() fileHandler = logging.FileHandler('/media/datalogs/pimonitor-log/{}.log'.format(log_and_csv_name_ts)) fileHandler.setFormatter(logFormatter) logger.addHandler(fileHandler) consoleHandler = logging.StreamHandler(sys.stdout) consoleHandler.setFormatter(logFormatter) logger.addHandler(consoleHandler) logger.setLevel(logging.DEBUG) foo = PM() foo.set(logger) logger.info('Lets do this!') csv_file = open('/media/datalogs/pimonitor-log/{}.csv'.format(log_and_csv_name_ts), 'w') writer = csv.writer(csv_file) # TODO: Maybe pickle the parameters. Does it load faster? parser = PMXmlParser() defined_parameters = parser.parse("logger_STD_EN_v336.xml") logger.info('-----------------------------------------------------------------------') logger.info('Defined Parameters') logger.info('-----------------------------------------------------------------------') for p in defined_parameters: logger.info(p.to_string())