OPC Studio User's Guide and Reference
Examples - Live Mapping - Define OPC DA type-less mapping and read

The example below shows how to define a new type-less mapping which maps a specified OPC-DA item to the Value member of your target MyClass object. The mapper is then instructed to invoke the OPC read operation, which will in turn store the OPC item’s value to your target object.

// Instantiate the client mapper object.
var mapper = new DAClientMapper();

var target = new MyClass2();

// Define a type-less mapping.

mapper.DefineMapping(
     new DAClientItemSource("OPCLabs.KitServer.2", "Simulation.Register_I4", DADataSource.Cache),
     new DAClientItemMapping(typeof(Int32)),
     new ObjectMemberLinkingTarget(target.GetType(), target, "Value"));

// Perform a read operation.
mapper.Read();

Public Shared Sub Main1()
    Dim mapper = New DAClientMapper()
    Dim target = New MyClass2()

    ' Define a type-less mapping.

    mapper.DefineMapping( _
             New DAClientItemSource( _
                 "OPCLabs.KitServer.2",
                 "Simulation.Register_I4",
                 New DAReadParameters(DADataSource.Cache)),
             New DAClientItemMapping(GetType(Int32)),
             New ObjectMemberLinkingTarget(target.GetType(), target, "Value"))

    ' Perform a read operation.
    mapper.Read()

    ' Display the result.
    Console.WriteLine(target.Value)
End Sub

 

See Also

Concepts

Examples - Client OPC Data Access