/// <summary>
        /// Unmarshals and deallocates an OPCHDA_ITEM structure.
        /// </summary>
        internal static ItemValueCollection GetItemValueCollection(OpcRcw.Hda.OPCHDA_ITEM input, bool deallocate)
        {
            ItemValueCollection output = new ItemValueCollection();

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

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

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

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

                output.Add(value);
            }

            return(output);
        }
        /// <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 = Technosoftware.DaAeHdaClient.Utilities.Interop.GetDateTimes(ref input.pftTimeStamps, input.dwCount, deallocate);
            int[]      qualities  = Technosoftware.DaAeHdaClient.Utilities.Interop.GetInt32s(ref input.pdwQualities, input.dwCount, deallocate);

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

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

                output.Add(value);
            }

            return(output);
        }