Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

viz reset action (Sofie 2830) #323

Merged
merged 4 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,20 @@ export interface VizMSEOptions {

export type SomeMappingVizMSE = Record<string, never>

export interface VizResetPayload {
/**
* Optional property
*/
activeRundownPlaylistId?: string
}

export interface ActivatePayload {
activeRundownPlaylistId: string
clearAll?: boolean
}

export enum VizMSEActions {
VizReset = 'vizReset',
PurgeRundown = 'purgeRundown',
Activate = 'activate',
StandDown = 'standDown',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
{
"$schema": "../../../$schemas/action-schema.json",
"actions": [
{
"id": "vizReset",
"name": "Reset",
"description": "Purges all rundowns, clears the engine and reactivates the Viz playlist",
"destructive": true,
"timeout": 10000,
"payload": {
"type": "object",
"properties": {
"activeRundownPlaylistId": {
"name": "Rundown playlist ID",
"description": "Optional property that helps track what rundown is active for optimisation reasons",
"type": "string"
}
},
"additionalProperties": false
}
},
{
"id": "purgeRundown",
"name": "Purge Viz Rundown",
Expand All @@ -15,8 +33,12 @@
"payload": {
"type": "object",
"properties": {
"activeRundownPlaylistId": { "type": "string" },
"clearAll": { "type": "boolean" }
"activeRundownPlaylistId": {
"type": "string"
},
"clearAll": {
"type": "boolean"
}
},
"required": ["activeRundownPlaylistId"],
"additionalProperties": false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
SomeMappingVizMSE,
TimelineContentVIZMSEElementPilot,
TimelineContentVIZMSEElementInternal,
VizResetPayload,
} from 'timeline-state-resolver-types'

import { createMSE, MSE } from '@tv2media/v-connection'
Expand Down Expand Up @@ -267,6 +268,15 @@ export class VizMSEDevice extends DeviceWithState<VizMSEState, DeviceOptionsVizM
commands: this._initOptions?.clearAllCommands || [],
})
}
public async resetViz(payload: VizResetPayload): Promise<void> {
await this.purgeRundown(true) // note - this might not be 100% necessary
await this.clearEngines()
await this._vizmseManager?.activate(payload?.activeRundownPlaylistId)

// lastly make sure we reset so timeline state is sent again
this.clearStates()
this.emit('resetResolver')
}

async executeAction(actionId: string, payload?: Record<string, any> | undefined): Promise<ActionExecutionResult> {
switch (actionId) {
Expand All @@ -280,6 +290,9 @@ export class VizMSEDevice extends DeviceWithState<VizMSEState, DeviceOptionsVizM
case VizMSEActions.ClearAllEngines:
await this.clearEngines()
return { result: ActionExecutionResultCode.Ok }
case VizMSEActions.VizReset:
await this.resetViz(payload ?? {})
return { result: ActionExecutionResultCode.Ok }
default:
return { result: ActionExecutionResultCode.Ok, response: t('Action "{{id}}" not found', { actionId }) }
}
Expand Down
Loading