CBPComponent#
- class lsst.ts.cbp.CBPComponent(log=None)#
Bases:
objectThis class is for implementing the CBP component.
The component implements a python wrapper over DMC code written by DFM Manufacturing. The following API exposes commands that move the motors of the CBP, sets the focus and selects the mask.
- Parameters:
log (
Noneorlogging.Logger) – Optional logger used for component diagnostics.
- log#
Component logger.
- Type:
- client#
TCP client used to communicate with the controller.
- Type:
lsst.ts.tcpip.Client
- client_lock#
Lock that serializes command traffic.
- Type:
- telemetry#
Latest hardware telemetry snapshot.
- Type:
- in_position#
Latest component-owned command-facing in-position snapshot.
- Type:
- monitor_condition#
Condition used to wake command waiters when monitor state changes.
- Type:
- masks#
Configured mask metadata keyed by mask ID.
- Type:
dictofstrtotypes.SimpleNamespace
- error_tolerance#
Allowed azimuth/elevation error before the axis is considered out of position.
- Type:
- rotation_tolerance#
Allowed mask rotation error before the axis is considered out of position.
- Type:
Notes
The class uses the python socket module to build TCP/IP connections to the Galil controller for the CBP. The underlying API is built on DMC.
Attributes Summary
Return the latest autoparked telemetry value.
Return the latest azimuth telemetry value.
Return whether the controller client is connected.
Return the latest elevation telemetry value.
Return the latest focus telemetry value.
Return the latest mask telemetry value.
Return the latest mask rotation telemetry value.
Return whether all CBP axes are in position.
Return the latest parked telemetry value.
Return whether the controller client should be connected.
Methods Summary
Validate and accept a configured mask target.
accept_target_update(**kwargs)Validate and accept a target update.
assert_in_range(name, value, min_value, ...)Raise ValueError if a value is out of range.
change_focus(position)Change focus.
Read hardware status bits from the CBP controller.
Read the current park and autopark states from hardware.
Clear the latest monitor failure state.
configure(config)Configure the CBP.
connect()Create a socket and connect to the CBP's static address and designated port.
Disconnect from the tcp socket.
Generate the initial mask metadata table.
Read the current azimuth from hardware.
Read and record the mount elevation encoder, in degrees.
Read the current focus from hardware.
get_mask()Read the current mask name and mask rotation from hardware.
get_mask_target(mask)Resolve a configured mask into a normalized target record.
Initialize target from the latest hardware telemetry.
move_azimuth(position)Move the azimuth encoder.
move_elevation(position)Move the elevation encoder.
notify_monitor_failure(reason)Record monitor failure reason and wake command waiters.
notify_monitor_success(telemetry)Record a successful monitor cycle and wake command waiters.
Reconnect the controller socket after the reply stream stalls.
send_command(msg[, log, await_reply, ...])Send a controller command and optionally read its reply.
set_mask(mask)Set the mask value
set_mask_rotation(mask_rotation)Set the mask rotation
set_park()Send the park command to the controller.
set_target(**kwargs)Update the component target state.
Send the unpark command to the controller.
Read hardware state and replace the telemetry snapshot.
validate_target([azimuth, elevation, focus, ...])Validate target fields before mutating component state.
wait_for_motion_complete(monitor_task)Wait for all CBP axes to be in position.
wait_for_park_state(parked, monitor_task)Wait for the monitor loop to observe the requested park state.
Attributes Documentation
- auto_parked#
Return the latest autoparked telemetry value.
- Returns:
auto_parked – Latest autoparked state from the component telemetry snapshot.
- Return type:
- azimuth#
Return the latest azimuth telemetry value.
- Returns:
azimuth – Latest azimuth value from the component telemetry snapshot.
- Return type:
- connected#
Return whether the controller client is connected.
- Returns:
connected – True if the TCP/IP client is connected.
- Return type:
- elevation#
Return the latest elevation telemetry value.
- Returns:
elevation – Latest elevation value from the component telemetry snapshot.
- Return type:
- focus#
Return the latest focus telemetry value.
- Returns:
focus – Latest focus value from the component telemetry snapshot.
- Return type:
- mask#
Return the latest mask telemetry value.
- Returns:
mask – Latest mask name from the component telemetry snapshot.
- Return type:
- mask_rotation#
Return the latest mask rotation telemetry value.
- Returns:
mask_rotation – Latest mask rotation value from the component telemetry snapshot.
- Return type:
- motion_complete#
Return whether all CBP axes are in position.
- Returns:
motion_complete – True if all in-position fields are true.
- Return type:
- parked#
Return the latest parked telemetry value.
- Returns:
parked – Latest parked state from the component telemetry snapshot.
- Return type:
- should_be_connected#
Return whether the controller client should be connected.
- Returns:
should_be_connected – True if the TCP/IP client is expected to be connected.
- Return type:
Methods Documentation
- accept_mask_target_update(mask)#
Validate and accept a configured mask target.
- accept_target_update(**kwargs)#
Validate and accept a target update.
The returned update contains the full target snapshot and the component-owned transient in-position state after marking the affected axes out of position.
- Parameters:
**kwargs (
Any) – Target fields and values to replace in the immutable target snapshot. Each key must name a field onTarget.- Returns:
target_update – Accepted target data for CSC publication.
- Return type:
- assert_in_range(name, value, min_value, max_value)#
Raise ValueError if a value is out of range.
- async change_focus(position)#
Change focus.
- Parameters:
position (
int) – The value of the new focus (microns).- Raises:
ValueError – Raised when the new value falls outside the accepted range.
- Return type:
- async check_cbp_status()#
Read hardware status bits from the CBP controller.
- Returns:
status – Hardware status bits.
- Return type:
- async check_park()#
Read the current park and autopark states from hardware.
- configure(config)#
Configure the CBP.
- Parameters:
config (
types.SimpleNamespace) – Configuration namespace produced by the CSC.- Return type:
- async connect()#
Create a socket and connect to the CBP’s static address and designated port.
- async disconnect()#
Disconnect from the tcp socket.
Safe to call even if already disconnected.
- Return type:
- generate_mask_info()#
Generate the initial mask metadata table.
- Return type:
Notes
The mask table is initialized with the controller IDs used by the mock server and configuration loader.
configurelater replaces the names and rotations with deployment-specific values.
- async get_azimuth()#
Read the current azimuth from hardware.
- Returns:
azimuth – Current azimuth, in degrees.
- Return type:
- async get_elevation()#
Read and record the mount elevation encoder, in degrees.
Note that the low-level controller calls this axis “altitude”.
- Returns:
elevation – Current elevation, in degrees.
- Return type:
- async get_focus()#
Read the current focus from hardware.
- Returns:
focus – Current focus, in microns.
- Return type:
- async get_mask()#
Read the current mask name and mask rotation from hardware.
- get_mask_target(mask)#
Resolve a configured mask into a normalized target record.
- initialize_target_from_telemetry()#
Initialize target from the latest hardware telemetry.
This is used during startup so that the CSC’s initial target matches the current hardware position. Because the target is set equal to the measured state, the resulting telemetry snapshot reports all axes in position.
- Raises:
RuntimeError – Raised if no valid hardware telemetry has been read.
- Return type:
- async move_azimuth(position)#
Move the azimuth encoder.
- Parameters:
position (
float) – The desired azimuth (degrees).- Raises:
ValueError – Raised when the new value falls outside the accepted range.
- Return type:
- async move_elevation(position)#
Move the elevation encoder.
- Parameters:
position (
float) – The desired elevation (degrees)- Raises:
ValueError – Raised when the new value falls outside the accepted range.
- Return type:
- async notify_monitor_failure(reason)#
Record monitor failure reason and wake command waiters.
- async notify_monitor_success(telemetry)#
Record a successful monitor cycle and wake command waiters.
- Parameters:
telemetry (
TelemetrySnapshot) – Snapshot read during the successful monitor cycle.- Return type:
- async reconnect_after_reply_failure(msg)#
Reconnect the controller socket after the reply stream stalls.
This method is called while the command lock is held. That prevents another command from using the socket while it is being reset.
- async send_command(msg, log=True, await_reply=True, await_terminator=True)#
Send a controller command and optionally read its reply.
- Parameters:
msg (
str) – The string command to be sent.log (
bool) – Call with False to suppress log messages. Useful for debugging purposes to limit output.await_reply (
bool) – If false, do not wait for a reply.await_terminator (
bool) – If false, read a fixed-size byte reply; otherwise read a terminator-delimited string reply.
- Returns:
reply – The normalized command reply, or None if
await_replyis false.- Return type:
- Raises:
CommandReplyError – Raised if no usable reply is received after all retry attempts, if reconnecting after a missing reply fails, or if the reply type is unexpected.
- async set_mask(mask)#
Set the mask value
- async set_mask_rotation(mask_rotation)#
Set the mask rotation
- Parameters:
mask_rotation (
float) – The mask_rotation value that will be sent.- Raises:
ValueError – Raised when the new value falls outside the accepted range.
- Return type:
- set_target(**kwargs)#
Update the component target state.
- async update_status()#
Read hardware state and replace the telemetry snapshot.
The new snapshot is built only after all telemetry fields have been read, so callers never observe a partially updated snapshot.
- Returns:
telemetry – Captured hardware snapshot.
- Return type:
- validate_target(azimuth=None, elevation=None, focus=None, mask=None, mask_rotation=None)#
Validate target fields before mutating component state.
- Parameters:
- Raises:
ValueError – Raised if any provided target value is out of range or not one of the configured masks.
- Return type:
- async wait_for_motion_complete(monitor_task)#
Wait for all CBP axes to be in position.
- Parameters:
monitor_task (
asyncio.Future) – Monitor task that should continue updating component telemetry.- Raises:
MonitorStoppedError – Raised if the monitor fails or stops before motion completes.
- Return type:
- async wait_for_park_state(parked, monitor_task)#
Wait for the monitor loop to observe the requested park state.
- Parameters:
parked (
bool) – Desired parked state.monitor_task (
asyncio.Future) – Monitor task that should continue updating component telemetry.
- Raises:
MonitorStoppedError – Raised if the monitor fails or stops before the state is observed.
- Return type: