Added ability for connections to update the connection view details
based on hardware status.
This commit is contained in:
+7
-1
@@ -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();
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
+16
-29
@@ -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()
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
if (ui->rbGVRET->isChecked())
|
|
||||||
{
|
|
||||||
conn = "GVRET";
|
|
||||||
connType = 0;
|
|
||||||
currentConnType = ConnectionType::GVRET_SERIAL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ui->rbKvaser->isChecked())
|
void ConnectionWindow::receiveBusStatus(int bus, int speed, int status)
|
||||||
{
|
{
|
||||||
conn = "KVASER";
|
qDebug() << "bus " << bus << " speed " << speed << " status " << status;
|
||||||
connType = 1;
|
CAN_Bus *busRef = connModel->getBus(bus);
|
||||||
currentConnType = ConnectionType::KVASER;
|
if (status & 40) busRef->setSpeed(speed);
|
||||||
}
|
if (status & 8) //update enabled status
|
||||||
|
|
||||||
if (ui->rbSocketCAN->isChecked())
|
|
||||||
{
|
{
|
||||||
conn = "SOCKETCAN";
|
busRef->setEnabled((status & 1)?true:false);
|
||||||
connType = 2;
|
|
||||||
currentConnType = ConnectionType::SOCKETCAN;
|
|
||||||
}
|
}
|
||||||
|
if (status & 0x10) //update single wire status
|
||||||
currentPortName = getPortName();
|
{
|
||||||
currentSpeed1 = getSpeed();
|
busRef->setSingleWire((status & 2)?true:false);
|
||||||
|
}
|
||||||
settings->setValue("Main/DefaultConnectionPort", currentPortName);
|
if (status & 0x20) //update listen only status
|
||||||
settings->setValue("Main/DefaultConnectionType", connType);
|
{
|
||||||
settings->setValue("Main/SingleWireMode", ui->ckSingleWire->isChecked());
|
busRef->setListenOnly((status & 4)?true:false);
|
||||||
|
}
|
||||||
emit updateConnectionSettings(conn, getPortName(), getSpeed());
|
connModel->refreshView();
|
||||||
|
|
||||||
this->close();
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConnectionWindow::handleConnSelectionChanged()
|
void ConnectionWindow::handleConnSelectionChanged()
|
||||||
|
|||||||
+1
-1
@@ -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
@@ -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++;
|
||||||
|
|||||||
Reference in New Issue
Block a user