Dawn Framework 1.0
Universal data acquisition framework for embedded systems
latest.hxx
1// dawn/include/dawn/prog/latest.hxx
2//
3// SPDX-License-Identifier: Apache-2.0
4//
5
6#pragma once
7
8#include "dawn/debug.hxx"
9#include "dawn/io/ddata.hxx"
10#include "dawn/io/common.hxx"
11#include "dawn/porting/config.hxx"
12#include "dawn/prog/process.hxx"
13
14namespace dawn
15{
24{
25public:
26 explicit CProgLatest(CDescObject &desc)
27 : CProgProcess(desc)
28 {
29 }
30
31#ifdef CONFIG_DAWN_OBJECT_HAS_NAME
32 const char *getClassNameStr() const override
33 {
34 return "latest";
35 }
36#endif
37
38 constexpr static SObjectId::ObjectId objectId(uint16_t inst)
39 {
42 }
43
44 constexpr static SObjectCfg::ObjectCfgId cfgId(bool rw, uint8_t size, uint8_t id)
45 {
48 }
49
50 constexpr static SObjectCfg::ObjectCfgId cfgIdIOBind(uint16_t size = 2)
51 {
52 return CProgLatest::cfgId(false, size, PROG_STATS_CFG_IOBIND);
53 }
54
55protected:
56 void handle(CIOCommon *output,
57 io_ddata_t *data,
58 io_ddata_t *ioData,
59 io_ddata_t *outputData,
60 bool &initsample) override
61 {
62 int ret;
63
64 (void)ioData;
65 (void)outputData;
66 (void)initsample;
67
68 ret = output->setData(*data);
69 if (ret != OK)
70 {
71 DAWNERR("failed to cache latest sample %d\n", ret);
72 }
73 }
74};
75} // Namespace dawn
Descriptor wrapper for individual object configuration.
Base class for all I/O objects.
Definition common.hxx:27
int setData(IODataCmn &data, size_t offset=0)
Set data for I/O (public interface with stats tracking).
Definition common.hxx:392
@ PROG_CLASS_LATEST
Cache latest notified sample for fetch-based readers.
Definition common.hxx:79
Latest-sample cache Program.
Definition latest.hxx:24
void handle(CIOCommon *output, io_ddata_t *data, io_ddata_t *ioData, io_ddata_t *outputData, bool &initsample)
Process incoming sample.
Definition latest.hxx:56
Base class for callback-driven sample processing Program objects.
Definition process.hxx:28
@ PROG_STATS_CFG_IOBIND
I/O binding configuration.
Definition process.hxx:35
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_PROG
Program/algorithm object type.
Definition objectid.hxx:202
@ DTYPE_ANY
Wildcard data type (matches any actual type).
Definition objectid.hxx:68
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
Heap-allocated dynamic I/O data buffer.
Definition ddata.hxx:21