/* * BACnetConfigurator.cpp * * Created on: 14.04.2018 * Author: Micha Mueller */ #include "BACnetConfigurator.h" #include #include BACnetConfigurator::BACnetConfigurator() { _bacClient = nullptr; _groupName = "group"; _baseName = "property"; } BACnetConfigurator::~BACnetConfigurator() {} void BACnetConfigurator::sensorBase(BACnetSensorBase& s, CFG_VAL config) { ADD { ATTRIBUTE("objectInstance", setObjectInstance); ATTRIBUTE("objectType", setObjectType); ATTRIBUTE("id", setPropertyId); ATTRIBUTE("factor", setFactor); } } void BACnetConfigurator::sensorGroup(BACnetSensorGroup& s, CFG_VAL config) { ADD { ATTRIBUTE("deviceInstance", setDeviceInstance); } s.setBACnetClient(_bacClient); } void BACnetConfigurator::global(CFG_VAL config) { _bacClient = std::make_shared(); std::string address_cache, interface; unsigned port = 47808, timeout = 1000, apdu_timeout = 200, apdu_retries = 0; ADD { SETTING("address_cache") { address_cache = val.second.data(); LOG(debug) << " Address Cache: " << address_cache; } SETTING("interface") { interface = val.second.data(); LOG(debug) << " Interface " << interface; } SETTING("port") { port = stoul(val.second.data()); LOG(debug) << " Port " << port; } SETTING("timeout") { timeout = stoul(val.second.data()); LOG(debug) << " Timeout " << timeout; } SETTING("apdu_timeout") { apdu_timeout = stoul(val.second.data()); LOG(debug) << " apdu_timeout " << apdu_timeout; } SETTING("apdu_retries") { apdu_retries = stoul(val.second.data()); LOG(debug) << " apdu_retries " << apdu_retries; } } try { _bacClient->init(interface, address_cache, port, timeout, apdu_timeout, apdu_retries); } catch (const std::exception& e) { LOG(error) << "Could not initialize BACnetClient: " << e.what(); _bacClient = nullptr; return; } } void BACnetConfigurator::printConfiguratorConfig(LOG_LEVEL ll) { LOG_VAR(ll) << " No other plugin specific general attributes"; if (_bacClient) { _bacClient->printConfig(ll); } else { LOG_VAR(ll) << " No BACClient present!"; } }