使用node-red和npm timer-stopwatch

时间:2017-06-08 22:21:27

标签: python node.js timer raspberry-pi node-red

我正在使用node-red上的项目来创建一个秒表。我在NPM中找到了计时器秒表,我想这将是我正在寻找的但问题是,我找不到启动秒表的方法。

我正在使用带有node-red和npm-contrib节点的raspberry pi来连接timer-stopwatch。每次我尝试注入命令时,调试控制台都会响应此错误:

  

TypeError:对象#没有方法'重置'

我正在研究拖曳灯的这个项目,我希望秒表在绿灯启动时启动,然后一组红外传感器将成为秒表的停止信号。

在此之后,我希望秒表的结果显示在本地网页上,如果可能的话,在现场直播,并在实时部分下显示历史记录。

我正在寻找可以实现的任何方式。

起初我正在处理灯光的简单python代码,然后发现了节点红色,这有助于我理解。

这里是秒表的节点红色部分的剪贴板副本:

[{"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":""}]

1 个答案:

答案 0 :(得分:0)

不确定您的方法,但您是否搜索了仪表板ui?

此致