OPC-UAエッジにMQTTブローカー機能を追加

OPCUAのシミュレーション環境構築の続きです。

Node-REDを起動します。

$ node_red

右上のメニューから Manage Palette->Installと進み、MQTTをキーワードとしてサーチすると、node-red-contrib-mqtt-brokerがリストに上がるので、そちらをインストールします。

MQTTブローカーと、メッセージのフローを定義します。ブローカー名もトピック名もopcusで統一しました。

ノードの定義情報は下記の通りです。

[{"id":"ec790534.951b68","type":"tab","label":"Flow 1","disabled":false,"info":""},
{"id":"67c1b94a.8e3d68","type":"inject","z":"ec790534.951b68","name":"","topic":"","payload":"","payloadType":"str","repeat":"1","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":100,"wires":[["636955.409ec6ac"]]},
{"id":"636955.409ec6ac","type":"OpcUa-Item","z":"ec790534.951b68","item":"ns=5,s=MyDevice.AirPump.Pressure","datatype":"Int16","value":"","name":"","x":360,"y":200,"wires":[["fd0f2661.df4c78"]]},{"id":"fd0f2661.df4c78","type":"OpcUa-Client","z":"ec790534.951b68","endpoint":"c373c829.ec8b98","action":"read","deadbandtype":"a","deadbandvalue":1,"time":10,"timeUnit":"s","certificate":"n","localfile":"/home/hajime/.prosysopc/prosys-opc-ua-simulation-server/PKI/CA/private/SimulationServerCA.der","name":"","x":620,"y":300,"wires":
[["62cc8ba4.c5f5c4","4db89240.c0b5dc"]]},
{"id":"62cc8ba4.c5f5c4","type":"debug","z":"ec790534.951b68","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":870,"y":360,"wires":[]},
{"id":"4db89240.c0b5dc","type":"mqtt out","z":"ec790534.951b68","name":"","topic":"opcua","qos":"","retain":"","broker":"fc2d7de0.630ad","x":860,"y":440,"wires":[]},{"id":"f33ba72d.1fa478","type":"mosca in","z":"ec790534.951b68","mqtt_port":1883,"mqtt_ws_port":8080,"name":"opcua","username":"","password":"","dburl":"","x":110,"y":40,"wires":[["4a8ca18b.c764d"]]},
{"id":"4a8ca18b.c764d","type":"debug","z":"ec790534.951b68","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":390,"y":40,"wires":[]},
{"id":"c20acf2d.4fe59","type":"mqtt in","z":"ec790534.951b68","name":"","topic":"opcua","qos":"2","datatype":"auto","broker":"fc2d7de0.630ad","x":110,"y":540,"wires":[["8aa024fd.a71708"]]},
{"id":"8aa024fd.a71708","type":"debug","z":"ec790534.951b68","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":860,"y":540,"wires":[]},
{"id":"c3cd8be0.bb0b08","type":"comment","z":"ec790534.951b68","name":"OPCA用 MQTTブローカー","info":"","x":660,"y":40,"wires":[]},
{"id":"43cd547b.38078c","type":"comment","z":"ec790534.951b68","name":"OPCAサーバーからデータを取り込むフロー","info":"","x":710,"y":180,"wires":[]},
{"id":"4e0bdd8f.28b054","type":"comment","z":"ec790534.951b68","name":"OPCAから外部IoTプラットフォームに接続","info":"","x":640,"y":500,"wires":[]},{"id":"c373c829.ec8b98","type":"OpcUa-Endpoint","z":"","endpoint":"opc.tcp://hajime-DAIV-NG5800:53530/OPCUA/SimulationServer","secpol":"None","secmode":"NONE","login":false},
{"id":"fc2d7de0.630ad","type":"mqtt-broker","z":"","name":"opcua","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"opcua","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]

ここからKafkaにデータを入れ、別途立ち上げたKairosDBにデータを入れ、時系列データ分析機能をもった、IoTプラットフォームのPoCを行ってみたいと考えています。

コメント

タイトルとURLをコピーしました