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

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章完)

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章