「.NET 開発基盤部会 Wiki」は、「Open棟梁Project」,「OSSコンソーシアム .NET開発基盤部会」によって運営されています。
ちょっと触ることになったので。
Apache NiFiと同じ、flow-based programmingツール。
モノのインターネットを配線するための
Node-REDエディタ
ローカルのPCやクラウド、Raspberry Pi上で動作させることが可能。
デスクトップPC上の開発環境でも動作する。
サーバとしても動作する。
Raspberry Piなどのデバイス(クライアント)上でも動作する。
Node-REDのダッシュボードUI
Open APIドキュメントや関数ノードのソースなど、
様々なソースからNode-REDノードモジュールを生成するCLI
Node-REDインスタンスをリモートで管理できるCLI
システム間の接続インタフェース(API)を統合管理する技術
Docker環境を準備して、以下を行う。
FROM nodered/node-red RUN mkdir -p $HOME/.node-red RUN cd $HOME/.node-red RUN npm install node-red-contrib-aedes※ MQTTを動かすため、追加インストールを行っている。
>docker build -t nodered-sample:p1 .
version: '3.4'
services:
nodered_sample:
image: nodered-sample:p1
ports:
- "1880:1880"
- "1883:1883">docker-compose up
※ portsは、ホスト側:コンテナ側で、1880は、HTTP。1883は、MQTT。
起動したら、以下のURLにアクセスする。
フロー・エディタが起動する。
フロー・エディタでフローの定義が完了したら、デプロイ・ボタンを押下。
フローのインポート / エクスポート
主要なノードの説明
[
{
"id": "f6f2187d.f17ca8",
"type": "tab",
"label": "Flow 1",
"disabled": false,
"info": ""
},
{
"id": "3e63d5c0.89476a",
"type": "http in",
"z": "f6f2187d.f17ca8",
"name": "HTTP Endpoint",
"url": "hoge/:param",
"method": "get",
"upload": false,
"swaggerDoc": "",
"x": 160,
"y": 320,
"wires": [
[
"3dcdaca5.9f0f64"
]
]
},
{
"id": "7027d3d1.6d81fc",
"type": "debug",
"z": "f6f2187d.f17ca8",
"name": "Debug",
"active": true,
"tosidebar": true,
"console": true,
"tostatus": true,
"complete": "payload",
"targetType": "msg",
"statusVal": "payload",
"statusType": "auto",
"x": 420,
"y": 260,
"wires": []
},
{
"id": "4cd59e40.9521f",
"type": "http response",
"z": "f6f2187d.f17ca8",
"name": "HTTP Response",
"statusCode": "200",
"headers": {},
"x": 500,
"y": 340,
"wires": []
},
{
"id": "3dcdaca5.9f0f64",
"type": "template",
"z": "f6f2187d.f17ca8",
"name": "page",
"field": "payload",
"fieldType": "msg",
"format": "handlebars",
"syntax": "mustache",
"template": "<!DOCTYPE html>\n<html lang=”en”>\n<head>\n<title>Response Named Parameters</title>\n</head>\n<h1>Page found Named Parameters {{req.params.param}}</h1>\n</html>",
"output": "str",
"x": 330,
"y": 340,
"wires": [
[
"4cd59e40.9521f",
"7027d3d1.6d81fc"
]
]
}
]http://localhost:1880/hoge/hogehoge
[
{
"id": "f6f2187d.f17ca8",
"type": "tab",
"label": "Flow 1",
"disabled": false,
"info": ""
},
{
"id": "1d2a9951.8880c7",
"type": "aedes broker",
"z": "f6f2187d.f17ca8",
"name": "",
"mqtt_port": 1883,
"mqtt_ws_port": "",
"cert": "",
"key": "",
"certname": "",
"keyname": "",
"dburl": "",
"usetls": false,
"x": 240,
"y": 100,
"wires": [
[
"b9d42de9.5a91f"
]
]
},
{
"id": "b9d42de9.5a91f",
"type": "debug",
"z": "f6f2187d.f17ca8",
"name": "",
"active": true,
"tosidebar": true,
"console": true,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 450,
"y": 100,
"wires": []
},
{
"id": "70b86e52.71106",
"type": "mqtt in",
"z": "f6f2187d.f17ca8",
"name": "",
"topic": "hoge",
"qos": "2",
"datatype": "auto",
"broker": "e9b0ae32.61f46",
"x": 210,
"y": 160,
"wires": [
[
"ba2f427b.97b3f"
]
]
},
{
"id": "ba2f427b.97b3f",
"type": "debug",
"z": "f6f2187d.f17ca8",
"name": "",
"active": true,
"tosidebar": true,
"console": true,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 460,
"y": 160,
"wires": []
},
{
"id": "e9b0ae32.61f46",
"type": "mqtt-broker",
"name": "hoge",
"broker": "localhost",
"port": "1883",
"clientid": "",
"usetls": false,
"compatmode": false,
"keepalive": "60",
"cleansession": true,
"birthTopic": "",
"birthQos": "0",
"birthPayload": "",
"closeTopic": "",
"closeQos": "0",
"closePayload": "",
"willTopic": "",
"willQos": "0",
"willPayload": ""
}
]mosquitto_pub -h localhost -p 1883 -t message -m 'hoge' -d※ localhostの部分は、FQDN名やIPアドレスなどでもOK(当たり前だが
IoTデバイス上で実行させるフロー
Node.js + Expressの設定で行うことが出来る。
ダッシュボードだけに適用する場合、
node-red-dashboard自体に設定がある。