Dod Dev
dod_dev
Classes
DoD
DoD(modules=None, ip='172.21.39.172', port=9999, supported_json='/cds/group/pcds/pyps/apps/hutch-python/mfx/dod/supported.json', log_file='/cds/group/pcds/pyps/apps/hutch-python/mfx/dod/dod.log')
Class definition of the DoD (Drop-on-Demand) robot.
Provides an interface for controlling the DoD robot at MFX, including motion control, nozzle dispensing, safety region enforcement, and EVR timing management.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
modules
|
str or None
|
Defines optional modules of the robot. Options: |
None
|
ip
|
str
|
IP address of the robot server. Default is |
'172.21.39.172'
|
port
|
int
|
Port of the robot server. Default is |
9999
|
supported_json
|
str
|
Path to the supported endpoints JSON file. Default is
|
'/cds/group/pcds/pyps/apps/hutch-python/mfx/dod/supported.json'
|
log_file
|
str
|
Path to the log file for |
'/cds/group/pcds/pyps/apps/hutch-python/mfx/dod/dod.log'
|
Attributes:
| Name | Type | Description |
|---|---|---|
client |
myClient
|
TCP client used for communication with the robot. |
ip |
str
|
IP address of the robot server. |
port |
int
|
Port of the robot server. |
supported_json |
str
|
Path to the supported endpoints JSON file. |
safety_abort |
bool
|
Flag used to abort task execution mid-run. Set to |
y_min |
int
|
Minimum allowed y-position (hutch coordinates, micrometers). |
y_safety |
int
|
y-position above which only vertical robot configuration is allowed. |
y_max |
int
|
Maximum allowed y-position (hutch coordinates, micrometers). |
forbidden_regions_horizontal |
list of tuple
|
List of forbidden rectangular regions (x_start, x_stop, y_start, y_stop) active when the robot is in horizontal rotation state. |
forbidden_regions_vertical |
list of tuple
|
List of forbidden rectangular regions active when the robot is in vertical rotation state. |
trigger_Xray |
Trigger
|
EVR trigger object for the X-ray simulator. |
trigger_nozzle_1 |
Trigger
|
EVR trigger object for nozzle 1. |
trigger_nozzle_2 |
Trigger
|
EVR trigger object for nozzle 2. |
trigger_LED |
Trigger
|
EVR trigger object for the LED array. |
timing_Xray |
float
|
Absolute X-ray trigger delay in nanoseconds. |
timing_nozzle_1 |
float
|
Absolute nozzle 1 trigger delay in nanoseconds. |
timing_nozzle_2 |
float
|
Absolute nozzle 2 trigger delay in nanoseconds. |
timing_LED |
float
|
Absolute LED trigger delay in nanoseconds. |
timing_delay_sciPulse |
float
|
Fixed science pulse delay offset in nanoseconds. |
timing_delay_LED |
float
|
Relative delay of the LED with respect to X-ray timing in nanoseconds. |
timing_delay_reaction |
float
|
Relative reaction delay with respect to X-ray timing in nanoseconds. |
timing_delay_nozzle_1 |
float
|
Relative delay of nozzle 1 with respect to X-ray timing in nanoseconds. |
timing_delay_nozzle_2 |
float
|
Relative delay of nozzle 2 with respect to X-ray timing in nanoseconds. |
codi |
(CoDI, optional)
|
CoDI module object. Only present if |
Examples:
Instantiate the robot with default settings:
Instantiate with the CoDI module enabled:
Instantiate with a custom IP address:
Source code in dod/dod_dev.py
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 | |
Attributes
client
instance-attribute
timing_delay_nozzle_1
instance-attribute
timing_delay_nozzle_1 = timing_Xray - timing_nozzle_1 - timing_delay_sciPulse - timing_delay_reaction
timing_delay_nozzle_2
instance-attribute
timing_delay_nozzle_2 = timing_Xray - timing_nozzle_2 - timing_delay_sciPulse - timing_delay_reaction
trigger_LED
instance-attribute
trigger_Xray
instance-attribute
trigger_nozzle_1
instance-attribute
trigger_nozzle_2
instance-attribute
Functions
busy_wait
Block until the robot is no longer busy or the timeout is reached.
Polls the robot status every 100 ms. Returns immediately if the robot is not busy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timeout
|
float
|
Maximum time to wait in seconds before returning. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
|
Raises:
| Type | Description |
|---|---|
ConnectionError
|
If the robot server cannot be reached during polling. |
Examples:
Wait up to 30 seconds for the robot to finish a move:
Source code in dod/dod_dev.py
clear_abort
Clear the robot abort flag and refresh status.
Reconnects to the robot, reads the current status, and resets the
safety_abort flag.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
verbose
|
bool
|
If |
True
|
Returns:
| Type | Description |
|---|---|
ServerResponse or None
|
Full server response if |
Raises:
| Type | Description |
|---|---|
ConnectionError
|
If the robot server cannot be reached. |
Examples:
Clear an abort and print the resulting status:
Clear an abort silently:
Source code in dod/dod_dev.py
do_move
Move the robot to a named position.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
position
|
str
|
Name of the target position as defined in the robot configuration. |
required |
safety_test
|
bool
|
If |
False
|
verbose
|
bool
|
If |
False
|
Returns:
| Type | Description |
|---|---|
dict or ServerResponse
|
Position data after the move completes. If |
Raises:
| Type | Description |
|---|---|
ConnectionError
|
If the robot server cannot be reached. |
Examples:
Move the robot to a named home position:
Move with verbose output:
Source code in dod/dod_dev.py
do_task
Execute a named task on the robot.
Blocks until the task completes or until safety_abort is set to
True, in which case the task is stopped immediately.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
task_name
|
str
|
Name of the task to execute. |
required |
safety_check
|
bool
|
If |
False
|
verbose
|
bool
|
If |
False
|
Returns:
| Type | Description |
|---|---|
dict or ServerResponse
|
Task result data. If |
Raises:
| Type | Description |
|---|---|
ConnectionError
|
If the robot server cannot be reached. |
Examples:
Execute a task named 'wash_nozzle':
Execute a task and inspect the full response:
Source code in dod/dod_dev.py
get_current_position
Return the current robot position.
Returns the name and properties of the last selected position, together with the real current position coordinates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
verbose
|
bool
|
If |
False
|
Returns:
| Type | Description |
|---|---|
dict or ServerResponse
|
Position data with keys |
Raises:
| Type | Description |
|---|---|
ConnectionError
|
If the robot server cannot be reached. |
Examples:
Get the current position and print the real coordinates:
Source code in dod/dod_dev.py
get_forbidden_region
Return the list of forbidden regions for a given rotation state.
Forbidden regions are defined as rectangles in the robot x-y plane. The returned list depends on the current rotation state of the robot.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rotation_state
|
str
|
Rotation state for which to retrieve forbidden regions. Options are:
|
'both'
|
Returns:
| Type | Description |
|---|---|
list of tuple
|
List of forbidden region tuples of the form
|
Examples:
Get forbidden regions for the horizontal rotation state:
Get all forbidden regions:
Source code in dod/dod_dev.py
get_nozzle_status
Return the current nozzle parameters and state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
verbose
|
bool
|
If |
False
|
Returns:
| Type | Description |
|---|---|
dict or ServerResponse
|
Nozzle status data with keys |
Raises:
| Type | Description |
|---|---|
ConnectionError
|
If the robot server cannot be reached. |
Examples:
Print the dispensing state of all nozzles:
Source code in dod/dod_dev.py
get_status
Return the current robot state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
verbose
|
bool
|
If |
False
|
Returns:
| Type | Description |
|---|---|
dict or ServerResponse
|
If |
Raises:
| Type | Description |
|---|---|
ConnectionError
|
If the robot server cannot be reached. |
Examples:
Get a summary status dict:
Get the full response object:
Source code in dod/dod_dev.py
get_task_details
Retrieve the details of a named task from the robot.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
task_name
|
str
|
Name of the task to retrieve. |
required |
verbose
|
bool
|
If |
False
|
Returns:
| Type | Description |
|---|---|
dict or ServerResponse
|
Task detail data. If |
Raises:
| Type | Description |
|---|---|
ConnectionError
|
If the robot server cannot be reached. |
KeyError
|
If |
Examples:
Print the details of a task named 'move_to_home':
Source code in dod/dod_dev.py
get_task_names
Retrieve the names of all available tasks from the robot.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
verbose
|
bool
|
If |
False
|
Returns:
| Type | Description |
|---|---|
dict or ServerResponse
|
Available task names. If |
Raises:
| Type | Description |
|---|---|
ConnectionError
|
If the robot server cannot be reached. |
Examples:
List all available task names:
Source code in dod/dod_dev.py
logging_string
Generate a formatted string for posting to the e-log.
Collects the current CoDI position and all timing parameters and formats them into a human-readable string suitable for logging.
Returns:
| Type | Description |
|---|---|
str
|
Multi-line string containing CoDI position data and timing parameter values. |
Raises:
| Type | Description |
|---|---|
AttributeError
|
If the |
Examples:
Post current state to the e-log:
Source code in dod/dod_dev.py
1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 | |
move_x_abs
Move the robot to an absolute x position (robot coordinate system).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
position_x
|
int
|
Absolute target x-position in micrometers. |
required |
safety_test
|
bool
|
If |
False
|
verbose
|
bool
|
If |
False
|
Returns:
| Type | Description |
|---|---|
dict or ServerResponse
|
Position data after the move command is issued. If |
Raises:
| Type | Description |
|---|---|
ConnectionError
|
If the robot server cannot be reached. |
Examples:
Move to x = 150000 micrometers:
Move with a safety check:
Source code in dod/dod_dev.py
move_y_abs
Move the robot to an absolute y position (robot coordinate system).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
position_y
|
int
|
Absolute target y-position in micrometers. |
required |
safety_test
|
bool
|
If |
False
|
verbose
|
bool
|
If |
False
|
Returns:
| Type | Description |
|---|---|
dict or ServerResponse
|
Position data after the move command is issued. If |
Raises:
| Type | Description |
|---|---|
ConnectionError
|
If the robot server cannot be reached. |
Examples:
Move to y = 30000 micrometers:
Move with a safety check:
Source code in dod/dod_dev.py
move_z_abs
Move the robot to an absolute z position (robot coordinate system).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
position_z
|
int
|
Absolute target z-position in micrometers. |
required |
safety_test
|
bool
|
If |
False
|
verbose
|
bool
|
If |
False
|
Returns:
| Type | Description |
|---|---|
dict or ServerResponse
|
Position data after the move command is issued. If |
Raises:
| Type | Description |
|---|---|
ConnectionError
|
If the robot server cannot be reached. |
Examples:
Move to z = 20000 micrometers:
Move with a safety check:
Source code in dod/dod_dev.py
reconnect
Attempt to reconnect to the robot after a timeout or connection loss.
Re-instantiates the client and reloads the endpoint configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
reload
|
bool
|
If |
False
|
verbose
|
bool
|
Reserved for future use; currently has no effect. Default is |
False
|
Returns:
| Type | Description |
|---|---|
bool
|
Always returns |
Raises:
| Type | Description |
|---|---|
ConnectionError
|
If the robot server cannot be reached at the stored IP and port. |
FileNotFoundError
|
If the supported JSON file cannot be found. |
Examples:
Reconnect after a timeout:
Reconnect and reload the endpoint configuration:
Source code in dod/dod_dev.py
set_forbidden_region
Define a forbidden region in the robot x-y plane.
Forbidden regions are rectangles within which robot end-point motion is not allowed. Only the endpoint is checked; path safety is not enforced.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x_start
|
float
|
Starting x-coordinate of the forbidden rectangle (micrometers). |
required |
x_stop
|
float
|
Ending x-coordinate of the forbidden rectangle (micrometers). |
required |
y_start
|
float
|
Starting y-coordinate of the forbidden rectangle (micrometers). |
required |
y_stop
|
float
|
Ending y-coordinate of the forbidden rectangle (micrometers). |
required |
rotation_state
|
str
|
Rotation state for which this region applies. Options are:
|
'both'
|
Raises:
| Type | Description |
|---|---|
None
|
Prints a warning if an invalid |
Examples:
Forbid the full x-range at low y-values for all rotation states:
Add a region forbidden only in horizontal rotation:
Source code in dod/dod_dev.py
set_nozzle_dispensing
Set the nozzle dispensing mode.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
str
|
Dispensing mode to set. Options are:
|
'Off'
|
verbose
|
bool
|
If |
False
|
Returns:
| Type | Description |
|---|---|
dict or ServerResponse
|
Server response from the dispensing command. If |
Raises:
| Type | Description |
|---|---|
ConnectionError
|
If the robot server cannot be reached. |
Examples:
Enable triggered dispensing:
Turn off dispensing on all nozzles:
Source code in dod/dod_dev.py
set_timing_abs_Xray
Set the absolute X-ray timing used for nozzle delay calculations.
Updates the stored X-ray timing reference and calls
:meth:set_timing_update to recalculate and apply all dependent
trigger delays. Does not directly write to the X-ray trigger PV.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timing_abs
|
float
|
Absolute X-ray trigger delay in nanoseconds. |
required |
Returns:
| Type | Description |
|---|---|
None
|
|
Raises:
| Type | Description |
|---|---|
ConnectionError
|
If any dependent trigger PV cannot be written. |
Examples:
Update the X-ray timing reference to 700000 ns:
Source code in dod/dod_dev.py
set_timing_rel_LED
Set the relative timing of the LED with respect to the X-rays.
Updates timing_delay_LED and calls :meth:set_timing_update to
apply the change to the EVR trigger.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timing_rel
|
float
|
Desired LED delay relative to X-ray timing in nanoseconds. |
required |
Returns:
| Type | Description |
|---|---|
None
|
|
Raises:
| Type | Description |
|---|---|
ConnectionError
|
If the LED trigger PV cannot be written. |
Examples:
Set the LED to fire 1000 ns after the X-ray pulse:
Source code in dod/dod_dev.py
set_timing_rel_reaction
Set the relative reaction delay with respect to the X-rays.
Updates timing_delay_reaction and calls :meth:set_timing_update
to propagate the change to all nozzle triggers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timing_rel
|
float
|
Desired reaction delay relative to X-ray timing in nanoseconds. |
required |
Returns:
| Type | Description |
|---|---|
None
|
|
Raises:
| Type | Description |
|---|---|
ConnectionError
|
If any nozzle trigger PV cannot be written. |
Examples:
Set a 5000 ns reaction delay:
Source code in dod/dod_dev.py
set_timing_relative_nozzle
Adjust the timing of a nozzle by a relative offset.
Increments the current delay of the specified nozzle by timing_rel
and calls :meth:set_timing_update to apply the change.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
nozzle
|
int
|
Nozzle number to adjust. Must be |
required |
timing_rel
|
float
|
Amount to add to the current nozzle delay in nanoseconds. Use a negative value to decrease the delay. |
required |
Returns:
| Type | Description |
|---|---|
None
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
Prints a warning if an invalid nozzle number is provided. |
Examples:
Advance nozzle 1 by 500 ns:
Delay nozzle 2 by 200 ns:
Source code in dod/dod_dev.py
set_timing_update
Recalculate and apply all trigger delays based on current timing parameters.
Updates nozzle 1, nozzle 2, and LED trigger delays using the stored absolute and relative timing values. If a calculated nozzle delay is negative, one full 120 Hz period (approximately 8.33 ms) is added.
Returns:
| Type | Description |
|---|---|
None
|
|
Raises:
| Type | Description |
|---|---|
ConnectionError
|
If any EVR trigger PV cannot be written. |
Examples:
Apply updated timings after changing a delay parameter:
Source code in dod/dod_dev.py
set_timing_zero_nozzle
Set the time-zero delay for a nozzle based on LED alignment.
Sets the absolute reference delay for the specified nozzle as measured
from the LED alignment procedure, then calls :meth:set_timing_update
to apply the change.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
nozzle
|
int
|
Nozzle number to configure. Must be |
required |
timing_rel
|
float
|
Relative delay in nanoseconds from the robot LED alignment. |
required |
Returns:
| Type | Description |
|---|---|
None
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
Prints a warning if an invalid nozzle number is provided. |
Examples:
Set time zero for nozzle 1 based on alignment result:
Source code in dod/dod_dev.py
stop_task
Stop a currently running robot task.
Sends a stop command to the robot and resets the safety_abort flag.
.. note::
After calling this method the robot may remain in "BUSY" status.
Call :meth:clear_abort to recover.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
verbose
|
bool
|
If |
True
|
Returns:
| Type | Description |
|---|---|
ServerResponse or None
|
Full server response if |
Raises:
| Type | Description |
|---|---|
ConnectionError
|
If the robot server cannot be reached. |
Examples:
Stop a running task and inspect the response:
Stop a task without capturing the response:
Source code in dod/dod_dev.py
test_forbidden_region
Test whether a target endpoint is inside a forbidden region.
Checks the given (x, y) coordinates against the list of forbidden regions appropriate for the current base rotation state. Only the endpoint is tested; the motion path is not checked.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x_test
|
float
|
x-coordinate of the target endpoint to test (micrometers). |
required |
y_test
|
float
|
y-coordinate of the target endpoint to test (micrometers). |
required |
Returns:
| Type | Description |
|---|---|
bool
|
|
Raises:
| Type | Description |
|---|---|
ConnectionError
|
If the CoDI base position cannot be read. |
Examples:
Check if a target position is safe before moving:
>>> safe = dod.test_forbidden_region(150000, 30000)
>>> if not safe:
... print('Target position is forbidden.')
Source code in dod/dod_dev.py
1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 | |