Dawn Framework 1.0
Universal data acquisition framework for embedded systems
sysinfo.hxx
1// dawn/include/dawn/io/sysinfo.hxx
2//
3// SPDX-License-Identifier: Apache-2.0
4//
5
6#pragma once
7
8#include <mutex>
9
10#include "dawn/io/common.hxx"
11#include "dawn/porting/config.hxx"
12
13namespace dawn
14{
22class CIOSysinfo : public CIOCommon
23{
24public:
25 explicit CIOSysinfo(CDescObject &desc)
26 : CIOCommon(desc)
27 , dim(getDataDim(getCls()))
28 {
29 }
30
31 ~CIOSysinfo() override;
32
33#ifdef CONFIG_DAWN_OBJECT_HAS_NAME
34 const char *getClassNameStr() const override
35 {
36 switch (getCls())
37 {
39 return "uptime";
41 return "cpuload";
42 default:
43 return "sysinfo";
44 }
45 }
46#endif
47
48 int init() override;
49 int getDataImpl(IODataCmn &data, size_t len) override;
50 int setDataImpl(IODataCmn &data) override;
51 size_t getDataSize() const override;
52 size_t getDataDim() const override;
53
54 bool isRead() const override
55 {
56 return true;
57 };
58
59 bool isWrite() const override
60 {
61 return false;
62 };
63
64 bool isNotify() const override
65 {
66 return false;
67 };
68
69 bool isBatch() const override
70 {
71 return false;
72 };
73
74 constexpr static SObjectId::ObjectId objectIdUptime()
75 {
78 }
79
80 constexpr static SObjectId::ObjectId objectIdCpuload(uint8_t dtype)
81 {
83 }
84
85private:
86 size_t dim;
87
88 size_t getDataDim(uint16_t cls) const;
89};
90} // Namespace dawn
Descriptor wrapper for individual object configuration.
Base class for all I/O objects.
Definition common.hxx:27
@ IO_CLASS_SYSTEM_UPTIME
System uptime.
Definition common.hxx:150
@ IO_CLASS_SYSTEM_CPULOAD
CPU load.
Definition common.hxx:151
System information I/O providing uptime and CPU load.
Definition sysinfo.hxx:23
bool isNotify() const
Check if IO supports notifications.
Definition sysinfo.hxx:64
bool isBatch() const
Check if IO supports batch operations.
Definition sysinfo.hxx:69
int getDataImpl(IODataCmn &data, size_t len)
Get data implementation (override in derived classes).
Definition sysinfo.cxx:56
int setDataImpl(IODataCmn &data)
Set data implementation (override in derived classes).
Definition sysinfo.cxx:128
size_t getDataDim() const
Get data vector dimension.
Definition sysinfo.cxx:25
size_t getDataSize() const
Get data size in bytes.
Definition sysinfo.cxx:135
int init()
One-time initialize object after bindings are resolved.
Definition sysinfo.cxx:13
bool isRead() const
Check if IO supports read operations.
Definition sysinfo.hxx:54
bool isWrite() const
Check if IO supports write operations.
Definition sysinfo.hxx:59
uint16_t getCls() const
Get object class field.
Definition object.cxx:170
Out-of-tree user-extension hooks for Dawn.
Definition bindable.hxx:13
Base interface for I/O data buffers (static and dynamic).
Definition idata.hxx:21
@ OBJTYPE_IO
Input/Output object type.
Definition objectid.hxx:184
@ DTYPE_UINT64
Unsigned 64-bit integer.
Definition objectid.hxx:104
uint32_t ObjectId
ObjectID type - single 32-bit value.
Definition objectid.hxx:44
static ObjectId objectId(uint8_t type, uint16_t cls, uint8_t dtype, uint8_t flags, uint16_t priv)
Construct 32-bit ObjectID from component fields.
Definition objectid.hxx:290