DAQ receiver subpackage

This subpackage implements Daq Receiver functionality for MCCS.

class DaqComponentManager(daq_id, receiver_interface, receiver_ip, receiver_ports, daq_address, consumers_to_start, skuid_url, logger, max_workers, communication_state_callback, component_state_callback, received_data_callback)

A component manager for a DaqReceiver.

__init__(daq_id, receiver_interface, receiver_ip, receiver_ports, daq_address, consumers_to_start, skuid_url, logger, max_workers, communication_state_callback, component_state_callback, received_data_callback)

Initialise a new instance of DaqComponentManager.

Parameters:
  • daq_id (int) – The ID of this DaqReceiver.

  • receiver_interface (str) – The interface this DaqReceiver is to watch.

  • receiver_ip (str) – The IP address of this DaqReceiver.

  • receiver_ports (str) – The port this DaqReceiver is to watch.

  • daq_address (str) – the address of the DAQ receiver. This is dependent on the communication mechanism used. For gRPC, this is the channel.

  • consumers_to_start (str) – The default consumers to be started.

  • skuid_url (str) – The address at which a SKUID service is running.

  • logger (Logger) – the logger to be used by this object.

  • max_workers (int) – the maximum worker threads for the slow commands associated with this component manager.

  • communication_state_callback (Callable[[CommunicationStatus], None]) – callback to be called when the status of the communications channel between the component manager and its component changes

  • component_state_callback (Callable[..., None]) – callback to be called when the component state changes

  • received_data_callback (Callable[[str, str, str], None]) – callback to be called when data is received from a tile

configure_daq(daq_config)

Apply a configuration to the DaqReceiver.

Parameters:

daq_config (str) – A json containing configuration settings.

Return type:

tuple[ResultCode, str]

Returns:

A tuple containing a return code and a string message indicating status. The message is for information purpose only.

daq_status(task_callback=None)

Provide status information for this MccsDaqReceiver.

Parameters:

task_callback (Optional[Callable]) – Update task state, defaults to None

Return type:

str

Returns:

a task status and response message

get_configuration()

Get the active configuration from DAQ.

Return type:

dict[str, str]

Returns:

The configuration in use by the DaqReceiver instance.

start_bandpass_monitor(argin, task_callback=None)

Start monitoring antenna bandpasses.

The MccsDaqReceiver will begin monitoring antenna bandpasses

and producing plots of the spectra.

Parameters:
  • argin (str) – A json string with keywords - plot_directory Directory in which to store bandpass plots. - monitor_rms Whether or not to additionally produce RMS plots. Default: False. - auto_handle_daq Whether DAQ should be automatically reconfigured, started and stopped without user action if necessary. This set to False means we expect DAQ to already be properly configured and listening for traffic and DAQ will not be stopped when StopBandpassMonitor is called. Default: False. - cadence The time in seconds over which to average bandpass data. Default: 0 returns snapshots.

  • task_callback (Optional[Callable]) – Update task state, defaults to None

Return type:

tuple[TaskStatus, str]

Returns:

a task status and response message

start_communicating()

Establish communication with the DaqReceiver components.

Return type:

None

start_daq(modes_to_start, task_callback=None)

Start data acquisition with the current configuration.

Extracts the required consumers from configuration and starts them.

Parameters:
  • modes_to_start (str) – A comma separated string of daq modes.

  • task_callback (Optional[Callable]) – Update task state, defaults to None

Return type:

tuple[TaskStatus, str]

Returns:

a task status and response message

stop_bandpass_monitor(task_callback=None)

Stop monitoring antenna bandpasses.

The MccsDaqReceiver will cease monitoring antenna bandpasses

and producing plots of the spectra.

Parameters:

task_callback (Optional[Callable]) – Update task state, defaults to None

Return type:

tuple[ResultCode, str]

Returns:

a ResultCode and response message

stop_communicating()

Break off communication with the DaqReceiver components.

Return type:

None

stop_daq(task_callback=None)

Stop data acquisition.

Stops the DAQ receiver and all running consumers.

Parameters:

task_callback (Optional[Callable]) – Update task state, defaults to None

Return type:

tuple[ResultCode, str]

Returns:

a task status and response message

class DaqHealthModel(component_state_callback)

