Cue Architecture
ActionHandler (action_handler.py)
Owns all ActionCue processing — validation, dispatch, hooks, and result delivery.
- Hook phases:
before_dispatch,after_dispatch,wrap_dispatch - Registration layers:
cue_layer(from CueHandler),node_layer(from NodeEngine) - Result sink: injectable callable; defaults to NNG
NodeOperation.STATUSviaNodeCommunications.send_operation
See action-handler-extensibility contract for integration details.
Dedicated action-cue execution, extension hooks, and optional result sink.
ActionHandler
Owns ActionCue validation, default handlers, hooks, and result delivery.
Source code in src/cuemsengine/cues/ActionHandler.py
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 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 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 | |
bind_cue_handler(cue_handler)
Bind the singleton cue orchestrator (arm, go, armed lookups).
Source code in src/cuemsengine/cues/ActionHandler.py
81 82 83 | |
clear_action_extensions()
Remove all hooks and custom sink (for isolated tests).
Source code in src/cuemsengine/cues/ActionHandler.py
95 96 97 98 99 100 | |
finalize_node_layer_bindings()
Call from NodeEngine after comms are ready (extension point; default no-op).
Source code in src/cuemsengine/cues/ActionHandler.py
130 131 132 | |
register_action_hook(phase, fn, *, source='cue_layer', action_types=None)
Register a hook; last registration wins for the same (phase, source, filter).
Source code in src/cuemsengine/cues/ActionHandler.py
104 105 106 107 108 109 110 111 112 113 114 115 116 | |
set_emit_enabled(enabled)
When False, suppress outcome emission (useful in tests).
Source code in src/cuemsengine/cues/ActionHandler.py
90 91 92 93 | |
set_result_sink(sink)
Replace result delivery; None restores default (NNG via comms thread).
Source code in src/cuemsengine/cues/ActionHandler.py
85 86 87 88 | |
ActionHookContext
dataclass
Context passed to extension hooks (stable field names for integrators).
Source code in src/cuemsengine/cues/ActionHandler.py
53 54 55 56 57 58 59 60 61 62 63 64 | |
CueHandler
Singleton class responsible for handling Cue objects.
Holds a list of armed cues and manages video players. Thread-safe: internal state mutations are guarded by a Lock.
Source code in src/cuemsengine/cues/CueHandler.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 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 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 | |
add_armed_cue(cue)
Adds an armed cue to the list.
Source code in src/cuemsengine/cues/CueHandler.py
90 91 92 93 94 | |
arm(cue, init=False)
Arms a cue by appending it to the armed_cues list.
Source code in src/cuemsengine/cues/CueHandler.py
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 | |
disarm(cue)
Disarms a cue by removing it from the armed_cues list.
Source code in src/cuemsengine/cues/CueHandler.py
294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 | |
disarm_all()
Disarms all cues.
Source code in src/cuemsengine/cues/CueHandler.py
337 338 339 340 341 342 343 344 | |
execute_action(cue, mtc, frozen_mtc_ms=None)
Execute an ActionCue against the running show (see ActionHandler).
Source code in src/cuemsengine/cues/CueHandler.py
502 503 504 505 506 507 508 509 510 511 | |
find_armed_cue(cue)
Finds an armed cue with the given uuid.
Source code in src/cuemsengine/cues/CueHandler.py
108 109 110 111 | |
get_armed_cue(cue)
Returns the armed cue with the given uuid.
Source code in src/cuemsengine/cues/CueHandler.py
101 102 103 104 105 106 | |
get_armed_cue_by_id(cue_id)
Returns the armed cue with the given uuid string.
Source code in src/cuemsengine/cues/CueHandler.py
603 604 605 606 607 608 609 | |
get_armed_cues()
Returns the list of armed cues.
Source code in src/cuemsengine/cues/CueHandler.py
96 97 98 99 | |
get_next_cue(cue)
Returns the next cue to be played.
Source code in src/cuemsengine/cues/CueHandler.py
346 347 348 | |
go(cue, mtc, frozen_mtc_ms=None)
Starts a cue in a thread.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cue
|
Cue
|
The cue to start |
required |
mtc
|
MtcListener
|
The MTC listener |
required |
frozen_mtc_ms
|
float
|
Optional frozen MTC timestamp for sync with chained cues |
None
|
Returns:
| Type | Description |
|---|---|
Thread | None
|
Thread running the cue, or None if the cue is disabled or not |
Thread | None
|
local to this node (the node owning the target will run it via |
Thread | None
|
its own GO/post_go dispatch). |
Source code in src/cuemsengine/cues/CueHandler.py
354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 | |
go_threaded(cue, mtc, frozen_mtc_ms=None, go_gen=0)
Runs a cue based on its properties.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cue
|
Cue
|
The cue to run |
required |
mtc
|
MtcListener
|
The MTC listener (for live MTC) |
required |
frozen_mtc_ms
|
float
|
Optional frozen MTC timestamp in milliseconds. |
None
|
go_gen
|
int
|
Generation counter captured at go() time. If the cue's generation has changed by the time the loop ends, another go/stop cycle occurred and this thread must not touch the cue. |
0
|
Source code in src/cuemsengine/cues/CueHandler.py
405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 | |
register_action_hook(phase, fn, *, action_types=None)
Register a cue-layer extension hook; forwards to ACTION_HANDLER.
Source code in src/cuemsengine/cues/CueHandler.py
513 514 515 516 517 518 519 520 521 522 523 524 525 | |
remove_armed_cue(cue)
Removes an armed cue from the list.
Source code in src/cuemsengine/cues/CueHandler.py
113 114 115 116 117 118 119 120 | |
reset_armed_cues()
Resets the list of armed cues.
Source code in src/cuemsengine/cues/CueHandler.py
122 123 124 125 126 | |
route_audio_message(path_parts, value)
Route audio OSCQuery message to the appropriate handler.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path_parts
|
list[str]
|
Path parts after 'audio' (e.g., ['mixer', '0', 'master', 'volume']
or ['cue', ' |
required |
value
|
The OSC value to set |
required |
Source code in src/cuemsengine/cues/CueHandler.py
531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 | |
route_dmx_message(path_parts, value)
Route DMX OSCQuery message to the DMX player.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path_parts
|
list[str]
|
Path parts after 'dmx' (e.g., ['mixer', '0', 'channel', '1']) |
required |
value
|
The OSC value to set |
required |
Source code in src/cuemsengine/cues/CueHandler.py
579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 | |
set_nng_comms(hub_address, node_id)
Set the communications infrastructure
Source code in src/cuemsengine/cues/CueHandler.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | |
stop_all_cues()
Signal all armed cues to stop their playback loops.
Also bumps each cue's generation counter so that any still-running go_threaded threads will see a mismatch and skip post-loop cleanup (disarm), which would otherwise undo the re-arm that follows.
Source code in src/cuemsengine/cues/CueHandler.py
325 326 327 328 329 330 331 332 333 334 335 | |
wait_for_cue(thread)
Waits for a cue to finish.
Source code in src/cuemsengine/cues/CueHandler.py
489 490 491 492 493 494 495 | |
arm_cue(cue)
Type-specific logic when arming a cue
Source code in src/cuemsengine/cues/arm_cue.py
15 16 17 18 19 20 | |
arm_dmxCue(cue)
Arm a DMX cue by extracting DMX scene data.
The DMX scene data is already loaded in the cue object from the script XML. We extract the universe and channel data from cue.DmxScene and store it in a format suitable for sending as OSC bundles to the local DMX player.
Note: cue._local should be set by check_mappings() based on the output_name. For DMX cues, the output_name format is "{node_uuid}" (just the node UUID). A DMX cue can have multiple outputs (one per target node). check_mappings() should iterate through all outputs and set _local=True if ANY output_name matches the current node UUID. Other outputs are ignored. This function is only called for local cues (checked in CueHandler.arm()).
Source code in src/cuemsengine/cues/arm_cue.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | |
loop_actionCue(cue, mtc)
Loop an ActionCue
Source code in src/cuemsengine/cues/loop_cue.py
41 42 43 44 45 46 | |
loop_audioCue(cue, mtc)
Handle the audio media playback loop.
This method manages the playback loop for audio media, including handling looping behavior and OSC communication for timing control.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ossia
|
The OSC communication interface. |
required | |
mtc
|
MtcListener
|
The MIDI Time Code interface. |
required |
Source code in src/cuemsengine/cues/loop_cue.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | |
loop_cue(cue, mtc)
Loop a cue based on its type
Source code in src/cuemsengine/cues/loop_cue.py
27 28 29 30 31 32 | |
loop_cueList(cue, mtc)
Loop a CueList
Source code in src/cuemsengine/cues/loop_cue.py
34 35 36 37 38 39 | |
loop_dmxCue(cue, mtc)
Handle the DMX cue duration wait.
DMX scenes are fire-and-forget (sent once in run_dmxCue), so we only wait for the cue duration to elapse to maintain proper script timing. The cue._local guard is maintained for potential future looping implementation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cue
|
DmxCue
|
The DmxCue |
required |
mtc
|
MtcListener
|
The MIDI Time Code interface |
required |
Source code in src/cuemsengine/cues/loop_cue.py
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 | |
loop_fadeCue(cue, mtc)
Hold a FadeCue in the cue runner for its full duration.
The actual fade is driven by gradient-motiond over OSC; this loop simply blocks until the FadeCue's _end_mtc is reached so general cue lifecycle (auto-disarm of the FadeCue itself in go_threaded's end-of-cue path) only fires after the fade has elapsed. _start_mtc / _end_mtc are set by ActionHandler._handle_fade_action at dispatch time.
Source code in src/cuemsengine/cues/loop_cue.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | |
loop_videoCue(cue, mtc)
Handle the video media playback loop.
Manages looping behavior for all layers in cue._layer_ids, updating offset via the single VideoClient in cue._osc.
Source code in src/cuemsengine/cues/loop_cue.py
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 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 | |
run_actionCue(cue, mtc, frozen_mtc_ms=None)
Run an ActionCue by delegating to ActionHandler.execute_action.
Forwards frozen_mtc_ms so a chained 'play' action triggered inside a post_go='go' chain preserves the chain's MTC snapshot — without it, ActionCue-mediated chains capture live MTC inside CueHandler.go and drift relative to the chain's other cues.
Source code in src/cuemsengine/cues/run_cue.py
38 39 40 41 42 43 44 45 46 47 48 49 | |
run_audioCue(cue, mtc, frozen_mtc_ms=None)
Run an AudioCue
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cue
|
AudioCue
|
The audio cue to run |
required |
mtc
|
The MTC listener (for framerate info) |
required | |
frozen_mtc_ms
|
float
|
Optional frozen MTC timestamp for perfect sync with chained cues |
None
|
Source code in src/cuemsengine/cues/run_cue.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 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 | |
run_cue(cue, mtc, frozen_mtc_ms=None)
Run a cue based on its type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cue
|
Cue
|
The cue to run |
required |
mtc
|
MtcListener
|
The MTC listener (for framerate info) |
required |
frozen_mtc_ms
|
float
|
Optional frozen MTC timestamp in milliseconds. When provided (e.g., for chained cues with post_go='go'), this timestamp is used instead of reading live MTC. This ensures perfect sync between audio and video cues. |
None
|
Source code in src/cuemsengine/cues/run_cue.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 | |
run_cueList(cue, mtc, frozen_mtc_ms=None)
Run a CueList by dispatching its first enabled child.
Source code in src/cuemsengine/cues/run_cue.py
30 31 32 33 34 35 36 | |
run_dmxCue(cue, mtc, frozen_mtc_ms=None)
Run a DmxCue
Sends DMX scene bundle directly to the local DMX player. Synchronized with MTC. The scene contains frame data, timing, and fade info. DMX cues have no media duration - duration is inferred from fade times. Only fadein_time is used for now. fade_out defaults to 0
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cue
|
DmxCue
|
The DMX cue to run |
required |
mtc
|
The MTC listener (for framerate info) |
required | |
frozen_mtc_ms
|
float
|
Optional frozen MTC timestamp for perfect sync with chained cues |
None
|
Source code in src/cuemsengine/cues/run_cue.py
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 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 | |
run_videoCue(cue, mtc, frozen_mtc_ms=None)
Run a VideoCue.
Sends offset/visible/mtcfollow to all layers in cue._layer_ids via the single VideoClient in cue._osc.
Source code in src/cuemsengine/cues/run_cue.py
271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 | |