SSE Level 2 Vendor Interface Specification(FAST)-15章-FAST Decoder(FAST解析-第一部分)

转自https://blog.csdn.net/islyb/article/details/5792754

15.1 FAST message

The structure of a message purely encoded in STEP looks like this:

 

The structure of a STEP message with message body encoded in FAST looks like this:

 

Within a STEP message, FAST message is stored in the raw data field (96) of which length in byte is
stored in raw data length (95). Vendor supplied system should first read raw data length field from
the STEP message and then extract the FAST message from the raw data field according to the length
specified in the raw data length field.


Each FAST message contains one or multiple market data message. All messages in a FAST message
are of the same category and message type.

>>>每个FAST消息包含一个或多个行情数据信息.在FAST消息内的所有信息具有相同的分类及消息类型.

 

For message that uses FAST operator, the scope of operator is each STEP message.  Thus the 
dictionary2 for previous value should be reset after each FAST message.  There is only one global 
dictionary in IDC. It will be reset each time after every FAST message.  The first entity of each 
market data is presence map which will be discussed later.  Then decoder should process the 
remaining market data by the information provided from the presence map and template.

>>>消息使用的是FAST操作符,操作符的范围是每一个STEP消息.因此在每一个FAST消息之后,dictionary 先前的值需要被重置.

>>>在IDC内部,仅有一个全局的dictionary.在每个FAST消息后,每次都将被重置.每一个行情数据的第一个实体是presence map.解析器需

>>>要根据presence map 和 template提供的信息对剩余的行情数据进行处理.

 

 

15.2 Presence Map

The presence map is encoded as bit vector by using stop bit encoding.  If a presence map that ends 
with a sequence of all zero, the byte(s) with all zero bits in the end of the presence map will be 
truncated.

>>>presence map是通过使用停止位作为位向量进行编码的.如果一个presence map是以一个全0序列来结尾的,那么在

>>>presence map  的末尾的所有0位的字节将被截掉.

15.3 Template

Message template is used for eliminate the tag in the FAST message.  As tag numbers are not sent out 
to the receiver, receiver cannot decode the message without the template.  Templates provide the 
information to instruct FAST how to encode or decode each entry within a message.  Field data type 
Field names, field ids, presence attribute, field operators are provided in the template.  Template is 
represented in xml format. The tag number of template id is 999.

>>>消息模板是用于排除(消除)FAST消息中的tag的.因为标签号没有发送给接收器,接收器不能解码不带模板的消息.模板提供的信息用来

>>>指示FAST如何编码或解码消息内部的每个实体.Field data type Field names, field ids, presence attribute, field operators

>>>都在模板内部被提供.模板是用xml格式呈现的.模板ID的标签号是999.

 

The template id of transaction is 1101 which is used for selecting the corresponding template to 
decode the FAST message.  The attribute decimalPlaces is an optional field.  If this tag is present, 
shifting decimal places is required.  The number of decimal places shifted is the value of the attribute.

>>>transaction的模板ID是1101,它被用于选取对应的模板来解析FAST消息.decimalPlaces属性是一个可选字段.如果出现这个tag

>>>则移动小数位是必需的.移动小数位的个数就是这个属性的值.

 

15.3.1 Data type

>>>数据类型

Here is the data type used or will be used in FAST.

>>>以下是在FAST中现用或者将被使用的数据类型

In each entry, field name and field ID are mandatory attributes while presence is an optional attribute. 
The presence attribute represents whether the field is mandatory or optional. The default value for 
presence attribute is mandatory. More detail about presence attribute will be discussed later.

>>>在每一个实体中,虽然presence是一个可选属性,但field name和field ID还是强制属性.

>>>presence属性表示字段是强制的还是可选的.它的默认值是强制的.

 

15.3.1.1  String data type

>>>String数据类型
A string data type has an optional charset attribute indicating the character set used in this data type.
There are two supported character sets are ASCII and UTF-8.  The default character set is ASCII.  
The value for UTF-8 is “unicode”. 

>>>String数据类型有一个可选的charset属性,它用来指示这个数据类型的字符集.有二种字符集被支持,它们是ASCII和UTF-8.默认

>>>的字符集是ASCII.UTF-8的值为"unicode".

 

15.3.1.2  Integer data type

>>>Integer数据类型
An integer data type is used for storing 32-bit integer data. 

>>>它用于存储32位有符号整型数.
 
15.3.1.3  Long data type

>>>Long数据类型
A long data type is used for storing 64-bit integer data.

>>>它用于存储64位有符号长整型数.

 

15.3.1.4  Repeating group data type

>>>Repeating group 数据类型
A repeating group data type is used for a group of repeating instructions.  The first child of sequence 
must be a length tag which is for storing the number of repeating group. The length field is signed 
integer in IDC.

>>>Repeating group 数据类型用于一组重复指令.序列的第一个子项必须是一个用于存储Repeating group个数的长度标签.

>>>在IDC中,这个长度字段是有符号整型.

 

15.3.2 Field encoding operator

>>>字段编码操作符
Here is the field encoding operator used or will be used in FAST. 

>>>以下是在FAST中现用或将被使用的字段编码操作符:

 

*The constant operator field which is optional will occupy a single bit. The bit will be set to on if the 
input value is equal to the constant value which is defined in the template.  It will be set to off if the 
input value is absent and no value will be set in the stream for constant operator. 

>>>constant操作符是可选的并且占据1bit.如果这个输入值等于在模板中定义的常量值,那么这个bit将被置成on.

>>>如果这个输入值是不存在的,那么这个bit将被置成off,并且在数据流中也将没有值被设置用于这个constant操作符.
 
