The TCSInterface Class

The DOS interface to the Mayall TCS.

This program can also use the simluator tcs_sim_ephem.py. To use the simulator, the “controller_type” option in the defaults should be set to “SIMULATOR”. The tcs_sim_ephem.py program should be used to simulate the TCS on the other side of the socket connecion. The connection information for this server should be supplied as the tcs_host and tcs_port defaults.

Configuration parameters (in self.config either via defaults, command line or config.ini file):
  • tcs_host (str, optional, default = localhost) The address of the TCS
  • tcs_port (int, optional, default = 9877) The port the TCS’s socket connection is on
  • redis_host (str, optional, default = localhost) The address of the TCS’s redis connection
  • redis_port (int, optional, default = 6379) The port the TCS’s redis connection
  • controller_type (str, optional, default = SIMULATOR) The system being connected to
  • poll_delay (list, optional, default = 2.0) The delay times in seconds for the loop of the telemetry thread
  • infot_update (str, optional, default = periodic) Update style of the telemetry thread. Options are periodic, onchange, and never
  • watchdog (str, optional, default = disarmed) The initial state of the watchdog, either disarmed or armed
  • print_corrections (boolean, optional, default = False) Whether or not to print guide corrections as they occur
  • slew_threshold (float, optional, default = 5.0) The amount of time left in a slew at which to signal that the slew is ending (in seconds)

The shared variables published by this application are:

  • INFOT - Telemetry dictionary
  • TRACKING - Reports whether or not the telescope is tracking
  • INCONTROL - Reports whether or not the telescope mount is in control
  • INPOS - Reports whether or not the telescope mount is in position
  • SLEWING - Reports whether or not the telescope is slewing
  • SLEWENDING - Reports whether or not the slew is ending
  • STATUS - the status of the application
Version History
2015/11/04 kh Initial version
2016/01/11 kh Mayall TCS test
2018/06/23 kh Mock observing
class TCSInterface.TCSInterface.TCSInterface(device_mode=False, noSVE=None, **extra_args)
commands = ['configure', 'get', 'set', 'stop', 'track', 'whitespot', 'zenith', 'move_telescope', 'offset_mount', 'guide_correction', 'hexapod_position', 'abort_slew', 'send_tcs_command', 'send_tcs_cmd']

PML accessible commands

defaults = {'controller_type': 'SIMULATOR', 'infot_update': 'periodic', 'poll_delay': 10.0, 'print_corrections': False, 'redis_host': 'mayall-db.kpno.noao.edu', 'redis_port': 6379, 'slew_threshold': 5.0, 'tcs_host': 'localhost', 'tcs_port': 9877, 'watchdog': 'disarmed'}

Default configuration parameters

init()

Initialize the TCSInterface application. Set up variables, discovery. Connect to the TCS

Parameters:None
Returns:SUCCESS (str)
configure(constants='DEFAULT')

Restore the system to its base state. Re-establich TCS connections

Parameters:None
Keyword Arguments:
 constants (str) – constants version to be loaded (not used by this application)
Raises:RuntimeError – Problems connecting to TCS

Returns: SUCCESS (str)

offset_mount(east, north)

Add an offset to the current mount position. The offsets have to be given in float arcseconds. The TCS will add this to mount_offset_ra/dec. The target position will not be changed

Parameters:
  • east (float) – Correction to mount RA in arcseconds
  • north (float) – Correction to mount declination in arcseconds
Raises:

RuntimeError – TCSInterface is is the wrong state, invalid corrections

Returns:

TCS response (str)

guide_correction(delta_ra=None, delta_dec=None)

Add a correction to the current pointing, in terms of RA and declination in arcsecs

Parameters:
  • delta_ra (float) – Correction to RA in arcseconds
  • delta_dec (float) – Correction to declination in arcseconds
Raises:

RuntimeError – TCSInterface is is the wrong state, invalid corrections

Returns:

TCS response (str)

hexapod_position(**position)

Send current hexapod position to TCS.

Parameters:

None

Keyword Arguments:
 
  • x (float) – Hexapod x position
  • y (float) – Hexapod y position
  • z (float) – Hexapod z position
  • tip (float) – Hexapod tip angle
  • tilt (float) – Hexapod tilt angle
  • rot (float) – Hexapod rot angle
Raises:

RuntimeError – TCSInterface not in correct state, invalid arguments

Returns:

TCS response (str)

get(what, expid=None)

Retrieve information about the TCSInterface application and the TCS at runtime. Allowed values include: status, target_position, position, version, info, tcs_status, target_position, sky_position, last_correction, last_hexapod, poll_delay,watchdog, slewing, any parameter in self.config

Parameters:what (str) – Variable or attribute to return
Keyword Arguments:
 expid (int) – exposure number (optional)
Raises:RuntimeError – Invalid argument, unexpected results
Returns:The current value of the requested variable/attribute
whitespot()

Position the telescope to point to the flatfield screen. Tracking will be turned off.

Parameters:None
Raises:RuntimeError – TCSInterface in wrong state, unexpected result
Returns:TCS response (str)
zenith()

Position the telescope to zenith. Tracking will be turned off.

