// 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.
# The QuickOPC package is needed. Install it using "pip install opclabs_quickopc".
import opclabs_quickopc
# Import .NET namespaces.
from OpcLabs.EasyOpc.DataAccess import *
from OpcLabs.EasyOpc.OperationModel import *
# Instantiate the client object
client = EasyDAClient()
# Perform the operation
try:
value = IEasyDAClientExtension.GetPropertyValue(client,
'', 'OPCLabs.KitServer.2', 'Simulation.Random', DAPropertyId(DAPropertyIds.Timestamp))
except OpcException as opcException:
print('*** Failure: ' + opcException.GetBaseException().Message)
exit()
# Display results
print('value: ', value, sep='')
' 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 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