-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
90 lines (85 loc) · 2.76 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import ConnectionProviderSerial from '../../connectionProviders/ConnectionProviderSerial'
class DeviceProviderHarrisPanacea extends ConnectionProviderSerial {
constructor (_device) {
super(_device)
this.levels = []
}
static providerRegistration = {
id: 'DeviceProviderHarrisPanacea',
label: 'Harris Panacea Router',
manufacturer: 'Harris',
protocol: 'Serial',
description: 'The fully programmable Panacea router offers comprehensive format coverage, including HD-SDI, SDI/ASI, AES, and analogue video and audio in a flexible array of matrix sizes.',
category: 'Router',
parameters: this.parameters,
constructor: DeviceProviderHarrisPanacea
}
providerFunctions = () => new Promise(resolve => {
const levelArray = [
{ id: '00', label: 'SDI', disabled: true },
{ id: '01', label: 'ANALOG AUDIO', disabled: true }
]
if (this.levels.length === 0) {
this.serialport.write('INFORMATION\r\n')
const levelData = []
const listener = data => {
levelData.push(data)
if (data.match(/Level 15: ((\d\d\dx\d\d\d)|(-------))/gm)) {
this.parser.removeListener('data', listener)
levelData.join('\n').match(/\d\d: \d\d\dx\d\d\d/gm).map(level => { levelArray[Number(level.slice(0, 2))].disabled = false })
this.levels = levelArray
}
}
this.parser.addListener('data', listener)
}
resolve([
{
id: 'crosspoint',
label: 'Crosspoint Route',
parameters: [
{
inputType: 'comboBox',
label: 'Level',
id: 'level',
items: this.levels.length === 0 ? levelArray : this.levels,
required: true,
placeholder: 'Router Level',
tooltip: 'The Router Level is typically which signal this XPT will switch.'
},
{
inputType: 'numberInput',
id: 'dst',
label: 'Destination',
required: true,
placeholder: 'Destination',
min: 1
},
{
inputType: 'numberInput',
id: 'src',
label: 'Source',
required: true,
placeholder: 'Source',
min: 1
}
]
}
])
})
interface = (_action) => {
switch (_action.providerFunction.id) {
case 'crosspoint': // Clear Composition
this.connectionProviderInterface({
message: `LEVEL ${_action.parameters.level.id}`
})
this.connectionProviderInterface({
message: `SOURCE ${_action.parameters.src}`
})
this.connectionProviderInterface({
message: `DESTINATION ${_action.parameters.dst}`
})
break
}
}
}
export default DeviceProviderHarrisPanacea