BACnetConfigurator.h 1.51 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
/*
 * BACnetConfigurator.h
 *
 *  Created on: 14.04.2018
 *      Author: Micha Mueller
 */

#ifndef BACNETCONFIGURATOR_H_
#define BACNETCONFIGURATOR_H_

11
12
13
#include "BACnetSensor.h"
#include "BACnetClient.h"

14
15
16
17
18
#include <string>
#include <vector>
#include <map>
#include <boost/property_tree/ptree.hpp>

19
20
21
#include "../../ConfiguratorTemplate.h"

class BACnetConfigurator: public ConfiguratorTemplate<BACnetSensor> {
22
23
24
25
26
27
28
29
30
31
32

	typedef std::map<std::string, BACnetSensor> sensorMap_t;

public:

	BACnetConfigurator();
	virtual ~BACnetConfigurator();

	/**
	 * Read in the configuration for BACnet-sensors.
	 * @param cfgPath	Path + name of the config-file
33
	 * @return		true on success, false otherwise
34
	 */
35
	bool readConfig(std::string cfgPath);
36

37
38
39
40
41
	//Overwrite from Configurator
	bool reReadConfig() {
		for (auto s : _sensors) {
			s->stopPolling();
		}
42
		sleep(10);
43
44
45
		delete _bacClient;
		_bacClient = NULL;
		_templateSensors.clear();
46
		return ConfiguratorTemplate::reReadConfig();
47
48
	}

49
50
51
52
53
private:
	/**
	 * Set the variables of sensor according to the values specified in config.
	 * @param sensor	The sensor to be configured
	 * @param config	A property(sub)tree containing the values
54
55
	 *
	 * @return	True on success, false otherwise
56
	 */
57
	bool readSensor(BACnetSensor& sensor, boost::property_tree::iptree& config);
58

59
	BACnetClient*		 _bacClient;
60
61
62
	sensorMap_t 	 	 _templateSensors;
};

63
extern "C" ConfiguratorTemplate* create() {
64
65
66
	return new BACnetConfigurator;
}

67
extern "C" void destroy(ConfiguratorTemplate* c) {
68
69
70
71
	delete c;
}

#endif /* BACNETCONFIGURATOR_H_ */