2017-06-08 2 views
0

Je travaille sur un projet sur node-red pour créer un chronomètre. J'ai trouvé chronomètre chronomètre dans NPM, je pense que ce serait ce que je cherche, mais le problème est, je ne peux pas trouver un moyen de démarrer le chronomètre. J'utilise un Raspberry pi avec node-red et le nœud npm-contrib pour interfacer le timer-stopwatch. chaque fois que j'essaie d'injecter une commande de la répondre de la console de débogage avec cette erreur:en utilisant node-red et npm timer-stopwatch

TypeError: Object # has no method 'reset'

Je travaille sur ce projet pour une lumière de glisser et je veux le chronomètre pour démarrer lorsque le activate feu vert puis un ensemble des capteurs IR sera le signal d'arrêt du chronomètre. Après cela, je veux que le résultat du chronomètre soit affiché sur une page web locale, en live si possible, et que l'historique soit affiché sous la partie live.

Je suis à la recherche de tout ce que cela pourrait être possible de réaliser. Au début, je travaillais avec des codes python simples pour les lumières puis j'ai découvert le nœud rouge qui m'a aidé à comprendre.

ici une copie de presse-papiers de la partie de nœud rouge pour le chronomètre:

[{"id":"fa4e7c52.2b88e","type":"rpi-gpio in","z":"5b54b95f.a4ab48","name":"capteur-input","pin":"37","intype":"tri","debounce":"5","read":false,"x":1368,"y":106,"wires":[[]]},{"id":"f1641fdd.b28d7","type":"delay","z":"5b54b95f.a4ab48","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":1618,"y":216,"wires":[["c0e8ebcf.82a488"]]},{"id":"ce973724.f05608","type":"hysteresis","z":"5b54b95f.a4ab48","name":"","rising_threshold":".2999","falling_threshold":".0002","x":1489.500015258789,"y":171.6666717529297,"wires":[["f1641fdd.b28d7"]]},{"id":"453729db.6c73a8","type":"function","z":"5b54b95f.a4ab48","name":"","func":"var Stopwatch = ('timer-stopwatch');\n \nvar stopwatch = new Stopwatch(); // A new count up stopwatch. Starts at 0.\nvar start = stopwatch.start();\nvar stop = stopwatch.stop();\nvar reset = stopwatch.reset(countDownMS);\nglobal.set(time.ms);\n\nreturn msg;","outputs":"1","noerr":0,"x":1779,"y":306,"wires":[[]]},{"id":"710b7c12.919654","type":"template","z":"5b54b95f.a4ab48","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<ul>\n {{#payload}}\n  <li>{{live-time.text}}</li>\n {{/payload}}\n</ul>","x":2245,"y":458,"wires":[["784f0ff.9fe1cf"]]},{"id":"d97e4759.f19cd8","type":"mongodb out","z":"5b54b95f.a4ab48","service":"_ext_","mongodb":"13244bb7.1f3da4","name":"","collection":"live-time","payonly":false,"upsert":false,"multi":false,"operation":"store","x":2274,"y":212,"wires":[]},{"id":"474dbe3a.ba9da","type":"mongodb in","z":"5b54b95f.a4ab48","service":"_ext_","mongodb":"13244bb7.1f3da4","name":"","collection":"live-time","operation":"find","x":2009,"y":452,"wires":[["710b7c12.919654"]]},{"id":"c0e8ebcf.82a488","type":"change","z":"5b54b95f.a4ab48","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"time.ms","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1815,"y":96,"wires":[["b263bb1c.08fd88"]]},{"id":"784f0ff.9fe1cf","type":"http response","z":"5b54b95f.a4ab48","name":"","x":2409,"y":410,"wires":[]},{"id":"dff41be4.6bfd18","type":"http in","z":"5b54b95f.a4ab48","name":"","url":"/timer","method":"get","swaggerDoc":"","x":1728,"y":397,"wires":[["474dbe3a.ba9da"]]},{"id":"66c775f3.50469c","type":"mongodb in","z":"5b54b95f.a4ab48","service":"_ext_","mongodb":"13244bb7.1f3da4","name":"","collection":"hist-time","operation":"find","x":2201,"y":550,"wires":[[]]},{"id":"b313546.c476ba8","type":"npm","z":"5b54b95f.a4ab48","name":"","func":"var Stopwatch = 'timer-stopwatch';\nvar stopwatch = new Stopwatch();\n//stopwatch.start();\n//stopwatch.stop();\n//stopwatch.reset(countDownMS)\ntime.ms;\n","npm_module":"timer-stopwatch","module_style":"custom","msg_payload":"return_val","function_name":"timer.start();","x":2070,"y":348,"wires":[[]]},{"id":"b263bb1c.08fd88","type":"npm","z":"5b54b95f.a4ab48","name":"","func":"// NPM module exposed as variable, npm_module\nreturn npm_module(msg.payload);","npm_module":"timer-stopwatch","module_style":"cstr","msg_payload":"callback","function_name":"","x":1961,"y":160,"wires":[["82e9f9f4.6a5fc8"]]},{"id":"82e9f9f4.6a5fc8","type":"debug","z":"5b54b95f.a4ab48","name":"","active":true,"console":"false","complete":"false","x":2120,"y":112,"wires":[]},{"id":"29f889d2.a5db26","type":"template","z":"5b54b95f.a4ab48","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{{#payload}}\nstart();\n{{/payload}}","x":1653,"y":306,"wires":[["453729db.6c73a8"]]},{"id":"98b56bab.049578","type":"inject","z":"5b54b95f.a4ab48","name":"","topic":"","payload":"timer.start","payloadType":"str","repeat":"","crontab":"","once":false,"x":1826,"y":229,"wires":[["b263bb1c.08fd88"]]},{"id":"13244bb7.1f3da4","type":"mongodb","z":"","hostname":"127.0.0.1","port":"27017","db":"Chrono","name":""}] 

Répondre

0

pas sûr de votre approche, mais avez-vous une recherche pour le tableau de bord ui?

Cordialement,