Opc.Ua.Com.Client.ComDaClient.ReadPropertyValues C# (CSharp) Method

ReadPropertyValues() private method

Reads the values of the properties from the server.
private ReadPropertyValues ( string itemId ) : DaValue[]
itemId string The item id.
return DaValue[]
        private DaValue[] ReadPropertyValues(string itemId, params int[] propertyIds)
        {
            string methodName = "IOPCItemProperties.GetItemProperties";

            // check for trivial case.
            if (propertyIds == null)
            {
                return null;
            }

            int count = propertyIds.Length;
            DaValue[] results = new DaValue[count];
            
            // check for empty list.
            if (count == 0)
            {
                return results;
            }

            // get the values from the server.
            IntPtr pValues = IntPtr.Zero;
            IntPtr pErrors = IntPtr.Zero;

            try
            {
                IOPCItemProperties server = BeginComCall<IOPCItemProperties>(methodName, true);

                server.GetItemProperties(
                    itemId,
                    count,
                    propertyIds,
                    out pValues,
                    out pErrors);
            }
            catch (Exception e)
            {
                if (ComUtils.IsUnknownError(e, ResultIds.E_FAIL, ResultIds.E_INVALIDARG, ResultIds.E_UNKNOWNITEMID, ResultIds.E_INVALIDITEMID))
                {
                    ComUtils.TraceComError(e, methodName);
                    return null;
                }

                for (int ii = 0; ii < count; ii++)
                {
                    DaValue result = results[ii] = new DaValue();
                    result.Value = null;
                    result.Quality = OpcRcw.Da.Qualities.OPC_QUALITY_GOOD;
                    result.Timestamp = DateTime.UtcNow;
                    result.Error = Marshal.GetHRForException(e);
                }

                return results;
            }
            finally
            {
                EndComCall(methodName);
            }

            // unmarshal results.
            object[] values = ComUtils.GetVARIANTs(ref pValues, count, true);
            int[]    errors = ComUtils.GetInt32s(ref pErrors, count, true);

            for (int ii = 0; ii < count; ii++)
            {
                DaValue result = results[ii] = new DaValue();

                Variant convertedValue;
                result.Error = ComDaClientNodeManager.RemoteToLocalValue(values[ii], out convertedValue);

                if (result.Error < 0)
                {
                    continue;
                }

                result.Value = convertedValue.Value;
                result.Quality = OpcRcw.Da.Qualities.OPC_QUALITY_GOOD;
                result.Timestamp = DateTime.UtcNow;
                result.Error = errors[ii];
            }

            return results;
        }

Same methods

ComDaClient::ReadPropertyValues ( List requests ) : void