コード例 #1
0
        /// <summary>
        /// Loads the dataset containing the test descriptions.
        /// </summary>
        private TestData[] LoadDataSet()
        {
            try
            {
                // create the dataset.
                mDataset_ = new DataSet();

                // load the test case descriptions.
                mDataset_.ReadXml(mFilePath_);

                // select only the desired test cases.
                mDataset_.TestCases.DefaultView.Sort = "Name";

                // execute the test cases.
                ArrayList tests = new ArrayList(mDataset_.TestCases.DefaultView.Count);

                foreach (DataRowView row in mDataset_.TestCases.DefaultView)
                {
                    DataSet.TestCase testcase = (DataSet.TestCase)row.Row;

                    // create trend.
                    TsCHdaTrend trend = new TsCHdaTrend(mServer_);

                    trend.Name             = testcase.Name;
                    trend.Aggregate        = testcase.AggregateId;
                    trend.MaxValues        = testcase.MaxValues;
                    trend.IncludeBounds    = testcase.IncludeBounds;
                    trend.ResampleInterval = testcase.ResampleInterval;

                    if (testcase.StartTime != Decimal.MinValue)
                    {
                        trend.StartTime = new TsCHdaTime(Basetime.AddSeconds((double)testcase.StartTime));
                    }

                    if (testcase.EndTime != Decimal.MinValue)
                    {
                        trend.EndTime = new TsCHdaTime(Basetime.AddSeconds((double)testcase.EndTime));
                    }

                    TestData test = new TestData();

                    test.TestCase = testcase;
                    test.Trend    = trend;
                    test.Expected = GetExpectedResults(testcase);

                    // add to list.
                    tests.Add(test);
                }

                // return set of trends.
                return((TestData[])tests.ToArray(typeof(TestData)));
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }

            return(null);
        }
コード例 #2
0
        /// <summary>
        /// Deletes am existing test case.
        /// </summary>
        private void RemoveMI_Click(object sender, System.EventArgs e)
        {
            try
            {
                // check for valid selection.
                if (resultsLv_.SelectedItems.Count != 1)
                {
                    return;
                }

                TestData test = (TestData)resultsLv_.SelectedItems[0].Tag;

                // confirm delete.
                DialogResult result = MessageBox.Show("Permenently delete the test case?", test.Trend.Name, MessageBoxButtons.YesNo);

                if (result != DialogResult.Yes)
                {
                    return;
                }

                // fetch the current index in the dataset.
                int index = mDataset_.TestCases.DefaultView.Find(test.Trend.Name);

                if (index == -1)
                {
                    return;
                }

                DataSet.TestCase testcase = (DataSet.TestCase)mDataset_.TestCases.DefaultView[index].Row;

                // delete the test case.
                testcase.Delete();

                // accept changes and save the dataset.
                mDataset_.AcceptChanges();
                mDataset_.WriteXml(mFilePath_);

                // update display.
                resultsLv_.SelectedItems[0].Remove();
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
        }
コード例 #3
0
        /// <summary>
        /// Reads the expected results for a test case from the dataset.
        /// </summary>
        private TsCHdaItemValueCollection GetExpectedResults(DataSet.TestCase testcase)
        {
            // create item value collection.
            TsCHdaItemValueCollection values = new TsCHdaItemValueCollection();

            try
            {
                // set expected result.
                values.Result = new OpcResult(testcase.ResultId, "");

                // get the item values.
                DataRow[] rows = testcase.GetChildRows(mDataset_.TestCases.ChildRelations[0]);

                // read the expected values.
                if (rows != null)
                {
                    foreach (DataSet.TsCHdaItemValue row in rows)
                    {
                        // create item value.
                        TsCHdaItemValue value = new TsCHdaItemValue();

                        if (!typeof(DBNull).IsInstanceOfType(row["Value"]))
                        {
                            value.Value = row.Value;
                        }

                        value.Timestamp        = Basetime.AddSeconds((double)row.Timestamp);
                        value.Quality          = new TsCDaQuality((short)(row.Quality & 0x000FFFF));
                        value.HistorianQuality = (Technosoftware.DaAeHdaClient.Hda.TsCHdaQuality)Enum.ToObject(typeof(Technosoftware.DaAeHdaClient.Hda.TsCHdaQuality), (int)(row.Quality & 0xFFFF0000));

                        // add to list.
                        values.Add(value);
                    }
                }
            }
            catch (Exception)
            {
                // ignore exceptions - return at whatever was read correctly.
            }

            // return set of values.
            return(values);
        }