LoadConfiguration() public method

Loads the item configuaration.
public LoadConfiguration ( ISystemContext context, ArchiveItem item ) : bool
context ISystemContext
item ArchiveItem
return bool
Ejemplo 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;
            }
        }
Ejemplo n.º 2
0
        static void DoTest(TestCase test, string filePath)
        {
            List<DataValue> expectedValues = GetExpectedResults(test.ExpectedResultsPath, test.TestId);

            ArchiveItem item = new ArchiveItem(test.DataPath, Assembly.GetExecutingAssembly(), test.DataPath);

            DataFileReader reader = new DataFileReader();
            reader.LoadConfiguration(null, item);
            reader.LoadHistoryData(null, item);

            AggregateConfiguration configuration = new AggregateConfiguration();
            configuration.PercentDataBad = 100;
            configuration.PercentDataGood = 100;
            configuration.TreatUncertainAsBad = test.TreatUncertainAsBad;
            configuration.UseSlopedExtrapolation = test.UseSlopedExtrapolation;
            configuration.UseServerCapabilitiesDefaults = false;

            DateTime startTime = DateTime.UtcNow;
            startTime = new DateTime(startTime.Year, startTime.Month, startTime.Day, startTime.Hour, 0, 0, DateTimeKind.Utc);

            AggregateCalculator calculator = new AggregateCalculator(
                test.AggregateId,
                startTime.AddSeconds(0),
                startTime.AddSeconds(100),
                5000,
                test.Stepped,
                configuration);

            StringBuilder buffer = new StringBuilder();
            List<DataValue> values = new List<DataValue>();

            foreach (DataRowView row in item.DataSet.Tables[0].DefaultView)
            {
                DataValue rawValue = (DataValue)row.Row[2];

                if (!calculator.QueueRawValue(rawValue))
                {
                    Utils.Trace("Oops!");
                    continue;
                }

                DataValue processedValue = calculator.GetProcessedValue(false);

                if (processedValue != null)
                {
                    values.Add(processedValue);
                }
            }

            for (DataValue processedValue = calculator.GetProcessedValue(true); processedValue != null; processedValue = calculator.GetProcessedValue(true))
            {
                values.Add(processedValue);
            }

            for (int ii = 0; ii < values.Count && ii < expectedValues.Count; ii++)
            {
                if (values[ii].SourceTimestamp != expectedValues[ii].SourceTimestamp)
                {
                    Utils.Trace("Wrong Status Timestamp");
                    continue;
                }

                if (values[ii].StatusCode != expectedValues[ii].StatusCode)
                {
                    Utils.Trace("Wrong Status Code");
                    continue;
                }

                if (StatusCode.IsNotBad(values[ii].StatusCode))
                {
                    double value1 = Math.Round(Convert.ToDouble(values[ii].Value), 4);
                    double value2 = Math.Round(Convert.ToDouble(expectedValues[ii].Value), 4);

                    if (value1 != value2)
                    {
                        Utils.Trace("Wrong Value");
                        continue;
                    }
                }
            }
            
            foreach (DataValue processedValue in values)
            {
                buffer.Append(processedValue.SourceTimestamp.ToString("HH:mm:ss"));
                buffer.Append(", ");
                buffer.Append(processedValue.WrappedValue);
                buffer.Append(", ");
                buffer.Append(new StatusCode(processedValue.StatusCode.CodeBits));
                buffer.Append(", ");
                buffer.Append(processedValue.StatusCode.AggregateBits);
                buffer.Append("\r\n");
            }

            // write to the file.
            using (StreamWriter writer = new StreamWriter(filePath))
            {
                writer.Write(buffer.ToString());
            }
        }
Ejemplo n.º 3
0
        static void DoTest(TestCase test, string filePath)
        {
            List <DataValue> expectedValues = GetExpectedResults(test.ExpectedResultsPath, test.TestId);

            ArchiveItem item = new ArchiveItem(test.DataPath, Assembly.GetExecutingAssembly(), test.DataPath);

            DataFileReader reader = new DataFileReader();

            reader.LoadConfiguration(null, item);
            reader.LoadHistoryData(null, item);

            AggregateConfiguration configuration = new AggregateConfiguration();

            configuration.PercentDataBad                = 100;
            configuration.PercentDataGood               = 100;
            configuration.TreatUncertainAsBad           = test.TreatUncertainAsBad;
            configuration.UseSlopedExtrapolation        = test.UseSlopedExtrapolation;
            configuration.UseServerCapabilitiesDefaults = false;

            DateTime startTime = DateTime.UtcNow;

            startTime = new DateTime(startTime.Year, startTime.Month, startTime.Day, startTime.Hour, 0, 0, DateTimeKind.Utc);

            AggregateCalculator calculator = new AggregateCalculator(
                test.AggregateId,
                startTime.AddSeconds(0),
                startTime.AddSeconds(100),
                5000,
                test.Stepped,
                configuration);

            StringBuilder    buffer = new StringBuilder();
            List <DataValue> values = new List <DataValue>();

            foreach (DataRowView row in item.DataSet.Tables[0].DefaultView)
            {
                DataValue rawValue = (DataValue)row.Row[2];

                if (!calculator.QueueRawValue(rawValue))
                {
                    Utils.Trace("Oops!");
                    continue;
                }

                DataValue processedValue = calculator.GetProcessedValue(false);

                if (processedValue != null)
                {
                    values.Add(processedValue);
                }
            }

            for (DataValue processedValue = calculator.GetProcessedValue(true); processedValue != null; processedValue = calculator.GetProcessedValue(true))
            {
                values.Add(processedValue);
            }

            for (int ii = 0; ii < values.Count && ii < expectedValues.Count; ii++)
            {
                if (values[ii].SourceTimestamp != expectedValues[ii].SourceTimestamp)
                {
                    Utils.Trace("Wrong Status Timestamp");
                    continue;
                }

                if (values[ii].StatusCode != expectedValues[ii].StatusCode)
                {
                    Utils.Trace("Wrong Status Code");
                    continue;
                }

                if (StatusCode.IsNotBad(values[ii].StatusCode))
                {
                    double value1 = Math.Round(Convert.ToDouble(values[ii].Value), 4);
                    double value2 = Math.Round(Convert.ToDouble(expectedValues[ii].Value), 4);

                    if (value1 != value2)
                    {
                        Utils.Trace("Wrong Value");
                        continue;
                    }
                }
            }

            foreach (DataValue processedValue in values)
            {
                buffer.Append(processedValue.SourceTimestamp.ToString("HH:mm:ss"));
                buffer.Append(", ");
                buffer.Append(processedValue.WrappedValue);
                buffer.Append(", ");
                buffer.Append(new StatusCode(processedValue.StatusCode.CodeBits));
                buffer.Append(", ");
                buffer.Append(processedValue.StatusCode.AggregateBits);
                buffer.Append("\r\n");
            }

            // write to the file.
            using (StreamWriter writer = new StreamWriter(filePath))
            {
                writer.Write(buffer.ToString());
            }
        }
Ejemplo n.º 4
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;
            }
        }