mirror of
https://github.com/nqrduck/LimeDriverBindings.git
synced 2024-11-17 07:51:01 +00:00
At least it's not crashing... run experiment is working (?)
This commit is contained in:
parent
85ecf5f39d
commit
57d9274199
1 changed files with 79 additions and 8 deletions
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
from cpython.mem cimport PyMem_Malloc, PyMem_Free
|
from cpython.mem cimport PyMem_Malloc, PyMem_Free
|
||||||
from libc.stdlib cimport malloc, free
|
from libc.stdlib cimport malloc, free
|
||||||
from libc.string cimport memcpy
|
from libc.string cimport memcpy, strcpy
|
||||||
|
|
||||||
|
|
||||||
from libcpp.string cimport string
|
from libcpp.string cimport string
|
||||||
|
@ -38,6 +38,7 @@ cdef extern from "limedriver.h":
|
||||||
double *p_pha
|
double *p_pha
|
||||||
int *p_phacyc_N
|
int *p_phacyc_N
|
||||||
int *p_phacyc_lev
|
int *p_phacyc_lev
|
||||||
|
|
||||||
double *am_frq
|
double *am_frq
|
||||||
double *am_pha
|
double *am_pha
|
||||||
double *am_depth
|
double *am_depth
|
||||||
|
@ -85,6 +86,8 @@ cdef extern from "limedriver.h":
|
||||||
|
|
||||||
cdef LimeConfig_t initializeLimeConfig(int Npulses)
|
cdef LimeConfig_t initializeLimeConfig(int Npulses)
|
||||||
|
|
||||||
|
cdef int run_experiment_from_LimeCfg(LimeConfig_t config)
|
||||||
|
|
||||||
|
|
||||||
cdef class PyLimeConfig:
|
cdef class PyLimeConfig:
|
||||||
cdef LimeConfig_t* _config
|
cdef LimeConfig_t* _config
|
||||||
|
@ -114,6 +117,7 @@ cdef class PyLimeConfig:
|
||||||
self._config.p_pha = <double*>malloc(Npulses * sizeof(double))
|
self._config.p_pha = <double*>malloc(Npulses * sizeof(double))
|
||||||
self._config.p_phacyc_N = <int*>malloc(Npulses * sizeof(int))
|
self._config.p_phacyc_N = <int*>malloc(Npulses * sizeof(int))
|
||||||
self._config.p_phacyc_lev = <int*>malloc(Npulses * sizeof(int))
|
self._config.p_phacyc_lev = <int*>malloc(Npulses * sizeof(int))
|
||||||
|
|
||||||
self._config.am_frq = <double*>malloc(Npulses * sizeof(double))
|
self._config.am_frq = <double*>malloc(Npulses * sizeof(double))
|
||||||
self._config.am_pha = <double*>malloc(Npulses * sizeof(double))
|
self._config.am_pha = <double*>malloc(Npulses * sizeof(double))
|
||||||
self._config.am_depth = <double*>malloc(Npulses * sizeof(double))
|
self._config.am_depth = <double*>malloc(Npulses * sizeof(double))
|
||||||
|
@ -681,11 +685,11 @@ cdef class PyLimeConfig:
|
||||||
# String properties
|
# String properties
|
||||||
@property
|
@property
|
||||||
def file_pattern(self):
|
def file_pattern(self):
|
||||||
return self._config.file_pattern.decode('utf-8')
|
return self._config.file_pattern.decode()
|
||||||
|
|
||||||
@file_pattern.setter
|
@file_pattern.setter
|
||||||
def file_pattern(self, value):
|
def file_pattern(self, value):
|
||||||
self._config.file_pattern = value.encode('utf-8')
|
self._config.file_pattern = value.encode()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def file_stamp(self):
|
def file_stamp(self):
|
||||||
|
@ -724,10 +728,77 @@ cdef class PyLimeConfig:
|
||||||
cdef LimeConfig_t config = initializeLimeConfig(Npulses)
|
cdef LimeConfig_t config = initializeLimeConfig(Npulses)
|
||||||
|
|
||||||
cdef PyLimeConfig instance = cls.__new__(cls, Npulses)
|
cdef PyLimeConfig instance = cls.__new__(cls, Npulses)
|
||||||
instance._config = <LimeConfig_t*>malloc(sizeof(LimeConfig_t))
|
|
||||||
|
|
||||||
if instance._config is NULL:
|
instance.srate = config.srate
|
||||||
raise MemoryError()
|
instance.frq = config.frq
|
||||||
memcpy(instance._config, &config, sizeof(LimeConfig_t))
|
instance.frq_set = config.frq_set
|
||||||
|
instance.RX_LPF = config.RX_LPF
|
||||||
|
instance.TX_LPF = config.TX_LPF
|
||||||
|
instance.RX_gain = config.RX_gain
|
||||||
|
instance.TX_gain = config.TX_gain
|
||||||
|
instance.TX_IcorrDC = config.TX_IcorrDC
|
||||||
|
instance.TX_QcorrDC = config.TX_QcorrDC
|
||||||
|
instance.TX_IcorrGain = config.TX_IcorrGain
|
||||||
|
instance.TX_QcorrGain = config.TX_QcorrGain
|
||||||
|
instance.TX_IQcorrPhase = config.TX_IQcorrPhase
|
||||||
|
instance.RX_IcorrGain = config.RX_IcorrGain
|
||||||
|
instance.RX_QcorrGain = config.RX_QcorrGain
|
||||||
|
instance.RX_IQcorrPhase = config.RX_IQcorrPhase
|
||||||
|
instance.RX_gain_rback = config.RX_gain_rback
|
||||||
|
instance.TX_gain_rback = config.TX_gain_rback
|
||||||
|
instance.Npulses = config.Npulses
|
||||||
|
instance.averages = config.averages
|
||||||
|
instance.repetitions = config.repetitions
|
||||||
|
instance.pcyc_bef_avg = config.pcyc_bef_avg
|
||||||
|
instance.reptime_secs = config.reptime_secs
|
||||||
|
instance.rectime_secs = config.rectime_secs
|
||||||
|
instance.reptime_smps = config.reptime_smps
|
||||||
|
instance.rectime_smps = config.rectime_smps
|
||||||
|
instance.buffersize = config.buffersize
|
||||||
|
instance.override_init = config.override_init
|
||||||
|
instance.override_save = config.override_save
|
||||||
|
|
||||||
|
instance.file_pattern = config.file_pattern.decode('utf-8')
|
||||||
|
instance.file_stamp = config.file_stamp.decode('utf-8')
|
||||||
|
instance.save_path = config.save_path.decode('utf-8')
|
||||||
|
instance.stamp_start = config.stamp_start.decode('utf-8')
|
||||||
|
instance.stamp_end = config.stamp_end.decode('utf-8')
|
||||||
|
|
||||||
|
|
||||||
|
instance.p_dur = [config.p_dur[i] for i in range(Npulses)]
|
||||||
|
instance.p_dur_smp = [config.p_dur_smp[i] for i in range(Npulses)]
|
||||||
|
instance.p_offs = [config.p_offs[i] for i in range(Npulses)]
|
||||||
|
instance.p_amp = [config.p_amp[i] for i in range(Npulses)]
|
||||||
|
instance.p_frq = [config.p_frq[i] for i in range(Npulses)]
|
||||||
|
instance.p_frq_smp = [config.p_frq_smp[i] for i in range(Npulses)]
|
||||||
|
instance.p_pha = [config.p_pha[i] for i in range(Npulses)]
|
||||||
|
instance.p_phacyc_N = [config.p_phacyc_N[i] for i in range(Npulses)]
|
||||||
|
instance.p_phacyc_lev = [config.p_phacyc_lev[i] for i in range(Npulses)]
|
||||||
|
instance.am_frq = [config.am_frq[i] for i in range(Npulses)]
|
||||||
|
instance.am_pha = [config.am_pha[i] for i in range(Npulses)]
|
||||||
|
instance.am_depth = [config.am_depth[i] for i in range(Npulses)]
|
||||||
|
instance.am_mode = [config.am_mode[i] for i in range(Npulses)]
|
||||||
|
instance.am_frq_smp = [config.am_frq_smp[i] for i in range(Npulses)]
|
||||||
|
instance.fm_frq = [config.fm_frq[i] for i in range(Npulses)]
|
||||||
|
instance.fm_pha = [config.fm_pha[i] for i in range(Npulses)]
|
||||||
|
instance.fm_width = [config.fm_width[i] for i in range(Npulses)]
|
||||||
|
instance.fm_mode = [config.fm_mode[i] for i in range(Npulses)]
|
||||||
|
instance.fm_frq_smp = [config.fm_frq_smp[i] for i in range(Npulses)]
|
||||||
|
instance.p_c0_en = [config.p_c0_en[i] for i in range(Npulses)]
|
||||||
|
instance.p_c1_en = [config.p_c1_en[i] for i in range(Npulses)]
|
||||||
|
instance.p_c2_en = [config.p_c2_en[i] for i in range(Npulses)]
|
||||||
|
instance.p_c3_en = [config.p_c3_en[i] for i in range(Npulses)]
|
||||||
|
|
||||||
|
instance.c0_tim = [config.c0_tim[i] for i in range(4)]
|
||||||
|
instance.c1_tim = [config.c1_tim[i] for i in range(4)]
|
||||||
|
instance.c2_tim = [config.c2_tim[i] for i in range(4)]
|
||||||
|
instance.c3_tim = [config.c3_tim[i] for i in range(4)]
|
||||||
|
instance.c0_synth = [config.c0_synth[i] for i in range(5)]
|
||||||
|
instance.c1_synth = [config.c1_synth[i] for i in range(5)]
|
||||||
|
instance.c2_synth = [config.c2_synth[i] for i in range(5)]
|
||||||
|
instance.c3_synth = [config.c3_synth[i] for i in range(5)]
|
||||||
|
|
||||||
return instance
|
return instance
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
return run_experiment_from_LimeCfg(self._config[0])
|
||||||
|
|
Loading…
Reference in a new issue