A health model for a Daq receiver.

__init__(component_state_callback)

Initialise a new instance.

Parameters:

component_state_callback (Callable[..., None]) – callback to be called whenever there is a change to this component’s state, including the health model’s evaluated health state.

evaluate_health()

Compute overall health of the Daq receiver.

Return type:

HealthState

Returns:

an overall health of the Daq receiver.

class DaqSimulator

An implementation of a DaqSimulator device.

__init__()

Initialise this device.

configure(config)

Apply a configuration to the DaqReceiver.

Parameters:

config (dict[str, Any]) – the configuration to apply

Return type:

tuple[ResultCode, str]

Returns:

a resultcode, message tuple

create_plotting_directory(parent, station_name)

Create plotting directory structure for this station.

This method will always return True unless parent==”invalid_directory”

Parameters:
  • parent (str) – Parent plotting directory

  • station_name (str) – Station name

Return type:

bool

Returns:

False if parent==”invalid_directory” else True

get_configuration()

Retrieve the current DAQ configuration.

Return type:

dict[str, Any]

Returns:

a configuration dictionary.

get_status()

Provide status information for this MccsDaqReceiver.

This method returns status as a json string with entries for:
  • Running Consumers: [DaqMode.name: str, DaqMode.value: int]

  • Receiver Interface: “Interface Name”: str

  • Receiver Ports: [Port_List]: list[int]

  • Receiver IP: “IP_Address”: str

Return type:

dict[str, Any]

Returns:

A json string containing the status of this DaqReceiver.

initialise(config)

Initialise a new DaqReceiver instance.

Parameters:

config (dict[str, Any]) – the configuration to apply

Return type:

tuple[ResultCode, str]

Returns:

a resultcode, message tuple

property initialised: bool

Return whether the simulated DAQ is initialised.

Returns:

whether the simulated DAQ is initialised.

start(modes_to_start)

Start data acquisition with the current configuration.

A infinite streaming loop will be started until told to stop. This will notify the client of state changes and metadata of files written to disk, e.g. data_type.`file_name`.

Parameters:

modes_to_start (str) – string listing the modes to start.

Yield:

a status update.

Return type:

Iterator[str | tuple[str, str, str]]

start_bandpass_monitor(argin)

Start monitoring antenna bandpasses.

The MccsDaqReceiver will begin monitoring antenna bandpasses

and producing plots of the spectra.

Parameters:

argin (str) – A json dictionary with keywords - plot_directory Directory in which to store bandpass plots. - monitor_rms Whether or not to additionally produce RMS plots. Default: False. - auto_handle_daq Whether DAQ should be automatically reconfigured, started and stopped without user action if necessary. This set to False means we expect DAQ to already be properly configured and listening for traffic and DAQ will not be stopped when StopBandpassMonitor is called. Default: False.

Yields:

a task status and response message. Optionally also bandpass data for both polarisations and rms data.

Return type:

Iterator[tuple[TaskStatus, str, Optional[str], Optional[str], Optional[str]]]

stop()

Stop data acquisition.

Return type:

tuple[ResultCode, str]

Returns:

a resultcode, message tuple

stop_bandpass_monitor()

Stop monitoring antenna bandpasses.

Return type:

tuple[ResultCode, str]

Returns:

a resultcode, message tuple

class MccsDaqReceiver(*args, **kwargs)

An implementation of a MccsDaqReceiver Tango device.

Configure(argin)

Configure the DaqReceiver.

Applies the specified configuration to the DaqReceiver.

Parameters:

argin (str) – A JSON string containing the daq configuration to apply.

Return type:

tuple[list[ResultCode], list[Optional[str]]]

Returns:

A tuple containing a return code and a string message indicating status. The message is for information purpose only.

Example:
>>> daq = tango.DeviceProxy("low-mccs/daqreceiver/001")
>>> daq_config = {
    "receiver_ports": "4660",
    "receiver_interface": "eth0",
}
>>> daq.Configure(json.dumps(daq_config))
class ConfigureCommand(component_manager, logger=None)

Class for handling the Configure(argin) command.

__init__(component_manager, logger=None)

Initialise a new ConfigureCommand instance.

