SocketCan: Rename to SerialBusConnection
QtCanBus is not limited to SocketCAN, it also supports various Windows CAN adapters directly. Also, add the term Connection to describe the inheritance hierarchy better.
This commit is contained in:
+2
-2
@@ -32,7 +32,7 @@ SOURCES += main.cpp\
|
|||||||
can_structs.cpp \
|
can_structs.cpp \
|
||||||
motorcontrollerconfigwindow.cpp \
|
motorcontrollerconfigwindow.cpp \
|
||||||
connections/canconnection.cpp \
|
connections/canconnection.cpp \
|
||||||
connections/socketcan.cpp \
|
connections/serialbusconnection.cpp \
|
||||||
connections/canconfactory.cpp \
|
connections/canconfactory.cpp \
|
||||||
connections/gvretserial.cpp \
|
connections/gvretserial.cpp \
|
||||||
connections/canconmanager.cpp \
|
connections/canconmanager.cpp \
|
||||||
@@ -84,7 +84,7 @@ HEADERS += mainwindow.h \
|
|||||||
utils/lfqueue.h \
|
utils/lfqueue.h \
|
||||||
motorcontrollerconfigwindow.h \
|
motorcontrollerconfigwindow.h \
|
||||||
connections/canconnection.h \
|
connections/canconnection.h \
|
||||||
connections/socketcan.h \
|
connections/serialbusconnection.h \
|
||||||
connections/canconconst.h \
|
connections/canconconst.h \
|
||||||
connections/canconfactory.h \
|
connections/canconfactory.h \
|
||||||
connections/gvretserial.h \
|
connections/gvretserial.h \
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
#include "canconfactory.h"
|
#include "canconfactory.h"
|
||||||
#include "socketcan.h"
|
#include "serialbusconnection.h"
|
||||||
#include "gvretserial.h"
|
#include "gvretserial.h"
|
||||||
|
|
||||||
using namespace CANCon;
|
using namespace CANCon;
|
||||||
@@ -9,7 +9,7 @@ CANConnection* CanConFactory::create(type pType, QString pPortName)
|
|||||||
{
|
{
|
||||||
switch(pType) {
|
switch(pType) {
|
||||||
case SOCKETCAN:
|
case SOCKETCAN:
|
||||||
return new SocketCan(pPortName);
|
return new SerialBusConnection(pPortName);
|
||||||
case GVRET_SERIAL:
|
case GVRET_SERIAL:
|
||||||
return new GVRetSerial(pPortName);
|
return new GVRetSerial(pPortName);
|
||||||
default: {}
|
default: {}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
#include <QCanBusFrame>
|
#include <QCanBusFrame>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
|
|
||||||
#include "socketcan.h"
|
#include "serialbusconnection.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
/**** class definition ****/
|
/**** class definition ****/
|
||||||
/***********************************/
|
/***********************************/
|
||||||
|
|
||||||
SocketCan::SocketCan(QString portName) :
|
SerialBusConnection::SerialBusConnection(QString portName) :
|
||||||
CANConnection(portName, CANCon::SOCKETCAN, 1, 4000, true),
|
CANConnection(portName, CANCon::SOCKETCAN, 1, 4000, true),
|
||||||
mDev_p(NULL),
|
mDev_p(NULL),
|
||||||
mTimer(this) /*NB: set connection as parent of timer to manage it from working thread */
|
mTimer(this) /*NB: set connection as parent of timer to manage it from working thread */
|
||||||
@@ -19,13 +19,13 @@ SocketCan::SocketCan(QString portName) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SocketCan::~SocketCan()
|
SerialBusConnection::~SerialBusConnection()
|
||||||
{
|
{
|
||||||
stop();
|
stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SocketCan::piStarted()
|
void SerialBusConnection::piStarted()
|
||||||
{
|
{
|
||||||
connect(&mTimer, SIGNAL(timeout()), this, SLOT(testConnection()));
|
connect(&mTimer, SIGNAL(timeout()), this, SLOT(testConnection()));
|
||||||
mTimer.setInterval(1000);
|
mTimer.setInterval(1000);
|
||||||
@@ -36,7 +36,7 @@ void SocketCan::piStarted()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SocketCan::piSuspend(bool pSuspend)
|
void SerialBusConnection::piSuspend(bool pSuspend)
|
||||||
{
|
{
|
||||||
/* update capSuspended */
|
/* update capSuspended */
|
||||||
setCapSuspended(pSuspend);
|
setCapSuspended(pSuspend);
|
||||||
@@ -47,19 +47,19 @@ void SocketCan::piSuspend(bool pSuspend)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SocketCan::piStop() {
|
void SerialBusConnection::piStop() {
|
||||||
mTimer.stop();
|
mTimer.stop();
|
||||||
disconnectDevice();
|
disconnectDevice();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool SocketCan::piGetBusSettings(int pBusIdx, CANBus& pBus)
|
bool SerialBusConnection::piGetBusSettings(int pBusIdx, CANBus& pBus)
|
||||||
{
|
{
|
||||||
return getBusConfig(pBusIdx, pBus);
|
return getBusConfig(pBusIdx, pBus);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SocketCan::piSetBusSettings(int pBusIdx, CANBus bus)
|
void SerialBusConnection::piSetBusSettings(int pBusIdx, CANBus bus)
|
||||||
{
|
{
|
||||||
CANConStatus stats;
|
CANConStatus stats;
|
||||||
/* sanity checks */
|
/* sanity checks */
|
||||||
@@ -86,9 +86,9 @@ void SocketCan::piSetBusSettings(int pBusIdx, CANBus bus)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* connect slots */
|
/* connect slots */
|
||||||
connect(mDev_p, &QCanBusDevice::errorOccurred, this, &SocketCan::errorReceived);
|
connect(mDev_p, &QCanBusDevice::errorOccurred, this, &SerialBusConnection::errorReceived);
|
||||||
connect(mDev_p, &QCanBusDevice::framesWritten, this, &SocketCan::framesWritten);
|
connect(mDev_p, &QCanBusDevice::framesWritten, this, &SerialBusConnection::framesWritten);
|
||||||
connect(mDev_p, &QCanBusDevice::framesReceived, this, &SocketCan::framesReceived);
|
connect(mDev_p, &QCanBusDevice::framesReceived, this, &SerialBusConnection::framesReceived);
|
||||||
|
|
||||||
/* set configuration */
|
/* set configuration */
|
||||||
/*if (p.useConfigurationEnabled) {
|
/*if (p.useConfigurationEnabled) {
|
||||||
@@ -107,7 +107,7 @@ void SocketCan::piSetBusSettings(int pBusIdx, CANBus bus)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool SocketCan::piSendFrame(const CANFrame& pFrame)
|
bool SerialBusConnection::piSendFrame(const CANFrame& pFrame)
|
||||||
{
|
{
|
||||||
/* sanity checks */
|
/* sanity checks */
|
||||||
if(0 != pFrame.bus || pFrame.len>8)
|
if(0 != pFrame.bus || pFrame.len>8)
|
||||||
@@ -131,7 +131,7 @@ bool SocketCan::piSendFrame(const CANFrame& pFrame)
|
|||||||
|
|
||||||
|
|
||||||
/* disconnect device */
|
/* disconnect device */
|
||||||
void SocketCan::disconnectDevice() {
|
void SerialBusConnection::disconnectDevice() {
|
||||||
if(mDev_p) {
|
if(mDev_p) {
|
||||||
mDev_p->disconnectDevice();
|
mDev_p->disconnectDevice();
|
||||||
delete mDev_p;
|
delete mDev_p;
|
||||||
@@ -140,7 +140,7 @@ void SocketCan::disconnectDevice() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SocketCan::errorReceived(QCanBusDevice::CanBusError error) const
|
void SerialBusConnection::errorReceived(QCanBusDevice::CanBusError error) const
|
||||||
{
|
{
|
||||||
switch (error) {
|
switch (error) {
|
||||||
case QCanBusDevice::ReadError:
|
case QCanBusDevice::ReadError:
|
||||||
@@ -155,13 +155,13 @@ void SocketCan::errorReceived(QCanBusDevice::CanBusError error) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SocketCan::framesWritten(qint64 count)
|
void SerialBusConnection::framesWritten(qint64 count)
|
||||||
{
|
{
|
||||||
Q_UNUSED(count);
|
Q_UNUSED(count);
|
||||||
//qDebug() << "Number of frames written:" << count;
|
//qDebug() << "Number of frames written:" << count;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SocketCan::framesReceived()
|
void SerialBusConnection::framesReceived()
|
||||||
{
|
{
|
||||||
uint64_t timeBasis = CANConManager::getInstance()->getTimeBasis();
|
uint64_t timeBasis = CANConManager::getInstance()->getTimeBasis();
|
||||||
|
|
||||||
@@ -211,7 +211,7 @@ void SocketCan::framesReceived()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SocketCan::testConnection() {
|
void SerialBusConnection::testConnection() {
|
||||||
QCanBusDevice* dev_p = QCanBus::instance()->createDevice("socketcan", getPort());
|
QCanBusDevice* dev_p = QCanBus::instance()->createDevice("socketcan", getPort());
|
||||||
CANConStatus stats;
|
CANConStatus stats;
|
||||||
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
#ifndef SocketCan_H
|
#ifndef SERIALBUSCONNECTION_H
|
||||||
#define SocketCan_H
|
#define SERIALBUSCONNECTION_H
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QCanBus>
|
#include <QCanBus>
|
||||||
@@ -11,13 +11,13 @@
|
|||||||
#include "canconmanager.h"
|
#include "canconmanager.h"
|
||||||
|
|
||||||
|
|
||||||
class SocketCan : public CANConnection
|
class SerialBusConnection : public CANConnection
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SocketCan(QString portName);
|
SerialBusConnection(QString portName);
|
||||||
virtual ~SocketCan();
|
virtual ~SerialBusConnection();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
@@ -42,4 +42,4 @@ protected:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif // SocketCan_H
|
#endif // SERIALBUSCONNECTION_H
|
||||||
Reference in New Issue
Block a user