Пример #1
0
        internal static ItemProperty[] GetItemProperties(IntPtr ItemProperties, int ItemPropertyCount)
        {
            ItemProperty[] result = null;
            if (ItemPropertyCount > 0 && ItemProperties != IntPtr.Zero)
            {
                result = new ItemProperty[ItemPropertyCount];
                IntPtr pos = ItemProperties;
                for (int i = 0; i < ItemPropertyCount; i++)
                {
                    ItemProperty itemProperty          = new ItemProperty();
                    OpcRcw.Da.OPCITEMPROPERTY property = (OpcRcw.Da.OPCITEMPROPERTY)Marshal.PtrToStructure(pos, typeof(OpcRcw.Da.OPCITEMPROPERTY));
                    itemProperty.PropertyId = (PropertiyId)property.dwPropertyID;
                    int ErrorId = property.hrErrorID;
                    itemProperty.Description = property.szDescription;
                    itemProperty.ItemId      = property.szItemID;
                    itemProperty.DataType    = Helper.GetType((VarEnum)property.vtDataType);
                    itemProperty.Value       = ConvertValue(itemProperty.PropertyId, property.vValue);

                    result[i] = itemProperty;

                    pos = (IntPtr)(pos.ToInt32() + Marshal.SizeOf(typeof(OpcRcw.Da.OPCITEMPROPERTY)));
                }
            }
            return(result);
        }
Пример #2
0
		/// <summary>
		/// Allocates and marshals an arary of OPCITEMPROPERTY structures.
		/// </summary>
		internal static OpcRcw.Da.OPCITEMPROPERTY GetItemProperty(ItemProperty input)
		{
			OpcRcw.Da.OPCITEMPROPERTY output = new OpcRcw.Da.OPCITEMPROPERTY();

			if (input != null)
			{
				output.dwPropertyID  = input.Id;
				output.szDescription = input.Description;
				output.vtDataType    = input.DataType;
				output.vValue        = ComUtils.GetVARIANT(input.Value);
				output.wReserved     = 0;
				output.hrErrorID     = input.ErrorId;
			}

			return output;
		}