diff --git a/server/constants/mixerProtocols/StuderVistaEmber.ts b/server/constants/mixerProtocols/StuderVistaEmber.ts index 9671286f..b1ebc826 100644 --- a/server/constants/mixerProtocols/StuderVistaEmber.ts +++ b/server/constants/mixerProtocols/StuderVistaEmber.ts @@ -4,11 +4,20 @@ export const StuderVistaMaster: IMixerProtocol = { protocol: 'VISTA', label: 'Studer Vista 1-5-9', mode: "master", - FADE_DISPATCH_RESOLUTION: 50, + FADE_DISPATCH_RESOLUTION: 5, leadingZeros: false, //some OSC protocols needs channels to be 01, 02 etc. - pingCommand: [emptyMixerMessage()], + // [127, 143, 255, 254, 217, 92, 128, 48, 128, 0, 0, 0, 0 + // 7F 8F FF FE D9 5C 80 30 80 00 00 00 00 + pingCommand: [{ + mixerMessage: '7F 8F FF FE D9 5C 80 30 80 00 00 00 00', + value: 0, + type: 'real', + min: -90, + max: 10, + zero: 0 + }], pingResponseCommand: [emptyMixerMessage()], - pingTime: 0, //Bypass ping when pingTime is zero + pingTime: 6000, //Bypass ping when pingTime is zero initializeCommands: [emptyMixerMessage()], channelTypes: [{ channelTypeName: 'MONO', @@ -32,7 +41,21 @@ export const StuderVistaMaster: IMixerProtocol = { CHANNEL_MUTE_OFF: [emptyMixerMessage()] }, toMixer: { - CHANNEL_OUT_GAIN: [{ // 7f 8f ff fe d9 5c 80 30 80 a1 25 31 23 a1 21 31 1f a1 1d 31 1b a1 19 31 17 {a3} 15 31 13 a1 11 31 0f a2 0d 31 0b e1 09 31 07 63 {05 09 03 c0 06 13 00 00 00 00} + +/* +VSM gadget mono fader 1 level + + 0000 00 1b 21 c6 30 96 ac 16 2d 72 97 88 08 00 45 00 + 0010 00 5c 00 a3 40 00 80 06 00 00 0a e1 0f 0d 0a e1 + 0020 0f c4 d5 2a 1f 97 04 8c d9 46 a3 4d c7 d7 50 18 + 0030 00 fd 34 e1 00 00 + + + + + */ + + CHANNEL_OUT_GAIN: [{ // 7f 8f ff fe d9 5c 80 30 80 a1 25 31 23 a1 21 31 1f a1 1d 31 1b a1 19 31 17 {a3} 15 31 13 a1 11 31 0f a2 0d 31 0b e1 09 31 07 63 {05 09 03 c0 06 13 00 00 00 00} mixerMessage: '7f 8f ff fe d9 5c 80 30 80 a1 25 31 23 a1 21 31 1f a1 1d 31 1b a1 19 31 17 {channel} 15 31 13 a1 11 31 0f a2 0d 31 0b e1 09 31 07 63 {level}', value: 0, type: 'real', @@ -100,7 +123,15 @@ export const StuderVistaMaster: IMixerProtocol = { CHANNEL_MUTE_OFF: [emptyMixerMessage()] }, toMixer: { + /* + 0000 00 1b 21 c6 30 96 ac 16 2d 72 97 88 08 00 45 00 + 0010 00 5c 39 93 40 00 80 06 00 00 0a e1 0f 0d 0a e1 + 0020 0f c4 f5 a8 1f 97 38 06 5f b9 53 17 12 6f 50 18 + 0030 01 00 34 e1 00 00 + 7f 8f ff fe d9 5c 80 30 80 a1 25 31 23 a1 21 31 1f a1 1d 31 1b a2 19 31 17 a1 15 31 13 a1 11 31 0f a2 0d 31 0b e1 09 31 07 63 05 09 03 c0 05 3b 00 00 00 00 + */ CHANNEL_OUT_GAIN: [{ // 7f 8f ff fe d9 5c 80 30 80 a1 25 31 23 a1 21 31 1f a1 1d 31 1b a2 19 31 17 b9 15 31 13 a1 11 31 0f a2 0d 31 0b e1 09 31 07 63 05 09 03 80 03 05 00 00 00 00 + // 7f 8f ff fe d9 5c 80 30 80 a1 25 31 23 a1 21 31 1f a1 1d 31 1b a2 19 31 17 a1 15 31 13 a1 11 31 0f a2 0d 31 0b e1 09 31 07 63 05 09 03 c0 05 3b 00 00 00 00 mixerMessage: '7f 8f ff fe d9 5c 80 30 80 a1 25 31 23 a1 21 31 1f a1 1d 31 1b a2 19 31 17 {channel} 15 31 13 a1 11 31 0f a2 0d 31 0b e1 09 31 07 63 {level}', value: 0, type: 'real', diff --git a/server/utils/mixerConnections/StuderVistaMixerConnection.ts b/server/utils/mixerConnections/StuderVistaMixerConnection.ts index 229c8b7a..5642aaf2 100644 --- a/server/utils/mixerConnections/StuderVistaMixerConnection.ts +++ b/server/utils/mixerConnections/StuderVistaMixerConnection.ts @@ -2,6 +2,7 @@ import { EmberClient, BER } from 'node-emberplus' import { store, state } from '../../reducers/store' import { huiRemoteConnection } from '../../mainClasses' +const net = require('net') //Utils: import { IMixerProtocol } from '../../constants/MixerProtocolInterface'; @@ -19,6 +20,7 @@ export class StuderVistaMixerConnection { emberConnection: EmberClient deviceRoot: any; emberNodeObject: Array; + socket: any constructor(mixerProtocol: IMixerProtocol) { this.sendOutMessage = this.sendOutMessage.bind(this); @@ -32,6 +34,7 @@ export class StuderVistaMixerConnection { state.settings[0].deviceIp, state.settings[0].devicePort ); + /* this.emberConnection.on('error', (error: any) => { if ( (error.message + '').match(/econnrefused/i) || @@ -54,11 +57,44 @@ export class StuderVistaMixerConnection { .catch((e: any) => { console.log(e.stack); }); + */ + this.socket = net.createConnection( + { + port: 8087, + host: "10.225.15.196", + timeout: 20000000 + }, + () => { + // Disable connect timeout to hand-over to keepalive mechanism + // this.socket.setTimeout(20000000); + } + ) + this.socket.on('data', (data: any) => { + console.log('Ember Server data recieved'); + // this.socket.write(data) + }) + + // When connection disconnected. + this.socket.on('end',() => { + console.log('Ember Client socket disconnect. '); + }) + + this.socket.on('timeout', () => { + console.log('Ember Client connection timeout. '); + }) + + this.socket.on('error', (err: any) => { + console.error(JSON.stringify(err)); + }) + + this.socket.on('connect', () => { + this.setupMixerConnection() + }) } setupMixerConnection() { - logger.info('Ember connection established - setting up subscription of channels') - + logger.info('Ember connection established') +/* let ch: number = 1; state.settings[0].numberOfChannelsInType.forEach((numberOfChannels, typeIndex) => { for (let channelTypeIndex=0; channelTypeIndex < numberOfChannels ; channelTypeIndex++) { @@ -66,6 +102,7 @@ export class StuderVistaMixerConnection { ch++; } }) + */ /* .CHANNEL_VU)){ store.dispatch({ @@ -133,16 +170,12 @@ export class StuderVistaMixerConnection { } pingMixerCommand() { - //Ping Ember mixer if mixerProtocol needs it. - return; this.mixerProtocol.pingCommand.map((command) => { - this.sendOutMessage( - command.mixerMessage, - 0, - command.value, - command.type - ); - }); + let hexArray = command.mixerMessage.split(' ') + let buf = new Buffer(hexArray.map((val:string) => { return parseInt(val, 16) })) + this.socket.write(buf) + console.log('WRITING PING TO MIXER') + }) } sendOutMessage(mixerMessage: string, channel: number, value: string | number, type: string) { @@ -194,11 +227,11 @@ export class StuderVistaMixerConnection { bufferString += ('0' + element.toString(16)).slice(-2) + ' ' }); levelMessage = levelMessage.replace('{channel}', ('0' + channelByte[0].toString(16)).slice(-2)) - levelMessage = levelMessage.replace('{level}', (bufferString + '00 00 00 00 00').slice(0, 32)) + levelMessage = levelMessage.replace('{level}', (bufferString + '00 00 00 00 00').slice(3, 35)) let hexArray = levelMessage.split(' ') let buf = new Buffer(hexArray.map((val:string) => { return parseInt(val, 16) })) - this.emberConnection._client.socket.write(buf) + this.socket.write(buf) logger.verbose("Send HEX: " + levelMessage) } @@ -218,7 +251,6 @@ export class StuderVistaMixerConnection { } updateOutLevel(channelIndex: number) { - let channelTypeIndex = state.channels[0].channel[channelIndex].channelTypeIndex; let outputlevel = state.channels[0].channel[channelIndex].outputLevel let level = 20 * Math.log((1.3*outputlevel)/0.775) if (level < -90) { @@ -227,13 +259,12 @@ export class StuderVistaMixerConnection { // console.log('Log level :', level) this.sendOutLevelMessage( - channelTypeIndex+1, + channelIndex+1, level, ); } updateFadeIOLevel(channelIndex: number, outputLevel: number) { - let channelTypeIndex = state.channels[0].channel[channelIndex].channelTypeIndex; let level = 20 * Math.log((1.3*outputLevel)/0.775) if (level < -90) { level = -90 @@ -241,7 +272,7 @@ export class StuderVistaMixerConnection { // console.log('Log level :', level) this.sendOutLevelMessage( - channelTypeIndex+1, + channelIndex+1, level ) }