Example #1
0
        /// <summary>
        /// Adds a new channel setting to the collection
        /// of channel settings in this monitor settings record.
        /// </summary>
        public ChannelSetting AddNewChannelSetting(ChannelDefinition channelDefinition)
        {
            CollectionElement channelSettingElement = new CollectionElement()
            {
                TagOfElement = OneChannelSettingTag
            };
            ChannelSetting channelSetting = new ChannelSetting(channelSettingElement, this);

            channelSetting.ChannelDefinitionIndex = (uint)channelDefinition.DataSource.ChannelDefinitions.IndexOf(channelDefinition);

            CollectionElement channelSettingsElement = m_physicalRecord.Body.Collection.GetCollectionByTag(ChannelSettingsArrayTag);

            if ((object)channelSettingsElement == null)
            {
                channelSettingsElement = new CollectionElement()
                {
                    TagOfElement = OneChannelSettingTag
                };
                m_physicalRecord.Body.Collection.AddElement(channelSettingsElement);
            }

            channelSettingsElement.AddElement(channelSettingElement);

            return(channelSetting);
        }
Example #2
0
        /// <summary>
        /// Adds a new channel instance to the collection
        /// of channel instances in this observation record.
        /// </summary>
        public ChannelInstance AddNewChannelInstance(ChannelDefinition channelDefinition)
        {
            CollectionElement channelInstanceElement = new CollectionElement()
            {
                TagOfElement = OneChannelInstanceTag
            };
            ChannelInstance channelInstance = new ChannelInstance(channelInstanceElement, this);

            channelInstance.ChannelDefinitionIndex = (uint)channelDefinition.DataSource.ChannelDefinitions.IndexOf(channelDefinition);
            channelInstanceElement.AddElement(new CollectionElement()
            {
                TagOfElement = ChannelInstance.SeriesInstancesTag
            });

            CollectionElement channelInstancesElement = m_physicalRecord.Body.Collection.GetCollectionByTag(ChannelInstancesTag);

            if ((object)channelInstancesElement == null)
            {
                channelInstancesElement = new CollectionElement()
                {
                    TagOfElement = ChannelInstancesTag
                };
                m_physicalRecord.Body.Collection.AddElement(channelInstancesElement);
            }

            channelInstancesElement.AddElement(channelInstanceElement);

            return(channelInstance);
        }
Example #3
0
        /// <summary>
        /// Adds a new channel definition to the collection
        /// of channel definitions in this data source record.
        /// </summary>
        public ChannelDefinition AddNewChannelDefinition()
        {
            CollectionElement channelDefinitionElement = new CollectionElement()
            {
                TagOfElement = OneChannelDefinitionTag
            };
            ChannelDefinition channelDefinition = new ChannelDefinition(channelDefinitionElement, this);

            channelDefinition.Phase            = Phase.None;
            channelDefinition.QuantityMeasured = QuantityMeasured.None;
            channelDefinitionElement.AddElement(new CollectionElement()
            {
                TagOfElement = ChannelDefinition.SeriesDefinitionsTag
            });

            CollectionElement channelDefinitionsElement = m_physicalRecord.Body.Collection.GetCollectionByTag(ChannelDefinitionsTag);

            if ((object)channelDefinitionsElement == null)
            {
                channelDefinitionsElement = new CollectionElement()
                {
                    TagOfElement = ChannelDefinitionsTag
                };
                m_physicalRecord.Body.Collection.AddElement(channelDefinitionsElement);
            }

            channelDefinitionsElement.AddElement(channelDefinitionElement);

            return(channelDefinition);
        }
Example #4
0
        /// <summary>
        /// Removes the given channel definition from the collection of channel definitions.
        /// </summary>
        /// <param name="channelDefinition">The channel definition to be removed.</param>
        public void Remove(ChannelDefinition channelDefinition)
        {
            CollectionElement        channelDefinitionsElement = m_physicalRecord.Body.Collection.GetCollectionByTag(ChannelDefinitionsTag);
            List <CollectionElement> channelDefinitionElements;
            ChannelDefinition        definition;

            if ((object)channelDefinitionsElement == null)
            {
                return;
            }

            channelDefinitionElements = channelDefinitionsElement.GetElementsByTag(OneChannelDefinitionTag).Cast <CollectionElement>().ToList();

            foreach (CollectionElement channelDefinitionElement in channelDefinitionElements)
            {
                definition = new ChannelDefinition(channelDefinitionElement, this);

                if (Equals(channelDefinition, definition))
                {
                    channelDefinitionsElement.RemoveElement(channelDefinitionElement);
                }
            }
        }
