2016-06-15 23:48:41 +02:00
|
|
|
#ifndef CPUUSAGE_H_
|
|
|
|
#define CPUUSAGE_H_
|
|
|
|
|
|
|
|
#include <framework/container/FixedArrayList.h>
|
|
|
|
#include <framework/serialize/SerializeIF.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
class CpuUsage : public SerializeIF {
|
|
|
|
public:
|
|
|
|
static const uint8_t MAXIMUM_NUMBER_OF_THREADS = 30;
|
|
|
|
|
|
|
|
class ThreadData: public SerializeIF {
|
|
|
|
public:
|
|
|
|
static const uint8_t MAX_LENGTH_OF_THREAD_NAME = 4;
|
|
|
|
|
|
|
|
uint32_t id;
|
|
|
|
char name[MAX_LENGTH_OF_THREAD_NAME];
|
|
|
|
float timeRunning;
|
|
|
|
float percentUsage;
|
|
|
|
|
2020-04-21 22:28:43 +02:00
|
|
|
virtual ReturnValue_t serialize(uint8_t** buffer, size_t* size,
|
|
|
|
size_t maxSize, Endianness streamEndianness) const override;
|
2016-06-15 23:48:41 +02:00
|
|
|
|
2020-04-21 22:28:43 +02:00
|
|
|
virtual size_t getSerializedSize() const override;
|
2016-06-15 23:48:41 +02:00
|
|
|
|
2020-04-21 22:28:43 +02:00
|
|
|
virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
|
|
|
|
Endianness streamEndianness) override;
|
2016-06-15 23:48:41 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
CpuUsage();
|
|
|
|
virtual ~CpuUsage();
|
|
|
|
|
|
|
|
uint8_t counter;
|
|
|
|
float timeSinceLastReset;
|
|
|
|
FixedArrayList<ThreadData, MAXIMUM_NUMBER_OF_THREADS> threadData;
|
|
|
|
ThreadData cachedValue;
|
|
|
|
|
|
|
|
static void resetCpuUsage();
|
|
|
|
|
|
|
|
void read();
|
|
|
|
|
|
|
|
void clear();
|
|
|
|
|
2020-04-21 22:28:43 +02:00
|
|
|
virtual ReturnValue_t serialize(uint8_t** buffer, size_t* size,
|
|
|
|
size_t maxSize, Endianness streamEndianness) const override;
|
2016-06-15 23:48:41 +02:00
|
|
|
|
2020-04-21 22:28:43 +02:00
|
|
|
virtual size_t getSerializedSize() const override;
|
2016-06-15 23:48:41 +02:00
|
|
|
|
2020-04-21 22:28:43 +02:00
|
|
|
virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
|
|
|
|
Endianness streamEndianness) override;
|
2016-06-15 23:48:41 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* CPUUSAGE_H_ */
|