Node-RED中change更改节点与switch分支节点的使用

生活中,最使人疲惫的往往不是道路的遥远,而是心中的郁闷;最使人痛苦的往往不是生活的不幸,而是希望的破灭;最使人颓废的往往不是前途的坎坷,而是自信的丧失;最使人绝望的往往不是挫折的打击,而是心灵的死亡。所以我们要有自己的梦想,让梦想的星光指引着我们走出落漠,走出惆怅,带着我们走进自己的理想。

导读:本篇文章讲解 Node-RED中change更改节点与switch分支节点的使用,希望对大家有帮助,欢迎收藏,转发!站点地址:www.bmabk.com,来源:原文

场景

Node-RED简介与Windows上安装、启动和运行示例:

Node-RED简介与Windows上安装、启动和运行示例_霸道流氓气质的博客-CSDN博客

Node-RED的switch节点就是条件判断,可以依据条件来传递msg物件至不同的下一个节点。

例如:inject注入0和1,使用switch和change节点来分别输出成ON和OFF

Node-RED中change更改节点与switch分支节点的使用

注:

博客:
霸道流氓气质的博客_CSDN博客-C#,架构之路,SpringBoot领域博主
关注公众号
霸道的程序猿
获取编程相关电子书、教程推送与免费下载。

实现

1、switch节点编辑

Node-RED中change更改节点与switch分支节点的使用

2、change节点编辑

Node-RED中change更改节点与switch分支节点的使用

3、流程转换的json数据

[{"id":"6ef823fa.ff781c","type":"inject","z":"34d4d5aa.c0d0ea","name":"","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"0","payloadType":"str","x":170,"y":80,"wires":[["45345f77.71a5f"]]},{"id":"90976eb6.0bc82","type":"inject","z":"34d4d5aa.c0d0ea","name":"","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1","payloadType":"str","x":170,"y":180,"wires":[["45345f77.71a5f"]]},{"id":"45345f77.71a5f","type":"switch","z":"34d4d5aa.c0d0ea","name":"On or OFF","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"str"},{"t":"eq","v":"1","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":350,"y":140,"wires":[["60b9f22a.9acb4c"],["8e48a261.b465e"]]},{"id":"aa1452ff.c3ffa","type":"debug","z":"34d4d5aa.c0d0ea","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":730,"y":80,"wires":[]},{"id":"de505863.01f448","type":"debug","z":"34d4d5aa.c0d0ea","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":710,"y":200,"wires":[]},{"id":"60b9f22a.9acb4c","type":"change","z":"34d4d5aa.c0d0ea","name":"Set to ON","rules":[{"t":"set","p":"payload","pt":"msg","to":"ON","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":100,"wires":[["aa1452ff.c3ffa"]]},{"id":"8e48a261.b465e","type":"change","z":"34d4d5aa.c0d0ea","name":"Set to OFF","rules":[{"t":"set","p":"payload","pt":"msg","to":"OFF","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":510,"y":200,"wires":[["de505863.01f448"]]}]

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/136004.html

(0)
飞熊的头像飞熊bm

相关推荐

发表回复

登录后才能评论
极客之音——专业性很强的中文编程技术网站,欢迎收藏到浏览器,订阅我们!