Files
lmxopcua/src/Core/ZB.MOM.WW.OtOpcUa.Commons/Protos/data_connection.proto
T

481 lines
15 KiB
Protocol Buffer

syntax = "proto3";
package data_connection.v1;
option csharp_namespace = "ZB.MOM.WW.OtOpcUa.Commons.Protos.DataConnection.V1";
import "google/protobuf/timestamp.proto";
service DataConnectionService {
rpc GetCapabilities(CapabilitiesRequest) returns (CapabilitiesResponse);
rpc Browse(BrowseRequest) returns (BrowseResponse);
rpc GetMetadata(MetadataRequest) returns (MetadataResponse);
rpc Read(ReadRequest) returns (ReadResponse);
rpc Write(WriteRequest) returns (WriteResponse);
rpc Subscribe(stream SubscriptionCommand) returns (stream SubscriptionFrame);
// H2: header-gated (x-otopcua-data-features: history). Without the negotiated feature ⇒ FAILED_PRECONDITION.
rpc HistoryRead(HistoryReadRequest) returns (HistoryReadResponse);
// A2b: header-gated (x-otopcua-data-features: conditions). Without the negotiated feature ⇒ FAILED_PRECONDITION.
rpc CallConditionMethod(ConditionMethodRequest) returns (ConditionMethodResponse);
}
enum ValueKind {
VALUE_KIND_UNSPECIFIED = 0;
VALUE_KIND_NULL = 1;
VALUE_KIND_BOOLEAN = 2;
VALUE_KIND_INT8 = 3;
VALUE_KIND_INT16 = 4;
VALUE_KIND_INT32 = 5;
VALUE_KIND_INT64 = 6;
VALUE_KIND_UINT8 = 7;
VALUE_KIND_UINT16 = 8;
VALUE_KIND_UINT32 = 9;
VALUE_KIND_UINT64 = 10;
VALUE_KIND_FLOAT = 11;
VALUE_KIND_DOUBLE = 12;
VALUE_KIND_STRING = 13;
VALUE_KIND_BYTES = 14;
VALUE_KIND_TIMESTAMP = 15;
VALUE_KIND_GUID = 16;
VALUE_KIND_ARRAY = 17;
}
message TypedValue {
ValueKind kind = 1;
oneof payload {
bool boolean = 2;
sint64 signed = 3;
uint64 unsigned = 4;
float float_value = 5;
double double_value = 6;
string string_value = 7;
bytes bytes_value = 8;
google.protobuf.Timestamp timestamp = 9;
string guid = 10;
TypedArray array = 11;
}
}
message TypedArray {
ValueKind element_kind = 1;
repeated uint32 dimensions = 2;
repeated TypedValue elements = 3;
}
message Address {
string origin_cluster_id = 1;
string namespace_uri = 2;
string identifier_kind = 3;
string identifier = 4;
}
message View {
Address address = 1;
int32 realm = 2;
optional string mapping_id = 3;
int64 mapping_revision = 4;
string subject = 5;
}
message Serving {
string node_id = 1;
string incarnation = 2;
string role = 3;
int64 catalog_epoch = 4;
int64 authority_epoch = 5;
int64 serving_generation = 6;
}
message Sample {
TypedValue value = 1;
uint32 status_code = 2;
google.protobuf.Timestamp source_timestamp = 3;
google.protobuf.Timestamp server_timestamp = 4;
Serving serving = 5;
int64 version = 6;
}
message Budget {
int64 timeout_ticks = 1;
int32 max_items = 2;
int64 max_bytes = 3;
}
message Limits {
int32 max_page_items = 1;
int32 max_batch_items = 2;
int32 max_message_bytes = 3;
int32 max_monitored_items = 4;
int32 max_streams = 5;
int64 max_pending_bytes = 6;
int64 max_metadata_lease_ticks = 7;
int64 max_session_lifetime_ticks = 8;
int64 write_retry_window_ticks = 9;
optional int32 max_value_elements = 10;
}
message CapabilitiesRequest {
int32 protocol_major = 1;
int32 protocol_minor = 2;
}
message CapabilitiesResponse {
int32 protocol_major = 1;
int32 protocol_minor = 2;
Serving serving = 3;
int32 readiness = 4;
uint32 operations = 5;
repeated ValueKind value_kinds = 6;
Limits limits = 7;
bool compact_batches = 8;
int32 compact_codec_version = 9;
string cluster_id = 10;
bool subscription_age_readiness = 11;
bool response_serving_identity = 12;
bool write_serving_generation_enforced = 13;
// The server accepts freshness_challenge and captures each stamped age after
// admitting the identified challenge. Absence or false leaves stream age unbounded.
bool subscription_freshness_challenges = 14;
// Good GetMetadata results may include an exact-item authority lease.
bool metadata_item_leases = 15;
// H2: only on a call that negotiated `history`, and only when this origin has a historian backend.
HistoryCapabilities history = 16;
// A2: only on a call that negotiated `conditions`, and only when this origin can serve them (a condition-key secret
// is provisioned and the condition-state hub is wired). Pinned by DataConnectionProtoContract + GrpcDataProtoReservationTests.
ConditionCapabilities conditions = 17;
}
// A2 (plan §4.2/§5.5): what the origin's condition streams offer this caller.
message ConditionCapabilities {
bool root_scope_items = 1;
// Bitmask of supported condition methods (A2b); 0 in A2a.
uint32 methods = 2;
// The most conditions one root-scoped item admits (the export's MaxConditions); 0 = undisclosed (no grant).
int32 max_conditions = 3;
}
message HistoryCapabilities {
bool raw = 1;
bool processed = 2;
bool at_time = 3;
// Stable HistoryAggregateType names the origin's backend serves.
repeated string aggregates = 4;
int64 timestamp_resolution_ticks = 5;
int32 max_values_per_page = 6;
int32 max_concurrent_reads = 7;
int64 continuation_idle_ticks = 8;
}
message HistoryInfo {
bool historizing = 1;
}
message Metadata {
View view = 1;
string browse_name = 2;
string node_kind = 3;
ValueKind value_kind = 4;
int32 value_rank = 5;
repeated int32 dimensions = 6;
bool writable = 7;
uint32 allowed_operations = 8;
int64 catalog_revision = 9;
optional string stable_source_id = 10;
optional string engineering_units = 11;
bool is_stale = 12;
optional ValueKind array_element_kind = 13;
// H2: only on a call that negotiated `history`.
HistoryInfo history = 14;
}
message Lease {
int64 catalog_epoch = 1;
int64 authority_epoch = 2;
int64 duration_ticks = 3;
}
message BrowseRequest {
View parent = 1;
optional string filter = 2;
optional string continuation = 3;
Budget budget = 4;
}
message BrowseResponse {
View parent = 1;
int32 status = 2;
repeated Metadata items = 3;
bool complete = 4;
optional string continuation = 5;
Lease lease = 6;
Serving serving = 7;
}
message MetadataRequest {
repeated View views = 1;
Budget budget = 2;
}
message MetadataResult {
string correlation_id = 1;
int32 status = 2;
Metadata value = 3;
optional string diagnostic = 4;
// Valid only for this authorized item and this response's serving identity.
Lease lease = 5;
}
message MetadataResponse { repeated MetadataResult items = 1; Serving serving = 2; }
message ReadItem {
string correlation_id = 1;
View view = 2;
optional int64 maximum_age_ticks = 3;
}
message ReadRequest {
repeated ReadItem items = 1;
Budget budget = 2;
}
message ReadResult {
string correlation_id = 1;
int32 status = 2;
int32 readiness = 3;
optional int64 age_ticks = 4;
Sample sample = 5;
optional string diagnostic = 6;
}
message ReadResponse { repeated ReadResult items = 1; Serving serving = 2; }
message WriteItem {
string correlation_id = 1;
string operation_id = 2;
View view = 3;
TypedValue value = 4;
int64 expected_catalog_revision = 5;
string expected_serving_incarnation = 6;
int64 remaining_budget_ticks = 7;
optional int64 expected_serving_generation = 8;
}
message WriteRequest {
repeated WriteItem items = 1;
Budget budget = 2;
}
message WriteResult {
string correlation_id = 1;
int32 state = 2;
uint32 status_code = 3;
optional string diagnostic = 4;
}
message WriteResponse { repeated WriteResult items = 1; Serving serving = 2; }
message Handle {
string subscription_id = 1;
int64 stream_epoch = 2;
uint64 handle = 3;
int64 item_revision = 4;
}
message Settings {
int64 sampling_ticks = 1;
int64 publishing_ticks = 2;
int32 trigger = 3;
optional double deadband = 4;
}
message SubscriptionItem {
string client_item_id = 1;
View view = 2;
Settings settings = 3;
// A2 (header-gated): one root-scoped item = "all conditions under this export root"; view = the mapping's remote root.
ConditionScope condition_scope = 4;
}
message ConditionScope { bool include_info = 1; }
message ConditionInfo {
string condition_type = 1; // namespace-URI qualified
string condition_name = 2;
int32 source_kind = 3; // 1 = NATIVE, 2 = SCRIPTED
repeated View placements = 4; // realm-local placement addresses inside THIS export (§5.2), never cross-realm
uint32 supported_methods = 5;
}
message ActivationMarker { string incarnation = 1; uint64 sequence = 2; }
message ConditionState {
string condition_key = 1; // opaque keyed hash (§5.2)
int64 version = 2;
bool removed = 3;
bool state_known = 4;
ConditionInfo info = 5; // first appearance in an epoch and in every snapshot record
bool active = 6;
bool acknowledged = 7;
bool confirmed = 8;
bool enabled = 9;
int32 shelving = 10;
uint32 severity = 11;
string message = 12;
uint32 quality = 13;
google.protobuf.Timestamp unshelve_at = 14;
int32 condition_class = 15;
google.protobuf.Timestamp time = 16;
bool retain = 17;
ActivationMarker activation = 18;
optional string comment = 19;
optional string client_user_id = 20;
}
message ConditionStates {
Handle handle = 1; // the root-scoped item's handle
bool is_snapshot = 2;
optional int32 total = 3; // on the snapshot-begin chunk, before any record (admission before materialising)
repeated ConditionState items = 4;
bool snapshot_complete = 5;
}
message SubscriptionCommand {
string subscription_id = 1;
int64 stream_epoch = 2;
string command_id = 3;
int64 acknowledgement_timeout_ticks = 4;
oneof command {
Open open = 5;
ItemChanges add = 6;
ItemChanges modify = 7;
HandleChanges remove = 8;
// Subscribe-authorized bounded current snapshot of these active item revisions.
// command_id is a per-stream strictly increasing freshness sequence.
HandleChanges freshness_challenge = 9;
}
}
message Open {
repeated SubscriptionItem items = 1;
bool watch_catalog_only = 2;
int64 session_lifetime_ticks = 3;
Budget snapshot_budget = 4;
}
message ItemChanges { repeated SubscriptionItem items = 1; }
message HandleChanges { repeated Handle items = 1; }
message ItemAck {
string client_item_id = 1;
int32 status = 2;
Handle handle = 3;
Settings revised_settings = 4;
optional string diagnostic = 5;
}
message Ack {
string command_id = 1;
repeated ItemAck items = 2;
}
message Watermark {
int32 partition_id = 1;
int64 version = 2;
}
message Control {
int32 kind = 1;
repeated Watermark watermarks = 2;
int64 catalog_epoch = 3;
int64 authority_epoch = 4;
optional string diagnostic = 5;
}
message ValueUpdate {
Handle handle = 1;
Sample sample = 2;
// Age since normalized origin-cache ingress, not sensor measurement age.
optional int64 origin_age_ticks = 3;
optional int32 readiness = 4;
// The admitted challenge observed before origin_age_ticks was computed.
// The value and this identifier must remain coupled through queued encoding.
optional string freshness_challenge_id = 5;
}
message Values {
bool is_snapshot = 1;
repeated ValueUpdate items = 2;
}
// Override messages distinguish absent timestamp from an inherited default.
message TimestampOverride { google.protobuf.Timestamp value = 1; }
message CompactUpdate {
uint64 handle = 1;
int64 item_revision = 2;
int64 version = 3;
TypedValue value = 4;
optional uint32 status_code = 5;
TimestampOverride source_timestamp = 6;
TimestampOverride server_timestamp = 7;
// Age since normalized origin-cache ingress, not sensor measurement age.
optional int64 origin_age_ticks = 8;
optional int32 readiness = 9;
// Same causal witness semantics as ValueUpdate.freshness_challenge_id.
optional string freshness_challenge_id = 10;
}
message CompactValues {
bool is_snapshot = 1;
Serving serving = 2;
uint32 default_status_code = 3;
google.protobuf.Timestamp default_source_timestamp = 4;
google.protobuf.Timestamp default_server_timestamp = 5;
repeated CompactUpdate items = 6;
}
message SubscriptionFrame {
string subscription_id = 1;
int64 stream_epoch = 2;
int64 sequence = 3;
Serving serving = 8;
oneof frame {
Ack ack = 4;
Control control = 5;
Values values = 6;
CompactValues compact_values = 7;
// A2: only ever sent on a call that negotiated `conditions` through x-otopcua-data-features (v1 clients fault on
// an unknown frame arm), and only for a root-scoped condition item that call opened.
ConditionStates condition_states = 9;
}
}
// H2 remote history (plan §4.2). An unset start/end is ABSENT, never MinValue: the origin's end-only rules depend on it.
message HistoryReadItem {
string correlation_id = 1;
View view = 2;
// A page continuation or a transport chunk token from a previous response; absent = a fresh read.
optional bytes continuation = 3;
}
message HistoryReadRequest {
repeated HistoryReadItem items = 1;
Budget budget = 2;
oneof details {
RawDetails raw = 3;
ProcessedDetails processed = 4;
AtTimeDetails at_time = 5;
}
// The only release mechanism (m2): drop the items' continuations without reading.
bool release_continuations = 6;
}
message RawDetails {
optional google.protobuf.Timestamp start = 1;
optional google.protobuf.Timestamp end = 2;
uint32 num_values_per_node = 3;
bool return_bounds = 4;
}
message AggregateConfiguration {
bool use_server_capabilities_defaults = 1;
bool treat_uncertain_as_bad = 2;
uint32 percent_data_bad = 3;
uint32 percent_data_good = 4;
bool use_sloped_extrapolation = 5;
}
message ProcessedDetails {
optional google.protobuf.Timestamp start = 1;
optional google.protobuf.Timestamp end = 2;
int64 interval_ticks = 3;
// Parallel to items: stable HistoryAggregateType names.
repeated string aggregate = 4;
// Client values verbatim; absent = server defaults. The origin's IsServable decides (m8).
AggregateConfiguration configuration = 5;
}
message AtTimeDetails {
repeated google.protobuf.Timestamp times = 1;
bool use_simple_bounds = 2;
}
message HistorySample {
TypedValue value = 1;
// The full OPC UA status, info bits included.
uint32 status_code = 2;
TimestampOverride source_timestamp = 3;
TimestampOverride server_timestamp = 4;
}
message HistoryReadResult {
string correlation_id = 1;
uint32 status_code = 2;
repeated HistorySample samples = 3;
optional bytes continuation = 4;
optional string diagnostic = 5;
// This is one bounded chunk; resume with `continuation` under the same details for the rest.
bool chunk_continues = 6;
}
message HistoryReadResponse {
repeated HistoryReadResult items = 1;
Serving serving = 2;
}
// A2b remote condition methods (plan §4.2, §5.6). method: 1 Acknowledge, 2 AddComment, 4 Confirm (exactly one).
message ConditionMethodRequest {
string operation_id = 1;
View placement = 2;
int32 method = 3;
ActivationMarker expected_activation = 4;
optional string comment = 5;
string expected_serving_incarnation = 6;
int64 remaining_budget_ticks = 7;
// Untrusted audit text; capped, sanitised, written only to the origin's audit log (§6).
optional string on_behalf_of = 8;
}
message ConditionMethodResponse {
// DataWriteState: 1 RejectedBeforeDispatch, 2 applied (scripted), 4 applied + routed (native), 5 outcome unknown.
int32 state = 1;
uint32 status_code = 2;
optional string diagnostic = 3;
Serving serving = 4;
}