Last active
September 26, 2016 23:42
-
-
Save upkarlidder/204ce29ab4f1a43c0205489decee337e to your computer and use it in GitHub Desktop.
coursera-iot-assignment2
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
[ | |
{ | |
"id": "dc765e4b.46713", | |
"type": "subflow", | |
"name": "random", | |
"info": "", | |
"in": [ | |
{ | |
"x": 230, | |
"y": 320, | |
"wires": [ | |
{ | |
"id": "de3b5593.c62e98" | |
} | |
] | |
} | |
], | |
"out": [ | |
{ | |
"x": 510, | |
"y": 320, | |
"wires": [ | |
{ | |
"id": "de3b5593.c62e98", | |
"port": 0 | |
} | |
] | |
} | |
] | |
}, | |
{ | |
"id": "de3b5593.c62e98", | |
"type": "function", | |
"z": "dc765e4b.46713", | |
"name": "random", | |
"func": "\/\/ Returns a random integer between min (included) and max (included)\n\/\/ Using Math.round() will give you a non-uniform distribution!\nfunction getRandomIntInclusive(min, max) {\n min = Math.ceil(min);\n max = Math.floor(max);\n return Math.floor(Math.random() * (max - min + 1)) + min;\n}\n\nmsg.payload = getRandomIntInclusive(1,100);\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 370, | |
"y": 320, | |
"wires": [ | |
[ | |
] | |
] | |
}, | |
{ | |
"id": "b05bdfad.7467f", | |
"type": "inject", | |
"z": "a4f73eb3.cf84f", | |
"name": "", | |
"topic": "", | |
"payload": "", | |
"payloadType": "date", | |
"repeat": "", | |
"crontab": "", | |
"once": false, | |
"x": 188.5, | |
"y": 91, | |
"wires": [ | |
[ | |
"c584659b.4645c8" | |
] | |
] | |
}, | |
{ | |
"id": "bb6dcbde.7ab7c8", | |
"type": "http response", | |
"z": "a4f73eb3.cf84f", | |
"name": "", | |
"x": 612.5, | |
"y": 90, | |
"wires": [ | |
] | |
}, | |
{ | |
"id": "c584659b.4645c8", | |
"type": "function", | |
"z": "a4f73eb3.cf84f", | |
"name": "currentTimeJSON", | |
"func": "msg.headers={\"Content-Type\":\"application\/json\"};\nvar time = new Date();\nhrs = time.getHours();\nmins = time.getMinutes();\n\nif(hrs && hrs.toString().length < 2) {\n hrs = \"0\" + hrs;\n}\nif(mins && mins.toString().length < 2) {\n mins = \"0\" + mins;\n}\n\nvar output = hrs + \":\" + mins;\nthis.context.flow.set(\"time\", output);\nmsg.payload={\"time\":output};\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 399.5, | |
"y": 89, | |
"wires": [ | |
[ | |
"bb6dcbde.7ab7c8", | |
"83f40301.e9305" | |
] | |
] | |
}, | |
{ | |
"id": "83f40301.e9305", | |
"type": "debug", | |
"z": "a4f73eb3.cf84f", | |
"name": "", | |
"active": true, | |
"console": "false", | |
"complete": "payload", | |
"x": 630, | |
"y": 140, | |
"wires": [ | |
] | |
}, | |
{ | |
"id": "238f674d.9abf78", | |
"type": "http in", | |
"z": "a4f73eb3.cf84f", | |
"name": "", | |
"url": "\/time", | |
"method": "get", | |
"swaggerDoc": "", | |
"x": 180, | |
"y": 160, | |
"wires": [ | |
[ | |
"c584659b.4645c8" | |
] | |
] | |
}, | |
{ | |
"id": "3124c75e.318c28", | |
"type": "http in", | |
"z": "a4f73eb3.cf84f", | |
"name": "", | |
"url": "\/random", | |
"method": "get", | |
"swaggerDoc": "", | |
"x": 200, | |
"y": 320, | |
"wires": [ | |
[ | |
"f767ee67.1dfbc" | |
] | |
] | |
}, | |
{ | |
"id": "fe2d18e1.dc2ab8", | |
"type": "debug", | |
"z": "a4f73eb3.cf84f", | |
"name": "", | |
"active": true, | |
"console": "false", | |
"complete": "false", | |
"x": 690, | |
"y": 320, | |
"wires": [ | |
] | |
}, | |
{ | |
"id": "33be2bda.1af764", | |
"type": "inject", | |
"z": "a4f73eb3.cf84f", | |
"name": "", | |
"topic": "", | |
"payload": "", | |
"payloadType": "date", | |
"repeat": "", | |
"crontab": "", | |
"once": false, | |
"x": 200, | |
"y": 380, | |
"wires": [ | |
[ | |
"f767ee67.1dfbc" | |
] | |
] | |
}, | |
{ | |
"id": "f767ee67.1dfbc", | |
"type": "subflow:dc765e4b.46713", | |
"z": "a4f73eb3.cf84f", | |
"name": "", | |
"x": 370, | |
"y": 320, | |
"wires": [ | |
[ | |
"7bcc6639.73f648" | |
] | |
] | |
}, | |
{ | |
"id": "7bcc6639.73f648", | |
"type": "function", | |
"z": "a4f73eb3.cf84f", | |
"name": "", | |
"func": "var time = new Date();\nhrs = time.getHours();\nmins = time.getMinutes();\n\nif(hrs && hrs.toString().length < 2) {\n hrs = \"0\" + hrs;\n}\nif(mins && mins.toString().length < 2) {\n mins = \"0\" + mins;\n}\n\nvar output = hrs + \":\" + mins;\nthis.context.flow.set(\"random-time\", output);\n\nmsg.headers={\"Content-Type\":\"application\/json\"};\nthis.context.flow.set(\"random\", msg.payload);\n\nmsg.payload = {\"random\" : msg.payload}\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 530, | |
"y": 320, | |
"wires": [ | |
[ | |
"fe2d18e1.dc2ab8", | |
"98b6b0f9.7a891" | |
] | |
] | |
}, | |
{ | |
"id": "98b6b0f9.7a891", | |
"type": "http response", | |
"z": "a4f73eb3.cf84f", | |
"name": "", | |
"x": 680, | |
"y": 380, | |
"wires": [ | |
] | |
}, | |
{ | |
"id": "878c22d7.fe52b", | |
"type": "inject", | |
"z": "a4f73eb3.cf84f", | |
"name": "", | |
"topic": "", | |
"payload": "", | |
"payloadType": "date", | |
"repeat": "", | |
"crontab": "", | |
"once": false, | |
"x": 200, | |
"y": 500, | |
"wires": [ | |
[ | |
"ae49f6b6.6c5d38" | |
] | |
] | |
}, | |
{ | |
"id": "8fe2fec2.7434e", | |
"type": "debug", | |
"z": "a4f73eb3.cf84f", | |
"name": "", | |
"active": true, | |
"console": "false", | |
"complete": "payload", | |
"x": 710, | |
"y": 500, | |
"wires": [ | |
] | |
}, | |
{ | |
"id": "ae49f6b6.6c5d38", | |
"type": "function", | |
"z": "a4f73eb3.cf84f", | |
"name": "", | |
"func": "var flowContext = this.context.flow;\nnode.warn('random flow: ' + this.context.flow.get('random'));\nmsg.random = this.context.flow.get('random');\nmsg.time = this.context.flow.get('time');\nmsg.randomTime = this.context.flow.get('random-time');\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 370, | |
"y": 500, | |
"wires": [ | |
[ | |
"69d1d2a6.b89c3c" | |
] | |
] | |
}, | |
{ | |
"id": "69d1d2a6.b89c3c", | |
"type": "template", | |
"z": "a4f73eb3.cf84f", | |
"name": "", | |
"field": "", | |
"fieldType": "msg", | |
"format": "handlebars", | |
"syntax": "mustache", | |
"template": "{{#time}}\nTime last server time request received at {{time}}\n{{\/time}}\n\n{{#random}}\nLast random number request returned {{random}}, which was received at {{randomTime}}\n{{\/random}}\n\n{{^time}}\n No server time requests have been received\n{{\/time}}\n\n{{^random}}\n No requests for random numbers have been received\n{{\/random}}", | |
"x": 510, | |
"y": 500, | |
"wires": [ | |
[ | |
"8fe2fec2.7434e", | |
"4581774.8786388" | |
] | |
] | |
}, | |
{ | |
"id": "4581774.8786388", | |
"type": "http response", | |
"z": "a4f73eb3.cf84f", | |
"name": "", | |
"x": 720, | |
"y": 600, | |
"wires": [ | |
] | |
}, | |
{ | |
"id": "2faedcd3.a8e964", | |
"type": "http in", | |
"z": "a4f73eb3.cf84f", | |
"name": "", | |
"url": "\/page", | |
"method": "get", | |
"swaggerDoc": "", | |
"x": 190, | |
"y": 560, | |
"wires": [ | |
[ | |
"ae49f6b6.6c5d38" | |
] | |
] | |
} | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment