Skip to content

Wait before running the end-of-sequence script - #19

Open
jan-tdy wants to merge 3 commits into
pchev:masterfrom
jan-tdy:claude/termination-actions-conditions-args-nsm6dn
Open

jan-tdy wants to merge 3 commits into
pchev:masterfrom
jan-tdy:claude/termination-actions-conditions-args-nsm6dn

Conversation

@jan-tdy

@jan-tdy jan-tdy commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds a new "Wait ___ min. before running the script" option to the sequence termination actions (Edit sequence → Termination options), enabled when "Run a script" is checked.
  • When enabled, the end-of-sequence script and/or the shutdown action wait the configured number of minutes before running — e.g. to give the camera time to warm up after "Warm the camera" was triggered — instead of firing immediately.
  • The option is persisted in the sequence file (/Termination/WaitScript, /Termination/WaitMinutes).
  • Fixed during review: the finalize/cleanup that runs after termination actions (saving done-count, firing the "sequence ended" event, clearing the finalizing/waiting flags) is now deferred via a completion callback until the termination actions actually finish, instead of firing immediately while a delay is still pending — which could otherwise let a new sequence start while the previous one's deferred script/shutdown was still outstanding.

Note: argument support for termination scripts (start/end/error script) already existed via the script selection dialog's parameter field, so it was not touched here. MQTT notifications for unattended mode are intentionally left out of this PR and will be addressed separately.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added configurable waiting before termination scripts, including an enable option and duration in minutes.
    • Termination actions now complete after scripts, shutdown operations, or the configured delay finishes.
  • Improvements
    • Termination-wait settings are saved and restored with each target.
    • Waiting controls are enabled only when applicable termination-script options are selected.
  • Bug Fixes
    • Replaced camera-temperature waiting and timeout behavior with the configurable termination-script delay.

Add "Wait for the camera before running the script" option to the
sequence termination actions. When enabled together with "Warm the
camera", the end-of-sequence script and the shutdown action are
delayed until the camera actually reaches its end temperature (with
a 15 minute safety timeout), instead of firing immediately after the
warm-up command is issued.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014QDaXC2gRibCBcDyAaghEn
…finalize

Replace the camera-temperature polling with a plain configurable delay
(in minutes) before running the termination script and/or shutting
down: simpler, doesn't depend on the camera driver reporting
temperature correctly, and works for any reason to wait (e.g. giving
the camera time to warm up).

Also fixes a race flagged in review: starting the wait timer used to
return from RunEndAction immediately, but callers still went on to
fire onEndSequence and clear the "finalizing" state right away, before
the deferred script/shutdown actually ran. A sequence could then be
restarted while the previous one's termination action was still
pending, and it would run with the new sequence's script settings.
The finalize/cleanup code at each call site is now a callback invoked
once the termination actions actually complete (immediately when no
delay is requested, or from the timer once it fires).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014QDaXC2gRibCBcDyAaghEn
RunErrorAction passed its completion callback straight into RunEndAction,
so on the no-delay path the callback (finalize/notify) fired before
OnErrorScript ran, and on the delay path OnErrorScript ran before the
delayed end action instead of after it. Route OnErrorScript through its
own step (RunErrorActionScript) that runs after RunEndAction's actions
complete and only then invokes the original callback, so the ordering
no longer depends on whether a delay is active.

Also reset FWaiting in StopSequenceFinalize so a stopped/aborted
sequence isn't left reporting as waiting.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014QDaXC2gRibCBcDyAaghEn
@pchev

pchev commented Sep 7, 2026

Copy link
Copy Markdown
Owner

Just a general question for now.
Why to complicate the user interface with an option instead of using time.sleep at the beginning of the script?

@jan-tdy

jan-tdy commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

Because time.sleep in an external script can be less reliable than directly in CCDCiel.

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.

3 participants