Parameters:None
Raises:RuntimeError – TCSInterface in wrong state, unexpected result
Returns:TCS response (str)
move_telescope(**where)

Absolute or relative repositioning of telescope. Keyword arguments (**where) are used to specify the coordinates. A few special keywords are supported as well:

  • epoch (default is 2000 but this might not be the default for the Mayall TCS (current epoch))
  • sexagesimal (coordinates specified as sexagesimal strings or float degrees; the default is sexagesimal unless AZ/EL, east/north, delta_ra/delta_dec are used)
  • track (defaults to True for RA/DEC and offsets otherwise the telescope is not tracking after the slew)
  • type mount/target/guide_corections (only used for offsets - you can also call offset_mount directly)
  • whitespot (if True move telescope to whitespot and ignore other coordinates)
  • zenith (if True move telescope to zenith and ignore other coordinates)

The software parses the coordinates to set the sexigesimal flag automatically if not specifically given.

Using anything but ra,dec,epoch will instruct the TCS to stop tracking. The next move command that uses ra, dec, epoch will restart tracking.

The target coordinates must be specified using one of the following sets of coordinates pairs:

  • ra, dec - (telescope will track)
  • ha, dec - (tracking will be stopped unless tracking = YES is given)
  • az, el - (tracking will be stopped unless tracking = YES is given)
  • offsets: +/-east/+/-north, n/s, e/w, delta_ra, delta_dec - (telescope will track)
Keyword Arguments:
 
  • ra (float, str) – Right ascension coordinate to move to. Must be given as float or sexagesimal string (xx:xx:xx.xx)
  • dec (float, str) – Declination coordinate to move to. Must be given as float or sexagesimal string (xx:xx:xx.xx)
  • ha (float, str) – Hour angle to move to. Must be given as float or sexagesimal string (xx:xx:xx.xx)
  • az (float, str) – Azimuth coordinate to move to. Must be given as float or sexagesimal string (xx:xx:xx.xx)
  • el (float, str) – Elevation coordinate to move to. Must be given as float or sexagesimal string (xx:xx:xx.xx)
  • north (float) – North offset to apply.
  • east (float) – The east offset to apply.
  • delta_ra (float) – The RA offset to apply.
  • delta_dec (float) – The DEC offset to apply.
  • N (float) – The North coordinate to move to.
  • S (float) – The South coordinate to move to.
  • E (float) – The East coordinate to move to.
  • W (float) – The West coordinate to move to.
  • epoch (float) – The epoch for the coordinates, default is 2000
  • whitespot (bool) – Move telescope to whitespot if True
  • zenith (bool) – Move telescipe to zenith if True
  • sexagesimal (bool) – Whether or not the coordinates are sexagesimal. no/False means they are in decimal degrees; yes/True means they are given as sexigesimal string
  • type (str) – Only used with offsets to distinguish mount, guide_correction and target offsets.
  • track (bool) – Whether the telescope should be tracking after the slew or not.
Raises:

RuntimeError – TCSInterface in wrong state, invalid arguments, unexpected result

Returns:

Response from TCS (str)

set(**options)

Set information about the TCSInterface application and the TCS at runtime passed as key/value pairs. Allowed keys include:: poll_delay, infot_update, watchdog (armed (true) or disarmed (false)), tracking on/off, any configure key

Parameters:options (dict) – Key/value pairs of variables and attributes to set
Raises:RuntimeError – Invalid parameters
Returns:SUCCESS (str)
send_tcs_command(*args, **kwargs)

alias for send_tcs_cmd

send_tcs_cmd(move_string=None, **kwargs)

Send a command string directly to the TCS. If move_string is None, the command will be constructed based on the keyword arguments provided (**kwargs) The move_string will simply be the concatenation of the key/value pairs provided in **kwargs.

Keyword Arguments:
 
  • move_string (str) – Command (including parameters) send to the TCS
  • key/value (other) – If move_string is not given, all other key/value pairs provided will be combined to form the move_string.
Raises:

RuntimeError – Invalid arguments, TCSInterface in wrong state

Returns:

TCS response (str)

abort_slew()

Stop waiting for the telescope to get into position by sending stop command to TCS

Parameters:None
Raises:RuntimeError – TCSInterface in wrong state
Returns:SUCCESS (str)
stop(abort=None)

Stop movements of the telescope (incl. tracking)

Parameters:None
Keyword Arguments:
 abort (bool) – If given, print an abort message
Raises:RuntimeError – TCSInterface in wrong state
Returns:TCS response (str)
track()

Start tracking

Parameters:None
Raises:RuntimeError – TCSInterface in wrong state
Returns:TCS response (str)
main()

main is the run-loop for DOS applications. Monitors the shutdown flag and runs the polling loop for the MED redis database. Monitors the TCS connection When main exits, the TCSInterface application exits. No parameters, no return, no exceptions

about_to_connect_to_instance(*args, **kwargs)

Instance management helper function. Internal use only unless overloaded

did_connect_to_instance(*args, **kwargs)

Instance management helper function. Internal use only unless overloaded

about_to_disconnect_from_instance(*args, **kwargs)

Instance management helper function. Internal use only unless overloaded

did_disconnect_from_instance(*args, **kwargs)

Instance management helper function. Internal use only unless overloaded