Parameters:
  • component_manager – the device to which this command belongs.

  • logger (Optional[Logger]) – a logger for this command to use.

do(argin)

Implement MccsDaqReceiver.ConfigureCommand command functionality.

Parameters:

argin (str) – A configuration dictionary.

Return type:

tuple[ResultCode, str]

Returns:

A tuple containing a return code and a string message indicating status. The message is for information purpose only.

DaqStatus()

Provide status information for this MccsDaqReceiver.

This method returns status as a json string with entries for:
  • Daq Health: [HealthState.name: str, HealthState.value: int]

  • Running Consumers: [DaqMode.name: str, DaqMode.value: int]

  • Receiver Interface: “Interface Name”: str

  • Receiver Ports: [Port_List]: list[int]

  • Receiver IP: “IP_Address”: str

Return type:

str

Returns:

A json string containing the status of this DaqReceiver.

Example:
>>> daq = tango.DeviceProxy("low-mccs/daqreceiver/001")
>>> jstr = daq.DaqStatus()
>>> dict = json.loads(jstr)
class DaqStatusCommand(component_manager, logger=None)

A class for the MccsDaqReceiver’s DaqStatus() command.

__init__(component_manager, logger=None)

Initialise a new instance.

Parameters:
  • component_manager – the device to which this command belongs.

  • logger (Optional[Logger]) – a logger for this command to use.

do()

Stateless hook for device DaqStatus() command.

Return type:

str

Returns:

The status of this Daq device.

GetConfiguration()

Get the Configuration from DAQ.

Return type:

str

Returns:

A JSON-encoded dictionary of the configuration.

Example:
>>> daq = tango.DeviceProxy("low-mccs/daqreceiver/001")
>>> jstr = daq.GetConfiguration()
>>> dict = json.loads(jstr)
class GetConfigurationCommand(component_manager, logger=None)

Class for handling the GetConfiguration() command.

__init__(component_manager, logger=None)

Initialise a new GetConfigurationCommand instance.

Parameters:
  • component_manager – the device to which this command belongs.

  • logger (Optional[Logger]) – a logger for this command to use.

do()

Implement MccsDaqReceiver.GetConfiguration() command.

Return type:

str

Returns:

The configuration as received from pydaq

class InitCommand(*args, **kwargs)

Implements device initialisation for the MccsDaqReceiver device.

do(*args, **kwargs)

Initialise the attributes and properties.

Parameters:
  • args (Any) – Positional arg list.

  • kwargs (Any) – Keyword arg list.

Return type:

tuple[ResultCode, str]

Returns:

A tuple containing a return code and a string message indicating status. The message is for information purpose only.

SetConsumers(argin)

Set the default list of consumers to start.

Sets the default list of consumers to start when left unspecified in the start_daq command.

Parameters:

argin (str) – A string containing a comma separated list of DaqModes.

Return type:

tuple[list[ResultCode], list[Optional[str]]]

Returns:

A tuple containing a return code and a string message indicating status. The message is for information purpose only.

Example:
>>> daq = tango.DeviceProxy("low-mccs/daqreceiver/001")
# pylint: disable=line-too-long
>>> consumers = "DaqModes.INTEGRATED_BEAM_DATA,ANTENNA_BUFFER, BEAM_DATA," # noqa: E501
>>> daq.SetConsumers(consumers)
class SetConsumersCommand(component_manager, logger=None)

Class for handling the SetConsumersCommand(argin) command.

__init__(component_manager, logger=None)

Initialise a new SetConsumersCommand instance.

Parameters:
  • component_manager – the device to which this command belongs.

  • logger (Optional[Logger]) – a logger for this command to use.

do(argin)

Implement MccsDaqReceiver.SetConsumersCommand functionality.

Parameters:

argin (str) – A string containing a comma separated list of DaqModes.

Return type:

tuple[ResultCode, str]

Returns:

A tuple containing a return code and a string message indicating status. The message is for information purpose only.

Start(argin='')

Start the DaqConsumers.

The MccsDaqReceiver will begin watching the interface specified in the

configuration and will start the configured consumers.

Parameters:

argin (str) – A json dictionary with optional keywords. ‘{“modes_to_start”}’.

Return type:

tuple[list[ResultCode], list[Optional[str]]]

