MTDomeCom#

class lsst.ts.mtdomecom.MTDomeCom(log, config, config_dir, simulation_mode=ValidSimulationMode.NORMAL_OPERATIONS, telemetry_callbacks=None, reject_small_azimuth_motions=False, start_periodic_tasks=True, communication_error=False, timeout_error=False)#

Bases: object

TCP/IP interface to the MTDome controller.

Parameters:
  • log (logging.Logger) – Logger for which a child logger is created.

  • config (SimpleNameSpace) – The configuration to use. This should contain the host name and port to connect to.

  • config_dir (pathlib.Path) – The configuration directory as used by the CSC. This must be the full path including the schema version directory.

  • simulation_mode (ValidSimulationMode) – The simulation mode to use. Defaults to NORMAL_OPERATIONS.

  • telemetry_callbacks (dict`[`LlcName, typing.Callable]) – List of telemetry callback coroutines to use. Defaults to None.

  • reject_small_azimuth_motions (bool) – Reject small azimuth motions or not? Defaults to False.

  • start_periodic_tasks (bool) – Start the periodic tasks or not. Defaults to True. Unit tests may set this to False.

  • communication_error (bool) – Is there a communication error with the rotating part (True) or not (False)? This is for unit tests only. The default is False.

  • timeout_error (bool) – Do command replies timeout of not? This is for unit tests only. The default is False.

Attributes Summary

Methods Summary

check_all_commands_have_replies()

Check if all commands have received a reply.

close_louvers()

Close all louvers.

close_shutter()

Close the shutter.

config_llcs(system, settings)

Config command not to be executed by SAL.

connect()

Connect to the dome controller's TCP/IP port.

crawl_az(velocity)

Crawl AZ.

crawl_el(velocity)

Crawl El.

disconnect()

Disconnect from the TCP/IP controller, if connected, and stop the mock controller, if running.

exit_fault(sub_system_ids)

Indicate that all hardware errors have been resolved.

exit_fault_az()

Indicate that all AMCS hardware errors have been resolved.

exit_fault_el()

Indicate that all LWSCS hardware errors have been resolved.

exit_fault_louvers()

Indicate that all LCS hardware errors have been resolved.

exit_fault_shutter()

Indicate that all ApSCS hardware errors have been resolved.

exit_fault_thermal()

Indicate that all ThCS hardware errors have been resolved.

fans(speed)

Set the speed of the fans.

has_non_status_command()

Check if a non-status command is running.

home(sub_system_ids, direction)

Search the home position of the Aperture Shutter in the indicated direction.

inflate(action)

Inflate or deflate the inflatable seal.

is_moveAz_same_as_current(position, velocity)

Is the received moveAz command the same as the current moveAz command or not.

move_az(position, velocity)

Move AZ.

move_el(position)

Move El.

one_periodic_task(method, interval[, ...])

Run one method forever at the specified interval.

open_shutter()

Open the shutter.

park()

Park the dome.

process_command_queue()

Process the commands in the queue, if there are any.

query_status()

Query the status of all lower level components.

remove_keys_from_dict(...)

Return a copy of a dict with specified items removed.

request_llc_status(llc_name)

Generic method for retrieving the status of a lower level component.

reset_drives_az(reset)

Reset one or more AZ drives.

reset_drives_louvers(reset)

Reset one or more Louver drives.

reset_drives_shutter(reset)

Reset one or more Aperture Shutter drives.

restore_llcs()

set_louvers(position)

Set the positions of the louvers.

set_operational_mode(operational_mode, ...)

Indicate that one or more sub_systems need to operate in degraded or normal state.

set_power_management_mode(power_management_mode)

Set the power management mode.

set_temperature(temperature)

Set the preferred temperature in the dome.

set_zero_az()

Take the current position of the dome as zero.

status_amcs()

AMCS status command.

status_apscs()

ApSCS status command.

status_cbcs()

CBCS status command.

status_cscs()

CSCS status command.

