Skip to content

Technical Documentation: NodeRed

Proficloud的NodeRed库是将您不同来源的数据在Proficloud上进行整合和显示的简单途径。 该库提供了Proficloud设备节点,表示在NodeRed中具有所有能力的云设备。

ProficloudDevice-Node, which represents the Cloud-Device in NodeRED with all its capabilities

Getting started

您可以通过 manage palette 对话框安装库. 搜索并安装“ node-red-contrib-proficloud ” 。

您也可以使用预装 proficloud/node-red (https://hub.docker.com/repository/docker/proficloud/node-red) docker 。

启动Docker(要求安装Docker)

首先,您需要从Docker集线器中拉出最新的图片:

docker pull proficloud/node-red

拉动后,您可以进行首次启动了。 容器将创建用于永久存储流程配置和设置的一个体积。 为更简单地进行管理,应对容器进行命名。 因此,运行以下命令进行启动:

docker run -d -it -p 1880:1880 --name <container-name> proficloud/node-red

Proficloud设备节点的使用

现在你可以访问 NodeRED 通过<<ip of your host>>/node-red.

连接

双击“连接节点”,输入您的设备的UUID(如果您还没有将您的设备添加到登台帐户的设备管理服务中)。

启用“自动连接”时,节点将在配置延迟后连接到Proficloud, 在“节点状态”中报告连接状态。

时间序列数据

向它发送一个 msg.payload.data 对象。 它将数据发送到云,以在时间序列数据服务的仪表板上可视化。

example payload:

msg = {};
msg.payload = {};
msg.payload.data = {"humidity": 12.0, "temp": 2.0};
return msg;

StateOfHealth

您还可以将日志或交通灯状态发送到 Proficloud。

要发送日志,该节点需要一个msg.payload.log对象,其中包含要在设备管理服务的“日志”面板中显示的消息和日志级别,不得缺失任何一项。

example payload:

msg = {};
msg.payload = {"log": {"level": 2, "tag":"Node-RED","msg": "System started"}};
return msg;

可以在设备管理服务中查看设备交通灯的状态。 该节点需要一个msg.payload.trafficlight对象,其中包含表示颜色的交通灯的数值(0=绿色;1=橙色;2=红色),以及显示为设备状态的消息。 不得缺失任何一项。

example payload:

msg = {};
msg.payload = {"trafficlight": {"color": 0, "msg": "Everything is okay"}};
return msg;

Reference implementation

You can import the following flow as a reference implementation.

[{"id":"e73dae77.7b465","type":"tab","label":"Proficloud Reference","disabled":false,"info":""},{"id":"c386f827.16eb38","type":"ProficloudDevice","z":"e73dae77.7b465","uuid":"","deviceType":"NodeRED-Node","env":"Production","autostart":true,"autodelay":0,"meta_by_payload":false,"serialnumber":"","hardwareVersion":"","x":650,"y":500,"wires":[[]]},{"id":"2f7723f2.906d24","type":"function","z":"e73dae77.7b465","name":"","func":"msg = {};\nmsg.payload = {\"data\" : {\"humidity\": 12.0, \"temp\": 2.0}};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":440,"y":280,"wires":[["c386f827.16eb38"]]},{"id":"788d6d09.2e35ec","type":"inject","z":"e73dae77.7b465","name":"","props":[],"repeat":"1","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":220,"y":280,"wires":[["2f7723f2.906d24"]]},{"id":"60b2ef0a.8aed9","type":"comment","z":"e73dae77.7b465","name":"TimeSeriesData","info":"","x":180,"y":240,"wires":[]},{"id":"ee768abb.14ce08","type":"function","z":"e73dae77.7b465","name":"","func":"msg = {};\nmsg.payload = {\"trafficlight\": {\"color\": 0, \"msg\": \"Everything is okay\"}};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":440,"y":420,"wires":[["c386f827.16eb38"]]},{"id":"11d12be5.0a1a34","type":"inject","z":"e73dae77.7b465","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":220,"y":420,"wires":[["ee768abb.14ce08"]]},{"id":"ded8d7ba.28c2f","type":"comment","z":"e73dae77.7b465","name":"TrafficLight - Green","info":"","x":190,"y":380,"wires":[]},{"id":"c17f2af0.f833b8","type":"function","z":"e73dae77.7b465","name":"","func":"msg = {};\nmsg.payload = {\"log\": {\"level\": 2, \"tag\":\"Node-RED\",\"msg\": \"System started\"}};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":440,"y":720,"wires":[["c386f827.16eb38"]]},{"id":"8a321346.644d7","type":"inject","z":"e73dae77.7b465","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":220,"y":720,"wires":[["c17f2af0.f833b8"]]},{"id":"6f96f6c8.4315f8","type":"comment","z":"e73dae77.7b465","name":"Log","info":"","x":150,"y":680,"wires":[]},{"id":"726085a2.7b897c","type":"function","z":"e73dae77.7b465","name":"","func":"msg = {};\nmsg.payload = {\"trafficlight\": {\"color\": 1, \"msg\": \"Some warning\"}};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":440,"y":500,"wires":[["c386f827.16eb38"]]},{"id":"36dbfce5.50a28c","type":"inject","z":"e73dae77.7b465","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":220,"y":500,"wires":[["726085a2.7b897c"]]},{"id":"b2e339a0.6f9588","type":"comment","z":"e73dae77.7b465","name":"TrafficLight - Orange","info":"","x":190,"y":460,"wires":[]},{"id":"a86c7275.a4358","type":"function","z":"e73dae77.7b465","name":"","func":"msg = {};\nmsg.payload = {\"trafficlight\": {\"color\": 2, \"msg\": \"Fatal error\"}};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":440,"y":580,"wires":[["c386f827.16eb38"]]},{"id":"2f33ea50.4da396","type":"inject","z":"e73dae77.7b465","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":220,"y":580,"wires":[["a86c7275.a4358"]]},{"id":"4a0ad995.ab5d6","type":"comment","z":"e73dae77.7b465","name":"TrafficLight - Red","info":"","x":180,"y":540,"wires":[]},{"id":"6a408571.4f517c","type":"comment","z":"e73dae77.7b465","name":"Reference implementation","info":"This is an example flow to show the capabilities of the ProficloudDevice-Node.\nThe inject->function combination can be replaced by the way you like to connect your application. You can also use one of the pre configured Nodes for PxC devices. Just install [this](https://www.npmjs.com/package/node-red-contrib-phoenix-contact).","x":150,"y":180,"wires":[]}]

其他数据来源

当然,可以将来自任何NodeRed数据来源的数据发送到Proficloud。

如果您正在使用预装的docker,已经安装有OPC UA和Modbus等节点。要获得NodeRed的PLCnext控制器的数据,查看 https://www.youtube.com/watch?v=PhM6ot3CtB8&list=PLTLcz6IpeLYLidXE0y6bIwD5cBRZp7dMt&index=11.

参考文献和从哪里了解更多信息


免费注册

从这里登录