Returns:

A tuple containing a return code and a string message indicating status. The message is for information purpose only.

Example:
>>> daq = tango.DeviceProxy("low-mccs/daqreceiver/001")
>>> argin = '{"modes_to_start": "INTEGRATED_CHANNEL_DATA,
RAW_DATA"}'
>>> daq.Start(argin) # use specified consumers
>>> daq.Start("") # Uses default consumers.
StartBandpassMonitor(argin)

Start monitoring antenna bandpasses.

The MccsDaqReceiver will begin monitoring antenna bandpasses

and producing plots of the spectra.

Parameters:

argin (str) – A json dictionary with keywords. - plot_directory Directory in which to store bandpass plots. - monitor_rms Whether or not to additionally produce RMS plots. Default: False. - auto_handle_daq Whether DAQ should be automatically reconfigured, started and stopped without user action if necessary. This set to False means we expect DAQ to already be properly configured and listening for traffic and DAQ will not be stopped when StopBandpassMonitor is called. Default: False. - cadence The time in seconds over which to average bandpass data. Default: 0 returns snapshots.

Return type:

tuple[list[ResultCode], list[Optional[str]]]

Returns:

A tuple containing a return code and a string message indicating status. The message is for information purpose only.

Stop()

Stop the DaqReceiver.

The DAQ receiver will cease watching the specified interface and will stop all running consumers.

Return type:

tuple[list[ResultCode], list[Optional[str]]]

Returns:

A tuple containing a return code and a string message indicating status. The message is for information purpose only.

Example:
>>> daq = tango.DeviceProxy("low-mccs/daqreceiver/001")
>>> daq.Stop()
StopBandpassMonitor()

Stop monitoring antenna bandpasses.

The MccsDaqReceiver will cease monitoring antenna bandpasses

and producing plots of the spectra.

Return type:

tuple[list[ResultCode], list[Optional[str]]]

Returns:

A tuple containing a return code and a string message indicating status. The message is for information purpose only.

class StopBandpassMonitorCommand(component_manager, logger=None)

Class for handling the StopBandpassMonitorCommand() command.

__init__(component_manager, logger=None)

Initialise a new StopBandpassMonitorCommand instance.

Parameters:
  • component_manager – the device to which this command belongs.

  • logger (Optional[Logger]) – a logger for this command to use.

do()

Implement MccsDaqReceiver.SetConsumersCommand functionality.

Stop monitoring antenna bandpasses.

The MccsDaqReceiver will cease monitoring antenna bandpasses

and producing plots of the spectra.

Return type:

tuple[ResultCode, str]

Returns:

A tuple containing a return code and a string message indicating status. The message is for information purpose only.

class StopCommand(component_manager, logger=None)

Class for handling the Stop() command.

__init__(component_manager, logger=None)

Initialise a new StopCommand instance.

Parameters:
  • component_manager – the device to which this command belongs.

  • logger (Optional[Logger]) – a logger for this command to use.

do()

Implement MccsDaqReceiver.StopCommand command functionality.

Return type:

tuple[ResultCode, str]

Returns:

A tuple containing a return code and a string message indicating status. The message is for information purpose only.

__init__(*args, **kwargs)

Initialise this device object.

Parameters:
  • args (Any) – positional args to the init

  • kwargs (Any) – keyword args to the init

create_component_manager()

Create and return a component manager for this device.

Return type:

DaqComponentManager

Returns:

a component manager for this device.

dataReceivedResult()

Read the result of the receiving of data.

Return type:

tuple[str, str]

Returns:

A tuple containing the data mode of transmission and a json string with any additional data about the data such as the file name.

init_command_objects()

Initialise the command handlers for commands supported by this device.

Return type:

None

init_device()

Initialise the device.

This is overridden here to change the Tango serialisation model.

Return type:

None

rmsPlot()

Read the last rms plot filepath.

Return type:

ndarray

Returns:

The last block of rms data.

xPolBandpass()

Read the last bandpass plot data for the x-polarisation.

Return type:

ndarray

Returns:

The last block of x-polarised bandpass data.

yPolBandpass()

Read the last bandpass plot data for the y-polarisation.

Return type:

ndarray

Returns:

The last block of y-polarised bandpass data.