Dawn Framework 1.0
Universal data acquisition framework for embedded systems
statsavg.hxx
1// dawn/include/dawn/prog/statsavg.hxx
2//
3// SPDX-License-Identifier: Apache-2.0
4//
5
6#pragma once
7
8#include "dawn/io/ddata.hxx"
9#include "dawn/io/common.hxx"
10#include "dawn/porting/config.hxx"
11#include "dawn/prog/common.hxx"
12#include "dawn/prog/process_template.hxx"
13
14namespace dawn
15{
23{
24 template<typename T>
25 static inline void apply(size_t idx, io_ddata_t *ioData, io_ddata_t *outputData, bool &update)
26 {
27 outputData->get<T>(idx) += ioData->get<T>(idx);
28 outputData->get<T>(idx) /= 2;
29 update = true;
30 }
31};
32
40class CProgStatsAvg : public CProgProcessTemplate<StatsOpAvg>
41{
42public:
43 explicit CProgStatsAvg(CDescObject &desc)
45 {
46 }
47
48#ifdef CONFIG_DAWN_OBJECT_HAS_NAME
49 const char *getClassNameStr() const override
50 {
51 return "avg";
52 }
53#endif
54
55 constexpr static SObjectId::ObjectId objectId(uint16_t inst)
56 {
59 }
60
61 constexpr static SObjectCfg::ObjectCfgId cfgId(bool rw, uint8_t size, uint8_t id)
62 {
66 rw,
67 size,
68 id);
69 }
70
71 constexpr static SObjectCfg::ObjectCfgId cfgIdIOBind(uint16_t size = 2)
72 {
73 return CProgStatsAvg::cfgId(false, size, PROG_STATS_CFG_IOBIND);
74 }
75};
76} // Namespace dawn
Descriptor wrapper for individual object configuration.
@ PROG_CLASS_STATS_AVG
Running average calculator.
Definition common.hxx:47
Policy-based template for sample processing implementations.
@ PROG_STATS_CFG_IOBIND
I/O binding configuration.
Definition process.hxx:35
Running average statistics Program.
Definition statsavg.hxx:41
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
Policy for running average calculation.
Definition statsavg.hxx:23
Heap-allocated dynamic I/O data buffer.
Definition ddata.hxx:21
T & get(size_t index, size_t batch=0)
Get data element by index and batch (type-safe).
Definition ddata.hxx:93