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 = Property.CreateProperty(_builder, Properties.DataChangeFilter, dataChangeFilter.Value);
148 _rules.Add(dataChangeFilterProperty);
161 bool browselistChange =
false,
bool metadataChange =
false,
bool connectionChange =
false)
163 var changeEvents = ChangeEvents.CreateChangeEvents(_builder, dataChangeTrigger, browselistChange, metadataChange, connectionChange);
164 var changeEventsProperty = Property.CreateProperty(_builder, Properties.ChangeEvents, changeEvents.Value);
165 _rules.Add(changeEventsProperty);
177 var queuing = Queueing.CreateQueueing(_builder, queueSize, queueBehaviour);
178 var queuingProperty = Property.CreateProperty(_builder, Properties.Queueing, queuing.Value);
179 _rules.Add(queuingProperty);
190 var counting = Counting.CreateCounting(_builder, countSubscriptions);
191 var countingProperty = Property.CreateProperty(_builder, Properties.Counting, counting.Value);
192 _rules.Add(countingProperty);
202 var rulesOffset = _rules.Count == 0
203 ?
new VectorOffset(0)
204 : SubscriptionProperties.CreateRulesVector(_builder, _rules.ToArray());
205 var propertiesOffset = SubscriptionProperties.CreateSubscriptionProperties(_builder,
207 _keepAliveIntervalMillis,
208 _publishIntervalMillis,
210 _errorIntervalMillis);
212 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 SetChangeEvents(DataChangeTrigger dataChangeTrigger, bool browselistChange=false, bool metadataChange=false, bool connectionChange=false)
Sets the change events.
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 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.