diff --git a/src/Create3SensorModel.cpp b/src/Create3SensorModel.cpp index f6ab4d31..35187dae 100644 --- a/src/Create3SensorModel.cpp +++ b/src/Create3SensorModel.cpp @@ -191,110 +191,129 @@ void Create3SensorModel::populate() void Create3SensorModel::populateBump(unsigned int port) { - - switch (port) + try + { + switch (port) + { + case 0: + appendRow(QList() + << new Create3SensorNameItem(Create3SensorModel::Bump0, port) + << new Create3SensorValueItem(Create3SensorModel::Bump, port, true)); + break; + case 1: + appendRow(QList() + << new Create3SensorNameItem(Create3SensorModel::Bump1, port) + << new Create3SensorValueItem(Create3SensorModel::Bump, port, true)); + break; + case 2: + appendRow(QList() + << new Create3SensorNameItem(Create3SensorModel::Bump2, port) + << new Create3SensorValueItem(Create3SensorModel::Bump, port, true)); + break; + case 3: + appendRow(QList() + << new Create3SensorNameItem(Create3SensorModel::Bump3, port) + << new Create3SensorValueItem(Create3SensorModel::Bump, port, true)); + break; + case 4: + appendRow(QList() + << new Create3SensorNameItem(Create3SensorModel::Bump4, port) + << new Create3SensorValueItem(Create3SensorModel::Bump, port, true)); + break; + default: + break; + } + } + catch (const std::exception &e) { - case 0: - appendRow(QList() - << new Create3SensorNameItem(Create3SensorModel::Bump0, port) - << new Create3SensorValueItem(Create3SensorModel::Bump, port, true)); - break; - case 1: - appendRow(QList() - << new Create3SensorNameItem(Create3SensorModel::Bump1, port) - << new Create3SensorValueItem(Create3SensorModel::Bump, port, true)); - break; - case 2: - appendRow(QList() - << new Create3SensorNameItem(Create3SensorModel::Bump2, port) - << new Create3SensorValueItem(Create3SensorModel::Bump, port, true)); - break; - case 3: - appendRow(QList() - << new Create3SensorNameItem(Create3SensorModel::Bump3, port) - << new Create3SensorValueItem(Create3SensorModel::Bump, port, true)); - break; - case 4: - appendRow(QList() - << new Create3SensorNameItem(Create3SensorModel::Bump4, port) - << new Create3SensorValueItem(Create3SensorModel::Bump, port, true)); - break; - default: - break; + std::cerr << 'Could not load bump sensor values\n' << e.what() << '\n'; } } void Create3SensorModel::populateCliff(unsigned int port) { - - switch (port) + try { - case 0: - appendRow(QList() - << new Create3SensorNameItem(Create3SensorModel::Cliff0, port) - << new Create3SensorValueItem(Create3SensorModel::Cliff, port, true)); - break; - case 1: - appendRow(QList() - << new Create3SensorNameItem(Create3SensorModel::Cliff1, port) - << new Create3SensorValueItem(Create3SensorModel::Cliff, port, true)); - break; - case 2: - appendRow(QList() - << new Create3SensorNameItem(Create3SensorModel::Cliff2, port) - << new Create3SensorValueItem(Create3SensorModel::Cliff, port, true)); - break; - case 3: - appendRow(QList() - << new Create3SensorNameItem(Create3SensorModel::Cliff3, port) - << new Create3SensorValueItem(Create3SensorModel::Cliff, port, true)); - break; + switch (port) + { + case 0: + appendRow(QList() + << new Create3SensorNameItem(Create3SensorModel::Cliff0, port) + << new Create3SensorValueItem(Create3SensorModel::Cliff, port, true)); + break; + case 1: + appendRow(QList() + << new Create3SensorNameItem(Create3SensorModel::Cliff1, port) + << new Create3SensorValueItem(Create3SensorModel::Cliff, port, true)); + break; + case 2: + appendRow(QList() + << new Create3SensorNameItem(Create3SensorModel::Cliff2, port) + << new Create3SensorValueItem(Create3SensorModel::Cliff, port, true)); + break; + case 3: + appendRow(QList() + << new Create3SensorNameItem(Create3SensorModel::Cliff3, port) + << new Create3SensorValueItem(Create3SensorModel::Cliff, port, true)); + break; - default: - break; + default: + break; + } + } + catch (const std::exception &e) + { + std::cerr << 'Could not load cliff sensor values\n' << e.what() << '\n'; } } void Create3SensorModel::populateIR(unsigned int port) { - switch (port) + try + { + switch (port) + { + case 0: + appendRow(QList() + << new Create3SensorNameItem(Create3SensorModel::IR0, port) + << new Create3SensorValueItem(Create3SensorModel::IR, port, true)); + break; + case 1: + appendRow(QList() + << new Create3SensorNameItem(Create3SensorModel::IR1, port) + << new Create3SensorValueItem(Create3SensorModel::IR, port, true)); + break; + case 2: + appendRow(QList() + << new Create3SensorNameItem(Create3SensorModel::IR2, port) + << new Create3SensorValueItem(Create3SensorModel::IR, port, true)); + break; + case 3: + appendRow(QList() + << new Create3SensorNameItem(Create3SensorModel::IR3, port) + << new Create3SensorValueItem(Create3SensorModel::IR, port, true)); + break; + case 4: + appendRow(QList() + << new Create3SensorNameItem(Create3SensorModel::IR4, port) + << new Create3SensorValueItem(Create3SensorModel::IR, port, true)); + break; + case 5: + appendRow(QList() + << new Create3SensorNameItem(Create3SensorModel::IR5, port) + << new Create3SensorValueItem(Create3SensorModel::IR, port, true)); + break; + case 6: + appendRow(QList() + << new Create3SensorNameItem(Create3SensorModel::IR6, port) + << new Create3SensorValueItem(Create3SensorModel::IR, port, true)); + break; + default: + break; + } + } + catch (const std::exception &e) { - case 0: - appendRow(QList() - << new Create3SensorNameItem(Create3SensorModel::IR0, port) - << new Create3SensorValueItem(Create3SensorModel::IR, port, true)); - break; - case 1: - appendRow(QList() - << new Create3SensorNameItem(Create3SensorModel::IR1, port) - << new Create3SensorValueItem(Create3SensorModel::IR, port, true)); - break; - case 2: - appendRow(QList() - << new Create3SensorNameItem(Create3SensorModel::IR2, port) - << new Create3SensorValueItem(Create3SensorModel::IR, port, true)); - break; - case 3: - appendRow(QList() - << new Create3SensorNameItem(Create3SensorModel::IR3, port) - << new Create3SensorValueItem(Create3SensorModel::IR, port, true)); - break; - case 4: - appendRow(QList() - << new Create3SensorNameItem(Create3SensorModel::IR4, port) - << new Create3SensorValueItem(Create3SensorModel::IR, port, true)); - break; - case 5: - appendRow(QList() - << new Create3SensorNameItem(Create3SensorModel::IR5, port) - << new Create3SensorValueItem(Create3SensorModel::IR, port, true)); - break; - case 6: - appendRow(QList() - << new Create3SensorNameItem(Create3SensorModel::IR6, port) - << new Create3SensorValueItem(Create3SensorModel::IR, port, true)); - break; - default: - break; + std::cerr << 'Could not load IR sensor values\n' << e.what() << '\n'; } } diff --git a/src/Create3Widget.cpp b/src/Create3Widget.cpp index 61ae6e99..97ea0479 100644 --- a/src/Create3Widget.cpp +++ b/src/Create3Widget.cpp @@ -39,9 +39,6 @@ Create3Widget::Create3Widget(Device *device, QWidget *parent) setStyleSheet("QScrollBar:vertical {border: 2px solid grey;background:grey ;width: 100px; margin: 22px 0 22px 0; } QScrollBar::handle:vertical { border: 2px solid grey;background: white; min-height: 20px; } QScrollBar::add-line:vertical { border: 2px solid grey;background: #32CC99; height: 20px; subcontrol-position: bottom; subcontrol-origin: margin; } QScrollBar::sub-line:vertical {border: 2px solid grey; background: #32CC99; height: 20px; subcontrol-position: top; subcontrol-origin: margin; } QScrollBar::up-arrow:vertical, QScrollBar::down-arrow:vertical { border: 2px solid grey;width: 3px; height: 3px; background: white; }QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {border: 2px solid grey; background: none;}"); connect(ui->CreateConnectButton, SIGNAL(clicked()), SLOT(isConnected())); connect(ui->ResetServerButton, SIGNAL(clicked()), SLOT(resetServer())); - // ui->sensors->setModel(_model); - // ui->sensors->setItemDelegate(new Create3SensorItemDelegate(_model, this)); - // connect(ui->testProgramComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(indexChanged(int))); connect(ui->Create3SensorListButton, SIGNAL(clicked()), SLOT(sensorList())); connect(ui->Create3ExampleProgramButton, SIGNAL(clicked()), SLOT(exampleList())); @@ -195,7 +192,7 @@ int Create3Widget::create3Connect() int connected = 0; try { - connected = create3_connect_manual("192.168.125.1", 50051); + connected = create3_connect(); qDebug() << "Create connected? " << connected; } catch (const std::exception &e)