Dawn Framework 1.0
Universal data acquisition framework for embedded systems
factory.cxx
1// dawn/src/prog/factory.cxx
2//
3// SPDX-License-Identifier: Apache-2.0
4//
5
6#include "dawn/prog/factory.hxx"
7
8#include "dawn/prog/common.hxx"
9
10#ifdef CONFIG_DAWN_PROG_ADJUST
11# include "dawn/prog/adjust.hxx"
12#endif
13
14#ifdef CONFIG_DAWN_PROG_DUMMY
15# include "dawn/prog/dummy.hxx"
16#endif
17
18#ifdef CONFIG_DAWN_PROG_SAMPLING
19# include "dawn/prog/sampling.hxx"
20#endif
21
22#ifdef CONFIG_DAWN_PROG_SEQUENCER
23# include "dawn/prog/sequencer.hxx"
24#endif
25
26#ifdef CONFIG_DAWN_PROG_GATEWAY
27# include "dawn/prog/gateway.hxx"
28#endif
29
30#ifdef CONFIG_DAWN_PROG_LATEST
31# include "dawn/prog/latest.hxx"
32#endif
33
34#ifdef CONFIG_DAWN_PROG_REDIRECT
35# include "dawn/prog/redirect.hxx"
36#endif
37
38#ifdef CONFIG_DAWN_PROG_BUFFER
39# include "dawn/prog/buffer.hxx"
40#endif
41
42#ifdef CONFIG_DAWN_PROG_MOVING_AVG
43# include "dawn/prog/movingavg.hxx"
44#endif
45
46#ifdef CONFIG_DAWN_PROG_IIR_FILTER
47# include "dawn/prog/iirfilter.hxx"
48#endif
49
50#ifdef CONFIG_DAWN_PROG_THRESHOLD_ANY
51# include "dawn/prog/threshold.hxx"
52#endif
53
54#ifdef CONFIG_DAWN_PROG_STATS_AVG
55# include "dawn/prog/statsavg.hxx"
56#endif
57
58#ifdef CONFIG_DAWN_PROG_STATS_COUNT
59# include "dawn/prog/statscount.hxx"
60#endif
61
62#ifdef CONFIG_DAWN_PROG_STATS_RMS
63# include "dawn/prog/statsrms.hxx"
64#endif
65
66#ifdef CONFIG_DAWN_PROG_STATS_MAX
67# include "dawn/prog/statsmax.hxx"
68#endif
69
70#ifdef CONFIG_DAWN_PROG_STATS_MIN
71# include "dawn/prog/statsmin.hxx"
72#endif
73
74#ifdef CONFIG_DAWN_PROG_STATS_SUM
75# include "dawn/prog/statssum.hxx"
76#endif
77
78#ifdef CONFIG_DAWN_PROG_BITSPLIT
79# include "dawn/prog/bitsplit.hxx"
80#endif
81
82#ifdef CONFIG_DAWN_PROG_TOGGLE
83# include "dawn/prog/toggle.hxx"
84#endif
85
86#ifdef CONFIG_DAWN_PROG_COUNTER
87# include "dawn/prog/counter.hxx"
88#endif
89
90#ifdef CONFIG_DAWN_PROG_SWITCH
91# include "dawn/prog/switch.hxx"
92#endif
93
94#ifdef CONFIG_DAWN_PROG_EXPRESSION
95# include "dawn/prog/expression.hxx"
96#endif
97
98#ifdef CONFIG_DAWN_PROG_SELECTOR
99# include "dawn/prog/selector.hxx"
100#endif
101
102#ifdef CONFIG_DAWN_PROG_BITPACK
103# include "dawn/prog/bitpack.hxx"
104#endif
105
106#ifdef CONFIG_DAWN_PROG_VECPACK
107# include "dawn/prog/vecpack.hxx"
108#endif
109
110#ifdef CONFIG_DAWN_PROG_SATURATE
111# include "dawn/prog/saturate.hxx"
112#endif
113
114#ifdef CONFIG_DAWN_PROG_BITMERGE
115# include "dawn/prog/bitmerge.hxx"
116#endif
117
118#ifdef CONFIG_DAWN_PROG_VECSPLIT
119# include "dawn/prog/vecsplit.hxx"
120#endif
121
122#ifdef CONFIG_DAWN_PROG_MANYTOONE
123# include "dawn/prog/manytoone.hxx"
124#endif
125
126#ifdef CONFIG_DAWN_PROG_AHRS
127# include "dawn/prog/ahrs.hxx"
128#endif
129
130#ifdef CONFIG_DAWN_PROG_ONETOMANY
131# include "dawn/prog/onetomany.hxx"
132#endif
133
134#ifdef CONFIG_DAWN_PROG_IOMUX
135# include "dawn/prog/iomux.hxx"
136#endif
137
138#ifdef CONFIG_DAWN_PROG_IODEMUX
139# include "dawn/prog/iodemux.hxx"
140#endif
141
142#ifdef CONFIG_DAWN_PROG_CONFIGWRITER
143# include "dawn/prog/configwriter.hxx"
144#endif
145
146using namespace dawn;
147
149{
150 DEBUGASSERT(desc.getObjectType() == SObjectId::OBJTYPE_PROG);
151
152 switch (desc.getObjectId().s.cls)
153 {
154#ifdef CONFIG_DAWN_PROG_ADJUST
156 return new CProgAdjust(desc);
157#endif
158
159#ifdef CONFIG_DAWN_PROG_DUMMY
161 return new CProgDummy(desc);
162#endif
163
164#ifdef CONFIG_DAWN_PROG_SAMPLING
166 return new CProgSampling(desc);
167#endif
168
169#ifdef CONFIG_DAWN_PROG_SEQUENCER
171 return new CProgSequencer(desc);
172#endif
173
174#ifdef CONFIG_DAWN_PROG_GATEWAY
176 return new CProgGateway(desc);
177#endif
178
179#ifdef CONFIG_DAWN_PROG_LATEST
181 return new CProgLatest(desc);
182#endif
183
184#ifdef CONFIG_DAWN_PROG_REDIRECT
186 return new CProgRedirect(desc);
187#endif
188
189#ifdef CONFIG_DAWN_PROG_BUFFER
191 return new CProgBuffer(desc);
192#endif
193
194#ifdef CONFIG_DAWN_PROG_MOVING_AVG
196 return new CProgMovingAverage(desc);
197#endif
198
199#ifdef CONFIG_DAWN_PROG_IIR_FILTER
201 return new CProgIIRFilter(desc);
202#endif
203
204#ifdef CONFIG_DAWN_PROG_THRESHOLD
206 return new CProgThreshold(desc);
207#endif
208
209#ifdef CONFIG_DAWN_PROG_THRESHOLD_VALUE
211 return new CProgThresholdValue(desc);
212#endif
213
214#ifdef CONFIG_DAWN_PROG_STATS_MIN
216 return new CProgStatsMin(desc);
217#endif
218
219#ifdef CONFIG_DAWN_PROG_STATS_MAX
221 return new CProgStatsMax(desc);
222#endif
223
224#ifdef CONFIG_DAWN_PROG_STATS_AVG
226 return new CProgStatsAvg(desc);
227#endif
228
229#ifdef CONFIG_DAWN_PROG_STATS_SUM
231 return new CProgStatsSum(desc);
232#endif
233
234#ifdef CONFIG_DAWN_PROG_STATS_COUNT
236 return new CProgStatsCount(desc);
237#endif
238
239#ifdef CONFIG_DAWN_PROG_STATS_RMS
241 return new CProgStatsRms(desc);
242#endif
243
244#ifdef CONFIG_DAWN_PROG_BITSPLIT
245 case CProgCommon::PROG_CLASS_BITSPLIT:
246 return new CProgBitSplit(desc);
247#endif
248
249#ifdef CONFIG_DAWN_PROG_TOGGLE
250 case CProgCommon::PROG_CLASS_TOGGLE:
251 return new CProgToggle(desc);
252#endif
253
254#ifdef CONFIG_DAWN_PROG_COUNTER
255 case CProgCommon::PROG_CLASS_COUNTER:
256 return new CProgCounter(desc);
257#endif
258
259#ifdef CONFIG_DAWN_PROG_SWITCH
260 case CProgCommon::PROG_CLASS_SWITCH:
261 return new CProgSwitch(desc);
262#endif
263
264#ifdef CONFIG_DAWN_PROG_EXPRESSION
265 case CProgCommon::PROG_CLASS_EXPRESSION:
266 return new CProgExpression(desc);
267#endif
268
269#ifdef CONFIG_DAWN_PROG_SELECTOR
270 case CProgCommon::PROG_CLASS_SELECTOR:
271 return new CProgSelector(desc);
272#endif
273
274#ifdef CONFIG_DAWN_PROG_BITPACK
275 case CProgCommon::PROG_CLASS_BITPACK:
276 return new CProgBitPack(desc);
277#endif
278
279#ifdef CONFIG_DAWN_PROG_VECPACK
280 case CProgCommon::PROG_CLASS_VECPACK:
281 return new CProgVecPack(desc);
282#endif
283
284#ifdef CONFIG_DAWN_PROG_SATURATE
285 case CProgCommon::PROG_CLASS_SATURATE:
286 return new CProgSaturate(desc);
287#endif
288
289#ifdef CONFIG_DAWN_PROG_BITMERGE
290 case CProgCommon::PROG_CLASS_BITMERGE:
291 return new CProgBitMerge(desc);
292#endif
293
294#ifdef CONFIG_DAWN_PROG_VECSPLIT
295 case CProgCommon::PROG_CLASS_VECSPLIT:
296 return new CProgVecSplit(desc);
297#endif
298
299#ifdef CONFIG_DAWN_PROG_MANYTOONE
300 case CProgCommon::PROG_CLASS_MANYTOONE:
301 return new CProgManyToOne(desc);
302#endif
303
304#ifdef CONFIG_DAWN_PROG_AHRS
305 case CProgCommon::PROG_CLASS_AHRS:
306 return new CProgAhrs(desc);
307#endif
308
309#ifdef CONFIG_DAWN_PROG_ONETOMANY
310 case CProgCommon::PROG_CLASS_ONETOMANY:
311 return new CProgOneToMany(desc);
312#endif
313
314#ifdef CONFIG_DAWN_PROG_IOMUX
315 case CProgCommon::PROG_CLASS_IOMUX:
316 return new CProgIOMux(desc);
317#endif
318
319#ifdef CONFIG_DAWN_PROG_IODEMUX
320 case CProgCommon::PROG_CLASS_IODEMUX:
321 return new CProgIODemux(desc);
322#endif
323
324#ifdef CONFIG_DAWN_PROG_CONFIGWRITER
325 case CProgCommon::PROG_CLASS_CONFIGWRITER:
326 return new CProgConfigWriter(desc);
327#endif
328
329 default:
330 {
331 DAWNERR("Unknown PROG class %d\n", desc.getObjectCls());
332 return nullptr;
333 }
334 }
335}
Descriptor wrapper for individual object configuration.
uint8_t getObjectType() const
Get object type field.
uint16_t getObjectCls() const
Get object class field.
SObjectId::UObjectId & getObjectId() const
Get object identifier as union structure.
Data scaling and offset transformation PROG.
Definition adjust.hxx:31
AHRS sensor fusion (x-io Fusion): accel + gyro IOs in, world-frame linear acceleration (gravity remov...
Definition ahrs.hxx:23
Bit merger: out = OR over inputs of ((in & mask) << shift).
Definition bitmerge.hxx:30
Bit packer: combines multiple typed inputs into a single packed output bitstream.
Definition bitpack.hxx:36
Bit demultiplexer: extracts configurable bit slices from the input into separate outputs.
Definition bitsplit.hxx:30
Notify-driven history buffer Program.
Definition buffer.hxx:27
Base class for all PROG (processing) objects.
Definition common.hxx:28
@ PROG_CLASS_LATEST
Cache latest notified sample for fetch-based readers.
Definition common.hxx:80
@ PROG_CLASS_MOVING_AVG
Moving average filter.
Definition common.hxx:88
@ PROG_CLASS_IIR_FILTER
First-order IIR filter.
Definition common.hxx:92
@ PROG_CLASS_DUMMY
Dummy program (test/helper).
Definition common.hxx:68
@ PROG_CLASS_THRESHOLD_VALUE
Threshold comparator returning gated source value.
Definition common.hxx:100
@ PROG_CLASS_STATS_MAX
Maximum value tracker.
Definition common.hxx:44
@ PROG_CLASS_STATS_MIN
Minimum value tracker.
Definition common.hxx:40
@ PROG_CLASS_GATEWAY
Protocol-to-protocol IO gateway.
Definition common.hxx:76
@ PROG_CLASS_SEQUENCER
Periodic state sequencer.
Definition common.hxx:108
@ PROG_CLASS_STATS_SUM
Sum accumulator.
Definition common.hxx:52
@ PROG_CLASS_BUFFER
Notify-driven history capture buffer.
Definition common.hxx:104
@ PROG_CLASS_SAMPLING
Periodic data sampler.
Definition common.hxx:64
@ PROG_CLASS_THRESHOLD
Threshold and hysteresis comparator.
Definition common.hxx:96
@ PROG_CLASS_REDIRECT
Generic input-to-output routing bridge.
Definition common.hxx:84
@ PROG_CLASS_STATS_RMS
Running RMS (root mean square) calculator.
Definition common.hxx:60
@ PROG_CLASS_ADJUST
Scale/offset adjustment.
Definition common.hxx:72
@ PROG_CLASS_STATS_COUNT
Sample counter.
Definition common.hxx:56
@ PROG_CLASS_STATS_AVG
Running average calculator.
Definition common.hxx:48
Event counter with configurable wrap-around.
Definition counter.hxx:31
Dummy Program for tests and descriptor binding placeholders.
Definition dummy.hxx:21
Arithmetic expression evaluator on IO values.
CProgCommon * create(CDescObject &desc)
Create a PROG object from descriptor.
Definition factory.cxx:148
Protocol-to-protocol IO gateway Program.
Definition gateway.hxx:30
First-order IIR low-pass filter.
Definition iirfilter.hxx:29
IO demultiplexer: routes one input to the selected output.
Definition iodemux.hxx:22
IO multiplexer: routes selected input to one output.
Definition iomux.hxx:22
Latest-sample cache Program.
Definition latest.hxx:24
Many-to-one bridge: forwards the last changed input to one output.
Definition manytoone.hxx:22
Notify-driven sliding window moving average filter.
Definition movingavg.hxx:30
One-to-many bridge: forwards one input to many outputs.
Definition onetomany.hxx:22
Input-to-output routing Program.
Definition redirect.hxx:29
Periodic data sampling and buffering Program.
Definition sampling.hxx:31
Saturating limiter: clamps input samples into a [min, max] range.
Definition saturate.hxx:25
Data selector: routes one of N data inputs to a target IO based on the value of a control input.
Definition selector.hxx:31
Periodic state sequencer Program.
Definition sequencer.hxx:29
Running average statistics Program.
Definition statsavg.hxx:41
Sample counting statistics Program.
Maximum value tracking statistics Program.
Definition statsmax.hxx:42
Minimum value tracking statistics Program.
Definition statsmin.hxx:45
Running RMS statistics Program.
Definition statsrms.hxx:31
Sum accumulation statistics Program.
Definition statssum.hxx:39
Multi-input AND-gate switch: writes on/off commands to a target IO when all control inputs match thei...
Definition switch.hxx:32
Threshold comparator returning gated source values.
Threshold comparator returning boolean alert output.
Toggle/latch: flips output between two configured values on each rising edge of the input.
Definition toggle.hxx:31
Vector packer: combines multiple IO values into one vector IO.
Definition vecpack.hxx:27
Vector splitter: splits one vector IO into multiple outputs.
Definition vecsplit.hxx:26
Out-of-tree user-extension hooks for Dawn.
Definition bindable.hxx:13
@ OBJTYPE_PROG
Program/algorithm object type.
Definition objectid.hxx:202
uint32_t cls
Object class field (bits 21-29, max 511).
Definition objectid.hxx:265
struct dawn::SObjectId::UObjectId::@305255014053264215072363020330017273014233040275 s
Bit-field structure for named member access.