def __init__(self, parent=None): super(Main_widget, self).__init__(parent) self.setWindowTitle("DDT4all") print "Scanning ECUs..." self.ecu_scan = ecu.Ecu_scanner() self.ecu_scan.qapp = app print "Done, %i loaded ECUs in database." % self.ecu_scan.getNumEcuDb() self.ecu_scan.send_report() self.paramview = None self.statusBar = gui.QStatusBar() self.setStatusBar(self.statusBar) self.connectedstatus = gui.QLabel() self.connectedstatus.setAlignment(core.Qt.AlignHCenter | core.Qt.AlignVCenter) self.protocolstatus = gui.QLabel() self.progressstatus = gui.QProgressBar() self.infostatus = gui.QLabel() self.connectedstatus.setFixedWidth(100) self.protocolstatus.setFixedWidth(200) self.progressstatus.setFixedWidth(150) self.infostatus.setFixedWidth(200) self.setConnected(True) self.refreshtimebox = gui.QSpinBox() self.refreshtimebox.setRange(100, 2000) self.refreshtimebox.setSingleStep(100) self.refreshtimebox.valueChanged.connect(self.changeRefreshTime) refrestimelabel = gui.QLabel("Rafraichissement:") self.statusBar.addWidget(self.connectedstatus) self.statusBar.addWidget(self.protocolstatus) self.statusBar.addWidget(self.progressstatus) self.statusBar.addWidget(refrestimelabel) self.statusBar.addWidget(self.refreshtimebox) self.statusBar.addWidget(self.infostatus) self.scrollview = gui.QScrollArea() self.scrollview.setWidgetResizable(False) self.setCentralWidget(self.scrollview) self.treedock_params = gui.QDockWidget(self) self.treeview_params = gui.QTreeWidget(self.treedock_params) self.treedock_params.setWidget(self.treeview_params) self.treeview_params.setHeaderLabels(["Screens"]) self.treeview_params.clicked.connect(self.changeScreen) self.treedock_logs = gui.QDockWidget(self) self.logview = gui.QTextEdit() self.logview.setReadOnly(True) self.treedock_logs.setWidget(self.logview) self.treedock_ecu = gui.QDockWidget(self) self.treeview_ecu = gui.QListWidget(self.treedock_ecu) self.treedock_ecu.setWidget(self.treeview_ecu) self.treeview_ecu.clicked.connect(self.changeECU) self.eculistwidget = Ecu_list(self.ecu_scan, self.treeview_ecu) self.treeview_eculist = gui.QDockWidget(self) self.treeview_eculist.setWidget(self.eculistwidget) self.addDockWidget(core.Qt.LeftDockWidgetArea, self.treeview_eculist) self.addDockWidget(core.Qt.LeftDockWidgetArea, self.treedock_ecu) self.addDockWidget(core.Qt.LeftDockWidgetArea, self.treedock_params) self.addDockWidget(core.Qt.BottomDockWidgetArea, self.treedock_logs) self.toolbar = self.addToolBar("File") scanaction = gui.QAction(gui.QIcon("icons/scan.png"), "Scanner les ECUs", self) scanaction.triggered.connect(self.scan) self.diagaction = gui.QAction(gui.QIcon("icons/dtc.png"), "Lire les Codes defauts", self) self.diagaction.triggered.connect(self.readDtc) self.diagaction.setEnabled(False) self.log = gui.QAction(gui.QIcon("icons/log.png"), "Full log", self) self.log.setCheckable(True) self.log.setChecked(options.log_all) self.log.triggered.connect(self.changeLogMode) self.expert = gui.QAction(gui.QIcon("icons/expert.png"), "Mode Expert", self) self.expert.setCheckable(True) self.expert.setChecked(options.promode) self.expert.triggered.connect(self.changeUserMode) self.autorefresh = gui.QAction(gui.QIcon("icons/autorefresh.png"), "Rafraichissement automatique", self) self.autorefresh.setCheckable(True) self.autorefresh.setChecked(options.auto_refresh) self.autorefresh.triggered.connect(self.changeAutorefresh) self.refresh = gui.QAction(gui.QIcon("icons/refresh.png"), "Rafraichir page", self) self.refresh.triggered.connect(self.refreshParams) self.refresh.setEnabled(not options.auto_refresh) self.hexinput = gui.QAction(gui.QIcon("icons/hex.png"), "Commande manuelle", self) self.hexinput.triggered.connect(self.hexeditor) self.hexinput.setEnabled(False) self.toolbar.addAction(scanaction) self.toolbar.addSeparator() self.toolbar.addAction(self.log) self.toolbar.addAction(self.expert) self.toolbar.addAction(self.autorefresh) self.toolbar.addSeparator() self.toolbar.addAction(self.refresh) self.toolbar.addSeparator() self.toolbar.addAction(self.diagaction) self.toolbar.addSeparator() self.toolbar.addAction(self.hexinput) vehicle_dir = "vehicles" if not os.path.exists(vehicle_dir): os.mkdir(vehicle_dir) ecu_files = [] for filename in os.listdir(vehicle_dir): basename, ext = os.path.splitext(filename) if ext == '.ecu': ecu_files.append(basename) menu = self.menuBar() diagmenu = menu.addMenu("Fichier") savevehicleaction = diagmenu.addAction("Sauvegarder ce vehicule") savevehicleaction.triggered.connect(self.saveEcus) diagmenu.addSeparator() for ecuf in ecu_files: ecuaction = diagmenu.addAction(ecuf) ecuaction.triggered.connect(lambda state, a=ecuf: self.loadEcu(a)) iskmenu = menu.addMenu("ISK") meg2isk = iskmenu.addAction("Megane II") meg2isk.triggered.connect(lambda: self.getISK('megane2'))
def __init__(self, parent = None): super(Main_widget, self).__init__(parent) self.sdsready = False self.ecunamemap = {} self.plugins = {} self.setWindowTitle(_("DDT4All")) self.ecu_scan = ecu.Ecu_scanner() self.ecu_scan.qapp = app options.ecu_scanner = self.ecu_scan print ("%i " + _("loaded ECUs in database.")) % self.ecu_scan.getNumEcuDb() if self.ecu_scan.getNumEcuDb() == 0: msgbox = gui.QMessageBox() msgbox.setIcon(gui.QMessageBox.Warning) msgbox.setText("No database found") msgbox.setInformativeText("Check documentation") msgbox.exec_() self.paramview = None self.docview = webkit.QWebView() self.docview.load(core.QUrl("https://github.com/cedricp/ddt4all/wiki")) self.docview.settings().setAttribute(webkit.QWebSettings.JavascriptEnabled, True) self.docview.settings().setAttribute(webkit.QWebSettings.PluginsEnabled, True) self.docview.settings().setAttribute(webkit.QWebSettings.AutoLoadImages, True) self.screennames = [] self.statusBar = gui.QStatusBar() self.setStatusBar(self.statusBar) self.connectedstatus = gui.QLabel() self.connectedstatus.setAlignment(core.Qt.AlignHCenter | core.Qt.AlignVCenter) self.protocolstatus = gui.QLabel() self.progressstatus = gui.QProgressBar() self.infostatus = gui.QLabel() self.connectedstatus.setFixedWidth(100) self.protocolstatus.setFixedWidth(200) self.progressstatus.setFixedWidth(150) self.infostatus.setFixedWidth(200) self.refreshtimebox = gui.QSpinBox() self.refreshtimebox.setRange(100, 2000) self.refreshtimebox.setSingleStep(100) self.refreshtimebox.valueChanged.connect(self.changeRefreshTime) refrestimelabel = gui.QLabel(_("Refresh rate (ms):")) self.cantimeout = gui.QSpinBox() self.cantimeout.setRange(0, 1000) self.cantimeout.setSingleStep(200) self.cantimeout.setValue(options.cantimeout) self.cantimeout.valueChanged.connect(self.changeCanTimeout) cantimeoutlabel = gui.QLabel(_("Can timeout (ms) [0:AUTO] :")) self.statusBar.addWidget(self.connectedstatus) self.statusBar.addWidget(self.protocolstatus) self.statusBar.addWidget(self.progressstatus) self.statusBar.addWidget(refrestimelabel) self.statusBar.addWidget(self.refreshtimebox) self.statusBar.addWidget(cantimeoutlabel) self.statusBar.addWidget(self.cantimeout) self.statusBar.addWidget(self.infostatus) self.tabbedview = gui.QTabWidget() self.setCentralWidget(self.tabbedview) self.scrollview = gui.QScrollArea() self.scrollview.setWidgetResizable(False) self.snifferview = sniffer.sniffer() self.tabbedview.addTab(self.docview, _("Documentation")) self.tabbedview.addTab(self.scrollview, _("Screen")) self.tabbedview.addTab(self.snifferview, _("CAN Sniffer")) if options.simulation_mode: self.buttonEditor = dataeditor.buttonEditor() self.requesteditor = dataeditor.requestEditor() self.dataitemeditor = dataeditor.dataEditor() self.ecuparameditor = dataeditor.ecuParamEditor() self.tabbedview.addTab(self.requesteditor, _("Requests")) self.tabbedview.addTab(self.dataitemeditor, _("Data")) self.tabbedview.addTab(self.buttonEditor, _("Buttons")) self.tabbedview.addTab(self.ecuparameditor, _("Ecu parameters")) screen_widget = gui.QWidget() self.treedock_widget = gui.QDockWidget(self) self.treedock_widget.setWidget(screen_widget) self.treeview_params = gui.QTreeWidget() self.treeview_params.setSortingEnabled(True) self.treeview_params.sortByColumn(0, core.Qt.AscendingOrder) self.screenmenu = gui.QMenuBar() treedock_layout = gui.QVBoxLayout() treedock_layout.addWidget(self.screenmenu) treedock_layout.addWidget(self.treeview_params) screen_widget.setLayout(treedock_layout) self.treeview_params.setHeaderLabels([_("Screens")]) self.treeview_params.clicked.connect(self.changeScreen) actionmenu = self.screenmenu.addMenu(_("Action")) cat_action = gui.QAction(_("New Category"), actionmenu) screen_action = gui.QAction(_("New Screen"), actionmenu) rename_action = gui.QAction(_("Rename"), actionmenu) actionmenu.addAction(cat_action) actionmenu.addAction(screen_action) actionmenu.addAction(rename_action) cat_action.triggered.connect(self.newCategory) screen_action.triggered.connect(self.newScreen) rename_action.triggered.connect(self.screenRename) self.treedock_logs = gui.QDockWidget(self) self.logview = gui.QTextEdit() self.logview.setReadOnly(True) self.treedock_logs.setWidget(self.logview) self.treedock_ecu = gui.QDockWidget(self) self.treeview_ecu = gui.QListWidget(self.treedock_ecu) self.treedock_ecu.setWidget(self.treeview_ecu) self.treeview_ecu.clicked.connect(self.changeECU) self.eculistwidget = Ecu_list(self.ecu_scan, self.treeview_ecu) self.treeview_eculist = gui.QDockWidget(self) self.treeview_eculist.setWidget(self.eculistwidget) self.addDockWidget(core.Qt.LeftDockWidgetArea, self.treeview_eculist) self.addDockWidget(core.Qt.LeftDockWidgetArea, self.treedock_ecu) self.addDockWidget(core.Qt.LeftDockWidgetArea, self.treedock_widget) self.addDockWidget(core.Qt.BottomDockWidgetArea, self.treedock_logs) self.toolbar = self.addToolBar(_("File")) self.diagaction = gui.QAction(gui.QIcon("icons/dtc.png"), _("Read DTC"), self) self.diagaction.triggered.connect(self.readDtc) self.diagaction.setEnabled(False) self.log = gui.QAction(gui.QIcon("icons/log.png"), _("Full log"), self) self.log.setCheckable(True) self.log.setChecked(options.log_all) self.log.triggered.connect(self.changeLogMode) self.expert = gui.QAction(gui.QIcon("icons/expert.png"), _("Expert mode (enable writing)"), self) self.expert.setCheckable(True) self.expert.setChecked(options.promode) self.expert.triggered.connect(self.changeUserMode) self.autorefresh = gui.QAction(gui.QIcon("icons/autorefresh.png"), _("Auto refresh"), self) self.autorefresh.setCheckable(True) self.autorefresh.setChecked(options.auto_refresh) self.autorefresh.triggered.connect(self.changeAutorefresh) self.refresh = gui.QAction(gui.QIcon("icons/refresh.png"), _("Refresh (one shot)"), self) self.refresh.triggered.connect(self.refreshParams) self.refresh.setEnabled(not options.auto_refresh) self.hexinput = gui.QAction(gui.QIcon("icons/hex.png"), _("Manual command"), self) self.hexinput.triggered.connect(self.hexeditor) self.hexinput.setEnabled(False) self.sdscombo = gui.QComboBox() self.sdscombo.setFixedWidth(300) self.sdscombo.currentIndexChanged.connect(self.changeSds) self.sdscombo.setEnabled(False) self.zoominbutton = gui.QPushButton("Zoom In") self.zoomoutbutton = gui.QPushButton("Zoom Out") self.zoominbutton.clicked.connect(self.zoomin) self.zoomoutbutton.clicked.connect(self.zoomout) self.toolbar.addSeparator() self.toolbar.addAction(self.log) self.toolbar.addAction(self.expert) self.toolbar.addSeparator() self.toolbar.addAction(self.autorefresh) self.toolbar.addAction(self.refresh) self.toolbar.addSeparator() self.toolbar.addAction(self.diagaction) self.toolbar.addSeparator() self.toolbar.addAction(self.hexinput) self.toolbar.addSeparator() self.toolbar.addWidget(self.sdscombo) self.toolbar.addSeparator() self.toolbar.addWidget(self.zoominbutton) self.toolbar.addWidget(self.zoomoutbutton) if options.simulation_mode: self.toolbar.addSeparator() self.ui_edit_button = gui.QPushButton("UI Edit") self.ui_edit_button.setCheckable(True) self.toolbar.addSeparator() self.toolbar.addWidget(self.ui_edit_button) self.ui_edit_button.clicked.connect(self.toggle_edit) vehicle_dir = "vehicles" if not os.path.exists(vehicle_dir): os.mkdir(vehicle_dir) ecu_files = [] for filename in os.listdir(vehicle_dir): basename, ext = os.path.splitext(filename) if ext == '.ecu': ecu_files.append(basename) menu = self.menuBar() diagmenu = menu.addMenu(_("File")) xmlopenaction = diagmenu.addAction("Open XML") newecuction = diagmenu.addAction(_("Create New ECU")) saveecuaction = diagmenu.addAction(_("Save current ECU")) diagmenu.addSeparator() savevehicleaction = diagmenu.addAction(_("Save ECU list")) savevehicleaction.triggered.connect(self.saveEcus) saveecuaction.triggered.connect(self.saveEcu) newecuction.triggered.connect(self.newEcu) xmlopenaction.triggered.connect(self.openxml) diagmenu.addSeparator() zipdbaction = diagmenu.addAction(_("Zip database")) zipdbaction.triggered.connect(self.zipdb) diagmenu.addSeparator() for ecuf in ecu_files: ecuaction = diagmenu.addAction(ecuf) ecuaction.triggered.connect(lambda state, a=ecuf: self.loadEcu(a)) plugins_menu = menu.addMenu(_("Plugins")) category_menus = {} plugins = glob.glob("./ddtplugins/*.py") for plugin in plugins: try: modulename = os.path.basename(plugin).replace(".py", "") plug = imp.load_source(modulename, plugin) category = plug.category name = plug.plugin_name need_hw = plug.need_hw #if options.simulation_mode and need_hw: # continue if not category in category_menus: category_menus[category] = plugins_menu.addMenu(category) plug_action = category_menus[category].addAction(name) plug_action.triggered.connect(lambda state, a=plug.plugin_entry: self.launchPlugin(a)) self.plugins[modulename] = plug except Exception as e: print _("Cannot load plugin %s, %s") % (plugin, traceback.format_exc()) self.setConnected(True)
def __init__(self, parent = None): super(Main_widget, self).__init__(parent) self.plugins = {} self.setWindowTitle(_("DDT4All")) print _("Scanning ECUs...") self.ecu_scan = ecu.Ecu_scanner() self.ecu_scan.qapp = app options.ecu_scanner = self.ecu_scan print ("%i " + _("loaded ECUs in database.")) % self.ecu_scan.getNumEcuDb() self.paramview = None self.screennames = [] self.statusBar = gui.QStatusBar() self.setStatusBar(self.statusBar) self.connectedstatus = gui.QLabel() self.connectedstatus.setAlignment(core.Qt.AlignHCenter | core.Qt.AlignVCenter) self.protocolstatus = gui.QLabel() self.progressstatus = gui.QProgressBar() self.infostatus = gui.QLabel() self.connectedstatus.setFixedWidth(100) self.protocolstatus.setFixedWidth(200) self.progressstatus.setFixedWidth(150) self.infostatus.setFixedWidth(200) self.refreshtimebox = gui.QSpinBox() self.refreshtimebox.setRange(100, 2000) self.refreshtimebox.setSingleStep(100) self.refreshtimebox.valueChanged.connect(self.changeRefreshTime) refrestimelabel = gui.QLabel(_("Refresh rate (ms):")) self.statusBar.addWidget(self.connectedstatus) self.statusBar.addWidget(self.protocolstatus) self.statusBar.addWidget(self.progressstatus) self.statusBar.addWidget(refrestimelabel) self.statusBar.addWidget(self.refreshtimebox) self.statusBar.addWidget(self.infostatus) self.tabbedview = gui.QTabWidget() self.setCentralWidget(self.tabbedview) self.scrollview = gui.QScrollArea() self.scrollview.setWidgetResizable(False) self.tabbedview.addTab(self.scrollview, _("Screen")) if options.simulation_mode: self.buttonEditor = dataeditor.buttonEditor() self.requesteditor = dataeditor.requestEditor() self.dataitemeditor = dataeditor.dataEditor() self.ecuparameditor = dataeditor.ecuParamEditor() self.tabbedview.addTab(self.requesteditor, _("Requests")) self.tabbedview.addTab(self.dataitemeditor, _("Data")) self.tabbedview.addTab(self.buttonEditor, _("Buttons")) self.tabbedview.addTab(self.ecuparameditor, _("Ecu parameters")) screen_widget = gui.QWidget() self.treedock_widget = gui.QDockWidget(self) self.treedock_widget.setWidget(screen_widget) self.treeview_params = gui.QTreeWidget() self.screenmenu = gui.QMenuBar() treedock_layout = gui.QVBoxLayout() treedock_layout.addWidget(self.screenmenu) treedock_layout.addWidget(self.treeview_params) screen_widget.setLayout(treedock_layout) self.treeview_params.setHeaderLabels([_("Screens")]) self.treeview_params.clicked.connect(self.changeScreen) actionmenu = self.screenmenu.addMenu(_("Action")) cat_action = gui.QAction(_("New Category"), actionmenu) screen_action = gui.QAction(_("New Screen"), actionmenu) rename_action = gui.QAction(_("Rename"), actionmenu) actionmenu.addAction(cat_action) actionmenu.addAction(screen_action) actionmenu.addAction(rename_action) cat_action.triggered.connect(self.newCategory) screen_action.triggered.connect(self.newScreen) rename_action.triggered.connect(self.screenRename) self.treedock_logs = gui.QDockWidget(self) self.logview = gui.QTextEdit() self.logview.setReadOnly(True) self.treedock_logs.setWidget(self.logview) self.treedock_ecu = gui.QDockWidget(self) self.treeview_ecu = gui.QListWidget(self.treedock_ecu) self.treedock_ecu.setWidget(self.treeview_ecu) self.treeview_ecu.clicked.connect(self.changeECU) self.eculistwidget = Ecu_list(self.ecu_scan, self.treeview_ecu) self.treeview_eculist = gui.QDockWidget(self) self.treeview_eculist.setWidget(self.eculistwidget) self.addDockWidget(core.Qt.LeftDockWidgetArea, self.treeview_eculist) self.addDockWidget(core.Qt.LeftDockWidgetArea, self.treedock_ecu) self.addDockWidget(core.Qt.LeftDockWidgetArea, self.treedock_widget) self.addDockWidget(core.Qt.BottomDockWidgetArea, self.treedock_logs) self.toolbar = self.addToolBar(_("File")) scanaction = gui.QAction(gui.QIcon("icons/scan.png"), _("Scan ECUs"), self) scanaction.triggered.connect(self.scan) self.diagaction = gui.QAction(gui.QIcon("icons/dtc.png"), _("Read DTC"), self) self.diagaction.triggered.connect(self.readDtc) self.diagaction.setEnabled(False) self.log = gui.QAction(gui.QIcon("icons/log.png"), _("Full log"), self) self.log.setCheckable(True) self.log.setChecked(options.log_all) self.log.triggered.connect(self.changeLogMode) self.expert = gui.QAction(gui.QIcon("icons/expert.png"), _("Expert mode (enable writing)"), self) self.expert.setCheckable(True) self.expert.setChecked(options.promode) self.expert.triggered.connect(self.changeUserMode) self.autorefresh = gui.QAction(gui.QIcon("icons/autorefresh.png"), _("Auto refresh"), self) self.autorefresh.setCheckable(True) self.autorefresh.setChecked(options.auto_refresh) self.autorefresh.triggered.connect(self.changeAutorefresh) self.refresh = gui.QAction(gui.QIcon("icons/refresh.png"), _("Refresh (one shot)"), self) self.refresh.triggered.connect(self.refreshParams) self.refresh.setEnabled(not options.auto_refresh) self.hexinput = gui.QAction(gui.QIcon("icons/hex.png"), _("Manual command"), self) self.hexinput.triggered.connect(self.hexeditor) self.hexinput.setEnabled(False) self.toolbar.addAction(scanaction) self.toolbar.addSeparator() self.toolbar.addAction(self.log) self.toolbar.addAction(self.expert) self.toolbar.addAction(self.autorefresh) self.toolbar.addSeparator() self.toolbar.addAction(self.refresh) self.toolbar.addSeparator() self.toolbar.addAction(self.diagaction) self.toolbar.addSeparator() self.toolbar.addAction(self.hexinput) vehicle_dir = "vehicles" if not os.path.exists(vehicle_dir): os.mkdir(vehicle_dir) ecu_files = [] for filename in os.listdir(vehicle_dir): basename, ext = os.path.splitext(filename) if ext == '.ecu': ecu_files.append(basename) menu = self.menuBar() diagmenu = menu.addMenu(_("File")) newecuction = diagmenu.addAction(_("Create New ECU")) saveecuaction = diagmenu.addAction(_("Save current ECU")) diagmenu.addSeparator() savevehicleaction = diagmenu.addAction(_("Save ECU list")) savevehicleaction.triggered.connect(self.saveEcus) saveecuaction.triggered.connect(self.saveEcu) newecuction.triggered.connect(self.newEcu) diagmenu.addSeparator() for ecuf in ecu_files: ecuaction = diagmenu.addAction(ecuf) ecuaction.triggered.connect(lambda state, a=ecuf: self.loadEcu(a)) plugins_menu = menu.addMenu(_("Plugins")) category_menus = {} plugins = glob.glob("./plugins/*.py") for plugin in plugins: try: modulename = os.path.basename(plugin).replace(".py", "") plug = imp.load_source(modulename, plugin) category = plug.category name = plug.plugin_name if not category in category_menus: category_menus[category] = plugins_menu.addMenu(category) plug_action = category_menus[category].addAction(name) plug_action.triggered.connect(lambda state, a=plug.plugin_entry: self.launchPlugin(a)) self.plugins[modulename] = plug except Exception as e: print _("Cannot load plugin %s, %s") % (plugin, traceback.format_exc()) self.setConnected(True)