def setup(self): port = ask_for_port(os.path.join("config", "ports.cfg")) if port is None: self.start_thread = False print "Running in debug mode - no serial port connected" else: self.start_thread = True self.read_config() print "Logging to %s" % self.general_options["database"] self.connection = sql.connect(self.general_options["database"], detect_types=(sql.PARSE_DECLTYPES | sql.PARSE_COLNAMES)) self.config_database(self.connection, False) desc_sets = self.load_can_descriptors() decoder = TransparentMessageDecoder([desc_set for (source, desc_set) in desc_sets]) #decoder = XOMBIEDecoder([desc_set for (source, desc_set) in desc_sets]) self.window = TelemetryViewerWindow(self, "Telemetry Viewer", desc_sets) if self.start_thread: stream = TransparentStream(decoder, self.window.logger, port) ## stream = XOMBIEStream(port, decoder, self.window.logger, ## self.general_options["board_address"]) else: stream = None self.xombie_thread = TransparentThread(self.connection, stream) link(self.lastWindowClosed, self.closeEvent)
def __init__(self, conn, stream, parent=None): QtCore.QThread.__init__(self, parent) self.stream = stream self.connection = conn self.timer = self.commit_timer = None link(self.started, self.setup)
def setup(self): self.timer = QtCore.QTimer() self.commit_timer = QtCore.QTimer() link(self.commit_timer.timeout, self.commit_data) link(self.timer.timeout, self.process) self.commit_timer.start(5000) self.timer.start(500)
def make_new_tab(self): new_tab = NewTabViewSelector(self.tabWidget, self.tab_types, self.tabWidget) if new_tab.view_icon: self.tabWidget.addTab(new_tab, find_icon(new_tab.view_icon), "A New Tab") else: self.tabWidget.addTab(new_tab, "A New Tab") self.tabWidget.setCurrentWidget(new_tab) self.tabs.append(new_tab) link(new_tab.choice_selected, self.transform_tab)
def __init__(self, conn, stream, parent=None): QtCore.QThread.__init__(self, parent) self.stream = stream self.connection = conn self.timer = self.commit_timer = None self.should_query = False self.should_test = False self.should_reassociate = False self.should_discover = False link(self.started, self.setup)
def __init__(self, application, title, desc_sets): QtGui.QMainWindow.__init__(self) self.title = title self.app = application self.setWindowTitle(title) self.icon_cache = {} self.tab_types = [] for view in [LiveGraphTabView, HistoricalGraphTabView, BatteryScatterPlotTabView]: self.tab_types.append((view.view_name, find_icon(view.view_icon), view.view_desc, view.view_id)) self._ui_setup() self.tabWidget.setMovable(True) self.tabs = [] #Take the CAN descriptions from the *.can.json files #and place them in the TreeWidget so that we can drag'n'drop them #to the main graph view self.canTreeWidget.add_descriptors(desc_sets) self.message_queue = Queue() self.logger = ConsoleLogger(self.message_queue) self.console_timer = QtCore.QTimer(self) self.redraw_timer = QtCore.QTimer(self) self.color_timer = QtCore.QTimer(self) link(self.console_timer.timeout, self.update_console) link(self.redraw_timer.timeout, self.redraw) self.console_timer.start(50) self.redraw_timer.start(100)
def setup(self): self.got_heartbeat = False self.checking_heartbeat = False self.checking_assoc = False self.heartbeat_timer = QtCore.QTimer() self.heartbeat_timer.setSingleShot(True) link(self.heartbeat_timer.timeout, self.check_timeout) self.timer = QtCore.QTimer() self.commit_timer = QtCore.QTimer() link(self.commit_timer.timeout, self.commit_data) link(self.timer.timeout, self.process) self.stream.add_callback(0x85, self.mark_heartbeat) self.stream.add_callback(0xC2, self.print_histogram) self.stream.add_callback(0xE2, self.print_test) self.stream.start() self.commit_timer.start(5000) self.timer.start(100)
def _ui_setup(self): "Largely autogenerated layout code to setup interface" self.centralwidget = QtGui.QWidget(self) self.verticalLayout = QtGui.QVBoxLayout(self.centralwidget) self.vsplitter = QtGui.QSplitter(self.centralwidget) self.vsplitter.setOrientation(QtCore.Qt.Vertical) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(1) sizePolicy.setVerticalStretch(1) sizePolicy.setHeightForWidth(self.vsplitter.sizePolicy().hasHeightForWidth()) self.vsplitter.setSizePolicy(sizePolicy) self.hsplitter = QtGui.QSplitter(self.vsplitter) self.hsplitter.setOrientation(QtCore.Qt.Horizontal) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(1) sizePolicy.setVerticalStretch(1) sizePolicy.setHeightForWidth(self.hsplitter.sizePolicy().hasHeightForWidth()) self.hsplitter.setSizePolicy(sizePolicy) self.canTreeWidget = SignalTreeWidget(self.hsplitter) self.canTreeWidget.setMinimumSize(QtCore.QSize(300, 300)) self.canTreeWidget.setObjectName("canTreeWidget") self.tabWidget = TabViewContainer(self.hsplitter) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(1) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.tabWidget.sizePolicy().hasHeightForWidth()) self.tabWidget.setSizePolicy(sizePolicy) self.tabWidget.setMinimumSize(QtCore.QSize(500, 300)) self.tabWidget.setObjectName("tabWidget") self.hsplitter.addWidget(self.canTreeWidget) self.hsplitter.addWidget(self.tabWidget) #Debugging Console self.console = QtGui.QTextEdit(self.vsplitter) self.console.setReadOnly(True) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.console.sizePolicy().hasHeightForWidth()) self.console.setSizePolicy(sizePolicy) self.console.setMinimumSize(QtCore.QSize(0, 100)) self.console.setMaximumSize(QtCore.QSize(2000, 2000)) self.console.setObjectName("console") self.vsplitter.addWidget(self.hsplitter) self.vsplitter.addWidget(self.console) self.setCentralWidget(self.centralwidget) self.centralwidget.setLayout(self.verticalLayout) self.verticalLayout.addWidget(self.vsplitter) self.menubar = QtGui.QMenuBar(self) self.menubar.setGeometry(QtCore.QRect(0, 0, 878, 19)) self.menubar.setObjectName("menubar") self.menuFile = QtGui.QMenu(self.menubar) self.menuFile.setObjectName("menuFile") self.setMenuBar(self.menubar) self.toolBar = QtGui.QToolBar(self) self.toolBar.setObjectName("toolBar") self.toolBar.setToolButtonStyle(QtCore.Qt.ToolButtonIconOnly) self.makeTabIcon = find_icon("list-add.png") self.makeTabAction = QtGui.QAction(self.makeTabIcon, " ", self) link(self.makeTabAction.triggered, self.make_new_tab) self.makeTabButton = QtGui.QToolButton() self.makeTabButton.setDefaultAction(self.makeTabAction) self.toolBar.addWidget(self.makeTabButton) self.sendQueryIcon = find_icon("emblem-system.png") self.sendQueryAction = QtGui.QAction(self.sendQueryIcon, "", self) self.sendQueryButton = QtGui.QToolButton() self.sendQueryButton.setDefaultAction(self.sendQueryAction) self.toolBar.addWidget(self.sendQueryButton) def trigger_xombie_query(): if self.app.xombie_thread.isRunning(): app.xombie_thread.should_query = True link(self.sendQueryAction.triggered, trigger_xombie_query) self.sendTestIcon = find_icon("network-wireless.png") self.sendTestAction = QtGui.QAction(self.sendTestIcon, "", self) self.sendTestButton = QtGui.QToolButton() self.sendTestButton.setDefaultAction(self.sendTestAction) self.toolBar.addWidget(self.sendTestButton) def trigger_xombie_test(): if self.app.xombie_thread.isRunning(): app.xombie_thread.should_test = True link(self.sendTestAction.triggered, trigger_xombie_test) self.reassociateIcon = find_icon("go-jump.png") self.reassociateAction = QtGui.QAction(self.reassociateIcon, "", self) self.reassociateButton = QtGui.QToolButton() self.reassociateButton.setDefaultAction(self.reassociateAction) self.toolBar.addWidget(self.reassociateButton) def trigger_reassociate(): if self.app.xombie_thread.isRunning(): app.xombie_thread.should_reassociate = True link(self.reassociateAction.triggered, trigger_reassociate) self.nodeDiscoverIcon = find_icon("applications-internet.png") self.nodeDiscoverAction = QtGui.QAction(self.nodeDiscoverIcon, "", self) self.nodeDiscoverButton = QtGui.QToolButton() self.nodeDiscoverButton.setDefaultAction(self.nodeDiscoverAction) self.toolBar.addWidget(self.nodeDiscoverButton) def trigger_node_discover(): if self.app.xombie_thread.isRunning(): app.xombie_thread.should_discover = True link(self.nodeDiscoverAction.triggered, trigger_node_discover) self.addToolBar(QtCore.Qt.TopToolBarArea, self.toolBar) #self.insertToolBarBreak(self.toolBar) self.cornerMakeTabButton = QtGui.QToolButton() self.cornerMakeTabButton.setDefaultAction(self.makeTabAction) self.cornerMakeTabButton.setToolButtonStyle(QtCore.Qt.ToolButtonIconOnly) self.tabWidget.setCornerWidget(self.cornerMakeTabButton, QtCore.Qt.TopLeftCorner) self.statusBar = QtGui.QStatusBar(self) self.statusBar.setObjectName("statusBar") self.setStatusBar(self.statusBar)