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

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

15.6 FAST decode example

>>>FAST解析例子
Here is an example for decoding a fast message of UA1101:

>>>解析UA1101 FAST消息的例子:
 
Template of UA1101: 
<template name="Transaction" id="1101"> 
        <string name="MessageType" id="35"><constant value="UA1101"/></string> 
        <int32 name="DataStatus" id="10121" presence="optional"><default/></int32> 
        <int32 name="TradeIndex" id="10011"><increment /></int32> 
        <string name="SecurityID" id="48" presence="optional"><copy/></string> 
        <int32 name="TradeChannel" id="10115"><copy/></int32> 
        <int32 name="TradeRef" id="10012" presence="optional"><increment /></int32> 
        <int32 name="TradeTime" id="10013" presence="optional"><copy/></int32> 
        <int32 name="TradePrice" id="10014" presence="optional" decimalPlaces="3"><default/></int32> 
        <int32 name="TradeQty" id="10015" presence="optional"><default/></int32> 
        <int64 name="TradeMoney" id="10016" presence="optional" decimalPlaces="3"><default/></int64> 
</template>

After the binary data of UA1101 for FAST are extracted from the tag RawData (96),  
 
The binary data, stop bit in red and the number of byte is in bracket:

>>>在这个二进制数据中: 停止位用红色,在括号里的是字节的序号(便于解释):

1.  Presence map should be come first, the first presence map for this binary data is 101 1111 111 0000. 

>>>Presence map 应该是首先要考虑的,这个二进制数据的第一个Presence map 是 101 1111 111 0000.

2.  The 1st entry of any FAST data is TemplateID (999) and it occupies a presence map bit.  The first 
presence map bit is on, so the template ID should be read from the third byte from the binary data.
Template ID is an integer and mandatory field and the stop bit is found in the fourth byte, 
therefore, the content is 100 0100 1101 which is 1101 in Dec. The corresponding template is 
found by the template ID 1101. 
>>>任何FAST数据的第一个实体是TemplateID(999)并且它占据一个Presence map 位。

>>>第一个Presence map 位是on,所以模板ID应该从这个二进制数据的第三个byte被读取。

>>>模板ID是一个整型值,并且是强制字段,并且在第四个byte找到了停止位,

>>>所以实际内容是100 0100 1101,十进制正好是1101。通过模板ID 1101,就找到了相对应的模板。

3.  The 2nd entry of UA1101 is DataStatus (10121) which is an optional integer field with default 
operator.  It occupied 1 presence map bit and the value of it is off (0).  Therefore, the DataStatus 
is absent in the stream. 
>>>UA1101的第二个实体是 DataStatus (10121),它是使用默认操作符的可选整型字段。

>>>它占据一个presence map位,并且它的值是off(0).所以,DataStatus 在这个流中是不存在的,缺席的。

4.  The 3rd entry of UA1101 is TradeIndex (10011) which is a mandatory integer field with increment
operator.  It occupied 1 presence map bit and it is on (1). Therefore, the value is in the stream and 
1 is decoded from 5th byte. 
>>>UA1101的第三个实体是 TradeIndex (10011),它是一个使用增量操作符的强制整型字段。

>>>它占据一个presence map位,并且它的值是on(1).所以,这个值是在这个流中的,并且从第五个byte解析出了1。

5.  The 4th entry of UA1101 is SecurityID (48) which is an optional ASCII filed with copy operator. 
It occupied 1 presence map bit and it is on (1). Therefore, the value is in the stream and started 
from the 6th byte.  The stop bit is found in the 11th byte. The value is “600000”.  
>>>UA1101的第四个实体是 SecurityID (48),它是一个使用拷贝操作符的可选ASCII字段。

>>>它占据一个presence map位,并且值是on(1).

>>>所以,这个值是在这个流中的,并且开始于第六个byte。停止位在第11个byte找到。这个值是“600000”。

6.  The 5th entry of UA1101 is TradeChannel (10115) which is a mandatory integer field with copy 
operator. It occupied 1 presence map bit and it is on (1). Therefore, the value is in the stream and 
1 is decoded from 12th byte. 
>>>UA1101的第五个实体是 TradeChannel (10115) ,它是一个使用拷贝操作符的强制整型字段。

>>>它占据一个presence map位,并且它的值是on(1).

>>>所以,这个值是在这个流中的,并且从第12个byte解析出了1。


7.  The 6th entry of UA1101 is TradeRef (10012) which is an optional integer field with increment 
operator. It occupied 1 presence map bit and it is on (1). The value is in the stream and 1 is 
decoded from 13th byte. 

>>>UA1101的第六个实体是 TradeRef (10012) ,它是一个使用增量操作符的可选整型字段。

>>>它占据一个presence map位,并且它的值是on(1).

>>>所以,这个值是在这个流中的,并且从第13个byte解析出了1。

8.  The 7th entry of UA1101 is TradeTime (10013) which is an optional integer filed with copy 
operator. It occupied 1 presence map bit and it is on (1). Therefore, the value is in the stream and 
‘93000’ is decoded from 14th byte to 16th byte. 
>>>UA1101的第七个实体是 TradeTime (10013) ,它是一个使用拷贝操作符的可选整型字段。

>>>它占据一个presence map位,并且它的值是on(1).

>>>所以,这个值是在这个流中的,并且从第14个byte到第16个byte解析出了‘93000’。

