diff --git a/secop_psi/FG_Lecroy_3000.py b/secop_psi/FG_Lecroy_3000.py new file mode 100644 index 0000000..a508559 --- /dev/null +++ b/secop_psi/FG_Lecroy_3000.py @@ -0,0 +1,222 @@ +#!/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 +# ***************************************************************************** +"""WAVE FUNCTION LECROY XX: SIGNAL GENERATOR""" + +from secop.core import Readable, Parameter, Override, Command, FloatRange, TupleOf, \ + HasIodev, StringIO, Done, Attached, IntRange, BoolType, EnumType,StringType + + +#class SR7270(StringIO): + # end_of_line = b'\x00' + +class StringIO(secop.stringio.StringIO): + identification = [('*IDN?', 'WST,WaveStation 3000,.*')] + wait_before = 0.05 +# to update.... +# def do_communicate(self, command): #remove dash from terminator + # reply = StringIO.do_communicate(self, command) + # status = self._conn.readbytes(2, 0.1) # get the 2 status bytes + # print('comm=',command,'reply=',reply,'status=',status) + # return reply + ';%d;%d' % tuple(status) + + + + + + +class channels(HasIodev, Readable): + properties = { + 'out1_arg': Attached(), + 'freq1_arg': Attached(), + 'amp1_arg': Attached(), + 'off1_arg': Attached(), + 'out2_arg': Attached(), + 'freq2_arg': Attached(), + 'amp2_arg': Attached(), + 'off2_arg': Attached(), + } + + parameters = { + 'value': Parameter('channel status',StringType, poll=False,initwrite=False), + 'channel':Parameter('choose channel to manipulate',IntRange(1,2), poll=True,initwrite=False,default=1), + 'freq': Parameter('exc_freq_int', + FloatRange(1e-6,20e6,unit='Hz'), + poll=True, readonly=False, 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 + ioidevClass = StringIO + + +# def comm(self, command): + # reply, status, overload = self.sendRecv(command).split(';') + # if overload != '0': + # self.status = self.Status.WARN, 'overload %s' % overload + # else: + # self.status = self.Status.IDLE, '' + # return reply + + +#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 + +#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='')), + } \ No newline at end of file