diff --git a/quick_tests/quick_tests.py b/quick_tests/quick_tests.py index f28772a71..9ce817e75 100644 --- a/quick_tests/quick_tests.py +++ b/quick_tests/quick_tests.py @@ -155,7 +155,7 @@ def __exit__(self, *_ignored): def print_transceiver_tests(transceiver): with Section("Version Information"): - version_info = transceiver.ensure_board_is_ready() + version_info = transceiver._get_scamp_version() print(version_info) app_id = SpiNNManDataView().get_new_id() diff --git a/spinnman/transceiver.py b/spinnman/transceiver.py index 2f80495e9..9111671f8 100644 --- a/spinnman/transceiver.py +++ b/spinnman/transceiver.py @@ -34,7 +34,7 @@ UDP_BOOT_CONNECTION_DEFAULT_PORT, NO_ROUTER_DIAGNOSTIC_FILTERS, ROUTER_REGISTER_BASE_ADDRESS, ROUTER_DEFAULT_FILTERS_MAX_POSITION, ROUTER_FILTER_CONTROLS_OFFSET, ROUTER_DIAGNOSTIC_FILTER_SIZE, N_RETRIES, - BOOT_RETRIES) + BOOT_RETRIES, POWER_CYCLE_WAIT_TIME_IN_SECONDS) from spinnman.data import SpiNNManDataView from spinnman.exceptions import ( SpinnmanInvalidParameterException, SpinnmanException, SpinnmanIOException, @@ -88,10 +88,27 @@ _ONE_LONG = struct.Struct(" _SCAMP_VERSION[1] - def ensure_board_is_ready(self, n_retries=5, extra_boot_values=None): + def _ensure_board_is_ready(self, n_retries=5, extra_boot_values=None): """ Ensure that the board is ready to interact with this version of the transceiver. Boots the board if not already booted and verifies that @@ -653,7 +677,6 @@ def ensure_board_is_ready(self, n_retries=5, extra_boot_values=None): This should only be used for values which are not standard based on the board version. :return: The version identifier - :rtype: VersionInfo :raise SpinnmanIOException: * If there is a problem booting the board * If the version of software on the board is not compatible with @@ -716,8 +739,6 @@ def ensure_board_is_ready(self, n_retries=5, extra_boot_values=None): self._scamp_connection_selector = MostDirectConnectionSelector( self._scamp_connections) - return version_info - def __is_default_destination(self, version_info): return (version_info.x == AbstractSCPRequest.DEFAULT_DEST_X_COORD and version_info.y == AbstractSCPRequest.DEFAULT_DEST_Y_COORD) @@ -1048,66 +1069,44 @@ def _power_on_machine(self): """ Power on the whole machine. - :rtype bool :return success of failure to power on machine """ if self._bmp_connection is None: logger.warning("No BMP connections, so can't power on") - return False - self.power_on(self._bmp_connection) - return True - - def power_on(self, boards=0): - """ - Power on a set of boards in the machine. + self._power(PowerCommand.POWER_ON) + self._machine_off = True + # Sleep for 5 seconds as the machine has just been powered on + time.sleep(BMP_POST_POWER_ON_SLEEP_TIME) - :param int boards: The board or boards to power on - """ - self._power(PowerCommand.POWER_ON, boards) - - def power_off_machine(self): + def _power_off_machine(self): """ Power off the whole machine. - :rtype bool :return success or failure to power off the machine """ if self._bmp_connection is None: - logger.warning("No BMP connections, so can't power off") - return False - logger.info("Turning off machine") - self.power_off(self._bmp_connection) - return True - - def power_off(self, boards=0): - """ - Power off a set of boards in the machine. + logger.warning(_POWER_CYCLE_FAILURE_WARNING) + self._power(PowerCommand.POWER_OFF) + logger.warning(_POWER_CYCLE_WARNING) + time.sleep(POWER_CYCLE_WAIT_TIME_IN_SECONDS) + logger.warning("Power cycle wait complete") - :param int boards: The board or boards to power off - """ - self._power(PowerCommand.POWER_OFF, boards) - - def _power(self, power_command, boards=0): + def _power(self, power_command): """ Send a power request to the machine. :param PowerCommand power_command: The power command to send :param boards: The board or boards to send the command to """ - connection_selector = self._bmp_selector timeout = ( BMP_POWER_ON_TIMEOUT if power_command == PowerCommand.POWER_ON else BMP_TIMEOUT) process = SendSingleCommandProcess( - connection_selector, timeout=timeout, n_retries=0) - process.execute(SetPower(power_command, boards)) + self._bmp_selector, timeout=timeout, n_retries=0) + process.execute(SetPower(power_command, self._bmp_connection.boards)) self._machine_off = power_command == PowerCommand.POWER_OFF - # Sleep for 5 seconds if the machine has just been powered on - if not self._machine_off: - time.sleep(BMP_POST_POWER_ON_SLEEP_TIME) - def read_fpga_register( self, fpga_num, register, board=0): """ @@ -1937,7 +1936,7 @@ def close(self): """ if self._bmp_connection is not None: if get_config_bool("Machine", "turn_off_machine"): - self.power_off_machine() + self._power_off_machine() for connection in self._all_connections: connection.close() diff --git a/unittests/test_transceiver.py b/unittests/test_transceiver.py index 6cee5bde8..5af5f14d5 100644 --- a/unittests/test_transceiver.py +++ b/unittests/test_transceiver.py @@ -58,6 +58,9 @@ def write_memory( def close(self): pass + def _ensure_board_is_ready(self, n_retries=5, extra_boot_values=None): + pass + class MockExtendedTransceiver(MockWriteTransceiver, ExtendedTransceiver): pass