-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Inputs): implement InPr (read) and CInL (write) commands
- Loading branch information
Alex Van Camp
committed
Apr 28, 2018
1 parent
8978d49
commit 17e1688
Showing
8 changed files
with
156 additions
and
1 deletion.
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
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,70 @@ | ||
import AbstractCommand from '../AbstractCommand' | ||
import { AtemState } from '../../state' | ||
import { InputChannel } from '../../state/input' | ||
import { ExternalPorts, ExternalPortType } from '../../enums' | ||
import { Util } from '../../lib/atemUtil' | ||
|
||
export class InputPropertiesCommand extends AbstractCommand { | ||
rawName = 'InPr' | ||
inputId: number | ||
MaskFlags = { | ||
longName: 1 << 0, | ||
shortName: 1 << 1, | ||
isExternal: 1 << 2 | ||
} | ||
|
||
properties: InputChannel | ||
|
||
updateProps (newProps: Partial<InputChannel>) { | ||
this._updateProps(newProps) | ||
} | ||
|
||
deserialize (rawCommand: Buffer) { | ||
this.inputId = rawCommand.readUInt16BE(0) | ||
|
||
const externalPortsMask = rawCommand[29] | ||
const externalPorts: ExternalPortType[] = [] | ||
if (externalPortsMask & ExternalPorts.SDI) { | ||
externalPorts.push(ExternalPortType.SDI) | ||
} | ||
if (externalPortsMask & ExternalPorts.HDMI) { | ||
externalPorts.push(ExternalPortType.HDMI) | ||
} | ||
if (externalPortsMask & ExternalPorts.Component) { | ||
externalPorts.push(ExternalPortType.Component) | ||
} | ||
if (externalPortsMask & ExternalPorts.Composite) { | ||
externalPorts.push(ExternalPortType.Composite) | ||
} | ||
if (externalPortsMask & ExternalPorts.SVideo) { | ||
externalPorts.push(ExternalPortType.SVideo) | ||
} | ||
|
||
this.properties = { | ||
longName: Util.bufToNullTerminatedString(rawCommand, 2, 20), | ||
shortName: Util.bufToNullTerminatedString(rawCommand, 22, 4), | ||
externalPorts: externalPorts.length > 0 ? externalPorts : null, | ||
isExternal: rawCommand[28] === 0, | ||
externalPortType: rawCommand.readUInt8(31), | ||
internalPortType: rawCommand.readUInt8(32), | ||
sourceAvailability: rawCommand.readUInt8(34), | ||
meAvailability: rawCommand.readUInt8(35) | ||
} | ||
} | ||
|
||
serialize () { | ||
const buffer = Buffer.alloc(24) | ||
buffer.writeUInt16BE(this.flag, 0) | ||
buffer.writeUInt16BE(this.inputId, 2) | ||
buffer.write(this.properties.longName, 4) | ||
buffer.write(this.properties.shortName, 24) | ||
buffer.writeUInt16BE(this.properties.externalPortType, 28) | ||
return Buffer.concat([Buffer.from('CInL', 'ascii'), buffer]) | ||
} | ||
|
||
applyToState (state: AtemState) { | ||
state.inputs[this.inputId] = { | ||
...this.properties | ||
} | ||
} | ||
} |
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 @@ | ||
export * from './InputPropertiesCommand' |
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
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
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,17 @@ | ||
import { | ||
ExternalPortType, | ||
InternalPortType, | ||
MeAvailability, | ||
SourceAvailability | ||
} from '../enums' | ||
|
||
export interface InputChannel { | ||
longName: string | ||
shortName: string | ||
isExternal: boolean | ||
readonly externalPorts: Array<ExternalPortType> | null | ||
externalPortType: ExternalPortType | ||
readonly internalPortType: InternalPortType | ||
readonly sourceAvailability: SourceAvailability | ||
readonly meAvailability: MeAvailability | ||
} |