Skip to content

control/camera_toupcam: use loggers - #7

Merged
ianohara merged 1 commit into
masterfrom
ian-logging-cameras
Oct 25, 2024
Merged

control/camera_toupcam: use loggers#7
ianohara merged 1 commit into
masterfrom
ian-logging-cameras

Conversation

@ianohara

Copy link
Copy Markdown
Collaborator

This starts converting all the camera implementations to using loggers, and marks a lot of TODO where we need to come back and do error handling.

@ianohara
ianohara changed the base branch from ian-file-logging to master October 25, 2024 21:24
@ianohara
ianohara force-pushed the ian-logging-cameras branch from 6da7e89 to 902c78d Compare October 25, 2024 21:26
@ianohara
ianohara merged commit 8e88671 into master Oct 25, 2024
@ianohara
ianohara deleted the ian-logging-cameras branch December 27, 2024 17:47
hongquanli added a commit that referenced this pull request May 18, 2026
…tbeat-skip, etc.

Addresses six issues from the copilot-pull-request-reviewer bot review:

#1 (cephla.py): Call acknowledge_aborted_command() after catching
CommandAborted (and after the inner resend failure if it was also a
CommandAborted), so the next send_command doesn't log the spurious
"Last command aborted and not cleared before new command sent!"
warning. The inner ack is gated on isinstance(e2, CommandAborted) to
avoid the "ack with nothing to ack" path on TimeoutError.

#2 (cephla.py): Drop the redundant `target_usteps = ...` recompute
after _home_wheel. config and target_pos haven't changed and
_target_pos_to_usteps doesn't depend on current_pos.

#3 (cephla.py): Fix _home_wheel docstring — wheel is driven to
config.min_index (typically slot 1), not "slot 0".

#5 (firmware/serial_communication.cpp): Skip the
`mcu_cmd_execution_status = COMPLETED_WITHOUT_ERRORS` reset when
processing a HEARTBEAT. The keepalive has no result to report, and
resetting would clobber a pending CMD_EXECUTION_ERROR from the
previous command if the broadcast hasn't fired yet. Eliminates the
narrow race where heartbeat traffic interleaves a failure broadcast.

#6 (firmware/stage_commands.cpp): Split mark_move_failed() into two
helpers — mark_move_failed() (for paths that already set
mcu_cmd_execution_in_progress = true) and report_move_error() (for
early-return paths that didn't). The !enabled branch in
dispatch_filterwheel_move now uses report_move_error() so it doesn't
spuriously unwind in_progress for an unrelated motion in flight on
another axis. Invariant: only the function that claimed in_progress
gets to clear it.

#7 (test_filter_wheel.py): Add `getattr(mc, move_rel_attr).assert_not_called()`
to both parametrized CommandAborted/TimeoutError tests, so the
absolute-MOVETO recovery path is enforced — fall-back to relative
MOVE would now be caught.
Alpaca233 added a commit that referenced this pull request May 26, 2026
Picks up the remaining cheap, reasonable fixes from PR #535 review:

#1 cv2.imwrite return value: cv2 returns False (without raising) on
missing dir, missing codec, or unsupported dtype. We now check the
return value, log a throttled WARNING per failure, increment a
_silent_write_failures counter (surfaced in the diagnostics summary),
and skip counter increment + CSV row write so no row references a
file that isn't on disk.

#4 channel-name path sanitization: get_image_filepath previously only
replaced spaces; now also strips '/', '\\', ':', '*', '?', '"', '<',
'>', '|'. Strict improvement for both the recording widget and the
multipoint pipeline.

#7 frames.csv open guarded: a PermissionError on the CSV file no
longer leaves the widget in a half-started state. On failure,
experiment_ID is cleared and the exception is re-raised so the
toggle_recording slot doesn't run streamHandler.start_recording().

#8 drop the dead image_format constructor parameter: process_queue
hasn't read it since the cv2.imwrite refactor — it derives the
extension from control._def.Acquisition.IMAGE_FORMAT via
get_image_filepath. No in-tree callers passed it.

#9 OSError auto-stop emits only once per recording: a saturated queue
hitting a persistent OSError (e.g., full disk) no longer fires 10
redundant stop_recording signals. _stop_requested_from_writer is
reset in start_new_experiment; subsequent errors during shutdown
log as WARNING instead of re-emitting.

#18 channel_provider returning None at start_new_experiment now logs
a distinct WARNING. Before, a user who launched the GUI and clicked
Record without first selecting a live channel got every frame
tagged 'live' with no warning (because the provider lambda itself
was non-None, just its return value was).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant