メインコンテンツまでスキップ

HART-IP ドライバ

概要

HART (Highway Addressable Remote Transducer) の IP バリアント。4-20 mA 産業用計測器を IP ゲートウェイ 経由でデジタル read/write する。HCF の公開 HART-IP 仕様に基づく。

項目
opc_typeHART
実装クラスplantpulse.driver.protocol.hart.HARTDriver
ライブラリ独自 Java 実装 (HCF spec ベース、外部ライブラリ依存なし)
read✅ (cmd 1, 3, 13)
write✅ (cmd 6, 17, 18, 19, 22)
セキュリティなし (HART-IP spec 自体に認証/暗号化がない)
デフォルトポート5094 (TCP)

クラス構成

クラス役割
HARTDriverライフサイクル / アドレスパーサ / read・write ディスパッチ / KeepAlive スレッド
HartIpHeader13-byte HART-IP ヘッダ (version, type, id, status, sequence, byteCount BE)
HartCommandHART コマンド PDU ビルダ — preamble + 0x82 + 5-byte address + cmd + byteCount + data + XOR
HartChecksumlongitudinal XOR (preamble を除く)
HartDecodefloat32 BE / packed-ASCII 6-bit デコーダ、communication status ビット解釈

Wire フォーマット

HART-IP 메시지 = 13-byte 헤더 + payload

byte 0 Version 1
byte 1 Message Type 0=Request 1=Response 2=Publish 3=NAK
byte 2 Message ID 0=Session-Init 1=Session-Close 2=KeepAlive 3=PDU
byte 3 Status / Error
byte 4-5 Sequence (BE)
byte 6-7 ByteCount (BE, 헤더 13 byte 포함)
byte 8-12 Reserved (0)

PDU payload (Message ID 3) =
Preamble(0xFF×N) + Start(0x82) + Address(5) + Command(1) + ByteCount(1) + Data(N) + XOR(1)

ハンドシェイク: connect() が Session Init (master-type 1 byte + inactivity-close-time 4 byte BE) を 送信 → Response を受信。以降、KeepAlive バックグラウンドスレッドが周期的に Message ID 2 を送信する。


OPC 登録オプション

フィールド意味デフォルト
opc_agent_ip / opc_agent_portゲートウェイ IP / ポート(port 0 の場合は 5094)
options.master-typeprimary / secondaryprimary
options.inactivity-msSession inactivity close time600000 (10 分)
options.keepalive-msKeepAlive 送信周期30000
options.connect-timeoutTCP connect タイムアウト5000
options.read-timeoutread SO タイムアウト5000

タグ plc_address 形式

表記意味デコード
1 または 1:pvcmd 1 — Read PVfloat32 BE (status 2 byte 以降の offset 3)
3:0 ~ 3:3 または 3:pv/sv/tv/qvcmd 3 — PV/SV/TV/QV4 × float32 BE (簡易モデル)
13 または 13:tagcmd 13 — Tag 8 charpacked-ASCII (3 byte → 4 char)

write アドレス (address.getValue() と併用):

表記意味value 形式
6 / polling-addresscmd 6 — Write Polling Address0..63 の整数
17 / messagecmd 17 — Write Message32-char packed-ASCII
18 / tag / descriptor / datecmd 18 — Tag/Descriptor/Datetag|desc|DD/MM/YY または sub-field 単位
19 / final-assemblycmd 19 — Final Assembly Number0..16777215
22 / long-tagcmd 22 — Long Tag (32 byte ISO-Latin-1)任意の文字列

非対応範囲

  • WirelessHART (HART 7) burst モード、publish (Message Type 2) の非同期受信。
  • Cmd 0/cmd 50/cmd 9 などの device-discovery 系 — 追加可能。
  • Long-frame 以外の Short-frame address。
  • 5-byte device address の manufacturer/device-type マッチング (現状は zero-fill)。
  • Keepalive 応答の同期処理 — 簡略化のため keepalive 応答は無視 (別 receiver thread + seq correlation で補強可能)。

テストカバレッジ

test/java/plantpulse/driver/protocol/hart/

テスト検証内容
HartIpHeaderTest13-byte ヘッダの round-trip
HartChecksumTestXOR の既知 vector
HartCommandTest / HartCommandWriteTestcmd 0/1/3/13/6/17/18/19/22 の PDU ビルド
HartDecodeTest / HartEncodeTestfloat32 BE、packed-ASCII (双方向)、BCD date
HARTDriverAddressTest / HARTDriverWriteTestアドレスパーサ + write ディスパッチ
HartSpecExtraTest追加の spec 適合性

参考

  • HART-IP spec — FieldComm Group / HART Communication Foundation (会員向け文書)。
  • コード: plantpulse-edge-driver/src/plantpulse/driver/protocol/hart/
  • 運用時はゲートウェイ (例: ABB AC500-eCo、Pepperl+Fuchs HART Multiplexer) で TCP 5094 が公開されている必要がある。