/// <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); }
/// <summary> /// Create trigger from writer group /// </summary> /// <param name="writerGroupConfig"></param> /// <param name="subscriptionManager"></param> /// <param name="logger"></param> public WriterGroupMessageTrigger(IWriterGroupConfig writerGroupConfig, ISubscriptionManager subscriptionManager, ILogger logger) { _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _subscriptionManager = subscriptionManager ?? throw new ArgumentNullException(nameof(subscriptionManager)); _writerGroup = writerGroupConfig?.WriterGroup?.Clone() ?? throw new ArgumentNullException(nameof(writerGroupConfig.WriterGroup)); _subscriptions = _writerGroup.DataSetWriters? .Select(g => new DataSetWriterSubscription(this, g)) .ToList(); _publisherId = writerGroupConfig.PublisherId ?? Guid.NewGuid().ToString(); }
/// <summary> /// Create subscription info model from message trigger configuration. /// </summary> public static SubscriptionModel ToSubscriptionModel( this DataSetWriterModel dataSetWriter, IWriterGroupConfig groupConfig) { if (dataSetWriter == null) { return(null); } if (dataSetWriter.DataSetWriterId == null) { throw new ArgumentNullException(nameof(dataSetWriter.DataSetWriterId)); } if (dataSetWriter.DataSet == null) { throw new ArgumentNullException(nameof(dataSetWriter.DataSet)); } if (dataSetWriter.DataSet.DataSetSource == null) { throw new ArgumentNullException(nameof(dataSetWriter.DataSet.DataSetSource)); } if (dataSetWriter.DataSet.DataSetSource.Connection == null) { throw new ArgumentNullException( nameof(dataSetWriter.DataSet.DataSetSource.Connection)); } var monitoredItems = dataSetWriter.DataSet.DataSetSource.ToMonitoredItems(); if (monitoredItems.Count == 0) { throw new ArgumentException(nameof(dataSetWriter.DataSet.DataSetSource)); } var model = new SubscriptionModel { Connection = dataSetWriter.DataSet.DataSetSource.Connection.Clone(), Id = dataSetWriter.DataSetWriterId, MonitoredItems = monitoredItems, ExtensionFields = dataSetWriter.DataSet.ExtensionFields, Configuration = dataSetWriter.DataSet.DataSetSource .ToSubscriptionConfigurationModel() }; model.Connection.Group ??= groupConfig?.WriterGroup?.WriterGroupId; return(model); }