ThreadStatus.hpp
Go to the documentation of this file.
1 
22 // RIOT includes
23 #include <etl/string.h>
24 
25 // Project includes
26 #include "MemoryStatus.hpp"
27 #include "PB_ThreadStatus.hpp"
28 #ifdef MODULE_CANPB
29 #include "canpb/CanProtobuf.hpp"
30 #endif
31 
32 #pragma once
33 
34 #ifndef SYSMON_THREADSTATUS_NAME_MAX_LENGTH
35 # define SYSMON_THREADSTATUS_NAME_MAX_LENGTH 64
36 #endif
37 
38 namespace cogip {
39 
40 namespace sysmon {
41 
42 class ThreadStatus: public MemoryStatus {
44  using PB_Message = PB_ThreadStatus<SYSMON_THREADSTATUS_NAME_MAX_LENGTH>;
45 
46  public:
48  ThreadStatus() : MemoryStatus(), pid_(0), loops_(0), overshots_(0) {};
49 
51  void inc_loops() { loops_++; };
53  void inc_overshots() { overshots_++; };
55  uint32_t loops() const { return loops_; };
57  etl::string<SYSMON_THREADSTATUS_NAME_MAX_LENGTH> name() const { return name_; };
59  uint32_t overshots() const { return overshots_; };
61  uint32_t pid() const { return pid_; };
63  void set_loops(const uint32_t loops) { loops_ = loops; };
65  void set_name(const etl::string<SYSMON_THREADSTATUS_NAME_MAX_LENGTH> &name) { name_ = name; };
67  void set_overshots(const uint32_t overshots) { overshots_ = overshots; };
69  void set_pid(const uint32_t pid) { pid_ = pid; };
70 
72  const PB_Message &pb_message() const { return pb_message_; };
74  void update_pb_message();
75 
76  private:
78  uint32_t pid_;
80  etl::string<SYSMON_THREADSTATUS_NAME_MAX_LENGTH> name_;
82  uint32_t loops_;
84  uint32_t overshots_;
85 
87  PB_Message pb_message_;
88 };
89 
91 void display_heap_status();
93 void display_threads_status();
95 void sysmon_start();
96 
97 #ifdef MODULE_CANPB
98 void register_canpb(cogip::canpb::CanProtobuf *);
100 #endif
101 
102 } // namespace sysmon
103 
104 } // namespace cogip
105 
cogip::sysmon::ThreadStatus
Definition: ThreadStatus.hpp:42
cogip::sysmon::ThreadStatus::inc_overshots
void inc_overshots()
Increment thread overshots number.
Definition: ThreadStatus.hpp:53
cogip::sysmon::ThreadStatus::update_pb_message
void update_pb_message()
Update Protobuf message.
cogip::sysmon::ThreadStatus::set_overshots
void set_overshots(const uint32_t overshots)
Set thread overshots number.
Definition: ThreadStatus.hpp:67
cogip::sysmon::ThreadStatus::loops
uint32_t loops() const
Get thread loops number.
Definition: ThreadStatus.hpp:55
cogip::sysmon::ThreadStatus::set_pid
void set_pid(const uint32_t pid)
Set thread pid.
Definition: ThreadStatus.hpp:69
cogip::sysmon::ThreadStatus::name
etl::string< SYSMON_THREADSTATUS_NAME_MAX_LENGTH > name() const
Get thread name.
Definition: ThreadStatus.hpp:57
cogip
Differential drive controller.
Definition: Coords.hpp:16
cogip::canpb::CanProtobuf
Generic CAN Protobuf communication class.
Definition: CanProtobuf.hpp:60
cogip::sysmon::ThreadStatus::set_loops
void set_loops(const uint32_t loops)
Set thread loops number.
Definition: ThreadStatus.hpp:63
cogip::sysmon::ThreadStatus::ThreadStatus
ThreadStatus()
Constructor.
Definition: ThreadStatus.hpp:48
cogip::sysmon::ThreadStatus::pid
uint32_t pid() const
Get thread pid.
Definition: ThreadStatus.hpp:61
cogip::sysmon::ThreadStatus::pb_message
const PB_Message & pb_message() const
Return the Protobuf message.
Definition: ThreadStatus.hpp:72
cogip::sysmon::ThreadStatus::inc_loops
void inc_loops()
Increment thread loops number.
Definition: ThreadStatus.hpp:51
CanProtobuf.hpp
Exchange Protobuf messages over CAN module.
cogip::sysmon::ThreadStatus::set_name
void set_name(const etl::string< SYSMON_THREADSTATUS_NAME_MAX_LENGTH > &name)
Set thread name.
Definition: ThreadStatus.hpp:65
cogip::sysmon::MemoryStatus
Definition: MemoryStatus.hpp:38
MemoryStatus.hpp
Public API for sysmon module.
cogip::sysmon::ThreadStatus::overshots
uint32_t overshots() const
Get thread overshots number.
Definition: ThreadStatus.hpp:59