@parallaxcontrol/node-red-control
Version:
A comprehensive package of Node-RED nodes designed to seamlessly integrate with the Parallax Control Engine, offering enhanced control capabilities for AV Automation.
389 lines (380 loc) • 16.9 kB
JavaScript
const { exec } = require('child_process');
module.exports = function (RED) {
function AVProACCX42(config) {
RED.nodes.createNode(this, config);
var node = this;
// Store selection of the node configuration (as defined in the .html)
this.selection = config.makeSelection;
node.on('input', function(msg) {
let command;
// Extract values from the message payload
this.x = Number(msg.payload.x);
this.y = Number(msg.payload.y);
this.z = Number(msg.payload.z);
this.zzzz = Number(msg.payload.zzzz);
this.ip = String(msg.payload.ip);
this.xx = String(msg.payload.xx);
this.yy = String(msg.payload.yy);
this.zz = String(msg.payload.zz);
// Define the commands
// Construct the command string
H = `H`;
STA = `STA`;
SETRBT = `SET RBT`;
SETRST = `SET RST`;
SETADDRxx = `SET ADDR ${node.xx}`; // Set System Address to xx {xx=[00~99](00=Single)}
GETADDR = `GET ADDR`;
GETSTA = `GET STA`;
GETINxSIGSTA = `GET IN${node.x} SIG STA`; // Get Input x Signal Status{x=[0~4](0=ALL)}
////////////////////////////////
//Output Setup Commands
////////////////////////////////
SETOUTxVSINy = `SET OUT${node.x} VS IN${node.y}`; // Set Output x To Input y{x=[0~2](0=ALL), y=[1~4]}
SETOUT1VIDEOy = `SET OUT1 VIDEO${node.y}`; // Set Output1 VIDEO Mode {y=[2,5](2=4K->2K,5=ICT Mode)}
SETEXABTVOUTx = `SET EXA BTV OUT${node.x}`; // Set Ex-Audio Output bind to Outputx{x=[1~2]}
SETSWITCHMODEx = `SET SWITCH MODE${node.x}`; // Set Switch Mode To Single Switch or Double Switch{x=[0~1]}
SETOUTxEXAENDIS = `SET OUT${node.x} EXA EN/DIS`; // Set Ex-Audio Output Enable/Disable{x=[0~1](0=ALL)}
SETOUTxEXAUDLEVy = `SET OUT${node.x} EXAUD LEV${node.y}`; // Set Output x Ex-Audio(Balanced) Volume Levely{x=[0~1](0=ALL),y=[0~100]}
SETOUT1EXAMICENDIS = `SET OUT1 EXA MIC EN/DIS`; // Set EX-Audio Route to Microphone Input Enable/Disable
SETOUTxSTREAMONOFF = `SET OUT${node.x} STREAM ON/OFF`; // Set Output x Stream ON/OFF{x=[0~2](0=ALL)}
SETOUTxHDMISTREAMMODEy = `SET OUT${node.x} HDMI STREAM MODE ${node.y}`; // Set Output x HDMI Stream Mode y{x=[2],y=[1,2](1-Force 5V Low,2-Force 5V High)}
SETOUT1TPPOEy = `SET OUT1 TP POE ${node.y}`; // Set Output1 POE Mode{y=[0~1](0=Auto,1=Force)}
SETOUTxHAMUTEONOFF = `SET OUT${node.x} HA MUTE ON/OFF`; // Set HDMI Output x Audio Mute ON/OFF{x=[0~2](0=ALL)}
SETOUT1TPSGMENDIS = `SET OUT1 TP SGM EN/DIS`; // Set HDBT Output Signal Generator Enable/Disable
SETOUT2HPSGMENDIS = `SET OUT2 HP SGM EN/DIS`; // Set HDMI Output Signal Generator Enable/Disable
GETOUTxVS = `GET OUT${node.x} VS`; // Get Output x Video Route{x=[0~2](0=ALL)}
GETOUT1VIDEO = `GET OUT1 VIDEO`; // Get Output1 Video Mode
GETEXABTVOUT = `GET EXA BTV OUT`;// Get Ex-Audio Output bind to Which Output
GETSWITCHMODE = `GET SWITCH MODE`;// Get Switch Mode
GETOUTxEXA = `GET OUT${node.x} EXA`; // Get Ex-Audio Output Enable/Disable Status{x=[0~1](0=ALL)}
GETOUTxEXAUDLEV = `GET OUT${node.x} EXAUD LEV`; // Get Output x Ex-Audio(Balanced) Volume Level{x=[0~1](0=ALL)}
GETOUT1EXAMIC = `GET OUT1 EXA MIC`;// Get EX-Audio Route to Microphone Input Enable/Disable Status
GETOUTxEDIDDATA = `GET OUT${node.x} EDID DATA`; // Get Output x EDID DATA{x=[1~2]}
GETOUTxSTREAM = `GET OUT${node.x} STREAM`; // Get Output x Stream ON/OFF Status{x=[0~2](0=ALL)}
GETOUTxHDMISTREAMMODE = `GET OUT${node.x} HDMI STREAM MODE`; // Get Output x HDMI Stream Mode Status{x=[2]}
GETOUT1TPPOE = `GET OUT1 TP POE`;// Get Output1 POE Mode
GETOUTxHAMUTE = `GET OUT${node.x} HA MUTE`; // Get HDMI Output x Audio Mute Status{x=[0~2](0=ALL)}
GETOUT1TPSGM = `GET OUT1 TP SGM`;// Get HDBT Output Signal Generator Enable/Disable Status
GETOUT2HPSGM = `GET OUT2 HP SGM`;// Get HDMI Output Signal Generator Enable/Disable Status
////////////////////////////////
//Input Setup Commands
////////////////////////////////
SETINxEDIDy = `SET IN${node.x} EDID ${node.y}`; // Set Input x EDID{x=[0~4](0=ALL), y=[0~32]}
SETINxEDIDCYOUTy = `SET IN${node.x} EDID CY OUT${node.y}`; // Copy Output y EDID To Input x(USER1 BUF){x=[0~4](0=ALL), y=[1~2]}
SETINxEDIDUyDATAz = `SET IN${node.x} EDID U${node.y} DATA${node.z}`; // Write EDID To User y Buffer of Input x{x=[0~4](0=ALL), y=[1~3],z=[EDID Data]}
SETIN1TPPOEy = `SET IN1 TP POE ${node.y}`; // Set IN1 POE Mode{y=[0~1](0=Auto,1=Force)}
GETINxEDID = `GET IN${node.x} EDID`; // Get Input x EDID Index{x=[0~4](0=ALL)}
GETINxEDIDyDATA = `GET IN${node.x} EDID ${node.y} DATA`; // Get Input x EDID y Data{x=[1~4],y=[0~32]}
GETIN1TPPOE = `GET IN1 TP POE`;// Get IN1 POE Mode
////////////////////////////////
//Auto Mode
////////////////////////////////
SETHDxAUTOENDIS = `SET HD${node.x} AUTO EN/DIS`; // Set HDMI1/HDMI2 Output Enter Auto Mode Control Enable/Disable {x=0(HDMI1&HDMI2 Output),x=1(HDMI1 Output),x=2(HDMI2 Output)}
GETHDxAUTO = `GET HD${node.x} AUTO`; // Get HDMI1/HDMI2 Output Auto Mode Control Status
////////////////////////////////
//Network Setup Command
////////////////////////////////
SETRIPxxxxxxxxxxxx = `SET RIP ${node.ip}`; // Set Route IP Address to xxx.xxx.xxx.xxx
SETHIPxxxxxxxxxxxx = `SET HIP ${node.ip}`; // Set Host IP Address to xxx.xxx.xxx.xxx
SETNMKxxxxxxxxxxxx = `SET NMK ${node.ip}`; // Set Net Mask to xxx.xxx.xxx.xxx
SETTIPzzzz = `SET TIP ${node.zzzz}`; // Set TCP/IP Port to zzzz
SETDHCPy = `SET DHCP ${node.y}`; // Set DHCP {y=[0~1](0=Dis,1=Enable)}
GETRIP = `GET RIP`; // Get Route IP Address
GETHIP = `GET HIP`; // Get Host IP Address
GETNMK = `GET NMK`;// Get Net Mask
GETTIP = `GET TIP`; // Get TCP/IP Port
GETDHCP = `GET DHCP`;// Get DHCP Status
GETMAC = `GET MAC`; // Get MAC Address
////////////////////////////////
//RS232 Route Setup Command
////////////////////////////////
SETRSHRFIxOx = `SET RS HRF I${node.x}/O${node.x}`; // Set HDBT RS232 RX From Input or Output Port x{x=[1](I=Input,O=Output)}
SETRSPTHOUTxLENyBRz = `SET RS PTH OUT${node.x} LEN${node.y} BR${node.z}`; // Set RS232 Pass Through to Ouput x
SETRSPTHINxLENyBRz = `SET RS PTH IN${node.x} LEN${node.y} BR${node.z}`; // Set RS232 Pass Through to Input x
GETRSHRF = `GET RS HRF`;// Get HDBT RS232 RX From Port State
////////////////////////////////
//IR Code Setup Command
////////////////////////////////
SETIRSYSxxyy = `SET IR SYS ${node.xx}.${node.yy}`; // Set IR Custom Code{xx=[00-FFH],yy=[00-FFH]}
SETIROUTxINyCODEzz = `SET IR OUT${node.x} IN${node.y} CODE ${node.zz}`; // Set IR Data Code{x=[1~2],y=[1~4],zz=[00-FFH]}
GETIRSYS = `GET IR SYS`;// Get IR Custom Code
GETIROUTxINyCODE = `GET IR OUT${node.x} IN${node.y} CODE`; // Get IR Data Code
////////////////////////////////
// Switch on the selection
switch(node.selection) {
case "H": {
command = H;
break;
}
case "STA": {
command = STA;
break;
}
case "SETRBT": {
command = SETRBT;
break;
}
case "SETRST": {
command = SETRST;
break;
}
case "SETADDRxx": {
command = SETADDRxx;
break;
}
case "GETADDR": {
command = GETADDR;
break;
}
case "GETSTA": {
command = GETSTA;
break;
}
case "GETINxSIGSTA": {
command = GETINxSIGSTA;
break;
}
case "SETOUTxVSINy": {
command = SETOUTxVSINy;
break;
}
case "SETOUT1VIDEOy": {
command = SETOUT1VIDEOy;
break;
}
case "SETEXABTVOUTx": {
command = SETEXABTVOUTx;
break;
}
case "SETSWITCHMODEx": {
command = SETSWITCHMODEx;
break;
}
case "SETOUTxEXAENDIS": {
command = SETOUTxEXAENDIS;
break;
}
case "SETOUTxEXAUDLEVy": {
command = SETOUTxEXAUDLEVy;
break;
}
case "SETOUT1EXAMICENDIS": {
command = SETOUT1EXAMICENDIS;
break;
}
case "SETOUTxSTREAMONOFF": {
command = SETOUTxSTREAMONOFF;
break;
}
case "SETOUTxHDMISTREAMMODEy": {
command = SETOUTxHDMISTREAMMODEy;
break;
}
case "SETOUT1TPPOEy": {
command = SETOUT1TPPOEy;
break;
}
case "SETOUTxHAMUTEONOFF": {
command = SETOUTxHAMUTEONOFF;
break;
}
case "SETOUT1TPSGMENDIS": {
command = SETOUT1TPSGMENDIS;
break;
}
case "SETOUT2HPSGMENDIS": {
command = SETOUT2HPSGMENDIS;
break;
}
case "GETOUTxVS": {
command = GETOUTxVS;
break;
}
case "GETOUT1VIDEO": {
command = GETOUT1VIDEO;
break;
}
case "GETEXABTVOUT": {
command = GETEXABTVOUT;
break;
}
case "GETSWITCHMODE": {
command = GETSWITCHMODE;
break;
}
case "GETOUTxEXA": {
command = GETOUTxEXA;
break;
}
case "GETOUTxEXAUDLEV": {
command = GETOUTxEXAUDLEV;
break;
}
case "GETOUT1EXAMIC": {
command = GETOUT1EXAMIC;
break;
}
case "GETOUTxEDIDDATA": {
command = GETOUTxEDIDDATA;
break;
}
case "GETOUTxSTREAM": {
command = GETOUTxSTREAM;
break;
}
case "GETOUTxHDMISTREAMMODE": {
command = GETOUTxHDMISTREAMMODE;
break;
}
case "GETOUT1TPPOE": {
command = GETOUT1TPPOE;
break;
}
case "GETOUTxHAMUTE": {
command = GETOUTxHAMUTE;
break;
}
case "GETOUT1TPSGM": {
command = GETOUT1TPSGM;
break;
}
case "GETOUT2HPSGM": {
command = GETOUT2HPSGM;
break;
}
case "SETINxEDIDy": {
command = SETINxEDIDy;
break;
}
case "SETINxEDIDCYOUTy": {
command = SETINxEDIDCYOUTy;
break;
}
case "SETINxEDIDUyDATAz": {
command = SETINxEDIDUyDATAz;
break;
}
case "SETIN1TPPOEy": {
command = SETIN1TPPOEy;
break;
}
case "GETINxEDID": {
command = GETINxEDID;
break;
}
case "GETINxEDIDyDATA": {
command = GETINxEDIDyDATA;
break;
}
case "GETIN1TPPOE": {
command = GETIN1TPPOE;
break;
}
case "SETHDxAUTOENDIS": {
command = SETHDxAUTOENDIS;
break;
}
case "GETHDxAUTO": {
command = GETHDxAUTO;
break;
}
case "SETRIPxxxxxxxxxxxx": {
command = SETRIPxxxxxxxxxxxx;
break;
}
case "SETHIPxxxxxxxxxxxx": {
command = SETHIPxxxxxxxxxxxx;
break;
}
case "SETNMKxxxxxxxxxxxx": {
command = SETNMKxxxxxxxxxxxx;
break;
}
case "SETTIPzzzz": {
command = SETTIPzzzz;
break;
}
case "SETDHCPy": {
command = SETDHCPy;
break;
}
case "GETRIP": {
command = GETRIP;
break;
}
case "GETHIP": {
command = GETHIP;
break;
}
case "GETNMK": {
command = GETNMK;
break;
}
case "GETTIP": {
command = GETTIP;
break;
}
case "GETDHCP": {
command = GETDHCP;
break;
}
case "GETMAC": {
command = GETMAC;
break;
}
case "SETRSHRFIxOx": {
command = SETRSHRFIxOx;
break;
}
case "SETRSPTHOUTxLENyBRz": {
command = SETRSPTHOUTxLENyBRz;
break;
}
case "SETRSPTHINxLENyBRz": {
command = SETRSPTHINxLENyBRz;
break;
}
case "GETRSHRF": {
command = GETRSHRF;
break;
}
case "SETIRSYSxxyy": {
command = SETIRSYSxxyy;
break;
}
case "SETIROUTxINyCODEzz": {
command = SETIROUTxINyCODEzz;
break;
}
case "GETIRSYS": {
command = GETIRSYS;
break;
}
case "GETIROUTxINyCODE": {
command = GETIROUTxINyCODE;
break;
}
default: {
command = null;
break;
}
}
// Execute the command if it's set
if (command) {
msg.payload = command + `\n`;
node.send(msg);
} else {
node.warn(`command not set`);
// Handle invalid input
node.warn("Warning in Node: " + node.id + ", check node status for more information.");
node.status({
fill: "red",
shape: "ring",
text: "Error: No command set for the given selection."
});
return [[null]];
}
});
}
RED.nodes.registerType("av-pro-ac-cx42", AVProACCX42);
};