Skip to content

Commit

Permalink
Wrap sensor list in try catch, remove some old ccomments
Browse files Browse the repository at this point in the history
  • Loading branch information
tcorbly committed Nov 29, 2023
1 parent c0a3e6c commit 428142a
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 95 deletions.
201 changes: 110 additions & 91 deletions src/Create3SensorModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,110 +191,129 @@ void Create3SensorModel::populate()

void Create3SensorModel::populateBump(unsigned int port)
{

switch (port)
try
{
switch (port)
{
case 0:
appendRow(QList<QStandardItem *>()
<< new Create3SensorNameItem(Create3SensorModel::Bump0, port)
<< new Create3SensorValueItem<unsigned short>(Create3SensorModel::Bump, port, true));
break;
case 1:
appendRow(QList<QStandardItem *>()
<< new Create3SensorNameItem(Create3SensorModel::Bump1, port)
<< new Create3SensorValueItem<unsigned short>(Create3SensorModel::Bump, port, true));
break;
case 2:
appendRow(QList<QStandardItem *>()
<< new Create3SensorNameItem(Create3SensorModel::Bump2, port)
<< new Create3SensorValueItem<unsigned short>(Create3SensorModel::Bump, port, true));
break;
case 3:
appendRow(QList<QStandardItem *>()
<< new Create3SensorNameItem(Create3SensorModel::Bump3, port)
<< new Create3SensorValueItem<unsigned short>(Create3SensorModel::Bump, port, true));
break;
case 4:
appendRow(QList<QStandardItem *>()
<< new Create3SensorNameItem(Create3SensorModel::Bump4, port)
<< new Create3SensorValueItem<unsigned short>(Create3SensorModel::Bump, port, true));
break;
default:
break;
}
}
catch (const std::exception &e)
{
case 0:
appendRow(QList<QStandardItem *>()
<< new Create3SensorNameItem(Create3SensorModel::Bump0, port)
<< new Create3SensorValueItem<unsigned short>(Create3SensorModel::Bump, port, true));
break;
case 1:
appendRow(QList<QStandardItem *>()
<< new Create3SensorNameItem(Create3SensorModel::Bump1, port)
<< new Create3SensorValueItem<unsigned short>(Create3SensorModel::Bump, port, true));
break;
case 2:
appendRow(QList<QStandardItem *>()
<< new Create3SensorNameItem(Create3SensorModel::Bump2, port)
<< new Create3SensorValueItem<unsigned short>(Create3SensorModel::Bump, port, true));
break;
case 3:
appendRow(QList<QStandardItem *>()
<< new Create3SensorNameItem(Create3SensorModel::Bump3, port)
<< new Create3SensorValueItem<unsigned short>(Create3SensorModel::Bump, port, true));
break;
case 4:
appendRow(QList<QStandardItem *>()
<< new Create3SensorNameItem(Create3SensorModel::Bump4, port)
<< new Create3SensorValueItem<unsigned short>(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<QStandardItem *>()
<< new Create3SensorNameItem(Create3SensorModel::Cliff0, port)
<< new Create3SensorValueItem<unsigned short>(Create3SensorModel::Cliff, port, true));
break;
case 1:
appendRow(QList<QStandardItem *>()
<< new Create3SensorNameItem(Create3SensorModel::Cliff1, port)
<< new Create3SensorValueItem<unsigned short>(Create3SensorModel::Cliff, port, true));
break;
case 2:
appendRow(QList<QStandardItem *>()
<< new Create3SensorNameItem(Create3SensorModel::Cliff2, port)
<< new Create3SensorValueItem<unsigned short>(Create3SensorModel::Cliff, port, true));
break;
case 3:
appendRow(QList<QStandardItem *>()
<< new Create3SensorNameItem(Create3SensorModel::Cliff3, port)
<< new Create3SensorValueItem<unsigned short>(Create3SensorModel::Cliff, port, true));
break;
switch (port)
{
case 0:
appendRow(QList<QStandardItem *>()
<< new Create3SensorNameItem(Create3SensorModel::Cliff0, port)
<< new Create3SensorValueItem<unsigned short>(Create3SensorModel::Cliff, port, true));
break;
case 1:
appendRow(QList<QStandardItem *>()
<< new Create3SensorNameItem(Create3SensorModel::Cliff1, port)
<< new Create3SensorValueItem<unsigned short>(Create3SensorModel::Cliff, port, true));
break;
case 2:
appendRow(QList<QStandardItem *>()
<< new Create3SensorNameItem(Create3SensorModel::Cliff2, port)
<< new Create3SensorValueItem<unsigned short>(Create3SensorModel::Cliff, port, true));
break;
case 3:
appendRow(QList<QStandardItem *>()
<< new Create3SensorNameItem(Create3SensorModel::Cliff3, port)
<< new Create3SensorValueItem<unsigned short>(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<QStandardItem *>()
<< new Create3SensorNameItem(Create3SensorModel::IR0, port)
<< new Create3SensorValueItem<unsigned short>(Create3SensorModel::IR, port, true));
break;
case 1:
appendRow(QList<QStandardItem *>()
<< new Create3SensorNameItem(Create3SensorModel::IR1, port)
<< new Create3SensorValueItem<unsigned short>(Create3SensorModel::IR, port, true));
break;
case 2:
appendRow(QList<QStandardItem *>()
<< new Create3SensorNameItem(Create3SensorModel::IR2, port)
<< new Create3SensorValueItem<unsigned short>(Create3SensorModel::IR, port, true));
break;
case 3:
appendRow(QList<QStandardItem *>()
<< new Create3SensorNameItem(Create3SensorModel::IR3, port)
<< new Create3SensorValueItem<unsigned short>(Create3SensorModel::IR, port, true));
break;
case 4:
appendRow(QList<QStandardItem *>()
<< new Create3SensorNameItem(Create3SensorModel::IR4, port)
<< new Create3SensorValueItem<unsigned short>(Create3SensorModel::IR, port, true));
break;
case 5:
appendRow(QList<QStandardItem *>()
<< new Create3SensorNameItem(Create3SensorModel::IR5, port)
<< new Create3SensorValueItem<unsigned short>(Create3SensorModel::IR, port, true));
break;
case 6:
appendRow(QList<QStandardItem *>()
<< new Create3SensorNameItem(Create3SensorModel::IR6, port)
<< new Create3SensorValueItem<unsigned short>(Create3SensorModel::IR, port, true));
break;
default:
break;
}
}
catch (const std::exception &e)
{
case 0:
appendRow(QList<QStandardItem *>()
<< new Create3SensorNameItem(Create3SensorModel::IR0, port)
<< new Create3SensorValueItem<unsigned short>(Create3SensorModel::IR, port, true));
break;
case 1:
appendRow(QList<QStandardItem *>()
<< new Create3SensorNameItem(Create3SensorModel::IR1, port)
<< new Create3SensorValueItem<unsigned short>(Create3SensorModel::IR, port, true));
break;
case 2:
appendRow(QList<QStandardItem *>()
<< new Create3SensorNameItem(Create3SensorModel::IR2, port)
<< new Create3SensorValueItem<unsigned short>(Create3SensorModel::IR, port, true));
break;
case 3:
appendRow(QList<QStandardItem *>()
<< new Create3SensorNameItem(Create3SensorModel::IR3, port)
<< new Create3SensorValueItem<unsigned short>(Create3SensorModel::IR, port, true));
break;
case 4:
appendRow(QList<QStandardItem *>()
<< new Create3SensorNameItem(Create3SensorModel::IR4, port)
<< new Create3SensorValueItem<unsigned short>(Create3SensorModel::IR, port, true));
break;
case 5:
appendRow(QList<QStandardItem *>()
<< new Create3SensorNameItem(Create3SensorModel::IR5, port)
<< new Create3SensorValueItem<unsigned short>(Create3SensorModel::IR, port, true));
break;
case 6:
appendRow(QList<QStandardItem *>()
<< new Create3SensorNameItem(Create3SensorModel::IR6, port)
<< new Create3SensorValueItem<unsigned short>(Create3SensorModel::IR, port, true));
break;
default:
break;
std::cerr << 'Could not load IR sensor values\n' << e.what() << '\n';
}
}
5 changes: 1 addition & 4 deletions src/Create3Widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()));

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 428142a

Please sign in to comment.