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_VECSPLIT
111# include "dawn/prog/vecsplit.hxx"
112#endif
113
114#ifdef CONFIG_DAWN_PROG_MANYTOONE
115# include "dawn/prog/manytoone.hxx"
116#endif
117
118#ifdef CONFIG_DAWN_PROG_AHRS
119# include "dawn/prog/ahrs.hxx"
120#endif
121
122#ifdef CONFIG_DAWN_PROG_ONETOMANY
123# include "dawn/prog/onetomany.hxx"
124#endif
125
126#ifdef CONFIG_DAWN_PROG_IOMUX
127# include "dawn/prog/iomux.hxx"
128#endif
129
130#ifdef CONFIG_DAWN_PROG_IODEMUX
131# include "dawn/prog/iodemux.hxx"
132#endif
133
134#ifdef CONFIG_DAWN_PROG_CONFIGWRITER
135# include "dawn/prog/configwriter.hxx"
136#endif
137
138using namespace dawn;
139
141{
142 DEBUGASSERT(desc.getObjectType() == SObjectId::OBJTYPE_PROG);
143
144 switch (desc.getObjectId().s.cls)
145 {
146#ifdef CONFIG_DAWN_PROG_ADJUST
148 return new CProgAdjust(desc);
149#endif
150
151#ifdef CONFIG_DAWN_PROG_DUMMY
153 return new CProgDummy(desc);
154#endif
155
156#ifdef CONFIG_DAWN_PROG_SAMPLING
158 return new CProgSampling(desc);
159#endif
160
161#ifdef CONFIG_DAWN_PROG_SEQUENCER
163 return new CProgSequencer(desc);
164#endif
165
166#ifdef CONFIG_DAWN_PROG_GATEWAY
168 return new CProgGateway(desc);
169#endif
170
171#ifdef CONFIG_DAWN_PROG_LATEST
173 return new CProgLatest(desc);
174#endif
175
176#ifdef CONFIG_DAWN_PROG_REDIRECT
178 return new CProgRedirect(desc);
179#endif
180
181#ifdef CONFIG_DAWN_PROG_BUFFER
183 return new CProgBuffer(desc);
184#endif
185
186#ifdef CONFIG_DAWN_PROG_MOVING_AVG
188 return new CProgMovingAverage(desc);
189#endif
190
191#ifdef CONFIG_DAWN_PROG_IIR_FILTER
193 return new CProgIIRFilter(desc);
194#endif
195
196#ifdef CONFIG_DAWN_PROG_THRESHOLD
198 return new CProgThreshold(desc);
199#endif
200
201#ifdef CONFIG_DAWN_PROG_THRESHOLD_VALUE
203 return new CProgThresholdValue(desc);
204#endif
205
206#ifdef CONFIG_DAWN_PROG_STATS_MIN
208 return new CProgStatsMin(desc);
209#endif
210
211#ifdef CONFIG_DAWN_PROG_STATS_MAX
213 return new CProgStatsMax(desc);
214#endif
215
216#ifdef CONFIG_DAWN_PROG_STATS_AVG
218 return new CProgStatsAvg(desc);
219#endif
220
221#ifdef CONFIG_DAWN_PROG_STATS_SUM
223 return new CProgStatsSum(desc);
224#endif
225
226#ifdef CONFIG_DAWN_PROG_STATS_COUNT
228 return new CProgStatsCount(desc);
229#endif
230
231#ifdef CONFIG_DAWN_PROG_STATS_RMS
233 return new CProgStatsRms(desc);
234#endif
235
236#ifdef CONFIG_DAWN_PROG_BITSPLIT
237 case CProgCommon::PROG_CLASS_BITSPLIT:
238 return new CProgBitSplit(desc);
239#endif
240
241#ifdef CONFIG_DAWN_PROG_TOGGLE
242 case CProgCommon::PROG_CLASS_TOGGLE:
243 return new CProgToggle(desc);
244#endif
245
246#ifdef CONFIG_DAWN_PROG_COUNTER
247 case CProgCommon::PROG_CLASS_COUNTER:
248 return new CProgCounter(desc);
249#endif
250
251#ifdef CONFIG_DAWN_PROG_SWITCH
252 case CProgCommon::PROG_CLASS_SWITCH:
253 return new CProgSwitch(desc);
254#endif
255
256#ifdef CONFIG_DAWN_PROG_EXPRESSION
257 case CProgCommon::PROG_CLASS_EXPRESSION:
258 return new CProgExpression(desc);
259#endif
260
261#ifdef CONFIG_DAWN_PROG_SELECTOR
262 case CProgCommon::PROG_CLASS_SELECTOR:
263 return new CProgSelector(desc);
264#endif
265
266#ifdef CONFIG_DAWN_PROG_BITPACK
267 case CProgCommon::PROG_CLASS_BITPACK:
268 return new CProgBitPack(desc);
269#endif
270
271#ifdef CONFIG_DAWN_PROG_VECPACK
272 case CProgCommon::PROG_CLASS_VECPACK:
273 return new CProgVecPack(desc);
274#endif
275
276#ifdef CONFIG_DAWN_PROG_VECSPLIT
277 case CProgCommon::PROG_CLASS_VECSPLIT:
278 return new CProgVecSplit(desc);
279#endif
280
281#ifdef CONFIG_DAWN_PROG_MANYTOONE
282 case CProgCommon::PROG_CLASS_MANYTOONE:
283 return new CProgManyToOne(desc);
284#endif
285
286#ifdef CONFIG_DAWN_PROG_AHRS
287 case CProgCommon::PROG_CLASS_AHRS:
288 return new CProgAhrs(desc);
289#endif
290
291#ifdef CONFIG_DAWN_PROG_ONETOMANY
292 case CProgCommon::PROG_CLASS_ONETOMANY:
293 return new CProgOneToMany(desc);
294#endif
295
296#ifdef CONFIG_DAWN_PROG_IOMUX
297 case CProgCommon::PROG_CLASS_IOMUX:
298 return new CProgIOMux(desc);
299#endif
300
301#ifdef CONFIG_DAWN_PROG_IODEMUX
302 case CProgCommon::PROG_CLASS_IODEMUX:
303 return new CProgIODemux(desc);
304#endif
305
306#ifdef CONFIG_DAWN_PROG_CONFIGWRITER
307 case CProgCommon::PROG_CLASS_CONFIGWRITER:
308 return new CProgConfigWriter(desc);
309#endif
310
311 default:
312 {
313 DAWNERR("Unknown PROG class %d\n", desc.getObjectCls());
314 return nullptr;
315 }
316 }
317}
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 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:27
@ PROG_CLASS_LATEST
Cache latest notified sample for fetch-based readers.
Definition common.hxx:79
@ PROG_CLASS_MOVING_AVG
Moving average filter.
Definition common.hxx:87
@ PROG_CLASS_IIR_FILTER
First-order IIR filter.
Definition common.hxx:91
@ PROG_CLASS_DUMMY
Dummy program (test/helper).
Definition common.hxx:67
@ PROG_CLASS_THRESHOLD_VALUE
Threshold comparator returning gated source value.
Definition common.hxx:99
@ PROG_CLASS_STATS_MAX
Maximum value tracker.
Definition common.hxx:43
@ PROG_CLASS_STATS_MIN
Minimum value tracker.
Definition common.hxx:39
@ PROG_CLASS_GATEWAY
Protocol-to-protocol IO gateway.
Definition common.hxx:75
@ PROG_CLASS_SEQUENCER
Periodic state sequencer.
Definition common.hxx:107
@ PROG_CLASS_STATS_SUM
Sum accumulator.
Definition common.hxx:51
@ PROG_CLASS_BUFFER
Notify-driven history capture buffer.
Definition common.hxx:103
@ PROG_CLASS_SAMPLING
Periodic data sampler.
Definition common.hxx:63
@ PROG_CLASS_THRESHOLD
Threshold and hysteresis comparator.
Definition common.hxx:95
@ PROG_CLASS_REDIRECT
Generic input-to-output routing bridge.
Definition common.hxx:83
@ PROG_CLASS_STATS_RMS
Running RMS (root mean square) calculator.
Definition common.hxx:59
@ PROG_CLASS_ADJUST
Scale/offset adjustment.
Definition common.hxx:71
@ PROG_CLASS_STATS_COUNT
Sample counter.
Definition common.hxx:55
@ PROG_CLASS_STATS_AVG
Running average calculator.
Definition common.hxx:47
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:140
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:29
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::@14 s
Bit-field structure for named member access.