Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager

Blocks for constructing packages

Information


The concept of the SerialPackager is to allow adding/retrieving data to/from a package in a device independent manner. See Getting started.

Extends from Modelica.Icons.Package (Icon for standard packages).

Package Content

NameDescription
Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager.Packager Packager Create a package which allows to add signals of various types
Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager.AddBoolean AddBoolean Add a Boolean vector to package
Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager.AddInteger AddInteger Add an Integer vector to package
Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager.AddReal AddReal Add a Real vector to package
Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager.AddFloat AddFloat Cast all elements of Real vector to float and add to package (loss of precision!)
Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager.AddString AddString Add string to package
Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager.GetBoolean GetBoolean Get Boolean vector from package
Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager.GetInteger GetInteger Get Integer vector from package
Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager.GetReal GetReal Get Real vector from package
Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager.GetFloat GetFloat Get float vector from package (all values casted to double before assigning it to Modelica Real array)
Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager.GetString GetString Get String from package
Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager.PackUnsignedInteger PackUnsignedInteger Encode (non-negative) integer value at bit level
Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager.UnpackUnsignedInteger UnpackUnsignedInteger decode integer value encoded at bit level
Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager.ResetPointer ResetPointer Set current writing/reading position of package to zero

Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager.Packager Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager.Packager

Create a package which allows to add signals of various types

Information


The Packager block creates a packager object to which payload can be added by subsequent blocks.

Advanced parameter settings

With the default parameter settings the buffer size (size of the serialized package), as well as the sample time of the block is determined automatically by backward propagation. However, that values may also be set manually. An example there this functionality is used is the TestSerialPackager model. In that model the parameter sampleTime is explicitely set, since backward propagation is not possible in that case.

Examples

The block is used in several examples, e.g. in, TestSerialPackager_UDP. The figure below shows an arrangement in which a Packager object is created and after that a payload of three Real values and one Integer value is added, serialized and finally sent using UDP.

Parameters

NameDescription
Advanced
useBackwardSampleTimePropagationtrue, use backward propagation for sample time (default!), otherwise switch to forward propagation
sampleTimeSample time if forward propagation of sample time is used
useBackwardPropagatedBufferSizetrue, use backward propagated (automatic) buffer size for package (default!), otherwise use manually specified buffer size below
userBufferSizeBuffer size for package if backward propagation of buffer size is deactivated

Connectors

NameDescription
pkgOut 

Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager.AddBoolean Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager.AddBoolean

Add a Boolean vector to package

Information

Extends from Modelica_DeviceDrivers.Utilities.Icons.SerialPackagerWriteIcon, Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager.Internal.PartialSerialPackager.

Parameters

NameDescription
n 

Connectors

NameDescription
pkgIn 
pkgOut[nu] 
u[n] 

Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager.AddInteger Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager.AddInteger

Add an Integer vector to package

Information



Extends from Modelica_DeviceDrivers.Utilities.Icons.SerialPackagerWriteIcon, Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager.Internal.PartialSerialPackager.

Parameters

NameDescription
n 

Connectors

NameDescription
pkgIn 
pkgOut[nu] 
u[n] 

Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager.AddReal Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager.AddReal

Add a Real vector to package

Information

Extends from Modelica_DeviceDrivers.Utilities.Icons.SerialPackagerWriteIcon, Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager.Internal.PartialSerialPackager.

Parameters

NameDescription
n 

Connectors

NameDescription
pkgIn 
pkgOut[nu] 
u[n] 

Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager.AddFloat Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager.AddFloat

Cast all elements of Real vector to float and add to package (loss of precision!)

Information

Extends from Modelica_DeviceDrivers.Utilities.Icons.SerialPackagerWriteIcon, Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager.Internal.PartialSerialPackager.

Parameters

NameDescription
n 

Connectors

NameDescription
pkgIn 
pkgOut[nu] 
u[n] 

Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager.AddString Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager.AddString

Add string to package

Information

Extends from Modelica_DeviceDrivers.Utilities.Icons.SerialPackagerWriteIcon, Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager.Internal.PartialSerialPackager.

Parameters

NameDescription
bufferSizeBuffer size (in bytes) reserved for String (ensure that same buffer size is used in corresponding GetString block!)
data 

Connectors

NameDescription
pkgIn 
pkgOut[nu] 

Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager.GetBoolean Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager.GetBoolean

Get Boolean vector from package

Information

Extends from Modelica_DeviceDrivers.Utilities.Icons.SerialPackagerReadIcon, Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager.Internal.PartialSerialPackager.

Parameters

NameDescription
n 

Connectors

NameDescription
pkgIn 
pkgOut[nu] 
y[n] 

Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager.GetInteger Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager.GetInteger

Get Integer vector from package

Information

Extends from Modelica_DeviceDrivers.Utilities.Icons.SerialPackagerReadIcon, Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager.Internal.PartialSerialPackager.

Parameters

NameDescription
n 

Connectors

NameDescription
pkgIn 
pkgOut[nu] 
y[n] 

Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager.GetReal Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager.GetReal

Get Real vector from package

Information

Extends from Modelica_DeviceDrivers.Utilities.Icons.SerialPackagerReadIcon, Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager.Internal.PartialSerialPackager.

