Skip to main content

Four Modes, One Loop

The same loop does four different jobs. Most of the time a camera takes a routine frame every minute. On a schedule it swings through a full panorama. When an operator grabs it, it becomes a fast, responsive control surface. And for special events it can burst images at high speed. These aren't four different programs — they're four modes of the one orchestration, and which one runs is a single value on the entity.

The one idea to hold on to​

The active mode is CameraState.CurrentConfig, and every transition is just a SetCurrentConfig signal. The loop reads the mode at the top, runs that mode's handler, and near the bottom decides whether to signal a transition. The whole scheduler is a small state machine living in the entity:

ModeWhat it doesWake-up rate
SINGLERoutine single-frame capturethe configured single rate (typically 10s)
PANOOne scheduled panorama (typically every ~2 min), then straight back1 second (wake immediately for the next single)
LEASEDOperator has exclusive PTZ controltypically 1s — see why
TURBOHigh-speed burst capture until an end timetypically 1s

The transitions are driven by two things: timers (the pano schedule, the lease and turbo end times) and events (a queued move, a move-home, a turbo request). Trace them yourself — given a mode and what just happened, predict where the camera goes:

🔀 Mode machine1/7 · score 0
currentlySINGLE

The scheduled pano time arrives.

Which mode next?

The exits from LEASED are the ones worth remembering: a move-home drops straight back to SINGLE, but a lease timeout is a two-part check — past the 5-minute mark and the SQL lease confirmed closed. The camera doesn't abandon an operator just because a timer fired.

Gotcha: a fresh camera starts in PANO, not SINGLE

On the very first cycle the entity's ScheduledPanoDt is null, and the loop reads that as "never run before": it sets the mode to PANO and captures a full panorama immediately. If you deploy a camera and the first thing it does is a pano rather than a single frame, that's not a bug — it's the initialization path establishing a baseline panorama.

Wrapping up​

One orchestration runs four modes — SINGLE, PANO, LEASED, TURBO — selected by CurrentConfig on the entity and switched by SetCurrentConfig signals driven by timers and events. Panorama is a quick detour that returns to SINGLE; LEASED is entered by a move and left by move-home or a confirmed lease timeout; TURBO runs until its end time. A brand-new camera starts in PANO to establish a baseline.

You've seen how one camera runs. Last in this section: how orchestrations get started, stopped, and redeployed across the whole fleet — Starting, Stopping & Redeploying.