EtherNet/IP (Logix) ドライバ
概要
CIP (Common Industrial Protocol) ベースの EtherNet/IP。主に Allen-Bradley / Rockwell ControlLogix / CompactLogix PLC と通信します。
| 項目 | 値 |
|---|---|
opc_type | EIP |
| 実装クラス | plantpulse.driver.protocol.eip.EIP_34_Driver |
| ライブラリ | digitalpetri/ethernet-ip (CipClient + GetAttributeListService) |
| read | ✅ (attribute list raw bytes → String) |
| write | ❌ (別途 service 呼び出しが必要) |
| セキュリティ | なし |
他の PLC ドライバと異なり、PLC4j ではなく digitalpetri/ethernet-ip を直接使用します (PLC4jProtocolDriver ではなく BaseProtocolDriver を継承)。
PLC4j の plc4j-driver-eip も lib に含まれていますが、本クラスでは使用しません。
OPC 登録フォーム
| フィールド | 意味 | 例 |
|---|---|---|
opc_agent_ip | PLC IP | 192.168.0.90 |
opc_agent_port | EIP ポート | 44818 |
timecycle | ポーリング周期 (ms) | 1000 |
options.backplane | backplane 番号 | 1 (default) |
options.local-slot | CPU slot 番号 | 0 (default) |
内部 timeout は 2 秒固定 (Duration.ofSeconds(2))。
タグ plc_address 形式
EIP の raw read は CIP class / instance / attribute 座標で動作します。Edge では plc_address
フィールドに <class>,<instance>,<attribute> 形式 (10進または16進) で入力します。
| 表記 | 意味 |
|---|---|
0x6B,1,1 | Symbol class 0x6B, instance 1, attribute 1 |
0x6C,1,1 | Template class |
0x01,1,7 | Identity object の Product Name |
Tag1.Member)Logix で一般的なシンボリックタグの read (MyController:Tag1) は別途 service (Read Tag Service) を
使用する必要があり、本ドライバは raw GetAttributeListService のみを使用します。シンボリック read が必要な場合は
PLC4j EIP ドライバへの切り替え、または後続実装が必要です。
data_type / format マッピング
data_type | format | 備考 |
|---|---|---|
| String | (empty) | 応答 raw bytes をそのまま String として蓄積 |
| Integer / Float / … | (empty) | 後処理でキャスト。現ドライバは raw bytes → String |
後処理 (PLCValueFomula / Sparkplug DataTypeMapper) で data_type にキャストします。
よくあるエラーと対処
| メッセージ / 症状 | 原因 | 対処 |
|---|---|---|
| Connection timeout | ポート 44818 が遮断、EIP が未稼働 | RSLogix / Studio5000 で EtherNet/IP module を有効化 |
| Forward Open failure | rack/slot の不一致 | options.backplane / options.local-slot を修正 |
Class/Instance not found | class / instance ID が不正 | Studio5000 の Tag Browser または wireshark で応答を確認 |
| 値が壊れて見える | byte をそのまま String 変換している | 後処理で 4-byte little-endian として解釈する fomula を適用 |
curl 登録例
curl -X POST http://<edge-host>/api/v1/opc \
-H "Content-Type: application/json" \
-d '{
"opc_id": "OPC_EIP_LOGIX",
"opc_type": "EIP",
"opc_name": "Logix L83E",
"opc_agent_ip": "192.168.0.90",
"opc_agent_port": "44818",
"site_id": "SITE_00001",
"auto_collect": true,
"timecycle": 1000,
"options": {
"backplane": "1",
"local-slot": "0"
},
"tag_list": [
{
"tag_id": "OPC_EIP_LOGIX_TAG_00001",
"tag_name": "ProductName",
"plc_address": "0x01,1,7",
"data_type": "String"
}
]
}'
サンプル集 (データタイプ別)
EIP raw read は <class>,<instance>,<attribute> 座標(10進または 0x 接頭の16進) の raw bytes を String として蓄積します。後処理で data_type / fomula にキャストします。
CIP 座標形式
plc_address | 意味 |
|---|---|
0x01,1,1 | Identity → Vendor ID |
0x01,1,2 | Identity → Device Type |
0x01,1,7 | Identity → Product Name (String) |
0x6B,1,1 | Symbol Class (Logix tag list) instance 1 attribute 1 |
0x6C,1,1 | Template Class |
0x6C,2,1 | Template Class instance 2 |
0x73,1,1 | Connection Manager |
データタイプ別マッピング
data_type | format | plc_address 例 | 備考 |
|---|---|---|---|
String | (empty) | 0x01,1,7 | Product name (raw bytes をそのまま String) |
Integer | (empty) | 0x01,1,1 | Vendor ID。raw bytes → fomula で little-endian 解釈 |
Integer | (empty) | 0x01,1,2 | Device Type |
Boolean | (empty) | 0x01,1,8 | Status word (bit 抽出は後処理) |
Float | (empty) | <class>,<inst>,<attr> | 4-byte raw 応答 → 後処理 |
EIP_34_Driver は GetAttributeListService のみを呼び出します。シンボリックタグ (MyController:Tag1.Member) の read が必要な場合は、ControlLogix Read Tag Service を使用する別途実装が必要です。PLC4j EIP が lib に含まれているため、後続での切り替えが可能です。
Formula の活用
| 用途 | data_type | fomula | 備考 |
|---|---|---|---|
| 整数 raw 補正 | Integer | ${VALUE}*1 | 無変換パススルー用 |
| 16-bit 2値の結合 | Integer | ${TAG_HI}*65536+${VALUE} | hi/lo 2 つの attribute を合成 |
| 単位変換 | Float | ${VALUE}*0.1 | raw 整数のスケーリング |
curl 総合例
curl -X POST http://<edge-host>/api/v1/opc \
-H "Content-Type: application/json" \
-d '{
"opc_id": "OPC_EIP_FULL",
"opc_type": "EIP",
"opc_name": "Logix Full",
"opc_agent_ip": "192.168.0.90",
"opc_agent_port": "44818",
"site_id": "SITE_00001",
"auto_collect": true,
"timecycle": 1000,
"options": { "backplane": "1", "local-slot": "0" },
"tag_list": [
{"tag_id":"OPC_EIP_FULL_T01", "tag_name":"VendorId", "plc_address":"0x01,1,1", "data_type":"Integer"},
{"tag_id":"OPC_EIP_FULL_T02", "tag_name":"DeviceType", "plc_address":"0x01,1,2", "data_type":"Integer"},
{"tag_id":"OPC_EIP_FULL_T03", "tag_name":"ProductName","plc_address":"0x01,1,7", "data_type":"String"},
{"tag_id":"OPC_EIP_FULL_T04", "tag_name":"Status", "plc_address":"0x01,1,5", "data_type":"Integer"}
]
}'