summaryrefslogtreecommitdiffstats
path: root/src/serialbus/qcancommondefinitions.cpp
blob: 8c49de12bc562cc2a49a324a4baa8ef33731428c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only

#include "qcancommondefinitions.h"

#ifndef QT_NO_DEBUG_STREAM
#include <QtCore/QDebug>
#endif // QT_NO_DEBUG_STREAM


QT_BEGIN_NAMESPACE

/*!
    \namespace QtCanBus
    \inmodule QtSerialBus
    \since 6.5
    \brief The QtCanBus namespace provides some commons enums that are used in
    the CAN bus handling part of the QtSerialPort module.
*/

/*!
    \enum QtCanBus::DataSource

    This enum represents the placement of the data within the CAN frame.

    \value Payload The data will be extracted from the payload.
    \value FrameId The data will be extracted from the frame ID.
*/

/*!
    \enum QtCanBus::DataFormat

    This enum represents the possible data formats. The format defines how the
    value will be extracted from its source.

    \value SignedInteger The signal value is a signed integer.
    \value UnsignedInteger The signal value is an unsigned integer.
    \value Float The signal value is float.
    \value Double The signal value is double.
    \value Ascii The signal value is an ASCII string.
*/

/*!
    \enum QtCanBus::DataEndian

    This enum represents the byte order of the data.

    \value LittleEndian The data is little endian.
    \value BigEndian The data is big endian.
*/

/*!
    \enum QtCanBus::MultiplexState

    This enum represents the possible multiplex states of a signal.

    \value None The signal is not used in multiplexing.
    \value MultiplexorSwitch The signal is used as a multiplexor switch, which
                             means that other signals depend on the values of
                             this signal.
    \value MultiplexedSignal The signal is multiplexed by some switch, and
                             therefore its value can only be extracted when the
                             switch has a specific value.
    \value SwitchAndSignal The multiplexor switch of the signal must have the
                           value that enables us to use this signal. When used,
                           the signal also acts as a multiplexor switch for
                           other multiplexed signals.
*/

/*!
    \typealias QtCanBus::UniqueId
*/

#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug dbg, QtCanBus::DataSource source)
{
    QDebugStateSaver saver(dbg);
    switch (source) {
    case QtCanBus::DataSource::Payload:
        dbg << "Payload";
        break;
    case QtCanBus::DataSource::FrameId:
        dbg << "FrameId";
        break;
    }
    return dbg;
}

QDebug operator<<(QDebug dbg, QtCanBus::DataFormat format)
{
    QDebugStateSaver saver(dbg);
    switch (format) {
    case QtCanBus::DataFormat::UnsignedInteger:
        dbg << "UnsignedInteger";
        break;
    case QtCanBus::DataFormat::SignedInteger:
        dbg << "SignedInteger";
        break;
    case QtCanBus::DataFormat::Float:
        dbg << "Float";
        break;
    case QtCanBus::DataFormat::Double:
        dbg << "Double";
        break;
    case QtCanBus::DataFormat::Ascii:
        dbg << "ASCII";
        break;
    }
    return dbg;
}

QDebug operator<<(QDebug dbg, QtCanBus::DataEndian endian)
{
    QDebugStateSaver saver(dbg);
    switch (endian) {
    case QtCanBus::DataEndian::LittleEndian:
        dbg << "LittleEndian";
        break;
    case QtCanBus::DataEndian::BigEndian:
        dbg << "BigEndian";
        break;
    }
    return dbg;
}

QDebug operator<<(QDebug dbg, QtCanBus::MultiplexState state)
{
    QDebugStateSaver saver(dbg);
    switch (state) {
    case QtCanBus::MultiplexState::None:
        dbg << "None";
        break;
    case QtCanBus::MultiplexState::MultiplexorSwitch:
        dbg << "MultiplexorSwitch";
        break;
    case QtCanBus::MultiplexState::MultiplexedSignal:
        dbg << "MultiplexedSignal";
        break;
    case QtCanBus::MultiplexState::SwitchAndSignal:
        dbg << "SwitchAndSignal";
        break;
    }
    return dbg;
}
#endif // QT_NO_DEBUG_STREAM

QT_END_NAMESPACE