status_lcs()

LCS status command.

status_llc()

LLC status command.

status_lwscs()

LWSCS status command.

status_moncs()

MonCS status command.

status_rad()

RAD status command.

status_thcs()

ThCS status command.

stop_az(engage_brakes)

Stop AZ motion and engage the brakes if indicated.

stop_el(engage_brakes)

Stop EL motion and engage the brakes if indicated.

stop_louvers(engage_brakes)

Stop Louvers motion and engage the brakes if indicated.

stop_shutter(engage_brakes)

Stop Shutter motion and engage the brakes if indicated.

stop_sub_systems(sub_system_ids, engage_brakes)

Stop all motion and engage the brakes if indicated in the data.

update_status_of_non_status_command(status)

Update the status of the non-status command.

write_then_read_reply(command, **params)

Write the cmd string and then read the reply to the command.

Attributes Documentation

connected#

Methods Documentation

async check_all_commands_have_replies()#

Check if all commands have received a reply.

If a command hasn’t received a reply after at least COMMANDS_REPLIED_PERIOD seconds, a warning is logged.

If a command hasn’t received a reply after at least 2 * COMMANDS_REPLIED_PERIOD seconds, an error is logged and the command is removed from the waiting list.

Return type:

None

async close_louvers()#

Close all louvers.

Return type:

None

async close_shutter()#

Close the shutter.

Return type:

None

async config_llcs(system, settings)#

Config command not to be executed by SAL.

This command will be used to send the values of one or more parameters to configure the lower level components.

Parameters:
  • system (LlcName) – The name of the lower level component to configure.

  • settings (dict) –

    A dict containing key,value for all the parameters that need to be configured. The structure is:

    "jmax"
    "amax"
    "vmax"
    

Return type:

None

async connect()#

Connect to the dome controller’s TCP/IP port.

Start the mock controller, if simulating.

Return type:

None

async crawl_az(velocity)#

Crawl AZ.

Parameters:

velocity (float) – The velocity of the target [deg/s].

Return type:

None

Notes

The AMCS expects the velocity in radians/sec. This method takes care the conversion to radians.

async crawl_el(velocity)#

Crawl El.

Parameters:

velocity (float) – The velocity of the target [deg/s].

Return type:

None

Notes

The LWSCS expects the velocity in radians/sec. This method takes care the conversion to radians.

async disconnect()#

Disconnect from the TCP/IP controller, if connected, and stop the mock controller, if running.

Return type:

None

async exit_fault(sub_system_ids)#

Indicate that all hardware errors have been resolved.

Parameters:

sub_system_ids (int) – Bitmask of the sub-systems to exit fault for.

Return type:

None

async exit_fault_az()#

Indicate that all AMCS hardware errors have been resolved.

Return type:

None

async exit_fault_el()#

Indicate that all LWSCS hardware errors have been resolved.

Return type:

None

async exit_fault_louvers()#

Indicate that all LCS hardware errors have been resolved.

Return type:

None

async exit_fault_shutter()#

Indicate that all ApSCS hardware errors have been resolved.

Return type:

None

async exit_fault_thermal()#

Indicate that all ThCS hardware errors have been resolved.

Return type:

None

async fans(speed)#

Set the speed of the fans.

Parameters:

speed (float) – The speed to set.

Return type:

None

async has_non_status_command()#

Check if a non-status command is running.

Returns:

status – True if a non-status command is running, False otherwise.

Return type:

bool

async home(sub_system_ids, direction)#

Search the home position of the Aperture Shutter in the indicated direction.

This is necessary in case the ApSCS (Aperture Shutter Control system) was shutdown with the Aperture Shutter not fully open or fully closed.

Parameters:
  • sub_system_ids (int) – Bitmask of the sub-systems to home.

  • direction (OpenClose) – The direction to home the aperture shutter to.

Return type:

None

async inflate(action)#

Inflate or deflate the inflatable seal.

Parameters:

action (OnOff) – The action to perform.

