Debug last commit
This commit is contained in:
parent
dc4804c3f1
commit
c649c4e234
34
main.js
34
main.js
|
|
@ -37,7 +37,7 @@ const PRESETS = [
|
||||||
{ id: '8' , label: 'Preset #8' , name: 'Preset8' , var_name: 'pst_name_8' }
|
{ id: '8' , label: 'Preset #8' , name: 'Preset8' , var_name: 'pst_name_8' }
|
||||||
];
|
];
|
||||||
|
|
||||||
class MixerInstance extends InstanceBase {
|
class MATRIXInstance extends InstanceBase {
|
||||||
constructor(internal) {
|
constructor(internal) {
|
||||||
super(internal);
|
super(internal);
|
||||||
Object.assign(this, {
|
Object.assign(this, {
|
||||||
|
|
@ -152,10 +152,10 @@ class MixerInstance extends InstanceBase {
|
||||||
initTCP() {
|
initTCP() {
|
||||||
this.killTCP();
|
this.killTCP();
|
||||||
|
|
||||||
this.log('info', `PT-MA-HD44M MIXER | INIT TCP CONNECTION >>> ${this.config.host} ${this.config.port}`);
|
this.log('info', `PT-MA-HD44M MATRIX | INIT TCP CONNECTION >>> ${this.config.host} ${this.config.port}`);
|
||||||
|
|
||||||
if(this.config.host && this.config.port) {
|
if(this.config.host && this.config.port) {
|
||||||
this.log('info', `PT-MA-HD44M MIXER | Opening TCP connection to ${this.config.host}:${this.config.port}`);
|
this.log('info', `PT-MA-HD44M MATRIX | Opening TCP connection to ${this.config.host}:${this.config.port}`);
|
||||||
this.socket = new TCPHelper(this.config.host, this.config.port, { reconnect: true });
|
this.socket = new TCPHelper(this.config.host, this.config.port, { reconnect: true });
|
||||||
|
|
||||||
this.socket.on('status_change', (status, message) => {
|
this.socket.on('status_change', (status, message) => {
|
||||||
|
|
@ -163,7 +163,7 @@ class MixerInstance extends InstanceBase {
|
||||||
this.setVariableValues({connect_status: status});
|
this.setVariableValues({connect_status: status});
|
||||||
this.checkFeedbacks('connect_status');
|
this.checkFeedbacks('connect_status');
|
||||||
|
|
||||||
this.log('info', `PT-MA-HD44M MIXER | TCP connection status changed >>> ${status}`);
|
this.log('info', `PT-MA-HD44M MATRIX | TCP connection status changed >>> ${status}`);
|
||||||
if(status=="ok") {
|
if(status=="ok") {
|
||||||
this.sendCommand('#get info');
|
this.sendCommand('#get info');
|
||||||
}
|
}
|
||||||
|
|
@ -174,7 +174,7 @@ class MixerInstance extends InstanceBase {
|
||||||
|
|
||||||
this.socket.on('error', (err) => {
|
this.socket.on('error', (err) => {
|
||||||
this.updateStatus(InstanceStatus.ConnectionFailure, err.message);
|
this.updateStatus(InstanceStatus.ConnectionFailure, err.message);
|
||||||
this.log('error', 'PT-MA-HD44M MIXER | Network error: ' + err.message);
|
this.log('error', 'PT-MA-HD44M MATRIX | Network error: ' + err.message);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.socket.on('data', (chunk) => {
|
this.socket.on('data', (chunk) => {
|
||||||
|
|
@ -228,20 +228,20 @@ class MixerInstance extends InstanceBase {
|
||||||
var cmd = cue.cmd;
|
var cmd = cue.cmd;
|
||||||
var escCmd = unescape(await this.parseVariablesInString(cmd));
|
var escCmd = unescape(await this.parseVariablesInString(cmd));
|
||||||
if(escCmd!="") {
|
if(escCmd!="") {
|
||||||
this.log('debug', `PT-MA-HD44M MIXER | SENDIND COMMAND >>> ${escCmd} | callback: ${cue.clbk}`);
|
this.log('debug', `PT-MA-HD44M MATRIX | SENDIND COMMAND >>> ${escCmd} | callback: ${cue.clbk}`);
|
||||||
const sendBuf = Buffer.from(escCmd+"\n", 'latin1');
|
const sendBuf = Buffer.from(escCmd+"\n", 'latin1');
|
||||||
if(this.socket !== undefined && this.socket.isConnected) {
|
if(this.socket !== undefined && this.socket.isConnected) {
|
||||||
currentCmd = cue;
|
currentCmd = cue;
|
||||||
this.socket.send(sendBuf);
|
this.socket.send(sendBuf);
|
||||||
tcpSendTimeout = setTimeout(function(self) { self.onSendCommandTimeout(); }, this.config.timeout, this);
|
tcpSendTimeout = setTimeout(function(self) { self.onSendCommandTimeout(); }, this.config.timeout, this);
|
||||||
}
|
}
|
||||||
else this.log('warn', `PT-MA-HD44M MIXER | CANNOT SEND COMMAND - Socket not connected >>> ${cmd}`);
|
else this.log('warn', `PT-MA-HD44M MATRIX | CANNOT SEND COMMAND - Socket not connected >>> ${cmd}`);
|
||||||
}
|
}
|
||||||
else if(tcpCommandBuffer.length>0) this.sendNextCommand();
|
else if(tcpCommandBuffer.length>0) this.sendNextCommand();
|
||||||
}
|
}
|
||||||
|
|
||||||
onSendCommandTimeout() {
|
onSendCommandTimeout() {
|
||||||
this.log('warn', `PT-MA-HD44M MIXER | SEND COMMAND TIMEOUT >>> ${currentCmd.cmd}`);
|
this.log('warn', `PT-MA-HD44M MATRIX | SEND COMMAND TIMEOUT >>> ${currentCmd.cmd}`);
|
||||||
tcpSendTimeout = undefined;
|
tcpSendTimeout = undefined;
|
||||||
currentCmd = false;
|
currentCmd = false;
|
||||||
this.sendNextCommand();
|
this.sendNextCommand();
|
||||||
|
|
@ -257,7 +257,7 @@ class MixerInstance extends InstanceBase {
|
||||||
parseReceivedMessage(msg) {
|
parseReceivedMessage(msg) {
|
||||||
if(tcpSendTimeout) { clearTimeout(tcpSendTimeout); tcpSendTimeout=undefined; }
|
if(tcpSendTimeout) { clearTimeout(tcpSendTimeout); tcpSendTimeout=undefined; }
|
||||||
|
|
||||||
this.log('debug', `PT-MA-HD44M MIXER | receive message > "${msg}"`);
|
this.log('debug', `PT-MA-HD44M MATRIX | receive message > "${msg}"`);
|
||||||
|
|
||||||
let namePos = msg.indexOf("[name=");
|
let namePos = msg.indexOf("[name=");
|
||||||
let endNamePos = msg.indexOf("]");
|
let endNamePos = msg.indexOf("]");
|
||||||
|
|
@ -270,7 +270,7 @@ class MixerInstance extends InstanceBase {
|
||||||
let ipt = this.getIptByID( msg.substr(6,1) );
|
let ipt = this.getIptByID( msg.substr(6,1) );
|
||||||
let name = msg.slice(namePos+6, endNamePos);
|
let name = msg.slice(namePos+6, endNamePos);
|
||||||
if(ipt && ipt.name != name) {
|
if(ipt && ipt.name != name) {
|
||||||
this.log('info', `PT-MA-HD44M MIXER | INPUT #${ipt.id} - NAME CHANGED >>> ${name}`);
|
this.log('info', `PT-MA-HD44M MATRIX | INPUT #${ipt.id} - NAME CHANGED >>> ${name}`);
|
||||||
ipt.name = name;
|
ipt.name = name;
|
||||||
INPUTS[ipt.num] = ipt;
|
INPUTS[ipt.num] = ipt;
|
||||||
this.setVariableValue(ipt.var_name, name);
|
this.setVariableValue(ipt.var_name, name);
|
||||||
|
|
@ -281,7 +281,7 @@ class MixerInstance extends InstanceBase {
|
||||||
let out = this.getOutByID( msg.substr(7,1) );
|
let out = this.getOutByID( msg.substr(7,1) );
|
||||||
let name = msg.slice(namePos+6, endNamePos);
|
let name = msg.slice(namePos+6, endNamePos);
|
||||||
if(out && out.name != name) {
|
if(out && out.name != name) {
|
||||||
this.log('info', `PT-MA-HD44M MIXER | OUTPUT #${out.id} - NAME CHANGED >>> ${name}`);
|
this.log('info', `PT-MA-HD44M MATRIX | OUTPUT #${out.id} - NAME CHANGED >>> ${name}`);
|
||||||
out.name = name;
|
out.name = name;
|
||||||
OUTPUTS[out.num] = out;
|
OUTPUTS[out.num] = out;
|
||||||
this.setVariableValue(out.var_name, name);
|
this.setVariableValue(out.var_name, name);
|
||||||
|
|
@ -292,7 +292,7 @@ class MixerInstance extends InstanceBase {
|
||||||
let pst = this.getPstByID( msg.substr(7,1) );
|
let pst = this.getPstByID( msg.substr(7,1) );
|
||||||
let name = msg.slice(namePos+6, endNamePos);
|
let name = msg.slice(namePos+6, endNamePos);
|
||||||
if(pst && pst.name != name) {
|
if(pst && pst.name != name) {
|
||||||
this.log('info', `PT-MA-HD44M MIXER | PRESET #${pst.id} - NAME CHANGED >>> ${name}`);
|
this.log('info', `PT-MA-HD44M MATRIX | PRESET #${pst.id} - NAME CHANGED >>> ${name}`);
|
||||||
pst.name = name;
|
pst.name = name;
|
||||||
PRESETS[pst.num] = pst;
|
PRESETS[pst.num] = pst;
|
||||||
this.setVariableValue(pst.var_name, name);
|
this.setVariableValue(pst.var_name, name);
|
||||||
|
|
@ -304,7 +304,7 @@ class MixerInstance extends InstanceBase {
|
||||||
let out = this.getOutByID( msg.substr(7,1) );
|
let out = this.getOutByID( msg.substr(7,1) );
|
||||||
let xpt = (parseInt( msg.slice(dataPos+6, endDataPos) ) + 1).toString();
|
let xpt = (parseInt( msg.slice(dataPos+6, endDataPos) ) + 1).toString();
|
||||||
if(out && out.xpt != xpt) {
|
if(out && out.xpt != xpt) {
|
||||||
this.log('info', `PT-MA-HD44M MIXER | OUTPUT #${out.id} - XPT CHANGED >>> ${xpt}`);
|
this.log('info', `PT-MA-HD44M MATRIX | OUTPUT #${out.id} - XPT CHANGED >>> ${xpt}`);
|
||||||
out.xpt = xpt;
|
out.xpt = xpt;
|
||||||
OUTPUTS[out.num] = out;
|
OUTPUTS[out.num] = out;
|
||||||
this.setVariableValue(out.var_xpt, xpt);
|
this.setVariableValue(out.var_xpt, xpt);
|
||||||
|
|
@ -355,12 +355,12 @@ class MixerInstance extends InstanceBase {
|
||||||
|
|
||||||
// SAVE
|
// SAVE
|
||||||
if(p[2] == "Save") {
|
if(p[2] == "Save") {
|
||||||
this.log('info', `PT-MA-HD44M MIXER | PRESET #${pst.id} SAVED >>> ${p[1]}`);
|
this.log('info', `PT-MA-HD44M MATRIX | PRESET #${pst.id} SAVED >>> ${p[1]}`);
|
||||||
this.saveLastPstID(pst.id);
|
this.saveLastPstID(pst.id);
|
||||||
}
|
}
|
||||||
// CALL
|
// CALL
|
||||||
else if(p[2] == "Call") {
|
else if(p[2] == "Call") {
|
||||||
this.log('info', `PT-MA-HD44M MIXER | PRESET #${pst.id} RECALLED >>> ${p[1]}`);
|
this.log('info', `PT-MA-HD44M MATRIX | PRESET #${pst.id} RECALLED >>> ${p[1]}`);
|
||||||
this.saveLastPstID(pst.id);
|
this.saveLastPstID(pst.id);
|
||||||
|
|
||||||
// REFRESH INFO
|
// REFRESH INFO
|
||||||
|
|
@ -368,7 +368,7 @@ class MixerInstance extends InstanceBase {
|
||||||
}
|
}
|
||||||
// CLEAR
|
// CLEAR
|
||||||
else if(p[2] == "Clear") {
|
else if(p[2] == "Clear") {
|
||||||
this.log('info', `PT-MA-HD44M MIXER | PRESET #${pst.id} CLEARED >>> ${p[1]}`);
|
this.log('info', `PT-MA-HD44M MATRIX | PRESET #${pst.id} CLEARED >>> ${p[1]}`);
|
||||||
if(this.getLastPstID() == pst.id) this.saveLastPstID(0);
|
if(this.getLastPstID() == pst.id) this.saveLastPstID(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -398,4 +398,4 @@ class MixerInstance extends InstanceBase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
runEntrypoint(MixerInstance, []);
|
runEntrypoint(MATRIXInstance, []);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue