> For the complete documentation index, see [llms.txt](https://docs.roboflow.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.roboflow.com/roboflow/roboflow-jp/deploy/device-manager/plc-relay.md).

# PLC Relay

PLC Relay は、PLC タグの読み書き用 HTTP API を提供するエッジコンテナサービスです。Deployment Manager UI でプロトコルを選択し、接続情報を入力し、タグを定義することで設定します。

{% hint style="info" %}
PLC Relay は Enterprise のお客様限定でご利用いただけます。 [Roboflow の営業チームにお問い合わせください](https://roboflow.com/sales) 詳細をご確認いただくためです。
{% endhint %}

## 対応プロトコル

PLC Relay サービスを追加または編集する際は、3 つのプロトコルのうち 1 つを選択します。各プロトコルには、それぞれ独自の接続設定とタグ形式があります。

| プロトコル                       | PLC                                | デフォルトポート |
| --------------------------- | ---------------------------------- | -------- |
| Allen-Bradley (EtherNet/IP) | CompactLogix、ControlLogix、Micro800 | 44818    |
| Modbus TCP                  | 任意の Modbus TCP デバイス                | 502      |
| Siemens S7                  | S7-300、S7-400、S7-1200、S7-1500      | 102      |

{% hint style="warning" %}
プロトコルを切り替えると、タグのアドレス形式はプロトコル間で互換性がないため、設定済みのタグがすべて消去されます。変更を適用する前に、UI で確認を求められます。
{% endhint %}

## 接続設定

### PLC アドレス

アドレス形式は、選択したプロトコルによって異なります。

* **Allen-Bradley:** IP またはホスト名。必要に応じてその後に `/slot` （例： `192.168.1.100/0`）または完全な CIP ルーティングパス。
* **Modbus TCP:** IP またはホスト名。必要に応じて `:port` （例： `192.168.1.100:502`）. また、32 ビット値には Unit ID（0-255）と Word Order（big または little）も必要です。
* **Siemens S7:** IP またはホスト名。必要に応じて `:port` （例： `192.168.1.100:102`）. また、Rack（0-7）と Slot（0-31）も必要です。

### シミュレーションモード

有効にすると、PLC Relay は実際の PLC に接続せず、メモリ内シミュレーターを使用します。すべての API 操作は通常どおり動作しますが、値はメモリ内に保存されます。これはハードウェアなしでのテストに便利です。

## タグ設定

タグは、API 経由でアクセス可能な PLC データポイントを定義します。各タグには、名前、データ型、書き込み可否フラグ、および任意の説明があります。

### データ型

| タイプ    | 説明           | 範囲                              |
| ------ | ------------ | ------------------------------- |
| `BOOL` | boolean      | `true` / `false`                |
| `INT`  | 16 ビット符号付き整数 | -32,768 から 32,767               |
| `DINT` | 32 ビット符号付き整数 | -2,147,483,648 から 2,147,483,647 |
| `REAL` | 32 ビット浮動小数点  | IEEE 754                        |

### タグ名の形式

{% tabs %}
{% tab title="Allen-Bradley" %}
タグ名は PLC プログラムと一致し、大文字小文字が区別されます。

| スタイル         | 例                             |
| ------------ | ----------------------------- |
| シンプル         | `TagName`                     |
| Program スコープ | `Program:MainProgram.TagName` |
| 配列要素         | `TagName[0]`                  |
| UDT メンバー     | `MyUDT.Member`                |
| {% endtab %} |                               |

{% tab title="Modbus TCP" %}
形式: `{area}:{address}` ここで address は 0 以上の整数です。

| エリア          | 型             | アクセス   | 例             |
| ------------ | ------------- | ------ | ------------- |
| `コイル`        | BOOL          | 書き込み可能 | `coil:0`      |
| `ディスクリート`    | BOOL          | 読み取り専用 | `discrete:5`  |
| `ホールディング`    | INT、DINT、REAL | 書き込み可能 | `holding:100` |
| `入力`         | INT、DINT、REAL | 読み取り専用 | `input:200`   |
| {% endtab %} |               |        |               |

{% tab title="Siemens S7" %}
Data Block 形式: `DB{n}.DB[XWD]{byte}[.{bit}]`

Area 形式: `[MIQEA][WD]?{byte}[.{bit}]`

| アドレス            | タイプ                 | 説明                            |
| --------------- | ------------------- | ----------------------------- |
| `DB1.DBX0.0`    | BOOL                | Data Block 1 の byte 0 の bit 0 |
| `DB1.DBW0`      | INT                 | DB1 の 16 ビットワード               |
| `DB1.DBD0`      | DINT または REAL       | DB1 の 32 ビットダブルワード            |
| `M0.0`          | BOOL                | Merker ビット                    |
| `I0.0` / `Q0.0` | BOOL                | プロセス入出力ビット                    |
| `MW0` / `MD0`   | INT / DINT または REAL | Merker ワード / ダブルワード           |

S7-1200/1500 の場合: TIA Portal で PUT/GET を有効にし、アクセス対象の DB では最適化ブロックアクセスを無効にします。
{% endtab %}
{% endtabs %}

## Web Dashboard と REST API

PLC Relay には、タグ値をリアルタイムで監視するための組み込み Web Dashboard が含まれています。サービスが起動したら、次の場所でアクセスできます。 `http://<device-ip>:8007`.

Dashboard には、次の場所に対話型の Swagger ドキュメントもあります `/docs` および次の場所にビジュアルな config builder があります `/static/config-builder.html`.

### API エンドポイント

| メソッド | パス               | 説明                  |
| ---- | ---------------- | ------------------- |
| GET  | `/healthz`       | 接続状況と検証状況を含むヘルスチェック |
| GET  | `/all_tags`      | すべてのタグの現在値を読み取る     |
| GET  | `/read?tag=name` | 名前で単一のタグを読み取る       |
| POST | `/write`         | 単一のタグを書き込む          |
| POST | `/read_batch`    | 複数のタグを一度に読み取る       |
| POST | `/write_batch`   | 複数のタグを一度に書き込む       |
| GET  | `/schema`        | すべてのタグ定義を取得する       |
| POST | `/validate`      | PLC に対してタグ検証を再実行する  |

## トラブルシューティング

| 症状                                  | 対処法                                                                                       |
| ----------------------------------- | ----------------------------------------------------------------------------------------- |
| "PLC not connected" (Allen-Bradley) | PLC アドレス形式（IP/Slot）を確認し、ポート 44818 に到達できることを確認してください                                       |
| "PLC not connected" (Modbus)        | IP/port（デフォルト 502）を確認し、Unit ID がデバイスと一致していることを確認してください                                    |
| "PLC not connected" (Siemens S7)    | IP/port（デフォルト 102）、rack、slot の値を確認してください。S7-1200/1500 では PUT/GET を有効にし、最適化ブロックアクセスを無効にします |
| "Function refused" (Siemens S7)     | TIA Portal で PUT/GET が無効になっているか、対象 DB で最適化ブロックアクセスが有効になっています                              |
| REAL 値がゴミとして読み取られる（Modbus）          | 逆の Word Order（big と little）を試してください                                                       |
| 検証結果が NOT\_FOUND になる                | PLC プログラムで正確なタグ名を確認してください（大文字小文字を区別します）                                                   |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.roboflow.com/roboflow/roboflow-jp/deploy/device-manager/plc-relay.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
