예제 #1
0
        /// <summary>
        /// Saves the test data.
        /// </summary>
        private void SaveData(TestData testData)
        {
            m_currentDataSet.DataSetName = HistorianCB.SelectedItem as string;
            m_currentDataSet.AggregateName = AggregateCB.SelectedItem as string;
            m_currentDataSet.PercentBad = (byte)PercentBadNP.Value;
            m_currentDataSet.PercentGood = (byte)PercentGoodNP.Value;
            m_currentDataSet.ProcessingInterval = (uint)ProcessingIntervalNP.Value;
            m_currentDataSet.Stepped = SteppedCK.Checked;
            m_currentDataSet.TreatUncertainAsBad = TreatUncertainAsBadCK.Checked;
            m_currentDataSet.UseSlopedExtrapolation = UseSlopedExtrapolationCK.Checked;

            m_currentDataSet.Name = TestData.GetName(m_currentDataSet);

            ResetRowState();

            List<TestData.DataValue> values = new List<TestData.DataValue>();
            DataView view = new DataView(m_dataset.Tables[0], "RowState = 'OK'", "Timestamp", DataViewRowState.CurrentRows);

            foreach (DataRowView row in view)
            {
                TestData.DataValue dv = new TestData.DataValue();
                dv.WrappedValue = TestData.ValidateValue(row[3]);
                dv.StatusCode = TestData.ValidateQuality(row[4]);
                dv.SourceTimestamp = TestData.ValidateTimestamp(row[0]);

                string comment = row[8] as string;

                if (!String.IsNullOrEmpty(comment))
                {
                    dv.Comment = comment;
                }

                values.Add(dv);
            }

            testData.SetProcessedValues(m_currentDataSet, values);

            if (Object.ReferenceEquals(TestNameCB.SelectedItem, m_currentDataSet))
            {
                int index = TestNameCB.SelectedIndex;
                TestNameCB.Items.RemoveAt(index);
                TestNameCB.Items.Insert(index, m_currentDataSet);
                TestNameCB.SelectedIndex = index;
            }
        }
예제 #2
0
        private void File_LoadDefaultsMI_Click(object sender, EventArgs e)
        {
            try
            {
                Stream istrm = Assembly.GetExecutingAssembly().GetManifestResourceStream("Opc.Ua.AggregateTester.DefaultData.xml");
                XmlSerializer serializer = new XmlSerializer(typeof(TestData));
                m_testData = (TestData)serializer.Deserialize(istrm);
                m_testData.ProcessedDataSets = new ProcessedDataSetType[0];
                GenerateData();
                LoadData(m_testData);
            }
            catch (Exception exception)
            {
                ClientUtils.HandleException(this.Text, exception);
            }

        }
예제 #3
0
        /// <summary>
        /// Updates an actual value in the grid.
        /// </summary>
        private void UpdateActualValue(DataRow row, TestData.DataValue value, RowState type)
        {
            if (value != null)
            {
                row[5] = TestData.FormatValue(value.WrappedValue);
                row[6] = TestData.FormatQuality(value.StatusCode);
            }
            else
            {
                row[5] = String.Empty;
                row[6] = String.Empty;
            }

            row[7] = type.ToString();
        }
예제 #4
0
        /// <summary>
        /// Loads the test data.
        /// </summary>
        private void LoadData(TestData testData)
        {
            m_loading = true;

            try
            {
                HistorianCB.Items.Clear();
                m_dataset.Tables[0].Clear();

                if (testData.RawDataSets != null)
                {
                    foreach (RawDataSetType dataset in testData.RawDataSets)
                    {
                        HistorianCB.Items.Add(dataset.Name);
                    }
                }

                if (HistorianCB.Items.Count > 0)
                {
                    HistorianCB.SelectedIndex = 0;
                }
            }
            finally
            {
                m_loading = false;
            }

            UpdatesComplete();
        }
예제 #5
0
        /// <summary>
        /// Adds an actual value to the grid.
        /// </summary>
        private void AddActualValue(TestData.DataValue value, RowState type)
        {
            DataRow row = m_dataset.Tables[0].NewRow();

            row[0] = TestData.FormatTimestamp(value.SourceTimestamp);
            row[1] = String.Empty;
            row[2] = String.Empty;
            row[3] = String.Empty;
            row[4] = String.Empty;
            row[5] = String.Empty;
            row[6] = String.Empty;
            row[8] = value.Comment;

            UpdateActualValue(row, value, type);

            m_dataset.Tables[0].Rows.Add(row);
        }
예제 #6
0
        /// <summary>
        /// Updates an expected value in the grid.
        /// </summary>
        private void UpdateExpectedValue(DataRow row, TestData.DataValue value, RowState type)
        {
            if (type != RowState.MissingExpected)
            {
                row[3] = TestData.FormatValue(value.WrappedValue);
                row[4] = TestData.FormatQuality(value.StatusCode);
            }
            else
            {
                row[3] = String.Empty;
                row[4] = String.Empty;
            }

            row[7] = type.ToString();
            row[8] = value.Comment;
        }
예제 #7
0
 /// <summary>
 /// Updates a raw value in the grid.
 /// </summary>
 private void UpdateRawValue(DataRow row, TestData.DataValue value)
 {
     row[1] = TestData.FormatValue(value.WrappedValue);
     row[2] = TestData.FormatQuality(value.StatusCode);
     row[8] = value.Comment;
 }
예제 #8
0
        /// <summary>
        /// Adds a raw value to the grid.
        /// </summary>
        private void AddRawValue(TestData.DataValue value)
        {
            DataRow row = m_dataset.Tables[0].NewRow();

            row[0] = TestData.FormatTimestamp(value.SourceTimestamp);
            row[1] = String.Empty;
            row[2] = String.Empty;
            row[3] = String.Empty;
            row[4] = String.Empty;
            row[5] = String.Empty;
            row[6] = String.Empty;
            row[7] = RowState.Raw.ToString();

            UpdateRawValue(row, value);

            m_dataset.Tables[0].Rows.Add(row);
        }
예제 #9
0
 private void File_LoadMI_Click(object sender, EventArgs e)
 {
     try
     {
         XmlReader reader = XmlReader.Create("TestData.xml");
         XmlSerializer serializer = new XmlSerializer(typeof(TestData));
         m_testData = (TestData)serializer.Deserialize(reader);
         reader.Close();
         LoadData(m_testData);
     }
     catch (Exception exception)
     {
         ClientUtils.HandleException(this.Text, exception);
     }
 }