Пример #1
0
    def __init__(self):
        self.backplane = Backplane()

        self.power_good = []
        for i in range(8):
            self.power_good.append(PowerGood(self.backplane, i))

        self.current_voltage = []
        for i in range(15):
            self.current_voltage.append(CurrentVoltage(self.backplane, i))

        self.resistors = []
        for i in range(8):
            self.resistors.append(Resistor(self.backplane, i))

        pw_good = {str(i+1) : pg.get for i,pg in enumerate(self.power_good)}
        pw_good.update({"list" : True, "description" : "Power good inputs from the MCP23008"})

        self.param_tree = MetadataTree({
            "name" : "QEM Backplane",
            "description" : "Testing information for the backplane on QEM.",
            "clock" : (self.backplane.get_clock_frequency, self.backplane.set_clock_frequency, {"units" : "MHz", "description" : "Clock frequency for the SI570 oscillator", "min" : 10, "max":945}),
            "sensors_enabled":(self.backplane.get_sensors_enable, self.backplane.set_sensors_enable, {"name" : "sensors updating"}),
            "update_required" : (self.backplane.get_update, self.backplane.set_update,{"name" : "Update Once"}),
            "non_volatile" : (self.backplane.get_resistor_non_volatile, self.backplane.set_resistor_non_volatile, {"name": "Set Defaults", "description":"When setting resistor values setermines if the new value should be set as a temporary value or as the new default"}), 
            "psu_enabled" : (self.backplane.get_psu_enable, self.backplane.set_psu_enable, {"name" : "PSU Enabled"}),
#            "capture_enabled" : (self.backplane.get_capture_enable, self.backplane.set_capture_enable, {"name" : "Capture Data"}),
            "power_good" : pw_good,
            "current_voltage" : [cv.param_tree for cv in self.current_voltage],
            "resistors" : [r.param_tree for r in self.resistors],
            "reset" : (False, self.backplane.set_reset,{"name" : "Reset Server"}),
            "temperature" : (self.backplane.get_temp,{"units": "C", "dp":1}),
            "temperature_far" : (self.backplane.get_temp_far,{"units": "C", "dp":1}),
            "fpga_reset" : (False, self.backplane.set_reset_fpga,{"name": "Reset FPGA"}),
        })
    def setup_class(cls):

        cls.basic_dict = {
            "int" : 0,
            "float" : 3.14,
            "string" : "hello world",
            "bool" : True
        }
        cls.basic_tree = MetadataTree(cls.basic_dict)

        cls.nested_dict = cls.basic_dict.copy()
        cls.nested_dict["dict"] = {"0" : 0, "1" : 1}
        cls.nested_tree = MetadataTree(cls.nested_dict)

        cls.list_dict = {
            "even" : [2,4,6,8, 10],
            "prime" : [2,3,5,7,11]
        }
        cls.list_tree = MetadataTree(cls.list_dict)

        cls.accessor_dict = {
            "value" : (0,),
            "metadata_value0" : (0, {"writeable" : False}),
            "metadata_value1" : ("not running", {"available" : ["not running", "pending", "running", "completed"]}),
            "getter" : (cls.getA),
            "getter_setter" : (cls.getB, cls.setB),
            "getter_metadata" : (cls.getC, {"units" : "s"}),
            "getter_setter_metadata" : (cls.getB, cls.setB, {"min" : 0, "max" : 100})
        }
        cls.accessor_tree = MetadataTree(cls.accessor_dict)
Пример #3
0
    def __init__(self):

        #        self.clock_tester = oscillator_test()
        self.volt_tester = voltage_test()
        self.param_tree = MetadataTree({
            "name":
            "I2C Component Tests",
            "description":
            "Testing information for the backplane on QEM.",
            #            "clock" : (None, self.clock_tester.clockTest),
            #            "resistors" : [r.param_tree for r in self.resistors],
            "voltage": (" ", self.volt_tester.voltageTest),
            #            "current" : [cv.param_tree for cv in self.current_voltage],
        })
