csaxs_bec.devices.omny.galil.sgalil_ophyd.GalilController#

class GalilController(*args, **kwargs)[source]#

Bases: Controller

Methods

add_instantiation_callback

Register a callback which will receive each OphydObject instance.

axis_is_referenced

check_value

Check if the value is valid for this object

clear_sub

Remove a subscription, given the original callback function

describe

destroy

Disconnect the object from the underlying control layer

fly_grid_scan

_summary_

galil_show_all

get_axis

Get device instance for a specified controller axis.

get_axis_by_name

Get an axis by name.

get_motor_limit_switch

is_axis_moving

is_motor_on

is_thread_active

off

Close the socket connection to the controller

on

Open a new socket connection to the controller

read_encoder_position

remove_axis

Remove the device instance assigned to a controller axis.

set_all_devices_enabled

Enable or disable all devices registered for the controller.

set_axis

Assign an axis to a device instance.

set_device_enabled

Enable/disable a device.

set_device_read_write

Change the read-only status of a device.

sgalil_reference

Reference all axes of the controller

show_running_threads

socket_get

Receive a response from the controller through the socket.

socket_put

Send a command to the controller through the socket.

socket_put_and_receive

Send a command to the controller and receive the response.

socket_put_confirmed

Send message to controller and ensure that it is received by checking that the socket receives a colon.

stop_all_axes

subscribe

Subscribe to events this event_type generates.

unsubscribe

Remove a subscription

unsubscribe_all

Attributes

SUB_CONNECTION_CHANGE

USER_ACCESS

attr_name

connected

If the device is connected.

dotted_name

Return the dotted name

event_types

Events that can be subscribed to via obj.subscribe

kind

name

name of the device

parent

The parent of the ophyd object.

report

A report on the object.

root

Walk parents to find ultimate ancestor (parent's parent...).

subscriptions

classmethod add_instantiation_callback(callback, fail_if_late=False)#

Register a callback which will receive each OphydObject instance.

Parameters:
  • callback (callable) – Expected signature: f(ophydobj_instance)

  • fail_if_late (boolean) – If True, verify that OphydObj has not yet been instantiated and raise RuntimeError if it has, as a way of verify that no instances will be “missed” by this registry. False by default.

check_value(value, **kwargs)#

Check if the value is valid for this object

This function does no normalization, but may raise if the value is invalid.

Raises:

ValueError

clear_sub(cb, event_type=None)#

Remove a subscription, given the original callback function

See also subscribe(), unsubscribe()

Parameters:
  • cb (callable) – The callback

  • event_type (str, optional) – The event to unsubscribe from (if None, removes it from all event types)

property connected#

If the device is connected.

Subclasses should override this

destroy()#

Disconnect the object from the underlying control layer

property dotted_name: str#

Return the dotted name

property event_types#

Events that can be subscribed to via obj.subscribe

fly_grid_scan(status: DeviceStatus, start_y: float, end_y: float, interval_y: int, start_x: float, end_x: float, interval_x: int, exp_time: float, readout_time: float, **kwargs) tuple[source]#

_summary_

Parameters:
  • start_y (float) – start position of y axis (fast axis)

  • end_y (float) – end position of y axis (fast axis)

  • interval_y (int) – number of points in y axis

  • start_x (float) – start position of x axis (slow axis)

  • end_x (float) – end position of x axis (slow axis)

  • interval_x (int) – number of points in x axis

  • exp_time (float) – exposure time in seconds

  • readout_time (float) – readout time in seconds, minimum of .5e-3s (0.5ms)

Raises:
  • LimitError – Raised if any position of motion is outside of the limits

  • LimitError – Raised if the speed is above 2mm/s or below 0.02mm/s

get_axis(axis_nr: int) Device#

Get device instance for a specified controller axis.

Parameters:

axis_nr (int) – Controller axis number

Returns:

Device instance (e.g. GalilMotor)

Return type:

Device

get_axis_by_name(name: str) Device#

Get an axis by name.

Parameters:

name (str) – Name of the axis

Returns:

Device instance

Return type:

Device

property name#

name of the device

off() None[source]#

Close the socket connection to the controller

on(timeout: int = 10) None[source]#

Open a new socket connection to the controller

property parent#

The parent of the ophyd object.

If at the top of its hierarchy, parent will be None

remove_axis(*, axis_nr: int) None#

Remove the device instance assigned to a controller axis.

Parameters:

axis_nr (int) – Controller axis number

property report#

A report on the object.

property root#

Walk parents to find ultimate ancestor (parent’s parent…).

set_all_devices_enabled(enabled: bool) None#

Enable or disable all devices registered for the controller.

Parameters:

enabled (bool) – Enable or disable all devices

set_axis(axis: Device, axis_nr: int) None[source]#

Assign an axis to a device instance.

Parameters:
  • axis (Device) – Device instance (e.g. GalilMotor)

  • axis_nr (int) – Controller axis number

set_device_enabled(device_name: str, enabled: bool) None#

Enable/disable a device. If the device is not configured, a warning is logged.

Parameters:
  • device_name (str) – Name of the device

  • enabled (bool) – Enable or disable the device

set_device_read_write(device_name: str, enabled: bool) None#

Change the read-only status of a device. If the device is not configured, a warning is logged.

Parameters:
  • device_name (str) – Name of the device

  • enabled (bool) – Set device to read-only or writable

sgalil_reference() None[source]#

Reference all axes of the controller

socket_get() str[source]#

Receive a response from the controller through the socket.

socket_put(val: str) None[source]#

Send a command to the controller through the socket.

Parameters:

val (str) – Command to send

socket_put_and_receive(val: str, remove_trailing_chars=True) str[source]#

Send a command to the controller and receive the response. Override this method in the derived class if necessary, especially if the response needs to be parsed differently.

socket_put_confirmed(val: str) None[source]#

Send message to controller and ensure that it is received by checking that the socket receives a colon.

Parameters:

val (str) – Message that should be sent to the socket

Raises:

GalilCommunicationError – Raised if the return value is not a colon.

subscribe(callback, event_type=None, run=True)#

Subscribe to events this event_type generates.

The callback will be called as cb(*args, **kwargs) with the values passed to _run_subs with the following additional keys:

sub_type : the string value of the event_type obj : the host object, added if ‘obj’ not already in kwargs

if the key ‘timestamp’ is in kwargs _and_ is None, then it will be replaced with the current time before running the callback.

The *args, **kwargs passed to _run_subs will be cached as shallow copies, be aware of passing in mutable data.

Warning

If the callback raises any exceptions when run they will be silently ignored.

Parameters:
  • callback (callable) –

    A callable function (that takes kwargs) to be run when the event is generated. The expected signature is

    def cb(*args, obj: OphydObject, sub_type: str, **kwargs) -> None:
    

    The exact args/kwargs passed are whatever are passed to _run_subs

  • event_type (str, optional) –

    The name of the event to subscribe to (if None, defaults to the default sub for the instance - obj._default_sub)

    This maps to the sub_type kwargs in _run_subs

  • run (bool, optional) – Run the callback now

See also

clear_sub, _run_subs

Returns:

cid – id of callback, can be passed to unsubscribe to remove the callback

Return type:

int

unsubscribe(cid)#

Remove a subscription

See also subscribe(), clear_sub()

Parameters:

cid (int) – token return by subscribe()