feat(grpc-data): X0 reserve DataOperations bits 32-512, DataOperationSets authority, DataFeatures; capabilities mask unknown bits
This commit is contained in:
@@ -226,7 +226,46 @@ public sealed record DataBudget(TimeSpan Timeout, int MaxItems, long MaxBytes)
|
||||
{
|
||||
public void Validate() { if (Timeout <= TimeSpan.Zero || MaxItems <= 0 || MaxBytes <= 0) throw new ArgumentOutOfRangeException(nameof(Timeout)); }
|
||||
}
|
||||
[Flags] public enum DataOperations { None = 0, Browse = 1, Metadata = 2, Read = 4, Write = 8, Subscribe = 16 }
|
||||
/// <summary>
|
||||
/// Data operation grants. The values are persisted (ConfigDb int) and carried on the wire (uint); never renumber.
|
||||
/// Bits 32..512 are RESERVED by phase X0 of the history/alarm plan: no node implements them yet, so every reader
|
||||
/// masks them to <see cref="DataOperationSets.Understood"/> (an unknown grant is no grant) and the authoring
|
||||
/// validator keeps rejecting them until the phase that implements each one (H2, A2).
|
||||
/// </summary>
|
||||
[Flags] public enum DataOperations
|
||||
{
|
||||
None = 0, Browse = 1, Metadata = 2, Read = 4, Write = 8, Subscribe = 16,
|
||||
/// <summary>Reserved (H2): Raw/Processed/AtTime history reads.</summary>
|
||||
HistoryRead = 32,
|
||||
/// <summary>Reserved (A2): root-scoped condition items (origin-side grant).</summary>
|
||||
AlarmSubscribe = 64,
|
||||
/// <summary>Reserved (A2): Acknowledge and AddComment.</summary>
|
||||
AlarmAcknowledge = 128,
|
||||
/// <summary>Reserved (A2): Confirm.</summary>
|
||||
AlarmConfirm = 256,
|
||||
/// <summary>Reserved for the deferred shelve methods.</summary>
|
||||
AlarmShelve = 512,
|
||||
}
|
||||
/// <summary>The one authority for which <see cref="DataOperations"/> bits this build understands.</summary>
|
||||
public static class DataOperationSets
|
||||
{
|
||||
/// <summary>The v1 operation set.</summary>
|
||||
public const DataOperations V1 = DataOperations.Browse | DataOperations.Metadata | DataOperations.Read |
|
||||
DataOperations.Write | DataOperations.Subscribe;
|
||||
/// <summary>
|
||||
/// What tolerant readers keep; every other bit is dropped fail-closed. Grows only in the phase that implements
|
||||
/// a bit (H2 adds <see cref="DataOperations.HistoryRead"/>; A2 the alarm bits).
|
||||
/// </summary>
|
||||
public const DataOperations Understood = V1;
|
||||
/// <summary>Bits reserved by X0 for later phases.</summary>
|
||||
public const DataOperations Reserved = DataOperations.HistoryRead | DataOperations.AlarmSubscribe |
|
||||
DataOperations.AlarmAcknowledge | DataOperations.AlarmConfirm | DataOperations.AlarmShelve;
|
||||
}
|
||||
/// <summary>
|
||||
/// Optional per-call protocol features negotiated through the <c>x-otopcua-data-features</c> request header.
|
||||
/// A call without the header (or with an empty effective set) gets exactly the v1 behaviour.
|
||||
/// </summary>
|
||||
[Flags] public enum DataFeatures { None = 0, History = 1, Conditions = 2 }
|
||||
/// <summary>
|
||||
/// Negotiated limits. When a peer omits the per-value element limit, the protocol default is 100,000.
|
||||
/// </summary>
|
||||
@@ -250,6 +289,10 @@ public sealed record DataCapabilities(int ProtocolMajor, int ProtocolMinor, Serv
|
||||
bool WriteServingGenerationEnforced = false, bool SubscriptionFreshnessChallenges = false,
|
||||
bool MetadataItemLeases = false)
|
||||
{
|
||||
private readonly DataOperations _operations = Operations & DataOperationSets.Understood;
|
||||
/// <summary>Masked to <see cref="DataOperationSets.Understood"/> on construction and on every <c>with</c>.</summary>
|
||||
public DataOperations Operations { get => _operations; init => _operations = value & DataOperationSets.Understood; }
|
||||
|
||||
public void Validate()
|
||||
{
|
||||
ArgumentException.ThrowIfNullOrWhiteSpace(ClusterId);
|
||||
@@ -268,12 +311,7 @@ public sealed record DataCapabilities(int ProtocolMajor, int ProtocolMinor, Serv
|
||||
{
|
||||
DataContractValidation.Required(kind);
|
||||
}
|
||||
const DataOperations known = DataOperations.Browse | DataOperations.Metadata | DataOperations.Read |
|
||||
DataOperations.Write | DataOperations.Subscribe;
|
||||
if ((Operations & ~known) != 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(Operations));
|
||||
}
|
||||
// Operations is masked by its accessor, so unknown bits from a newer peer never reach here (X0).
|
||||
}
|
||||
}
|
||||
public sealed record DataMetadata(DataView View, string BrowseName, string NodeKind, DataValueKind ValueKind, int ValueRank,
|
||||
|
||||
Reference in New Issue
Block a user