Skip to content

Commit

Permalink
no cabinet or frame
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian-B committed Aug 1, 2023
1 parent 0496ea2 commit 10fa298
Showing 1 changed file with 14 additions and 31 deletions.
45 changes: 14 additions & 31 deletions spinnman/transceiver.py
Original file line number Diff line number Diff line change
Expand Up @@ -1059,21 +1059,16 @@ def _power_on_machine(self):
logger.warning("No BMP connections, so can't power on")
return False
for bmp_connection in self._bmp_connections:
self.power_on(bmp_connection.boards, bmp_connection.cabinet,
bmp_connection.frame)
self.power_on(bmp_connection.boards)
return True

def power_on(self, boards=0, cabinet=0, frame=0):
def power_on(self, boards=0):
"""
Power on a set of boards in the machine.
:param int boards: The board or boards to power on
:param int cabinet: the ID of the cabinet containing the frame, or 0
if the frame is not in a cabinet
:param int frame: the ID of the frame in the cabinet containing the
board(s), or 0 if the board is not in a frame
"""
self._power(PowerCommand.POWER_ON, boards, cabinet, frame)
self._power(PowerCommand.POWER_ON, boards)

def power_off_machine(self):
"""
Expand All @@ -1087,48 +1082,36 @@ def power_off_machine(self):
return False
logger.info("Turning off machine")
for bmp_connection in self._bmp_connections:
self.power_off(bmp_connection.boards, bmp_connection.cabinet,
bmp_connection.frame)
self.power_off(bmp_connection.boards)
return True

def power_off(self, boards=0, cabinet=0, frame=0):
def power_off(self, boards=0):
"""
Power off a set of boards in the machine.
:param int boards: The board or boards to power off
:param int cabinet: the ID of the cabinet containing the frame, or 0
if the frame is not in a cabinet
:param int frame: the ID of the frame in the cabinet containing the
board(s), or 0 if the board is not in a frame
"""
self._power(PowerCommand.POWER_OFF, boards, cabinet, frame)
self._power(PowerCommand.POWER_OFF, boards)

def _bmp_selector(self, cabinet, frame):
def _bmp_selector(self):
"""
:param int cabinet:
:param int frame:
:rtype: FixedConnectionSelector
"""
assert (cabinet == frame == 0)
key = (cabinet, frame)
key = (0, 0)
if key not in self._bmp_connection_selectors:
raise SpinnmanInvalidParameterException(
"cabinet and frame", f"{cabinet} and {frame}",
"cabinet and frame", f"{0} and {0}",
"Unknown combination")
return self._bmp_connection_selectors[key]

def _power(self, power_command, boards=0, cabinet=0, frame=0):
def _power(self, power_command, boards=0):
"""
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
:param int cabinet: the ID of the cabinet containing the frame, or 0
if the frame is not in a cabinet
:param int frame: the ID of the frame in the cabinet containing the
board(s), or 0 if the board is not in a frame
"""
connection_selector = self._bmp_selector(cabinet, frame)
connection_selector = self._bmp_selector()
timeout = (
BMP_POWER_ON_TIMEOUT
if power_command == PowerCommand.POWER_ON
Expand Down Expand Up @@ -1158,7 +1141,7 @@ def read_fpga_register(self, fpga_num, register, cabinet, frame, board):
:rtype: int
"""
process = SendSingleCommandProcess(
self._bmp_selector(cabinet, frame), timeout=1.0)
self._bmp_selector(), timeout=1.0)
response = process.execute(
ReadFPGARegister(fpga_num, register, board))
return response.fpga_register # pylint: disable=no-member
Expand All @@ -1179,7 +1162,7 @@ def write_fpga_register(self, fpga_num, register, value, cabinet, frame,
:param int board: which board to write the FPGA register to
"""
process = SendSingleCommandProcess(
self._bmp_selector(cabinet, frame))
self._bmp_selector())
process.execute(
WriteFPGARegister(fpga_num, register, value, board))

Expand All @@ -1193,7 +1176,7 @@ def read_bmp_version(self, board, cabinet, frame):
:return: the sver from the BMP
"""
process = SendSingleCommandProcess(
self._bmp_selector(cabinet, frame))
self._bmp_selector())
response = process.execute(BMPGetVersion(board))
return response.version_info # pylint: disable=no-member

Expand Down

0 comments on commit 10fa298

Please sign in to comment.