9.  The 8th entry of UA1101 is TradePrice (10014) which is an optional integer field with default 
operator. It occupied 1 presence map bit and it is on (1). Therefore, the value is in the stream and 
‘3100’ is decoded from 17th byte to 18th byte. The number of decimal places is 3 for TradePrice, 
so the value is 3.100. 
>>>UA1101的第八个实体是 TradePrice (10014),它是一个使用默认操作符的可选整型字段。

>>>它占据一个presence map位,并且它的值是on(1).

>>>所以,这个值是在这个流中的,并且从第17个byte到第18个byte解析出了‘3100’。

>>>TradePrice的小数位数是3,所以这个值应是3.100.

10. The 9th entry of UA1101 is TradeQty (10015) which is an optional integer field with default 
operator. It occupied 1 presence map bit and it is on (1). Therefore, the value is in the stream and 
‘200’ is decoded from 19th byte and 20th byte. 
>>>UA1101的第九个实体是 TradeQty (10015),它是一个使用默认操作符的可选整型字段。

>>>它占据一个presence map位,并且它的值是on(1).

>>>所以,这个值是在这个流中的,并且从第19个byte到第20个byte解析出了‘200‘。

11. The last entry of UA1101 is TradeMoney (10016) which is an optional 64-bit integer field with 
default operator. It occupied 1 presence map bit and it is on (1). Therefore, the value is in the 
stream and ‘620000’ is decoded from 21st to 23rd
 byte. The number of decimal places is 3 for TradeMoney, so the value is 620.000. 
>>>UA1101的最后一个实体是 TradeMoney (10016),它是一个使用默认操作符的可选64位整型字段。

>>>它占据一个presence map位,并且它的值是on(1).

>>>所以,这个值是在这个流中的,并且从第21个byte到第23个byte解析出了‘620000’。

>>>TradeMoney的小数位数是3,所以这个值应是620.000.

12. The final result is 999=1101, 35=UA1101, 10011=1, 48=600000, 10115=1, 10012=1, 
10013=930000, 10014=3.100, 10015=200, 10016=620.000. 
>>>最后的结果是:

>>>999=1101, 35=UA1101, 10011=1, 48=600000, 10115=1, 10012=1, 
>>>10013=930000, 10014=3.100, 10015=200, 10016=620.000. 


13. As there is still some bytes left, do step 1 to 11 again. 
>>>这里仍有一些byte剩余,重复第一步到第十一步。

14. Presence map is 110 1011 from 24th byte. 
>>>从24个byte开始,Presence map 是 110 1011。


15. The 1st entry is TemplateID (999), the value is 1101 in the stream from 25th
 byte to 26th byte.

>>>第一个实体是TemplateID (999),在流中这个值是1101,并且是从第25个byte到第26个byte.


16. The 2nd entry of UA1101 is DataStatus (10121) which is an optional integer field with default 
operator.  It occupied 1 presence map bit and the value of it is on (1).  Therefore, the DataStatus is
in the stream. The value is 1 from 27th byte.

>>>略


17. The 3rd entry of UA1101 is TradeIndex (10011) which is a mandatory integer field with increment 
operator.  It occupied 1 presence map bit and it is off (0). Therefore, the value 2 is referred by the 
increment value, 1, of TradeIndex plus previous value in the dictionary.  
>>>略


18. The 4th entry of UA1101 is SecurityID (48) which is an optional ASCII filed with copy operator. 
It occupied 1 presence map bit and it is on (1). Therefore, the value is in the stream and it is empty 
string from 28th. 
>>>略


19. The 5th entry of UA1101 is TradeChannel (10115) which is a mandatory integer field with copy 
operator. It occupied 1 presence map bit and it is off (0). The trade channel is copied from 
previous value in the dictionary which is 1. 
>>>略


20. The 6th entry of UA1101 is TradeRef (10012) which is an optional integer field with increment 
operator. It occupied 1 presence map bit and it is on (1). The value is in the stream and it is NULL, 
so the TradeRef is absent.  
>>>略


21. The 7th entry of UA1101 is TradeTime (10013) which is an optional integer filed with copy 
operator. It occupied 1 presence map bit and it is on (1). Therefore, the value is in the stream and 
it is NULL which represents TradeRef is absent.  
>>>略


22. The 8th entry of UA1101 is TradePrice (10014) which is an optional integer field with default 
operator. It occupied 1 presence map bit and it is off (0). Therefore, the TradePrice is absent. 
>>>略


23. The 9th entry of UA1101 is TradeQty (10015) which is an optional integer field with default 
operator. It occupied 1 presence map bit and it is off (0). Therefore, the TradePrice is absent. 
>>>略


24. The last entry of UA1101 is TradeMoney (10016) which is an optional 64-bit integer field with 
default operator. It occupied 1 presence map bit and it is off (0). Therefore, the TradePrice is 
absent. 
>>>略


25. The final result is 999=1101, 35=UA1101, 100121=1, 10011=2, 10115=1. 
>>>略


26. No more byte is in the data. The decode process is finished for this binary data.

>>>没有更多的byte。这个二进制数据解码结束。


 

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

发布了87 篇原创文章 · 获赞 64 · 访问量 25万+

猜你喜欢

转载自blog.csdn.net/wqfhenanxc/article/details/86512143