Return type:

None

is_moveAz_same_as_current(position, velocity)#

Is the received moveAz command the same as the current moveAz command or not.

Parameters:
  • position (float) – The target position to move to.

  • velocity (float) – The velocity at which the target position is moving.

Returns:

False if reject_small_azimuth_motions is False, True if the issued moveAz command is the same as the current moveAz command or False otherwise.

Return type:

bool

Notes

If reject_small_azimuth_motions is False, this method will always return False.

The moveAz command is regarded to be the same as the current one if and only if the position is the same and the velocity is 0.0. In all other cases the command is regarded not to be the same. This is important because, if the velocity != 0.0, the dome is following a moving target and the chance of it being at exactly the commanded position with the commanded velocity can be considered zero and therefore the moveAz command has to be sent to the dome.

The very first moveAz command, when connecting to the low-level controller, always is executed, even if the position matches the current position of the dome. This may lead to a full 360º rotation by the dome, but it is a small risk.

The tolerance for the position is 0.25 deg as specified in LTS-97. The tolerance for the velocity is set to a small but non-zero value. See lsst.ts.mtdomecom.enums for more information.

async move_az(position, velocity)#

Move AZ.

Parameters:
  • position (float) – The current azimuth position of the target [deg].

  • velocity (float) – The velocity of the target [deg/s].

Return type:

None

Notes

The AMCS expects the position in radians and the velocity in radians/s. On top of that, the AMCS internal angle is offset by about 32 degrees east with respect to 0 degrees azimuth. This method takes care of the offset and the conversion to radians.

async move_el(position)#

Move El.

Parameters:

position (float) – The elevation position of the target [deg].

Return type:

None

Notes

The LWSCS expects the position in radians. This method takes care of the conversion to radians.

async one_periodic_task(method, interval, wrap_with_async_task=True)#

Run one method forever at the specified interval.

Parameters:
  • method (typing.Callable) – The periodic method to run.

  • interval (float) – The interval (sec) at which to run the status method.

  • wrap_with_async_task (bool, optional) – Wrap the method in an asyncio task or not. Defaults to True.

Return type:

None

async open_shutter()#

Open the shutter.

Return type:

None

async park()#

Park the dome.

Return type:

None

async process_command_queue()#

Process the commands in the queue, if there are any.

Depending on the power management state, certain commands take precedence over others. Whether a command actually can be issued depends on the expected power draw for the command and the available power for the rotating part of the dome. If a command can be issued then it is removed from the queue, otherwise not.

Return type:

None

async query_status()#

Query the status of all lower level components.

Return type:

None

remove_keys_from_dict(dict_with_too_many_keys, keys_to_remove)#

Return a copy of a dict with specified items removed.

Parameters:
  • dict_with_too_many_keys (dict) – The dict where to remove the keys from.

  • keys_to_remove (set`[`str]) – The keys to remove from the dict.

Returns:

dict_with_keys_removed – A dict with the same keys as the given dict but with the given keys removed.

Return type:

dict

async request_llc_status(llc_name)#

Generic method for retrieving the status of a lower level component.

The status also is pre_processed, meaning prepared for further processing downstream.

Parameters:

llc_name (LlcName) – The name of the lower level component.

Return type:

None

async reset_drives_az(reset)#

Reset one or more AZ drives.

This is necessary when exiting from FAULT state without going to Degraded Mode since the drives don’t reset themselves.

Parameters:

reset (list`[`int]) – List of indices of the motors to reset.

Return type:

None

async reset_drives_louvers(reset)#

Reset one or more Louver drives.

This is necessary when exiting from FAULT state without going to Degraded Mode since the drives don’t reset themselves.

Parameters:

reset (list`[`int]) – List of indices of the motors to reset.

Return type:

None

async reset_drives_shutter(reset)#

Reset one or more Aperture Shutter drives.

This is necessary when exiting from FAULT state without going to Degraded Mode since the drives don’t reset themselves.

Parameters:

