generated from MysteryCode/node-red-example
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add node for interaction with named controls
- Loading branch information
Showing
11 changed files
with
387 additions
and
1 deletion.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
dist/nodes/qsys-named-control/locales/de/qsys-named-control.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"qsys-named-control": { | ||
"label": { | ||
"core": "Q-SYS Core", | ||
"codename": "Named Control" | ||
}, | ||
"placeholder": { | ||
"codename": "Mixer_8x8Input1Mute" | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
dist/nodes/qsys-named-control/locales/en-US/qsys-named-control.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"qsys-named-control": { | ||
"label": { | ||
"core": "Q-SYS Core", | ||
"codename": "Named Control" | ||
}, | ||
"placeholder": { | ||
"codename": "Mixer_8x8Input1Mute" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<script type="text/html" data-template-name="qsys-named-control"> | ||
<div class="form-row"> | ||
<label for="node-input-name"> | ||
<i class="fa fa-tag"></i> | ||
<span data-i18n="node-red:common.label.name"></span> | ||
</label> | ||
<input type="text" id="node-input-name" data-i18n="[placeholder]node-red:common.label.name" /> | ||
</div> | ||
|
||
<div class="form-row"> | ||
<label for="node-input-core"> | ||
<span data-i18n="qsys-named-control.label.core"></span> | ||
</label> | ||
<input type="text" id="node-input-core" /> | ||
</div> | ||
|
||
<div class="form-row"> | ||
<label for="node-input-codename"> | ||
<span data-i18n="qsys-named-control.label.codename"></span> | ||
</label> | ||
<input type="text" id="node-input-codename" data-i18n="[placeholder]qsys-named-control.placeholder.codename" /> | ||
</div> | ||
</script> | ||
<script type="text/html" data-help-name="qsys-named-control"> | ||
<p> | ||
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, | ||
sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. | ||
At vero eos et accusam et justo duo dolores et ea rebum. | ||
Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. | ||
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, | ||
sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. | ||
At vero eos et accusam et justo duo dolores et ea rebum. | ||
Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. | ||
</p> | ||
</script> | ||
<script type="text/javascript"> | ||
RED.nodes.registerType("qsys-named-control", { | ||
category: "Q-SYS", | ||
paletteLabel: "Q-SYS Named Control", | ||
color: "#1a7ab9", | ||
icon: "qsys-named-control.svg", | ||
inputs: 1, | ||
outputs: 1, | ||
defaults: { | ||
name: { | ||
value: "Q-SYS Named Control", | ||
required: false, | ||
}, | ||
core: { | ||
value: "", | ||
type: "qsys-config", | ||
}, | ||
codename: { | ||
value: "", | ||
required: true, | ||
}, | ||
}, | ||
label: function () { | ||
return this.name || "Q-SYS Named Control"; | ||
}, | ||
}); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const qsys_config_1 = require("../qsys-config/qsys-config"); | ||
class NodeHandler { | ||
node; | ||
config; | ||
nodeApi; | ||
core = undefined; | ||
constructor(node, config, nodeApi) { | ||
this.node = node; | ||
this.config = config; | ||
this.nodeApi = nodeApi; | ||
this.core = this.nodeApi.nodes.getNode(config.core); | ||
this.core.nodeHandler.registerStatusCallback(this.node.id, (_socket, status, error) => { | ||
const nodeStatus = { | ||
fill: "grey", | ||
shape: "dot", | ||
text: "", | ||
}; | ||
switch (status) { | ||
case "Inactive": | ||
nodeStatus.fill = "grey"; | ||
nodeStatus.text = "Inactive."; | ||
break; | ||
case "Error": | ||
nodeStatus.fill = "red"; | ||
nodeStatus.text = error instanceof Error ? error.message : "Failure."; | ||
break; | ||
case "Connected": | ||
case "Active": | ||
nodeStatus.fill = "green"; | ||
nodeStatus.text = "Connected."; | ||
break; | ||
default: | ||
break; | ||
} | ||
this.node.status(nodeStatus); | ||
}); | ||
this.node.on("close", () => { | ||
this.core?.nodeHandler.unregisterStatusCallback(this.node.id); | ||
}); | ||
this.node.on("input", (msg) => { | ||
const message = msg; | ||
const controls = this.config.codename.split(";"); | ||
let params; | ||
let action = "Get"; | ||
if (["string", "number", "boolean"].includes(typeof message.payload)) { | ||
action = "Set"; | ||
params = { | ||
Name: this.config.codename, | ||
Value: message.payload, | ||
Ramp: message.ramp, | ||
}; | ||
} | ||
else { | ||
params = controls; | ||
} | ||
this.core?.nodeHandler | ||
.send({ | ||
id: (0, qsys_config_1.reserveId)(), | ||
method: `Control.${action}`, | ||
params: params, | ||
}) | ||
.then((response) => { | ||
const data = response; | ||
if (action === "Get" && data.result.length === 1) { | ||
msg.payload = data.result.pop(); | ||
} | ||
else { | ||
msg.payload = data.result; | ||
} | ||
this.node.send(msg); | ||
}) | ||
.catch((e) => { | ||
if (e instanceof Error) { | ||
this.node.error(e.message); | ||
} | ||
}); | ||
}); | ||
} | ||
} | ||
exports.default = (RED) => { | ||
RED.nodes.registerType("qsys-named-control", function (config) { | ||
RED.nodes.createNode(this, config); | ||
new NodeHandler(this, config, RED); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<p> | ||
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, | ||
sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. | ||
At vero eos et accusam et justo duo dolores et ea rebum. | ||
Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. | ||
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, | ||
sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. | ||
At vero eos et accusam et justo duo dolores et ea rebum. | ||
Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. | ||
</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<div class="form-row"> | ||
<label for="node-input-name"> | ||
<i class="fa fa-tag"></i> | ||
<span data-i18n="node-red:common.label.name"></span> | ||
</label> | ||
<input type="text" id="node-input-name" data-i18n="[placeholder]node-red:common.label.name" /> | ||
</div> | ||
|
||
<div class="form-row"> | ||
<label for="node-input-core"> | ||
<span data-i18n="qsys-named-control.label.core"></span> | ||
</label> | ||
<input type="text" id="node-input-core" /> | ||
</div> | ||
|
||
<div class="form-row"> | ||
<label for="node-input-codename"> | ||
<span data-i18n="qsys-named-control.label.codename"></span> | ||
</label> | ||
<input type="text" id="node-input-codename" data-i18n="[placeholder]qsys-named-control.placeholder.codename" /> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { EditorNodeDef, EditorNodeProperties, EditorRED } from "node-red"; | ||
|
||
declare const RED: EditorRED; | ||
|
||
interface Defaults extends EditorNodeProperties { | ||
codename: string; | ||
} | ||
|
||
RED.nodes.registerType("qsys-named-control", { | ||
category: "Q-SYS", | ||
paletteLabel: "Q-SYS Named Control", | ||
color: "#1a7ab9", | ||
icon: "qsys-named-control.svg", | ||
inputs: 1, | ||
outputs: 1, | ||
defaults: { | ||
name: { | ||
value: "Q-SYS Named Control", | ||
required: false, | ||
}, | ||
core: { | ||
value: "", | ||
type: "qsys-config", | ||
}, | ||
codename: { | ||
value: "", | ||
required: true, | ||
}, | ||
}, | ||
label: function () { | ||
return this.name || "Q-SYS Named Control"; | ||
}, | ||
} as EditorNodeDef<Defaults>); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"label": { | ||
"core": "Q-SYS Core", | ||
"codename": "Named Control" | ||
}, | ||
"placeholder": { | ||
"codename": "Mixer_8x8Input1Mute" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"label": { | ||
"core": "Q-SYS Core", | ||
"codename": "Named Control" | ||
}, | ||
"placeholder": { | ||
"codename": "Mixer_8x8Input1Mute" | ||
} | ||
} |
Oops, something went wrong.