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_ONETOMANY
119# include "dawn/prog/onetomany.hxx"
120#endif
121
122#ifdef CONFIG_DAWN_PROG_IOMUX
123# include "dawn/prog/iomux.hxx"
124#endif
125
126#ifdef CONFIG_DAWN_PROG_IODEMUX
127# include "dawn/prog/iodemux.hxx"
128#endif
129
130#ifdef CONFIG_DAWN_PROG_CONFIGWRITER
131# include "dawn/prog/configwriter.hxx"
132#endif
133
134using namespace dawn;
135
137{
138 DEBUGASSERT(desc.getObjectType() == SObjectId::OBJTYPE_PROG);
139
140 switch (desc.getObjectId().s.cls)
141 {
142#ifdef CONFIG_DAWN_PROG_ADJUST
144 return new CProgAdjust(desc);
145#endif
146
147#ifdef CONFIG_DAWN_PROG_DUMMY
149 return new CProgDummy(desc);
150#endif
151
152#ifdef CONFIG_DAWN_PROG_SAMPLING
154 return new CProgSampling(desc);
155#endif
156
157#ifdef CONFIG_DAWN_PROG_SEQUENCER
159 return new CProgSequencer(desc);
160#endif
161
162#ifdef CONFIG_DAWN_PROG_GATEWAY
164 return new CProgGateway(desc);
165#endif
166
167#ifdef CONFIG_DAWN_PROG_LATEST
169 return new CProgLatest(desc);
170#endif
171
172#ifdef CONFIG_DAWN_PROG_REDIRECT
174 return new CProgRedirect(desc);
175#endif
176
177#ifdef CONFIG_DAWN_PROG_BUFFER
179 return new CProgBuffer(desc);
180#endif
181
182#ifdef CONFIG_DAWN_PROG_MOVING_AVG
184 return new CProgMovingAverage(desc);
185#endif
186
187#ifdef CONFIG_DAWN_PROG_IIR_FILTER
189 return new CProgIIRFilter(desc);
190#endif
191
192#ifdef CONFIG_DAWN_PROG_THRESHOLD
194 return new CProgThreshold(desc);
195#endif
196
197#ifdef CONFIG_DAWN_PROG_THRESHOLD_VALUE
199 return new CProgThresholdValue(desc);
200#endif
201
202#ifdef CONFIG_DAWN_PROG_STATS_MIN
204 return new CProgStatsMin(desc);
205#endif
206
207#ifdef CONFIG_DAWN_PROG_STATS_MAX
209 return new CProgStatsMax(desc);
210#endif
211
212#ifdef CONFIG_DAWN_PROG_STATS_AVG
214 return new CProgStatsAvg(desc);
215#endif
216
217#ifdef CONFIG_DAWN_PROG_STATS_SUM
219 return new CProgStatsSum(desc);
220#endif
221
222#ifdef CONFIG_DAWN_PROG_STATS_COUNT
224 return new CProgStatsCount(desc);
225#endif
226
227#ifdef CONFIG_DAWN_PROG_STATS_RMS
229 return new CProgStatsRms(desc);
230#endif
231
232#ifdef CONFIG_DAWN_PROG_BITSPLIT
233 case CProgCommon::PROG_CLASS_BITSPLIT:
234 return new CProgBitSplit(desc);
235#endif
236
237#ifdef CONFIG_DAWN_PROG_TOGGLE
238 case CProgCommon::PROG_CLASS_TOGGLE:
239 return new CProgToggle(desc);
240#endif
241
242#ifdef CONFIG_DAWN_PROG_COUNTER
243 case CProgCommon::PROG_CLASS_COUNTER:
244 return new CProgCounter(desc);
245#endif
246
247#ifdef CONFIG_DAWN_PROG_SWITCH
248 case CProgCommon::PROG_CLASS_SWITCH:
249 return new CProgSwitch(desc);
250#endif
251
252#ifdef CONFIG_DAWN_PROG_EXPRESSION
253 case CProgCommon::PROG_CLASS_EXPRESSION:
254 return new CProgExpression(desc);
255#endif
256
257#ifdef CONFIG_DAWN_PROG_SELECTOR
258 case CProgCommon::PROG_CLASS_SELECTOR:
259 return new CProgSelector(desc);
260#endif
261
262#ifdef CONFIG_DAWN_PROG_BITPACK
263 case CProgCommon::PROG_CLASS_BITPACK:
264 return new CProgBitPack(desc);
265#endif
266
267#ifdef CONFIG_DAWN_PROG_VECPACK
268 case CProgCommon::PROG_CLASS_VECPACK:
269 return new CProgVecPack(desc);
270#endif
271
272#ifdef CONFIG_DAWN_PROG_VECSPLIT
273 case CProgCommon::PROG_CLASS_VECSPLIT:
274 return new CProgVecSplit(desc);
275#endif
276
277#ifdef CONFIG_DAWN_PROG_MANYTOONE
278 case CProgCommon::PROG_CLASS_MANYTOONE:
279 return new CProgManyToOne(desc);
280#endif
281
282#ifdef CONFIG_DAWN_PROG_ONETOMANY
283 case CProgCommon::PROG_CLASS_ONETOMANY:
284 return new CProgOneToMany(desc);
285#endif
286
287#ifdef CONFIG_DAWN_PROG_IOMUX
288 case CProgCommon::PROG_CLASS_IOMUX:
289 return new CProgIOMux(desc);
290#endif
291
292#ifdef CONFIG_DAWN_PROG_IODEMUX
293 case CProgCommon::PROG_CLASS_IODEMUX:
294 return new CProgIODemux(desc);
295#endif
296
297#ifdef CONFIG_DAWN_PROG_CONFIGWRITER
298 case CProgCommon::PROG_CLASS_CONFIGWRITER:
299 return new CProgConfigWriter(desc);
300#endif
301
302 default:
303 {
304 DAWNERR("Unknown PROG class %d\n", desc.getObjectCls());
305 return nullptr;
306 }
307 }
308}
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
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:136
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.