csaxs_bec.devices.smaract.smaract_controller.SmaractController#
- class SmaractController(*args, **kwargs)[source]#
Bases:
ControllerMethods
Register a callback which will receive each OphydObject instance.
all_axes_referencedaxis_is_referencedCheck if the value is valid for this object
Remove a subscription, given the original callback function
describeDisconnect the object from the underlying control layer
find_reference_markGet device instance for a specified controller axis.
Get an axis by name.
get_channel_typeReturns the currently configured movement speed that is used for closed-loop commands for a channel.
get_communication_modeThis command may be used to retrieve the interface version of the system.
This command may be used to determine how many control channels are available on a system.
Returns the current position of a positioner.
May be used to read out the travel range limit that is currently configured for a linear channel.
get_sensor_typeReturns the current movement status code of a positioner or end effector.This command can be used to check whether a previously issued movement command has been completed.
This command may be used to physically identify a system connected to the PC.
Check if axis is moving.
Instructs a positioner to move to a specific position.
Instructs a positioner to move to a position relative to its current position.
Move open loop steps.
Close the socket connection to the controller
Open a new socket connection to the controller
Remove the device instance assigned to a controller axis.
When this command is sent the system will perform a reset.
Enable or disable all devices registered for the controller.
Assign an axis to a device instance.
This command configures the speed control feature of a channel for closed-loop commands move_axis_to_absolute_position.
Enable/disable a device.
Change the read-only status of a device.
If a Hand Control Module (HCM) is connected to the system, this command may be used to enable or disable it in order to avoid interference while the software is in control of the system.
For positioners with integrated sensors this command may be used to limit the travel range of a linear positioner by software.
Receive a response from the controller through the socket.
Send a command to the controller through the socket.
Send a command to the controller and receive the response.
stop_all_axesSubscribe to events this event_type generates.
Remove a subscription
unsubscribe_allAttributes
SUB_CONNECTION_CHANGEUSER_ACCESSattr_nameIf the device is connected.
Return the dotted name
Events that can be subscribed to via
obj.subscribekindname of the device
The parent of the ophyd object.
A report on the object.
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
RuntimeErrorif 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
- 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
- get_closed_loop_move_speed(axis_Id_numeric: int) float[source]#
Returns the currently configured movement speed that is used for closed-loop commands for a channel.
- Parameters:
axis_Id_numeric (int) – Axis number.
- Returns:
move speed in mm/s. A return value of 0 means that the speed control feature is disabled.
- Return type:
float
- get_interface_version() str[source]#
This command may be used to retrieve the interface version of the system. It is useful to check if changes have been made to the software interface. An application may check the version in order to ensure that the system behaves as the application expects it to do.
- Returns:
interface version
- Return type:
str
- get_number_of_channels() int[source]#
This command may be used to determine how many control channels are available on a system. This includes positioner channels and end effector channels. Each channel is of a specific type. Use the GCT command to determine the types of the channels. Note that the number of channels does not represent the number positioners and/or end effectors that are currently connected to the system. The channel indexes throughout the interface are zero based. If your system has N channels then the valid range for a channel index is 0.. N-1.
- Returns:
number of channels
- Return type:
int
- get_position(axis_Id_numeric: int) float[source]#
Returns the current position of a positioner.
- Parameters:
axis_Id_numeric (int) – Axis number.
- Returns:
Position in mm
- Return type:
float
- get_position_limits(axis_Id_numeric: int) list[source]#
May be used to read out the travel range limit that is currently configured for a linear channel.
- Args:
axis_Id_numeric (int): Axis
- Returns:
list: [low_limit, high_limit] in mm
- get_status(axis_Id_numeric: int) SmaractChannelStatus[source]#
Returns the current movement status code of a positioner or end effector.This command can be used to check whether a previously issued movement command has been completed.
- Parameters:
axis_Id_numeric (int) – Axis number
- Returns:
Channel status
- Return type:
- get_system_id() str[source]#
This command may be used to physically identify a system connected to the PC. Each system has a unique ID which makes it possible to distinguish one from another. The ID returned is a generic decimal number that uniquely identifies the system.
- is_axis_moving(axis_Id_numeric: int) bool[source]#
Check if axis is moving. Returns true upon open loop move, scanning, closed loop move or reference mark search.
- Parameters:
axis_Id_numeric (int) – Axis number.
- Returns:
True if axis is moving.
- Return type:
bool
- move_axis_to_absolute_position(axis_Id_numeric: int, target_val: float, hold_time: int = 1000) None[source]#
Instructs a positioner to move to a specific position.
- Parameters:
axis_Id_numeric (int) – Axis number.
target_val (float) – Target position in mm.
hold_time (int, optional) – Specifies how long (in milliseconds) the position is actively held after reaching the target. The valid range is 0..60,000. A 0 deactivates this feature, a value of 60,000 is infinite (until manually stopped, see S command). Defaults to 1000.
- move_axis_to_relative_position(axis_Id_numeric: int, target_val: float, hold_time: int = 1000) None[source]#
Instructs a positioner to move to a position relative to its current position.
- Parameters:
axis_Id_numeric (int) – Axis number.
target_val (float) – Relative position to move to in mm.
hold_time (int, optional) – Specifies how long (in milliseconds) the position is actively held after reaching the target. The valid range is 0..60,000. A 0 deactivates this feature, a value of 60,000 is infinite (until manually stopped, see S command). Defaults to 1000.
- move_open_loop_steps(axis_Id_numeric: int, steps: int, amplitude: int = 4000, frequency: int = 2000) None[source]#
Move open loop steps. It performs a burst of steps with the given parameters.
- Parameters:
axis_Id_numeric (int) – Axis number.
steps (int) – Number and direction of steps to perform. The valid range is -30,000..30,000. A value of 0 stops the positioner, but see S command. A value of 30,000 or -30,000 performs an unbounded move. This should be used with caution since the positioner will only stop on an S command.
amplitude (int) – Amplitude that the steps are performed with. Lower amplitude values result in a smaller step width. The parameter must be given as a 12bit value (range 0..4,095). 0 corresponds to 0V, 4,095 to 100V. Default: 4000
frequency (int) – Frequency in Hz that the steps are performed with. The valid range is 1..18,500. Default: 2000.
- property name#
name of the device
- off(update_config: bool = True) None#
Close the socket connection to the controller
- on(timeout: int = 10) None#
Open a new socket connection to the controller
- Parameters:
timeout (int) – Time in seconds to wait for connection
- 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.
- reset() None[source]#
When this command is sent the system will perform a reset. It has the same effect as a power down/power up cycle. The system replies with an acknowledge string before resetting itself.
- 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#
Assign an axis to a device instance.
- Parameters:
axis (Device) – Device instance (e.g. GalilMotor)
axis_nr (int) – Controller axis number
- set_closed_loop_move_speed(axis_Id_numeric: int, move_speed: float) None[source]#
This command configures the speed control feature of a channel for closed-loop commands move_axis_to_absolute_position. By default the speed control is inactive. In this state the behavior of closed-loop commands is influenced by the maximum driving frequency. If a movement speed is configured, all following closed-loop commands will be executed with the new speed.
- Parameters:
axis_Id_numeric (int) – Axis number.
move_speed (float) – Movement speed given in mm/s for linear positioners. The valid range is 0 .. 100. A value of 0 (default) deactivates the speed control feature.
- 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
- set_hcm_mode(mode: int)[source]#
If a Hand Control Module (HCM) is connected to the system, this command may be used to enable or disable it in order to avoid interference while the software is in control of the system. There are three possible modes to set: 0: In this mode the Hand Control Module is disabled. It may not be used to control positioners. 1: This is the default setting where the Hand Control Module may be used to control the positioners. 2: In this mode the Hand Control Module cannot be used to control the positioners. However, if there are positioners with sensors attached, their position data will still be displayed.
- Parameters:
mode (int) – HCM mode
- set_position_limits(axis_Id_numeric: int, low_limit: float, high_limit: float) None[source]#
For positioners with integrated sensors this command may be used to limit the travel range of a linear positioner by software. By default there is no limit set. If defined the positioner will not move beyond the limit. This affects open-loop as well as closed-loop movements.
- Args:
axis_Id_numeric (int): Axis low_limit (float): low limit in mm high_limit (float): high limit in mm
- socket_get()#
Receive a response from the controller through the socket.
- socket_put(val: str)[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, check_for_errors=True, raise_if_not_status=False) 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.
- 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,**kwargspassed 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_subsevent_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_typekwargs in _run_subsrun (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()