finished ctython interfae
This commit is contained in:
parent
97d26f57da
commit
5333441336
19
example.py
19
example.py
@ -1,13 +1,22 @@
|
|||||||
import tdm_ripper
|
import tdm_ripper
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
tdmpath = b"samples/SineData.tdm"
|
tdmpath = b"samples/SineData.tdm"
|
||||||
tdxpath = b"samples/SineData.tdx"
|
tdxpath = b"samples/SineData.tdx"
|
||||||
|
|
||||||
rippobj = tdm_ripper.pytdmripper(tdmpath)
|
# create instance of ripper class
|
||||||
|
RP = tdm_ripper.pytdmripper(tdmpath)
|
||||||
|
|
||||||
rippobj.show_channels()
|
# provide overview of available channels
|
||||||
|
RP.show_channels()
|
||||||
|
|
||||||
print(rippobj.num_channels())
|
print(RP.num_channels())
|
||||||
print(rippobj.num_groups())
|
print(RP.num_groups())
|
||||||
|
|
||||||
rippobj.print_channel(1,b"SineData_extract.dat")
|
# print particular channel to file
|
||||||
|
RP.print_channel(1,b"SineData_extract.dat")
|
||||||
|
|
||||||
|
# extract channel and return it to numpy array
|
||||||
|
chann = RP.get_channel(1)
|
||||||
|
|
||||||
|
print(dim(chann))
|
||||||
|
@ -5,8 +5,8 @@ from tdm_ripper cimport tdm_ripper
|
|||||||
|
|
||||||
cdef class pytdmripper:
|
cdef class pytdmripper:
|
||||||
|
|
||||||
# use pointer since there's no nullary constructor
|
# pointer to C++ instance (since there's no nullary constructor)
|
||||||
cdef tdm_ripper*cripp
|
cdef tdm_ripper *cripp
|
||||||
|
|
||||||
def __cinit__(self, string tdmfile):
|
def __cinit__(self, string tdmfile):
|
||||||
self.cripp = new tdm_ripper(tdmfile)
|
self.cripp = new tdm_ripper(tdmfile)
|
||||||
@ -23,5 +23,8 @@ cdef class pytdmripper:
|
|||||||
def num_groups(self):
|
def num_groups(self):
|
||||||
return self.cripp.num_groups()
|
return self.cripp.num_groups()
|
||||||
|
|
||||||
def print_channel(self,int channelid, const char* filename):
|
def get_channel(self, int channelid):
|
||||||
|
return self.cripp.get_channel(channelid)
|
||||||
|
|
||||||
|
def print_channel(self, int channelid, const char* filename):
|
||||||
self.cripp.print_channel(channelid,filename)
|
self.cripp.print_channel(channelid,filename)
|
||||||
|
@ -11,4 +11,5 @@ cdef extern from "tdm_ripper.hpp":
|
|||||||
void show_channels()
|
void show_channels()
|
||||||
int num_channels()
|
int num_channels()
|
||||||
int num_groups()
|
int num_groups()
|
||||||
|
vector[double] get_channel(int)
|
||||||
void print_channel(int,const char*)
|
void print_channel(int,const char*)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user