-
Notifications
You must be signed in to change notification settings - Fork 0
/
capture.py
62 lines (49 loc) · 2.13 KB
/
capture.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
from ctypes import *
from .wfm import Wfm
class Channel(Structure):
_fields_ = [
('min', c_double),
('max', c_double),
('base', c_double),
('top', c_double),
('midpoint', c_double),
('rising_frequency', c_double),
('rising_period', c_double),
('falling_frequency', c_double),
('falling_period', c_double),
('nrising', c_uint32),
('nfalling', c_uint32),
('_raw_data', POINTER(c_int16)),
('_data', POINTER(c_double)),
('_rising_edges', POINTER(c_uint32)),
('_falling_edges', POINTER(c_uint32)),
('_rising_times', POINTER(c_double)),
('_falling_times', POINTER(c_double)),
]
class Frame(Structure):
_fields_ = [
('_ch', POINTER(Channel)),
]
class Capture(Structure):
_fields_ = [
('nch', c_uint32),
('nframes', c_uint32),
('record_bytes', c_uint32),
('record_len', c_uint32),
('data_len', c_uint32),
('precharge_len', c_uint32),
('postcharge_len', c_uint32),
('t_scale', c_double),
('t_offset', c_double),
('_v_scale', POINTER(c_double)),
('_v_offset', POINTER(c_double)),
('_times', POINTER(c_double)),
('_frames', POINTER(Frame)),
('_wfms', POINTER(POINTER(Wfm))),
('_all_channels', POINTER(Channel)),
('_all_data', POINTER(c_double)),
]
def wfm(self, n: int) -> Wfm:
if n > self.nch:
raise IndexError('list index out of range')
return self._wfms[n].contents