-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsamdatafile.py
92 lines (83 loc) · 2.99 KB
/
samdatafile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
from collections import OrderedDict, namedtuple
from struct import Struct
class CStruct(OrderedDict):
@property
def struct_str(self):
return ''.join(self.values())
board_info_def_v2 = CStruct({
'assembly': 'i',
'firmware_rev': 'i',
'board_rev': 'i',
'board_serial': 'i',
'digital_serial': 'i',
'analog_serial': 'i',
'adc_offset_pa': 'q',
'adc_offset_m_meas': 'd',
'adc_offset_b_meas': 'd',
'adc_offset_m_cond': 'd',
'adc_offset_b_cond': 'd',
'dac_offset_uv': 'q',
'dac_offset_m_cis_meas': 'd',
'dac_offset_b_cis_meas': 'd',
'dac_offset_m_trans_meas': 'd',
'dac_offset_b_trans_meas': 'd',
'dac_offset_m_cis_cond': 'd',
'dac_offset_b_cis_cond': 'd',
'dac_offset_m_trans_cond': 'd',
'dac_offset_b_trans_cond': 'd',
'dac_stepup_meas': 'd',
'dac_stepup_cond': 'd',
'conversion_value': 'Q',
'conversion_accuracy': 'Q',
'transcap_nf': 'Q',
'bessel_cutoff_freq_khz': 'Q',
'rc_time_ns': 'q',
'cap_parasitic_ff': 'q',
'voltage_stepdown': 'd',
'reference_voltage': 'q',
'sense_resistor': 'q',
'cond_resistor': 'q',
'default_cis_positive': 'q',
'default_cis_negative': 'q',
'default_cond_positive': 'q',
'default_cond_negative': 'q',
'dac_resolution_meas': 'q',
'dac_resolution_cond': 'q',
'common_cis': 'B',
'inversed_voltage': 'B',
'cis_channel': 'q',
'emf_offset': 'q',
})
board_info_def_v1 = board_info_def_v2.copy()
board_info_def_v1.pop('cap_parasitic_ff')
board_info_nt_v1 = namedtuple('BoardInfo', board_info_def_v1.keys())
board_info_nt_v2 = namedtuple('BoardInfo', board_info_def_v2.keys())
data_file_header_def = CStruct({
'version': 'L',
'data_size_bytes': 'L',
'assembly': '64s',
'firmware_rev': '64s',
'board_rev': '64s',
'board_serial': '256s',
'digital_serial': '64s',
'analog_serial': '64s',
'repo_manifest': '4096s',
'board_info': '',
})
data_file_header_nt = namedtuple('DataFileHeader', data_file_header_def.keys())
data_block_header_def = CStruct({
'timestamp': 'd',
'sampling_rate': 'q',
'seqno': 'Q',
'overrun': 'Q',
'cis': 'q',
'trans': 'q',
'pore': 'q',
'conditioning': 'B',
'samples_size': 'I',
})
data_block_header_nt = namedtuple('DataBlockHeader', data_block_header_def.keys())
board_info_struct_v1 = Struct(board_info_def_v1.struct_str)
board_info_struct_v2 = Struct(board_info_def_v2.struct_str)
data_block_struct = Struct(data_block_header_def.struct_str)
data_file_struct = Struct(data_file_header_def.struct_str)