Пример #4
0
class BackplaneData(object):
    def __init__(self):
        self.backplane = Backplane()

        self.power_good = []
        for i in range(8):
            self.power_good.append(PowerGood(self.backplane, i))

        self.current_voltage = []
        for i in range(13):
            self.current_voltage.append(CurrentVoltage(self.backplane, i))

        self.resistors = []
        for i in range(7):
            self.resistors.append(Resistor(self.backplane, i))

        pw_good = {str(i): pg.get for i, pg in enumerate(self.power_good)}
        pw_good.update({
            "list": True,
            "description": "Power good inputs from the MCP23008"
        })

        self.param_tree = MetadataTree({
            "name":
            "QEM Backplane",
            "description":
            "Testing information for the backplane on QEM.",
            "clock": (self.backplane.get_clock_frequency,
                      self.backplane.set_clock_frequency, {
                          "units": "MHz",
                          "description":
                          "Clock frequency for the SI570 oscillator"
                      }),
            "psu_enabled":
            (self.backplane.get_psu_enable, self.backplane.set_psu_enable, {
                "name": "PSU Enabled"
            }),
            "power_good":
            pw_good,
            "current_voltage": [cv.param_tree for cv in self.current_voltage],
            "resistors": [r.param_tree for r in self.resistors]
        })

    def get(self, path, metadata):
        return self.param_tree.get(path, metadata=metadata)

    def set(self, path, value):
        self.param_tree.set(path, value)
Пример #5
0
    def __init__(self, backplane, i):
        self.index = i
        self.backplane = backplane

        self.param_tree = MetadataTree({
            "name" : self.backplane.get_resistor_name(self.index),
            "voltage_current" : (self.get, self.set, {"units" : self.backplane.get_resistor_units(self.index), "min" : self.backplane.get_resistor_min(self.index), "max" : self.backplane.get_resistor_max(self.index)}),
            "register_value" : (self.raw_get,self.raw_set,{"dp" : 0, "min" : 0, "max" : self.backplane.get_register_max(self.index)}),
       })
Пример #6
0
    def __init__(self, backplane, i):
        self.index = i
        self.backplane = backplane

        self.param_tree = MetadataTree({
            "name" : self.backplane.get_adc_name(i),
            "current" : (self.get_current, {"units" : "mA"}),
            "voltage" : (self.get_voltage, {"units" : "V", "dp":3}),
            "voltage_register" : (self.get_voltage_raw,{"dp" : 0}),
            "current_register" : (self.get_current_raw,{"dp" : 0}),
        })
Пример #7
0
    def __init__(self, backplane, i):
        self.index = i
        self.backplane = backplane

        self.param_tree = MetadataTree({
            "name":
            self.backplane.get_resistor_name(i),
            "value": (self.get, self.set, {
                "units": self.backplane.get_resistor_units(self.index)
            })
        })
Пример #8
0
class Tester(object):
    def __init__(self):

        #        self.clock_tester = oscillator_test()
        self.volt_tester = voltage_test()
        self.param_tree = MetadataTree({
            "name":
            "I2C Component Tests",
            "description":
            "Testing information for the backplane on QEM.",
            #            "clock" : (None, self.clock_tester.clockTest),
            #            "resistors" : [r.param_tree for r in self.resistors],
            "voltage": (" ", self.volt_tester.voltageTest),
            #            "current" : [cv.param_tree for cv in self.current_voltage],
        })

    def get(self, path, metadata):
        return self.param_tree.get(path)

    def set(self, path, value):
        self.param_tree.set(path, value)
Пример #9
0
    def __init__(self, asic_interface, i):
        """Initialises the DAC instance
        This creates a parameter tree for the resistor which contains the voltage read for the resistance as it stands, with name, units, minimum and maximum resistance stored as metadata, linking in the methods to access the data
        :param asic_interface: the instance of the asic_interface that handles communication with the ASIC
        :param i: The unique number to associate with this supply
        """
        self.index = i
        self.asic_interface = asic_interface

        self.param_tree = MetadataTree({
            "value": (self.get, self.set),
        })
Пример #10
0
    def __init__(self, backplane, i):
        self.index = i
        self.backplane = backplane

        self.param_tree = MetadataTree({
            "name":
            self.backplane.get_adc_name(i),
            "current": (self.get_current, {
                "units": "mA"
            }),
            "voltage": (self.get_voltage, {
                "units": "V"
            })
        })
Пример #11
0
    def __init__(self, backplane_interface, i):
        """Initialises the CurrentVoltage instance
        This creates a parameter tree for the supply which contains the current and voltage, with name and units stored as metadata, linking in the methods to access the data
        :param backplane_interface: the instance of the backplane_interface that handles communication with the odin_qem server
        :param i: The unique number to associate with this supply"""
        self.index = i
        self.backplane_interface = backplane_interface

        self.param_tree = MetadataTree({
            #"identity" : (apiGET handler, {metadata})
            "name":
            self.backplane_interface.get_adc_name(i),
            "current": (self.get_current, {
                "units": "mA"
            }),
            "voltage": (self.get_voltage, {
                "units": "V",
                "dp": 3
            }),
        })
