2using Google.FlatBuffers;
3using System.Collections.Generic;
15 private readonly FlatBufferBuilder _builder;
20 private readonly List<Offset<Property>> _rules;
28 private uint _errorIntervalMillis = Subscription.DefaultErrorIntervalMillis;
36 private StringOffset _idOffset;
42 private uint _keepAliveIntervalMillis = Subscription.DefaultKeepaliveIntervalMillis;
51 private uint _publishIntervalMillis = Subscription.DefaultPublishIntervalMillis;
63 _rules =
new List<Offset<Property>>();
74 private void SetId(
string id)
76 _idOffset = _builder.CreateString(
id);
86 _keepAliveIntervalMillis = keepAliveIntervalMillis;
97 _publishIntervalMillis = publishIntervalMillis;
108 _errorIntervalMillis = errorIntervalMillis;
119 var samplingIntervalMicros = samplingIntervalMillis * 1000;
120 var sampling = Sampling.CreateSampling(_builder, samplingIntervalMicros);
121 var samplingProperty = Property.CreateProperty(_builder, Properties.Sampling, sampling.Value);
122 _rules.Add(samplingProperty);
133 var sampling = Sampling.CreateSampling(_builder, samplingIntervalMicros);
134 var samplingProperty = Property.CreateProperty(_builder, Properties.Sampling, sampling.Value);
135 _rules.Add(samplingProperty);
146 var dataChangeFilter = DataChangeFilter.CreateDataChangeFilter(_builder, deadbandValue);
147 var dataChangeFilterProperty =
148 Property.CreateProperty(_builder, Properties.DataChangeFilter, dataChangeFilter.Value);
149 _rules.Add(dataChangeFilterProperty);
161 bool browselistChange =
false,
bool metadataChange =
false)
164 ChangeEvents.CreateChangeEvents(_builder, dataChangeTrigger, browselistChange, metadataChange);
165 var changeEventsProperty = Property.CreateProperty(_builder, Properties.ChangeEvents, changeEvents.Value);
166 _rules.Add(changeEventsProperty);
178 var queuing = Queueing.CreateQueueing(_builder, queueSize, queueBehaviour);
179 var queuingProperty = Property.CreateProperty(_builder, Properties.Queueing, queuing.Value);
180 _rules.Add(queuingProperty);
191 var counting = Counting.CreateCounting(_builder, countSubscriptions);
192 var countingProperty = Property.CreateProperty(_builder, Properties.Counting, counting.Value);
193 _rules.Add(countingProperty);
203 var rulesOffset = _rules.Count == 0
204 ?
new VectorOffset(0)
205 : SubscriptionProperties.CreateRulesVector(_builder, _rules.ToArray());
206 var propertiesOffset = SubscriptionProperties.CreateSubscriptionProperties(_builder,
208 _keepAliveIntervalMillis,
209 _publishIntervalMillis,
211 _errorIntervalMillis);
213 SubscriptionProperties.FinishSubscriptionPropertiesBuffer(_builder, propertiesOffset);
Provides a convenient way to build a SubscriptionProperties flatbuffers.
SubscriptionPropertiesBuilder SetSamplingIntervalMicros(ulong samplingIntervalMicros)
Sets the sampling interval in microseconds.
SubscriptionPropertiesBuilder SetQueueing(uint queueSize, QueueBehaviour queueBehaviour)
Sets the queueing.
SubscriptionPropertiesBuilder SetSamplingIntervalMillis(ulong samplingIntervalMillis)
Sets the sampling interval in milliseconds.
SubscriptionPropertiesBuilder SetPublishIntervalMillis(uint publishIntervalMillis)
Sets the publish interval in milliseconds.
SubscriptionPropertiesBuilder SetErrorIntervalMillis(uint errorIntervalMillis)
Sets the error interval in milliseconds.
SubscriptionPropertiesBuilder SetChangeEvents(DataChangeTrigger dataChangeTrigger, bool browselistChange=false, bool metadataChange=false)
Sets the change events.
SubscriptionPropertiesBuilder SetCounting(bool countSubscriptions)
Sets the counting.
SubscriptionPropertiesBuilder(string id)
Initializes a new instance of the SubscriptionPropertiesBuilder class.
Variant Build()
Builds this the SubscriptionProperties as flatbuffers object.
SubscriptionPropertiesBuilder SetDataChangeFilter(float deadbandValue)
Sets the data change filter.
SubscriptionPropertiesBuilder SetKeepAliveIntervalMillis(uint keepAliveIntervalMillis)
Sets the keep alive interval in milliseconds.
Provides the implementation for IVariant.
static readonly int DefaultFlatbuffersInitialSize
Gets the default Flatbuffers initial size in bytes.
The ISubscription interface.
static readonly uint DefaultKeepaliveIntervalMillis
The default keep alive interval in milli seconds.
static readonly uint DefaultErrorIntervalMillis
The default error interval in milli seconds.
static readonly uint DefaultPublishIntervalMillis
The default publish interval in milli seconds.