QuickOPC User's Guide and Reference
GetPropertyValue(IEasyDAClient,ServerDescriptor,DANodeDescriptor,DAPropertyDescriptor) Method
Example 



OpcLabs.EasyOpcClassic Assembly > OpcLabs.EasyOpc.DataAccess Namespace > IEasyDAClientExtension Class > GetPropertyValue Method : GetPropertyValue(IEasyDAClient,ServerDescriptor,DANodeDescriptor,DAPropertyDescriptor) Method
The client object that will perform the operation.
The OPC server involved in the operation.
The descriptor of the OPC node involved in the operation.
The descriptor of the OPC property involved in the operation.
Gets a value of OPC property of a specified OPC item. Gets a value of OPC property, using descriptor object for the OPC server, and a node descriptor.
Syntax
'Declaration
 
<ExtensionAttribute()>
<CanBeNullAttribute()>
Public Overloads Shared Function GetPropertyValue( _
   ByVal client As IEasyDAClient, _
   ByVal serverDescriptor As ServerDescriptor, _
   ByVal nodeDescriptor As DANodeDescriptor, _
   ByVal propertyDescriptor As DAPropertyDescriptor _
) As Object
'Usage
 
Dim client As IEasyDAClient
Dim serverDescriptor As ServerDescriptor
Dim nodeDescriptor As DANodeDescriptor
Dim propertyDescriptor As DAPropertyDescriptor
Dim value As Object
 
value = IEasyDAClientExtension.GetPropertyValue(client, serverDescriptor, nodeDescriptor, propertyDescriptor)

Parameters

client
The client object that will perform the operation.
serverDescriptor
The OPC server involved in the operation.
nodeDescriptor
The descriptor of the OPC node involved in the operation.
propertyDescriptor
The descriptor of the OPC property involved in the operation.

Return Value

If successful, the function returns the actual value of the OPC property requested.
Exceptions
ExceptionDescription
Thrown when the OPC operation fails.
A null reference (Nothing in Visual Basic) is passed to a method that does not accept it as a valid argument.
Example
// This example shows how to get a value of a single OPC property.
//
// Note that some properties may not have a useful value initially (e.g. until the item is activated in a group), which also the
// case with Timestamp property as implemented by the demo server. This behavior is server-dependent, and normal. You can run 
// IEasyDAClient.ReadItemValue.Main.vbs shortly before this example, in order to obtain better property values. Your code may 
// also subscribe to the item in order to assure that it remains active.

using System;
using OpcLabs.EasyOpc.DataAccess;
using OpcLabs.EasyOpc.OperationModel;

namespace DocExamples.DataAccess._EasyDAClient
{
    partial class GetPropertyValue
    {
        public static void Main1()
        {
            // Instantiate the client object.
            var client = new EasyDAClient();

            object value;
            try
            {
                value = client.GetPropertyValue("", "OPCLabs.KitServer.2", "Simulation.Random",
                    DAPropertyIds.Timestamp);
            }
            catch (OpcException opcException)
            {
                Console.WriteLine("*** Failure: {0}", opcException.GetBaseException().Message);
                return;
            }

            Console.WriteLine(value);
        }
    }
}
' This example shows how to get a value of a single OPC property.
'
' Note that some properties may not have a useful value initially (e.g. until the item is activated in a group), which also the
' case with Timestamp property as implemented by the demo server. This behavior is server-dependent, and normal. You can run 
' IEasyDAClient.ReadItemValue.Main.vbs shortly before this example, in order to obtain better property values. Your code may 
' also subscribe to the item in order to assure that it remains active.

Imports OpcLabs.EasyOpc.DataAccess
Imports OpcLabs.EasyOpc.OperationModel

Namespace DocExamples.DataAccess._EasyDAClient
    Partial Friend Class GetPropertyValue
        Public Shared Sub Main1()
            Dim client = New EasyDAClient()

            Dim value As Object
            Try
                value = client.GetPropertyValue("", "OPCLabs.KitServer.2", "Simulation.Random", DAPropertyIds.Timestamp)
            Catch opcException As OpcException
                Console.WriteLine("*** Failure: {0}", opcException.GetBaseException().Message)
                Exit Sub
            End Try

            Console.WriteLine(value)
        End Sub
    End Class
