152 lines
3.8 KiB
Cython
152 lines
3.8 KiB
Cython
import sys
|
|
include "config.pxi"
|
|
cimport cython
|
|
from .lasp_avtype import AvType
|
|
from libcpp.string cimport string
|
|
from libcpp.vector cimport vector
|
|
from libc.stdlib cimport malloc, free
|
|
from libc.stdio cimport printf, fprintf, stderr
|
|
from libc.string cimport memcpy, memset
|
|
from cpython.ref cimport PyObject,Py_INCREF, Py_DECREF
|
|
|
|
cdef extern from "lasp_cppthread.h" nogil:
|
|
cdef cppclass CPPThread[T,F]:
|
|
CPPThread(F threadfunction, T data)
|
|
void join()
|
|
|
|
void CPPsleep_ms(unsigned int ms)
|
|
void CPPsleep_us(unsigned int us)
|
|
|
|
cdef extern from "lasp_cppqueue.h" nogil:
|
|
cdef cppclass SafeQueue[T]:
|
|
SafeQueue()
|
|
void enqueue(T t)
|
|
T dequeue()
|
|
size_t size() const
|
|
bool empty() const
|
|
|
|
cdef extern from "atomic" namespace "std" nogil:
|
|
cdef cppclass atomic[T]:
|
|
T load()
|
|
void store(T)
|
|
|
|
cdef extern from "lasp_pyarray.h":
|
|
PyObject* data_to_ndarray(void* data,
|
|
int n_rows,int n_cols,
|
|
int typenum,
|
|
bool transfer_ownership,
|
|
bool F_contiguous)
|
|
|
|
ctypedef size_t us
|
|
ctypedef vector[bool] boolvec
|
|
ctypedef vector[double] dvec
|
|
ctypedef vector[us] usvec
|
|
|
|
cdef extern from "lasp_cppdaq.h" nogil:
|
|
|
|
cdef cppclass DaqApi:
|
|
string apiname
|
|
unsigned apicode
|
|
unsigned api_specific_subcode
|
|
|
|
@staticmethod
|
|
vector[DaqApi] getAvailableApis();
|
|
|
|
cdef cppclass DataType:
|
|
string name
|
|
unsigned sw
|
|
bool is_floating
|
|
DataType dtype_fl64
|
|
bool operator==(const DataType&)
|
|
|
|
DataType dtype_fl64
|
|
DataType dtype_fl32
|
|
DataType dtype_int8
|
|
DataType dtype_int16
|
|
DataType dtype_int32
|
|
DataType dtype_invalid
|
|
|
|
cdef cppclass cppDeviceInfo "DeviceInfo":
|
|
DaqApi api
|
|
string device_name
|
|
|
|
int api_specific_devindex
|
|
|
|
vector[DataType] availableDataTypes
|
|
int prefDataTypeIndex
|
|
|
|
vector[double] availableSampleRates
|
|
int prefSampleRateIndex
|
|
|
|
vector[us] availableFramesPerBlock
|
|
unsigned prefFramesPerBlockIndex
|
|
|
|
dvec availableInputRanges
|
|
int prefInputRangeIndex
|
|
|
|
unsigned ninchannels
|
|
unsigned noutchannels
|
|
|
|
string serialize()
|
|
|
|
cppDeviceInfo deserialize(string)
|
|
bool hasInputIEPE
|
|
bool hasInputACCouplingSwitch
|
|
bool hasInputTrigger
|
|
|
|
cdef cppclass cppDaqConfiguration "DaqConfiguration":
|
|
DaqApi api
|
|
string device_name
|
|
|
|
boolvec eninchannels
|
|
boolvec enoutchannels
|
|
|
|
vector[double] inchannel_sensitivities
|
|
vector[string] inchannel_names
|
|
vector[string] inchannel_metadata
|
|
|
|
vector[string] outchannel_names
|
|
vector[double] outchannel_sensitivities
|
|
vector[string] outchannel_metadata
|
|
|
|
us sampleRateIndex
|
|
|
|
us dataTypeIndex
|
|
|
|
us framesPerBlockIndex
|
|
|
|
bool monitorOutput
|
|
vector[us] input_qty_idx
|
|
|
|
boolvec inputIEPEEnabled
|
|
boolvec inputACCouplingMode
|
|
|
|
usvec inputRangeIndices
|
|
|
|
cppDaqConfiguration()
|
|
cppDaqConfiguration(cppDeviceInfo& devinfo)
|
|
|
|
int getHighestInChannel()
|
|
int getHighestOutChannel()
|
|
|
|
int getLowestInChannel()
|
|
int getLowestOutChannel()
|
|
|
|
cdef cppclass cppDaq "Daq":
|
|
void start(SafeQueue[void*] *inQueue,
|
|
SafeQueue[void*] *outQueue) except +
|
|
void stop() except +
|
|
double samplerate()
|
|
us neninchannels(bool include_monitorchannel)
|
|
us nenoutchannels()
|
|
DataType dataType()
|
|
us framesPerBlock()
|
|
bool isRunning()
|
|
bool duplexMode()
|
|
|
|
@staticmethod
|
|
cppDaq* createDaq(cppDeviceInfo&, cppDaqConfiguration&) except +
|
|
|
|
@staticmethod
|
|
vector[cppDeviceInfo] getDeviceInfo() except +
|