devices.base

Base classes for RadEye device implementations.

Response: TypeAlias = tuple[bool, typing.Optional[str]]

Result of a remote-control command: (success, response) where response is the device text or None on failure.

@dataclass
class BaseData:

Base data class for all data classes.

def to_dict(self) -> dict:

Convert to a JSON-serializable dictionary.

@dataclass
class BaseHistoryStatus(BaseData):

Base data class for history status information.

Parameters
  • display_unit: Display unit label
  • raw_decimal: Raw decimal value
  • display_unit_raw_decimal: Raw display unit code
BaseHistoryStatus( display_unit: str = '', raw_decimal: int = 0, display_unit_raw_decimal: int = 0)
Inherited Members
BaseData
to_dict
@dataclass
class DisplayStatusData(BaseData):

Data class for data displayed on the device screen and status information.

Parameters
  • values: List of values displayed on the device screen
  • status: Status information. This can be: radeye_comms_sdk.radeye.devices.g10.G10HistoryStatus, radeye_comms_sdk.radeye.devices.sx.SXHistoryStatus, or None if no status information is available.
DisplayStatusData( values: list[int] = <factory>, status: Optional[BaseHistoryStatus] = None)
Inherited Members
BaseData
to_dict
@dataclass
class AutosendData(BaseData):

Data class for autosend data frame.

Parameters
  • data: Raw autosend payload string (without STX)
  • checksum_ok: Whether the frame BCC validated
  • parse_successful: Whether the frame split and field parse succeeded
  • rates: Dose rate values
  • rate_units: Unit code indices for each rate
  • status_hex: Raw status word (hex field from frame)
  • information: Device / model information string
  • dose_in_uR_per_hour: Accumulated dose in µR/h
  • bcc_hex: Trailing BCC from frame
  • rate_unit_strs: Human-readable unit labels per rate
  • status: Active alarm / status labels
AutosendData( data: str = '', checksum_ok: bool = False, parse_successful: bool = False, rates: list[int] = <factory>, rate_units: list[int] = <factory>, status_hex: int = 0, information: str = '', dose_in_uR_per_hour: int = 0, bcc_hex: int = 0, rate_unit_strs: list[str] = <factory>, status: list[str] = <factory>)
@classmethod
def parse( cls, data: str, measurement_unit_bit_dict: Optional[dict[int, str]] = None, status_bit_dict: Optional[dict[int, str]] = None) -> AutosendData:

Parse autosend payload into a radeye_comms_sdk.radeye.devices._base.AutosendData instance.

Parameters
  • data: Raw autosend payload string (without STX)
  • measurement_unit_bit_dict: Optional unit code → label map
  • status_bit_dict: Optional status bit → alarm label map
Returns

Parsed radeye_comms_sdk.radeye.devices._base.AutosendData instance

Inherited Members
BaseData
to_dict
class RadEyeDevice:

Base class for RadEye device serial protocol handlers.

Parameters
  • port: Serial port name (e.g. COM3 or /dev/ttyUSB0)
  • baudrate: Baud rate for serial communication
  • timeout: Timeout for serial responses (seconds)
Raises
  • RuntimeError: If the serial port cannot be opened or an unexpected error occurs.
  • ValueError: If the serial port is not found or permission is denied.
  • Exception: If an unexpected error occurs while initializing the serial port.
RadEyeDevice(port: str, baudrate: int = 9600, timeout: int = 1)
is_ready: bool

Checks if the device is ready to send and receive commands.

Returns

True if the device is ready, False otherwise.

def close(self) -> None:

Close the serial connection.

def initialise_remote_control(self) -> bool:

Initiates remote control and waiting for the RadEye response.

Returns

True if the remote control is initiated successfully, False otherwise.

Raises
  • RuntimeError: If response from the RadEye is unexpected.
def send_command(self, command: str) -> tuple[bool, typing.Optional[str]]:

Sends a remote control command to the RadEye following the required protocol.

Parameters
  • command: The command string to send.
Returns

(success, response) where success is True if the command is acknowledged and response is the data payload received from the RadEye as a string or None if an error occurs.

Raises
  • RuntimeError: If the command is not acknowledged or an error occurs.
def read_radeye_type( self) -> tuple[typing.Optional[str], typing.Optional[str], typing.Optional[str]]:

Reads the RadEye type, firmware version, and firmware checksum from the device.

Returns

(radeye_type, firmware_version, firmware_checksum)

Raises
  • RuntimeError: If there is an error reading from the device or if the response format is unexpected.
def activate_autosend(self) -> bool:

Activates autosend.

Returns

True if the command is acknowledged, False otherwise.

def deactivate_autosend(self) -> bool:

Deactivates autosend.

Returns

True if the command is acknowledged, False otherwise.

def read_autosend_data(self) -> Optional[AutosendData]:

Reads the autosend data from the RadEye device.

Returns

None if no data was received, otherwise the autosend data as a radeye_comms_sdk.radeye.devices._base.AutosendData instance

def read_serial_no(self) -> Optional[str]:

Read the device serial number.

Returns

The serial number if successful, None otherwise

def read_raw_count_rate(self) -> Optional[list[int]]:

Read raw count rate with dead time correction. Abstract method to be implemented by subclasses.

Returns

None if no data was received, otherwise a list of the raw count rate

def read_filtered_count_rate(self) -> Optional[list[int]]:

Read filtered count rate. Abstract method to be implemented by subclasses.

Returns

None if no data was received, otherwise a list of the filtered count rate

def read_display_value_and_status(self) -> Optional[DisplayStatusData]:

Read values displayed on the device screen and status information. Abstract method to be implemented by subclasses.

Returns

None if no data was received, otherwise a radeye_comms_sdk.radeye.devices._base.DisplayStatusData instance

def read_values(self) -> Optional[list[int]]:

Read measured dose rate. Abstract method to be implemented by subclasses.

Returns

None if no data was received, otherwise a list of the measured dose rate

def read_measurement_units(self) -> Optional[dict[str, str]]:

Read measurement units. Abstract method to be implemented by subclasses.

Returns

None if no data was received, otherwise a dictionary of the parsed units

def get_publisher_info(self) -> dict[int, dict[str, str]]:

Get message publishers for the device. Abstract method to be implemented by subclasses.

Returns

A dictionary of dictionaries {topic name, radiation type, muliplication factor}

@staticmethod
def parse_units(hex_value: str) -> dict[str, str]:

Parses the response based on the given bit description and returns a dictionary of the results.

Parameters
  • hex_value: The hex value response to be parsed.
Returns

A dictionary with the parsed flags and corresponding descriptions: { "Hex_Value": hex_value, "Binary_Value": bin_value, "Flags": flags }

@staticmethod
def safe_int_conversion(value: str) -> Optional[int]:

Safely converts a value to an integer.

Parameters
  • value: The value to convert.
Returns

The converted integer if successful, None if the conversion fails.

@staticmethod
def safe_int_conversion_list(values: Optional[list[str]]) -> Optional[list[int]]:

Safely converts a list of values to a list of integers.

Parameters
  • values: The list of values to convert.
Returns

The converted list of integers if successful, None if the conversion fails.