Dawn Framework 1.0
Universal data acquisition framework for embedded systems
control.hxx
1// dawn/include/dawn/io/control.hxx
2//
3// SPDX-License-Identifier: Apache-2.0
4//
5
6#pragma once
7
8#include <vector>
9
10#include "dawn/common/object.hxx"
11#include "dawn/io/common.hxx"
12#include "dawn/porting/config.hxx"
13
14namespace dawn
15{
18class CIOControl : public CIOCommon
19{
20public:
21 enum
22 {
23 IO_CONTROL_CFG_FIRST = 0,
24 IO_CONTROL_CFG_ALLOCOBJ = 1,
25 IO_CONTROL_CFG_ALLOWED = 2,
26 IO_CONTROL_CFG_LAST = 31
27 };
28
29 enum
30 {
31 CTRL_ALLOW_STOP = (1 << 0),
32 CTRL_ALLOW_START = (1 << 1)
33 };
34
35 explicit CIOControl(CDescObject &desc)
36 : CIOCommon(desc)
37 , allowed(0)
38 {
39 }
40
41 ~CIOControl() override;
42
43#ifdef CONFIG_DAWN_OBJECT_HAS_NAME
44 const char *getClassNameStr() const override
45 {
46 return "control";
47 }
48#endif
49
50 int configure() override;
51 int deinit() override;
52 int getDataImpl(IODataCmn &data, size_t len) override;
53 int setDataImpl(IODataCmn &data) override;
54 size_t getDataSize() const override;
55 size_t getDataDim() const override;
56
57 bool isRead() const override
58 {
59 return true;
60 }
61
62 bool isWrite() const override
63 {
64 return true;
65 }
66
67 bool isNotify() const override
68 {
69 return false;
70 }
71
72 bool isBatch() const override
73 {
74 return false;
75 }
76
77 int bind(CObject *obj);
78
79 std::vector<SObjectId::ObjectId> ids;
80
82
83 constexpr static SObjectId::ObjectId objectId(uint16_t inst)
84 {
85 return ObjectIdHelper::create(inst);
86 }
87
88 constexpr static SObjectCfg::ObjectCfgId cfgIdAllocObj(size_t n = 1)
89 {
90 return CIOControl::cfgId(false, static_cast<uint8_t>(n), IO_CONTROL_CFG_ALLOCOBJ);
91 }
92
93 constexpr static SObjectCfg::ObjectCfgId cfgIdAllowed()
94 {
95 return CIOControl::cfgId(false, 1, IO_CONTROL_CFG_ALLOWED);
96 }
97
98 constexpr static SObjectCfg::ObjectCfgId cfgId(bool rw, uint8_t size, uint8_t id)
99 {
102 }
103
104private:
105 std::vector<CObject *> targets;
106 uint32_t allowed;
107
108 int configureDesc(const CDescObject &desc);
109};
110
111} // namespace dawn
Descriptor wrapper for individual object configuration.
Template helper for creating ObjectIDs for I/O types without timestamp support.
Definition common.hxx:303
static SObjectId::ObjectId create(uint16_t inst)
Create ObjectID with fixed data type and no timestamp.
Definition common.hxx:312
Base class for all I/O objects.
Definition common.hxx:27
@ IO_CLASS_CONTROL
Control I/O.
Definition common.hxx:93
Control I/O for lifecycle management of bound objects.
Definition control.hxx:19
size_t getDataDim() const
Get data vector dimension.
Definition control.cxx:173
bool isBatch() const
Check if IO supports batch operations.
Definition control.hxx:72
int setDataImpl(IODataCmn &data)
Set data implementation (override in derived classes).
Definition control.cxx:112
bool isWrite() const
Check if IO supports write operations.
Definition control.hxx:62
int configure()
Configure object from descriptor data.
Definition control.cxx:74
@ CTRL_ALLOW_STOP
Allow stop command.
Definition control.hxx:31
@ CTRL_ALLOW_START
Allow start command.
Definition control.hxx:32
int getDataImpl(IODataCmn &data, size_t len)
Get data implementation (override in derived classes).
Definition control.cxx:94
bool isRead() const
Check if IO supports read operations.
Definition control.hxx:57
std::vector< SObjectId::ObjectId > ids
Object IDs to resolve; populated during configure().
Definition control.hxx:79
bool isNotify() const
Check if IO supports notifications.
Definition control.hxx:67
size_t getDataSize() const
Get data size in bytes.
Definition control.cxx:168
int deinit()
De-initialize object.
Definition control.cxx:89
Base class for all Dawn objects (IOs, Programs, Protocols).
Definition object.hxx:28
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
@ OBJTYPE_IO
Input/Output object type.
Definition objectid.hxx:184
@ DTYPE_UINT8
Unsigned 8-bit integer (0 to 255).
Definition objectid.hxx:80
uint32_t ObjectId
ObjectID type - single 32-bit value.
Definition objectid.hxx:44