End Namespace
// This example shows how to obtain a data type of an OPC item.

using System;
using OpcLabs.BaseLib.ComInterop;
using OpcLabs.EasyOpc.DataAccess;
using OpcLabs.EasyOpc.OperationModel;

namespace DocExamples.DataAccess._EasyDAClient
{
    partial class GetPropertyValue
    {
        public static void DataType()
        {
            // Instantiate the client object.
            var client = new EasyDAClient();

            // Get the value of DataType property; it is a 16-bit signed integer
            short dataType;
            try
            {
                dataType = (short)client.GetPropertyValue("", "OPCLabs.KitServer.2", "Simulation.Random",
                    DAPropertyIds.DataType);
            }
            catch (OpcException opcException)
            {
                Console.WriteLine("*** Failure: {0}", opcException.GetBaseException().Message);
                return;
            }
            // Convert the data type to VarType
            var varType = (VarType)dataType;

            // Display the obtained data type
            Console.WriteLine("DataType: {0}", dataType);   // Display data type as numerical value
            Console.WriteLine("VarType: {0}", varType);     // Display data type symbolically

            // Code below illustrates how decisions can be made based on type
            switch (varType.InternalValue)
            {
                case VarTypes.R8:
                    Console.WriteLine("The data type is VarTypes.R8, as we expected.");
                    break;

                // other cases may come here ...

                default:
                    Console.WriteLine("The data type is not as we expected!");
                    break;
            }
        }
    }
}
' This example shows how to obtain a data type of an OPC item.

Imports OpcLabs.BaseLib.ComInterop
Imports OpcLabs.EasyOpc.DataAccess
Imports OpcLabs.EasyOpc.OperationModel

Namespace DocExamples.DataAccess._EasyDAClient
    Partial Friend Class GetPropertyValue
        Public Shared Sub DataType()
            Dim client = New EasyDAClient()

            ' Get the value of DataType property; it is a 16-bit signed integer
            Dim aDataType As Short
            Try
                aDataType = CShort(Fix(client.GetPropertyValue("", "OPCLabs.KitServer.2", "Simulation.Random", DAPropertyIds.DataType)))
            Catch opcException As OpcException
                Console.WriteLine("*** Failure: {0}", opcException.GetBaseException().Message)
                Exit Sub
            End Try

            ' Convert the data type to VarType
            Dim varType = CType(aDataType, VarType)

            ' Display the obtained data type
            Console.WriteLine("DataType: {0}", aDataType) ' Display data type as numerical value
            Console.WriteLine("VarType: {0}", varType) ' Display data type symbolically

            ' Code below illustrates how decisions can be made based on type
            Select Case varType
                Case VarTypes.R8
                    Console.WriteLine("The data type is VarTypes.R8, as we expected.")

                    ' other cases may come here ...

                Case Else
                    Console.WriteLine("The data type is not as we expected!")
            End Select
        End Sub
    End Class
End Namespace
// This example shows how to get a value of a single OPC property.
//
// Note that some properties may not have a useful value initially (e.g. until the item is activated in a group), which also the
// case with Timestamp property as implemented by the demo server. This behavior is server-dependent, and normal. You can run 
// IEasyDAClient.ReadItemValue.Main.vbs shortly before this example, in order to obtain better property values. Your code may 
// also subscribe to the item in order to assure that it remains active.

using System;
using OpcLabs.EasyOpc.DataAccess;
using OpcLabs.EasyOpc.OperationModel;

namespace DocExamples.DataAccess._EasyDAClient
{
    partial class GetPropertyValue
    {
        public static void Main1()
        {
            // Instantiate the client object.
            var client = new EasyDAClient();

            object value;
            try
            {
                value = client.GetPropertyValue("", "OPCLabs.KitServer.2", "Simulation.Random",
                    DAPropertyIds.Timestamp);
            }
            catch (OpcException opcException)
            {
                Console.WriteLine("*** Failure: {0}", opcException.GetBaseException().Message);
                return;
            }

            Console.WriteLine(value);
        }
    }
}
' This example shows how to get a value of a single OPC property.
'
' Note that some properties may not have a useful value initially (e.g. until the item is activated in a group), which also the
' case with Timestamp property as implemented by the demo server. This behavior is server-dependent, and normal. You can run 
' IEasyDAClient.ReadItemValue.Main.vbs shortly before this example, in order to obtain better property values. Your code may 
' also subscribe to the item in order to assure that it remains active.

