Professional OPC
Development Tools

logos

Live Mapping Development Model

The Live Mapping model of QuickOPC allows you to write OPC client objects that correspond logically to a functionality provided by whatever is “behind” the OPC data. For example, if part of your application works with a boiler, it is natural for you to create a boiler object in the code (sometimes called "POCO" - Plain Old CLR Object). You then describe how your objects and their members correspond to OPC data – this is done using attributes to annotate your objects. Using Live Mapping methods, you then map your objects to OPC data, and perform OPC operations on them.

When you subscribe to OPC items, incoming OPC item changes can directly set corresponding properties in your objects, without any further coding. Similarly for reads, writes etc. You can then focus on creating the code that handles these property changes, abstracting away the fact how they come in.

The live mapping can be combined with other OPC client development models, such as the traditional imperative programming, in the same project.

Live Mapping Example

Here is a piece of code of a .NET object annotated for live mapping with OPC Data Access, in C# (this is part of a larger example; not all code is shown here):

 [DAType]                                                             
 class BoilerInputPipe                                                
 {                                                                    
     [DANode]                                                         
     public FlowTransmitter FlowTransmitter1 = new FlowTransmitter(); 
                                                                      
     [DANode]                                                         
     public Valve Valve = new Valve();                                
                                                                      
     [DANode, DAItem]                                                 
     public bool InAlarm { get; set; }                                
 }                                                                    

If you want to subscribe to changes occurring in the boiler, and have the properties in your object automatically updates with new values, you can do it as below. When, e.g., the InAlarm OPC item changes its value, the InAlarm property on the BoilerInputPipe obect will be set to a new value, and a correspoding code will run.

 var mapper = new DAClientMapper();                                                        
 var boiler1 = new Boiler();                                                         
 mapper.Map(boiler1, new DAMappingContext                                            
     {                                                                               
         ServerDescriptor = "OPCLabs.KitServer.2",   // local OPC server             
         // The NodeDescriptor below determines where in the OPC address space       
         // we want to map our data to.                                              
         NodeDescriptor = new DANodeDescriptor { BrowsePath = "/Boilers/Boiler #1"}, 
         GroupParameters = 1000,  // requested update rate (for subscriptions)       
     });                                                                             
                                                                                     
 mapper.Subscribe(/*active:*/true);                                                  

You can already see some of the benefits of the live mapping in this simple example. The code that you write can focus on the logic of the application, and works directly with members of your .NET objects. You do not have to clutter your code with OPC-specific information such as server and item IDs. It also gets very easy to reuse the mapped types: If you had more boilers that are represented identically in the OPC address space, you can simply create more Boiler objects and map them all, without a need to change anything in the definition of the Boiler class.

With live mapping model, you generally need to do following steps in order:

  1. Write classes that are a logical model of your application. If you are following object-oriented principles in your design, chances are that your code already has such classes anyway.
  2. Annotate the classes with attributes for live mapping. The main purpose of these attributes is to describe how the members of your classes correspond to nodes in the OPC address space.
  3. Create instance(s) of your classes, as usually.
  4. Perform the actual mapping, which associates your objects with OPC data.
  5. Call mapping operations as needed, e.g. execute OPC reads, writes, or subscribe to changes in OPC values.

 

Useful links: Documentation / Knowledge Base

Live Mapping Features

Live Mapping works with OPC Data Access ("Classic") and OPC Unified Architecture servers (for data access).
  • You can map to any OPC item, node attribute or property.
  • Different mapping kinds such as Value, Quality, Timestamps, ErrorMessage, and many more.
  • Whole class can be mapped at once, or details can be specified on mapped members individually.
  • Operations on mapped types can be narrowly targeted as needed using mapping tags.
  • Relative OPC browse paths can be used to avoid necessity of mapping to absolute item or node IDs.
  • Meta-members allow to relate the mapped object to its location in the address space, and parameters for operations.
  • Pre-made node classes for easier mapping.
  • Type-less mapping is also possible, for direct correspondence between the .NET members and OPC data.

 

Footnote & required disclosure: QuickOPC (including its Options) is a software development kit (SDK) for development of OPC clients and subscribers. Installing QuickOPC or its Options does not change system settings.