Commit b91493e7 authored by Micha Mueller's avatar Micha Mueller
Browse files

Add copy constr and assignment op to BACnet, IPMI, opa plugins

parent 1d684738
......@@ -25,8 +25,26 @@ public:
_objectIndex = BACNET_ARRAY_ALL;
}
BACnetSensorBase(const BACnetSensorBase& other) : SensorBase(other),
_factor(other._factor),
_objectInstance(other._objectInstance),
_objectType(other._objectType),
_propertyId(other._propertyId),
_objectIndex(other._objectIndex) {}
virtual ~BACnetSensorBase() {}
BACnetSensorBase& operator=(const BACnetSensorBase& other) {
SensorBase::operator=(other);
_factor = other._factor;
_objectInstance = other._objectInstance;
_objectType = other._objectType;
_propertyId = other._propertyId;
_objectIndex = other._objectIndex;
return *this;
}
double getFactor() const { return _factor; }
uint32_t getObjectInstance() const { return _objectInstance; }
BACNET_OBJECT_TYPE getObjectType() const { return _objectType; }
......
......@@ -11,11 +11,22 @@
BACnetSensorGroup::BACnetSensorGroup(const std::string& name) : SensorGroupTemplate(name), _deviceInstance(0) {
_bacClient = nullptr;
}
BACnetSensorGroup::BACnetSensorGroup(const BACnetSensorGroup& other) : SensorGroupTemplate(other),
_bacClient(other._bacClient),
_deviceInstance(other._deviceInstance) {}
BACnetSensorGroup::~BACnetSensorGroup() {}
BACnetSensorGroup& BACnetSensorGroup::operator=(const BACnetSensorGroup& other) {
SensorGroupTemplate::operator =(other);
_bacClient = other._bacClient;
_deviceInstance = other._deviceInstance;
return *this;
}
void BACnetSensorGroup::init(boost::asio::io_service& io) {
SensorGroupTemplate::init(io);
if(_bacClient) {
......
......@@ -17,7 +17,9 @@ class BACnetSensorGroup: public SensorGroupTemplate<BACnetSensorBase> {
public:
BACnetSensorGroup(const std::string& name);
BACnetSensorGroup(const BACnetSensorGroup& other);
virtual ~BACnetSensorGroup();
BACnetSensorGroup& operator=(const BACnetSensorGroup& other);
void init(boost::asio::io_service& io) override;
void start() override;
......
......@@ -25,7 +25,26 @@ public:
_start(0),
_stop(0) {}
virtual ~IPMISensorBase() {
IPMISensorBase(const IPMISensorBase& other) : SensorBase(other),
_recordId(other._recordId),
_sdrRecord(other._sdrRecord),
_factor(other._factor),
_rawCmd(other._rawCmd),
_start(other._start),
_stop(other._stop) {}
virtual ~IPMISensorBase() {}
IPMISensorBase& operator=(const IPMISensorBase& other) {
SensorBase::operator=(other);
_recordId = other._recordId;
_sdrRecord = other._sdrRecord;
_factor = other._factor;
_rawCmd = other._rawCmd;
_start = other._start;
_stop = other._stop;
return *this;
}
uint16_t getRecordId() const { return _recordId; }
......
......@@ -23,8 +23,19 @@ IPMISensorGroup::IPMISensorGroup(const std::string& name) :
_host = nullptr;
}
IPMISensorGroup::IPMISensorGroup(const IPMISensorGroup& other) :
SensorGroupTemplate(other),
_host(other._host) {}
IPMISensorGroup::~IPMISensorGroup() {}
IPMISensorGroup& IPMISensorGroup::operator=(const IPMISensorGroup& other) {
SensorGroupTemplate::operator=(other);
_host = other._host;
return *this;
}
void IPMISensorGroup::init(boost::asio::io_service& io) {
SensorGroupTemplate::init(io);
if (_host) {
......
......@@ -15,7 +15,9 @@ class IPMISensorGroup: public SensorGroupTemplate<IPMISensorBase> {
public:
IPMISensorGroup(const std::string& name);
IPMISensorGroup(const IPMISensorGroup& other);
virtual ~IPMISensorGroup();
IPMISensorGroup& operator=(const IPMISensorGroup& other);
void init(boost::asio::io_service& io) override;
void start() override;
......
......@@ -46,8 +46,18 @@ public:
SensorBase(name),
_counterData(999) {}
OpaSensorBase(const OpaSensorBase& other) : SensorBase(other),
_counterData(other._counterData) {}
virtual ~OpaSensorBase() {}
OpaSensorBase& operator=(const OpaSensorBase& other) {
SensorBase::operator=(other);
_counterData = other._counterData;
return *this;
}
int getCounterData() const { return _counterData; }
void setCounterData(int counterData) { _counterData = counterData; }
......
......@@ -10,9 +10,19 @@
OpaSensorGroup::OpaSensorGroup(const std::string name) :
SensorGroupTemplate(name),
_hfiNum(0),
_portNum(0) {
_port = nullptr;
_imageID = {0};
_portNum(0),
_port(nullptr) {
_imageId = {0};
_imageInfo = {0};
}
OpaSensorGroup::OpaSensorGroup(const OpaSensorGroup& other) :
SensorGroupTemplate(other),
_hfiNum(other._hfiNum),
_portNum(other._portNum),
_port(nullptr) {
_imageId = {0};
_imageInfo = {0};
}
OpaSensorGroup::~OpaSensorGroup() {
......@@ -21,6 +31,17 @@ OpaSensorGroup::~OpaSensorGroup() {
}
}
OpaSensorGroup& OpaSensorGroup::operator=(const OpaSensorGroup& other) {
SensorGroupTemplate::operator =(other);
_hfiNum = other._hfiNum;
_portNum = other._portNum;
_port = nullptr;
_imageId = {0};
_imageInfo = {0};
return *this;
}
void OpaSensorGroup::start() {
if (_keepRunning) {
//we have been started already
......@@ -34,7 +55,7 @@ void OpaSensorGroup::start() {
return;
}
if (omgt_pa_get_image_info(_port, _imageID, &_imageInfo)) {
if (omgt_pa_get_image_info(_port, _imageId, &_imageInfo)) {
LOG(error) << "Sensorgroup " << _groupName << " failed to get PA image";
omgt_close_port(_port);
_port = nullptr;
......@@ -64,7 +85,7 @@ void OpaSensorGroup::read() {
STL_PORT_COUNTERS_DATA portCounters;
try {
if (omgt_pa_get_port_stats(_port, _imageID, 1, _portNum, &_imageID, &portCounters, NULL, 0, 1)) {
if (omgt_pa_get_port_stats(_port, _imageId, 1, _portNum, &_imageId, &portCounters, NULL, 0, 1)) {
throw std::runtime_error("Failed to get port counters");
}
} catch (const std::exception& e) {
......
......@@ -18,7 +18,9 @@
class OpaSensorGroup : public SensorGroupTemplate<OpaSensorBase> {
public:
OpaSensorGroup(const std::string name);
OpaSensorGroup(const OpaSensorGroup& other);
virtual ~OpaSensorGroup();
OpaSensorGroup& operator=(const OpaSensorGroup& other);
void start() override;
void stop() override;
......@@ -37,7 +39,7 @@ private:
uint8_t _portNum;
struct omgt_port * _port;
STL_PA_IMAGE_ID_DATA _imageID;
STL_PA_IMAGE_ID_DATA _imageId;
STL_PA_IMAGE_INFO_DATA _imageInfo;
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment