Beispiel #1
0
        private DataSource AddDataSource(DataSourceTemplate template)
        {
            DataSource newDataSource = CreateDataSourceFromTemplate(template);

            newDataSource.AddArchives(this.archiveTemplates);
            this.dataSources.Add(newDataSource);
            return(newDataSource);
        }
Beispiel #2
0
 /// <summary>
 /// Initialises a data source
 /// </summary>
 /// <param name="database">Database to exist within</param>
 /// <param name="template">Data source template</param>
 internal DataSource(TimeSeriesDatabase database, DataSourceTemplate template)
 {
     this.database           = database;
     this.Name               = template.Name;
     this.ConversionFunction = template.ConversionFunction;
     this.CreateConversionFunction();
     this.PollingInterval = template.PollingInterval;
     this.range           = new Range(template.MinThreshold, template.MaxThreshold);
     this.archives        = new Archive.ArchiveCollection(this);
     this.stats           = new DataSourceStats(this);
 }
        /// <summary>
        /// Add a new data source template
        /// </summary>
        /// <param name="newDataSourceTemplate">New data source template</param>
        public void AddDataSource(DataSourceTemplate newDataSourceTemplate)
        {
            // Validate the data source template info
            if (newDataSourceTemplate.Name.Length == 0 || newDataSourceTemplate.Name.Length > DataSource.MaxNameLength)
            {
                throw new ArgumentException(string.Format("Invalid data source name: {0}", newDataSourceTemplate.Name));
            }
            else if (newDataSourceTemplate.MinThreshold >= newDataSourceTemplate.MaxThreshold)
            {
                throw new ArgumentException(
                          string.Format("Max threshold {1} is lower than the lower threshold {0}", newDataSourceTemplate.MinThreshold, newDataSourceTemplate.MaxThreshold));
            }
            else if (newDataSourceTemplate.PollingInterval.TotalSeconds < 1)
            {
                throw new ArgumentException(string.Format("Invalid interval: {0}", newDataSourceTemplate.PollingInterval));
            }
            else if (dataSources.ContainsKey(newDataSourceTemplate.Name.ToLower()))
            {
                throw new ArgumentException(string.Format("Duplicate data source: {0}", newDataSourceTemplate.Name));
            }

            // Template info is ok, add it and index by its name
            this.dataSources[newDataSourceTemplate.Name.ToLower()] = newDataSourceTemplate;
        }
Beispiel #4
0
 private DataSource CreateDataSourceFromTemplate(DataSourceTemplate template)
 {
     return(new DataSource(this, template));
 }