def _load_lamp_lists_from_config(self, config): lamp_source_bank_list = [] lamp_list = [] lamp_list_for_index = [] # Make a list of unique lamp source banks. The P-ROC/P3-ROC only supports 2. # If this is exceeded we will error out later. if 'lights' in config: for name in config['lights']: item_dict = config['lights'][name] if "subtype" not in item_dict or item_dict[ "subtype"] != "matrix": continue lamp = PDBLight(self, str(item_dict['number'])) # Catalog PDB banks # Dedicated lamps don't use PDB banks. They use P-ROC direct # driver pins (not available on P3-ROC). if lamp.lamp_type == 'dedicated': pass elif lamp.lamp_type == 'pdb': if lamp.source_bank() not in lamp_source_bank_list: lamp_source_bank_list.append(lamp.source_bank()) # Create dicts of unique sink banks. The source index is # needed when setting up the driver groups. lamp_dict = { 'source_index': lamp_source_bank_list.index(lamp.source_bank()), 'sink_bank': lamp.sink_bank(), 'source_output': lamp.source_output() } # lamp_dict_for_index. This will be used later when the # p-roc numbers are requested. The requestor won't know # the source_index, but it will know the source board. # This is why two separate lists are needed. lamp_dict_for_index = { 'source_board': lamp.source_board(), 'sink_bank': lamp.sink_bank(), 'source_output': lamp.source_output() } if lamp_dict not in lamp_list: lamp_list.append(lamp_dict) lamp_list_for_index.append(lamp_dict_for_index) return lamp_source_bank_list, lamp_list, lamp_list_for_index
def get_proc_light_number(self, number_str): """Get the actual number of a light from the lamp config. Args: number_str (str): PDB string """ lamp = PDBLight(self, number_str) if lamp.lamp_type == 'unknown': return -1 elif lamp.lamp_type == 'dedicated': return lamp.dedicated_output() lamp_dict_for_index = {'source_board': lamp.source_board(), 'sink_bank': lamp.sink_bank(), 'source_output': lamp.source_output()} if lamp_dict_for_index not in self.indexes: raise AssertionError("Light not in lamp dict") index = self.indexes.index(lamp_dict_for_index) num = index * 8 + lamp.sink_output() return num