Exemplo n.º 1
0
 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))
Exemplo n.º 2
0
    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)
Exemplo n.º 3
0
def new_ask_it(name, form_str, log_prefix=""):
    """get pass function. used as place holder."""
    def new_ask(instr, **kwargs):
        return instr.asker(form_str.format(**kwargs))
    new_ask=log_func(new_ask, name)
    new_ask.log_message=log_prefix+"ASK: {0} {1}: "+name
    return new_ask
Exemplo n.º 4
0
    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))
Exemplo n.º 5
0
def new_write_it(name, form_str, log_prefix=""):
    """send pass function. used as place holder"""
    def new_write(instr, **kwargs):
        instr.writer(form_str.format(**kwargs))
    new_write=log_func(new_write, name)
    new_write.log_message=log_prefix+"WRITE: {0} {1}: "+name
    new_write.run_params.append(name)
    return new_write
Exemplo n.º 6
0
def new_ask_it(name, form_str, log_prefix=""):
    """get pass function. used as place holder."""
    def new_ask(instr, **kwargs):
        return instr.asker(form_str.format(**kwargs))

    new_ask = log_func(new_ask, name)
    new_ask.log_message = log_prefix + "ASK: {0} {1}: " + name
    return new_ask
Exemplo n.º 7
0
def COM_ask_it(aka, name):
    """returns custom GPIB_ask with GPIB_string encoded in GPIB_log object"""
    def COM_ask(instr, **kwargs):
        return getattr(instr, aka) #instr.session.ask(GPIB_string.format(**kwargs))
    COM_ask=log_func(COM_ask, name)
    COM_ask.log_message="COM ASK: {0} {1}: "+name
    COM_ask.run_params.append(name)
    #GPIB_ask.GPIB_string=GPIB_string
    return COM_ask
Exemplo n.º 8
0
def GPIB_write_it(GPIB_string, name):
    """returns custom GPIB_write with GPIB_string encoded in GPIB_log object"""
    def GPIB_write(instr, **kwargs):
        instr.session.write(GPIB_string.format(**kwargs))
    GPIB_write=log_func(GPIB_write, name)
    GPIB_write.log_message="GPIB WRITE: {0} {1}: "+GPIB_string
    GPIB_write.run_params.append(name)
    #func.GPIB_string=GPIB_string
    return GPIB_write
Exemplo n.º 9
0
def GPIB_ask_it(GPIB_string, name):
    """returns custom GPIB_ask with GPIB_string encoded in GPIB_log object"""
    def GPIB_ask(instr, **kwargs):
        return instr.session.ask(GPIB_string.format(**kwargs))
    GPIB_ask=log_func(GPIB_ask, name)
    GPIB_ask.log_message="GPIB ASK: {0} {1}: "+GPIB_string
    GPIB_ask.run_params.append(name)
    #GPIB_ask.GPIB_string=GPIB_string
    return GPIB_ask
Exemplo n.º 10
0
def new_write_it(name, form_str, log_prefix=""):
    """send pass function. used as place holder"""
    def new_write(instr, **kwargs):
        instr.writer(form_str.format(**kwargs))

    new_write = log_func(new_write, name)
    new_write.log_message = log_prefix + "WRITE: {0} {1}: " + name
    new_write.run_params.append(name)
    return new_write
Exemplo n.º 11
0
def COM_write_it(aka, name):
    """returns custom GPIB_write with GPIB_string encoded in GPIB_log object"""
    def COM_write(instr, **kwargs):
        setattr(instr, aka, kwargs[name])
        #instr.session.write(GPIB_string.format(**kwargs))
    COM_write=log_func(COM_write, name)
    COM_write.log_message="COM WRITE: {0} {1}: "+name
    COM_write.run_params.append(name)
    #func.GPIB_string=GPIB_string
    return COM_write
Exemplo n.º 12
0
def COM_write_it(aka, name):
    """returns custom GPIB_write with GPIB_string encoded in GPIB_log object"""
    def COM_write(instr, **kwargs):
        setattr(instr, aka, kwargs[name])
        #instr.session.write(GPIB_string.format(**kwargs))

    COM_write = log_func(COM_write, name)
    COM_write.log_message = "COM WRITE: {0} {1}: " + name
    COM_write.run_params.append(name)
    #func.GPIB_string=GPIB_string
    return COM_write
Exemplo n.º 13
0
def COM_ask_it(aka, name):
    """returns custom GPIB_ask with GPIB_string encoded in GPIB_log object"""
    def COM_ask(instr, **kwargs):
        return getattr(instr,
                       aka)  #instr.session.ask(GPIB_string.format(**kwargs))

    COM_ask = log_func(COM_ask, name)
    COM_ask.log_message = "COM ASK: {0} {1}: " + name
    COM_ask.run_params.append(name)
    #GPIB_ask.GPIB_string=GPIB_string
    return COM_ask
Exemplo n.º 14
0
 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)
Exemplo n.º 15
0
 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))
Exemplo n.º 16
0
    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))