示例#1
0
        /// <summary>
        /// Prompts the user to view the values of a trend.
        /// </summary>
        public bool ShowDialog(TsCHdaServer server, TsCHdaItemValueCollection values, bool readOnly)
        {
            if (server == null)
            {
                throw new ArgumentNullException("server");
            }
            if (values == null)
            {
                throw new ArgumentNullException("values");
            }

            // initialize controls.
            trendCtrl_.Initialize(server, values);
            trendCtrl_.ReadOnly = readOnly;

            // show the dialog.
            if (ShowDialog() != DialogResult.OK)
            {
                return(false);
            }

            // update collection if not read only.
            if (!readOnly)
            {
                values.Clear();

                foreach (TsCHdaItemValue value in trendCtrl_.GetValues())
                {
                    values.Add(value);
                }
            }

            return(true);
        }
示例#2
0
        /// <summary>
        /// Unmarshals and deallocates an OPCHDA_ITEM structure.
        /// </summary>
        internal static TsCHdaItemValueCollection GetItemValueCollection(OpcRcw.Hda.OPCHDA_ITEM input, bool deallocate)
        {
            TsCHdaItemValueCollection output = new TsCHdaItemValueCollection();

            output.ClientHandle = input.hClient;
            output.Aggregate    = input.haAggregate;

            object[]   values     = Com.Interop.GetVARIANTs(ref input.pvDataValues, input.dwCount, deallocate);
            DateTime[] timestamps = Utilities.Interop.GetDateTimes(ref input.pftTimeStamps, input.dwCount, deallocate);
            int[]      qualities  = Utilities.Interop.GetInt32s(ref input.pdwQualities, input.dwCount, deallocate);

            for (int ii = 0; ii < input.dwCount; ii++)
            {
                TsCHdaItemValue value = new TsCHdaItemValue();

                value.Value            = values[ii];
                value.Timestamp        = timestamps[ii];
                value.Quality          = new TsCDaQuality((short)(qualities[ii] & 0x0000FFFF));
                value.HistorianQuality = (TsCHdaQuality)((int)(qualities[ii] & 0xFFFF0000));

                output.Add(value);
            }

            return(output);
        }
        /// <summary>
        /// Returns the set of item values stored in the list control.
        /// </summary>
        public TsCHdaItemValueCollection GetValues()
        {
            TsCHdaItemValueCollection values = new TsCHdaItemValueCollection();

            foreach (ListViewItem listItem in valuesLv_.Items)
            {
                if (typeof(TsCHdaItemValue).IsInstanceOfType(listItem.Tag))
                {
                    values.Add(listItem.Tag);
                }
            }

            return(values);
        }
示例#4
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);
        }