@@ -1233,17 +1233,15 @@ def set_data_buffer_for_enabled_channels(
12331233 # Rapid
12341234 if captures > 0 :
12351235 for channel in self .range :
1236- buffer = []
1237- for capture_segment in range (captures ):
1238- buffer .append (self .set_data_buffer (channel , samples , segment + capture_segment , datatype , ratio_mode , action = ACTION .ADD ))
1239- channels_buffer [channel ] = buffer
1236+ np_buffer = self .set_data_buffer_rapid_capture (channel , samples , captures , segment , datatype , ratio_mode , action = ACTION .ADD )
1237+ channels_buffer [channel ] = np_buffer
12401238 # Single
12411239 else :
12421240 for channel in self .range :
12431241 channels_buffer [channel ] = self .set_data_buffer (channel , samples , segment , datatype , ratio_mode , action = ACTION .ADD )
12441242
12451243 return channels_buffer
1246-
1244+
12471245 def set_data_buffer (
12481246 self ,
12491247 channel ,
@@ -1303,6 +1301,69 @@ def set_data_buffer(
13031301 )
13041302 return buffer
13051303
1304+
1305+ def set_data_buffer_rapid_capture (
1306+ self ,
1307+ channel ,
1308+ samples ,
1309+ captures ,
1310+ segment = 0 ,
1311+ datatype = DATA_TYPE .INT16_T ,
1312+ ratio_mode = RATIO_MODE .RAW ,
1313+ action = ACTION .CLEAR_ALL | ACTION .ADD ,
1314+ ) -> np .ndarray | None :
1315+ """
1316+ Allocates and assigns multiple data buffers for rapid block capture on a specified channel.
1317+
1318+ Args:
1319+ channel (int): The channel to associate the buffer with (e.g., CHANNEL.A).
1320+ samples (int): Number of samples to allocate in the buffer.
1321+ captures (int): Number of rapid block captures
1322+ segment (int, optional): Memory segment to start at.
1323+ datatype (DATA_TYPE, optional): C data type for the buffer (e.g., INT16_T).
1324+ ratio_mode (RATIO_MODE, optional): Downsampling mode.
1325+ action (ACTION, optional): Action to apply to the data buffer (e.g., CLEAR_ALL | ADD).
1326+
1327+ Returns:
1328+ np.array | None: The allocated buffer or ``None`` when clearing existing buffers.
1329+
1330+ Raises:
1331+ PicoSDKException: If an unsupported data type is provided.
1332+ """
1333+ if samples == 0 :
1334+ buffer = None
1335+ buf_ptr = None
1336+ else :
1337+ # Map to NumPy dtype
1338+ dtype_map = {
1339+ DATA_TYPE .INT8_T : np .int8 ,
1340+ DATA_TYPE .INT16_T : np .int16 ,
1341+ DATA_TYPE .INT32_T : np .int32 ,
1342+ DATA_TYPE .INT64_T : np .int64 ,
1343+ DATA_TYPE .UINT32_T : np .uint32 ,
1344+ }
1345+
1346+ np_dtype = dtype_map .get (datatype )
1347+ if np_dtype is None :
1348+ raise PicoSDKException ("Invalid datatype selected for buffer" )
1349+
1350+ buffer = np .zeros ((captures , samples ), dtype = np_dtype )
1351+
1352+ for i in range (captures ):
1353+ self ._call_attr_function (
1354+ "SetDataBuffer" ,
1355+ self .handle ,
1356+ channel ,
1357+ npc .as_ctypes (buffer [i ]),
1358+ samples ,
1359+ datatype ,
1360+ segment + i ,
1361+ ratio_mode ,
1362+ action ,
1363+ )
1364+
1365+ return buffer
1366+
13061367 def set_data_buffers (
13071368 self ,
13081369 channel ,
@@ -1313,7 +1374,7 @@ def set_data_buffers(
13131374 action = ACTION .CLEAR_ALL | ACTION .ADD ,
13141375 ) -> tuple [np .ndarray , np .ndarray ]:
13151376 """
1316- Allocate and assign max and min NumPy-backed data buffers for 6000A series .
1377+ Allocate and assign max and min NumPy-backed data buffers.
13171378
13181379 Args:
13191380 channel (int): The channel to associate the buffers with.
@@ -1362,6 +1423,70 @@ def set_data_buffers(
13621423 )
13631424
13641425 return buffer_min , buffer_max
1426+
1427+ def set_data_buffers_rapid_capture (
1428+ self ,
1429+ channel ,
1430+ samples ,
1431+ captures ,
1432+ segment = 0 ,
1433+ datatype = DATA_TYPE .INT16_T ,
1434+ ratio_mode = RATIO_MODE .RAW ,
1435+ action = ACTION .CLEAR_ALL | ACTION .ADD ,
1436+ ) -> np .ndarray | None :
1437+ """
1438+ Allocate and assign max and min NumPy-backed data buffers for rapid block
1439+ capture on a specified channel.
1440+
1441+ Args:
1442+ channel (int): The channel to associate the buffer with (e.g., CHANNEL.A).
1443+ samples (int): Number of samples to allocate in the buffer.
1444+ captures (int): Number of rapid block captures
1445+ segment (int, optional): Memory segment to start at.
1446+ datatype (DATA_TYPE, optional): C data type for the buffer (e.g., INT16_T).
1447+ ratio_mode (RATIO_MODE, optional): Downsampling mode.
1448+ action (ACTION, optional): Action to apply to the data buffer (e.g., CLEAR_ALL | ADD).
1449+
1450+ Returns:
1451+ np.array | None: The allocated buffer or ``None`` when clearing existing buffers.
1452+
1453+ Raises:
1454+ PicoSDKException: If an unsupported data type is provided.
1455+ """
1456+ if samples == 0 :
1457+ buffer = None
1458+ buf_ptr = None
1459+ else :
1460+ # Map to NumPy dtype
1461+ dtype_map = {
1462+ DATA_TYPE .INT8_T : np .int8 ,
1463+ DATA_TYPE .INT16_T : np .int16 ,
1464+ DATA_TYPE .INT32_T : np .int32 ,
1465+ DATA_TYPE .INT64_T : np .int64 ,
1466+ DATA_TYPE .UINT32_T : np .uint32 ,
1467+ }
1468+
1469+ np_dtype = dtype_map .get (datatype )
1470+ if np_dtype is None :
1471+ raise PicoSDKException ("Invalid datatype selected for buffer" )
1472+
1473+ buffer = np .zeros ((captures , samples , 2 ), dtype = np_dtype )
1474+
1475+ for i in range (captures ):
1476+ self ._call_attr_function (
1477+ "SetDataBuffers" ,
1478+ self .handle ,
1479+ channel ,
1480+ npc .as_ctypes (buffer [i ][0 ]),
1481+ npc .as_ctypes (buffer [i ][1 ]),
1482+ samples ,
1483+ datatype ,
1484+ segment + i ,
1485+ ratio_mode ,
1486+ action ,
1487+ )
1488+
1489+ return buffer
13651490
13661491
13671492 # Run functions
0 commit comments