optoKummenberg

Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
optoKummenberg.commands.Command Class Reference
Inheritance diagram for optoKummenberg.commands.Command:

## Public Member Functions
def | __init__ (self, board=None)
def | handshake (self, bool force=False)
def | go_pro (self, bool force=False)
def | reset_general (self, bool force=False)
def | reset (self, bool force=False)
def | generic_command (self, bool force=False)
def | get_firmware_id (self, bool force=False)
def | get_status (self, bool force=False)
def | start_self_test (self, bool force=False)
def | load_snapshot (self, int memory_id, bool force=False)
def | save_snapshot (self, int memory_id, bool force=False)
def | go_simple (self, bool force=False)
def | set_value (self, dict or list or int register, value)
def | get_value (self, dict or list or int register)
def | set_vector (self, dict or int register, int index, vector)
def | get_vector (self, dict or int register, int index, int count)
def | disconnect (self)

## Protected Attributes
| _simple

## Detailed Description

    Command object from which to send Board commands and process responses.
    Note: these commands are inherited by a given board (Duck typed)

    For Board information, see help(connection.Board) or connection.Board.__doc__

    Parameters
    ----------
    board : Board
        The Board object from which to issue commands and receive responses.

    Returns
    -------
    response : str
        Firmware response string, or parse_error code string.

    Raises
    ------
    none

    Notes
    -----
    Board commands operate via duck typing. Must pass a valid Board.
    Command success may depend on _board mode (simple/pro)

    Examples
    --------
    Given an existing _board connection (bd) in simple mode, this will perform a simple handshake acknowledgement.

    >>> Command(bd).handshake()
    Handshake Successful.

## Constructor & Destructor Documentation

## ◆ __init__()

def optoKummenberg.commands.Command.__init__ | ( |  | self,
|  |  | board = `None`
| ) |  |

Reimplemented in optoKummenberg.connections.Board.

## Member Function Documentation

## ◆ disconnect()

def optoKummenberg.commands.Command.disconnect | ( |  | self | ) |

    Severs the serial connection, flushing input/output buffers.

## ◆ generic_command()

def optoKummenberg.commands.Command.generic_command | ( |  | self,
|  | bool | force = `False`
| ) |  |

        Sends generic pro-mode command.

        Parameters
        ----------
        force : bool
            Will first ensure board is in correct mode before sending command.

        Returns
        -------
        response : bytes
            Firmware response string, or parse_error code string.

## ◆ get_firmware_id()

def optoKummenberg.commands.Command.get_firmware_id | ( |  | self,
|  | bool | force = `False`
| ) |  |

    Gets firmware identification.

    Parameters
    ----------
    force : bool
    Will first ensure board is in correct mode before sending command.

    Returns
    -------
    response : bytes
    Firmware response string, or parse_error code string.

## ◆ get_status()

def optoKummenberg.commands.Command.get_status | ( |  | self,
|  | bool | force = `False`
| ) |  |

    Gets the board status information.

    Parameters
    ----------
    force : bool
    Will first ensure board is in correct mode before sending command.

    Returns
    -------
    response : bytes
    Firmware response string, or parse_error code string.

## ◆ get_value()

def optoKummenberg.commands.Command.get_value | ( |  | self,
|  | dict or list or int | register
| ) |  |

    Gets the given registers value.

    Parameters
    ----------
    register_record : dict or list or int
    Register dictionary fields corresponding to register.{'id': registers number, 'type': data type, ...}
    set_internal : bool
    Determines whether to set the returned value internally. (recommended)

    Returns
    -------
    str
    Firmware response, contains registers value, along with acknowledgement or parse_error information.

    Raises
    ------
    none

    See Also
    --------
    Register IDs, value type and range can be found in the registers module.

    Examples
    --------
    In this example, the same _board (_board) is used and the X channel OF is set to 0.0 over USB/UART
    Note: system and registers name must be known, see registers module for more info.

    >>> board.initialize_channel(0)
    >>> register_record = board.Channel_0.StaticInput.of
    >>> board.get_value(register_record)
    Sending: b'~\x00\x11\x02P\x01\x00\x00~'
    Received: b'~\x00\x11\x04\x00\x00\x00\x00\xf2\x81~'
    Command: [GET_VALUE]. Register: [0x5001]. Value: [[0.0]].
    Data Received: [0.0]
    (0, 17, [0.0], [242, 129])

## ◆ get_vector()

def optoKummenberg.commands.Command.get_vector | ( |  | self,
|  | dict or int | register,
|  | int | index,
|  | int | count
| ) |  |

    Gets the given register vector.

    Parameters
    ----------
    register : int
    The system location of the desired vector.
    index : int
    The location of the vector to begin reading from.
    count :
    The number of vector elements, where each elements is 4 bytes if float/int or 1 byte otherwise.

    Returns
    -------
    str
    Firmware response, contains registers value, along with acknowledgement or parse_error information.

    Raises
    ------
    none

    See Also
    --------
    Register IDs, value type and range can be found in the registers module.

    Examples
    --------
    In this example, the same _board (_board) is used and the X channel OF is set to 0.0 over USB/UART
    Note: system and registers name must be known, see registers module for more info.

    >>> board.initialize_channel(0)
    >>> register_record = board.Channel_0.StaticInput.of
    >>> board.get_value(register_record)
    Sending: b'~\x00\x11\x02P\x01\x00\x00~'
    Received: b'~\x00\x11\x04\x00\x00\x00\x00\xf2\x81~'
    Command: [GET_VALUE]. Register: [0x5001]. Value: [[0.0]].
    Data Received: [0.0]
    (0, 17, [0.0], [242, 129])

## ◆ go_pro()

