1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
|
#include <QObject>
#include <QDebug>
#include "canbus.h"
CANBus::CANBus()
{
speed = 500000;
listenOnly = false;
singleWire = false;
active = false;
canFD = false;
dataRate = 2000000;
}
bool CANBus::operator==(const CANBus& bus) const{
return speed == bus.speed &&
listenOnly == bus.listenOnly &&
singleWire == bus.singleWire &&
active == bus.active &&
canFD == bus.canFD &&
dataRate == bus.dataRate;
}
void CANBus::setSpeed(int newSpeed){
//qDebug() << "CANBUS SetSpeed = " << newSpeed;
speed = newSpeed;
}
void CANBus::setListenOnly(bool mode){
//qDebug() << "CANBUS SetListenOnly = " << mode;
listenOnly = mode;
}
void CANBus::setSingleWire(bool mode){
//qDebug() << "CANBUS SetSingleWire = " << mode;
singleWire = mode;
}
void CANBus::setActive(bool mode){
//qDebug() << "CANBUS SetEnabled = " << mode;
active = mode;
}
void CANBus::setCanFD(bool mode){
//qDebug() << "CANBUS setCanFD = " << mode;
canFD = mode;
}
int CANBus::getSpeed() const {
return speed;
}
int CANBus::getDataRate() const {
return dataRate;
}
void CANBus::setDataRate(int newSpeed){
//qDebug() << "CANBUS SetSpeed = " << newSpeed;
dataRate = newSpeed;
}
bool CANBus::isListenOnly() const {
return listenOnly;
}
bool CANBus::isSingleWire() const {
return singleWire;
}
bool CANBus::isActive() const {
return active;
}
bool CANBus::isCanFD() const {
return canFD;
}
QDataStream& operator<<(QDataStream & pStream, const CANBus& pCanBus)
{
pStream << pCanBus.speed;
pStream << pCanBus.listenOnly;
pStream << pCanBus.singleWire;
pStream << pCanBus.active;
// FIXME CANFD settings missing
return pStream;
}
QDataStream & operator>>(QDataStream & pStream, CANBus& pCanBus)
{
pStream >> pCanBus.speed;
pStream >> pCanBus.listenOnly;
pStream >> pCanBus.singleWire;
pStream >> pCanBus.active;
return pStream;
}
|