Exemple #1
0
        /// <inheritdoc/>
        public Task OnSubscriberSampleAsync(SubscriberSampleModel sample)
        {
            var cdmModel = new SubscriberCdmSampleModel()
            {
                SubscriptionId  = sample.SubscriptionId,
                EndpointId      = sample.EndpointId,
                DataSetId       = sample.DataSetId,
                NodeId          = sample.NodeId,
                Value           = sample.Value.ToString(),
                Timestamp       = sample.Timestamp,
                ServerTimestamp = sample.ServerTimestamp,
                SourceTimestamp = sample.SourceTimestamp
            };

            return(_client.ProcessAsync(cdmModel));
        }
Exemple #2
0
        private async Task ProcessCdmSampleAsync(SubscriberCdmSampleModel payload)
        {
            try {
                await _lock.WaitAsync();

                _cacheList.Add(payload);
                if (!_cacheUploadTriggered && _cacheList.Count >= _cacheListSize)
                {
                    Try.Op(() => _cacheUploadTimer.Change(TimeSpan.Zero, Timeout.InfiniteTimeSpan));
                    _cacheUploadTriggered = true;
                }
            }
            finally {
                _lock.Release();
            }
        }
        /// <inheritdoc/>
        public Task HandleSampleAsync(MonitoredItemSampleModel sample)
        {
            var cdmModel = new SubscriberCdmSampleModel()
            {
                SubscriptionId = sample.SubscriptionId,
                EndpointId     = sample.EndpointId,
                DataSetId      = sample.DataSetId,
                NodeId         = sample.NodeId,
                Value          = sample.Value.ToString(),
                // Set timestamp as source timestamp - todo make configurable
                Timestamp       = sample.SourceTimestamp,
                ServerTimestamp = sample.ServerTimestamp,
                SourceTimestamp = sample.SourceTimestamp
            };

            return(_client.ProcessAsync(cdmModel));
        }
Exemple #4
0
 /// <summary>
 /// Processes the payload message from the IoTHub for storage
 /// </summary>
 /// <param name="payload"></param>
 /// <param name="properties"></param>
 /// <param name="partitionKey"></param>
 /// <returns></returns>
 public async Task ProcessAsync(SubscriberCdmSampleModel payload,
                                IDictionary <string, string> properties = null,
                                string partitionKey = null)
 {
     await ProcessCdmSampleAsync(payload);
 }