QCanMessageDescription Class

The QCanMessageDescription class describes the rules to process a CAN message and represent it in an application-defined format. 更多...

头: #include <QCanMessageDescription>
CMake: find_package(Qt6 REQUIRED COMPONENTS SerialBus)
target_link_libraries(mytarget PRIVATE Qt6::SerialBus)
qmake: QT += serialbus
Since: Qt 6.5

该类在开发且可能改变。

公共函数

QCanMessageDescription ()
QCanMessageDescription (const QCanMessageDescription & other )
QCanMessageDescription (QCanMessageDescription && other )
~QCanMessageDescription ()
void addSignalDescription (const QCanSignalDescription & description )
void clearSignalDescriptions ()
QString comment () const
bool isValid () const
QString name () const
void setComment (const QString & text )
void setName (const QString & name )
void setSignalDescriptions (const QList<QCanSignalDescription> & descriptions )
void setSize (quint8 size )
void setTransmitter (const QString & transmitter )
void setUniqueId (QtCanBus::UniqueId id )
QCanSignalDescription signalDescriptionForName (const QString & name ) const
QList<QCanSignalDescription> signalDescriptions () const
quint8 size () const
QString transmitter () const
QtCanBus::UniqueId uniqueId () const
QCanMessageDescription & operator= (const QCanMessageDescription & other )
QCanMessageDescription & operator= (QCanMessageDescription && other )

详细描述

A CAN message is basically a QCanBusFrame . The description of a CAN message includes the following:

  • Message ID.
  • Message name.
  • Message length in bytes.
  • Source of the message (transmitter).
  • Description of signals in the message.

The QCanMessageDescription class provides methods to control all those parameters.

Message ID

The message ID is a unique identifier, which is used to select the proper message description when decoding the incoming QCanBusFrame or encoding a QCanBusFrame based on the provided data.

QCanUniqueIdDescription documentation for more details on the unique identifier description.

Signal Description

The signal description is represented by the QCanSignalDescription class. The QCanMessageDescription class only provides a list of signals that belong to the message.

另请参阅 QCanSignalDescription and QCanUniqueIdDescription .

成员函数文档编制

QCanMessageDescription:: QCanMessageDescription ()

Creates an empty message description.

QCanMessageDescription:: QCanMessageDescription (const QCanMessageDescription & other )

Creates a message description with the values copied from other .

QCanMessageDescription:: QCanMessageDescription ( QCanMessageDescription && other )

Creates a message description by moving from other .

注意: The moved-from QCanMessageDescription object can only be destroyed or assigned to. The effect of calling other functions than the destructor or one of the assignment operators is undefined.

QCanMessageDescription:: ~QCanMessageDescription ()

Destroys this message description.

void QCanMessageDescription:: addSignalDescription (const QCanSignalDescription & description )

Adds a new signal description description to this message description.

If the message description already has a signal description for a signal with the same name, it is overwritten.

另请参阅 signalDescriptions (), signalDescriptionForName (), setSignalDescriptions (),和 clearSignalDescriptions ().

void QCanMessageDescription:: clearSignalDescriptions ()

Clears all the signal descriptions of this message.

另请参阅 signalDescriptions (), signalDescriptionForName (), addSignalDescription (),和 setSignalDescriptions ().

QString QCanMessageDescription:: comment () const

Returns the comment for the message.

This parameter is introduced only for extra description. It's not used during message encoding or decoding.

另请参阅 setComment ().

bool QCanMessageDescription:: isValid () const

返回 true when the message description is valid and false 否则。

A valid message description must have at least one signal description. All signal descriptions must be valid as well.

另请参阅 signalDescriptions () 和 QCanSignalDescription::isValid ().

QString QCanMessageDescription:: name () const

Returns the name of the CAN message.

This parameter is introduced only for extra description. It's not used during message encoding or decoding.

另请参阅 setName ().

void QCanMessageDescription:: setComment (const QString & text )

Sets the comment for the message to text .

This parameter is introduced only for extra description. It's not used during message encoding or decoding.

另请参阅 comment ().

void QCanMessageDescription:: setName (const QString & name )

Sets the name of the CAN message to name .

This parameter is introduced only for extra description. It's not used during message encoding or decoding.

另请参阅 name ().

void QCanMessageDescription:: setSignalDescriptions (const QList < QCanSignalDescription > & descriptions )

Sets the descriptions of the signals belonging to this message description to descriptions .

注意: Message description must have signal descriptions with unique signal names, so if the descriptions list contains entries with duplicated names, only the last entry will be added.

另请参阅 signalDescriptions (), signalDescriptionForName (), addSignalDescription (),和 clearSignalDescriptions ().

void QCanMessageDescription:: setSize ( quint8 size )

Sets the size in bytes of the CAN message to size .

另请参阅 size ().

void QCanMessageDescription:: setTransmitter (const QString & transmitter )

Sets the transmitter node of the message to transmitter .

This parameter is introduced only for extra description. It's not used during message encoding or decoding.

另请参阅 transmitter ().

void QCanMessageDescription:: setUniqueId ( QtCanBus::UniqueId id )

Sets the unique identifier of the CAN message to id .

Message ID section for more information about the unique identifier.

另请参阅 uniqueId ().

QCanSignalDescription QCanMessageDescription:: signalDescriptionForName (const QString & name ) const

Returns the signal description of a signal with the name name .

If the message description does not have such signal description, a default-constructed QCanSignalDescription object is returned.

另请参阅 signalDescriptions (), addSignalDescription (), setSignalDescriptions (),和 clearSignalDescriptions ().

QList < QCanSignalDescription > QCanMessageDescription:: signalDescriptions () const

Returns the list of signal descriptions that belong to this message description.

另请参阅 signalDescriptionForName (), addSignalDescription (), setSignalDescriptions (),和 clearSignalDescriptions ().

quint8 QCanMessageDescription:: size () const

Returns the size in bytes of the CAN message.

另请参阅 setSize ().

QString QCanMessageDescription:: transmitter () const

Returns the transmitter node of the message.

This parameter is introduced only for extra description. It's not used during message encoding or decoding.

另请参阅 setTransmitter ().

QtCanBus::UniqueId QCanMessageDescription:: uniqueId () const

Returns the unique identifier of the CAN message.

Message ID section for more information about the unique identifier.

另请参阅 setUniqueId ().

QCanMessageDescription &QCanMessageDescription:: operator= (const QCanMessageDescription & other )

Assigns the values from other to this message description.

QCanMessageDescription &QCanMessageDescription:: operator= ( QCanMessageDescription && other )

Move-assigns the values from other to this message description.

注意: The moved-from QCanMessageDescription object can only be destroyed or assigned to. The effect of calling other functions than the destructor or one of the assignment operators is undefined.