import { VideohubCommand } from './Command'

export enum PortStatus {
    None = 'None',
    BNC = 'BNC',
    RS422 = 'RS422'
}

export enum PortLockState {
    Unlocked = 'U',
    LockedByOther = 'L',
    LockedByOwn = 'O'
}

export enum PortLockAction {
    Unlock = 'U',
    ForceUnlock = 'F',
    Lock = 'L'
}

export enum PortDirection {
    Auto = 'auto'
}

export enum VideohubPort {
    Input = 'input',
    Output = 'output',
    Serial = 'serial',
    Monitoring = 'monitoring'
}

export enum CommandTypes {
    Ping = 'PING',
    ProtocolPreamble = 'PROTOCOL PREAMBLE',
    VideohubDevice = 'VIDEOHUB DEVICE',
    InputLabels = 'INPUT LABELS',
    OutputLabels = 'OUTPUT LABELS',
    VideoOutputRouting = 'VIDEO OUTPUT ROUTING',
    VideoOutputLocks = 'VIDEO OUTPUT LOCKS',
    VideoInputStatus = 'VIDEO INPUT STATUS',
    VideoOutputStatus = 'VIDEO OUTPUT STATUS'
}

export interface InputInterface {
    id: number
    name: string
    status: PortStatus
}

export interface OutputInterface extends InputInterface {
    route: number
    lock: PortLockState
    lockHolder?: string
}

export interface SerialInterface extends OutputInterface {
    direction: PortDirection
}

export interface VideohubConfigInterface {
    inputCount: number
    outputCount: number
    monitoringCount: number
    serialCount: number
}

export interface ChangeEventInterface {
    type: string
    value: any
}

export interface VideohubAdapterInterface {
    getConfig (): VideohubConfigInterface
    getName (): string
    getDeviceName (): string

    getInput (id: number): InputInterface
    getOutput (id: number): OutputInterface
    getMonitoringOutput (id: number): OutputInterface
    getSerial (id: number): SerialInterface

    process (cmd: VideohubCommand, clientId: string): boolean
    onChanges (handler: (cmd: VideohubCommand) => void): void
}
