ska_mid_dish_simulators.devices.dsc_components package

Submodules

ska_mid_dish_simulators.devices.dsc_components.event_loop_utils module

Module for containing event loop utilities.

class EventLoopManager[source]

Bases: ABC

Abstract class with helper methods and variables for asyncio usage.

__init__()[source]
get_task()[source]

Gets the task handle.

Return type:

Task

Returns:

Task handle

async run()[source]

This method should be overridden by subclasses.

start()[source]

Start the task.

Return type:

Task

Returns:

Task handle

stop()[source]

Stop the task.

ska_mid_dish_simulators.devices.dsc_components.motion_loop module

Module containing the dish structure controller servo loop implementation.

exception ReferenceTableEmpty[source]

Bases: Exception

Exception to indicate that the reference table is empty.

class ReferenceTableTracker(max_table_size=10000, get_current_time=<built-in function time>, update_reference_cb=None)[source]

Bases: EventLoopManager

This class is responsible for managing the internal buffer for reference tracking. It tracks the timestamp in the reference table and triggers a callback with reference angles that can drive the servo loop.

The internal table contains the reference entries with the most recent entries first in the list. As points are added to the list, the table’s end index is increased. The internal list is a fixed length circular buffer.

__init__(max_table_size=10000, get_current_time=<built-in function time>, update_reference_cb=None)[source]

Initialises the ReferenceTableTracker class.

Parameters:
  • max_table_size (int) – Maximum internal table size maintained, defaults to TRACK_TABLE_BUFFER_SIZE

  • get_current_time (Callable) – Method to get the timestamp, defaults to time.time

  • update_reference_cb (Optional[Callable[[float, float, float], None]]) – Callback to be made when time crosses timestamps in reference table, defaults to None

property act_index: int

Gets the current index in the table.

Returns:

Current index

property active: bool

Gets the flag which indicates if the tracking loop is active.

Returns:

Tracking active flag

append_to_table(src_table, slen)[source]

Append supplied table to internal circular buffer. Input validation is done to check the size of the table supplied and there is sufficient space available.

Parameters:
  • src_table (List[Tuple[float, float, float]]) – Table to append

  • slen (int) – Length of valid entries to copy

Raises:
  • ValueError – If the length of src_table is not equal to the required TRACK_TABLE_SIZE.

  • ValueError – If there is insufficient space available in the circular buffer.

property end_index: int

Gets the index of the last element in the table.

Returns:

Last index in the table

get_current_table_size()[source]

Gets the current table size.

Return type:

int

Returns:

Table size

get_next_valid_entry()[source]

Iterates through the table to find the next valid entry in the table.

Raises:

ReferenceTableEmpty – If there are no more valid entries in the table

Return type:

List[float]

Returns:

Next valid entry in table

get_space_available()[source]

Gets the space available in the internal table.

Return type:

int

Returns:

Space available

load_new_table(table, slen)[source]

Load a new table into the buffer and reset indexes accordingly.

Parameters:
  • table (List[Tuple[float, float, float]]) – New table to load into the buffer

  • slen (int) – Length of valid entries to copy

Raises:

ValueError – If the table size is not of length TRACK_TABLE_SIZE.

reset_table()[source]

Resets internal table parameters.

async run()[source]

This loop is responsible for tracking the reference table. If tracking is active and points are available in the reference table, this routine will iterate through the available points until a valid point in the future is found, it will then wait to sync up with the reference timestamp and make the callback passing the timestamp, desired azimuth and desired elevation references.

property tracking_complete: bool

Check if all the points in the table have been consumed.

Returns:

Whether tracking has been completed

class ServoLoop(servo_id=None, min_position_limit=None, max_position_limit=None, velocity_limit=None, init_pos=0.0, position_update_cb=None, velocity_update_cb=None, target_reached_cb=None, get_current_time=<built-in function time>)[source]

Bases: EventLoopManager

This class implements the cascaded loop closure for the dish position loop.

__init__(servo_id=None, min_position_limit=None, max_position_limit=None, velocity_limit=None, init_pos=0.0, position_update_cb=None, velocity_update_cb=None, target_reached_cb=None, get_current_time=<built-in function time>)[source]

Initialises the ServoLoop class.

Parameters:
  • servo_id (Optional[str]) – Unique ID for servo, defaults to None

  • min_position_limit (Optional[float]) – Minimum position in degrees allowable, defaults to None

  • max_position_limit (Optional[float]) – Maximum position in degrees allowable, defaults to None

  • velocity_limit (Optional[float]) – Maximum magnitude of velocity in degrees per second, defaults to None

  • init_pos (float) – Starting position in degrees, defaults to 0.0

  • position_update_cb (Optional[Callable[[str, float, float, float], None]]) – Callback that is made when position is updated, defaults to None

  • velocity_update_cb (Optional[Callable[[str, float, float], None]]) – Callback that is made when velocity is updated, defaults to None

  • target_reached_cb (Optional[Callable]) – Callback that is made when target is reached, defaults to None

  • get_current_time (Callable) – Method to get the system timestamp, defaults to time.time

clear_target_reached()[source]

Clear target reached flag.

property error: float

Gets the current position error.

Returns:

Error between desired and actual position (deg)

property moving: bool

Check if the servo is moving i.e. above moving threshold.

Returns:

whether the axis is moving

property position: float

Gets the current position.

Returns:

Current position (deg)

async run()[source]

Wraps the step function in an indefinite loop.

property servo_id: str

Gets the servo ID.

Returns:

Servo ID

step()[source]

Execute one step of position servo loop processing.

Return type:

float

Returns:

Position output

stop_moving()[source]

Stops the servo at the current output by changing the internal reference position to current position.

property target_reached: bool

Check if the target position has been reached within threshold.

Returns:

Whether servo has reached target position

update_desired_position(value)[source]

Update the desired position reference to the internal loop.

Parameters:

value – Desired position (deg)

property velocity: float

Gets the current velocity.

Returns:

Servo velocity (deg/s)

class VelocityLoop(servo_id, time_constant, sampling_time, limit=None, velocity_update_cb=None, get_current_time=<built-in function time>)[source]

Bases: object

This class models the velocity as a first-order dynamic model with saturation limits.

__init__(servo_id, time_constant, sampling_time, limit=None, velocity_update_cb=None, get_current_time=<built-in function time>)[source]

Initialises the VelocityLoop class.

Parameters:
  • servo_id (str) – Unique ID for servo

  • time_constant (float) – First order time constant in seconds

  • sampling_time (float) – Sample time in seconds

  • limit (Optional[float]) – Maximum magnitude of the output velocity, defaults to None

  • velocity_update_cb (Optional[Callable[[str, float, float], None]]) – Callback that is made when the velocity is updated, defaults to None

  • get_current_time (Callable) – Method to get the system timestamp, defaults to time.time

property output: float

Gets the current velocity.

Returns:

Current velocity (deg/s)

step(ref_input)[source]

Execute one step of processing the reference velocity.

Parameters:

ref_input (float) – Reference velocity (deg/s)

Return type:

float

Returns:

Output velocity (deg/s)

Module contents