Add Device Wizard

Introduce a wizard for adding realtime devices since it
is prone to user error, is relatively complicated and is
something most users will only ever do once or twice.

There are several logical updates within this patch:

First; Fix intermittent ANT+ not working
* LibUsb     - check bufRemaining is > 0 not non-zero
* LibUsb     - Always reset the USB stick on open
* ANT.cpp    - Support > 4 channels on USB2
* ANTChannel -  Do not use pairing, but always
*               unassign, assign and set channel id.

Second; Fix device discovery
* Find and discover support in realtime controllers
* Extend Serial.cpp to cover more Serial devices
* Support for 4 or 8 ANT channels for USB1/USB2

Third; Introduce Add Device Wizard with
* General and Specific wizard pages for each device type
* Device pairing with telemetry display
* fixed compile time warnings

Fourth; Update Device Config Page
* use wizard to add new device
* remove edit fields, replaced by wizard
* remove pair, firmware buttons replaced by wizard

Fifth; Deprecate/Remove Device Types
* Null Device - used by developers only
* Quarqd client - replaced by Native ANT+
* GC Server - not implemented yet

I have also introduced a device specific wheel size
and flags for controlling the default selection and
sources for sensor data when in multi-device mode. These
are not yet supported in the code.

Fixes #611.
Fixes #497.
This commit is contained in:
Mark Liversedge
2012-01-16 22:29:49 +00:00
parent 3863b7f0a2
commit 3ca7f1a5d2
39 changed files with 1633 additions and 455 deletions

View File

@@ -8,6 +8,8 @@
#include "Settings.h"
#include "Zones.h"
#include "AddDeviceWizard.h"
/* cyclist dialog protocol redesign:
* no zones:
@@ -82,11 +84,8 @@ ConfigDialog::ConfigDialog(QDir _home, Zones *_zones, MainWindow *mainWindow) :
fortiusFirmware = appsettings->value(this, FORTIUS_FIRMWARE, "").toString();
connect(closeButton, SIGNAL(clicked()), this, SLOT(accept()));
connect(devicePage->typeSelector, SIGNAL(currentIndexChanged(int)), this, SLOT(changedType(int)));
connect(devicePage->addButton, SIGNAL(clicked()), this, SLOT(devaddClicked()));
connect(devicePage->firmwareButton, SIGNAL(clicked()), this, SLOT(firmwareClicked()));
connect(devicePage->delButton, SIGNAL(clicked()), this, SLOT(devdelClicked()));
connect(devicePage->pairButton, SIGNAL(clicked()), this, SLOT(devpairClicked()));
connect(contentsWidget, SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)),
this, SLOT(changePage(QListWidgetItem *, QListWidgetItem*)));
connect(saveButton, SIGNAL(clicked()), this, SLOT(save_Clicked()));
@@ -234,82 +233,10 @@ void
ConfigDialog::devaddClicked()
{
DeviceConfiguration add;
DeviceTypes Supported;
// get values from the gui elements
add.name = devicePage->deviceName->displayText();
add.type = devicePage->typeSelector->itemData(devicePage->typeSelector->currentIndex()).toInt();
add.portSpec = devicePage->deviceSpecifier->displayText();
add.deviceProfile = devicePage->deviceProfile->displayText();
add.postProcess = devicePage->virtualPower->currentIndex();
// NOT IMPLEMENTED IN THIS RELEASE XXX
//add.isDefaultDownload = devicePage->isDefaultDownload->isChecked() ? true : false;
//add.isDefaultRealtime = devicePage->isDefaultDownload->isChecked() ? true : false;
// Validate the name
QRegExp nameSpec(".+");
if (nameSpec.exactMatch(add.name) == false) {
QMessageBox::critical(0, "Invalid Device Name",
QString("Device Name should be non-blank"));
return ;
AddDeviceWizard *p = new AddDeviceWizard(mainWindow, add);
if (p->exec() == QDialog::Accepted) {
devicePage->deviceListModel->add(add);
}
// Validate the portSpec
QRegExp antSpec("[^:]*:[^:]*"); // ip:port same as TCP ... for now...
QRegExp tcpSpec("[^:]*:[^:]*"); // ip:port
#ifdef WIN32
QRegExp serialSpec("COM[0-9]*"); // COMx for WIN32, /dev/* for others
#else
QRegExp serialSpec("/dev/.*"); // COMx for WIN32, /dev/* for others
#endif
// check the portSpec is valid, based upon the connection type
switch (Supported.getType(add.type).connector) {
case DEV_QUARQ :
if (antSpec.exactMatch(add.portSpec) == false) {
QMessageBox::critical(0, "Invalid Port Specification",
QString("For ANT devices the specifier must be ") +
"hostname:portnumber");
return ;
}
break;
case DEV_SERIAL :
if (serialSpec.exactMatch(add.portSpec) == false) {
QMessageBox::critical(0, "Invalid Port Specification",
QString("For Serial devices the specifier must be ") +
#ifdef WIN32
"COMn"
#else
"/dev/xxxxx"
#endif
);
return ;
}
break;
case DEV_LIBUSB :
// Is the fortius firmware configured?
if (add.type == DEV_FORTIUS && fortiusFirmware == "") {
QMessageBox::critical(0, "Fortius Firmware",
QString("For Fortius devices you must import the firmware ") +
"using the Firmware button.");
return ;
}
break;
case DEV_TCP :
if (tcpSpec.exactMatch(add.portSpec) == false) {
QMessageBox::critical(0, "Invalid Port Specification",
QString("For TCP streaming devices the specifier must be ") +
"hostname:portnumber");
return ;
}
break;
}
devicePage->deviceListModel->add(add);
}
void
@@ -321,28 +248,13 @@ ConfigDialog::devdelClicked()
void
ConfigDialog::devpairClicked()
{
DeviceConfiguration add;
// get values from the gui elements
add.name = devicePage->deviceName->displayText();
add.type = devicePage->typeSelector->itemData(devicePage->typeSelector->currentIndex()).toInt();
add.portSpec = devicePage->deviceSpecifier->displayText();
add.deviceProfile = devicePage->deviceProfile->displayText();
QProgressDialog *progress = new QProgressDialog("Looking for Devices...", "Abort Scan", 0, 200, this);
progress->setWindowModality(Qt::WindowModal);
devicePage->pairClicked(&add, progress);
// replaced by wizard.
}
void
ConfigDialog::firmwareClicked()
{
// we need to set the firmware for this device
QString current = fortiusFirmware;
FortiusDialog *p = new FortiusDialog(mainWindow, fortiusFirmware);
p->exec();
// replaced by wizard
}
//