radloggerpy.device.device module

class radloggerpy.device.device.Device(info: Type[_U], condition: Condition)[source]

Bases: object

Abstract class all radiation monitoring devices should implement

INTERFACE = None

Each radiation monitoring device should use a specific interface

NAME = 'Device'

Each radiation monitoring device should have a unique name

TYPE = 1

Each radiation monitoring device should define its type

class _U

Bound to radloggerpy.database.objects.device.DeviceObject

alias of TypeVar(‘_U’, bound=DeviceObject)

_abc_impl = <_abc._abc_data object>
abstract _init()[source]

Method to perform device initialization

Devices are allowed to clear any flags or variables set when stop() was called previously inside of this method.

abstract _run()[source]

Method to be called to run continuously in its own thread

Devices should not return from this method unless the intent is for the device to stop retrieving data. Data can be gathered by either polling or using events / wait if the external system supports to do so. Timers may also be used, please be sure to honor: CONF.devices.minimal_polling_delay

get_data()[source]

Return a collection of radiation monitoring data if any is available

Retrieves the currently stored collection of radiation monitoring data and subsequently clears it.

Returns:

Collection of RadiationReading objects

Return type:

List of :py:class: ‘~.RadiationReading’ instances

get_state()[source]

Return the current statemachine state

has_data()[source]

Wrapper around internal buffer

abstract is_stopping()[source]

Should return true if in the progress of stopping false otherwise

Returns:

True if stopping, false otherwise

run()[source]

Entry point for devices to initialize and start running

Serves as the entry point for devices and calls _init and _run. In addition handles any required state transitions

Any exception encountered will be raised so DeviceManager can handle it appropriately.

abstract stop()[source]

Method when called that should halt operation of device asap

Halting can be achieved by setting a variable and checking this variable inside a loop in the _run method. Other methods include using conditions to notify the _run method.