diff --git a/src/atem.ts b/src/atem.ts index e519fbc7..01bdb985 100644 --- a/src/atem.ts +++ b/src/atem.ts @@ -439,6 +439,11 @@ export class Atem extends BasicAtem { return this.sendCommand(command) } + public async setTimeMode(mode: Enums.TimeMode): Promise { + const command = new Commands.TimeConfigCommand(mode) + return this.sendCommand(command) + } + public async requestTime(): Promise { const command = new Commands.TimeRequestCommand() return this.sendCommand(command) diff --git a/src/commands/TimeConfigCommand.ts b/src/commands/TimeConfigCommand.ts new file mode 100644 index 00000000..5d8413a1 --- /dev/null +++ b/src/commands/TimeConfigCommand.ts @@ -0,0 +1,40 @@ +import * as Enums from '../enums' +import { BasicWritableCommand } from '.' +import { DeserializedCommand } from './CommandBase' +import { AtemState } from '../state' + +export class TimeConfigCommand extends BasicWritableCommand<{ mode: Enums.TimeMode }> { + public static readonly rawName = 'CTCC' + public static readonly minimumVersion = Enums.ProtocolVersion.V8_1_1 + + constructor(mode: Enums.TimeMode) { + super({ mode }) + } + + public serialize(): Buffer { + const buffer = Buffer.alloc(4) + buffer.writeUInt8(this.properties.mode, 0) + + return buffer + } +} + +export class TimeConfigUpdateCommand extends DeserializedCommand<{ mode: Enums.TimeMode }> { + public static readonly rawName = 'TCCc' + public static readonly minimumVersion = Enums.ProtocolVersion.V8_1_1 + + constructor(mode: Enums.TimeMode) { + super({ mode }) + } + + public static deserialize(rawCommand: Buffer): TimeConfigUpdateCommand { + const mode = rawCommand.readUInt8(0) + + return new TimeConfigUpdateCommand(mode) + } + + public applyToState(state: AtemState): string { + state.settings.timeMode = this.properties.mode + return 'settings.timeMode' + } +} diff --git a/src/commands/index.ts b/src/commands/index.ts index 9f962aa8..036e2f06 100644 --- a/src/commands/index.ts +++ b/src/commands/index.ts @@ -22,3 +22,4 @@ export * from './PowerStatusCommand' export * from './StartupStateCommand' export * from './TallyBySourceCommand' export * from './TimeCommand' +export * from './TimeConfigCommand' diff --git a/src/enums/index.ts b/src/enums/index.ts index 6bf5f606..c8b8a307 100644 --- a/src/enums/index.ts +++ b/src/enums/index.ts @@ -412,3 +412,8 @@ export enum AudioInternalPortType { AuxOut = 10, AudioAuxOut = 11, // TODO - verify } + +export enum TimeMode { + FreeRun = 0, + TimeOfDay = 1, +} diff --git a/src/state/settings.ts b/src/state/settings.ts index 3ebc387e..fbb581ff 100644 --- a/src/state/settings.ts +++ b/src/state/settings.ts @@ -1,4 +1,4 @@ -import { VideoMode, MultiViewerLayout } from '../enums' +import { VideoMode, MultiViewerLayout, TimeMode } from '../enums' export interface MultiViewerSourceState { source: number @@ -33,4 +33,5 @@ export interface SettingsState { readonly multiViewers: Array videoMode: VideoMode mediaPool?: MediaPool + timeMode?: TimeMode }