Skip to content

Commit e1e1c38

Browse files
committed
fix: reorder the kairos monitor messages, so that the "fundamental ones" show up first
1 parent 67457bc commit e1e1c38

1 file changed

Lines changed: 36 additions & 28 deletions

File tree

packages/timeline-state-resolver/src/integrations/kairos/kairos-application-monitor.ts

Lines changed: 36 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -239,17 +239,20 @@ export class KairosApplicationMonitor extends EventEmitter<KairosApplicationMoni
239239
private async checkApplicationStatus() {
240240
this.applyMappings()
241241

242-
const issues: string[] = []
243-
const ensureExists = async (pExists: Promise<boolean>, description: string): Promise<void> => {
242+
const highPrioIssues: string[] = []
243+
const lowPrioIssues: string[] = []
244+
const ensureExists = async (pExists: Promise<boolean>, description: string, highPrio: boolean): Promise<void> => {
244245
try {
245246
const value = await pExists
246247

247248
if (value === false) {
248-
issues.push(`${description} not found on the Kairos.`)
249+
if (highPrio) highPrioIssues.push(`${description} not found on the Kairos.`)
250+
else lowPrioIssues.push(`${description} not found on the Kairos.`)
249251
}
250252
} catch (e) {
251253
if (e instanceof ResponseError) {
252-
issues.push(`${description}) not found on the Kairos.`)
254+
if (highPrio) highPrioIssues.push(`${description}) not found on the Kairos.`)
255+
else lowPrioIssues.push(`${description}) not found on the Kairos.`)
253256
} else {
254257
this.emit('error', e instanceof Error ? e : new Error(e + ''))
255258
}
@@ -265,71 +268,76 @@ export class KairosApplicationMonitor extends EventEmitter<KairosApplicationMoni
265268
}
266269

267270
if (sourceRef.realm === 'clipPlayer') {
268-
await ensureExists(this.kairos.clipPlayerExists(sourceRef), `Clip Player "${refToPath(sourceRef)}"`)
271+
await ensureExists(this.kairos.clipPlayerExists(sourceRef), `Clip Player "${refToPath(sourceRef)}"`, true)
269272
} else if (sourceRef.realm === 'ramRecorder') {
270-
await ensureExists(this.kairos.ramRecorderExists(sourceRef), `Ram Recorder "${refToPath(sourceRef)}"`)
273+
await ensureExists(this.kairos.ramRecorderExists(sourceRef), `Ram Recorder "${refToPath(sourceRef)}"`, true)
271274
} else if (sourceRef.realm === 'imageStore') {
272-
await ensureExists(this.kairos.imageStoreExists(sourceRef), `Image Store "${refToPath(sourceRef)}"`)
275+
await ensureExists(this.kairos.imageStoreExists(sourceRef), `Image Store "${refToPath(sourceRef)}"`, true)
273276
} else if (sourceRef.realm === 'scene') {
274-
await ensureExists(this.kairos.sceneExists(sourceRef), `Scene "${refToPath(sourceRef)}"`)
277+
await ensureExists(this.kairos.sceneExists(sourceRef), `Scene "${refToPath(sourceRef)}"`, true)
275278
} else if (sourceRef.realm === 'ip-input') {
276-
await ensureExists(this.kairos.inputExists(sourceRef), `IP Input "${refToPath(sourceRef)}"`)
279+
await ensureExists(this.kairos.inputExists(sourceRef), `IP Input "${refToPath(sourceRef)}"`, true)
277280
} else if (sourceRef.realm === 'sdi-input') {
278-
await ensureExists(this.kairos.inputExists(sourceRef), `SDI Input "${refToPath(sourceRef)}"`)
281+
await ensureExists(this.kairos.inputExists(sourceRef), `SDI Input "${refToPath(sourceRef)}"`, true)
279282
} else if (sourceRef.realm === 'ndi-input') {
280-
await ensureExists(this.kairos.inputExists(sourceRef), `NDI Input "${refToPath(sourceRef)}"`)
283+
await ensureExists(this.kairos.inputExists(sourceRef), `NDI Input "${refToPath(sourceRef)}"`, true)
281284
} else if (sourceRef.realm === 'stream-input') {
282-
await ensureExists(this.kairos.inputExists(sourceRef), `Stream Input "${refToPath(sourceRef)}"`)
285+
await ensureExists(this.kairos.inputExists(sourceRef), `Stream Input "${refToPath(sourceRef)}"`, true)
283286
} else if (sourceRef.realm === 'hdmi-input') {
284-
await ensureExists(this.kairos.inputExists(sourceRef), `HDMI Input "${refToPath(sourceRef)}"`)
287+
await ensureExists(this.kairos.inputExists(sourceRef), `HDMI Input "${refToPath(sourceRef)}"`, true)
285288
} else if (sourceRef.realm === 'media-still') {
286-
await ensureExists(this.kairos.mediaStillExists(sourceRef), `Media Still "${refToPath(sourceRef)}"`)
289+
await ensureExists(this.kairos.mediaStillExists(sourceRef), `Media Still "${refToPath(sourceRef)}"`, true)
287290
} else if (sourceRef.realm === 'media-ramrec') {
288-
await ensureExists(this.kairos.mediaRamRecExists(sourceRef), `Media RamRec "${refToPath(sourceRef)}"`)
291+
await ensureExists(this.kairos.mediaRamRecExists(sourceRef), `Media RamRec "${refToPath(sourceRef)}"`, true)
289292
} else if (sourceRef.realm === 'matte') {
290293
// There is no method to check a matte individually (yet)
291294
} else if (sourceRef.realm === 'gfx-channel') {
292-
await ensureExists(this.kairos.gfxChannelExists(sourceRef), `GFX Channel "${refToPath(sourceRef)}"`)
295+
await ensureExists(this.kairos.gfxChannelExists(sourceRef), `GFX Channel "${refToPath(sourceRef)}"`, true)
293296
} else if (sourceRef.realm === 'source-base') {
294297
// Ignore, eg: BLACK / WHITE
295298
} else if (sourceRef.realm === 'source-int') {
296299
// Ignore, eg: ColorBar / ColorCircle
297300
} else if (sourceRef.realm === 'mv-int') {
298301
await ensureExists(
299302
this.kairos.multiViewerSourceExists(sourceRef),
300-
`MultiViewer Source "${refToPath(sourceRef)}"`
303+
`MultiViewer Source "${refToPath(sourceRef)}"`,
304+
true
301305
)
302306
} else if (sourceRef.realm === 'scene-snapshot') {
303-
await ensureExists(this.kairos.sceneSnapshotExists(sourceRef), `Scene Snapshot "${refToPath(sourceRef)}"`)
307+
await ensureExists(
308+
this.kairos.sceneSnapshotExists(sourceRef),
309+
`Scene Snapshot "${refToPath(sourceRef)}"`,
310+
false
311+
)
304312
} else if (sourceRef.realm === 'scene-layer') {
305-
await ensureExists(this.kairos.sceneLayerExists(sourceRef), `Scene Layer "${refToPath(sourceRef)}"`)
313+
await ensureExists(this.kairos.sceneLayerExists(sourceRef), `Scene Layer "${refToPath(sourceRef)}"`, false)
306314
} else if (sourceRef.realm === 'macro') {
307-
await ensureExists(this.kairos.macroExists(sourceRef), `Macro "${refToPath(sourceRef)}"`)
315+
await ensureExists(this.kairos.macroExists(sourceRef), `Macro "${refToPath(sourceRef)}"`, true)
308316
} else if (sourceRef.realm === 'media-sound') {
309-
await ensureExists(this.kairos.mediaSoundExists(sourceRef), `Media Sound "${refToPath(sourceRef)}"`)
317+
await ensureExists(this.kairos.mediaSoundExists(sourceRef), `Media Sound "${refToPath(sourceRef)}"`, true)
310318
} else if (sourceRef.realm === 'audio-player') {
311-
await ensureExists(this.kairos.audioPlayerExists(sourceRef), `Audio Player "${refToPath(sourceRef)}"`)
319+
await ensureExists(this.kairos.audioPlayerExists(sourceRef), `Audio Player "${refToPath(sourceRef)}"`, true)
312320
} else if (sourceRef.realm === 'scene-layer-effect') {
313321
const layerRef = refSceneLayer(refScene(sourceRef.scenePath), sourceRef.layerPath)
314322
const layerEffects = await this.kairos.listSceneLayerEffects(layerRef)
315323

316324
if (!layerEffects.find((effect) => _.isEqual(effect.effectPath, sourceRef.effectPath))) {
317-
issues.push(`Layer Effect ${refToPath(sourceRef)} not found on the Kairos.`)
325+
lowPrioIssues.push(`Layer Effect ${refToPath(sourceRef)} not found on the Kairos.`)
318326
}
319327
} else if (sourceRef.realm === 'aux') {
320-
await ensureExists(this.kairos.auxExists(sourceRef), `Aux "${refToPath(sourceRef)}"`)
328+
await ensureExists(this.kairos.auxExists(sourceRef), `Aux "${refToPath(sourceRef)}"`, true)
321329
} else if (sourceRef.realm === 'media-clip') {
322-
await ensureExists(this.kairos.mediaClipExists(sourceRef), `Media Clip "${refToPath(sourceRef)}"`)
330+
await ensureExists(this.kairos.mediaClipExists(sourceRef), `Media Clip "${refToPath(sourceRef)}"`, true)
323331
} else if (sourceRef.realm === 'media-image') {
324-
await ensureExists(this.kairos.mediaImageExists(sourceRef), `Media Image "${refToPath(sourceRef)}"`)
332+
await ensureExists(this.kairos.mediaImageExists(sourceRef), `Media Image "${refToPath(sourceRef)}"`, true)
325333
} else {
326334
assertNever(sourceRef)
327335
}
328336
}
329337

330338
const status: DeviceStatus = {
331-
statusCode: issues.length > 0 ? StatusCode.BAD : StatusCode.GOOD,
332-
messages: issues,
339+
statusCode: highPrioIssues.length + lowPrioIssues.length > 0 ? StatusCode.BAD : StatusCode.GOOD,
340+
messages: [...highPrioIssues, ...lowPrioIssues],
333341
active: true,
334342
}
335343
if (!_.isEqual(this.status, status)) {

0 commit comments

Comments
 (0)