/// <summary>
            /// Create subscription from template
            /// </summary>
            /// <param name="outer"></param>
            /// <param name="dataSetWriter"></param>
            public DataSetWriterSubscription(WriterGroupMessageTrigger outer,
                                             DataSetWriterModel dataSetWriter)
            {
                _outer         = outer ?? throw new ArgumentNullException(nameof(outer));
                _dataSetWriter = dataSetWriter.Clone() ??
                                 throw new ArgumentNullException(nameof(dataSetWriter));
                _subscriptionInfo = _dataSetWriter.ToSubscriptionModel();

                if (dataSetWriter.KeyFrameInterval.HasValue &&
                    dataSetWriter.KeyFrameInterval.Value > TimeSpan.Zero)
                {
                    _keyframeTimer = new Timer(
                        dataSetWriter.KeyFrameInterval.Value.TotalMilliseconds);
                    _keyframeTimer.Elapsed += KeyframeTimerElapsedAsync;
                }
                else
                {
                    _keyFrameCount = dataSetWriter.KeyFrameCount;
                }

                if (dataSetWriter.DataSetMetaDataSendInterval.HasValue &&
                    dataSetWriter.DataSetMetaDataSendInterval.Value > TimeSpan.Zero)
                {
                    _metaData = dataSetWriter.DataSet?.DataSetMetaData ??
                                throw new ArgumentNullException(nameof(dataSetWriter.DataSet));

                    _metadataTimer = new Timer(
                        dataSetWriter.DataSetMetaDataSendInterval.Value.TotalMilliseconds);
                    _metadataTimer.Elapsed += MetadataTimerElapsed;
                }
            }
Ejemplo n.º 2
0
 /// <summary>
 /// Create subscription from a DataSetWriterModel template
 /// </summary>
 public DataSetWriterSubscription(WriterGroupMessageTrigger outer,
                                  DataSetWriterModel dataSetWriter, IWriterGroupConfig writerGroup)
 {
     _outer         = outer ?? throw new ArgumentNullException(nameof(outer));
     _dataSetWriter = dataSetWriter?.Clone() ??
                      throw new ArgumentNullException(nameof(dataSetWriter));
     _subscriptionInfo = _dataSetWriter.ToSubscriptionModel(writerGroup);
     InitializeKeyframeTrigger(dataSetWriter);
     InitializeMetaDataTrigger(dataSetWriter);
 }