Added ability for connections to update the connection view details

based on hardware status.
This commit is contained in:
Collin Kidder
2016-03-26 22:01:34 -04:00
parent 147d539c36
commit 87c201aa44
6 changed files with 31 additions and 30 deletions
+7 -1
View File
@@ -55,7 +55,13 @@ signals:
void frameUpdate(int); void frameUpdate(int);
void connectionSuccess(); void connectionSuccess();
void connectionFailure(); void connectionFailure();
void deviceInfo(int, int); //First param = driver version (or version of whatever you want), second param a status byte (listen only, single wire, etc) void deviceInfo(int, int); //First param = driver version (or version of whatever you want), second param a status byte
//bus number, bus speed, status (bit 0 = enabled, 1 = single wire, 2 = listen only)
//3 = Use value stored for enabled, 4 = use value passed for single wire, 5 = use value passed for listen only
//6 = use value passed for speed. This allows bus status to be updated but set that some things aren't really
//being passed. Just set for things that really are being updated.
void busStatus(int, int, int);
public slots: public slots:
virtual void run(); virtual void run();
+6
View File
@@ -7,6 +7,12 @@ CANConnectionModel::CANConnectionModel(QObject *parent)
{ {
} }
void CANConnectionModel::refreshView()
{
beginResetModel();
endResetModel();
}
QVariant CANConnectionModel::headerData(int section, Qt::Orientation orientation, int role) const QVariant CANConnectionModel::headerData(int section, Qt::Orientation orientation, int role) const
{ {
if (role != Qt::DisplayRole) if (role != Qt::DisplayRole)
+1
View File
@@ -27,6 +27,7 @@ public:
void addBus(CAN_Bus &bus); void addBus(CAN_Bus &bus);
CAN_Bus* getBus(int bus); CAN_Bus* getBus(int bus);
CANConnection* getConnection(int conn); CANConnection* getConnection(int conn);
void refreshView();
private: private:
QList<CANConnectionContainer *> connections; QList<CANConnectionContainer *> connections;
+14 -27
View File
@@ -89,6 +89,7 @@ void ConnectionWindow::handleOKButton()
if (ui->rbGVRET->isChecked()) if (ui->rbGVRET->isChecked())
{ {
SerialWorker *serial = new SerialWorker(canModel, connModel->rowCount()); SerialWorker *serial = new SerialWorker(canModel, connModel->rowCount());
connect(serial, SIGNAL(busStatus(int,int,int)), this, SLOT(receiveBusStatus(int,int,int)));
connModel->addConnection(serial); connModel->addConnection(serial);
qDebug() << "Setup initial connection object"; qDebug() << "Setup initial connection object";
@@ -136,40 +137,26 @@ void ConnectionWindow::handleOKButton()
} }
} }
}
/* void ConnectionWindow::receiveBusStatus(int bus, int speed, int status)
if (ui->rbGVRET->isChecked()) {
qDebug() << "bus " << bus << " speed " << speed << " status " << status;
CAN_Bus *busRef = connModel->getBus(bus);
if (status & 40) busRef->setSpeed(speed);
if (status & 8) //update enabled status
{ {
conn = "GVRET"; busRef->setEnabled((status & 1)?true:false);
connType = 0;
currentConnType = ConnectionType::GVRET_SERIAL;
} }
if (status & 0x10) //update single wire status
if (ui->rbKvaser->isChecked())
{ {
conn = "KVASER"; busRef->setSingleWire((status & 2)?true:false);
connType = 1;
currentConnType = ConnectionType::KVASER;
} }
if (status & 0x20) //update listen only status
if (ui->rbSocketCAN->isChecked())
{ {
conn = "SOCKETCAN"; busRef->setListenOnly((status & 4)?true:false);
connType = 2;
currentConnType = ConnectionType::SOCKETCAN;
} }
connModel->refreshView();
currentPortName = getPortName();
currentSpeed1 = getSpeed();
settings->setValue("Main/DefaultConnectionPort", currentPortName);
settings->setValue("Main/DefaultConnectionType", connType);
settings->setValue("Main/SingleWireMode", ui->ckSingleWire->isChecked());
emit updateConnectionSettings(conn, getPortName(), getSpeed());
this->close();
*/
} }
void ConnectionWindow::handleConnSelectionChanged() void ConnectionWindow::handleConnSelectionChanged()
+1 -1
View File
@@ -53,7 +53,7 @@ private slots:
void handleConnSelectionChanged(); void handleConnSelectionChanged();
void handleRemoveConn(); void handleRemoveConn();
void handleRevert(); void handleRevert();
void receiveBusStatus(int bus, int speed, int status);
private: private:
Ui::ConnectionWindow *ui; Ui::ConnectionWindow *ui;
+2 -1
View File
@@ -81,7 +81,6 @@ void SerialWorker::setSerialPort(QSerialPortInfo *port)
serial = new QSerialPort(*port); serial = new QSerialPort(*port);
qDebug() << "Serial port name is " << port->portName(); qDebug() << "Serial port name is " << port->portName();
//serial->setBaudRate(10000000); //more speed! probably does nothing for USB serial
serial->setDataBits(serial->Data8); serial->setDataBits(serial->Data8);
serial->setFlowControl(serial->HardwareControl); //this is important though serial->setFlowControl(serial->HardwareControl); //this is important though
if (!serial->open(QIODevice::ReadWrite)) if (!serial->open(QIODevice::ReadWrite))
@@ -414,6 +413,8 @@ void SerialWorker::procRXChar(unsigned char c)
if (!can0Enabled) can0Baud = 0; if (!can0Enabled) can0Baud = 0;
isConnected = true; isConnected = true;
emit connectionSuccess(); emit connectionSuccess();
emit busStatus(busBase, can0Baud, can0Enabled?0x49:0x48); //say that we're updating baud rate and set enabled status
emit busStatus(busBase + 1, can1Baud, can1Enabled?0x49:0x48);
break; break;
} }
rx_step++; rx_step++;