Dawn Framework 1.0
Universal data acquisition framework for embedded systems
timestamp.hxx
1// dawn/include/dawn/io/timestamp.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/io/timerfd.hxx"
12#include "dawn/porting/config.hxx"
13
14namespace dawn
15{
23 : public CIOCommon
24 , public CIOTimerfd
25{
26public:
27 enum
28 {
29 IO_TIMESTAMP_CFG_FIRST = 0,
30 IO_TIMESTAMP_CFG_INTERVAL = 1,
31 IO_TIMESTAMP_CFG_LAST = 31
32 };
33
34 explicit CIOTimestamp(CDescObject &desc)
35 : CIOCommon(desc)
36 , tlen(getDtypeSize())
37 {
38 }
39
40 ~CIOTimestamp() override;
41
42#ifdef CONFIG_DAWN_OBJECT_HAS_NAME
43 const char *getClassNameStr() const override
44 {
45 return "timestamp";
46 }
47#endif
48
49 int doStart() override;
50 int doStop() override;
51 int configure() override;
52 int deinit() override;
53 int getDataImpl(IODataCmn &data, size_t len) override;
54
55#ifdef CONFIG_DAWN_IO_NOTIFY
56 int getFd() const override;
57#endif
58
59 size_t getDataSize() const override;
60 size_t getDataDim() const override;
61
62 bool isRead() const override
63 {
64 return true;
65 };
66
67 bool isWrite() const override
68 {
69 return false;
70 };
71
72 bool isNotify() const override
73 {
74 return true;
75 };
76
77 bool isBatch() const override
78 {
79 return false;
80 };
81
83
84 constexpr static SObjectId::ObjectId objectId(SObjectId::EObjectDataType dtype,
85 bool ts,
86 uint16_t inst)
87 {
88 return ObjectIdHelper::create(dtype, ts, inst);
89 }
90
91 constexpr static SObjectCfg::ObjectCfgId cfgInterval(bool rw)
92 {
96 rw,
97 1,
98 IO_TIMESTAMP_CFG_INTERVAL);
99 }
100
101private:
102 size_t tlen;
103
104 int configureDesc(const CDescObject &desc);
105};
106} // Namespace dawn
Descriptor wrapper for individual object configuration.
Template helper for creating ObjectIDs for I/O types.
Definition common.hxx:236
static SObjectId::ObjectId create(bool ts, uint16_t inst)
Create ObjectID with default data type.
Definition common.hxx:246
Base class for all I/O objects.
Definition common.hxx:27
virtual int getFd() const
Get file descriptor for notifications.
Definition common.hxx:425
@ IO_CLASS_TIMESTAMP
Timestamp generator.
Definition common.hxx:103
Internal helper for timer-based I/O notifications.
Definition timerfd.hxx:22
System timestamp/monotonic time generator.
Definition timestamp.hxx:25
int deinit()
De-initialize object.
Definition timestamp.cxx:75
bool isBatch() const
Check if IO supports batch operations.
Definition timestamp.hxx:77
bool isRead() const
Check if IO supports read operations.
Definition timestamp.hxx:62
bool isWrite() const
Check if IO supports write operations.
Definition timestamp.hxx:67
bool isNotify() const
Check if IO supports notifications.
Definition timestamp.hxx:72
size_t getDataSize() const
Get data size in bytes.
int doStart()
Start implementation hook.
int getDataImpl(IODataCmn &data, size_t len)
Get data implementation (override in derived classes).
Definition timestamp.cxx:84
int configure()
Configure object from descriptor data.
Definition timestamp.cxx:60
int doStop()
Stop implementation hook.
size_t getDataDim() const
Get data vector dimension.
size_t getDtypeSize() const
Get size of this object's data type.
Definition object.cxx:195
static ObjectCfgId objectCfg(uint8_t type, uint16_t cls, uint8_t dtype, bool rw, uint16_t size, uint8_t id)
Construct 32-bit ConfigID from component fields.
uint32_t ObjectCfgId
ConfigID type - single 32-bit value.
Definition objectcfg.hxx:60
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
EObjectDataType
Data types supported by Dawn framework.
Definition objectid.hxx:61
@ DTYPE_UINT32
Unsigned 32-bit integer (0 to 4294967295).
Definition objectid.hxx:96
uint32_t ObjectId
ObjectID type - single 32-bit value.
Definition objectid.hxx:44