-
Notifications
You must be signed in to change notification settings - Fork 4
AND gate
cflurin edited this page Oct 29, 2018
·
1 revision
{
"currentState": "undefined",
"data": {
"a": false,
"b": false
},
"methods": {
"a": "sm.data.a = msg.payload;",
"b": "sm.data.b = msg.payload;",
"onTransition": [
"if (sm.data.a && sm.data.b) {",
" sm.currentState = true;",
" sm.fill = 'green';",
"} else {",
" sm.currentState = false;",
" sm.fill = 'yellow';",
"}",
"msg.payload = sm.currentState;",
"output = true;"
],
"status": {
"fill": {
"get": "sm.fill;"
},
"shape": "dot",
"text": {
"get": "sm.currentState;"
}
}
}
}
[{"id":"bc8967c5.5db488","type":"inject","z":"cb099c1f.9ea6b","name":"","topic":"a","payload":"false","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":90,"y":3000,"wires":[["297807c2.f52008"]]},{"id":"bc4dc61a.f01998","type":"inject","z":"cb099c1f.9ea6b","name":"","topic":"b","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":90,"y":3140,"wires":[["297807c2.f52008"]]},{"id":"6aeef8ba.d459e8","type":"inject","z":"cb099c1f.9ea6b","name":"","topic":"b","payload":"false","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":90,"y":3100,"wires":[["297807c2.f52008"]]},{"id":"6ec5688a.41f3e8","type":"inject","z":"cb099c1f.9ea6b","name":"","topic":"a","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":90,"y":3040,"wires":[["297807c2.f52008"]]},{"id":"297807c2.f52008","type":"dsm","z":"cb099c1f.9ea6b","name":"AND","sm_config":"{\n \"currentState\": \"undefined\",\n \"data\": {\n \"a\": false,\n \"b\": false\n },\n \"methods\": {\n \"a\": \"sm.data.a = msg.payload;\",\n \"b\": \"sm.data.b = msg.payload;\",\n \"onTransition\": [\n \"if (sm.data.a && sm.data.b) {\",\n \" sm.currentState = true;\",\n \" sm.fill = 'green';\",\n \"} else {\",\n \" sm.currentState = false;\",\n \" sm.fill = 'yellow';\",\n \"}\",\n \"msg.payload = sm.currentState;\",\n \"output = true;\"\n ],\n \"status\": {\n \"fill\": {\n \"get\": \"sm.fill;\"\n },\n \"shape\": \"dot\",\n \"text\": {\n \"get\": \"sm.currentState;\"\n }\n }\n }\n}","x":260,"y":3080,"wires":[["37af395f.cbf106"]]},{"id":"37af395f.cbf106","type":"debug","z":"cb099c1f.9ea6b","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":410,"y":3080,"wires":[]}]