Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Vorto » Mapping Vorto Model to Target Domain models(A detailed explaination on how to use mapping dsl to map Vorto models to information models)
Mapping Vorto Model to Target Domain models [message #1703365] Fri, 31 July 2015 06:42
Luke Liao is currently offline Luke LiaoFriend
Messages: 2
Registered: July 2015
Junior Member
Vorto mapping model supports mapping Vorto models (Information Model/Function Block/Data Types) to other domain models. In this post I will try to explain with examples on how it can be done.

Note*: You may find a models used in this mapping examples as attachment.

Mapping Rule Syntax

Basic mapping rule Syntax is as explained below:
'from' (ModelElement)* 'to' (StereoType ('with {' attributes+=Attribute (',' attributes+=Attribute)* '}')?)*


  • ModelElement: Model elements represents attributes, properties of a Vorto model
  • 2 StereoType: Stereo Type represents a target platform model type. It may contains zero or many attributes.


Mapping an information model attributes
from MyDevice.category  to TargetModel with { Component: "Abc"}


Mapping an information model function block instance

from MyDevice.functionBlock1 to TargetFunctionBlock with {ItemID: "1"}


Mapping child elements of information model
from MyDevice.functionBlock1.operation.on to TargetFunctionBlock with {Operation: "Start"}
from MyDevice.functionBlock1.status.brightnessLevel to TargetStatus with {Attribute : "brightness", type : "Number" }


Similarly, you can create a function block model.

Mapping function block attributes
from MyFunctionBlock.displayname to TargetResource with { Display: "Abc"}
from MyFunctionBlock.status.brightnessLevel to TargetStatus with {Attribute : "brightness", type : "Number" }


Or you can create a mapping for entity
from EntityA to TargetEntity with { Attribute1 : "d1", Attribute2 : "d2" }
from EntityA.paramRefEntityB.paramRefEntityC.paramRefEntityD to TargetNestedEntity


You can even combine different type of models in one mapping definition (Please refer to example code below). Alternatively, as mapping model extends model, you can import other mapping model use 'using' statement.
namespace com.mycompany
version 1.0.0
using com.mycompany.MyDevice ; 1.0.0
using com.mycompany.MyFunctionBlock ; 1.0.0
using com.mycompany.type.EntityA ; 1.0.0
using com.mycompany.type.EnumA ; 1.0.0
mapping MyPlatformMapping {
 
    from MyDevice
    to targetdevice with { Attribute1 : "i1", Attribute2 : "i2" }
 
    from MyDevice.name
    to DummyTarget
 
    from MyDevice.namespace
    to DummyTarget
 
    from MyDevice.version
    to DummyTarget
 
    from MyDevice.description
    to DummyTarget
 
    from MyDevice.category
    to DummyTarget
 
    from MyDevice.displayname
    to DummyTarget
 
    from MyDevice.myfunctionblock
    to targetFunctionBlock
 
    from MyDevice.myfunctionblock.name
    to DummyTarget
 
    from MyDevice.myfunctionblock.configuration.entityAParam.name
    to param
 
    from MyDevice.myfunctionblock.configuration.entityAParam.paramRefEntityB
    to param
 
    functionblock {
 
        from MyFunctionBlock
        to DummyTarget with { Attribute1 : "f1", Attribute2 : "f2" }
 
        from MyFunctionBlock.category
        to DummyTarget
 
        from MyFunctionBlock.operation.off
        to TargetOperation
 
        from MyFunctionBlock.configuration.entityAParam
        to DummyTarget
 
        from MyFunctionBlock.status.entityAParam
        to DummyTarget
 
        from MyFunctionBlock.status.entityAParam.paramRefEntityB
        to DummyTarget
 
        from MyFunctionBlock.status.enumAParam
        to TargetEnum
 
        from MyFunctionBlock.status.enumAParam.name
        to TargetEnumName
    }
 
    datatype {
         
        from EntityA
        to DummyTarget with { Attribute1 : "d1", Attribute2 : "d2" }
 
        from EntityA.name
        to aDummyTarget
 
        from EntityA.version
        to DummyTarget
 
        from EntityA.paramRefEntityB.paramRefEntityC.paramRefEntityD
        to DummyTarget
 
        from EnumA
        to DummyTarget with { Value1 : "dummy value 1", Value2 : "dummy value 2" }
 
        from EnumA.name
        to Dummy
    }
}


Example Mapping from Vorto to LightWeightM2M Model

Here is a example mapping model to LWM2M Object Model.

namespace org.openmobilealliance
version 1.0.0
using com.mycompany.DjiPhantomVision ; 3.0.0-Plus
using com.mycompany.fb.Drone ; 1.0.0
using com.mycompany.fb.Switcher ; 1.0.0
mapping LWM2M {
    from DjiPhantomVision
    to ObjectType with {
    Type : "MODefinition", Name : "Location", ObjectID : "6", ObjectURN : "TBD", MultipleInstances : "Single", Mandatory : "Optional"
    }
    functionblock {
        from Drone.status.location.latitude
        to Resource with { ItemID : "0", Units : "deg" }
        from Drone.status.location.longitude
        to Resource with { ItemID : "1", Units : "deg" }
        from Drone.status.location.altitude
        to Resource with { ItemID : "2", Units : "m" }
         
        from Drone.operation.ascend,Switcher.operation.on to Resource with {ItemID : "0", Operations : "R"}
    }
}

Lastly, please find all models used in this document in attached file.

  • Attachment: lwm2m.zip
    (Size: 1.97KB, Downloaded 171 times)
  • Attachment: mydevice.zip
    (Size: 2.88KB, Downloaded 150 times)
Previous Topic:Relation to OPC UA Information Model
Next Topic:Vorto documentation
Goto Forum:
  


Current Time: Fri Apr 26 13:31:06 GMT 2024

Powered by FUDForum. Page generated in 0.02962 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top