def setup_ranges(self, param, typer): """Autosets low/high tags for Range and FloatRange""" if typer in [Range, FloatRange]: set_tag(self, param, low=self.get_member(param).validate_mode[1][0], high=self.get_member(param).validate_mode[1][1])
def setup_units(self, param, typer): """autosets units using unit_dict""" unit = get_tag(self, param, "unit") if unit is not None: unit_dict = getattr(self, "unit_dict", UNIT_DICT) if unit in unit_dict: set_tag(self, param, unit=unit_dict[unit])
def do_receive(self, name, **kwargs): """performs receive of parameter name i.e. executing associated get_cmd with value checking""" get_cmd=get_tag(self, name, 'get_cmd') if self.status=="Active": if get_cmd!=None: if not hasattr(get_cmd, "pname"): get_cmd=log_func(get_cmd, name) set_tag(self, name, get_cmd=get_cmd) self.receive_log(name) value=get_cmd(self, **kwargs) if isinstance(value, dict): self.nosend_safeset(**value) return value[name] else: self.nosend_safeset(**{name:value}) return value # #safe_log(value) # with self.nosend_context(name): # value=type(getattr(self, name))(value) # value=get_value_check(self, name, value) # safe_setattr(self, name, value) #return value else: print "WARNING: {instr} {name} get_cmd doesn't exist".format(instr=self.name, name=name) else: print "WARNING: Instrument {instr} not active".format(instr=self.name)
def setup_units(self, param, typer): """autosets units using unit_dict""" unit=get_tag(self, param, "unit") if unit is not None: unit_dict=getattr(self, "unit_dict", UNIT_DICT) if unit in unit_dict: set_tag(self, param, unit=unit_dict[unit])
def extra_setup(self, param, typer): super(Instrument, self).extra_setup(param, typer) aka = get_tag(self, param, "aka") if aka != None: do = get_tag(self, param, "do", False) set_tag(self, param, set_cmd=COM_write_it(aka, param), do=do) GPIB_string = get_tag(self, param, 'GPIB_asks') if GPIB_string != None: do = get_tag(self, param, "do", False) set_tag(self, param, get_cmd=COM_ask_it(aka, param), do=do)
def extra_setup(self, param, typer): super(GPIB_Instrument, self).extra_setup(param, typer) GPIB_string=get_tag(self, param, 'GPIB_writes') if GPIB_string!=None: do=get_tag(self, param, "do", False) set_tag(self, param, set_cmd=GPIB_write_it(GPIB_string, param), do=do) GPIB_string=get_tag(self, param, 'GPIB_asks') if GPIB_string!=None: do=get_tag(self, param, "do", False) set_tag(self, param, get_cmd=GPIB_ask_it(GPIB_string, param), do=do)
def extra_setup(self, param, typer): super(Instrument, self).extra_setup(param, typer) aka = get_tag(self, param, "aka") if aka!=None: do=get_tag(self, param, "do", False) set_tag(self, param, set_cmd=COM_write_it(aka, param), do=do) GPIB_string=get_tag(self, param, 'GPIB_asks') if GPIB_string!=None: do=get_tag(self, param, "do", False) set_tag(self, param, get_cmd=COM_ask_it(aka, param), do=do)
def do_send(self, name, value=None, **kwargs): """performs send of parameter name i.e. executing associated set_cmd. If value is specified, parameter is set to value kwargs allows additional parameters required by set_cmd to be fed in.""" if self.status=="Active": set_cmd=get_tag(self, name, 'set_cmd') if set_cmd!=None: if not hasattr(set_cmd, "pname"): set_cmd=log_func(set_cmd, name) set_tag(self, name, set_cmd=set_cmd) with self.nosend_context(name): if value is not None: safe_setattr(self, name, value) self.send_log(name) value=set_cmd(self, **kwargs) else: print "WARNING: {instr} {name} set_cmd doesn't exist".format(instr=self.name, name=name) else: print "WARNING: Instrument {instr} not active".format(instr=self.name)
def send(self, name, value=None, **kwargs): """performs send of parameter name i.e. executing associated set_cmd. If value is specified, parameter is set to value kwargs allows additional parameters required by set_cmd to be fed in.""" set_cmd = get_tag(self, name, 'set_cmd') if self.status == "Active": if set_cmd != None and self.status == 'Active': if not hasattr(set_cmd, "pname"): set_cmd = log_func(set_cmd, name) set_tag(self, name, set_cmd=set_cmd) Instrument.busy = True temp = get_tag(self, name, 'send_now', self.send_now) set_tag(self, name, send_now=False) if value != None: setattr(self, name, value) self.send_log(name) set_cmd(self, **kwargs) set_tag(self, name, send_now=temp) Instrument.busy = False else: log_warning( "WARNING: {instr} {name} set_cmd doesn't exist".format( instr=self.name, name=name)) else: log_warning("WARNING: Instrument {instr} not active".format( instr=self.name))
def receive(self, name, **kwargs): """performs receive of parameter name i.e. executing associated get_cmd with value checking""" get_cmd = get_tag(self, name, 'get_cmd') if self.status == "Active": if get_cmd != None: if not hasattr(get_cmd, "pname"): get_cmd = log_func(get_cmd, name) set_tag(self, name, get_cmd=get_cmd) self.receive_log(name) Instrument.busy = True value = get_cmd(self, **kwargs) log_debug(value) Instrument.busy = False temp = get_tag(self, name, 'send_now', self.send_now) set_tag(self, name, send_now=False) value = get_value_check(self, name, value) setattr(self, name, value) set_tag(self, name, send_now=temp) else: log_warning( "WARNING: {instr} {name} get_cmd doesn't exist".format( instr=self.name, name=name)) else: log_warning("WARNING: Instrument {instr} not active".format( instr=self.name))
def extra_setup(self, param, typer): """extends extra_setup to set response get_cmd to self.reader and autoset set_cmd and get_cmd for params with get_str and set_str""" set_tag(self, "response", get_cmd=self.reader) write_string=get_tag(self, param, 'set_str') if write_string!=None: do=get_tag(self, param, "do", False) set_tag(self, param, set_cmd=new_write_it(param, write_string, self.log_prefix), do=do) ask_string=get_tag(self, param, 'get_str') if ask_string!=None: do=get_tag(self, param, "do", False) set_tag(self, param, get_cmd=new_ask_it(param, ask_string, self.log_prefix), do=do) super(String_Instrument, self).extra_setup(param, typer)
def extra_setup(self, param, typer): """extends extra_setup to set response get_cmd to self.reader and autoset set_cmd and get_cmd for params with get_str and set_str""" set_tag(self, "response", get_cmd=self.reader) write_string = get_tag(self, param, 'set_str') if write_string != None: do = get_tag(self, param, "do", False) set_tag(self, param, set_cmd=new_write_it(param, write_string, self.log_prefix), do=do) ask_string = get_tag(self, param, 'get_str') if ask_string != None: do = get_tag(self, param, "do", False) set_tag(self, param, get_cmd=new_ask_it(param, ask_string, self.log_prefix), do=do) super(String_Instrument, self).extra_setup(param, typer)
def send(self, name, value=None, **kwargs): """performs send of parameter name i.e. executing associated set_cmd. If value is specified, parameter is set to value kwargs allows additional parameters required by set_cmd to be fed in.""" set_cmd=get_tag(self, name, 'set_cmd') if self.status=="Active": if set_cmd!=None and self.status=='Active': if not hasattr(set_cmd, "pname"): set_cmd=log_func(set_cmd, name) set_tag(self, name, set_cmd=set_cmd) Instrument.busy=True temp=get_tag(self, name, 'send_now', self.send_now) set_tag(self, name, send_now=False) if value!=None: setattr(self, name, value) self.send_log(name) set_cmd(self, **kwargs) set_tag(self, name, send_now=temp) Instrument.busy=False else: log_warning("WARNING: {instr} {name} set_cmd doesn't exist".format(instr=self.name, name=name)) else: log_warning("WARNING: Instrument {instr} not active".format(instr=self.name))
def receive(self, name, **kwargs): """performs receive of parameter name i.e. executing associated get_cmd with value checking""" get_cmd=get_tag(self, name, 'get_cmd') if self.status=="Active": if get_cmd!=None: if not hasattr(get_cmd, "pname"): get_cmd=log_func(get_cmd, name) set_tag(self, name, get_cmd=get_cmd) self.receive_log(name) Instrument.busy=True value=get_cmd(self, **kwargs) log_debug(value) Instrument.busy=False temp=get_tag(self, name, 'send_now', self.send_now) set_tag(self, name, send_now=False) value=get_value_check(self, name, value) setattr(self, name, value) set_tag(self, name, send_now=temp) else: log_warning("WARNING: {instr} {name} get_cmd doesn't exist".format(instr=self.name, name=name)) else: log_warning("WARNING: Instrument {instr} not active".format(instr=self.name))
""" from TA88_fundamental import TA88_Read, TA88_Fund, qdt from atom.api import Typed, Unicode, Float, observe, FloatRange from h5py import File from taref.core.universal import Array from numpy import float64, linspace, shape, reshape, squeeze, mean, angle, absolute, array from taref.core.atom_extension import tag_Property, set_tag, private_property from taref.physics.units import dB from taref.plotter.fig_format import Plotter from taref.core.shower import shower from taref.core.agent import Operative from scipy.optimize import leastsq # Levenberg-Marquadt Algorithm # set_tag(qdt, "flux_factor", log=False) class Fitter(Operative): base_name="fitter" class Fitter1(Fitter): offset=FloatRange(-1.0, 1.0, -0.036).tag(tracking=True) flux_factor=FloatRange(0.01, 1.0, qdt.flux_factor).tag(tracking=True) @tag_Property(plot=True, private=True) def flux_parabola(self): return qdt.call_func("flux_parabola", voltage=a.yoko, offset=self.offset, flux_factor=self.flux_factor, Ec=qdt.Ec) @observe("offset", "flux_factor") def update_plot(self, change): if change["type"]=="update":
def __init__(self, **kwargs): super(Yoko, self).__init__(**kwargs) set_tag(self, "identify", do=False)
@author: thomasaref """ from TA45_fundamental import TA45_Read, TA45_Fund, qdt from atom.api import Typed, Unicode, Float, observe, FloatRange from h5py import File from taref.core.universal import Array from numpy import float64, linspace, shape, reshape, squeeze, mean, angle, absolute, array from taref.core.atom_extension import tag_Property, set_tag, private_property from taref.physics.units import dB from taref.plotter.fig_format import Plotter from taref.core.shower import shower from taref.core.agent import Operative from scipy.optimize import leastsq # Levenberg-Marquadt Algorithm # set_tag(qdt, "flux_factor", log=False) class Fitter(Operative): base_name = "fitter" class Fitter1(Fitter): offset = FloatRange(-1.0, 1.0, -0.036).tag(tracking=True) flux_factor = FloatRange(0.01, 1.0, qdt.flux_factor).tag(tracking=True) @tag_Property(plot=True, private=True) def flux_parabola(self): return qdt.call_func("flux_parabola", voltage=a.yoko, offset=self.offset,
print log_info("test code:") print """class Test(Atom): a=Int().tag(tg=4) b=Float() t=Test()""" class Test(Atom): a=Int().tag(tg=4) b=Float() t=Test() print print 'set_tag(t, "a", z="p")' set_tag(t, "a", z="p") print 'print t.get_member("a").metadata' print t.get_member("a").metadata print 'print t.get_member("b").metadata' print t.get_member("b").metadata print print 'set_all_tags(t, z=True)' set_all_tags(t, z=True) print 'print t.get_member("a").metadata' print t.get_member("a").metadata print 'print t.get_member("b").metadata' print t.get_member("b").metadata print print 'get_tag(t, "a", "tg", "five")' print get_tag(t, "a", "tg", "five") print 'get_tag(t, "b", "tg", "five")'
def __init__(self, **kwargs): super(Yoko, self).__init__(**kwargs) set_tag(self, "identify", do=False)
log_info("test code:") print """class Test(Atom): a=Int().tag(tg=4) b=Float() t=Test()""" class Test(Atom): a = Int().tag(tg=4) b = Float() t = Test() print print 'set_tag(t, "a", z="p")' set_tag(t, "a", z="p") print 'print t.get_member("a").metadata' print t.get_member("a").metadata print 'print t.get_member("b").metadata' print t.get_member("b").metadata print print 'set_all_tags(t, z=True)' set_all_tags(t, z=True) print 'print t.get_member("a").metadata' print t.get_member("a").metadata print 'print t.get_member("b").metadata' print t.get_member("b").metadata print print 'get_tag(t, "a", "tg", "five")' print get_tag(t, "a", "tg", "five") print 'get_tag(t, "b", "tg", "five")'
def setup_ranges(self, param, typer): """Autosets low/high tags for Range and FloatRange""" if typer in [Range, FloatRange]: set_tag(self, param, low=self.get_member(param).validate_mode[1][0], high=self.get_member(param).validate_mode[1][1])