Skip to main content

6. OPC Service

Access via client.opc(). OPC represents a Source Connection. It is the entry point for external data, such as OPC UA servers, PLCs, Modbus devices, databases, message brokers, and REST APIs.

ID Rules: OPC_ prefix is required. For more details, refer to Domain ID Rules.

6.1 Method List​

MethodReturn TypeHTTPEndpoint
create(OPCRequestV5)OPCResponseV5 or nullPOST/api/v5/opc
update(opc_id, OPCRequestV5)OPCResponseV5 or nullPUT/api/v5/opc/{id}
delete(opc_id)booleanDELETE/api/v5/opc/{id}
get(opc_id)OPCResponseV5 or nullGET/api/v5/opc/{id}
list()List<OPCResponseV5>GET/api/v5/opc
listBySite(site_id)List<OPCResponseV5>GET/api/v5/opc?site_id=...
listByType(opc_source_type)List<OPCResponseV5>GET/api/v5/opc?opc_source_type=...
exists(opc_id)booleanGET/api/v5/opc/{id}/exists
count()longGET/api/v5/opc/count
countBySite(site_id)longGET/api/v5/opc/count?site_id=...

6.2 Protocols and Source Types​

A connection has a protocol (opc_protocol, e.g., S7·LS·MELSEC·MODBUS·OPCUA·MQTT_CLIENT·API). Source types and collection entities are derived from the protocol and are not written directly. The authoritative source for protocol vocabulary is the protocol catalog in plantpulse-event.

Source TypeUse Case
OPCOPC UA server
PLCDirect PLC connection (Siemens, LS, Mitsubishi, Allen-Bradley, etc.)
MODBUSModbus TCP/UDP/RTU device
DATABASEExternal database polling
MESSAGINGMessage broker/Push protocol (MQTT, Kafka, HTTP, WebSocket, CoAP, ROS 2)
APIData entering via PlantPulse REST API
SYSTEMEdge gateway self-monitoring (OPC_SYSTEM_<edge_id>, declared by Edge)

6.3 OPCRequestV5 / OPCResponseV5​

FieldTypeDescription
opc_idStringOPC ID (PK, OPC_ required)
opc_nameStringOPC display name
opc_protocolStringProtocol code (e.g., S7, LS, OPCUA, API)
opc_source_ipStringIP or host of the actual source (PLC, device, OPC UA server, DB, broker)
opc_source_portintPort of the actual source
opc_edge_idStringEdge performing the collection for this connection. Leave empty if collected directly by Platform
opc_source_typeString(Response only) Source type derived from protocol
opc_collected_byString(Response only) EDGE / PLATFORM — derived from protocol
site_idStringAssociated site
descriptionStringDescription

Protocols and addresses for connections collected by an Edge (connections with opc_edge_id) are only modified via Edge sync (PUT /api/v5/opc/{id}/sync). They are read-only on the Platform screen.

6.4 Usage Examples​

Create OPC (Direct PLC)​

import plantpulse.api.v5.dto.request.OPCRequestV5;
import plantpulse.api.v5.dto.response.OPCResponseV5;

OPCRequestV5 req = new OPCRequestV5();
req.setOpc_id("OPC_PLC_L1_001");
req.setOpc_name("Line1 메인 PLC");
req.setOpc_protocol("S7");
req.setSite_id("SITE_DJ");
req.setOpc_source_ip("192.168.10.50");
req.setOpc_source_port(102);

OPCResponseV5 created = client.opc().create(req);

Create OPC (External REST API)​

OPCRequestV5 api = new OPCRequestV5();
api.setOpc_id("OPC_API_ERP_001"); // OPC_ 접두사 필수
api.setOpc_name("ERP 생산 실적 API");
api.setOpc_protocol("API");
api.setSite_id("SITE_DJ");
api.setDescription("매시간 ERP에서 생산 카운트 폴링");
client.opc().create(api);

Create OPC (For Testing — API Source)​

OPCRequestV5 v = new OPCRequestV5();
v.setOpc_id("OPC_TEST_001");
v.setOpc_name("테스트용 OPC");
v.setOpc_protocol("API");
v.setSite_id("SITE_000001");
client.opc().create(v);

Query OPC by Site​

import java.util.List;

List<OPCResponseV5> djOpcs = client.opc().listBySite("SITE_DJ");
for (OPCResponseV5 opc : djOpcs) {
System.out.println(opc.getOpc_id() + " (" + opc.getOpc_protocol() + ", " + opc.getOpc_source_type() + ")");
}

Query OPC by Source Type​

// 사이트를 가리지 않고 PLC 만
List<OPCResponseV5> plcs = client.opc().listByType("PLC");

// 사이트를 가리지 않고 Modbus 만
List<OPCResponseV5> modbus = client.opc().listByType("MODBUS");

Count​

long total = client.opc().count();
long djCount = client.opc().countBySite("SITE_DJ");
System.out.printf("전체 OPC: %d, 대전공장: %d%n", total, djCount);

CUD Lifecycle​

String opcId = "OPC_PLC_L1_001";

// 생성
OPCRequestV5 req = new OPCRequestV5();
req.setOpc_id(opcId);
req.setOpc_name("초기 이름");
req.setOpc_protocol("S7");
req.setSite_id("SITE_DJ");
client.opc().create(req);

// 존재 여부 확인
assert client.opc().exists(opcId);

// 수정
req.setOpc_name("수정된 이름");
client.opc().update(opcId, req);

// 삭제
boolean deleted = client.opc().delete(opcId);
assert !client.opc().exists(opcId);

6.5 Application Scenario​

Scenario — Waiting for tag collection after registering new line PLC​

// 1) OPC 등록
OPCRequestV5 plc = new OPCRequestV5();
plc.setOpc_id("OPC_PLC_L2_001");
plc.setOpc_protocol("S7");
plc.setSite_id("SITE_DJ");
plc.setOpc_source_ip("192.168.10.60");
plc.setOpc_source_port(102);
client.opc().create(plc);

// 2) 수집이 시작되면 — 이후 Tag 서비스에서 확인
List<TagResponseV5> tags = client.tag().listByOpc("OPC_PLC_L2_001");
System.out.println("수집된 태그 수: " + tags.size());

Next Steps​