/* * BACnetSensorBase.h * * Created on: 13.08.2018 * Author: Micha Mueller */ #ifndef SRC_SENSORS_BACNET_BACNETSENSORBASE_H_ #define SRC_SENSORS_BACNET_BACNETSENSORBASE_H_ #include "sensorbase.h" #include "BACnetClient.h" #include "bacenum.h" class BACnetSensorBase : public SensorBase { public: BACnetSensorBase(const std::string& name) : SensorBase(name), _factor(1), _objectInstance(0) { _objectType = OBJECT_DEVICE; _propertyId = PROP_PRESENT_VALUE; _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; } BACNET_PROPERTY_ID getPropertyId() const { return _propertyId; } int32_t getObjectIndex() const { return _objectIndex; } 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(stoul(objectType)); } void setPropertyId(const std::string& property) { _propertyId = static_cast(stoul(property)); } void setObjectIndex(int32_t objectIndex) { _objectIndex = objectIndex; } void printConfig(LOG_LEVEL ll, LOGGER& lg, unsigned leadingSpaces=16) override { std::string leading(leadingSpaces, ' '); LOG_VAR(ll) << leading << " Factor: " << _factor; LOG_VAR(ll) << leading << " objectInstance: " << _objectInstance; LOG_VAR(ll) << leading << " objectType: " << _objectType; LOG_VAR(ll) << leading << " propertyId: " << _propertyId; LOG_VAR(ll) << leading << " objectIndex: " << _objectIndex; } protected: double _factor; uint32_t _objectInstance; BACNET_OBJECT_TYPE _objectType; BACNET_PROPERTY_ID _propertyId; int32_t _objectIndex; }; #endif /* SRC_SENSORS_BACNET_BACNETSENSORBASE_H_ */