Skip to content

Commit

Permalink
swap class order to make typing easier
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian-B committed Nov 29, 2023
1 parent 6847e23 commit 105dea7
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 58 deletions.
46 changes: 23 additions & 23 deletions spinnman/extended/read_adc.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,28 @@
from spinnman.model import ADCInfo


class ReadADC(BMPRequest['_SCPReadADCResponse']):
class _SCPReadADCResponse(BMPResponse[ADCInfo]):
"""
An SCP response to a request for ADC information.
"""
__slots__ = ("_adc_info", )

def __init__(self) -> None:
super().__init__("Read ADC", SCPCommand.CMD_BMP_INFO)
self._adc_info = None

def _parse_payload(self, data: bytes, offset: int) -> ADCInfo:
return ADCInfo(data, offset)

@property
def adc_info(self):
"""
The ADC information.
"""
return self._value


class ReadADC(BMPRequest[_SCPReadADCResponse]):
"""
SCP Request for the data from the BMP including voltages and
temperature.
Expand All @@ -44,26 +65,5 @@ def __init__(self, board: int):
argument_1=BMPInfo.ADC.value)

@overrides(AbstractSCPRequest.get_scp_response)
def get_scp_response(self) -> '_SCPReadADCResponse':
def get_scp_response(self) -> _SCPReadADCResponse:
return _SCPReadADCResponse()


class _SCPReadADCResponse(BMPResponse[ADCInfo]):
"""
An SCP response to a request for ADC information.
"""
__slots__ = ("_adc_info", )

def __init__(self) -> None:
super().__init__("Read ADC", SCPCommand.CMD_BMP_INFO)
self._adc_info = None

def _parse_payload(self, data: bytes, offset: int) -> ADCInfo:
return ADCInfo(data, offset)

@property
def adc_info(self):
"""
The ADC information.
"""
return self._value
32 changes: 16 additions & 16 deletions spinnman/messages/scp/impl/bmp_get_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,21 @@
from spinnman.messages.scp.enums import SCPCommand


class BMPGetVersion(BMPRequest['_BMPVersion']):
class _BMPVersion(BMPResponse[VersionInfo]):
def _parse_payload(self, data: bytes, offset: int) -> VersionInfo:
return VersionInfo(data, offset)

@property
def version_info(self) -> VersionInfo:
"""
The version information received.
:rtype: VersionInfo
"""
return self._value


class BMPGetVersion(BMPRequest[_BMPVersion]):
"""
An SCP request to read the version of software running on a core.
"""
Expand All @@ -37,19 +51,5 @@ def __init__(self, board: int):
board, SCPRequestHeader(command=SCPCommand.CMD_VER))

@overrides(AbstractSCPRequest.get_scp_response)
def get_scp_response(self) -> '_BMPVersion':
def get_scp_response(self) -> _BMPVersion:
return _BMPVersion("Read BMP version", SCPCommand.CMD_VER)


class _BMPVersion(BMPResponse[VersionInfo]):
def _parse_payload(self, data: bytes, offset: int) -> VersionInfo:
return VersionInfo(data, offset)

@property
def version_info(self) -> VersionInfo:
"""
The version information received.
:rtype: VersionInfo
"""
return self._value
38 changes: 19 additions & 19 deletions spinnman/messages/scp/impl/read_fpga_register.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,24 @@
_ONE_WORD = struct.Struct("<I")


class ReadFPGARegister(BMPRequest['_SCPReadFPGARegisterResponse']):
class _SCPReadFPGARegisterResponse(BMPResponse[int]):
"""
An SCP response to a request for the version of software running.
"""
def _parse_payload(self, data: bytes, offset: int) -> int:
return _ONE_WORD.unpack_from(data, offset)[0]

@property
def fpga_register(self) -> int:
"""
The register information received.
:rtype: int
"""
return self._value


class ReadFPGARegister(BMPRequest[_SCPReadFPGARegisterResponse]):
"""
Requests the data from a FPGA's register.
"""
Expand All @@ -48,23 +65,6 @@ def __init__(self, fpga_num: int, register: int, board: int):
argument_1=arg1, argument_2=4, argument_3=fpga_num)

@overrides(AbstractSCPRequest.get_scp_response)
def get_scp_response(self) -> '_SCPReadFPGARegisterResponse':
def get_scp_response(self) -> _SCPReadFPGARegisterResponse:
return _SCPReadFPGARegisterResponse(
"Read FPGA register", SCPCommand.CMD_LINK_READ)


class _SCPReadFPGARegisterResponse(BMPResponse[int]):
"""
An SCP response to a request for the version of software running.
"""
def _parse_payload(self, data: bytes, offset: int) -> int:
return _ONE_WORD.unpack_from(data, offset)[0]

@property
def fpga_register(self) -> int:
"""
The register information received.
:rtype: int
"""
return self._value

0 comments on commit 105dea7

Please sign in to comment.