OPC UAコネクタ
**OPC UA(Open Platform Communications Unified Architecture)**コネクタは、産業オートメーションとデータ交換の産業標準プロトコルであるOPC UAサーバーとの通信を可能にします。
コネクタタイプ:
OpcuaReader- OPC UAサーバーからデータを読み取るOpcuaWriter- OPC UAサーバーにデータを書き込む
- ✅ 産業オートメーション用の産業標準プロトコル
- ✅ 複数の認証方法(匿名、Basic、証明書)
- ✅ セキュリティモード(None、Sign、SignAndEncrypt)
- ✅ 設定可能なポーリングレート
- ✅ 複雑なノード構造のサポート
- ✅ 読み取りおよび書き込み操作
OPC UA Reader
Section titled “OPC UA Reader”{ "type": "OpcuaReader", "config": { "endpoint": "opc.tcp://localhost:4840", "pollingRate": 1000 }, "variables": [ { "key": "temperature", "nodeId": "ns=1;s=Temperature" }, { "key": "pressure", "nodeId": "ns=1;s=Pressure" } ]}{ "type": "OpcuaReader", "config": { "endpoint": "opc.tcp://localhost:4840", "pollingRate": 1000, "auth": { "mode": "Basic", "username": "opcuser", "password": "opcpassword" } }, "variables": [ { "key": "temperature", "nodeId": "ns=1;s=Temperature" } ]}{ "type": "OpcuaReader", "config": { "endpoint": "opc.tcp://localhost:4840", "pollingRate": 1000, "auth": { "authCertificateFile": { "mode": "DirectPath", "fileName": "certificate.pem", "path": "/path/to/certificate.pem" }, "authKeyFile": { "mode": "DirectPath", "fileName": "key.pem", "path": "/path/to/key.pem" } }, "security": { "mode": "SignAndEncrypt", "policy": "Basic256Sha256" } }, "variables": [ { "key": "temperature", "nodeId": "ns=1;s=Temperature" } ]}OPC UA Writer
Section titled “OPC UA Writer”{ "type": "OpcuaWriter", "config": { "endpoint": "opc.tcp://localhost:4840", "auth": { "mode": "Basic", "username": "opcuser", "password": "opcpassword" } }, "variables": [ { "key": "setpoint", "nodeId": "ns=1;s=Setpoint" }, { "key": "control_mode", "nodeId": "ns=1;s=ControlMode" } ]}設定パラメータ
Section titled “設定パラメータ”エンドポイント
Section titled “エンドポイント”OPC UAサーバーのエンドポイントURL。
{ "endpoint": "opc.tcp://192.168.1.100:4840"}形式: opc.tcp://[host]:[port][/path]
ポーリングレート
Section titled “ポーリングレート”リーダーの場合、データ読み取り間のミリ秒単位の間隔。
{ "pollingRate": 1000 // 1秒ごとに読み取る}推奨値:
- 高速: 100-500ms
- 通常: 1000ms(1秒)
- 低速: 5000ms(5秒)
匿名(デフォルト)
Section titled “匿名(デフォルト)”認証不要:
{ // authフィールド不要}Basic認証
Section titled “Basic認証”ユーザー名とパスワード:
{ "auth": { "mode": "Basic", "username": "your-username", "password": "your-password" }}X.509証明書:
{ "auth": { "authCertificateFile": { "mode": "DirectPath", "fileName": "client-cert.pem", "path": "/path/to/client-cert.pem" }, "authKeyFile": { "mode": "DirectPath", "fileName": "client-key.pem", "path": "/path/to/client-key.pem" } }}セキュリティ
Section titled “セキュリティ”セキュリティモードとポリシーを設定:
{ "security": { "mode": "SignAndEncrypt", "policy": "Basic256Sha256" }}セキュリティモード:
None- セキュリティなし(デフォルト)Sign- メッセージに署名のみSignAndEncrypt- メッセージに署名して暗号化
セキュリティポリシー:
NoneBasic128Rsa15Basic256Basic256Sha256(推奨)
変数は、読み取りまたは書き込みするOPC UAノードを定義します。
{ "key": "temperature", "nodeId": "ns=1;s=Temperature"}フィールド:
key- Meddleペイロード内のキー名nodeId- OPC UAノード識別子
Node ID形式
Section titled “Node ID形式”OPC UAはさまざまなNode ID形式をサポートします:
{ "key": "sensor1", "nodeId": "ns=1;s=SensorName"}{ "key": "sensor2", "nodeId": "ns=1;i=1001"}{ "key": "sensor3", "nodeId": "ns=1;g=12345678-1234-1234-1234-123456789012"}{ "key": "sensor4", "nodeId": "ns=1;b=AQIDBAUGBwg="}形式: ns=[namespace];[type]=[identifier]
ここで:
ns- 名前空間インデックス(0-65535)type- Node IDタイプ:s- 文字列i- 数値g- GUIDb- Opaque(Base64)
データフロー
Section titled “データフロー”リーダーデータフロー
Section titled “リーダーデータフロー”OPC UAサーバー → OpcuaReader → Meddleペイロード例:
OPC UAノード:
ns=1;s=Temperature= 25.5ns=1;s=Pressure= 101.3
出力ペイロード:
{ "temperature": 25.5, "pressure": 101.3}ライターデータフロー
Section titled “ライターデータフロー”Meddleペイロード → OpcuaWriter → OPC UAサーバー例:
入力ペイロード:
{ "setpoint": 30.0, "mode": "auto"}書き込み先:
ns=1;s=Setpoint← 30.0ns=1;s=Mode← “auto”
一般的なユースケース
Section titled “一般的なユースケース”1. 温度監視
Section titled “1. 温度監視”PLCから温度センサーを読み取る:
{ "type": "OpcuaReader", "config": { "endpoint": "opc.tcp://plc.local:4840", "pollingRate": 1000 }, "variables": [ { "key": "zone1_temp", "nodeId": "ns=2;s=Zone1.Temperature" }, { "key": "zone2_temp", "nodeId": "ns=2;s=Zone2.Temperature" }, { "key": "ambient_temp", "nodeId": "ns=2;s=Ambient.Temperature" } ]}2. プロセス制御
Section titled “2. プロセス制御”プロセスを制御するための設定値を書き込む:
{ "type": "OpcuaWriter", "config": { "endpoint": "opc.tcp://plc.local:4840", "auth": { "mode": "Basic", "username": "operator", "password": "secure123" } }, "variables": [ { "key": "temperature_setpoint", "nodeId": "ns=2;s=Control.TempSetpoint" }, { "key": "pressure_setpoint", "nodeId": "ns=2;s=Control.PressureSetpoint" } ]}3. 生産ライン監視
Section titled “3. 生産ライン監視”複数のマシンを監視:
{ "type": "OpcuaReader", "config": { "endpoint": "opc.tcp://scada.local:4840", "pollingRate": 500 }, "variables": [ { "key": "machine1_status", "nodeId": "ns=3;s=Machine1.Status" }, { "key": "machine1_speed", "nodeId": "ns=3;s=Machine1.Speed" }, { "key": "machine1_count", "nodeId": "ns=3;s=Machine1.ProductCount" }, { "key": "machine2_status", "nodeId": "ns=3;s=Machine2.Status" }, { "key": "machine2_speed", "nodeId": "ns=3;s=Machine2.Speed" } ]}トラブルシューティング
Section titled “トラブルシューティング”問題: OPC UAサーバーに接続できない
解決策:
- エンドポイントURLが正しいことを確認
- ネットワーク接続を確認:
ping [server-ip] - ポートが開いていることを確認:
telnet [server-ip] 4840 - ファイアウォールルールを確認
- OPC UAサーバーが実行中であることを確認
問題: 認証エラー
解決策:
- ユーザー名とパスワードが正しいことを確認
- ユーザーに適切な権限があることを確認
- 証明書認証の場合、証明書が有効で期限切れでないことを確認
- 証明書パスが正しいことを確認
ノードが見つからない
Section titled “ノードが見つからない”問題: 「ノードが見つかりません」エラー
解決策:
- OPC UAクライアント(UaExpertなど)を使用してサーバーを参照
- 名前空間インデックスが正しいことを確認
- Node ID形式がサーバーの形式と一致することを確認
- ノードが存在しアクセス可能であることを確認
セキュリティポリシーの不一致
Section titled “セキュリティポリシーの不一致”問題: セキュリティポリシーエラー
解決策:
- サーバーがサポートするセキュリティポリシーを確認
security.policyをサポートされているポリシーと一致させる- 暗号化接続用に証明書が正しく設定されていることを確認
パフォーマンスの問題
Section titled “パフォーマンスの問題”問題: データ更新が遅いまたはCPU使用率が高い
解決策:
- 頻度を減らすために
pollingRateを増やす - 読み取る変数の数を減らす
- サポートされている場合はサブスクリプションベースの読み取りを使用
- ネットワークレイテンシを確認
ベストプラクティス
Section titled “ベストプラクティス”1. 適切なポーリングレートを使用
Section titled “1. 適切なポーリングレートを使用”必要以上に速くポーリングしない:
- 重要なデータ: 100-500ms
- 通常の監視: 1000ms
- ゆっくり変化する値: 5000ms以上
2. 接続を保護
Section titled “2. 接続を保護”本番環境では常に認証と暗号化を使用:
{ "auth": { "mode": "Basic", "username": "user", "password": "pass" }, "security": { "mode": "SignAndEncrypt", "policy": "Basic256Sha256" }}3. 関連変数をグループ化
Section titled “3. 関連変数をグループ化”より良い組織化のために、関連する変数を同じコネクタに保持:
{ "variables": [ // 温度センサー {"key": "temp1", "nodeId": "ns=1;s=Temp1"}, {"key": "temp2", "nodeId": "ns=1;s=Temp2"}, // 圧力センサー {"key": "press1", "nodeId": "ns=1;s=Press1"}, {"key": "press2", "nodeId": "ns=1;s=Press2"} ]}4. 接続喪失を処理
Section titled “4. 接続喪失を処理”Meddleは接続喪失と再接続を自動的に処理しますが、以下を考慮してください:
- 欠落データを処理するためにタイムアウト付きの
Mergeコネクタを使用 - 接続の問題を通知するために
Alertコネクタを追加
5. 最初に匿名でテスト
Section titled “5. 最初に匿名でテスト”接続を確認するために匿名認証から始め、その後セキュリティを追加:
- 認証なしでテスト
- ユーザー名/パスワードを追加
- 暗号化を追加
- 証明書認証を追加
ワークフロー例
Section titled “ワークフロー例”完全な監視ワークフロー
Section titled “完全な監視ワークフロー”OpcuaReader → Filter → Reshape → InfluxDb2Writer ↓ Trigger → Alert(高温時にメール)- OpcuaReader: 温度と圧力を読み取る
- Filter: 関連フィールドのみを保持
- Reshape: メタデータを追加(場所、単位)
- InfluxDb2Writer: 時系列データベースに保存
- Trigger: 高温をチェック
- Alert: しきい値を超えた場合にメールを送信
関連コネクタ
Section titled “関連コネクタ”- Modbus - 代替産業プロトコル
- Siemens S7 - Siemens PLC直接通信
- Filter - OPC UAデータをフィルタリング
- Trigger - OPC UAデータの条件付きロジック
追加リソース
Section titled “追加リソース”- OPC Foundation
- OPC UA仕様
- UaExpert - テスト用の無料OPC UAクライアント