Spectrum analyser subpackage (ska_ser_test_equipment.spectrum_analyser)

This subpackage implements monitoring and control of spectrum analysers.

class ska_ser_test_equipment.spectrum_analyser_anritsu.SpectrumAnalyserComponentManagerAnritsu(interface_definition, protocol, host, port, logger, communication_state_callback, component_state_callback, update_rate=5.0)

A component manager for a spectrum analyser.

__init__(interface_definition, protocol, host, port, logger, communication_state_callback, component_state_callback, update_rate=5.0)

Initialise a new instance.

Parameters:
  • interface_definition (InterfaceDefinitionType) – definition of the spectrum analyser’s SCPI interface.

  • protocol (Literal['tcp', 'telnet']) – the network protocol to be used to communicate with the spectrum analyser.

  • host (str) – the host name or IP address of the spectrum analyser.

  • port (int) – the port of the spectrum analyser.

  • logger (Logger) – a logger for this component manager to use for logging.

  • communication_state_callback (Callable) – callback to be called when the status of communications between the component manager and its component changes.

  • component_state_callback (Callable) – callback to be called when the state of the component changes.

  • update_rate (float) – how often updates to attribute values should be provided. This is not necessarily the same as the rate at which the instrument is polled. For example, the instrument may be polled every 0.1 seconds, thus ensuring that any invoked commands or writes will be executed promptly. However, if the update_rate is 5.0, then routine reads of instrument values will only occur every 50th poll (i.e. every 5 seconds).

acquire(task_callback=None)

Collect a new trace.

Depending on the configuration of the spectrum analyser, this could be a long-running operation - for instance if the trace is configured to average over a number of samples.

Parameters:

task_callback (Optional[Callable]) – callback to be called when the status of the command changes.

Return type:

Tuple[TaskStatus, str]

Returns:

the task status and a message.

get_request()

Return the reads and writes to be executed in the next poll.

Return type:

AttributeRequest

Returns:

reads and writes to be executed in the next poll.

get_trace(task_callback=None)

Get a trace.

Parameters:

task_callback (Optional[Callable]) – callback to be called when the status of the command changes.

Return type:

None

off(task_callback=None)

Turn the component off.

Parameters:

task_callback (Optional[Callable]) – callback to be called when the status of the command changes.

Raises:

NotImplementedError – because this command is not yet implemented.

Return type:

Tuple[TaskStatus, str]

on(task_callback=None)

Turn the component on.

Parameters:

task_callback (Optional[Callable]) – callback to be called when the status of the command changes.

Raises:

NotImplementedError – because this command is not yet implemented.

Return type:

Tuple[TaskStatus, str]

poll(poll_request)

Poll the hardware.

Connect to the hardware, write any values that are to be written, and then read all values.

Parameters:

poll_request (AttributeRequest) – specification of the reads and writes to be performed in this poll.

Return type:

AttributeResponse

Returns:

responses to queries in this poll.

poll_succeeded(poll_response)

Handle the receipt of new polling values.

This is a hook called by the poller when values have been read during a poll.

Parameters:

poll_response (AttributeResponse) – response to the pool, including any values read.

Return type:

None

polling_stopped()

Respond to polling having stopped.

This is a hook called by the poller when it stops polling.

Return type:

None

reset(task_callback=None)

Reset the component (from fault state).

Parameters:

task_callback (Optional[Callable]) – callback to be called when the status of the command changes.

Return type:

Tuple[TaskStatus, str]

Returns:

the task status and a message.

send_receive(attribute_request)

Send an attribute request, and receive an attribute response.

Parameters:

attribute_request (AttributeRequest) – details of the attribute request to be sent.

Return type:

AttributeResponse

Returns:

details of the attribute response.

standby(task_callback=None)

Put the component into low-power standby mode.

Parameters:

task_callback (Optional[Callable]) – callback to be called when the status of the command changes.

Raises:

NotImplementedError – because this command is not yet implemented.

Return type:

Tuple[TaskStatus, str]

write_attribute(**kwargs)

Update spectrum analyser attribute value(s).

This doesn’t actually immediately write to the spectrum analyser. It only stores the details of the requested write where it will be picked up by the next iteration of the polling loop.

Parameters:

kwargs (Any) – keyword arguments specifying attributes to be written along with their corresponding value.

Return type:

None

write_command(*cmds)

Enqueue a no-argument SCPI command to be executed next poll.

Parameters:

cmds (str) – SCPI commands to enqueue as named in the device definition YAML file.

Return type:

None

class ska_ser_test_equipment.spectrum_analyser_anritsu.SpectrumAnalyserDeviceAnritsu(*args, **kwargs)

The device.

adminMode(value)

Control device status.

Parameters:

value (bool) – new mode

Return type:

None

attenuation(value)

Set value for Input Attenuation.

Parameters:

value (int) – new attenuation in dBm

Return type:

None

attribute_poll(attr_name)

Check if instrument should be read.

Parameters:

attr_name (str) – attribute name to be checked

Return type:

bool

Returns:

flag to indicate polling in progress

autoattenuation(value)

Set status of automatic attenuation.

Parameters:

value (bool) – new status

Return type:

None

clear_markers()

Set all markers to off.

Return type:

None

command_error()

Get command error.

Return type:

Optional[bool]

Returns:

current flag value

continuous(value)

Specify whether the sweep/measurement is triggered continuously.

Parameters:

value (bool) – new value

Return type:

None

create_component_manager()

Create and return a component manager for this device.

Return type:

None

device_error()

Get device error.

Return type:

