【问题标题】:using node-red and npm timer-stopwatch使用 node-red 和 npm timer-stopwatch
【发布时间】:2017-06-08 22:21:26
【问题描述】:

我在 node-red 上做一个项目来创建秒表。我在 NPM 中找到了计时器秒表,我想这就是我要找的东西,但问题是,我找不到启动秒表的方法。

我正在使用带有 node-red 和 npm-contrib 节点的树莓派来连接计时器秒表。每次我尝试注入命令时,调试控制台都会响应此错误:

TypeError: Object # has no method 'reset'

我正在为拖灯做这个项目,我希望秒表在绿灯激活时启动,然后一组 IR 传感器将成为秒表的停止信号。

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

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

起初我使用简单的 python 代码编写灯光,然后发现 node-red 可以帮助我理解。

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

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

【问题讨论】:

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


    【解决方案1】:

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

    问候,

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多