Presence map is a sequence of bits representing the presence of fields inside a FAST message.  A field 
does not occupy a bit when it is without operator or it is a mandatory constant field. 

>>>Presence map是一个位序列,用来表示在FAST消息内部字段是否存在.

>>>当一个字段不带操作符或者它是一个强制的常量字段,那么它不占据任何bit.

15.3.3 Repeating group

In UA1102, there are two repeating groups.  If one or more repeating groups are present, the first 
encoded field is the number of level of the repeating group.  After the number of the repeating group 
is the presence map of first level if the allocated slot for the repeating group is larger than one.  In 
UA1102, those two fields in the repeating group are mandatory and without operator. Thus, no 
presence map slot is allocated.  Consequently, there is no presence map for the entities of repeating 
group. If presence map slots is allocated, each repeating group contains presence map on their own. 

>>>在UA1102内部,有二个Repeating group.如果存在一个或多个Repeating group,则第一个编码字段就是这个

>>>repeating group的level的个数.如果已经为多于一个repeating group分配了槽位,那么在repeating group个数的后面

>>>就是第一个level的presence map.

>>>在UA1102内部,repeating group 里有二个字段是强制的并且不带操作符,所以没有presence map 位被分配.

>>>因此这里没有用于repeating group 实体的presence map.

>>>如果presence map 位是有分配的,那么每一个repeating group 都有包含他们自己的presence map.

 

Here is an example of UA1102 with repeating group:

>>>一个带有repeating group的UA1102例子:

 

Another example of UA1102 without repeating group:

>>>一个不带有repeating group的UA1102例子:

 

 

To decode a FAST message, firstly, the presence map is extracted from the message first.  Then, the 
non-repeating field before the repeating group 1 should be processed.  If repeating group 1 is present, 
the number of repeating entities should be read and each entity should then be processed based on it’s
own presence map. After processed repeating group 1, repeating group 2 should be processed in the 
same way and finally, the non-repeating fields after the repeating group 2 should be  processed.

>>>解析一个FAST消息,第一步,首先从消息中提取presence map;然后,应该先处理在重复组 1 之前的非重复字段.

>>>如果重复组 1存在,则读取重复实体的个数,并且每个实体根据它自己的presence map逐一处理.

>>>在处理完重复组 1之后,重复组 2使用同样的方法进行处理,直到结束,

>>>在重复组 2之后,非重复字段应该被处理.

 

 

 

 SSE Level 2 Vendor Interface Specification(FAST)-15章-FAST Decoder(FAST解析-第一部分)---完

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Fast-RTPS 是一个高性能的实时通信协议,用于在分布式系统中传输实时数据。在 Fast-RTPS 中,每个消息都由头部和数据组成。在本示例中,我们将展示如何解析 Fast-RTPS 消息的头部字段以及 topic name。 首先,我们需要了解 Fast-RTPS 消息头部字段的含义。Fast-RTPS 消息头部包括以下字段: - `protocolId`:Fast-RTPS 协议的版本号。 - `vendorId`:Fast-RTPS 实现的厂商 ID。 - `guidPrefix`:全局唯一标识符的前缀,用于识别 Fast-RTPS 实例。 - `guidEntityId`:Fast-RTPS 实体的唯一标识符。 - `sequenceNumber`:消息的序列号。 - `sourceTimestamp`:消息的时间戳。 - `destinationGuidPrefix`:消息的目标实体的 GUID 前缀。 其中,`guidPrefix` 和 `guidEntityId` 组成了消息的唯一标识符 GUID,用于在 Fast-RTPS 网络中识别消息。 接下来,我们可以通过以下代码示例解析 Fast-RTPS 消息的头部字段和 topic name: ```c++ #include <fastrtps/fastrtps.h> #include <fastrtps/attributes/TopicAttributes.h> void parseFastRTPSMessageHeader(const void* buffer, size_t size) { // Deserialize the message header using Fast-RTPS library eprosima::fastcdr::FastBuffer cdrbuffer(reinterpret_cast<char*>(const_cast<void*>(buffer)), size); eprosima::fastrtps::rtps::CDRMessage_t cdrm(cdrbuffer); eprosima::fastcdr::Cdr cdr_des(cdrm, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); // Parse the fields in the header eprosima::fastrtps::rtps::Header_t header; header.readFromCDRMessage(cdrm); std::cout << "protocolId: " << std::to_string(header.protocolId) << std::endl; std::cout << "vendorId: " << std::to_string(header.vendorId) << std::endl; std::cout << "guidPrefix: " << header.guidPrefix << std::endl; std::cout << "guidEntityId: " << header.guidEntityId << std::endl; std::cout << "sequenceNumber: " << std::to_string(header.sequenceNumber.to64long()) << std::endl; std::cout << "sourceTimestamp: " << header.sourceTimestamp.to_string() << std::endl; std::cout << "destinationGuidPrefix: " << header.destinationGuidPrefix << std::endl; // Deserialize the topic name from the message payload eprosima::fastrtps::TopicAttributes topic_attr; topic_attr.deserialize(&cdr_des); std::cout << "topic name: " << topic_attr.getTopicName() << std::endl; } ``` 在上述示例中,我们使用了 Fast-RTPS 库中的 `Header_t` 类和 `TopicAttributes` 类来解析消息头部和 topic name。首先,我们将消息头部反序列化为 `Header_t` 类型,并读取其中的各个字段。然后,我们从消息负载中反序列化出 `TopicAttributes` 类型,以获取 topic name。 该示例代码可以在 Fast-RTPS 库提供的各种平台和语言中使用。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值