Dawn Framework 1.0
Universal data acquisition framework for embedded systems
factory.cxx
1// dawn/src/proto/factory.cxx
2//
3// SPDX-License-Identifier: Apache-2.0
4//
5
6#include "dawn/proto/factory.hxx"
7
8#ifdef CONFIG_DAWN_PROTO_DUMMY
9# include "dawn/proto/dummy.hxx"
10#endif
11
12#ifdef CONFIG_DAWN_PROTO_NXSCOPE_DUMMY
13# include "dawn/proto/nxscope/dummy.hxx"
14#endif
15#ifdef CONFIG_DAWN_PROTO_NXSCOPE_SERIAL
16# include "dawn/proto/nxscope/serial.hxx"
17#endif
18#ifdef CONFIG_DAWN_PROTO_NXSCOPE_UDP
19# include "dawn/proto/nxscope/udp.hxx"
20#endif
21#ifdef CONFIG_DAWN_PROTO_SHELL_PRETTY
22# include "dawn/proto/shell/pretty.hxx"
23#endif
24#ifdef CONFIG_DAWN_PROTO_SERIAL
25# include "dawn/proto/serial/simple.hxx"
26#endif
27#ifdef CONFIG_DAWN_PROTO_UDP
28# include "dawn/proto/udp/simple.hxx"
29#endif
30#ifdef CONFIG_DAWN_PROTO_IPC
31# include "dawn/proto/ipc/simple.hxx"
32#endif
33#ifdef CONFIG_DAWN_PROTO_NIMBLE_PERIPHERAL
34# include "dawn/proto/nimble/prph.hxx"
35#endif
36#ifdef CONFIG_DAWN_PROTO_CAN
37# include "dawn/proto/can/can.hxx"
38#endif
39#ifdef CONFIG_DAWN_PROTO_MODBUS_RTU
40# include "dawn/proto/modbus/rtu.hxx"
41#endif
42#ifdef CONFIG_DAWN_PROTO_MODBUS_TCP
43# include "dawn/proto/modbus/tcp.hxx"
44#endif
45
46using namespace dawn;
47
49{
50 DEBUGASSERT(desc.getObjectType() == SObjectId::OBJTYPE_PROTO);
51
52 switch (desc.getObjectCls())
53 {
54#ifdef CONFIG_DAWN_PROTO_DUMMY
56 return new CProtoDummy(desc);
57#endif
58
59#ifdef CONFIG_DAWN_PROTO_NXSCOPE_DUMMY
61 return new CProtoNxscopeDummy(desc);
62#endif
63
64#ifdef CONFIG_DAWN_PROTO_NXSCOPE_SERIAL
66 return new CProtoNxscopeSerial(desc);
67#endif
68
69#ifdef CONFIG_DAWN_PROTO_NXSCOPE_UDP
71 return new CProtoNxscopeUdp(desc);
72#endif
73
74#ifdef CONFIG_DAWN_PROTO_SHELL_PRETTY
76 return new CProtoShellPretty(desc);
77#endif
78
79#ifdef CONFIG_DAWN_PROTO_SERIAL
81 return new CProtoSerial(desc);
82#endif
83
84#ifdef CONFIG_DAWN_PROTO_UDP
86 return new CProtoUdp(desc);
87#endif
88
89#ifdef CONFIG_DAWN_PROTO_IPC
91 return new CProtoIpc(desc);
92#endif
93
94#ifdef CONFIG_DAWN_PROTO_NIMBLE_PERIPHERAL
96 return new CProtoNimblePrph(desc);
97#endif
98
99#ifdef CONFIG_DAWN_PROTO_CAN
101 return new CProtoCan(desc);
102#endif
103
104#ifdef CONFIG_DAWN_PROTO_MODBUS_RTU
106 return new CProtoModbusRtu(desc);
107#endif
108
109#ifdef CONFIG_DAWN_PROTO_MODBUS_TCP
111 return new CProtoModbusTcp(desc);
112#endif
113
114 default:
115 {
116 DAWNERR("Unknown PROTO class %d\n", desc.getObjectCls());
117 return nullptr;
118 }
119 }
120}
Descriptor wrapper for individual object configuration.
uint8_t getObjectType() const
Get object type field.
uint16_t getObjectCls() const
Get object class field.
CAN bus protocol for industrial automation.
Definition can.hxx:36
Base class for all protocol implementations.
Definition common.hxx:23
@ PROTO_CLASS_NXSCOPE_UDP
NxScope real-time visualization (UDP interface).
Definition common.hxx:51
@ PROTO_CLASS_MODBUS_TCP
Modbus TCP (network implementation).
Definition common.hxx:71
@ PROTO_CLASS_MODBUS_RTU
Modbus RTU (serial implementation).
Definition common.hxx:67
@ PROTO_CLASS_NXSCOPE_SERIAL
NxScope real-time visualization (serial interface).
Definition common.hxx:47
@ PROTO_CLASS_DUMMY
Dummy protocol (test/helper).
Definition common.hxx:43
@ PROTO_CLASS_UDP
UDP-based protocol.
Definition common.hxx:79
@ PROTO_CLASS_SERIAL
Compact binary protocol over serial port.
Definition common.hxx:63
@ PROTO_CLASS_NIMBLE_PRPH
BLE Peripheral using Apache NimBLE stack.
Definition common.hxx:35
@ PROTO_CLASS_IPC
FIFO-based local IPC protocol.
Definition common.hxx:83
@ PROTO_CLASS_NXSCOPE_DUMMY
NxScope real-time visualization (dummy interface).
Definition common.hxx:39
@ PROTO_CLASS_SHELL_STD
Interactive shell on stdin/stdout.
Definition common.hxx:55
@ PROTO_CLASS_CAN
CAN bus protocol.
Definition common.hxx:75
Dummy Protocol for tests and binding placeholders.
Definition dummy.hxx:21
CProtoCommon * create(CDescObject &desc)
Create a protocol object from descriptor.
Definition factory.cxx:48
Simple FIFO-based IPC transport for local Dawn communication.
Definition simple.hxx:30
Modbus RTU (Remote Terminal Unit) protocol implementation.
Definition rtu.hxx:27
Modbus TCP protocol implementation.
Definition tcp.hxx:27
BLE Peripheral (Slave) Protocol Implementation using NimBLE.
Definition prph.hxx:27
NXScope no-op/dummy transport implementation.
Definition dummy.hxx:20
NXScope over serial port transport.
Definition serial.hxx:21
NXScope over UDP transport.
Definition udp.hxx:16
Simple binary serial protocol for device communication.
Definition simple.hxx:28
Interactive Command-Line Shell Interface.
Definition pretty.hxx:33
Simple binary UDP protocol for device communication.
Definition simple.hxx:30
Out-of-tree user-extension hooks for Dawn.
Definition bindable.hxx:13
@ OBJTYPE_PROTO
Protocol object type.
Definition objectid.hxx:193