Imports OpcLabs.EasyOpc.DataAccess
Imports OpcLabs.EasyOpc.OperationModel

Namespace DocExamples.DataAccess._EasyDAClient
    Partial Friend Class GetPropertyValue
        Public Shared Sub Main1()
            Dim client = New EasyDAClient()

            Dim value As Object
            Try
                value = client.GetPropertyValue("", "OPCLabs.KitServer.2", "Simulation.Random", DAPropertyIds.Timestamp)
            Catch opcException As OpcException
                Console.WriteLine("*** Failure: {0}", opcException.GetBaseException().Message)
                Exit Sub
            End Try

            Console.WriteLine(value)
        End Sub
    End Class
End Namespace
// This example shows how to obtain a data type of an OPC item.

using System;
using OpcLabs.BaseLib.ComInterop;
using OpcLabs.EasyOpc.DataAccess;
using OpcLabs.EasyOpc.OperationModel;

namespace DocExamples.DataAccess._EasyDAClient
{
    partial class GetPropertyValue
    {
        public static void DataType()
        {
            // Instantiate the client object.
            var client = new EasyDAClient();

            // Get the value of DataType property; it is a 16-bit signed integer
            short dataType;
            try
            {
                dataType = (short)client.GetPropertyValue("", "OPCLabs.KitServer.2", "Simulation.Random",
                    DAPropertyIds.DataType);
            }
            catch (OpcException opcException)
            {
                Console.WriteLine("*** Failure: {0}", opcException.GetBaseException().Message);
                return;
            }
            // Convert the data type to VarType
            var varType = (VarType)dataType;

            // Display the obtained data type
            Console.WriteLine("DataType: {0}", dataType);   // Display data type as numerical value
            Console.WriteLine("VarType: {0}", varType);     // Display data type symbolically

            // Code below illustrates how decisions can be made based on type
            switch (varType.InternalValue)
            {
                case VarTypes.R8:
                    Console.WriteLine("The data type is VarTypes.R8, as we expected.");
                    break;

                // other cases may come here ...

                default:
                    Console.WriteLine("The data type is not as we expected!");
                    break;
            }
        }
    }
}
' This example shows how to obtain a data type of an OPC item.

Imports OpcLabs.BaseLib.ComInterop
Imports OpcLabs.EasyOpc.DataAccess
Imports OpcLabs.EasyOpc.OperationModel

Namespace DocExamples.DataAccess._EasyDAClient
    Partial Friend Class GetPropertyValue
        Public Shared Sub DataType()
            Dim client = New EasyDAClient()

            ' Get the value of DataType property; it is a 16-bit signed integer
            Dim aDataType As Short
            Try
                aDataType = CShort(Fix(client.GetPropertyValue("", "OPCLabs.KitServer.2", "Simulation.Random", DAPropertyIds.DataType)))
            Catch opcException As OpcException
                Console.WriteLine("*** Failure: {0}", opcException.GetBaseException().Message)
                Exit Sub
            End Try

            ' Convert the data type to VarType
            Dim varType = CType(aDataType, VarType)

            ' Display the obtained data type
            Console.WriteLine("DataType: {0}", aDataType) ' Display data type as numerical value
            Console.WriteLine("VarType: {0}", varType) ' Display data type symbolically

            ' Code below illustrates how decisions can be made based on type
            Select Case varType
                Case VarTypes.R8
                    Console.WriteLine("The data type is VarTypes.R8, as we expected.")

                    ' other cases may come here ...

                Case Else
                    Console.WriteLine("The data type is not as we expected!")
            End Select
        End Sub
    End Class
End Namespace
Requirements

Target Platforms: .NET Framework: Windows 10 (selected versions), Windows 11 (selected versions), Windows Server 2012, Windows Server 2016; .NET Core, .NET 5, .NET 6: Linux, macOS, Microsoft Windows

See Also

Reference

IEasyDAClientExtension Class
IEasyDAClientExtension Members
Overload List