public static OpcDaItemProperty[] LookupItemIDs(this OpcItemProperties opcItemProperties, string itemId,
                                                        IList <int> propertyIds)
        {
            HRESULT[] ppErrors;
            var       ppszNewItemIDs = opcItemProperties.LookupItemIDs(itemId, propertyIds.ToArray(), out ppErrors);

            var properties = new OpcDaItemProperty[propertyIds.Count];

            for (var i = 0; i < propertyIds.Count; i++)
            {
                var property = new OpcDaItemProperty
                {
                    PropertyId = propertyIds[i],
                    ItemId     = ppszNewItemIDs[i],
                    ErrorId    = ppErrors[i]
                };
                properties[i] = property;
            }

            return(properties);
        }
        public static OpcDaItemProperties QueryAvailableProperties(this OpcItemProperties opcItemProperties,
            string itemId)
        {
            string[] ppDescriptions;
            VarEnum[] ppvtDataTypes;
            var pdwPropertyIDs = opcItemProperties.QueryAvailableProperties(itemId, out ppDescriptions,
                out ppvtDataTypes);

            var props = new OpcDaItemProperties {Properties = new OpcDaItemProperty[pdwPropertyIDs.Length]};
            for (var i = 0; i < pdwPropertyIDs.Length; i++)
            {
                var property = new OpcDaItemProperty
                {
                    PropertyId = pdwPropertyIDs[i],
                    Description = ppDescriptions[i],
                    DataType = TypeConverter.FromVarEnum(ppvtDataTypes[i])
                };
                props.Properties[i] = property;
            }
            return props;
        }
        public static OpcDaItemProperty[] GetItemProperties(this OpcItemProperties opcItemProperties, string itemId,
            IList<int> propertyIds)
        {
            HRESULT[] ppErrors;
            var ppvData = opcItemProperties.GetItemProperties(itemId, propertyIds.ToArray(), out ppErrors);


            var properties = new OpcDaItemProperty[ppvData.Length];
            for (var i = 0; i < properties.Length; i++)
            {
                var property = new OpcDaItemProperty
                {
                    PropertyId = propertyIds[i],
                    Value = ppvData[i],
                    ErrorId = ppErrors[i]
                };
                properties[i] = property;
            }

            return properties;
        }
        public static OpcDaItemProperty[] GetItemProperties(this OpcItemProperties opcItemProperties, string itemId,
                                                            IList <int> propertyIds)
        {
            HRESULT[] ppErrors;
            var       ppvData = opcItemProperties.GetItemProperties(itemId, propertyIds.ToArray(), out ppErrors);


            var properties = new OpcDaItemProperty[ppvData.Length];

            for (var i = 0; i < properties.Length; i++)
            {
                var property = new OpcDaItemProperty
                {
                    PropertyId = propertyIds[i],
                    Value      = ppvData[i],
                    ErrorId    = ppErrors[i]
                };
                properties[i] = property;
            }

            return(properties);
        }
        public static OpcDaItemProperties QueryAvailableProperties(this OpcItemProperties opcItemProperties,
                                                                   string itemId)
        {
            string[]  ppDescriptions;
            VarEnum[] ppvtDataTypes;
            var       pdwPropertyIDs = opcItemProperties.QueryAvailableProperties(itemId, out ppDescriptions,
                                                                                  out ppvtDataTypes);

            var props = new OpcDaItemProperties {
                Properties = new OpcDaItemProperty[pdwPropertyIDs.Length]
            };

            for (var i = 0; i < pdwPropertyIDs.Length; i++)
            {
                var property = new OpcDaItemProperty
                {
                    PropertyId  = pdwPropertyIDs[i],
                    Description = ppDescriptions[i],
                    DataType    = TypeConverter.FromVarEnum(ppvtDataTypes[i])
                };
                props.Properties[i] = property;
            }
            return(props);
        }
Exemplo n.º 6
0
        private static OpcDaItemProperty[] ReadItemProperties(ref IntPtr pItemProperties, int dwNumProperties)
        {
            var    result  = new OpcDaItemProperty[dwNumProperties];
            IntPtr current = pItemProperties;

            for (int i = 0; i < dwNumProperties; i++)
            {
                var opcitemproperty = (OPCITEMPROPERTY)Marshal.PtrToStructure(current, typeof(OPCITEMPROPERTY));
                result[i] = new OpcDaItemProperty
                {
                    DataType    = TypeConverter.FromVarEnum((VarEnum)opcitemproperty.vtDataType),
                    PropertyId  = opcitemproperty.dwPropertyID,
                    ItemId      = opcitemproperty.szItemID,
                    Description = opcitemproperty.szDescription,
                    Value       = opcitemproperty.vValue,
                    ErrorId     = opcitemproperty.hrErrorID
                };
                Marshal.DestroyStructure(current, typeof(OPCITEMPROPERTY));
                current += Marshal.SizeOf(typeof(OPCITEMPROPERTY));
            }
            Marshal.FreeCoTaskMem(pItemProperties);
            pItemProperties = IntPtr.Zero;
            return(result);
        }
        public static OpcDaItemProperty[] LookupItemIDs(this OpcItemProperties opcItemProperties, string itemId,
            IList<int> propertyIds)
        {
            HRESULT[] ppErrors;
            var ppszNewItemIDs = opcItemProperties.LookupItemIDs(itemId, propertyIds.ToArray(), out ppErrors);

            var properties = new OpcDaItemProperty[propertyIds.Count];
            for (var i = 0; i < propertyIds.Count; i++)
            {
                var property = new OpcDaItemProperty
                {
                    PropertyId = propertyIds[i],
                    ItemId = ppszNewItemIDs[i],
                    ErrorId = ppErrors[i]
                };
                properties[i] = property;
            }

            return properties;
        }
Exemplo n.º 8
0
 private static OpcDaItemProperty[] ReadItemProperties(ref IntPtr pItemProperties, int dwNumProperties)
 {
     var result = new OpcDaItemProperty[dwNumProperties];
     IntPtr current = pItemProperties;
     for (int i = 0; i < dwNumProperties; i++)
     {
         var opcitemproperty = (OPCITEMPROPERTY) Marshal.PtrToStructure(current, typeof (OPCITEMPROPERTY));
         result[i] = new OpcDaItemProperty
         {
             DataType = TypeConverter.FromVarEnum((VarEnum) opcitemproperty.vtDataType),
             PropertyId = opcitemproperty.dwPropertyID,
             ItemId = opcitemproperty.szItemID,
             Description = opcitemproperty.szDescription,
             Value = opcitemproperty.vValue,
             ErrorId = opcitemproperty.hrErrorID
         };
         Marshal.DestroyStructure(current, typeof (OPCITEMPROPERTY));
         current += Marshal.SizeOf(typeof (OPCITEMPROPERTY));
     }
     Marshal.FreeCoTaskMem(pItemProperties);
     pItemProperties = IntPtr.Zero;
     return result;
 }