198 lines
6.3 KiB
Python
198 lines
6.3 KiB
Python
#!/usr/bin/env python
|
|
# -*- coding: utf-8 -*-
|
|
# *****************************************************************************
|
|
# This program is free software; you can redistribute it and/or modify it under
|
|
# the terms of the GNU General Public License as published by the Free Software
|
|
# Foundation; either version 2 of the License, or (at your option) any later
|
|
# version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful, but WITHOUT
|
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
# details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License along with
|
|
# this program; if not, write to the Free Software Foundation, Inc.,
|
|
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
#
|
|
# Module authors:
|
|
# Daniel Margineda <daniel.margineda@psi.ch>
|
|
# *****************************************************************************
|
|
"""WAVE FUNCTION LECROY XX: SIGNAL GENERATOR"""
|
|
|
|
from secop.core import Readable, Parameter, Override, Command, FloatRange, TupleOf, \
|
|
HasIodev, StringIO, Done, Attached, IntRange, BoolType, EnumType,StringType, Module
|
|
|
|
|
|
class Channel(Module):
|
|
properties = {
|
|
'channel':Property('choose channel to manipulate',IntRange(1,2)),
|
|
}
|
|
parameters = {
|
|
'freq': Parameter('frequency',
|
|
FloatRange(1e-6,20e6,unit='Hz'),
|
|
poll=True, initwrite=True, default=1000),
|
|
'amp': Parameter('exc_volt_int',
|
|
FloatRange(0.00,5,unit='Vrms'),
|
|
poll=True, readonly=False, initwrite=True, default=0.1),
|
|
'offset': Parameter('offset_volt_int',
|
|
FloatRange(0.00,10,unit='V'),
|
|
'wave': Parameter ('type of wavefunction', StringType=('SINE','SQUARE','RAMP','PULSE','NOISE','ARB','DC'), poll=True, readonly=False, default='SINE'),
|
|
poll=True, readonly=False, initwrite=True, default=0.0),
|
|
'phase': Parameter('signal phase', FloatRange(0,360,unit='deg'), poll=True, readonly=False, initwrite=True, default=0),
|
|
'enabled': Parameter('enable output channel', datatype=StringType('OFF','ON'),readonly=False, default='OFF'),
|
|
'symm': Parameter('wavefunction symmetry', FloatRange(0,100, unit=''), poll=True, readonly =False, default=0),
|
|
|
|
}
|
|
pollerClass = Poller
|
|
|
|
|
|
#update instruments values
|
|
"""
|
|
def read_value(self):
|
|
#response type: self._freq1_arg.value = self.freq(1) C1:BSWV TYPE', 'SINE', 'FRQ', '1000', 'AMP', '3', 'OFST', '3
|
|
# channel 1 status
|
|
reply=self.sendRecv('C1:BSWV?').split(',')
|
|
out=self.sendRecv('C1:OUTP?').split(',') #C1:OUTP ON,LOAD,HZ
|
|
self._freq1_arg.value = reply[3]
|
|
self._amp1_arg.value = reply[5]
|
|
self._off1_arg.value = reply[7]
|
|
self._out1_arg.value = out.split('')[1]
|
|
reply2=self.sendRecv('C2:BSWV?').split(',')
|
|
out2=self.sendRecv('C1:OUTP?').split(',')
|
|
self._freq2_arg.value = reply[3]
|
|
self._amp2_arg.value = reply[5]
|
|
self._off2_arg.value = reply[7]
|
|
self._out2_arg.value = out2.split('')[1]
|
|
return reply, out, reply2, out2
|
|
"""
|
|
|
|
def read_value(self):
|
|
reply = self.sendRecv('C%d:BSWV FRQ?' % self.channel)
|
|
|
|
return reply
|
|
|
|
|
|
def write_target(self,value):
|
|
self.sendRecv('C%d:BSWV FRQ, %g' % (self.channel, str(value)+'Hz'))
|
|
|
|
#signal channel parameter
|
|
|
|
def read_channel(self):
|
|
reply=self.channel()
|
|
return reply
|
|
|
|
def write_channel(self,value):
|
|
|
|
return value
|
|
|
|
#signal wavefunction parameter
|
|
|
|
def read_wave(self):
|
|
ch=str(self.channel)
|
|
reply = self.sendRecv('C'+ch+':BSWV WVTP?')
|
|
|
|
|
|
return reply
|
|
|
|
def write_wave(self,value): #string value
|
|
ch=str(self.channel)
|
|
reply = self.sendRecv('C'+ch+':BSWV WVTP, %g' % value)
|
|
|
|
|
|
return reply
|
|
|
|
"""
|
|
#signal freq parameter
|
|
def read_freq(self):
|
|
ch=str(self.channel)
|
|
reply = self.sendRecv('C'+ch+':BSWV FRQ?')
|
|
|
|
return reply
|
|
|
|
def write_freq(self,value):
|
|
ch=str(self.channel)
|
|
self.sendRecv('C'+ch+':BSWV FRQ, %g' % str(value)+'Hz')
|
|
|
|
return value
|
|
"""
|
|
|
|
#signal amplitude parameter
|
|
def read_amp(self):
|
|
ch=str(self.channel)
|
|
reply = self.sendRecv'C'+ch+':BSWV AMP?')
|
|
|
|
return reply
|
|
|
|
def write_amp(self,value):
|
|
ch=str(self.channel)
|
|
reply = self.sendRecv('C'+ch+':BSWV AMP, %g' % str(value))
|
|
|
|
return value
|
|
|
|
#offset value parameter
|
|
def read_offset(self):
|
|
ch=str(self.channel)
|
|
reply = self.sendRecv('C'+ch+':BSWV OFST?')
|
|
|
|
return reply
|
|
|
|
def write_offset(self,ch,value):
|
|
ch=str(self.channel)
|
|
self.sendRecv('C'+ch+':BSWV OFST %g' % str(value))
|
|
|
|
return value
|
|
|
|
# channel symmetry
|
|
def read_symm(self):
|
|
ch=str(self.channel)
|
|
reply = self.sendRecv('C'+ch+':BSWV SYM?')
|
|
|
|
return reply
|
|
|
|
def write_symm(self,ch,value):
|
|
ch=str(self.channel)
|
|
self.comm('C'+ch+':BSWV SYM %g' % str(value))
|
|
|
|
return value
|
|
|
|
# wave phase parameter
|
|
def read_phase(self):
|
|
ch=str(self.channel)
|
|
reply = self.sendRecv('C'+ch+':BSWV PHSE?')
|
|
|
|
return reply
|
|
|
|
def write_phase(self,value):
|
|
ch=str(self.channel)
|
|
self.sendRecv('C'+ch+':BSWV PHSE %g' % str(value))
|
|
|
|
return value
|
|
|
|
|
|
# dis/enable output channel
|
|
def read_enabled(self):
|
|
ch=str(self.channel)
|
|
reply=self.sendRecv('C'+ch+': OUTP?')
|
|
|
|
return reply
|
|
|
|
def write_enabled(self,ch,value):
|
|
self.sendRecv('C'+ch+': OUTP %g' % str(value))
|
|
|
|
|
|
|
|
# devices are defined as arg less output enable what is defined as arg2
|
|
|
|
class arg(Readable):
|
|
pollerClass = None
|
|
parameters = {
|
|
'value': Override(datatype=FloatRange(unit='')),
|
|
}
|
|
|
|
class arg2(Readable):
|
|
pollerClass = None
|
|
parameters = {
|
|
'value': Override(datatype=BoolType(unit='')),
|
|
}
|