Quickstarts.HistoricalAccessServer.DataFileReader.LoadConfiguration C# (CSharp) Method

LoadConfiguration() public method

Loads the item configuaration.
public LoadConfiguration ( ISystemContext context, ArchiveItem item ) : bool
context ISystemContext
item ArchiveItem
return bool
        public bool LoadConfiguration(ISystemContext context, ArchiveItem item)
        {
            using (StreamReader reader = item.OpenArchive())
            {
                while (!reader.EndOfStream)
                {
                    string line = reader.ReadLine();

                    // check for end or error.
                    if (line == null)
                    {
                        break;
                    }

                    // ignore blank lines.
                    line = line.Trim();

                    if (String.IsNullOrEmpty(line))
                    {
                        continue;
                    }

                    // ignore commented out lines.
                    if (line.StartsWith("//"))
                    {
                        continue;
                    }

                    BuiltInType dataType = BuiltInType.String;
                    int valueRank = ValueRanks.Scalar;
                    int samplingInterval = 0;
                    int simulationType = 0;
                    int amplitude = 0;
                    int period = 0;
                    int archiving = 0;
                    int stepped = 0;
                    int useSlopedExtrapolation = 0;
                    int treatUncertainAsBad = 0;
                    int percentDataBad = 0;
                    int percentDataGood = 0;

                    // get data type.
                    if (!ExtractField(1, ref line, out dataType))
                    {
                        return false;
                    }

                    // get value rank.
                    if (!ExtractField(1, ref line, out valueRank))
                    {
                        return false;
                    }

                    // get sampling interval.
                    if (!ExtractField(1, ref line, out samplingInterval))
                    {
                        return false;
                    }

                    // get simulation type.
                    if (!ExtractField(1, ref line, out simulationType))
                    {
                        return false;
                    }

                    // get simulation amplitude.
                    if (!ExtractField(1, ref line, out amplitude))
                    {
                        return false;
                    }

                    // get simulation period.
                    if (!ExtractField(1, ref line, out period))
                    {
                        return false;
                    }

                    // get flag indicating whether new data is generated.
                    if (!ExtractField(1, ref line, out archiving))
                    {
                        return false;
                    }

                    // get flag indicating whether stepped interpolation is used.
                    if (!ExtractField(1, ref line, out stepped))
                    {
                        return false;
                    }

                    // get flag indicating whether sloped interpolation should be used.
                    if (!ExtractField(1, ref line, out useSlopedExtrapolation))
                    {
                        return false;
                    }

                    // get flag indicating whether sloped interpolation should be used.
                    if (!ExtractField(1, ref line, out treatUncertainAsBad))
                    {
                        return false;
                    }

                    // get the maximum permitted of bad data in an interval.
                    if (!ExtractField(1, ref line, out percentDataBad))
                    {
                        return false;
                    }

                    // get the minimum amount of good data in an interval.
                    if (!ExtractField(1, ref line, out percentDataGood))
                    {
                        return false;
                    }
                    
                    // update the item.
                    item.DataType = dataType;
                    item.ValueRank = valueRank;
                    item.SimulationType = simulationType;
                    item.Amplitude = amplitude;
                    item.Period = period;
                    item.SamplingInterval = samplingInterval;
                    item.Archiving = archiving != 0;
                    item.Stepped = stepped != 0;
                    item.AggregateConfiguration = new AggregateConfiguration();
                    item.AggregateConfiguration.UseServerCapabilitiesDefaults = false;
                    item.AggregateConfiguration.UseSlopedExtrapolation = useSlopedExtrapolation != 0;
                    item.AggregateConfiguration.TreatUncertainAsBad = treatUncertainAsBad != 0;
                    item.AggregateConfiguration.PercentDataBad = (byte)percentDataBad;
                    item.AggregateConfiguration.PercentDataGood = (byte)percentDataGood;
                    break;
                }
            }

            return true;
        }

Usage Example

Exemplo n.º 1
0
        /// <summary>
        /// Loads the configuration.
        /// </summary>
        public void LoadConfiguration(SystemContext context)
        {
            DataFileReader reader = new DataFileReader();

            if (reader.LoadConfiguration(context, m_archiveItem))
            {
                this.DataType    = (uint)m_archiveItem.DataType;
                this.ValueRank   = m_archiveItem.ValueRank;
                this.Historizing = m_archiveItem.Archiving;

                m_configuration.MinTimeInterval.Value = m_archiveItem.SamplingInterval;
                m_configuration.MaxTimeInterval.Value = m_archiveItem.SamplingInterval;
                m_configuration.Stepped.Value         = m_archiveItem.Stepped;

                AggregateConfiguration configuration = m_archiveItem.AggregateConfiguration;
                m_configuration.AggregateConfiguration.PercentDataGood.Value        = configuration.PercentDataGood;
                m_configuration.AggregateConfiguration.PercentDataBad.Value         = configuration.PercentDataBad;
                m_configuration.AggregateConfiguration.UseSlopedExtrapolation.Value = configuration.UseSlopedExtrapolation;
                m_configuration.AggregateConfiguration.TreatUncertainAsBad.Value    = configuration.TreatUncertainAsBad;
            }
        }
All Usage Examples Of Quickstarts.HistoricalAccessServer.DataFileReader::LoadConfiguration