mirror of
https://github.com/stagehacks/Cue-View.git
synced 2026-08-14 10:13:39 +00:00
new universal plugin configuration object
This commit is contained in:
+13
-5
@@ -49,6 +49,7 @@ function registerDevice(newDevice) {
|
||||
port: newDevice.port,
|
||||
addresses: newDevice.addresses,
|
||||
data: {},
|
||||
fields: {},
|
||||
pinIndex: false,
|
||||
lastDrawn: 0,
|
||||
lastHeartbeat: 0,
|
||||
@@ -65,6 +66,13 @@ function registerDevice(newDevice) {
|
||||
},
|
||||
};
|
||||
|
||||
if(PLUGINS.all[newDevice.type].config.fields){
|
||||
PLUGINS.all[newDevice.type].config.fields.forEach(field => {
|
||||
devices[id].fields[field.key] = field.value;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
VIEW.addDeviceToList(devices[id]);
|
||||
initDeviceConnection(id);
|
||||
return true;
|
||||
@@ -89,8 +97,8 @@ function initDeviceConnection(id) {
|
||||
const { type } = devices[id];
|
||||
const plugins = PLUGINS.all;
|
||||
|
||||
if (plugins[type].connectionType.includes('osc')) {
|
||||
if (plugins[type].connectionType.includes('udp')) {
|
||||
if (plugins[type].config.connectionType.includes('osc')) {
|
||||
if (plugins[type].config.connectionType.includes('udp')) {
|
||||
device.connection = new osc.UDPPort({
|
||||
localAddress: '0.0.0.0',
|
||||
remoteAddress: device.addresses[0],
|
||||
@@ -125,7 +133,7 @@ function initDeviceConnection(id) {
|
||||
device.connection.send({ address, args });
|
||||
};
|
||||
device.plugin = plugins[type];
|
||||
} else if (plugins[type].connectionType === 'TCPsocket') {
|
||||
} else if (plugins[type].config.connectionType === 'TCPsocket') {
|
||||
device.connection = new net.Socket();
|
||||
|
||||
device.connection.connect(
|
||||
@@ -155,7 +163,7 @@ function initDeviceConnection(id) {
|
||||
// log("SOCK OUT", data);
|
||||
device.connection.write(data);
|
||||
};
|
||||
} else if (plugins[type].connectionType === 'UDPsocket') {
|
||||
} else if (plugins[type].config.connectionType === 'UDPsocket') {
|
||||
device.connection = udp.createSocket('udp4');
|
||||
|
||||
device.connection.bind({ port: plugins[type].defaultPort }, () => {
|
||||
@@ -177,7 +185,7 @@ function initDeviceConnection(id) {
|
||||
}
|
||||
);
|
||||
};
|
||||
} else if (plugins[type].connectionType === 'multicast') {
|
||||
} else if (plugins[type].config.connectionType === 'multicast') {
|
||||
device.connection = udp.createSocket('udp4');
|
||||
|
||||
device.connection.bind(device.port, () => {
|
||||
|
||||
+23
-7
@@ -47,17 +47,33 @@ module.exports.init = function init(callback) {
|
||||
);
|
||||
|
||||
|
||||
if (p.heartbeatTimeout === undefined || p.heartbeatTimeout < 50) {
|
||||
if(p.heartbeatInterval){
|
||||
p.heartbeatTimeout = p.heartbeatInterval * 1.5;
|
||||
//if (p.heartbeatTimeout === undefined || p.heartbeatTimeout < 50) {
|
||||
if(p.config.heartbeatTimeout){
|
||||
p.heartbeatTimeout = p.config.heartbeatInterval * 1.5;
|
||||
}else{
|
||||
p.heartbeatTimeout = 10000;
|
||||
}
|
||||
}
|
||||
//}
|
||||
|
||||
if (p.heartbeatInterval === undefined || p.heartbeatInterval < 50) {
|
||||
p.heartbeatInterval = 5000;
|
||||
}
|
||||
if(p.config.heartbeatInterval){
|
||||
p.heartbeatInterval = Math.max(50, p.config.heartbeatInterval);
|
||||
}else{
|
||||
p.heartbeatInterval = 5000;
|
||||
}
|
||||
|
||||
// p.fields = {};
|
||||
// if(p.config.fields){
|
||||
// p.config.fields.forEach(field => {
|
||||
// p.fields[field.key] = field.value;
|
||||
// });
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
// if (p.heartbeatInterval === undefined || p.heartbeatInterval < 50) {
|
||||
// p.heartbeatInterval = 5000;
|
||||
// }
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
+5
-5
@@ -60,21 +60,21 @@ function searchAll() {
|
||||
const plugin = PLUGINS.all[p];
|
||||
|
||||
try {
|
||||
const t = plugin.searchOptions.type;
|
||||
const t = plugin.config.searchOptions.type;
|
||||
|
||||
if(t === 'TCPport'){
|
||||
if (TCPFlag) {
|
||||
searchTCP(p, plugin);
|
||||
searchTCP(p, plugin.config);
|
||||
}
|
||||
|
||||
}else if(t === 'Bonjour'){
|
||||
searchBonjour(p, plugin);
|
||||
searchBonjour(p, plugin.config);
|
||||
|
||||
}else if(t === 'UDPsocket'){
|
||||
searchUDP(p, plugin);
|
||||
searchUDP(p, plugin.config);
|
||||
|
||||
}else if(t === 'multicast'){
|
||||
searchMulticast(p, plugin);
|
||||
searchMulticast(p, plugin.config);
|
||||
|
||||
}
|
||||
|
||||
|
||||
+31
-2
@@ -197,6 +197,35 @@ function switchDevice(id) {
|
||||
document.getElementById('device-settings-port').value = activeDevice.port || '';
|
||||
document.getElementById('device-settings-pin').checked = activeDevice.pinIndex;
|
||||
|
||||
if(activeDevice.plugin.config.mayChangePort){
|
||||
document.getElementById('device-settings-port').disabled = false;
|
||||
}else{
|
||||
document.getElementById('device-settings-port').disabled = true;
|
||||
}
|
||||
|
||||
document.getElementById('device-settings-fields').innerHTML = "";
|
||||
|
||||
if(activeDevice.plugin.config.fields){
|
||||
let fields = activeDevice.plugin.config.fields;
|
||||
|
||||
fields.forEach(field => {
|
||||
let $elem = document.createElement("input");
|
||||
$elem.type = "text";
|
||||
$elem.value = activeDevice.fields[field.key] || field.value;
|
||||
$elem.name = field.key;
|
||||
$elem.onchange = function(e){
|
||||
activeDevice.fields[field.key] = $elem.value;
|
||||
field.action(activeDevice);
|
||||
}
|
||||
|
||||
if(field.type=="textinput"){
|
||||
let rowHTML =`<tr><th>${field.label}:</th><td colspan="3" id="${field.key}"></td></tr>`;
|
||||
document.getElementById('device-settings-fields').insertAdjacentHTML("beforeend", rowHTML);
|
||||
document.getElementById(field.key).appendChild($elem);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ipcRenderer.send('enableDeviceDropdown', '');
|
||||
ipcRenderer.send('setDevicePin', !DEVICE.all[id].pinIndex === false);
|
||||
};
|
||||
@@ -303,8 +332,8 @@ function populatePluginLists() {
|
||||
|
||||
Object.keys(PLUGINS.all).forEach((pluginType) => {
|
||||
const plugin = PLUGINS.all[pluginType];
|
||||
addSelect += `<option value='${pluginType}'>${plugin.defaultName}</option>`;
|
||||
typeSelect += `<option value='${pluginType}'>${plugin.defaultName}</option>`;
|
||||
addSelect += `<option value='${pluginType}'>${plugin.config.defaultName}</option>`;
|
||||
typeSelect += `<option value='${pluginType}'>${plugin.config.defaultName}</option>`;
|
||||
});
|
||||
|
||||
document.getElementById('device-settings-plugin-dropdown').innerHTML = typeSelect;
|
||||
|
||||
Reference in New Issue
Block a user