Implemented first pointer p_dur

This commit is contained in:
jupfi 2024-02-08 14:56:50 +01:00
parent 4d4161e878
commit f53ad866ff

View file

@ -85,11 +85,14 @@ cdef extern from "limedriver.h":
cdef class PyLimeConfig:
cdef LimeConfig_t* _config
def __cinit__(self):
def __cinit__(self, Npulses):
self._config = <LimeConfig_t*>malloc(sizeof(LimeConfig_t))
if self._config is NULL:
raise MemoryError()
# Set Npulses
self._config.Npulses = Npulses
# Allocate memory for string fields
self._config.file_pattern = <char*>malloc(256)
self._config.file_stamp = <char*>malloc(256)
@ -97,6 +100,9 @@ cdef class PyLimeConfig:
self._config.stamp_start = <char*>malloc(256)
self._config.stamp_end = <char*>malloc(256)
# Allocate memory for arrays with Npulses elements
self._config.p_dur = <double*>malloc(Npulses * sizeof(double))
def __dealloc__(self):
if self._config is not NULL:
@ -234,11 +240,12 @@ cdef class PyLimeConfig:
@property
def p_dur(self):
return self._config.p_dur
return [self._config.p_dur[i] for i in range(self._config.Npulses)]
@p_dur.setter
def p_dur(self, double *value):
self._config.p_dur = <double>value
def p_dur(self, list value):
for i in range(len(value)):
self._config.p_dur[i] = value[i]
# Arrays