Skip to content

Instantly share code, notes, and snippets.

@hardillb
Created September 10, 2014 09:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hardillb/3d6e6e4d4b296d8268fc to your computer and use it in GitHub Desktop.
Save hardillb/3d6e6e4d4b296d8268fc to your computer and use it in GitHub Desktop.
Tata F1 Timing flow
[{"id":"595f8cc.92912f4","type":"file in","name":"","filename":"/data/f1.xml","format":"utf8","x":319.08331298828125,"y":46.083335876464844,"z":"1c9784d4.222773","wires":[["a915baa2.9ecae"]]},{"id":"6a5d6db5.efe6b4","type":"inject","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":96.08332824707031,"y":46.083335876464844,"z":"1c9784d4.222773","wires":[["595f8cc.92912f4"]]},{"id":"8f7943ec.516408","type":"xml","name":"","x":535.0833129882812,"y":142.08334350585938,"z":"1c9784d4.222773","wires":[["d4cb38f5.69dbc"]]},{"id":"730d4af8.19591c","type":"debug","name":"","active":true,"console":"false","complete":"true","x":817.0833129882812,"y":45.083335876464844,"z":"1c9784d4.222773","wires":[]},{"id":"a915baa2.9ecae","type":"function","name":"","func":"var lines = msg.payload.split(\"\\n\");\nvar messages = [];\n\nfor (var i=0; i<lines.length; i++) {\n //deep copy the orginal message to ensure we don't loose any other fields\n var tmp = JSON.parse(JSON.stringify(msg));\n //the trim deals with dos line endings\n tmp.payload = lines[i].trim();\n messages.push(tmp);\n}\nreturn [messages];\n","outputs":1,"x":354.08331298828125,"y":142.08334350585938,"z":"1c9784d4.222773","wires":[["8f7943ec.516408"]]},{"id":"d4cb38f5.69dbc","type":"delay","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":605.0833129882812,"y":43.083335876464844,"z":"1c9784d4.222773","wires":[["730d4af8.19591c"]]}]
@hardillb
Copy link
Author

This flow takes a file called /data/f1.xml and splits into rows, converts each row to json objects and then rate limits the json objects to 1 per second.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment