PerfSensorGroup.h 1.62 KB
Newer Older
1
/*
2
 * PerfSensorGroup.h
3
4
 *
 *  Created on: 04.08.2018
lu43jih's avatar
lu43jih committed
5
 *      Author: Micha Mueller, Carla Guillen
6
7
 */

8
9
#ifndef PERFSENSORGROUP_H_
#define PERFSENSORGROUP_H_
10

11
#include "../../includes/SensorGroupTemplate.h"
12
#include "PerfSensorBase.h"
13

14
15
16
17
class PerfSensorGroup;

using PerfSGPtr = std::shared_ptr<PerfSensorGroup>;

18
class PerfSensorGroup : public SensorGroupTemplate<PerfSensorBase> {
19
public:
20
	PerfSensorGroup(const std::string& name);
21
	PerfSensorGroup(const PerfSensorGroup& other);
22
	virtual ~PerfSensorGroup();
23
	PerfSensorGroup& operator=(const PerfSensorGroup& other);
24

25
26
27
	void init(boost::asio::io_service& io) override;
	void start() override;
	void stop() override;
28

29
30
31
32
	int		getCpuId() 				const	{ return _cpuId; }

	void setCpuId(int cpuId) 							{ _cpuId = cpuId; }
	void setSensorGroupLeader(bool sensorGroupLeader) { _sensorGroupLeader = sensorGroupLeader; }
lu43jih's avatar
lu43jih committed
33
	void setMaxCorrection(double maxCorrection){ _maxCorrection = maxCorrection; }
34

35
	void pushBackGroup(PerfSGPtr perfGroup) { _fellowSensorGroups.push_back(perfGroup); }
36

Micha Mueller's avatar
Micha Mueller committed
37
38
	void printConfig(LOG_LEVEL ll) override;

39
private:
40
41
42
	void read() override;
	void readAsync() override;

43
44
45
	//are we the sensorGroupLeader?
	bool _sensorGroupLeader;

46
	int	_cpuId;
47
48
	int	_group_fd;
	std::vector<int> _fds;
49

50
51
52
	char *	_buf;
	std::size_t	_bufSize;
	std::vector<uint64_t>	_ids;
53
54

	//the sensorGroupLeader stores attached groups in here
55
	std::vector<PerfSGPtr> _fellowSensorGroups;
56

lu43jih's avatar
lu43jih committed
57
58
	uint64_t _latest_time_enabled;
	uint64_t _latest_time_running;
59
	bool _lastValid;
lu43jih's avatar
lu43jih committed
60
61

	double _maxCorrection;
62
63

	uint64_t calculateIntervalValue(uint64_t previous, uint64_t current, uint64_t maxValue);
64
65
};

66

lu43jih's avatar
lu43jih committed
67

68
#endif /* PERFSENSORGROUP_H_ */