DMX

ENTTEC ODE MK2を使ってNode-REDからsACNでDMX機器を操作するメモ

ENTTEC ODE MK2を使ってNode-REDからsACNでDMX機器を操作するフローのメモです。

node-red-contrib-sacn (node) – Node-RED

** このフローの改良版があります。

ENTTEC ODE MK2を使ってNode-REDからsACNでDMX機器を操作するメモ2(改良版)

全チャンネルの値を配列でmsg.payloadで送る

Node red contrib sacn  node  Node RED 2021 07 21 15 20 22

公式サイトにでているfull universeに配列でデータを送る方法です。

Node RED 2021 07 21 15 14 20

このフローでは、Injectノードから調光レベル(dimLevel)を数値でおくり、その後のfunctionノードで、器具台数分の全チャンネルにdimLevelを書き込み、ENTTEC ODE MK2に送っています。

var dimLevel = msg.payload;
var fixtureNumber = 50;
var DMXValues =[];

for(i=0; i<(50*3); i++){
    DMXValues[i]= dimLevel;
}

// globalに器具のDMXValuesをセットする
global.set('DMXValues',DMXValues);


msg.topic = "1/1";
// (string: Universe/Channel)

msg.payload = DMXValues;
// DMX values


//msg.payload = value;

return msg;

↓ フロー

[{"id":"36307.52e03cf9a","type":"sACN","z":"e8d9391e.fd3de8","server":"294eb160.1174ce","universe":"","channel":"","transition":"instant","transitionRate":50,"transitionTime":1000,"name":"ENTTEC ODE Mk2","x":650,"y":280,"wires":[]},{"id":"f9258493.9132d8","type":"function","z":"e8d9391e.fd3de8","name":"sACN-DATA","func":"var dimLevel = msg.payload;\nvar fixtureNumber = 50;\nvar DMXValues =[];\n\nfor(i=0;i<(50*3);i++){\n    DMXValues[i]= dimLevel;\n}\n\n\n// globalに器具のDMXValuesをセットする\nglobal.set('DMXValues',DMXValues);\n\n\nmsg.topic = \"1/1\";\n// (string: Universe/Channel)\n\nmsg.payload = DMXValues;\n// DMX values\n\n\n//msg.payload = value;\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":590,"y":220,"wires":[["36307.52e03cf9a"]]},{"id":"ad4f925.8a0517","type":"inject","z":"e8d9391e.fd3de8","name":"255:Max","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"255","payloadType":"num","x":420,"y":200,"wires":[["f9258493.9132d8"]]},{"id":"2886b78a.5c3fd8","type":"inject","z":"e8d9391e.fd3de8","name":"0:Off","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"0","payloadType":"num","x":410,"y":260,"wires":[["f9258493.9132d8"]]},{"id":"294eb160.1174ce","type":"sacn-config","hostOrUniverse":"192.168.1.110","port":"5568"}]

msg.payloadで1chづつ送る

Node red contrib sacn  node  Node RED 2021 07 21 17 21 34

こちらの方法です。

Node red contrib sacn  node  Node RED 2021 07 21 17 26 29

transitionも入れることができます。

Node RED 2021 07 21 15 30 45

msg.payloadで送る際、まずは、配列でDMXチャンネル分のdimLevelをDMXValuesで準備。

あとは1chづつmsg.payloadでDMXのレベルを送るようにしています。

var dimLevel = 255;
var fixtureNumber;
var DMXValues = global.get('DMXValues');
var channel = msg.counter+1;

msg.payload = {
    "universe": 1,
    "channel": channel,
    "value": DMXValues[channel]
}

msg.counter = msg.counter +1;

return msg;

↓フロー

[{"id":"771ba540.0bfaec","type":"inject","z":"e8d9391e.fd3de8","name":"START","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":110,"y":340,"wires":[["8b1694fd.563ee8"]]},{"id":"54b89136.864","type":"comment","z":"e8d9391e.fd3de8","name":"順番送信","info":"// Set Universe in config or topic:\n\nmsg.topic = \"1/1\" \n// (string: Universe/Channel)\nmsg.payload = [128,0,128] \n// (array: First 3 DMX values in the universe set to 50%,0%,50%)\n","x":80,"y":420,"wires":[]},{"id":"cddcc304.e1203","type":"function","z":"e8d9391e.fd3de8","name":"sACN DATA","func":"var dimLevel = 255;\nvar fixtureNumber;\nvar DMXValues = global.get('DMXValues');\nvar channel = msg.counter+1;\n\nmsg.payload = {\n    \"universe\": 1,\n    \"channel\": channel,\n    \"value\": DMXValues[channel]\n}\n\nmsg.counter = msg.counter +1;\n\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":330,"y":680,"wires":[["d6690929.a68be8"]]},{"id":"6ba991f.10f147","type":"function","z":"e8d9391e.fd3de8","name":"カウンターセット","func":"msg.payload = \"\";\n\nflow.set('counter',10);\n\nmsg.counter = 0;\n\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":210,"y":540,"wires":[["d6690929.a68be8"]]},{"id":"d6690929.a68be8","type":"switch","z":"e8d9391e.fd3de8","name":"ループチェック","property":"counter","propertyType":"msg","rules":[{"t":"lt","v":"counter","vt":"flow"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":280,"y":600,"wires":[["cddcc304.e1203","eb7cbe18.d5ab7","d15bac03.3f4d2"],["d15bac03.3f4d2"]]},{"id":"d15bac03.3f4d2","type":"debug","z":"e8d9391e.fd3de8","name":"終了","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":570,"y":600,"wires":[]},{"id":"8b1694fd.563ee8","type":"function","z":"e8d9391e.fd3de8","name":"SET DMXValues","func":"var dimLevel = 255;\nvar fixtureNumber = 50; //1fixture has RGB 3CH\nvar DMXValues =[];\n\nfor(i=0;i<(50*3);i++){\n    DMXValues[i]= dimLevel;\n}\n\n\n// globalに器具のDMXValuesをセットする\nglobal.set('DMXValues',DMXValues);\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":300,"y":340,"wires":[[]]},{"id":"d6ca909e.12b63","type":"comment","z":"e8d9391e.fd3de8","name":"初期値の設定","info":"// Set Universe in config or topic:\n\nmsg.topic = \"1/1\" \n// (string: Universe/Channel)\nmsg.payload = [128,0,128] \n// (array: First 3 DMX values in the universe set to 50%,0%,50%)\n","x":110,"y":280,"wires":[]},{"id":"ff9a0008.b3838","type":"inject","z":"e8d9391e.fd3de8","name":"START","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":90,"y":480,"wires":[["6ba991f.10f147"]]},{"id":"eb7cbe18.d5ab7","type":"sACN","z":"e8d9391e.fd3de8","server":"294eb160.1174ce","universe":"","channel":"","transition":"instant","transitionRate":50,"transitionTime":1000,"name":"ENTTEC ODE Mk2","x":610,"y":560,"wires":[]},{"id":"294eb160.1174ce","type":"sacn-config","hostOrUniverse":"192.168.1.110","port":"5568"}]
ABOUT ME
中畑 隆拓
スマートライト㈱ 代表取締役。IoTソリューションの開発、スマートホーム&オフィスのコンサルティング、DALI,KNX,EnOceanなどのインテグレーションを行っています。

COMMENT

メールアドレスが公開されることはありません。 が付いている欄は必須項目です