8. タグ サービス
client.tag() でアクセスします。タグはデータポイント(センサ値、カウンタ、状態)の 定義(メタデータ) です。V5では タブ別 PATCH 10種 を通じて、アラーム・集計・計算などの詳細設定を安全に部分修正できます。
ID ルール:
TAG_プレフィックス必須。詳細は ドメイン ID ルール を参照。
8.1 メソッド一覧
CRUD
| メソッド | 戻り値の型 | HTTP | エンドポイント |
|---|---|---|---|
create(TagRequestV5) | TagResponseV5 または null | POST | /api/v5/tag |
update(tag_id, TagRequestV5) | TagResponseV5 または null | PUT | /api/v5/tag/{id} |
delete(tag_id) | boolean | DELETE | /api/v5/tag/{id} |
get(tag_id) | TagResponseV5 または null | GET | /api/v5/tag/{id} |
exists(tag_id) | boolean | GET | /api/v5/tag/{id}/exists |
リスト / カウント
| メソッド | 戻り値の型 | HTTP | エンドポイント |
|---|---|---|---|
list() | List<TagResponseV5> | GET | /api/v5/tag |
listBySite(site_id) | List<TagResponseV5> | GET | /api/v5/tag?site_id=... |
listByOpc(opc_id) | List<TagResponseV5> | GET | /api/v5/tag?opc_id=... |
listByAsset(asset_id) | List<TagResponseV5> | GET | /api/v5/tag?asset_id=... |
count() | long | GET | /api/v5/tag/count |
countBySite(site_id) | long | GET | /api/v5/tag/count?site_id=... |
countByOpc(opc_id) | long | GET | /api/v5/tag/count?opc_id=... |
countByAsset(asset_id) | long | GET | /api/v5/tag/count?asset_id=... |
PATCH — タブ別部分修正 (V5 コア機能)
10種の PATCH は null フィールド = 変更しない ルールに従います(サーバ DAO で COALESCE 処理)。一部の PATCH はサーバで CEP/EQL の再配布まで自動的に行います。
| メソッド | HTTP | エンドポイント | 副次効果 |
|---|---|---|---|
patchBasic(id, TagBasicPatchRequestV5) | PATCH | /api/v5/tag/{id}/basic | — |
patchAlarm(id, TagAlarmPatchRequestV5) | PATCH | /api/v5/tag/{id}/alarm | CEP/EQL 再配布 |
patchMetadata(id, TagMetadataPatchRequestV5) | PATCH | /api/v5/tag/{id}/metadata | — |
patchCalculation(id, TagCalculationPatchRequestV5) | PATCH | /api/v5/tag/{id}/calculation | deployCalculation 再呼出 |
patchSampling(id, TagSamplingPatchRequestV5) | PATCH | /api/v5/tag/{id}/sampling | — |
patchAggregation(id, TagAggregationPatchRequestV5) | PATCH | /api/v5/tag/{id}/aggregation | deployAggregation 再呼出 |
patchAi(id, TagAiPatchRequestV5) | PATCH | /api/v5/tag/{id}/ai | — |
patchPublish(id, TagPublishPatchRequestV5) | PATCH | /api/v5/tag/{id}/publish | — |
patchAttribute(id, TagAttributePatchRequestV5) | PATCH | /api/v5/tag/{id}/attribute | — |
patchLink(id, TagLinkPatchRequestV5) | PATCH | /api/v5/tag/{id}/link | — |
8.2 TagRequestV5 / TagResponseV5 (全体登録・修正用)
| フィールド | 型 | 説明 |
|---|---|---|
tag_id | String | タグ ID (PK, TAG_ 必須) |
tag_name | String | 表示名 |
opc_id | String | 所属 OPC (FK) |
site_id | String | 所属サイト |
linked_asset_id | String | 接続された設備(Equipment) |
java_type | String | 値のデータ型 — Double, Float, Int, Long, Short, Boolean, String, Date |
unit | String | 単位 (例: ℃, RPM, kPa) |
source_type | String | (応答専用) ソースタイプ — タグの接続プロトコルから派生 (OPC/PLC/MODBUS/DATABASE/MESSAGING/API/SYSTEM) |
description | String | 説明 |
8.3 PATCH DTO フィールド (タブ別)
TagBasicPatchRequestV5 (基本)
| フィールド | 説明 |
|---|---|
tag_name | 表示名 |
java_type | データ型 |
description | 説明 |
TagMetadataPatchRequestV5 (メタデータ)
| フィールド | 説明 |
|---|---|
tag_type | タグタイプ |
importance | 重要度 (1~10) |
use_metric | メトリクス使用可否 |
rate | 受信周期 (ms) — 記録用。実際のポーリング間隔は接続設定で決定 |
rw | 読み書き (R/W/RW) |
alias_name | 別名 |
min_value / max_value | ゲージチャートの目盛基準 — 値を検証しない |
display_format | UI 表示形式 |
unit | 単位 |
number_round / number_scale | 四捨五入 / 小数点 |
io_address / source_tag_name | I/O アドレス・元タグ名 |
lat / lng | 経緯度 |
TagAlarmPatchRequestV5 (アラーム)
| フィールド | 説明 |
|---|---|
trip_hi, hi_hi, hi, lo, lo_lo, trip_lo | 閾値 (6段階) |
bool_true, bool_true_priority, bool_true_message | ブーリアン TRUE アラーム |
bool_false, bool_false_priority, bool_false_message | ブーリアン FALSE アラーム |
band_message | 正常バンドメッセージ |
duplicate_check_minutes | 重複アラーム遮断分 |
user_defined_alarm_class | ユーザー定義クラス |
use_alarm | アラーム使用 (Y/N) |
recieve_me, recieve_others | 本人/他人受信 |
send_email, send_sms | メール/SMS送信 |
TagCalculationPatchRequestV5 (計算)
| フィールド | 説明 |
|---|---|
calculation_eql | EQL 式 |
use_calculation | 使用可否 (Y/N) |
TagSamplingPatchRequestV5 (サンプリング)
| フィールド | 説明 |
|---|---|
use_sampling | 使用可否 (Y/N) |
TagAggregationPatchRequestV5 (集計)
| フィールド | 説明 |
|---|---|
use_aggregation | 使用可否 |
aggregation_1_minutes ~ aggregation_1_hours | 5種類の周期有効化フラグ |
TagAiPatchRequestV5 (AI 異常検知)
| フィールド | 説明 |
|---|---|
use_target | 多変量相関分析 対象 (Y/N) — 1つの設備に2個以上ある場合に分析が有効化される |
use_category | 多変量データを分ける 分岐カラム (Y/N) — レシピ・設備モード・運転など |
TagPublishPatchRequestV5 (発行)
| フィールド | 説明 |
|---|---|
publish_mqtt | MQTT 発行 (Y/N) |
publish_kafka | Kafka 発行 (Y/N) — OPC-UA サーバプラグインがデータを受信するには Y である必要がある |
TagAttributePatchRequestV5 (ノート)
| フィールド | 説明 |
|---|---|
note | 自由形式メモ |
TagLinkPatchRequestV5 (設備マッピング)
| フィールド | 説明 |
|---|---|
linked_asset_id | 接続設備 ID。空文字列 = マッピング解除 |
8.4 使用例
タグ作成 (OPC 接続タグ)
import plantpulse.api.v5.dto.request.TagRequestV5;
import plantpulse.api.v5.dto.response.TagResponseV5;
TagRequestV5 req = new TagRequestV5();
req.setTag_id("TAG_EDGE_00303_90007");
req.setTag_name("Spindle RPM");
req.setOpc_id("OPC_EDGE_00303");
req.setSite_id("SITE_DJ");
req.setLinked_asset_id("EQUIPMENT_000001");
req.setJava_type("Double");
req.setUnit("RPM");
req.setDescription("Spindle 회전수");
TagResponseV5 created = client.tag().create(req);
単一照会 / 存在確認
TagResponseV5 tag = client.tag().get("TAG_EDGE_00303_90007");
if (tag != null) {
System.out.println(tag.getTag_name() + " (" + tag.getUnit() + ")");
}
boolean exists = client.tag().exists("TAG_EDGE_00303_90007");
サイト / OPC / アセット別リスト
List<TagResponseV5> siteTags = client.tag().listBySite("SITE_DJ");
List<TagResponseV5> opcTags = client.tag().listByOpc("OPC_PLC_L1_001");
List<TagResponseV5> assetTags = client.tag().listByAsset("EQUIPMENT_000001");
カウント
long total = client.tag().count();
long siteTotal = client.tag().countBySite("SITE_DJ");
long opcTotal = client.tag().countByOpc("OPC_PLC_L1_001");
long assetTotal = client.tag().countByAsset("EQUIPMENT_000001");
全体修正 (PUT)
全フィールドを再送信する場合:
TagRequestV5 update = new TagRequestV5();
update.setTag_id("TAG_EDGE_00303_90007");
update.setTag_name("Spindle RPM (변경됨)");
update.setOpc_id("OPC_EDGE_00303");
update.setSite_id("SITE_DJ");
update.setJava_type("Double");
update.setUnit("RPM");
// ... 모든 필드 ...
client.tag().update("TAG_EDGE_00303_90007", update);
部分修正 — patchBasic
名称と説明のみ変更:
import plantpulse.api.v5.dto.request.TagBasicPatchRequestV5;
TagBasicPatchRequestV5 patch = new TagBasicPatchRequestV5();
patch.setTag_name("Spindle RPM (보정 후)");
patch.setDescription("2026-05-14 보정 적용");
// java_type 은 null 로 두면 변경 안 함
client.tag().patchBasic("TAG_EDGE_00303_90007", patch);
部分修正 — patchAlarm
アラーム閾値設定 (サーバで CEP/EQL 再配布):
import plantpulse.api.v5.dto.request.TagAlarmPatchRequestV5;
TagAlarmPatchRequestV5 alarm = new TagAlarmPatchRequestV5();
alarm.setUse_alarm("Y");
alarm.setLo_lo("0");
alarm.setLo("10");
alarm.setHi("80");
alarm.setHi_hi("95");
alarm.setTrip_hi("100");
alarm.setDuplicate_check_minutes(5);
alarm.setSend_email("Y");
client.tag().patchAlarm("TAG_EDGE_00303_90007", alarm);
部分修正 — patchMetadata
別名と表示形式を変更:
import plantpulse.api.v5.dto.request.TagMetadataPatchRequestV5;
TagMetadataPatchRequestV5 meta = new TagMetadataPatchRequestV5();
meta.setAlias_name("HMI_TAG_RPM_01");
meta.setDisplay_format("#,##0");
meta.setNumber_scale(0);
meta.setImportance(8);
client.tag().patchMetadata("TAG_EDGE_00303_90007", meta);
部分修正 — patchCalculation
EQL 計算式を付帯 (サーバで deployCalculation 再呼出):
import plantpulse.api.v5.dto.request.TagCalculationPatchRequestV5;
TagCalculationPatchRequestV5 calc = new TagCalculationPatchRequestV5();
calc.setUse_calculation("Y");
calc.setCalculation_eql("VAL('TAG_RAW_RPM') * 60 / 1000"); // 가상의 EQL
client.tag().patchCalculation("TAG_EDGE_00303_90007", calc);
部分修正 — patchAggregation
5種類の周期集計を有効化 (deployAggregation 再呼出):
import plantpulse.api.v5.dto.request.TagAggregationPatchRequestV5;
TagAggregationPatchRequestV5 agg = new TagAggregationPatchRequestV5();
agg.setUse_aggregation("Y");
agg.setAggregation_1_minutes("Y");
agg.setAggregation_5_minutes("Y");
agg.setAggregation_10_minutes("Y");
agg.setAggregation_30_minutes("N");
agg.setAggregation_1_hours("Y");
client.tag().patchAggregation("TAG_EDGE_00303_90007", agg);
部分修正 — patchPublish
MQTT/Kafka 発行トグル:
import plantpulse.api.v5.dto.request.TagPublishPatchRequestV5;
TagPublishPatchRequestV5 pub = new TagPublishPatchRequestV5();
pub.setPublish_mqtt("Y");
pub.setPublish_kafka("N");
client.tag().patchPublish("TAG_EDGE_00303_90007", pub);
部分修正 — patchLink (設備マッピング)
import plantpulse.api.v5.dto.request.TagLinkPatchRequestV5;
// 자산에 연결
TagLinkPatchRequestV5 link = new TagLinkPatchRequestV5();
link.setLinked_asset_id("EQUIPMENT_000001");
client.tag().patchLink("TAG_EDGE_00303_90007", link);
// 매핑 해제 — 빈 문자열
TagLinkPatchRequestV5 unlink = new TagLinkPatchRequestV5();
unlink.setLinked_asset_id("");
client.tag().patchLink("TAG_EDGE_00303_90007", unlink);
削除
boolean ok = client.tag().delete("TAG_EDGE_00303_90007");
8.5 活用シナリオ
シナリオ — 新規ラインタグの自動分類後の一括設定
// 1) 자동 등록된 태그 목록 (OPC 연결 직후)
List<TagResponseV5> tags = client.tag().listByOpc("OPC_PLC_L2_001");
// 2) 이름 패턴으로 자산 자동 연결 + 알람 일괄 설정
for (TagResponseV5 t : tags) {
String name = t.getTag_name();
// 자산 매핑
TagLinkPatchRequestV5 link = new TagLinkPatchRequestV5();
if (name.contains("CNC1")) {
link.setLinked_asset_id("EQUIPMENT_CNC1");
} else if (name.contains("CNC2")) {
link.setLinked_asset_id("EQUIPMENT_CNC2");
} else {
continue;
}
client.tag().patchLink(t.getTag_id(), link);
// 온도 태그는 알람 임계치 자동 설정
if (name.endsWith("_TEMP")) {
TagAlarmPatchRequestV5 alarm = new TagAlarmPatchRequestV5();
alarm.setUse_alarm("Y");
alarm.setHi("80");
alarm.setHi_hi("95");
client.tag().patchAlarm(t.getTag_id(), alarm);
}
}
シナリオ — 集計と発行を同時に有効化
String tagId = "TAG_EDGE_00303_90007";
TagAggregationPatchRequestV5 agg = new TagAggregationPatchRequestV5();
agg.setUse_aggregation("Y");
agg.setAggregation_1_minutes("Y");
agg.setAggregation_1_hours("Y");
client.tag().patchAggregation(tagId, agg);
TagPublishPatchRequestV5 pub = new TagPublishPatchRequestV5();
pub.setPublish_mqtt("Y");
client.tag().patchPublish(tagId, pub);
次のステップ
- Alarm サービス — アラームイベント照会
- Path サービス — タグの設備パス