Parameters

NameDescription
n 

Connectors

NameDescription
pkgIn 
pkgOut[nu] 
y[n] 

Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager.GetFloat Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager.GetFloat

Get float vector from package (all values casted to double before assigning it to Modelica Real array)

Information

Extends from Modelica_DeviceDrivers.Utilities.Icons.SerialPackagerReadIcon, Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager.Internal.PartialSerialPackager.

Parameters

NameDescription
n 

Connectors

NameDescription
pkgIn 
pkgOut[nu] 
y[n] 

Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager.GetString Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager.GetString

Get String from package

Information

Extends from Modelica_DeviceDrivers.Utilities.Icons.SerialPackagerReadIcon, Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager.Internal.PartialSerialPackager.

Parameters

NameDescription
bufferSizeBuffer size (in bytes) reserved for String (ensure that same buffer size is used in corresponding AddString block!)

Connectors

NameDescription
pkgIn 
pkgOut[nu] 

Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager.PackUnsignedInteger Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager.PackUnsignedInteger

Encode (non-negative) integer value at bit level

Information


The block allows to pack unsigned integer values on bit level. The number of bits used for encoding is set by parameter width, therefore the maximum value of the integer signal that can be encoded is 2^width - 1. The parameter bitOffset allows to specify the bit at which the encoding starts relative to the preceding block.

If an AddBoolean, AddInteger, AddReal or AddString block follows a PackUnsignedInteger block the bit position after the PackUnsignedInteger block is aligned to the next byte boundery.

Endianness

Currently, the pack block only supports Intel-Endiannes (little-endian!).

For information about endianness in computing see for example http://en.wikipedia.org/wiki/Endianness

Example

The block is used in example TestSerialPackagerBitPack_UDP, depicted below.

The first 3*8 byte of the payload is used for the Real variables. After that two Integer variables are packed into the payload. Finally one Integer variable is added using an ordinary AddInteger block. Assuming that the value of the first Integer variable was 3 (decimal) == 11 (binary) we would get the memory layout below. A '.' denotes that the bit is not part of the bits encoding the value (LSB = Least Significant Byte and MSB = Most Significant Byte).
                                           byte 24                 byte 25
                                             LSB                      MSB
Relative bit position in Memory: (0  1  2  3  4  5  6  7)  (8  9  10 11 12 13 14 15) ( ..
Value of bit                   : (0  0  0  0  0  0  1  1)  (.  .   .  .  .  .  0  0)

See also UnpackUnsignedInteger.

Extends from Modelica_DeviceDrivers.Utilities.Icons.SerialPackagerWriteIcon, Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager.Internal.PartialSerialPackager.

Parameters

NameDescription
bitOffsetBit offset from current packager position until first encoding bit
widthNumber of bits that encode the integer value

Connectors

NameDescription
pkgIn 
pkgOut[nu] 
uOnly postive (unsigned) values are supported

Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager.UnpackUnsignedInteger Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager.UnpackUnsignedInteger

decode integer value encoded at bit level

Information


The block allows to unpack unsigned integer values on bit level. The number of bits used for decoding is set by parameter width. The parameter bitOffset allows to specify the bit at which the decoding starts relative to the preceding block.

If an GetBoolean, GetInteger, GetReal or GetString block follows an UnpackUnsignedInteger block the bit position after the UnpackUnsignedInteger block is aligned to the next byte boundery.

Endianness

Currently, the pack block only supports Intel-Endiannes (little-endian!).

For information about endianness in computing see for example http://en.wikipedia.org/wiki/Endianness

Example

The block is used in example TestSerialPackagerBitPack_UDP, depicted below.

The first 3*8 byte of the payload is deserialized to Real variables. After that two Integer variables are unpacked from the payload. Finally one Integer variable is deserialized using an ordinary GetInteger block. Assume that we had the memory layout below and would like to unpack the second Integer value. A '.' denotes that the bit is not part of the bits encoding the value (LSB = Least Significant Byte and MSB = Most Significant Byte).
                                  byte 24  byte 25  byte 26          byte 27                    byte 28
                                                                       LSB                         MSB
Relative bit position in Memory:   0-7      8-15     16-23   (24 25 26 27 28 29 30 31) (32 33 34 35 36 37 38 39) (..
Value of bit                   :                               0  1  .  .  .  .  .  .    0  0  0  0  0  0  0  1

The value of the unpacked second Integer value would be 5 (decimal) == 101 (binary).

See also PackUnsignedInteger.

Extends from Modelica_DeviceDrivers.Utilities.Icons.SerialPackagerReadIcon, Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager.Internal.PartialSerialPackager.

Parameters

NameDescription
bitOffsetBit offset from current packager position until first encoding bit
widthNumber of bits that encode the integer value

Connectors

NameDescription
pkgIn 
pkgOut[nu] 
y 

Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager.ResetPointer Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager.ResetPointer

Set current writing/reading position of package to zero

Information

Extends from Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager.Internal.PartialSerialPackager.

Connectors

NameDescription
pkgIn 
pkgOut[nu] 

Automatically generated Tue Oct 1 14:26:57 2013.