diff --git a/packages/timeline-state-resolver/src/integrations/atem/index.ts b/packages/timeline-state-resolver/src/integrations/atem/index.ts index 7badd2eff..5ca77f701 100644 --- a/packages/timeline-state-resolver/src/integrations/atem/index.ts +++ b/packages/timeline-state-resolver/src/integrations/atem/index.ts @@ -65,10 +65,16 @@ export class AtemDevice extends Device this.context.logger.error('Error resetting atem state', new Error(e))) + } else { + // Do a state diff to at least send all the commands we know about + this.context.resetState().catch((e) => this.context.logger.error('Error resetting atem state', new Error(e))) } }) diff --git a/packages/timeline-state-resolver/src/service/DeviceInstance.ts b/packages/timeline-state-resolver/src/service/DeviceInstance.ts index 5e70e7d67..1c4886228 100644 --- a/packages/timeline-state-resolver/src/service/DeviceInstance.ts +++ b/packages/timeline-state-resolver/src/service/DeviceInstance.ts @@ -242,6 +242,13 @@ export class DeviceInstanceWrapper extends EventEmitter { }, resetState: async () => { + await this._stateHandler.setCurrentState(undefined) + await this._stateHandler.clearFutureStates() + this.emit('resetResolver') + }, + + resetToState: async (state: any) => { + await this._stateHandler.setCurrentState(state) await this._stateHandler.clearFutureStates() this.emit('resetResolver') }, diff --git a/packages/timeline-state-resolver/src/service/device.ts b/packages/timeline-state-resolver/src/service/device.ts index b283310fb..090ba5a17 100644 --- a/packages/timeline-state-resolver/src/service/device.ts +++ b/packages/timeline-state-resolver/src/service/device.ts @@ -136,7 +136,11 @@ export interface DeviceContextAPI { /** Notify that the connection status has changed. */ connectionChanged: (status: Omit) => void - /** Notify the conductor that it should reset the resolver, in order to trigger it again. */ + /** + * Notify the conductor that it should reset the resolver, in order to trigger it again. + * Note: this will not change anything about the current state and should technically not lead + * to any new commands being sent + */ resetResolver: () => void /** Something went wrong when executing a command */ @@ -148,6 +152,9 @@ export interface DeviceContextAPI { timeTrace: (trace: FinishedTrace) => void - /** Reset the state of the State */ + /** Reset the tracked device state to undefined and notify the conductor to reset the resolver */ resetState: () => Promise + + /** Reset the tracked device state to "state" and notify the conductor to reset the resolver */ + resetToState: (state: any) => Promise // todo - types? }