The ADC Class¶
The DOS side controller for the ADC.
This application is the interface between DOS and the two ADC controllers, via the ADC controller’s python module (HMdrive.py). This program can also use the simluator ADC_sim.py. To use the simulator, the “controller_type” option in the defaults should be set to “SIMULATOR”.
The following commands are implemented:
- configure - to configure the application and controller
- get - to read status and configuration information
- set - to update select variables at run time
These commands manipulate the mechanisms of the ADC
- home - to send one or both lenses to their home position
- move - to send one of both lenses to specified position(s)
- stop - to stop the motion of the lenses
- send_adc_command - to send a command directly to the ADC controller
The shared variables published by this application are:
- STATUS - the status of the application
- CONTROLLERS - the current state of of the controllers
The current state of the controllers is shared as a dictionary.:
{"c1": {"status":
"angle":
"rem_time":}
"c2": {"status":
"angle":
"rem_time":}
}
-
exception
ADC.
ADCException
(value)¶
-
class
ADC.
ADC
(device_mode=False, noSVE=None, **extra_args)¶ -
commands
= ['configure', 'get', 'set', 'stop', 'home', 'move', 'send_adc_command']¶ PML accessible commands
-
defaults
= {'constants_version': 'DEFAULT', 'controller_1_address': '192.168.1.1', 'controller_1_port': 1, 'controller_2_address': '192.168.1.2', 'controller_2_port': 2, 'controller_type': 'SIMULATOR', 'poll_delay': 5.0}¶ Default configuration parameters
-
init
()¶ Initialize ADC application. Set up variables, import controller module, discovery.
Returns: SUCCESS Return type: str
-
configure
(constants='DEFAULT')¶ Restore the system to its base state. Resets connections to the controllers.
Returns: SUCCESS/FAILED Return type: str
-
get
(key)¶ - Getter function for the application and the underlying controllers. The availible information is:
status - The status of the application.
connected - Whether or not the application is connected to an instance.
poll_delay - The delay between telemetry updates.
nrevol - A dictionary of the two controllers, keys ‘c1’ and ‘c2’, where the values are the number of absolute rotations made.
Any parameter in self.config
controller_status - A dictionary of two controllers:
{"status1": "angle1": "nrev1": "rem_time1": "error1": "status2": "angle2": "nrev2": "rem_time2": "error2":} }
Keyword Arguments: key – status, connected, controller_status, poll_delay, any parameter in self.config Raises: RuntimeError – Invalid parameter Returns: The value requested
-
home
(controllers=None, blocking=True)¶ Tell one or both controllers to send their lense to the home position. Example 1 - to tell the second controller to return to home:
>>> adc.home([2])
Example 2 - to send both controllers to home with a non-blocking call:
>>> adc.home([1,2], blocking=False)
Keyword Arguments: - controllers – The number of the controller to home.
- blocking – Whether or not to block until finished. Default is True.
Raises: RuntimeError – ADC in wrong state, invalid parameters.
Returns: The current status of the controllers. See status description at the top of the page.
Return type: dict
-
move
(angles=[None, None], direction='shortest', blocking=True)¶ CHANGED API - REMOVED CONTROLLERS and ONLY USE angles field Tell one or both controllers to send their lense to the specified position. Example 1 - to send the first controller to 50 degrees:
>>> adc.move([50.0, None])
Example 2 - to send the first controller to 10 degrees and the second to 80, both conunterclockwise:
>>> adc.move([10.0, 80.0], direction='cclock')
Example 3 - to send the second controller to 11 degrees without blocking:
>>> adc.move([None, 11.0], blocking=False)
Keyword Arguments: - angles – List of angles (as floats) to move the lenses to. Must match order for the controller list.
- direction – What direction to move the ADC in. Options are shortest/clock/cclock.
- blocking – Whether or not to block until finished. Default is True.
Raises: RuntimeError – ADC in wrong state, invalid parameters.
Returns: The current status of the controllers. See top of page for detail.
Return type: dict
-
stop
(*args, **kwargs)¶ Tell both controllers to stop all motion.
Raises: RuntimeError – ADC in wrong state Returns: The current status of the controllers. See top of page for details. Return type: dict
-
set
(*args, **kwargs)¶ Standard set function.
Keyword Arguments: - **kwargs – A key/value pair to set. Only poll_delay is availible.
- **kwargs – outlets and their new values, such as poll_delay=2.0.
Raises: RuntimeError – Invalid entry.
Returns str: SUCCESS
-
send_adc_command
(controller, function, function_args=(), function_kwargs={})¶ Send a command directly to the ADC control application.
Keyword Arguments: - controller (int) – The number of the controller to send the command to.
- function (str) – Whether or not to block until finished. Default is True.
- function_args (tuple,optional) – Arguments for the called ADC function
- function_kwargs (dict,optional) – Keyword argments to send to the called function
Raises: RuntimeError – Invalid parameters, error on controller side
Returns: The return value of the function being called on the controller
Return type: dict
-
about_to_connect_to_instance
(*args, **kwargs)¶ To be overridden by the user so that any actions can be taken when the device application is about to connect to an instance
-
did_connect_to_instance
(*args, **kwargs)¶ To be overridden by the user so that any actions can be taken when the device application connects to an instance
-
about_to_disconnect_from_instance
(*args, **kwargs)¶ To be overridden by the user so that any actions can be taken when the device application is about to disconnect from an instance
-
did_disconnect_from_instance
(*args, **kwargs)¶ To be overridden by the user so that any actions can be taken when the device application disconnects from an instance
-
-
class
ADC.
ADC
(device_mode=False, noSVE=None, **extra_args) -
commands
= ['configure', 'get', 'set', 'stop', 'home', 'move', 'send_adc_command'] PML accessible commands
-
defaults
= {'constants_version': 'DEFAULT', 'controller_1_address': '192.168.1.1', 'controller_1_port': 1, 'controller_2_address': '192.168.1.2', 'controller_2_port': 2, 'controller_type': 'SIMULATOR', 'poll_delay': 5.0} Default configuration parameters
-
init
() Initialize ADC application. Set up variables, import controller module, discovery.
Returns: SUCCESS Return type: str
-
configure
(constants='DEFAULT') Restore the system to its base state. Resets connections to the controllers.
Returns: SUCCESS/FAILED Return type: str
-
get
(key) - Getter function for the application and the underlying controllers. The availible information is:
status - The status of the application.
connected - Whether or not the application is connected to an instance.
poll_delay - The delay between telemetry updates.
nrevol - A dictionary of the two controllers, keys ‘c1’ and ‘c2’, where the values are the number of absolute rotations made.
Any parameter in self.config
controller_status - A dictionary of two controllers:
{"status1": "angle1": "nrev1": "rem_time1": "error1": "status2": "angle2": "nrev2": "rem_time2": "error2":} }
Keyword Arguments: key – status, connected, controller_status, poll_delay, any parameter in self.config Raises: RuntimeError – Invalid parameter Returns: The value requested
-
home
(controllers=None, blocking=True) Tell one or both controllers to send their lense to the home position. Example 1 - to tell the second controller to return to home:
>>> adc.home([2])
Example 2 - to send both controllers to home with a non-blocking call:
>>> adc.home([1,2], blocking=False)
Keyword Arguments: - controllers – The number of the controller to home.
- blocking – Whether or not to block until finished. Default is True.
Raises: RuntimeError – ADC in wrong state, invalid parameters.
Returns: The current status of the controllers. See status description at the top of the page.
Return type: dict
-
move
(angles=[None, None], direction='shortest', blocking=True) CHANGED API - REMOVED CONTROLLERS and ONLY USE angles field Tell one or both controllers to send their lense to the specified position. Example 1 - to send the first controller to 50 degrees:
>>> adc.move([50.0, None])
Example 2 - to send the first controller to 10 degrees and the second to 80, both conunterclockwise:
>>> adc.move([10.0, 80.0], direction='cclock')
Example 3 - to send the second controller to 11 degrees without blocking:
>>> adc.move([None, 11.0], blocking=False)
Keyword Arguments: - angles – List of angles (as floats) to move the lenses to. Must match order for the controller list.
- direction – What direction to move the ADC in. Options are shortest/clock/cclock.
- blocking – Whether or not to block until finished. Default is True.
Raises: RuntimeError – ADC in wrong state, invalid parameters.
Returns: The current status of the controllers. See top of page for detail.
Return type: dict
-
stop
(*args, **kwargs) Tell both controllers to stop all motion.
Raises: RuntimeError – ADC in wrong state Returns: The current status of the controllers. See top of page for details. Return type: dict
-
set
(*args, **kwargs) Standard set function.
Keyword Arguments: - **kwargs – A key/value pair to set. Only poll_delay is availible.
- **kwargs – outlets and their new values, such as poll_delay=2.0.
Raises: RuntimeError – Invalid entry.
Returns str: SUCCESS
-
send_adc_command
(controller, function, function_args=(), function_kwargs={}) Send a command directly to the ADC control application.
Keyword Arguments: - controller (int) – The number of the controller to send the command to.
- function (str) – Whether or not to block until finished. Default is True.
- function_args (tuple,optional) – Arguments for the called ADC function
- function_kwargs (dict,optional) – Keyword argments to send to the called function
Raises: RuntimeError – Invalid parameters, error on controller side
Returns: The return value of the function being called on the controller
Return type: dict
-
about_to_connect_to_instance
(*args, **kwargs) To be overridden by the user so that any actions can be taken when the device application is about to connect to an instance
-
did_connect_to_instance
(*args, **kwargs) To be overridden by the user so that any actions can be taken when the device application connects to an instance
-
about_to_disconnect_from_instance
(*args, **kwargs) To be overridden by the user so that any actions can be taken when the device application is about to disconnect from an instance
-
did_disconnect_from_instance
(*args, **kwargs) To be overridden by the user so that any actions can be taken when the device application disconnects from an instance
-
-
class
ADC_sim.
HMdrive
(host, port, comType='tcp')¶ The ADC simulator Simulates the controller for an ADC. For details and the API definition see DESI docDB # <not yet assigned>
-
connect
()¶ Connects to the ADC motor controller
Returns dict: controller_status dictionary
-
disconnect
()¶ Disconnects the ADC motor
Returns dict: Dictionary with either OK or an error
-
move
(degrees, direction='shortest')¶ Controls the motor, takes an angle and moves the lense to that position.
Keyword Arguments: - angle (float) – The angle to turn the ADC to
- direction (str,default='shortest') – The direction to turn the ADC in, shortest/clock/cclock
Returns dict: A dict with either status=OK rem_time=## or an error
-
home
()¶ Controls the motor, takes an angle and moves the lense to that position.
Returns dict: Dictionary with either OK or an error
-
stop
()¶ Halt motion of the motor if it is moving
Returns dict: Dictionary with either OK or an error
-
status
()¶ Get the full AEC motor information
Returns dict: A full status dictionary
-
drv_move
(position, relative=True)¶ Move to specified encoder position. Moves relative to current position unless otherwise specified
-
drv_home
()¶ Move to home
-
drv_stop
()¶ Stop motion
-
drv_get_enable
()¶ Get whether or not the amplifier is enabled
-
drv_enable
()¶ Enable the amplifier
-
drv_disable
()¶ Disable the amplifier
-
drv_clear_faults
()¶ Clear faults
-
drv_get_position
()¶ Get the current position in encoder counts
-
drv_get_error
()¶ Get the motor error code
-
drv_get_register
(regnum)¶ Get a register value
-
drv_get_bit
(regnum, bitnum)¶ Get a bit value
-
drv_set_register
(regnum, value)¶ Set a register value
-
drv_set_bit
(regnum, bitnum, value)¶ Set a bit value
-
drv_get_allregs
()¶ Get all the registers (Currently just returns True)
-
set
(*args, **kwargs)¶ - Manually sets a status value
- Calling pattern:
- <status field> = value where status field has to be a key of the status dictionary delay = <time> to set a delay before the status is updated
-