Skip to content
Permalink
Browse files

add configured-by-OS option to generic setup dlg

  • Loading branch information...
HubertD committed May 17, 2016
1 parent 9f61bde commit cffbd0c264d66ba219a603fadef037253c39eea1
@@ -26,7 +26,7 @@
#include <driver/CanInterface.h>

MeasurementInterface::MeasurementInterface()
: _doConfigure(false),
: _doConfigure(true),
_isListenOnlyMode(false),
_isOneShotMode(false),
_isTripleSampling(false),
@@ -45,7 +45,8 @@ class CanInterface {
capability_listen_only = 0x02,
capability_triple_sampling = 0x04,
capability_one_shot = 0x08,
capability_auto_restart = 0x10
capability_auto_restart = 0x10,
capability_config_os = 0x20
};

public:
@@ -19,6 +19,7 @@ GenericCanSetupPage::GenericCanSetupPage(QWidget *parent) :
connect(ui->cbBitrateFD, SIGNAL(currentIndexChanged(int)), this, SLOT(updateUI()));
connect(ui->cbSamplePointFD, SIGNAL(currentIndexChanged(int)), this, SLOT(updateUI()));

connect(ui->cbConfigOS, SIGNAL(stateChanged(int)), this, SLOT(updateUI()));
connect(ui->cbListenOnly, SIGNAL(stateChanged(int)), this, SLOT(updateUI()));
connect(ui->cbOneShot, SIGNAL(stateChanged(int)), this, SLOT(updateUI()));
connect(ui->cbTripleSampling, SIGNAL(stateChanged(int)), this, SLOT(updateUI()));
@@ -53,6 +54,9 @@ void GenericCanSetupPage::onShowInterfacePage(SetupDialog &dlg, MeasurementInter
ui->cbBitrateFD->setEnabled(caps & CanInterface::capability_canfd);
ui->cbSamplePointFD->setEnabled(caps & CanInterface::capability_canfd);

ui->cbConfigOS->setEnabled(caps & CanInterface::capability_config_os);
ui->cbConfigOS->setChecked(!_mi->doConfigure());

ui->cbListenOnly->setEnabled(caps & CanInterface::capability_listen_only);
ui->cbListenOnly->setChecked(_mi->isListenOnlyMode());

@@ -68,13 +72,15 @@ void GenericCanSetupPage::onShowInterfacePage(SetupDialog &dlg, MeasurementInter
dlg.displayPage(this);

_enable_ui_updates = true;
updateUI();
}

void GenericCanSetupPage::updateUI()
{
if (_enable_ui_updates && (_mi!=0)) {
CanInterface *intf = backend().getInterfaceById(_mi->canInterface());

_mi->setDoConfigure(!ui->cbConfigOS->isChecked());
_mi->setListenOnlyMode(ui->cbListenOnly->isChecked());
_mi->setOneShotMode(ui->cbOneShot->isChecked());
_mi->setTripleSampling(ui->cbTripleSampling->isChecked());
@@ -83,6 +89,8 @@ void GenericCanSetupPage::updateUI()
_mi->setSamplePoint(ui->cbSamplePoint->currentData().toUInt());

_enable_ui_updates = false;

disenableUI(_mi->doConfigure());
fillSamplePointsForBitrate(
intf,
ui->cbBitrate->currentData().toUInt(),
@@ -91,6 +99,8 @@ void GenericCanSetupPage::updateUI()
_enable_ui_updates = true;

}


}

void GenericCanSetupPage::fillBitratesList(CanInterface *intf, uint32_t selectedBitrate)
@@ -129,6 +139,19 @@ void GenericCanSetupPage::fillSamplePointsForBitrate(CanInterface *intf, uint32_
ui->cbSamplePoint->setCurrentText(CanTiming::getSamplePointStr(selectedSamplePoint));
}

void GenericCanSetupPage::disenableUI(bool enabled)
{
ui->cbBitrate->setEnabled(enabled);
ui->cbSamplePoint->setEnabled(enabled);
ui->cbBitrateFD->setEnabled(enabled);
ui->cbSamplePointFD->setEnabled(enabled);

ui->cbListenOnly->setEnabled(enabled);
ui->cbOneShot->setEnabled(enabled);
ui->cbTripleSampling->setEnabled(enabled);
ui->cbAutoRestart->setEnabled(enabled);
}

Backend &GenericCanSetupPage::backend()
{
return Backend::instance();
@@ -34,6 +34,7 @@ private slots:

void fillBitratesList(CanInterface *intf, uint32_t selectedBitrate);
void fillSamplePointsForBitrate(CanInterface *intf, uint32_t selectedBitrate, uint32_t selectedSamplePoint);
void disenableUI(bool enabled);

Backend &backend();
};
@@ -202,10 +202,17 @@
<x>120</x>
<y>220</y>
<width>186</width>
<height>88</height>
<height>111</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<layout class="QVBoxLayout" name="vbOptions">
<item>
<widget class="QCheckBox" name="cbConfigOS">
<property name="text">
<string>configured by operating system</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cbListenOnly">
<property name="text">

0 comments on commit cffbd0c

Please sign in to comment.
You can’t perform that action at this time.