API doc for configparser¶
-
class
common.python.pandablocks.configparser.ConfigParser(config_dir)¶ Parser for config/register/description file
Will populate itself with the blocks and fields described in the config files, checking for validity
Variables: - blocks (OrderedDict) – map str block_name ->
ConfigBlockinstance where block name doesn’t include number (e.g. “SEQ”) - bit_bus (OrderedDict) – map str block_name.field_name -> int bit_bus_idx for each block and field
- pos_bus (OrderedDict) – map str block_name.field_name -> int pos_bus_idx for each block and field
- ext_names (OrderedDict) – map int ext_bus_idx -> str block_name.field_name for each block and field
Populate parser with files from config_dir
Parameters: config_dir (str) – Path to config directory - blocks (OrderedDict) – map str block_name ->
-
class
common.python.pandablocks.configparser.ConfigBlock(reg_line, config_line=None, desc_line=None)¶ Represents a block definition in the config file.
Variables: - name (str) – The block name (e.g. PULSE)
- num (int) – The number of blocks that should be created (e.g. 2)
- base (int) – The base register offset for this block
- desc (str) – The description for this block
- fields (OrderedDict) – map str field_name ->
ConfigFieldinstance for each field the block has - registers (OrderedDict) – map str attr_name -> (int reg num, ConfigField)
- outputs (OrderedDict) – map str attr_name -> ([int out idx], ConfigField)
Also, there will be an attribute for each attr_name in registers.keys() that also has that string as its value. This will allow lookup of register strings in a safe way. For example:
self.TABLE_DATA = “TABLE_DATA”Initialise with relevant config/reg/desc lines for this block.
Should include block definition and all field definitions for this block
Parameters: - reg_line (str) – Line specifying block in registers file
- config_line (str) – Optional line specifying block in config file
- desc_line (str) – Optional line specifying block in descriptions file
-
add_field(field)¶ Add a ConfigField instance to self.fields dictionary
This also sets an attribute on itself so we can do safer lookups. E.g. self.FORCE_RST = “FORCE_RST”
Parameters: field (ConfigField) – ConfigField instance
-
class
common.python.pandablocks.configparser.ConfigField(name, reg_lines, config_lines=None, desc_lines=None)¶ Represents a field of a field definition.
The information held here spans the config, description and register files
Variables: - name (str) – The field name (e.g. OUTD)
- reg (list) – The register string (e.g. [“3”, “2”, “>3”])
- cls (str) – The field class (e.g. pos_out)
- cls_args (list) – The arguments needed to configure the cls (e.g. [“encoder”])
- cls_extra (list) – Any extra data associated with cls (e.g. enum values [“0 Falling”, “1 Rising”])
- desc (str) – The description of the field
Initialise with relevant config/reg/desc lines for this field
Parameters: - reg_lines (list) – Lines specifying field in registers file
- config_lines (list) – Optional lines specifying field in config file
- desc_lines (list) – Optional line specifying field in descriptions
- file –