BACnetSensorBase.h 2.4 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
/*
 * BACnetSensorBase.h
 *
 *  Created on: 13.08.2018
 *      Author: Micha Mueller
 */

#ifndef SRC_SENSORS_BACNET_BACNETSENSORBASE_H_
#define SRC_SENSORS_BACNET_BACNETSENSORBASE_H_

11
#include "sensorbase.h"
12 13 14 15 16

#include "BACnetClient.h"

#include "bacenum.h"

17
class BACnetSensorBase : public SensorBase {
18 19 20 21 22 23 24 25 26 27
public:
	BACnetSensorBase(const std::string& name) :
		SensorBase(name),
		_factor(1),
		_objectInstance(0) {
		_objectType = OBJECT_DEVICE;
		_propertyId = PROP_PRESENT_VALUE;
		_objectIndex = BACNET_ARRAY_ALL;
	}

28 29 30 31 32 33 34
	BACnetSensorBase(const BACnetSensorBase& other) : SensorBase(other),
	  _factor(other._factor),
	  _objectInstance(other._objectInstance),
	  _objectType(other._objectType),
	  _propertyId(other._propertyId),
	  _objectIndex(other._objectIndex) {}

35 36
	virtual ~BACnetSensorBase() {}

37 38 39 40 41 42 43 44 45 46 47
	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;
	}

48 49 50 51 52 53
	double		getFactor()				const { return _factor; }
	uint32_t	getObjectInstance()		const { return _objectInstance; }
	BACNET_OBJECT_TYPE	getObjectType() const { return _objectType; }
	BACNET_PROPERTY_ID	getPropertyId() const { return _propertyId; }
	int32_t			getObjectIndex()	const { return _objectIndex; }

54 55 56 57 58
	void setFactor(const std::string& factor)					{ _factor = std::stod(factor); }
	void setObjectInstance(const std::string& objectInstance)	{ _objectInstance = stoul(objectInstance); }
	void setObjectType(const std::string& objectType)			{ _objectType = static_cast<BACNET_OBJECT_TYPE>(stoul(objectType)); }
	void setPropertyId(const std::string& property)				{ _propertyId = static_cast<BACNET_PROPERTY_ID>(stoul(property)); }
	void setObjectIndex(int32_t objectIndex)					{ _objectIndex = objectIndex; }
59

60
	void printConfig(LOG_LEVEL ll, LOGGER& lg) override {
Micha Müller's avatar
Micha Müller committed
61 62 63 64 65
	  LOG_VAR(ll) << "     Factor: " << _factor;
	  LOG_VAR(ll) << "     objectInstance: " << _objectInstance;
	  LOG_VAR(ll) << "     objectType:     " << _objectType;
	  LOG_VAR(ll) << "     propertyId:     " << _propertyId;
	  LOG_VAR(ll) << "     objectIndex:    " << _objectIndex;
66 67
	}

68 69 70 71 72 73 74 75 76
protected:
	double	_factor;
	uint32_t _objectInstance;
	BACNET_OBJECT_TYPE _objectType;
	BACNET_PROPERTY_ID _propertyId;
	int32_t _objectIndex;
};

#endif /* SRC_SENSORS_BACNET_BACNETSENSORBASE_H_ */