Builder Class

class QKnxLinkLayerFrame ::Builder

The QKnxLinkLayerFrame::Builder class provides the means to create a KNX link layer frame. 更多...

公共函数

QKnxLinkLayerFrame createFrame () const
Builder & setAdditionalInfos (const QVector<QKnxAdditionalInfo> & infos )
Builder & setControlField (const QKnxControlField & ctrl )
Builder & setData (const QKnxByteArray & data , quint16 offset = 0)
Builder & setDestinationAddress (const QKnxAddress & dest )
Builder & setExtendedControlField (const QKnxExtendedControlField & extCtrl )
Builder & setMedium (QKnx::MediumType type )
Builder & setMessageCode (MessageCode code )
Builder & setSourceAddress (const QKnxAddress & source )
Builder & setTpdu (const QKnxTpdu & tpdu )

详细描述

A KNX link layer frame contains several fields: message code, additional information, control field, maybe an extended control field, a TPDU, as well as a source address and destination address. The fields must be valid for the builder to be able to create a frame.

The builder is set up with default values to create a common external message interface (cEMI) group value read frame, except for the destination address, which needs to be specified during the creation of the frame.

The following code sample illustrates how to establish a KNXnet/IP tunnel connection, to create group value read and write frames, and to send the frames over the connection:

QKnxNetIpTunnel tunnel(...);
tunnel.connectToHost(...);
auto frame = QKnxLinkLayerFrame::builder()
    .setDestinationAddress({ QKnxAddress::Type::Group, QLatin1String("2/1/4") })
    .create();
tunnel.sendFrame(frame);
frame = QKnxLinkLayerFrame::builder()
    .setDestinationAddress({ QKnxAddress::Type::Group, QLatin1String("2/1/4") })
    .setTpdu({
        QKnxTpdu::TransportControlField::DataGroup,
        QKnxTpdu::ApplicationControlField::GroupValueWrite,
        QKnxSwitch(QKnxSwitch::State::On).bytes()
    }).create();
tunnel.sendFrame(frame);
					

另请参阅 QKnxLinkLayerFrame and Qt KNX Tunneling Classes .

成员函数文档编制

QKnxLinkLayerFrame Builder:: createFrame () const

Creates a frame from the values set for the link layer frame message code, additional information, control field, extended control field, TPDU, source address, and destination address. Alternatively, uses a byte array with all the fields already encoded into it.

另请参阅 QKnxLinkLayerFrame , QKnxLinkLayerFrame::MessageCode , QKnxAdditionalInfo , QKnxControlField , QKnxExtendedControlField , QKnxTpdu , QKnxAddress ,和 QKnxByteArray .

Builder &Builder:: setAdditionalInfos (const QVector < QKnxAdditionalInfo > & infos )

Sets the additional information to be used by the builder to infos and returns a reference to the builder.

另请参阅 QKnxAdditionalInfo .

Builder &Builder:: setControlField (const QKnxControlField & ctrl )

Sets the control field to be used by the builder to ctrl and returns a reference to the builder.

另请参阅 QKnxControlField .

Builder &Builder:: setData (const QKnxByteArray & data , quint16 offset = 0)

Sets an array of bytes specified by data with all the fields encoded into a byte array starting from the position offset to avoid having to use each of the field setters separately.

另请参阅 createFrame () 和 QKnxByteArray .

Builder &Builder:: setDestinationAddress (const QKnxAddress & dest )

Sets the destination address to be used by the builder to dest and returns a reference to the builder.

另请参阅 QKnxAddress .

Builder &Builder:: setExtendedControlField (const QKnxExtendedControlField & extCtrl )

Sets the extended control field to be used by the builder to extCtrl and returns a reference to the builder.

另请参阅 QKnxExtendedControlField .

Builder &Builder:: setMedium ( QKnx::MediumType type )

Sets the medium that will determine the format and order of fields to type and returns a reference to the builder.

另请参阅 QKnx::MediumType .

Builder &Builder:: setMessageCode ( MessageCode code )

Sets the link layer frame message code to be used by the builder to code and returns a reference to the builder.

另请参阅 QKnxLinkLayerFrame::MessageCode .

Builder &Builder:: setSourceAddress (const QKnxAddress & source )

Sets the source address to be used by the builder to source and returns a reference to the builder.

另请参阅 QKnxAddress .

Builder &Builder:: setTpdu (const QKnxTpdu & tpdu )

Sets the TPDU to be used by the builder to tpdu and returns a reference to the builder.

另请参阅 QKnxTpdu .