Exemple #1
0
 public override void DeserializeChildren(PersistenceReader ip)
 {
     while (ip.HasChild)
     {
         m_Values.Add(ip.GetChild() as ItemValue);
     }
 }
        /// <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);
        }
 private ItemValueCollection CreateTestCollection()
 {
     ItemValueCollection testCollection = new ItemValueCollection();
     ItemValue testItemValue = new ItemValue();
     testItemValue.ItemID = "SimulatedData.Random";
     testItemValue.Timestamp = DateTime.Now;
     Random rnd = new Random();
     testItemValue.Value = rnd.Next(900000);
     testCollection.Add(testItemValue);
     return testCollection;
 }
Exemple #4
0
        internal static ItemValueCollection GetItemValueCollection(OPCHDA_ITEM input, bool deallocate)
        {
            ItemValueCollection values = new ItemValueCollection {
                ClientHandle = input.hClient,
                AggregateID  = input.haAggregate
            };

            object[]   objArray  = OpcCom.Interop.GetVARIANTs(ref input.pvDataValues, input.dwCount, deallocate);
            DateTime[] timeArray = OpcCom.Interop.GetFILETIMEs(ref input.pftTimeStamps, input.dwCount, deallocate);
            int[]      numArray  = OpcCom.Interop.GetInt32s(ref input.pdwQualities, input.dwCount, deallocate);
            for (int i = 0; i < input.dwCount; i++)
            {
                Opc.Hda.ItemValue value2 = new Opc.Hda.ItemValue {
                    Value            = objArray[i],
                    Timestamp        = timeArray[i],
                    Quality          = new Opc.Da.Quality((short)(numArray[i] & 0xffff)),
                    HistorianQuality = ((Opc.Hda.Quality)numArray[i]) & ((Opc.Hda.Quality)(unchecked ((int)0xffff0000L)))
                };
                values.Add(value2);
            }
            return(values);
        }
 private ItemValueCollection CreateItemValues(DataTable dt)
 {
     ItemValueCollection result = new ItemValueCollection();
     ItemValue newItemValue;
     foreach (DataRow currentRow in dt.Rows) {
         newItemValue = CreateSingleItemValue(currentRow);
         result.Add(newItemValue);
     }
     return result;
 }