2
2
from typing import List , Union
3
3
4
4
from radiacode .bytes_buffer import BytesBuffer
5
- from radiacode .types import CountRate , DoseRate , DoseRateDB , Event , RareData
5
+ from radiacode .types import DoseRateDB , Event , RareData , RawData , RealTimeData
6
6
7
7
8
8
def decode_VS_DATA_BUF (
9
9
br : BytesBuffer ,
10
10
base_time : datetime .datetime ,
11
- ) -> List [Union [CountRate , DoseRate , DoseRateDB , RareData , Event ]]:
12
- ret : List [Union [CountRate , DoseRate , DoseRateDB , RareData , Event ]] = []
11
+ ) -> List [Union [RealTimeData , DoseRateDB , RareData , RawData , Event ]]:
12
+ ret : List [Union [RealTimeData , DoseRateDB , RareData , RawData , Event ]] = []
13
13
next_seq = None
14
14
while br .size () > 0 :
15
15
seq , eid , gid , ts_offset = br .unpack ('<BBBi' )
@@ -18,24 +18,26 @@ def decode_VS_DATA_BUF(
18
18
raise Exception (f'seq jump, expect:{ next_seq } , got:{ seq } ' )
19
19
20
20
next_seq = (seq + 1 ) % 256
21
- if eid == 0 and gid == 0 : # GRP_CountRate
22
- count_rate , count_rate_err , flags = br .unpack ('<fHH ' )
21
+ if eid == 0 and gid == 0 : # GRP_RealTimeData
22
+ count_rate , dose_rate , count_rate_err , dose_rate_err , flags , rt_flags = br .unpack ('<ffHHHB ' )
23
23
ret .append (
24
- CountRate (
24
+ RealTimeData (
25
25
dt = dt ,
26
26
count_rate = count_rate ,
27
- count_rate_err = count_rate_err * 0.1 ,
27
+ count_rate_err = count_rate_err / 10 ,
28
+ dose_rate = dose_rate ,
29
+ dose_rate_err = dose_rate_err / 10 ,
28
30
flags = flags ,
31
+ real_time_flags = rt_flags ,
29
32
)
30
33
)
31
- elif eid == 0 and gid == 1 : # GRP_DoseRate
32
- dose_rate , dose_rate_err , flags = br .unpack ('<fHH ' )
34
+ elif eid == 0 and gid == 1 : # GRP_RawData
35
+ count_rate , dose_rate = br .unpack ('<ff ' )
33
36
ret .append (
34
- DoseRate (
37
+ RawData (
35
38
dt = dt ,
39
+ count_rate = count_rate ,
36
40
dose_rate = dose_rate ,
37
- dose_rate_err = dose_rate_err * 0.1 ,
38
- flags = flags ,
39
41
)
40
42
)
41
43
elif eid == 0 and gid == 2 : # GRP_DoseRateDB
@@ -46,7 +48,7 @@ def decode_VS_DATA_BUF(
46
48
count = count ,
47
49
count_rate = count_rate ,
48
50
dose_rate = dose_rate ,
49
- dose_rate_err = dose_rate_err * 0.1 ,
51
+ dose_rate_err = dose_rate_err / 10 ,
50
52
flags = flags ,
51
53
)
52
54
)
@@ -57,8 +59,8 @@ def decode_VS_DATA_BUF(
57
59
dt = dt ,
58
60
duration = duration ,
59
61
dose = dose ,
60
- temperature = temperature * 0.01 - 20 ,
61
- charge_level = charge_level * 0.01 ,
62
+ temperature = ( temperature - 2000 ) / 100 ,
63
+ charge_level = charge_level / 100 ,
62
64
flags = flags ,
63
65
)
64
66
)
@@ -85,6 +87,9 @@ def decode_VS_DATA_BUF(
85
87
count_rate , flags = br .unpack ('<fH' )
86
88
elif eid == 0 and gid == 9 : # GRP_RawDoseRate
87
89
dose_rate , flags = br .unpack ('<fH' )
90
+ elif eid == 1 and gid == 1 : # ???
91
+ samples_num , smpl_time_ms = br .unpack ('<HI' )
92
+ br .unpack (f'<{ 8 * samples_num } x' ) # skip
88
93
elif eid == 1 and gid == 2 :
89
94
samples_num , smpl_time_ms = br .unpack ('<HI' )
90
95
br .unpack (f'<{ 16 * samples_num } x' ) # skip
0 commit comments