Optional[bool]

Returns:

current flag value

execution_error()

Get execution error.

Return type:

Optional[bool]

Returns:

current flag value

flag_when_complete(value)

Set OPC bit of Standard Event Status Register on next transition of No Op.

Parameters:

value (bool) – new value

Return type:

None

frequency_start(value)

Get Start Frequency.

Parameters:

value (int) – new value

Return type:

None

frequency_stop(value)

Set Stop Frequency.

Parameters:

value (int) – new value

Return type:

None

hostInfo()

Get information about host.

Return type:

str

Returns:

host name and port number

identity()

Get manufacturer name, model number, serial number, and firmware package number.

Return type:

str

Returns:

identity string

init_command_objects()

Register command objects (handlers) for this device’s commands.

Return type:

None

init_device()

Initialize the device.

Raises:

ValueError – when YAML file can not be read

Return type:

None

loggingLevel(log_lvl)

Set logging level.

Parameters:

log_lvl (int) – integer value zero to five

marker_find_peak()

Move X value to point in marker’s assigned trace that has highest peak.

Return type:

None

marker_frequency(value)

Set marker frequency.

Parameters:

value (int) – marker frequency in Hz

Return type:

None

marker_power(value)

Set amplitude value.

Parameters:

value (float) – new amplitude value in dBm

Return type:

None

maximum_value_check(attr_name, attr_value)

Check attribute value.

Parameters:
  • attr_name (str) – attribute name

  • attr_value (float | int) – attribute value

Return type:

bool

Returns:

true if value is greater than configured maximum

minimum_value_check(attr_name, attr_value)

Check attribute value.

Parameters:
  • attr_name (str) – attribute name

  • attr_value (float | int) – attribute value

Return type:

bool

Returns:

true if value is less than configured minimum

operation_complete()

Get operation complete.

Return type:

Optional[bool]

Returns:

current flag value

power_cycled()

Get power cycled.

Return type:

Optional[bool]

Returns:

current flag value

preamp_enabled(value)

Set state of the preamp.

Parameters:

value (bool) – new value

Return type:

None

query_error()

Get query error.

Return type:

Optional[bool]

Returns:

current flag value

rbw(value)

Set resolution bandwidth.

Parameters:

value (float) – resolution bandwidth in Hz

Return type:

None

rbw_auto(value)

Set state of the coupling of the resolution bandwidth to the frequency span.

Parameters:

value (bool) – new value

Return type:

None

reference_level(value)

Set Reference Level.

Parameters:

value (int) – new value

Return type:

None

reset()

Press the reset button.

Return type:

None

sweep_points(value)

Set number of display points.

Parameters:

value (int) – new value for number of display points

Return type:

None

trace1()

Get trace data.

Trace data uses SCPI standard (IEEE 488.2) block data format. The data format is ‘#AXD’, where D is a comma separated list of amplitudes (in ASCII), X is one or more ASCII digits specifying the number of bytes in D, and A is a single ASCII digit specifying the number of digits in X.

Return type:

str

Returns:

list of float values

trace1_bin()

Get trace data.

Return type:

DevVarFloatArray

Returns:

list of float values

trace_format(value)

Set format in which data is returned.

Valid values are <ASCii|INTeger|REAL>,[<32|64>]

Parameters:

value (str) – new value

Return type:

None

vbw(value)

Set video bandwidth.

Parameters:

value (float) – new value for video bandwidth in Hz

Return type:

None

vbw_auto(value)

Set state of coupling of video bandwidth to resolution bandwidth.

Parameters:

value (bool) – new value

Return type:

None

class ska_ser_test_equipment.spectrum_analyser_anritsu.SpectrumAnalyserSimulatorAnritsu(model, **kwargs)

A spectrum analyser simulator TCP server.

__init__(model, **kwargs)

Initialise a new spectrum analyser simulator.

Parameters:
  • model (str) – the model identifier to use.

  • kwargs (bool | float | int | str | list[float | int | number[Any]]) – initial values for simulator attributes; where an initial value is not provided for an attribute, a default value will be used.

add_marker(mk_flag=None)

Add a marker.

Parameters:

mk_flag (Optional[bool]) – marker flag

Return type:

None

clear_markers()

Clear all markers.

Return type:

None

flag_when_complete(c_flag=None)

Raise a flag when command is complete.

Parameters:

c_flag (Optional[bool]) – value to set

Return type:

bool

Returns:

current value

get_trace()

Get a trace.

Return type:

None

marker_find_peak()

Set marker_frequency and marker_power based on the current trace’s peak.

Return type:

None

marker_frequency(mark_freq=None)

Return the frequency of the peak.

This method overrides the default behaviour (simply reading the attribute value) to ensure that the number of markers is checked first.

Parameters:

mark_freq (Optional[float]) – marker frequency in Hz

Return type:

Optional[float]

Returns:

the frequency of the peak, or None if the marker has not been added.

marker_power(mark_pwr=None)

Return the power at the peak.

This method overrides the default behaviour (simply reading the attribute value) to ensure that the number of markers is checked first.

Parameters:

mark_pwr (Optional[float]) – marker power in dBm

Return type:

Optional[float]

Returns:

the power at the peak, or None if the marker has not been added.

operation_complete()

Return whether all previous operations are complete.

This only returns true if flag_when_complete() was called while the operation was running, and the operation is now complete.

Return type:

bool

Returns:

whether all previous operations are complete.

reset()

Reset to factory default values.

Return type:

None

trace1()

Read trace data.

Return type:

str

Returns:

trace data buffer