Skip to content

Commit c6a93f2

Browse files
author
neil.hamilton
committed
Add streaming callback function to ps5000a.py
1 parent aa571a1 commit c6a93f2

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

picosdk/ps5000a.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"""
99

1010
from ctypes import *
11+
from picosdk.ctypes_wrapper import C_CALLBACK_FUNCTION_FACTORY
1112
from picosdk.library import Library
1213
from picosdk.constants import make_enum
1314

@@ -161,6 +162,25 @@ def _define_conditionsInfo():
161162
"PS5000A_CONDITION_MAX"
162163
])
163164

165+
ps5000a.PS5000A_RATIO_MODE = {
166+
'PS5000A_RATIO_MODE_NONE': 0,
167+
'PS5000A_RATIO_MODE_AGGREGATE': 1,
168+
'PS5000A_RATIO_MODE_DECIMATE': 2,
169+
'PS5000A_RATIO_MODE_AVERAGE': 4,
170+
}
171+
172+
ps5000a.PS5000A_TIME_UNITS = make_enum([
173+
'PS5000A_FS',
174+
'PS5000A_PS',
175+
'PS5000A_NS',
176+
'PS5000A_US',
177+
'PS5000A_MS',
178+
'PS5000A_S',
179+
'PS5000A_MAX_TIME_UNITS',
180+
])
181+
182+
ps5000a.PICO_RATIO_MODE = {k[19:]: v for k, v in ps5000a.PS5000A_RATIO_MODE.items()}
183+
164184

165185
class PS5000A_DIGITAL_CHANNEL_DIRECTIONS(Structure):
166186
_pack_ = 1
@@ -619,6 +639,32 @@ class PS5000A_CONDITION (Structure):
619639
); """
620640
ps5000a.make_symbol("_GetStreamingLatestValues", "ps5000aGetStreamingLatestValues", c_uint32,
621641
[c_int16, c_void_p, c_void_p], doc)
642+
643+
doc = """ void *ps5000aStreamingReady
644+
(
645+
int16_t handle,
646+
int32_t noOfSamples,
647+
uint32_t startIndex,
648+
int16_t overflow,
649+
uint32_t triggerAt,
650+
int16_t triggered,
651+
int16_t autoStop,
652+
void *pParameter
653+
);
654+
define a python function which accepts the correct arguments, and pass it to the constructor of this type.
655+
"""
656+
657+
ps5000a.StreamingReadyType = C_CALLBACK_FUNCTION_FACTORY(None,
658+
c_int16,
659+
c_int32,
660+
c_uint32,
661+
c_int16,
662+
c_uint32,
663+
c_int16,
664+
c_int16,
665+
c_void_p)
666+
667+
ps5000a.StreamingReadyType.__doc__ = doc
622668

623669
# TODO sort out how to make a callback for a C function in ctypes!
624670
# doc = """ void *ps5000aStreamingReady

0 commit comments

Comments
 (0)