def optoKummenberg.commands.Command.go_pro | ( |  | self,
|  | bool | force = `False`
| ) |  |

        Switches _board into pro-mode.

        Parameters
        ----------
        force : bool
            Will first ensure board is in correct mode before sending command.

        Returns
        -------
        response : bytes
            Firmware response string, or parse_error code string.

## ◆ go_simple()

def optoKummenberg.commands.Command.go_simple | ( |  | self,
|  | bool | force = `False`
| ) |  |

    Switches _board into simple-mode.

    Parameters
    ----------
    force : bool
    Will first ensure board is in correct mode before sending command.

    Returns
    -------
    response : bytes
    Firmware response string, or parse_error code string.

## ◆ handshake()

def optoKummenberg.commands.Command.handshake | ( |  | self,
|  | bool | force = `False`
| ) |  |

        Acknowledge communication in simple mode.

        Parameters
        ----------
        force : bool
            Will first ensure board is in correct mode before sending command.

        Returns
        -------
        response : bytes
            Firmware response string, or parse_error code string.

## ◆ load_snapshot()

def optoKummenberg.commands.Command.load_snapshot | ( |  | self,
|  | int | memory_id,
|  | bool | force = `False`
| ) |  |

    Loads snapshot at given memory location, may not work if id is invalid.
    For more information, see: SnapshotManager in registers.

    Parameters
    ----------
    memory_id : int
    Memory location to load.
    force : bool
    Will first ensure board is in correct mode before sending command.

    Returns
    -------
    response : bytes
    Firmware response string, or parse_error code string.

## ◆ reset()

def optoKummenberg.commands.Command.reset | ( |  | self,
|  | bool | force = `False`
| ) |  |

    Reset firmware and reconnect to Board. Will be in simple-mode after reset.
    Must be in Simple Mode to execute this Command!

    Parameters
    ----------
    force : bool
        Will first ensure board is in correct mode before sending command.

    Returns
    -------
    response : bytes
        Firmware response string, or parse_error code string.

## ◆ reset_general()

def optoKummenberg.commands.Command.reset_general | ( |  | self,
|  | bool | force = `False`
| ) |  |

## ◆ save_snapshot()

def optoKummenberg.commands.Command.save_snapshot | ( |  | self,
|  | int | memory_id,
|  | bool | force = `False`
| ) |  |

    Saves snapshot at given memory location, may not work if id is invalid. (i.e. location 0 is readonly)
    For more information, see: SnapshotManager in registers.

    Parameters
    ----------
    memory_id : int
    Memory location to save.
    force : bool
    Will first ensure board is in correct mode before sending command.

    Returns
    -------
    response : bytes
    Firmware response string, or parse_error code string.

## ◆ set_value()

def optoKummenberg.commands.Command.set_value | ( |  | self,
|  | dict or list or int | register,
|  |  | value
| ) |  |

    Sets the given registers to desired value.

    Parameters
    ----------
    register : dict or list of dicts or int or list of ints
        Register dictionary corresponding to desired registers.{'id': registers number, 'type': data type, ...}
        Further, a raw registers id can be passed, in which case no validation will occur (COULD CAUSE ERRORS).
    value : varies, can also be list of values
        The type and range of value is dependent on the registers being addressed, see 'type' element above.

    Returns
    -------
    str
        Firmware response, contains acknowledgement or parse_error information.

    Raises
    ------
    none

    See Also
    --------
    Register IDs, value type and range can be found in the registers module.

    Examples
    --------
    In this example, the same _board (con) is used and the X channel OF is set to 0 over USB/UART
    Note: system and registers name must be known, see registers module for more info.

    >>> from optoKummenberg.registers.generic_registers import StaticInput
    >>> from src.main.python.optoKummenberg.connections import Board
    >>> board = Board()
    >>> registers = StaticInput(0).of
    >>> board.set_value(registers, 0.0)

## ◆ set_vector()

def optoKummenberg.commands.Command.set_vector | ( |  | self,
|  | dict or int | register,
|  | int | index,
|  |  | vector
| ) |  |

    Sets the given register vector to desired value.

    Parameters
    ----------
    register : dict or list of dicts or int or list of ints
    Register dictionary corresponding to desired registers.{'id': registers number, 'type': data type, ...}
    Further, a raw registers id can be passed, in which case no validation will occur (COULD CAUSE ERRORS).
    index : int
    The location to store the given vector.
    value : varies, can also be list of values
    The type and range of value is dependent on the registers being addressed, see 'type' element above.

    Returns
    -------
    str
    Firmware response, contains acknowledgement or parse_error information.

    Raises
    ------
    none

    See Also
    --------
    Register IDs, value type and range can be found in the registers module.

    Examples
    --------
    In this example, the same _board (con) is used and the X channel OF is set to 0 over USB/UART
    Note: system and registers name must be known, see registers module for more info.

    >>> from optoKummenberg.registers.generic_registers import VectorPatternMemory
    >>> from optoKummenberg.connections import Board
    >>> board = Board()
    >>> register = {'id': VectorPatternMemory().sys_id << 8, 'type': float}  # could also send register = 0x2600
    >>> vector = [0, 0.1, 0.2, 0.3]
    >>> board.set_vector(register, 0, vector)

## ◆ start_self_test()

def optoKummenberg.commands.Command.start_self_test | ( |  | self,
|  | bool | force = `False`
| ) |  |

    Begins board self-test.

    Parameters
    ----------
    force : bool
    Will first ensure board is in correct mode before sending command.

    Returns
    -------
    response : bytes
    Firmware response string, or parse_error code string.

## Member Data Documentation

## ◆ _simple

optoKummenberg.commands.Command._simple
| protected

The documentation for this class was generated from the following file:

- C:/Users/filip.stary/Documents/142-421-00_optoKummenberg/src/main/python/optoKummenberg/commands.py