Beispiel #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))
Beispiel #2
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))
Beispiel #3
0
 def data_save(self, instr, name, value):
     if not instr.get_tag(name, 'discard', False) and self.saving!="No buffer":
         if instr.get_tag(name, 'save', False):
             group_name=self.SAVE_GROUP_NAME
         else:
             group_name=self.SETUP_GROUP_NAME
         label=instr.get_tag(name, 'label', name)
         if instr.get_type(name) in (Float, Int, Range, FloatRange, ContainerList, Unicode, Str, float, int, basestring, list, List):
             self.save_file.data_save(data=value, name=label, group_name=group_name)
         elif instr.get_type(name) in (Callable,):
             pass
         elif instr.get_type(name) in (Bool, Enum, bool):
             self.save_file.data_save(data=str(value), name=label, group_name=group_name)
         else:
             log_warning("No save format!")
Beispiel #4
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))
Beispiel #5
0
 def data_save(self, instr, name, value):
     if not instr.get_tag(name, 'discard',
                          False) and self.saving != "No buffer":
         if instr.get_tag(name, 'save', False):
             group_name = self.SAVE_GROUP_NAME
         else:
             group_name = self.SETUP_GROUP_NAME
         label = instr.get_tag(name, 'label', name)
         if instr.get_type(name) in (Float, Int, Range, FloatRange,
                                     ContainerList, Unicode, Str, float,
                                     int, basestring, list, List):
             self.save_file.data_save(data=value,
                                      name=label,
                                      group_name=group_name)
         elif instr.get_type(name) in (Callable, ):
             pass
         elif instr.get_type(name) in (Bool, Enum, bool):
             self.save_file.data_save(data=str(value),
                                      name=label,
                                      group_name=group_name)
         else:
             log_warning("No save format!")
Beispiel #6
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))
Beispiel #7
0
 def read_data_distribute(self):
     log_warning("read_data_distribute not tested!")
     for key, item in self.read_file.data.iteritems():
         target = filter(lambda x: x.name == key, self.agents)
         if target != []:
             for subkey, subitem in item.iteritems():
                 if subkey in target[0].all_params:
                     setattr(target[0], subkey, subitem)
                 else:
                     log_warning("target base does not have target param!")
         else:
             log_warning("target base not found!")
Beispiel #8
0
 def read_data_distribute(self):
     log_warning("read_data_distribute not tested!")
     for key, item in self.read_file.data.iteritems():
         target=filter(lambda x: x.name==key, self.agents)
         if target!=[]:
             for subkey, subitem in item.iteritems():
                 if subkey in target[0].all_params:
                     setattr(target[0], subkey, subitem)
                 else:
                     log_warning("target base does not have target param!")
         else:
             log_warning("target base not found!")
 def do_read(self):
     log_warning("do_read not implemented!")
Beispiel #10
0
# -*- coding: utf-8 -*-
"""
Created on Fri Oct 30 20:44:22 2015

@author: thomasaref
"""

from taref.core.log import log_info, log_warning, make_log_file, remove_log_file

log_info("balh")

log_info("yoy")
log_warning("yay")
make_log_file("/Users/thomasaref/Documents/TA_software/test_code/ztestlog2.txt", mode='w')

log_info(2)
log_info(3)
log_info(4)
log_info(5)
remove_log_file()
#dir_path, divider, log_name=memory_handler.target.baseFilename.rpartition("/")
#print dir_path, divider, log_name #memory_handler.target.baseFilename.split(log_name)
log_info(6)
#make_log_file("/Users/thomasaref/Documents/TA_software/ztestlog2.txt")

log_info(7)
log_info(8)
log_info(9)
log_info(10)
#
#make_log_file("/Users/thomasaref/Documents/TA_software/ztestlog3.txt")
 def do_data_save(self):
     log_warning("do_data_save not overwritten")
 def do_data_save(self):
     log_warning("do_data_save not overwritten")
 def do_read(self):
     log_warning("do_read not implemented!")