reset (list`[`int]) – List of indices of the motors to reset.

Return type:

None

async restore_llcs()#
Return type:

None

async set_louvers(position)#

Set the positions of the louvers.

Parameters:

position (array of float) – An array of positions, in percentage with 0 meaning closed and 100 fully open, for each louver. A position of -1 means “do not move”.

Return type:

None

async set_operational_mode(operational_mode, sub_system_ids)#

Indicate that one or more sub_systems need to operate in degraded or normal state.

Parameters:
  • operational_mode (OperationalMode) – The operaitonal mode to set.

  • sub_system_ids (int) – Bitmask of the sub-systems to set the operational mode for.

Return type:

None

async set_power_management_mode(power_management_mode)#

Set the power management mode.

Parameters:

power_management_mode (PowerManagementMode) – The power management mode to set.

Return type:

None

async set_temperature(temperature)#

Set the preferred temperature in the dome.

Parameters:

temperature (float) – The temperature, in degrees Celsius, to set.

Return type:

None

async set_zero_az()#

Take the current position of the dome as zero.

This is necessary as long as the racks and pinions on the drives have not been installed yet to compensate for slippage of the drives.

Return type:

None

async status_amcs()#

AMCS status command.

Return type:

None

async status_apscs()#

ApSCS status command.

Return type:

None

async status_cbcs()#

CBCS status command.

Return type:

None

async status_cscs()#

CSCS status command.

Return type:

None

async status_lcs()#

LCS status command.

Return type:

None

async status_llc()#

LLC status command.

Return type:

None

async status_lwscs()#

LWSCS status command.

Return type:

None

async status_moncs()#

MonCS status command.

Return type:

None

async status_rad()#

RAD status command.

Return type:

None

async status_thcs()#

ThCS status command.

Return type:

None

async stop_az(engage_brakes)#

Stop AZ motion and engage the brakes if indicated. Also disengage the locking pins if engaged.

Parameters:

engage_brakes (bool) – Engage the brakes (true) or not (false).

Return type:

None

async stop_el(engage_brakes)#

Stop EL motion and engage the brakes if indicated. Also disengage the locking pins if engaged.

Parameters:

engage_brakes (bool) – Engage the brakes (true) or not (false).

Return type:

None

async stop_louvers(engage_brakes)#

Stop Louvers motion and engage the brakes if indicated. Also disengage the locking pins if engaged.

Parameters:

engage_brakes (bool) – Engage the brakes (true) or not (false).

Return type:

None

async stop_shutter(engage_brakes)#

Stop Shutter motion and engage the brakes if indicated. Also disengage the locking pins if engaged.

Parameters:

engage_brakes (bool) – Engage the brakes (true) or not (false).

Return type:

None

async stop_sub_systems(sub_system_ids, engage_brakes)#

Stop all motion and engage the brakes if indicated in the data. Also disengage the locking pins if engaged.

Parameters:
  • sub_system_ids (int) – Bitmask of the sub-systems to stop.

  • engage_brakes (bool) – Engage the brakes (True) or not (False).

Return type:

None

async update_status_of_non_status_command(status)#

Update the status of the non-status command.

Parameters:

status (bool) – Set True if running a non-status command. After it is done, set False.

Return type:

None

async write_then_read_reply(command, **params)#

Write the cmd string and then read the reply to the command.

Notes

For the function that calls this method, it might need to call the self.update_status_of_non_status_command() first and set the argument to be True if it is a non-status command. Otherwise, the continuous status commands in self.query_status() will block this in the TCP/IP pipe.

Parameters:
  • command (CommandName) – The command to write.

  • **params (typing.Any) – The parameters for the command. This may be empty.

Returns:

data – A dict of the form {“response”: ResponseCode, “timeout”: TimeoutValue} where “response” can be zero for “OK” or non-zero for any other situation.

Return type:

dict

Raises:

TimeoutError – If waiting for a command reply takes longer than _TIMEOUT seconds.