optoKummenberg

Loading...
Searching...
No Matches
optoKummenberg.commands.Command Class Reference
Inheritance diagram for optoKummenberg.commands.Command:

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

## Public Attributes
| verbose

## Protected Attributes
bool | _simple = self.IsSimpleMode()

## 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__()

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

## Member Function Documentation

## ◆ disconnect()

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

    Severs the serial connection, flushing input/output buffers.

## ◆ generic_command()

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()

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()

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()

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()

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()

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()

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()

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()

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()

optoKummenberg.commands.Command.reset | ( |  | self,
|  | bool | force = False,
|  | float | registration_interval = 10 )

    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.
    :param registration_interval:
        Description:
        - During this period of time software checks if driver has been
        detected by OS after reset and reboot. If not an exception is thrown.
        Unit:
        - Seconds

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

## ◆ reset_general()

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

## ◆ save_snapshot()

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()

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()

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()

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 = self.IsSimpleMode()
| protected

## ◆ verbose

optoKummenberg.commands.Command.verbose

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

- C:/git/142-421-00_optoKummenberg/src/main/python/optoKummenberg/commands.py