Beispiel #1
0
 def handle_param_value(self, param_value):
     try:
         ParamManager().update_param(param_value.param_id,
                                     param_value.param_index,
                                     param_value.param_count,
                                     value_ParamType(param_value.value))
     except ValueError as ex:
         log.error(repr(ex))
Beispiel #2
0
 def create_comm(self, port, baudrate, engine_id, log_db, log_name):
     try:
         CommManager().clear()
         CommManager().register(CommThread(port, baudrate, engine_id, log_db, log_name))
         logging.info("DEV: %s: opened", port)
         TimeRefManager().start()
         ParamManager().retrieve_all()
     except serial.SerialException as ex:
         logging.error("DEV: %s: %s", port, repr(ex))
Beispiel #3
0
    def update_params(self, **kvargs):
        """Param update slot"""
        for k, p in sorted(ParamManager().parameters.iteritems()):
            row = self.param_rows.get(k)
            if row:
                row.update()
            else:
                row = ParamBoxRow(p)
                self.param_rows[k] = row
                self.param_listbox.add(row)

        # TODO: recalculate gauge min/max and strip position by
        # RPM_LIMIT, BATT_TYPE, BATT_CELLS, TEMP_OVERHEAT

        # remove old rows
        for k, row in self.param_rows.items():
            if not ParamManager().parameters.has_key(k):
                self.param_listbox.remove(row)
                del self.param_rows[k]
Beispiel #4
0
    def __init__(self):
        builder = get_builder('ccgui.ui')
        self.window = builder.get_object('ccgui_window')
        builder.connect_signals(self)

        self.rpm_gauge = GtkGauge()
        self.rpm_gauge.name = 'RPM\n<span foreground="orange"><i><small>x1000</small></i></span>'
        self.rpm_gauge.start_value = 0
        self.rpm_gauge.end_value = 10
        self.rpm_gauge.initial_step = 1
        self.rpm_gauge.sub_step = 0.2
        self.rpm_gauge.drawing_step = 1
        self.rpm_gauge.strip_color_order = 'GYR'
        self.rpm_gauge.green_strip_start = 0
        self.rpm_gauge.yellow_strip_start = 7
        self.rpm_gauge.red_strip_start = 8
        self.rpm_gauge.smooth_interval = 50

        self.temp_gauge = GtkGauge()
        self.temp_gauge.name = 'Temp\n<span foreground="orange"><i>°C</i></span>'
        self.temp_gauge.start_value = 0
        self.temp_gauge.end_value = 130
        self.temp_gauge.initial_step = 10
        self.temp_gauge.sub_step = 2.0
        self.temp_gauge.drawing_step = 20
        self.temp_gauge.strip_color_order = 'GYR'
        self.temp_gauge.green_strip_start = 0
        self.temp_gauge.yellow_strip_start = 100
        self.temp_gauge.red_strip_start = 110
        self.temp_gauge.smooth_interval = 50

        self.batt_gauge = GtkGauge()
        self.batt_gauge.name = 'Battery\n<span foreground="orange"><i>V</i></span>'
        self.batt_gauge.start_value = 0
        self.batt_gauge.end_value = 12
        self.batt_gauge.initial_step = 1
        self.batt_gauge.sub_step = 0.2
        self.batt_gauge.drawing_step = 2
        self.batt_gauge.strip_color_order = 'RYG'
        self.batt_gauge.green_strip_start = 5
        self.batt_gauge.yellow_strip_start = 4
        self.batt_gauge.red_strip_start = 0
        self.batt_gauge.smooth_interval = 50

        gbox = builder.get_object('gauge_box')
        gbox.pack_start(self.rpm_gauge, True, True, 0)
        gbox.pack_start(self.temp_gauge, True, True, 0)
        gbox.pack_start(self.batt_gauge, True, True, 0)

        # Status message tree view
        self.status_treeview = builder.get_object('status_treeview')
        self.status_store = Gtk.ListStore(str, str)
        self.status_treeview.set_model(self.status_store)
        renderer1 = Gtk.CellRendererText()
        renderer2 = Gtk.CellRendererText()
        column1 = Gtk.TreeViewColumn("Field", renderer1, text=0)
        column2 = Gtk.TreeViewColumn("Value", renderer2, text=1)
        self.status_treeview.append_column(column1)
        self.status_treeview.append_column(column2)

        self.window.set_default_size(640, 480)
        self.window.show_all()

        # store ref to some widgets
        self.param_listbox = builder.get_object('param_listbox')
        self.status_bar = builder.get_object('status_bar')
        self.ignition_switch = builder.get_object('ignition_switch')
        self.starter_switch = builder.get_object('starter_switch')

        # param widgets
        self.param_rows = {}

        # connect model signals
        ParamManager().sig_changed.connect(self.update_params)
        StatusManager().sig_changed.connect(self.update_status)
        StatusTextManager().sig_changed.connect(self.update_statustext)
Beispiel #5
0
    def on_param_save_clicked(self, *args):
        logging.debug("onParamSave")

        ParamManager().sync()
        CommandManger().save_config()
Beispiel #6
0
    def on_param_load_clicked(self, *args):
        logging.debug("onParamLoad")

        if CommandManger().load_config():
            ParamManager().retrieve_all()
Beispiel #7
0
    def on_param_send_clicked(self, *args):
        logging.debug("onParamSend")

        ParamManager().sync()
Beispiel #8
0
    def on_param_request_clicked(self, *args):
        logging.debug("onParamRequest")

        ParamManager().retrieve_all()