Skip to content
Snippets Groups Projects
Commit 05a0a857 authored by Samuel Werner Hermann Möller's avatar Samuel Werner Hermann Möller
Browse files

Mehr Einstellmöglichkeiten der IMportierten Daten

parent 09e2dcfc
Branches
Tags
1 merge request!9Deca dac3
# Instrument driver configuration file.
[General settings]
# The name is shown in all the configuration windows
name: Signal_Import_by_File
# The version string should be updated whenever changes are made to this config file
version: 1.0
# Name of folder containing the code defining a custom driver. Do not define this item
# or leave it blank for any standard driver based on the built-in VISA interface.
driver_path: Signal_Import_by_File
# Define that the driver is a Signal Generator
signal_generator: True
# Define quantities in sections. This list is a selection of allowed keywords,
# see the manual for a full list of options
# datatype: The datatype should be one of DOUBLE, BOOLEAN, COMBO,
# STRING, COMPLEX, VECTOR, VECTOR_COMPLEX, PATH or BUTTON.
# unit: Quantity unit
# set_cmd: Command used to send data to the instrument. Put <*> where the value should appear.
# get_cmd: Command used to get the data from the instrument. Default is set_cmd?
# def_value: Default value
# low_lim: Lowest allowable value. Defaults to -INF
# high_lim: Highest allowable values. Defaults to +INF
# combo_def_1: First option in a pull-down combo box. Only used when datatype=COMBO
# combo_def_2: Second option in a pull-down combo box. Only used when datatype=COMBO
# ...
# combo_def_n: nth option in a pull-down combo box. Only used when datatype=COMBO
# state_quant: Quantity that determines this control's visibility
# state_value_1: Value of "state_quant" for which the control is visible
# state_value_2: Value of "state_quant" for which the control is visible
# ...
# state_value_n: Value of "state_quant" for which the control is visible
# permission: Sets read/writability, options are BOTH, READ, WRITE or NONE. Default is BOTH
# group: Name of the group where the control belongs.
# section: Name of the section where the control belongs.
[Datapath]
datatype: PATH
def_value: C:\Users\
[Skip Header]
datatype: DOUBLE
def_value: 1
[Skip Footer]
datatype: DOUBLE
def_value: 0
[Delimiter]
datatype: STRING
def_value: ,
[Add noise]
datatype: BOOLEAN
def_value: False
[Scale Factor]
datatype: DOUBLE
def_value: 1
[CutWaveform]
datatype: BOOLEAN
def_value: TRUE
[Max Values]
datatype: DOUBLE
unit: V
def_value:0.5
low_lim = 0
high_lim = 0.5
state_quant: CutWaveform
state_value_1: 1
[Min Values]
datatype: DOUBLE
unit: V
def_value: -0.5
low_lim = -0.5
high_lim = 0
state_quant: CutWaveform
state_value_1: 1
[Noise amplitude]
datatype: DOUBLE
unit: V
def_value: 0.1
state_quant: Add noise
state_value_1: True
[Signal]
datatype: VECTOR
permission: READ
x_name: Time
x_unit: s
# -*- coding: utf-8 -*-
"""
Created on Thu Aug 30 18:36:00 2018
@author: tebbe
"""
import InstrumentDriver
import numpy as np
class Driver(InstrumentDriver.InstrumentWorker):
""" This class implements a simple signal generator driver"""
def performOpen(self, options = {}):
"""Perform the operation of opening the instrument connection"""
pass
def performClose(self, bError = False, options = {}):
"""Perform the close instrument connection operation"""
pass
def performSetValue(self, quant, value, sweepRate = 0.0, options = {}):
"""Perform the Set Value instrument operation. This function should
return the actual value set by the instrument"""
# just return the value
return value
def performGetValue(self, quant, options = {}):
"""Perform the Get Value instrument operation"""
# proceed depending on quantity
if quant.name == 'Signal':
# if asking for signal, start with getting values of other controls
DATAPATH = self.getValue('Datapath')
skiph = int(self.getValue('Skip Header'))
skipf = int(self.getValue('Skip Footer'))
delim = self.getValue('Delimiter')
if not len(delim):
delim = ' '
scale = float(self.getValue('Scale Factor'))
max_signal = float(self.getValue('Max Values'))
min_signal = float(self.getValue('Min Values'))
self.log(max_signal)
self.log(min_signal)
data = np.genfromtxt(DATAPATH, delimiter = delim, skip_header = skiph, skip_footer = skipf)
time = data[:,0]
signal = data[:,1] * scale
add_noise = self.getValue('Add noise')
if add_noise:
noise_amp = self.getValue('Noise amplitude') * scale
signal += noise_amp * np.random.randn(len(signal))
if int(self.getValue('CutWaveform')):
for i,j in enumerate(signal):
self.log(signal[i])
if signal[i] > max_signal:
signal[i] = max_signal
if signal[i] < min_signal:
signal[i] = min_signal
# create trace object that contains timing info
self.log(signal, level = 30)
self.log(time, level = 30)
trace = quant.getTraceDict(signal,time)
# finally, return the trace object
return trace
else:
# for other quantities, just return current value of control
return quant.getValue()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment