-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: update for protocol v1.11 (firmware V7)
- Loading branch information
1 parent
1b08a8e
commit 680b3ea
Showing
14 changed files
with
467 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { ResponseMessage } from '../message' | ||
import { IHandler } from './iHandler' | ||
import { AsynchronousCode } from '../codes' | ||
|
||
export interface DisplayTimecodeChangeResponse { | ||
displayTimecode: string | ||
} | ||
|
||
export class DisplayTimecodeChange implements IHandler { | ||
responseCode = AsynchronousCode.DisplayTimecode | ||
eventName = 'notify.displayTimecode' | ||
|
||
deserialize(msg: ResponseMessage): DisplayTimecodeChangeResponse { | ||
const res: DisplayTimecodeChangeResponse = { | ||
displayTimecode: msg.params['display timecode'], | ||
} | ||
return res | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { ResponseMessage } from '../message' | ||
import { IHandler } from './iHandler' | ||
import { AsynchronousCode } from '../codes' | ||
|
||
export interface TimelinePositionChangeResponse { | ||
timelinePosition: string | ||
} | ||
|
||
export class TimelinePositionChange implements IHandler { | ||
responseCode = AsynchronousCode.TimelinePosition | ||
eventName = 'notify.timelinePosition' | ||
|
||
deserialize(msg: ResponseMessage): TimelinePositionChangeResponse { | ||
const res: TimelinePositionChangeResponse = { | ||
timelinePosition: msg.params['timeline position'], | ||
} | ||
return res | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { SynchronousCode } from '../codes' | ||
import { ResponseMessage, NamedMessage } from '../message' | ||
import { AbstractCommand } from './abstractCommand' | ||
|
||
export interface CacheInfoCommandResponse { | ||
status: string | ||
transferringSlotId: number | ||
recordingTime: number | ||
} | ||
|
||
export class CacheInfoGetCommand extends AbstractCommand { | ||
expectedResponseCode = SynchronousCode.CacheInfo | ||
|
||
deserialize(msg: ResponseMessage): CacheInfoCommandResponse { | ||
const res: CacheInfoCommandResponse = { | ||
status: msg.params['status'], | ||
transferringSlotId: parseInt(msg.params['transferring slot id']), | ||
recordingTime: parseInt(msg.params['recording time']), | ||
} | ||
return res | ||
} | ||
|
||
serialize(): NamedMessage { | ||
const res: NamedMessage = { | ||
name: 'cache info', | ||
params: {}, | ||
} | ||
|
||
return res | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
import { SynchronousCode } from '../codes' | ||
import { NamedMessage, ResponseMessage } from '../message' | ||
import { AbstractCommand, AbstractCommandNoResponse } from './abstractCommand' | ||
|
||
export interface Clip { | ||
clipId: string | ||
name: string | ||
startTime: string | ||
duration: string | ||
in?: string | ||
out?: string | ||
} | ||
export interface ClipsGetCommandResponse { | ||
clipCount: number | ||
clips: Clip[] | ||
} | ||
|
||
export class ClipsGetCommand extends AbstractCommand { | ||
expectedResponseCode = SynchronousCode.ClipsGet | ||
|
||
constructor(public clip?: number, public count?: number, public readonly version?: 1 | 2) { | ||
super() | ||
} | ||
|
||
deserialize(msg: ResponseMessage): ClipsGetCommandResponse { | ||
const clipIds = Object.keys(msg.params).filter((x) => x !== 'clip count') | ||
const clips = clipIds.map<Clip>((x) => { | ||
if (this.version === 2) { | ||
return { | ||
clipId: x, | ||
name: msg.params[x].substr(48), | ||
startTime: msg.params[x].substr(0, 11), | ||
duration: msg.params[x].substr(12, 11), | ||
in: msg.params[x].substr(24, 11), | ||
out: msg.params[x].substr(35, 11), | ||
} | ||
} else { | ||
// v1 | ||
return { | ||
clipId: x, | ||
name: msg.params[x].slice(0, -24), | ||
startTime: msg.params[x].substr(-23, 11), | ||
duration: msg.params[x].substr(-11, 11), | ||
} | ||
} | ||
}) | ||
|
||
const res: ClipsGetCommandResponse = { | ||
clipCount: parseInt(msg.params['clip count'], 10), | ||
clips, | ||
} | ||
|
||
return res | ||
} | ||
serialize(): NamedMessage { | ||
const res: NamedMessage = { | ||
name: 'clips get', | ||
params: {}, | ||
} | ||
|
||
if (this.clip !== undefined) res.params['clip id'] = this.clip + '' | ||
if (this.count !== undefined) res.params['count'] = this.count + '' | ||
if (this.version !== undefined) res.params['version'] = this.version + '' | ||
|
||
return res | ||
} | ||
} | ||
|
||
export class ClipsAddCommand extends AbstractCommandNoResponse { | ||
constructor(public name: string, public clip?: string, public inPoint?: string, public outPoint?: string) { | ||
super() | ||
} | ||
|
||
serialize(): NamedMessage { | ||
const res: NamedMessage = { | ||
name: 'clips add', | ||
params: { | ||
name: this.name, | ||
}, | ||
} | ||
|
||
if (this.clip) res.params['clip'] = this.clip | ||
if (this.inPoint) res.params['inPoint'] = this.inPoint | ||
if (this.outPoint) res.params['outPoint'] = this.outPoint | ||
|
||
return res | ||
} | ||
} | ||
|
||
export class ClipsClearCommand extends AbstractCommandNoResponse { | ||
constructor() { | ||
super() | ||
} | ||
|
||
serialize(): NamedMessage { | ||
const res: NamedMessage = { | ||
name: 'clips clear', | ||
params: {}, | ||
} | ||
|
||
return res | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { SynchronousCode } from '../codes' | ||
import { ResponseMessage, NamedMessage } from '../message' | ||
import { AbstractCommand, AbstractCommandNoResponse } from './abstractCommand' | ||
import { DynamicRange } from '../enums' | ||
|
||
export interface DynamicRangeCommandResponse { | ||
playbackOverride: DynamicRange | ||
} | ||
|
||
export class DynamicRangeGetCommand extends AbstractCommand { | ||
expectedResponseCode = SynchronousCode.DynamicRange | ||
|
||
deserialize(msg: ResponseMessage): DynamicRangeCommandResponse { | ||
const res: DynamicRangeCommandResponse = { | ||
playbackOverride: msg.params['playback override'] as DynamicRange, | ||
} | ||
return res | ||
} | ||
|
||
serialize(): NamedMessage { | ||
const res: NamedMessage = { | ||
name: 'dynamic range', | ||
params: {}, | ||
} | ||
|
||
return res | ||
} | ||
} | ||
|
||
export class DynamicRangeSetCommand extends AbstractCommandNoResponse { | ||
constructor(public override: DynamicRange) { | ||
super() | ||
} | ||
|
||
serialize(): NamedMessage { | ||
const res: NamedMessage = { | ||
name: 'dynamic range', | ||
params: { | ||
'playback override': this.override, | ||
}, | ||
} | ||
|
||
return res | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { SynchronousCode } from '../codes' | ||
import { NamedMessage, ResponseMessage } from '../message' | ||
import { AbstractCommand, AbstractCommandNoResponse } from './abstractCommand' | ||
|
||
export interface PlayOnStartupCommandResponse { | ||
enable: boolean | ||
singleClip: boolean | ||
} | ||
|
||
export class PlayOnStartupGetCommand extends AbstractCommand { | ||
expectedResponseCode = SynchronousCode.Playrange | ||
|
||
deserialize(msg: ResponseMessage): PlayOnStartupCommandResponse { | ||
const res: PlayOnStartupCommandResponse = { | ||
enable: msg.params['enable'] === 'true', | ||
singleClip: msg.params['single clip'] === 'true', | ||
} | ||
return res | ||
} | ||
serialize(): NamedMessage { | ||
const res: NamedMessage = { | ||
name: 'play on startup', | ||
params: {}, | ||
} | ||
|
||
return res | ||
} | ||
} | ||
|
||
export class PlayOnStartupSetCommand extends AbstractCommandNoResponse { | ||
enable?: boolean | ||
singleClip?: boolean | ||
|
||
serialize(): NamedMessage { | ||
const res: NamedMessage = { | ||
name: 'playrange set', | ||
params: {}, | ||
} | ||
|
||
if (this.enable !== false) res.params['enable'] = this.enable + '' | ||
if (this.singleClip !== false) res.params['single clip'] = this.singleClip + '' | ||
|
||
return res | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { SynchronousCode } from '../codes' | ||
import { NamedMessage, ResponseMessage } from '../message' | ||
import { AbstractCommand, AbstractCommandNoResponse } from './abstractCommand' | ||
|
||
export interface PlayOptionCommandResponse { | ||
stopMode: 'lastframe' | 'nextframe' | 'black' | ||
} | ||
|
||
export class PlayOptionGetCommand extends AbstractCommand { | ||
expectedResponseCode = SynchronousCode.PlayOption | ||
|
||
deserialize(msg: ResponseMessage): PlayOptionCommandResponse { | ||
const res: PlayOptionCommandResponse = { | ||
stopMode: msg.params['stop mode'] as PlayOptionCommandResponse['stopMode'], | ||
} | ||
return res | ||
} | ||
serialize(): NamedMessage { | ||
const res: NamedMessage = { | ||
name: 'play option', | ||
params: {}, | ||
} | ||
|
||
return res | ||
} | ||
} | ||
|
||
export class PlayOptionSetCommand extends AbstractCommandNoResponse { | ||
constructor(public stopMode: 'lastframe' | 'nextframe' | 'black') { | ||
super() | ||
} | ||
|
||
serialize(): NamedMessage { | ||
const res: NamedMessage = { | ||
name: 'play option', | ||
params: {}, | ||
} | ||
|
||
if (this.stopMode !== undefined) res.params['stop mode'] = this.stopMode | ||
|
||
return res | ||
} | ||
} |
Oops, something went wrong.