Пример #12
0
    def __init__(self, backplane_interface, i):
        """Initialises the CurrentVoltage instance
        This creates a parameter tree for the resistor which contains the voltage read for the resistance as it stands, with name, units, minimum and maximum resistance stored as metadata, linking in the methods to access the data
        :param backplane_interface: the instance of the backplane_interface that handles communication with the odin_qem server
        :param i: The unique number to associate with this supply
        """
        self.index = i
        self.backplane_interface = backplane_interface

        self.param_tree = MetadataTree({
            #"identity":(HTTP Get handler, HTTP PUT handler, {metadata "name": HTTP GET handler})
            "name":
            self.backplane_interface.get_resistor_name(self.index),
            "resistance": (self.get, self.set, {
                "units":
                self.backplane_interface.get_resistor_units(self.index),
                "min":
                self.backplane_interface.get_resistor_min(self.index),
                "max":
                self.backplane_interface.get_resistor_max(self.index)
            }),
        })
Пример #13
0
 def test_accessor_invalid_kwarg(self):
     with assert_raises_regexp(MetadataParameterError, "Invalid argument: "):
         MetadataTree({"error" : (1, {"units" : "m", "invalid_kwarg" : "test"})}) 
Пример #14
0
    def test_accessor_create_error(self):
        with assert_raises_regexp(MetadataParameterError, ".+ is not a valid leaf node"):
            MetadataTree({"error" : ()})

        with assert_raises_regexp(MetadataParameterError, ".+ is not a valid leaf node"):
            MetadataTree({"error" : (TestMetadataTree.getA, TestMetadataTree.getB, [0,1,2])})
Пример #15
0
    def __init__(self):
        """Initialises the InterfaceData Data structure
        creates instances of the backplane_interface and asic_interface,
        then creates a tree structure containing all data needed by the interace, and passes the API commands to the relevant interface so they can be sent on to the asic or the backplane server
        """
        self.backplane_interface = Backplane_Interface()
        self.asic_interface = ASIC_Interface()

        #Initialise all backplane power supplies
        self.current_voltage = []
        for i in range(13):
            self.current_voltage.append(
                CurrentVoltage(self.backplane_interface, i))

        self.resistors = []
        for i in range(7):
            self.resistors.append(Resistor(self.backplane_interface, i))

        self.dacs = []
        for i in range(19):
            self.dacs.append(DAC(self.asic_interface, i))

        #create the tree structure
        self.param_tree = MetadataTree({
            "name":
            "QEM Interface",

            #Backplane subtree
            "clock": (self.backplane_interface.get_clock_frequency,
                      self.backplane_interface.set_clock_frequency, {
                          "units": "MHz",
                          "description":
                          "Clock frequency for the SI570 oscillator",
                          "min": 10,
                          "max": 945
                      }),
            "sensors_enabled": (self.backplane_interface.get_sensors_enable,
                                self.backplane_interface.set_sensors_enable, {
                                    "name": "sensors updating"
                                }),
            "update_required": (self.backplane_interface.get_update,
                                self.backplane_interface.set_update, {
                                    "name": "Update Once"
                                }),
            "non_volatile":
            (self.backplane_interface.get_resistor_non_volatile,
             self.backplane_interface.set_resistor_non_volatile, {
                 "name":
                 "Set Defaults",
                 "description":
                 "When setting resistor values determines if the new value should be set as a temporary value or as the new default"
             }),
            #reset always returns false
            "reset": (u'False', self.backplane_interface.set_reset, {
                "name": "Reset Backplane"
            }),
            # Attach subtrees for each supply and resistor
            "current_voltage": [cv.param_tree for cv in self.current_voltage],
            "resistors": [r.param_tree for r in self.resistors],

            #ASIC subtree
            "image": (self.asic_interface.get_image,
                      self.asic_interface.set_image_capture),
            "capture_run": (self.asic_interface.get_capture_run,
                            self.asic_interface.set_capture_run, {
                                "name": "Capture Run"
                            }),
            "dacs": [d.param_tree for d in self.dacs],
        })
