Ejemplo n.º 1
0
        // Static Methods

        /// <summary>
        /// Creates a new channel definition belonging to the given data source record.
        /// </summary>
        /// <param name="dataSourceRecord">The data source record that the new channel definition belongs to.</param>
        /// <returns>The new channel definition.</returns>
        public static ChannelDefinition CreateChannelDefinition(DataSourceRecord dataSourceRecord)
        {
            ChannelDefinition channelDefinition = dataSourceRecord.AddNewChannelDefinition();

            channelDefinition.Phase            = Phase.None;
            channelDefinition.QuantityMeasured = QuantityMeasured.None;

            CollectionElement physicalStructure = channelDefinition.PhysicalStructure;

            physicalStructure.AddElement(new CollectionElement {
                TagOfElement = SeriesDefinitionsTag
            });

            return(channelDefinition);
        }
Ejemplo n.º 2
0
        // Static Methods

        /// <summary>
        /// Creates a new data source record from scratch.
        /// </summary>
        /// <param name="dataSourceName">The name of the data source to be created.</param>
        /// <returns>The new data source record.</returns>
        public static DataSourceRecord CreateDataSourceRecord(string dataSourceName)
        {
            Guid             recordTypeTag    = Record.GetTypeAsTag(RecordType.DataSource);
            Record           physicalRecord   = new Record(recordTypeTag);
            DataSourceRecord dataSourceRecord = new DataSourceRecord(physicalRecord);

            DateTime now = DateTime.UtcNow;

            dataSourceRecord.DataSourceTypeID = DataSourceType.Simulate;
            dataSourceRecord.DataSourceName   = dataSourceName;
            dataSourceRecord.Effective        = now;

            CollectionElement bodyElement = physicalRecord.Body.Collection;

            bodyElement.AddElement(new CollectionElement {
                TagOfElement = ChannelDefinitionsTag
            });

            return(dataSourceRecord);
        }
