diff --git a/canbus.cpp b/canbus.cpp index 91e83ad..d0f4646 100644 --- a/canbus.cpp +++ b/canbus.cpp @@ -3,10 +3,10 @@ CANBus::CANBus() { - speed = 250000; - listenOnly = false; - singleWire = false; - active = false; + speed = 250000; + listenOnly = false; + singleWire = false; + active = false; } @@ -24,44 +24,53 @@ bool CANBus::operator==(const CANBus& bus) const{ active == bus.active; } - -void CANBus::setSpeed(int newSpeed) -{ +void CANBus::setSpeed(int newSpeed){ speed = newSpeed; } -void CANBus::setListenOnly(bool mode) -{ +void CANBus::setListenOnly(bool mode){ listenOnly = mode; } -void CANBus::setSingleWire(bool mode) -{ +void CANBus::setSingleWire(bool mode){ singleWire = mode; } -void CANBus::setEnabled(bool mode) -{ +void CANBus::setEnabled(bool mode){ active = mode; } -int CANBus::getSpeed() -{ +int CANBus::getSpeed(){ return speed; } -bool CANBus::isListenOnly() -{ +bool CANBus::isListenOnly(){ return listenOnly; } -bool CANBus::isSingleWire() -{ +bool CANBus::isSingleWire(){ return singleWire; } -bool CANBus::isActive() -{ +bool CANBus::isActive(){ return active; } + +QDataStream& operator<<( QDataStream & pStream, const CANBus& pCanBus ) +{ + pStream << pCanBus.speed; + pStream << pCanBus.listenOnly; + pStream << pCanBus.singleWire; + pStream << pCanBus.active; + return pStream; +} + +QDataStream & operator>>(QDataStream & pStream, CANBus& pCanBus) +{ + pStream >> pCanBus.speed; + pStream >> pCanBus.listenOnly; + pStream >> pCanBus.singleWire; + pStream >> pCanBus.active; + return pStream; +} diff --git a/canbus.h b/canbus.h index 8dd8044..9b39358 100644 --- a/canbus.h +++ b/canbus.h @@ -1,6 +1,6 @@ #ifndef CANBus_H #define CANBus_H - +#include class CANBus { @@ -8,7 +8,8 @@ public: CANBus(); CANBus(const CANBus&); bool operator==(const CANBus&) const; - virtual ~CANBus(){}; /*TODO: remove connection from CANBus and add CANBus as an element of CANConnection */ + virtual ~CANBus(){}; + int speed; bool listenOnly; bool singleWire; @@ -25,4 +26,9 @@ public: bool isActive(); }; +QDataStream& operator<<( QDataStream & pStream, const CANBus& pCanBus ); +QDataStream & operator>>(QDataStream & pStream, CANBus& pCanBus); + +Q_DECLARE_METATYPE(CANBus); + #endif // CANBus_H diff --git a/connections/canconmanager.cpp b/connections/canconmanager.cpp new file mode 100644 index 0000000..c363d2a --- /dev/null +++ b/connections/canconmanager.cpp @@ -0,0 +1,6 @@ +#include "canconmanager.h" + +CANConManager::CANConManager() +{ + +} diff --git a/connections/canconmanager.h b/connections/canconmanager.h new file mode 100644 index 0000000..fd17d6e --- /dev/null +++ b/connections/canconmanager.h @@ -0,0 +1,11 @@ +#ifndef CANCONMANAGER_H +#define CANCONMANAGER_H + + +class CANConManager +{ +public: + CANConManager(); +}; + +#endif // CANCONMANAGER_H \ No newline at end of file