Пример #16
0
    def __init__(self, **kwargs):
        """Initialises the InterfaceData Data structure
        creates instances of the backplane_interface and asic_interface,
        then creates a tree structure containing all data needed by the interace, and passes the API commands to the relevant interface so they can be sent on to the asic or the backplane server
        """

        self.backplane_interface = Backplane_Interface(
            kwargs['fem_ip'], kwargs['fem_port'], kwargs['resistor_defaults'])
        self.asic_interface = ASIC_Interface(
            self.backplane_interface, kwargs['working_dir'],
            kwargs['data_dir'], kwargs['server_ctrl_ip'],
            kwargs['server_data_ip'], kwargs['camera_ctrl_ip'],
            kwargs['camera_data_ip'])
        self.operating_interface = Operating_Interface(kwargs['working_dir'])

        #Initialise all backplane power supplies
        self.current_voltage = []
        for i in range(13):
            self.current_voltage.append(
                CurrentVoltage(self.backplane_interface, i))

        self.resistors = []
        for i in range(8):  #add another row for coarse..
            self.resistors.append(Resistor(self.backplane_interface, i))

        self.dacs = []
        for i in range(19):
            self.dacs.append(DAC(self.asic_interface, i + 1))

        #create the tree structure
        self.param_tree = MetadataTree({
            "name":
            "QEM Interface",

            #Backplane subtree
            "clock": (self.backplane_interface.get_clock_frequency,
                      self.backplane_interface.set_clock_frequency, {
                          "units": "MHz",
                          "description":
                          "Clock frequency for the SI570 oscillator",
                          "min": 10,
                          "max": 945
                      }),
            "sensors_enabled": (self.backplane_interface.get_sensors_enable,
                                self.backplane_interface.set_sensors_enable, {
                                    "name": "sensors updating"
                                }),
            "update_required": (self.backplane_interface.get_update,
                                self.backplane_interface.set_update, {
                                    "name": "Update Once"
                                }),
            "non_volatile":
            (self.backplane_interface.get_resistor_non_volatile,
             self.backplane_interface.set_resistor_non_volatile, {
                 "name":
                 "Set Defaults",
                 "description":
                 "When setting resistor values determines if the new value should be set as a temporary value or as the new default"
             }),
            #reset always returns false
            "reset": (u'False', self.backplane_interface.set_reset, {
                "name": "Reset Backplane"
            }),
            # Attach subtrees for each supply and resistor
            "current_voltage": [cv.param_tree for cv in self.current_voltage],
            "resistors": [r.param_tree for r in self.resistors],
            "fpga_reset": (u'False', self.backplane_interface.set_reset_fpga),
            "load_defaults":
            (u'False', self.backplane_interface.load_default_resistors),
            "defaults_loaded": (self.backplane_interface.get_defaults_loaded,
                                self.backplane_interface.set_defaults_loaded),

            #ASIC subtree
            "image": (1, self.asic_interface.set_image_capture),
            "capture_run": (self.asic_interface.get_capture_run,
                            self.asic_interface.set_capture_run, {
                                "name": "Capture Run"
                            }),
            "image_ready": (self.asic_interface.get_image_ready,
                            self.asic_interface.set_image_ready),
            "dacs": [d.param_tree for d in self.dacs],
            "vector_file": (self.asic_interface.get_vector_file,
                            self.asic_interface.set_vector_file),
            "update_bias": (u'true', self.asic_interface.set_update_bias),
            "upload_vector_file":
            (u'False', self.asic_interface.upload_vector_file),
            "bias_parsed": (self.asic_interface.get_bias_data_parsed,
                            self.asic_interface.set_bias_data_parsed),
            "vector_file_written":
            (self.asic_interface.get_vector_file_written,
             self.asic_interface.set_vector_file_written),
            "upload_vector_complete":
            (self.asic_interface.get_upload_vector_complete,
             self.asic_interface.set_upload_vector_complete),
            "log_complete": (self.asic_interface.get_log_image_complete,
                             self.asic_interface.set_log_image_complete),
            "adc_config": (self.asic_interface.get_adc_config,
                           self.asic_interface.set_adc_config),
            "adc_calibrate_fine": (u'False',
                                   self.asic_interface.adc_calibrate_fine),
            "adc_calibrate_coarse": (u'False',
                                     self.asic_interface.adc_calibrate_coarse),
            "coarse_cal_complete":
            (self.asic_interface.get_coarse_cal_complete,
             self.asic_interface.set_coarse_cal_complete),
            "fine_cal_complete": (self.asic_interface.get_fine_cal_complete,
                                  self.asic_interface.set_fine_cal_complete),
            "plot_fine": (u'False', self.asic_interface.plot_fine),
            "plot_coarse": (u'False', self.asic_interface.plot_coarse),
            "coarse_plot_complete":
            (self.asic_interface.get_coarse_plot_complete,
             self.asic_interface.set_coarse_plot_complete),
            "fine_plot_complete": (self.asic_interface.get_fine_plot_complete,
                                   self.asic_interface.set_fine_plot_complete),

            #operating subtree to parse configuration files
            "image_vector_files":
            (self.operating_interface.get_image_vector_files),
            "adc_vector_files":
            (self.operating_interface.get_adc_vector_files),
        })