1 | // Copyright (C) 2022 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | #include "qcancommondefinitions.h" |
5 | |
6 | #ifndef QT_NO_DEBUG_STREAM |
7 | #include <QtCore/QDebug> |
8 | #endif // QT_NO_DEBUG_STREAM |
9 | |
10 | |
11 | QT_BEGIN_NAMESPACE |
12 | |
13 | /*! |
14 | \namespace QtCanBus |
15 | \inmodule QtSerialBus |
16 | \since 6.5 |
17 | \brief The QtCanBus namespace provides some commons enums that are used in |
18 | the CAN bus handling part of the QtSerialPort module. |
19 | */ |
20 | |
21 | /*! |
22 | \enum QtCanBus::DataSource |
23 | |
24 | This enum represents the placement of the data within the CAN frame. |
25 | |
26 | \value Payload The data will be extracted from the payload. |
27 | \value FrameId The data will be extracted from the frame ID. |
28 | */ |
29 | |
30 | /*! |
31 | \enum QtCanBus::DataFormat |
32 | |
33 | This enum represents the possible data formats. The format defines how the |
34 | value will be extracted from its source. |
35 | |
36 | \value SignedInteger The signal value is a signed integer. |
37 | \value UnsignedInteger The signal value is an unsigned integer. |
38 | \value Float The signal value is float. |
39 | \value Double The signal value is double. |
40 | \value AsciiString The signal value is an ASCII string. |
41 | */ |
42 | |
43 | /*! |
44 | \enum QtCanBus::MultiplexState |
45 | |
46 | This enum represents the possible multiplex states of a signal. |
47 | |
48 | \value None The signal is not used in multiplexing. |
49 | \value MultiplexorSwitch The signal is used as a multiplexor switch, which |
50 | means that other signals depend on the values of |
51 | this signal. |
52 | \value MultiplexedSignal The signal is multiplexed by some switch, and |
53 | therefore its value can only be extracted when the |
54 | switch has a specific value. |
55 | \value SwitchAndSignal The multiplexor switch of the signal must have the |
56 | value that enables us to use this signal. When used, |
57 | the signal also acts as a multiplexor switch for |
58 | other multiplexed signals. |
59 | */ |
60 | |
61 | /*! |
62 | \enum QtCanBus::UniqueId |
63 | |
64 | Represents a CAN unique identifier. The underlying type is quint32. |
65 | |
66 | An enum is used to avoid implicit conversions to or from unsigned int. |
67 | */ |
68 | |
69 | #ifndef QT_NO_DEBUG_STREAM |
70 | QDebug QtCanBus::operator<<(QDebug dbg, DataSource source) |
71 | { |
72 | QDebugStateSaver saver(dbg); |
73 | switch (source) { |
74 | case DataSource::Payload: |
75 | dbg << "Payload" ; |
76 | break; |
77 | case DataSource::FrameId: |
78 | dbg << "FrameId" ; |
79 | break; |
80 | } |
81 | return dbg; |
82 | } |
83 | |
84 | QDebug QtCanBus::operator<<(QDebug dbg, DataFormat format) |
85 | { |
86 | QDebugStateSaver saver(dbg); |
87 | switch (format) { |
88 | case DataFormat::UnsignedInteger: |
89 | dbg << "UnsignedInteger" ; |
90 | break; |
91 | case DataFormat::SignedInteger: |
92 | dbg << "SignedInteger" ; |
93 | break; |
94 | case DataFormat::Float: |
95 | dbg << "Float" ; |
96 | break; |
97 | case DataFormat::Double: |
98 | dbg << "Double" ; |
99 | break; |
100 | case DataFormat::AsciiString: |
101 | dbg << "ASCII" ; |
102 | break; |
103 | } |
104 | return dbg; |
105 | } |
106 | |
107 | QDebug QtCanBus::operator<<(QDebug dbg, MultiplexState state) |
108 | { |
109 | QDebugStateSaver saver(dbg); |
110 | switch (state) { |
111 | case MultiplexState::None: |
112 | dbg << "None" ; |
113 | break; |
114 | case MultiplexState::MultiplexorSwitch: |
115 | dbg << "MultiplexorSwitch" ; |
116 | break; |
117 | case MultiplexState::MultiplexedSignal: |
118 | dbg << "MultiplexedSignal" ; |
119 | break; |
120 | case MultiplexState::SwitchAndSignal: |
121 | dbg << "SwitchAndSignal" ; |
122 | break; |
123 | } |
124 | return dbg; |
125 | } |
126 | |
127 | QDebug QtCanBus::operator<<(QDebug dbg, UniqueId uid) |
128 | { |
129 | dbg << qToUnderlying(e: uid); |
130 | return dbg; |
131 | } |
132 | #endif // QT_NO_DEBUG_STREAM |
133 | |
134 | QT_END_NAMESPACE |
135 | |