Example #5
0
        /// <summary>
        /// Adds a new channel definition to the collection
        /// of channel definitions in this data source record.
        /// </summary>
        public ChannelDefinition AddNewChannelDefinition()
        {
            CollectionElement channelDefinitionsElement = m_physicalRecord.Body.Collection.GetCollectionByTag(ChannelDefinitionsTag);
            CollectionElement channelDefinitionElement  = new CollectionElement()
            {
                TagOfElement = OneChannelDefinitionTag
            };
            ChannelDefinition channelDefinition = new ChannelDefinition(channelDefinitionElement, this);

            if ((object)channelDefinitionsElement == null)
            {
                channelDefinitionsElement = new CollectionElement()
                {
                    TagOfElement = ChannelDefinitionsTag
                };

                m_physicalRecord.Body.Collection.AddElement(channelDefinitionsElement);
            }

            channelDefinitionsElement.AddElement(channelDefinitionElement);

            return(channelDefinition);
        }
Example #6
0
 /// <summary>
 /// Creates a new instance of the <see cref="SeriesDefinition"/> class.
 /// </summary>
 /// <param name="physicalStructure">The collection that is the physical structure of the series definition.</param>
 /// <param name="channelDefinition">The channel definition in which the series definition resides.</param>
 public SeriesDefinition(CollectionElement physicalStructure, ChannelDefinition channelDefinition)
 {
     m_physicalStructure = physicalStructure;
     m_channelDefinition = channelDefinition;
 }
Example #7
0
        private Channel ParseChannel(Meter meter, GSF.PQDIF.Logical.ChannelDefinition channeldef, AdoDataConnection connection)
        {
            Channel channel = new Channel();

            channel.MeterID = meter.ID;
            channel.Name    = channeldef.ChannelName;

            GSF.PQDIF.Logical.QuantityMeasured quantity = channeldef.QuantityMeasured;
            Guid quantityType = channeldef.QuantityTypeID;

            GSF.PQDIF.Logical.Phase phase = channeldef.Phase;

            if (isRMS(quantityType))
            {
                channel.SignalType = SignalType.RMS;
            }
            else if (isPOW(quantityType))
            {
                channel.SignalType = SignalType.PointOnWave;
            }
            else
            {
                channel.SignalType = SignalType.other;
            }

            Boolean isV = quantity == QuantityMeasured.Voltage;
            Boolean isI = quantity == QuantityMeasured.Current;

            Boolean isA = (phase == Phase.AN) || (phase == Phase.AB);
            Boolean isB = (phase == Phase.BN) || (phase == Phase.BC);
            Boolean isC = (phase == Phase.CN) || (phase == Phase.CA);
            Boolean isN = phase == Phase.Residual;



            string measurementname = MeasurementType.other;

            if (isV && isA)
            {
                measurementname = MeasurementType.VoltageA;
            }
            else if (isV && isB)
            {
                measurementname = MeasurementType.VoltageB;
            }
            else if (isV && isC)
            {
                measurementname = MeasurementType.VoltageC;
            }
            else if (isI && isA)
            {
                measurementname = MeasurementType.CurrentA;
            }
            else if (isI && isB)
            {
                measurementname = MeasurementType.CurrentB;
            }
            else if (isI && isC)
            {
                measurementname = MeasurementType.CurrentC;
            }
            else if (isV && isN)
            {
                measurementname = MeasurementType.other;
            }
            else if (isI && isN)
            {
                measurementname = MeasurementType.other;
            }

            GSF.Data.Model.TableOperations <Channel> channelTable = new GSF.Data.Model.TableOperations <Channel>(connection);

            channel.MeasurementType = measurementname;

            channelTable.AddNewRecord(channel);
            channel.ID = ModelID.GetID <Channel>(connection);


            return(channel);
        }