return self.channels[self.sc.channel_name] def create_arb_waveform(self, waveform): """ waveform is a numpy array, with values normalized between 0 and 1. Returns the integer handle of the created waveform. """ waveform = array(waveform) if waveform.dtype != double: waveform = waveform.astype(dtype=double, casting='safe') length = len(waveform) c_array = ctypes.c_double * length c_array = c_array.from_buffer(waveform.data) handle = ctypes.c_int() self.call('CreateArbWaveform', self.visession, length, c_array, ctypes.byref(handle)) return handle.value def get_channel_name(self, ch_index): name = ctypes.create_string_buffer(256) self.call("GetChannelName", self.visession, ch_index, 256, name) return name.value add_repeated_capability(IviCFGen, 'Channel', ChannelFgen) add_props(IviCFGen)
def create_arb_waveform(self, waveform): """ waveform is a numpy array, with values normalized between 0 and 1. Returns the integer handle of the created waveform. """ waveform = array(waveform) if waveform.dtype != double: waveform = waveform.astype(dtype=double, casting='safe') length = len(waveform) c_array = ctypes.c_double*length c_array = c_array.from_buffer(waveform.data) handle = ctypes.c_int() self.call('CreateArbWaveform', self.visession, length, c_array, ctypes.byref(handle)) return handle.value def get_channel_name(self, ch_index): name = ctypes.create_string_buffer(256) self.call("GetChannelName", self.visession, ch_index, 256, name) return name.value add_repeated_capability(IviCFGen, 'Channel', ChannelFgen) add_props(IviCFGen)
return numpy_x, numpy_y def fetch_waveform(self, channel=None): """ Channel must be specified as a string """ if not channel: channel = self.channels.keys()[0] chan = ctypes.c_char_p(channel) py_len = self.horz_record_length length = ctypes.c_int(py_len) arr = ctypes.c_double * py_len data = zeros(py_len, dtype=double) arr = arr.from_buffer_copy(data.data) actual_length = ctypes.c_int() initial_x = ctypes.c_double() x_increment = ctypes.c_double() self.call('FetchWaveform', self.visession, chan, length, arr, ctypes.byref(actual_length), ctypes.byref(initial_x), ctypes.byref(x_increment)) numpy_y = frombuffer(arr, dtype=double) numpy_x = linspace(initial_x.value, x_increment.value * py_len, py_len, False) return numpy_x, numpy_y IviCScope._new_attr('channel_count', IVI_ATTR_CHANNEL_COUNT, 'ViInt32', False, False, True) add_repeated_capability(IviCScope, 'Channel', ChannelScope) add_props(IviCScope)
numpy_y = frombuffer(arr, dtype=double) return numpy_y def read_y_trace(self, trace_name=None, timeout_ms=10000): """ Same as fetch_waveform, but also initializes an acquisition """ if not trace_name: trace_name = list(self.traces.keys())[0] trace_name_c = ctypes.c_char_p(trace_name) trace = self.traces[trace_name] timeout_ms_c = ctypes.c_int32(timeout_ms) py_len = trace.trace_size length = ctypes.c_int(py_len) arr = ctypes.c_double * py_len data = zeros(py_len, dtype=double) arr = arr.from_buffer_copy(data.data) actual_length = ctypes.c_int() initial_x = ctypes.c_double() x_increment = ctypes.c_double() self.call('ReadYTrace', self.visession, trace_name_c, timeout_ms_c, length, ctypes.byref(actual_length), arr) numpy_y = frombuffer(arr, dtype=double) return numpy_y IviCSpecAn._new_attr('trace_count', IVI_CLASS_PUBLIC_ATTR_BASE + 18, 'ViInt32', False, False, False) add_repeated_capability(IviCSpecAn, 'Trace', TraceSpecAn) add_props(IviCSpecAn)
def fetch_waveform(self, channel=None): """ Channel must be specified as a string """ if not channel: channel = self.channels.keys()[0] chan = ctypes.c_char_p(channel) py_len = self.horz_record_length length = ctypes.c_int(py_len) arr = ctypes.c_double*py_len data = zeros(py_len, dtype = double) arr = arr.from_buffer_copy(data.data) actual_length = ctypes.c_int() initial_x = ctypes.c_double() x_increment = ctypes.c_double() self.call('FetchWaveform', self.visession, chan, length, arr, ctypes.byref(actual_length), ctypes.byref(initial_x), ctypes.byref(x_increment)) numpy_y = frombuffer(arr, dtype = double) numpy_x = linspace(initial_x.value, x_increment.value*py_len, py_len, False) return numpy_x, numpy_y IviCScope._new_attr('channel_count', IVI_ATTR_CHANNEL_COUNT,'ViInt32',False,False,True) add_repeated_capability(IviCScope, 'Channel', ChannelScope) add_props(IviCScope)
""" Same as fetch_waveform, but also initializes an acquisition """ if not trace_name: trace_name = self.traces.keys()[0] trace_name_c = ctypes.c_char_p(trace_name) trace = self.traces[trace_name] timeout_ms_c = ctypes.c_int32(timeout_ms) py_len = trace.trace_size length = ctypes.c_int(py_len) arr = ctypes.c_double*py_len data = zeros(py_len, dtype = double) arr = arr.from_buffer_copy(data.data) actual_length = ctypes.c_int() initial_x = ctypes.c_double() x_increment = ctypes.c_double() self.call('ReadYTrace', self.visession, trace_name_c, timeout_ms_c, length, ctypes.byref(actual_length), arr) numpy_y = frombuffer(arr, dtype = double) return numpy_y IviCSpecAn._new_attr('trace_count', IVI_CLASS_PUBLIC_ATTR_BASE + 18L ,'ViInt32',False,False,False) add_repeated_capability(IviCSpecAn, 'Trace', TraceSpecAn) add_props(IviCSpecAn)