ByteSwap Class

(Automation::ByteSwap)

The ByteSwap operator lets the user re-position bytes in the signal it resides in. More...

Header: #include <ByteSwap>
Inherits: CDPOperator<OPERATOR_TYPE>

Public Functions

ByteSwap(const CDPPropertyBase &in)
~ByteSwap()

Reimplemented Public Functions

virtual void Configure(XMLPrimitive *operatorXML) override
virtual void Create(const char *shortName, CDPBaseObject *parent) override
virtual void FillNodeChildren(CDP::StudioAPI::NodeStream &stream) const override
virtual std::string GetNodeTypeName() const override
virtual unsigned int Process() override

Additional Inherited Members

Detailed Description

The ByteSwap operator lets the user re-position bytes in the signal it resides in.

Depending on the signal type size, the ByteSwap has up to 8 numbered 'BytePosition' properties. Each 'BytePosition' property can be assigned a value which indicates where that byte should be positioned in the signal. The special BytePosition value '-1' means 'Skip processing of this byte'.

The following table describes the byte-positions in an 8-byte (uint64_t, int64_t, double) signal, and how they relate to Least Significant Byte (LSB) and the Most Significant Byte (MSB):

MSBLSB
76543210

Example

To reverse the order of bytes in an 8-byte signal, the following 'BytePosition' property values could be set

NameValue
BytePosition07
BytePosition16
BytePosition25
BytePosition34
BytePosition43
BytePosition52
BytePosition61
BytePosition70

...resulting in a signal-value that is re-mapped to the byte positions shown in this table:

MSBLSB
01234567

In other words: Assume an Input='1' CDPSignal<uint64_t> with a ByteSwap<uint64_t>. If configured with the above BytePositions, a Value of 0x0011223344556677 would yield an InternalValue of 0x7766554433221100.

For signals with less bytes, the scheme is the same, but you only have 4 or 2 BytePosition properties to configure.

Note: There are no restrictions on BytePositions, so in theory it would be possible to map all bytes to position 0. Unused byte-positions will get the value '0', and the last BytePosition written would have precedence over the others.

Member Function Documentation

ByteSwap::ByteSwap(const CDPPropertyBase &in)

Default constructs an instance of ByteSwap.

ByteSwap::~ByteSwap()

Destroys the instance of ByteSwap.

[override virtual] void ByteSwap::Configure(XMLPrimitive *operatorXML)

[override virtual] void ByteSwap::Create(const char *shortName, CDPBaseObject *parent)

[override virtual] void ByteSwap::FillNodeChildren(CDP::StudioAPI::NodeStream &stream) const

[override virtual] std::string ByteSwap::GetNodeTypeName() const

[override virtual] unsigned int ByteSwap::Process()