DMX

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

前回、ENTTEC ODE MK2を使ってNode-REDからsACNでDMX機器を操作するメモという記事を書きましたが、その改良番です。

改良点は
1. Delayノードを挿入
2.一括送信時と順番に送信時は、DMXValuesの0番目の扱いが変わるので修正
3. DMXValuesがNullのときは(0番目)はENNTECに送信しない

といったところです。

フロー

Node RED 2021 07 25 07 34 32
[{"id":"36307.52e03cf9a","type":"sACN","z":"e8d9391e.fd3de8","server":"294eb160.1174ce","universe":"","channel":"","transition":"instant","transitionRate":50,"transitionTime":1000,"name":"ENTTEC ODE Mk2","x":410,"y":180,"wires":[]},{"id":"54b89136.864","type":"comment","z":"e8d9391e.fd3de8","name":"OneByOne","info":"","x":100,"y":280,"wires":[]},{"id":"cddcc304.e1203","type":"function","z":"e8d9391e.fd3de8","name":"sACN DATA","func":"var 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":390,"y":460,"wires":[["19c1c349.084add"]]},{"id":"d6690929.a68be8","type":"switch","z":"e8d9391e.fd3de8","name":"CheckLoop","property":"counter","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"num"},{"t":"lte","v":"counter","vt":"flow"},{"t":"else"}],"checkall":"false","repair":false,"outputs":3,"x":330,"y":400,"wires":[["cddcc304.e1203","810f5709.179468"],["cddcc304.e1203","eb7cbe18.d5ab7","d15bac03.3f4d2"],["810f5709.179468"]]},{"id":"d15bac03.3f4d2","type":"debug","z":"e8d9391e.fd3de8","name":"ENTTEC-NotSend","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":630,"y":360,"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// (string: Universe/Channel)\nmsg.topic = \"1/1\";\n\n// DMX values\nmsg.payload = DMXValues;\n\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":330,"y":120,"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":180,"y":100,"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":170,"y":160,"wires":[["f9258493.9132d8"]]},{"id":"8b1694fd.563ee8","type":"function","z":"e8d9391e.fd3de8","name":"SET DMXValues","func":"var dimLevel = msg.payload;\nvar fixtureNumber = 10; //1fixture has RGB 3CH\nvar DMXValues =[];\n\nflow.set('counter',(fixtureNumber*3));\n\nmsg.counter = 0;\n\n// globalに器具のDMXValuesをセットする\n// 一括でおくる場合は0が1chだけど、\n// この場合は0はブランクにする\nDMXValues[0]=\"\";\n\nfor(i=1;i<=(50*3);i++){\n    DMXValues[i]= dimLevel;\n}\n\nglobal.set('DMXValues',DMXValues);\n\nmsg.payload = \"\";\n\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":300,"y":340,"wires":[["d6690929.a68be8"]]},{"id":"d6ca909e.12b63","type":"comment","z":"e8d9391e.fd3de8","name":"OneTime","info":"","x":120,"y":60,"wires":[]},{"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":400,"wires":[]},{"id":"aed7e220.40bf4","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":120,"y":320,"wires":[["8b1694fd.563ee8"]]},{"id":"da68c6df.c74d78","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":130,"y":360,"wires":[["8b1694fd.563ee8"]]},{"id":"19c1c349.084add","type":"delay","z":"e8d9391e.fd3de8","name":"Delay","pauseType":"delay","timeout":"1","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":450,"y":520,"wires":[["d6690929.a68be8"]]},{"id":"810f5709.179468","type":"debug","z":"e8d9391e.fd3de8","name":"ENNTEC-Send","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":620,"y":320,"wires":[]},{"id":"294eb160.1174ce","type":"sacn-config","hostOrUniverse":"192.168.1.110","port":"5568"}]
ABOUT ME
中畑 隆拓
スマートライト㈱ 代表取締役。IoTソリューションの開発、スマートホーム&オフィスのコンサルティング、DALI,KNX,EnOceanなどのインテグレーションを行っています。