Skip to content

Commit 79ede3b

Browse files
authored
Merge pull request #184 from NoahCallaway/master
add support for outgoing TSL UMD 5
2 parents f2418df + 759e979 commit 79ede3b

File tree

4 files changed

+128
-3
lines changed

4 files changed

+128
-3
lines changed

docs/docs/usage/sections/devices.md

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Once a device is assigned to a source(s), if a matching condition is met, an act
2323

2424
The following Device Actions are implemented:
2525
* TSL 3.1 UDP/TCP
26+
* TSL 5.0 UDP/TCP
2627
* Outgoing Webhook
2728
* Generic TCP
2829
* Local Console Output/Logging (useful for testing)

index.js

+96-3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
const net = require('net');
55
const packet = require('packet');
66
const TSLUMD = require('tsl-umd'); // TSL UDP package
7+
const TSLUMDv5 = require('tsl-umd-v5');
78
const dgram = require('dgram');
89
const { Atem } = require('atem-connection');
910
const AtemListVisibleInputs = require('atem-connection').listVisibleInputs;
@@ -633,6 +634,8 @@ var source_types_panasonic = [ // AV-HS410 INPUTS
633634
var output_types = [ //output actions that Tally Arbiter can perform
634635
{ id: '7dcd66b5', label: 'TSL 3.1 UDP', type: 'tsl_31_udp', enabled: true},
635636
{ id: '276a8dcc', label: 'TSL 3.1 TCP', type: 'tsl_31_tcp', enabled: true },
637+
{ id: '8b99d588', label: 'TSL 5 UDP', type: 'tsl_5_udp', enabled: true },
638+
{ id: '54ae4a7e', label: 'TSL 5 TCP', type: 'tsl_5_tcp', enabled: true },
636639
{ id: 'ffe2b0b6', label: 'Outgoing Webhook', type: 'webhook', enabled: true},
637640
{ id: '79e3ce27', label: 'Generic TCP', type: 'tcp', enabled: true},
638641
{ id: '4827f903', label: 'RossTalk', type: 'rosstalk', enabled: true},
@@ -663,6 +666,30 @@ var output_types_datafields = [ //data fields for the outgoing actions
663666
{ fieldName: 'tally4', fieldLabel: 'Tally 4', fieldType: 'bool' }
664667
]
665668
},
669+
{ outputTypeId: '8b99d588', fields: [ //TSL 5 UDP
670+
{ fieldName: 'ip', fieldLabel: 'IP Address', fieldType: 'text' },
671+
{ fieldName: 'port', fieldLabel: 'Port', fieldType: 'port' },
672+
{ fieldName: 'index', fieldLabel: 'Address Index', fieldType: 'number' },
673+
{ fieldName: 'screen', fieldLabel: 'Screen', fieldType: 'number' },
674+
{ fieldName: 'text', fieldLabel: 'Label', fieldType: 'text' },
675+
{ fieldName: 'text_tally', fieldLabel: 'Text Tally', fieldType: 'dropdown', options: [ { id: '0', label: 'Off' }, { id: '1', label: 'Red'}, { id: '2', label: 'Green'}, { id: '3', label: 'Amber'} ] },
676+
{ fieldName: 'rh_tally', fieldLabel: 'Right Tally', fieldType: 'dropdown', options: [ { id: '0', label: 'Off' }, { id: '1', label: 'Red'}, { id: '2', label: 'Green'}, { id: '3', label: 'Amber'} ] },
677+
{ fieldName: 'lh_tally', fieldLabel: 'Left Tally', fieldType: 'dropdown', options: [ { id: '0', label: 'Off' }, { id: '1', label: 'Red'}, { id: '2', label: 'Green'}, { id: '3', label: 'Amber'} ] },
678+
{ fieldName: 'brightness', fieldLabel: 'Brightness', fieldType: 'dropdown', options: [ { id: '0', label: '0' }, { id: '1', label: '1'}, { id: '2', label: '2'}, { id: '3', label: '3'} ] }
679+
]
680+
},
681+
{ outputTypeId: '54ae4a7e', fields: [ //TSL 5 TCP
682+
{ fieldName: 'ip', fieldLabel: 'IP Address', fieldType: 'text' },
683+
{ fieldName: 'port', fieldLabel: 'Port', fieldType: 'port' },
684+
{ fieldName: 'index', fieldLabel: 'Address Index', fieldType: 'number' },
685+
{ fieldName: 'screen', fieldLabel: 'Screen', fieldType: 'number' },
686+
{ fieldName: 'text', fieldLabel: 'Label', fieldType: 'text' },
687+
{ fieldName: 'text_tally', fieldLabel: 'Text Tally', fieldType: 'dropdown', options: [ { id: '0', label: 'Off' }, { id: '1', label: 'Red'}, { id: '2', label: 'Green'}, { id: '3', label: 'Amber'} ] },
688+
{ fieldName: 'rh_tally', fieldLabel: 'Right Tally', fieldType: 'dropdown', options: [ { id: '0', label: 'Off' }, { id: '1', label: 'Red'}, { id: '2', label: 'Green'}, { id: '3', label: 'Amber'} ] },
689+
{ fieldName: 'lh_tally', fieldLabel: 'Left Tally', fieldType: 'dropdown', options: [ { id: '0', label: 'Off' }, { id: '1', label: 'Red'}, { id: '2', label: 'Green'}, { id: '3', label: 'Amber'} ] },
690+
{ fieldName: 'brightness', fieldLabel: 'Brightness', fieldType: 'dropdown', options: [ { id: '0', label: '0' }, { id: '1', label: '1'}, { id: '2', label: '2'}, { id: '3', label: '3'} ] }
691+
]
692+
},
666693
{ outputTypeId: 'ffe2b0b6', fields: [ //Outgoing Webhook
667694
{ fieldName: 'protocol', fieldLabel: 'Protocol', fieldType: 'dropdown', options: [ { id: 'http://', label: 'HTTP' }, { id: 'https://', label: 'HTTPS'} ] },
668695
{ fieldName: 'ip', fieldLabel: 'IP Address/URL', fieldType: 'text' },
@@ -2539,9 +2566,7 @@ function SetUpTSL5Server_TCP(sourceId)
25392566
});
25402567

25412568
socket.on('close', function () {
2542-
logger(`Source: ${source.name} TSL 5.0 Server connection closed.`, 'info');
2543-
StopTSLServer_TCP(sourceId);
2544-
CheckReconnect(sourceId);
2569+
logger(`Source: ${source.name} TSL 5.0 Server remote disconnected`, 'info');
25452570
});
25462571
}).listen(port, function() {
25472572
logger(`Source: ${source.name} TSL 5.0 Server started. Listening for data on TCP Port: ${port}`, 'info');
@@ -5259,6 +5284,12 @@ function RunAction(deviceId, busId, active) {
52595284
case 'tsl_31_tcp':
52605285
RunAction_TSL_31_TCP(actionObj.data);
52615286
break;
5287+
case 'tsl_5_udp':
5288+
RunAction_TSL_5_UDP(actionObj.data);
5289+
break;
5290+
case 'tsl_5_tcp':
5291+
RunAction_TSL_5_TCP(actionObj.data);
5292+
break;
52625293
case 'webhook':
52635294
RunAction_Webhook(actionObj.data);
52645295
break;
@@ -5365,6 +5396,68 @@ function RunAction_TSL_31_TCP(data) {
53655396
}
53665397
}
53675398

5399+
function RunAction_TSL_5_UDP(data) {
5400+
try {
5401+
var umd = new TSLUMDv5();
5402+
var display_fields = ['rh_tally', 'text_tally', 'lh_tally', 'brightness',' text']
5403+
let tally = { display: {} }
5404+
5405+
if (!data.ip | !data.port) {
5406+
logger('Error in TSL 5 UDP Action. IP and Port must be given', 'error')
5407+
}
5408+
if (!data.index) {
5409+
logger('TSL 5 UDP Action. No index given. Using index 1 by default', 'info')
5410+
tally.index = 1
5411+
}
5412+
5413+
for (var [key, value] of Object.entries(data)) {
5414+
if (display_fields.includes(key)) {
5415+
tally.display[key] = value
5416+
}
5417+
else {
5418+
tally[key] = value
5419+
}
5420+
}
5421+
5422+
umd.sendTallyUDP(data.ip, data.port, tally)
5423+
logger(`TSL 5 UDP Data sent.`, 'info');
5424+
}
5425+
catch (error) {
5426+
logger(`An error occured sending the TSL 5 UDP Message: ${error}`, 'error');
5427+
}
5428+
}
5429+
5430+
function RunAction_TSL_5_TCP(data) {
5431+
try {
5432+
var umd = new TSLUMDv5();
5433+
var display_fields = ['rh_tally', 'text_tally', 'lh_tally', 'brightness',' text']
5434+
let tally = { display: {} }
5435+
5436+
if (!data.ip | !data.port) {
5437+
logger('Error in TSL 5 TCP Action. IP and Port must be given', 'error')
5438+
}
5439+
if (!data.index) {
5440+
logger('TSL 5 TCP Action. No index given. Using index 1 by default', 'info')
5441+
tally.index = 1
5442+
}
5443+
5444+
for (var [key, value] of Object.entries(data)) {
5445+
if (display_fields.includes(key)) {
5446+
tally.display[key] = value
5447+
}
5448+
else {
5449+
tally[key] = value
5450+
}
5451+
}
5452+
5453+
umd.sendTallyTCP(data.ip, data.port, tally)
5454+
logger(`TSL 5 TCP Data sent.`, 'info');
5455+
}
5456+
catch (error) {
5457+
logger(`An error occured sending the TSL 5 TCP Message: ${error}`, 'error');
5458+
}
5459+
}
5460+
53685461
function RunAction_Webhook(data) {
53695462
try {
53705463
let path = data.path ? (data.path.startsWith('/') ? data.path : '/' + data.path) : '';

package-lock.json

+30
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
"socket.io": "4.1.2",
6464
"socket.io-client": "4.1.2",
6565
"tsl-umd": "^1.1.2",
66+
"tsl-umd-v5": "^1.0.3",
6667
"xml2js": "^0.4.23"
6768
},
6869
"main": "main.js",

0 commit comments

Comments
 (0)