-
Notifications
You must be signed in to change notification settings - Fork 166
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
226 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,15 @@ | ||
SOURCES += \ | ||
$$PWD/PeakCanDriver.cpp \ | ||
$$PWD/PeakCanInterface.cpp | ||
$$PWD/PeakCanInterface.cpp \ | ||
$$PWD/PeakCanSetupPage.cpp | ||
|
||
win32:LIBS += -L$$PWD/pcan-basic-api/Win32/VC_LIB/ -lPCANBasic | ||
win32:INCLUDEPATH += $$PWD/pcan-basic-api/Win32/VC_LIB | ||
win32:DEPENDPATH += $$PWD/pcan-basic-api/Win32/VC_LIB | ||
|
||
HEADERS += \ | ||
$$PWD/PeakCanInterface.h | ||
$$PWD/PeakCanInterface.h \ | ||
$$PWD/PeakCanSetupPage.h | ||
|
||
FORMS += \ | ||
$$PWD/PeakCanSetupPage.ui |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
#include "PeakCanSetupPage.h" | ||
#include "ui_PeakCanSetupPage.h" | ||
|
||
#include <Backend.h> | ||
#include <model/MeasurementInterface.h> | ||
#include <window/SetupDialog/SetupDialog.h> | ||
#include "PeakCanInterface.h" | ||
|
||
PeakCanSetupPage::PeakCanSetupPage(QWidget *parent) : | ||
QWidget(parent), | ||
ui(new Ui::PeakCanSetupPage), | ||
_mi(0), | ||
_enable_ui_updates(true) | ||
{ | ||
ui->setupUi(this); | ||
|
||
connect(ui->cbListenOnly, SIGNAL(stateChanged(int)), this, SLOT(updateUI())); | ||
connect(ui->cbAutoRestart, SIGNAL(stateChanged(int)), this, SLOT(updateUI())); | ||
connect(ui->cbBitrate, SIGNAL(currentIndexChanged(int)), this, SLOT(updateUI())); | ||
} | ||
|
||
PeakCanSetupPage::~PeakCanSetupPage() | ||
{ | ||
delete ui; | ||
} | ||
|
||
void PeakCanSetupPage::onSetupDialogCreated(SetupDialog &dlg) | ||
{ | ||
dlg.addPage(this); | ||
connect(&dlg, SIGNAL(onShowInterfacePage(SetupDialog&,MeasurementInterface*)), this, SLOT(onShowInterfacePage(SetupDialog&,MeasurementInterface*))); | ||
} | ||
|
||
void PeakCanSetupPage::onShowInterfacePage(SetupDialog &dlg, MeasurementInterface *mi) | ||
{ | ||
PeakCanInterface *pci = 0; | ||
if (mi && (backend().getDriverName(mi->canInterface()) == "PCAN")) { | ||
_mi = mi; | ||
pci = (PeakCanInterface*)backend().getInterfaceById(_mi->canInterface()); | ||
} else { | ||
return; | ||
} | ||
|
||
_enable_ui_updates = false; | ||
|
||
ui->laDriver->setText(backend().getDriverName(_mi->canInterface())); | ||
ui->laInterfaceName->setText(backend().getInterfaceName(_mi->canInterface())); | ||
|
||
ui->cbListenOnly->setChecked(_mi->isListenOnlyMode()); | ||
ui->cbAutoRestart->setChecked(_mi->doAutoRestart()); | ||
|
||
ui->cbBitrate->clear(); | ||
foreach (int br, pci->getAvailableBitrates()) { | ||
ui->cbBitrate->addItem(QString::number(br)); | ||
} | ||
ui->cbBitrate->setCurrentText(QString::number(_mi->bitrate())); | ||
|
||
_enable_ui_updates = true; | ||
|
||
dlg.displayPage(this); | ||
updateUI(); | ||
} | ||
|
||
void PeakCanSetupPage::updateUI() | ||
{ | ||
PeakCanInterface *pci = (PeakCanInterface*)backend().getInterfaceById(_mi->canInterface()); | ||
|
||
if ((!_enable_ui_updates) || (pci==0)) { | ||
return; | ||
} | ||
|
||
_mi->setListenOnlyMode(ui->cbListenOnly->isChecked()); | ||
_mi->setAutoRestart(ui->cbAutoRestart->isChecked()); | ||
_mi->setBitrate(ui->cbBitrate->currentText().toInt()); | ||
} | ||
|
||
Backend &PeakCanSetupPage::backend() | ||
{ | ||
return Backend::instance(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#ifndef PEAKCANSETUPPAGE_H | ||
#define PEAKCANSETUPPAGE_H | ||
|
||
#include <QWidget> | ||
|
||
namespace Ui { | ||
class PeakCanSetupPage; | ||
} | ||
|
||
class Backend; | ||
class SetupDialog; | ||
class MeasurementInterface; | ||
|
||
class PeakCanSetupPage : public QWidget | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
explicit PeakCanSetupPage(QWidget *parent); | ||
~PeakCanSetupPage(); | ||
|
||
public slots: | ||
void onSetupDialogCreated(SetupDialog &dlg); | ||
void onShowInterfacePage(SetupDialog &dlg, MeasurementInterface *mi); | ||
|
||
private slots: | ||
void updateUI(); | ||
|
||
private: | ||
Ui::PeakCanSetupPage *ui; | ||
MeasurementInterface *_mi; | ||
bool _enable_ui_updates; | ||
|
||
Backend &backend(); | ||
}; | ||
|
||
#endif // PEAKCANSETUPPAGE_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ui version="4.0"> | ||
<class>PeakCanSetupPage</class> | ||
<widget class="QWidget" name="PeakCanSetupPage"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>0</x> | ||
<y>0</y> | ||
<width>876</width> | ||
<height>549</height> | ||
</rect> | ||
</property> | ||
<property name="windowTitle"> | ||
<string>Form</string> | ||
</property> | ||
<layout class="QFormLayout" name="formLayout"> | ||
<item row="0" column="0"> | ||
<widget class="QLabel" name="label"> | ||
<property name="text"> | ||
<string>Driver:</string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="0" column="1"> | ||
<widget class="QLabel" name="laDriver"> | ||
<property name="text"> | ||
<string>TextLabel</string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="1" column="0"> | ||
<widget class="QLabel" name="label_5"> | ||
<property name="text"> | ||
<string>Interface:</string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="1" column="1"> | ||
<widget class="QLabel" name="laInterfaceName"> | ||
<property name="text"> | ||
<string>TextLabel</string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="3" column="0"> | ||
<widget class="QLabel" name="label_26"> | ||
<property name="text"> | ||
<string>Bitrate:</string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="3" column="1"> | ||
<widget class="QComboBox" name="cbBitrate"/> | ||
</item> | ||
<item row="5" column="0"> | ||
<widget class="QLabel" name="laOptions"> | ||
<property name="text"> | ||
<string>Options:</string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="5" column="1"> | ||
<layout class="QVBoxLayout" name="verticalLayout"> | ||
<property name="topMargin"> | ||
<number>4</number> | ||
</property> | ||
<property name="bottomMargin"> | ||
<number>15</number> | ||
</property> | ||
<item> | ||
<widget class="QCheckBox" name="cbListenOnly"> | ||
<property name="text"> | ||
<string>Listen only</string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item> | ||
<widget class="QCheckBox" name="cbAutoRestart"> | ||
<property name="text"> | ||
<string>Automatic restart after bus off condition</string> | ||
</property> | ||
</widget> | ||
</item> | ||
</layout> | ||
</item> | ||
</layout> | ||
</widget> | ||
<resources/> | ||
<connections/> | ||
</ui> |