| optoMDC

Functions
optoKummenberg.tools.systems_registers_tools Namespace Reference

## Functions
def | list_systems ()
def | get_register (str system_name, register_name, int channel=0)
def | get_registers (str system_name, int channel=0)
def | process_registers (dict register_fields, values)
def | is_valid_channel (value)
def | is_valid_value (register_dict, value)

## Function Documentation

## ◆ get_register()

def optoKummenberg.tools.systems_registers_tools.get_register | ( | str | system_name,
|  |  | register_name,
|  | int | channel = `0`
| ) |  |

    Given a System name and Register name, will return the associated register_id integer
    :param system_name: str
    :param register_name: str
    :param channel: int
    :return: int register_id

## ◆ get_registers()

def optoKummenberg.tools.systems_registers_tools.get_registers | ( | str | system_name,
|  | int | channel = `0`
| ) |  |

    Returns list of tuples containing registers name and dictionary.
    :param system_name:
    :param channel:
    :return:

## ◆ is_valid_channel()

def optoKummenberg.tools.systems_registers_tools.is_valid_channel | ( |  | value | ) |

    Given a channel number value, determines if value is within accepted parameters.

    Parameters
    ----------
    value
        Must be between 0 and 8, can be int float or string

## ◆ is_valid_value()

def optoKummenberg.tools.systems_registers_tools.is_valid_value | ( |  | register_dict,
|  |  | value
| ) |  |

    Given a registers record and a value, determines if value is within accepted parameters.

    Parameters
    ----------
    register_dict : dict
        Register dictionary fields corresponding to desired registers.{'id': registers number, 'type': data type, ...}
    value : varies
        Value to set given registers.
    Raises
    ------
    none

    Notes
    -----
    Valid inputs follow the following logic table.

    +------------------------+-------------+-------------+------------+------------+
    | Input Value            | Register    | Register    | Register   | Register   |
    |                        | Type: int   | Type: float | Type: bool | Type: None |
    +========================+=============+=============+============+============+
    | int                    | check range | check range | is binary? | False      |
    +------------------------+-------------+-------------+------------+------------+
    | float                  | check range | check range | is binary? | False      |
    +------------------------+-------------+-------------+------------+------------+
    | bool                   | False       | False       | True       | False      |
    +------------------------+-------------+-------------+------------+------------+
    | None                   | False       | False       | False      | True       |
    +------------------------+-------------+-------------+------------+------------+
    | Other                  | False       | False       | False      | False      |
    +------------------------+-------------+-------------+------------+------------+

    Additional Notes
    ----------------
    Validation for requests to set values in the Signal Flow Manager are slightly different.
    The channel you are setting must match the channel in the flow manager.
    For example, it would not make sense to set the Input channel 0 to SPI channel 2, etc.

## ◆ list_systems()

def optoKummenberg.tools.systems_registers_tools.list_systems | ( |  | ) |

    Inspect generic_registers for all imported and defined Systems.
    :return: list of System names

## ◆ process_registers()

def optoKummenberg.tools.systems_registers_tools.process_registers | ( | dict | register_fields,
|  |  | values
| ) |  |

    Gives validity of registers field values to be set, and returns command and registers(s) IDs.

    Parameters
    ----------
    register_fields : dict
        The dictionary containing registers information.
    values
        The desired value(s) to set the registers.

    Returns
    -------
    command_id : int
        Command ID necessary to send single or multiple registers settings.
    register_id : int
        Register ID corresponding to given registers.

    Raises
    ------
    Returns None in case of parse_error (value out of range, or invalid input)

    See Also
    --------
    Register fields are returned by registers class attributes, see registers.