Esempio n. 1
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)
Esempio n. 2
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(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 get(self, path, metadata):
        return self.param_tree.get(path, metadata=metadata)

    def set(self, path, value):
        print(path, value)
        self.param_tree.set(path, value)
Esempio n. 3
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)
Esempio n. 4
0
class InterfaceData(object):
    """This class handles the API commands for the interface by constructing a tree structure for the data and passing the commands down to each leaf"""
    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],
        })

    def get(self, path, metadata):
        """ Construct a dict by running the get command for the given path on the tree
        :param path: URI path of request
        :param metadata: Boole representing whether to include the metadata
        :return: a dict containing the data in a tree structure
        """
        return self.param_tree.get(path, metadata=metadata)

    def set(self, path, value):
        self.param_tree.set(path, value)
Esempio n. 5
0
class InterfaceData(object):
    """This class handles the API commands for the interface by constructing a tree structure for the data and passing the commands down to each leaf"""
    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),
        })

    def get(self, path, metadata):
        """ Construct a dict by running the get command for the given path on the tree
        :param path: URI path of request
        :param metadata: Boole representing whether to include the metadata
        :return: a dict containing the data in a tree structure
        """

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

    def set(self, path, value):
        """ Runs the set command on the given path on the tree, settings
            the value to the value provided.
            
        @param path: uri path of request
        @param value: the value to set 
        """
        if "dacs" in path:
            value = value.encode('ascii', 'ignore')

        self.param_tree.set(path, value)