Ejemplo n.º 3
0
        // Static Methods

        /// <summary>
        /// Creates a new observation record from scratch with the given data source and settings.
        /// </summary>
        /// <param name="dataSource">The data source record that defines the channels in this observation record.</param>
        /// <param name="settings">The monitor settings to be applied to this observation record.</param>
        /// <returns>The new observation record.</returns>
        public static ObservationRecord CreateObservationRecord(DataSourceRecord dataSource, MonitorSettingsRecord?settings)
        {
            Guid              recordTypeTag     = Record.GetTypeAsTag(RecordType.Observation);
            Record            physicalRecord    = new Record(recordTypeTag);
            ObservationRecord observationRecord = new ObservationRecord(physicalRecord, dataSource, settings);

            DateTime now = DateTime.UtcNow;

            observationRecord.Name          = now.ToString();
            observationRecord.CreateTime    = now;
            observationRecord.StartTime     = now;
            observationRecord.TriggerMethod = TriggerMethod.None;

            CollectionElement bodyElement = physicalRecord.Body.Collection;

            bodyElement.AddElement(new CollectionElement {
                TagOfElement = ChannelInstancesTag
            });

            return(observationRecord);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Creates a new instance of the <see cref="ObservationRecord"/> class.
 /// </summary>
 /// <param name="physicalRecord">The physical structure of the observation record.</param>
 /// <param name="dataSource">The data source record that defines the channels in this observation record.</param>
 /// <param name="settings">The monitor settings to be applied to this observation record.</param>
 private ObservationRecord(Record physicalRecord, DataSourceRecord dataSource, MonitorSettingsRecord?settings)
 {
     PhysicalRecord = physicalRecord;
     DataSource     = dataSource;
     Settings       = settings;
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Creates a new observation record from the given physical record
        /// if the physical record is of type observation. Returns null if
        /// it is not.
        /// </summary>
        /// <param name="physicalRecord">The physical record used to create the observation record.</param>
        /// <param name="dataSource">The data source record that defines the channels in this observation record.</param>
        /// <param name="settings">The monitor settings to be applied to this observation record.</param>
        /// <returns>The new observation record, or null if the physical record does not define a observation record.</returns>
        public static ObservationRecord?CreateObservationRecord(Record physicalRecord, DataSourceRecord dataSource, MonitorSettingsRecord?settings)
        {
            bool isValidObservationRecord = physicalRecord.Header.TypeOfRecord == RecordType.Observation;

            return(isValidObservationRecord ? new ObservationRecord(physicalRecord, dataSource, settings) : null);
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Creates a new instance of the <see cref="ChannelDefinition"/> class.
 /// </summary>
 /// <param name="physicalStructure">The collection element which is the physical structure of the channel definition.</param>
 /// <param name="dataSource">The data source in which the channel definition resides.</param>
 public ChannelDefinition(CollectionElement physicalStructure, DataSourceRecord dataSource)
 {
     m_dataSource        = dataSource;
     m_physicalStructure = physicalStructure;
 }
Ejemplo n.º 7
0
        private void ValidateDataSourceRecord(DataSourceRecord dataSourceRecord)
        {
            if (!dataSourceRecord.PhysicalRecord.Body.Collection.GetElementsByTag(DataSourceRecord.DataSourceTypeIDTag).Any())
            {
                m_missingTags.Add(new MissingTag(RecordType.DataSource, "DataSourceTypeTag", DataSourceRecord.DataSourceTypeIDTag));
            }

            if (!dataSourceRecord.PhysicalRecord.Body.Collection.GetElementsByTag(DataSourceRecord.DataSourceNameTag).Any())
            {
                m_missingTags.Add(new MissingTag(RecordType.DataSource, "DataSourceNameTag", DataSourceRecord.DataSourceNameTag));
            }

            if (!dataSourceRecord.PhysicalRecord.Body.Collection.GetElementsByTag(DataSourceRecord.EffectiveTag).Any())
            {
                m_missingTags.Add(new MissingTag(RecordType.DataSource, "EffectiveTag", DataSourceRecord.EffectiveTag));
            }

            if (!dataSourceRecord.PhysicalRecord.Body.Collection.GetElementsByTag(DataSourceRecord.ChannelDefinitionsTag).Any())
            {
                m_missingTags.Add(new MissingTag(RecordType.DataSource, "ChannelDefinitionsTag", DataSourceRecord.ChannelDefinitionsTag));
            }

            if (dataSourceRecord.ChannelDefinitions.Count == 0)
            {
                m_missingTags.Add(new MissingTag(RecordType.DataSource, "OneChannelDefinitionTag", DataSourceRecord.OneChannelDefinitionTag));
            }

            foreach (ChannelDefinition channelDefinition in dataSourceRecord.ChannelDefinitions)
            {
                if (!channelDefinition.PhysicalStructure.GetElementsByTag(ChannelDefinition.PhaseIDTag).Any())
                {
                    m_missingTags.Add(new MissingTag(RecordType.DataSource, "PhaseIDTag", ChannelDefinition.PhaseIDTag));
                }

                if (!channelDefinition.PhysicalStructure.GetElementsByTag(ChannelDefinition.QuantityTypeIDTag).Any())
                {
                    m_missingTags.Add(new MissingTag(RecordType.DataSource, "QuantityTypeIDTag", ChannelDefinition.QuantityTypeIDTag));
                }

                if (!channelDefinition.PhysicalStructure.GetElementsByTag(ChannelDefinition.QuantityMeasuredIDTag).Any())
                {
                    m_missingTags.Add(new MissingTag(RecordType.DataSource, "QuantityMeasuredIDTag", ChannelDefinition.QuantityMeasuredIDTag));
                }

                if (!channelDefinition.PhysicalStructure.GetElementsByTag(ChannelDefinition.SeriesDefinitionsTag).Any())
                {
                    m_missingTags.Add(new MissingTag(RecordType.DataSource, "SeriesDefinitionsTag", ChannelDefinition.SeriesDefinitionsTag));
                }

                if (channelDefinition.SeriesDefinitions.Count == 0)
                {
                    m_missingTags.Add(new MissingTag(RecordType.DataSource, "OneSeriesDefinitionTag", ChannelDefinition.OneSeriesDefinitionTag));
                }

                foreach (SeriesDefinition seriesDefinition in channelDefinition.SeriesDefinitions)
                {
                    if (!seriesDefinition.PhysicalStructure.GetElementsByTag(SeriesDefinition.ValueTypeIDTag).Any())
                    {
                        m_missingTags.Add(new MissingTag(RecordType.DataSource, "ValueTypeIDTag", SeriesDefinition.ValueTypeIDTag));
                    }

                    if (!seriesDefinition.PhysicalStructure.GetElementsByTag(SeriesDefinition.QuantityUnitsIDTag).Any())
                    {
                        m_missingTags.Add(new MissingTag(RecordType.DataSource, "QuantityUnitsIDTag", SeriesDefinition.QuantityUnitsIDTag));
                    }

                    if (!seriesDefinition.PhysicalStructure.GetElementsByTag(SeriesDefinition.QuantityCharacteristicIDTag).Any())
                    {
                        m_missingTags.Add(new MissingTag(RecordType.DataSource, "QuantityCharacteristicIDTag", SeriesDefinition.QuantityCharacteristicIDTag));
                    }

                    if (!seriesDefinition.PhysicalStructure.GetElementsByTag(SeriesDefinition.StorageMethodIDTag).Any())
                    {
                        m_missingTags.Add(new MissingTag(RecordType.DataSource, "StorageMethodIDTag", SeriesDefinition.StorageMethodIDTag));
                    }
                }
            }
        }