How to propagate code changes into the model

February 16, 2018

If you frequently modify generated C++ code outside Model RealTime, you can propagate the changes made back to the model by means of a special command which runs code-to-model synchronization. It is present in the context menu of a transformation configuration in the Project Explorer, as well as on a generated target project.

A dialog lists available options for synchronization. If you want to review each change that will be propagated, you should unmark the “Silent synchronization” checkbox. In case your workspace contains models that are not loaded, you should review available loading options.

The code-to-model synchronization console will appear once the synch process is started. It will report all updated code snippets and the final status.

13:25:45 : Starting code to model synchronization
13:25:45 : Refreshing resources
13:25:45 : Found 14 resource to process
13:25:45 : Updating code snippet: platform:/resource/CodeToModelSynch/CodeToModelSynch.emx#_BqxywBZdEeGFterdnTTgww
13:25:45 : Qualified name: CodeToModelSynch::Class1::Operation1
13:25:46 : Updating code snippet: platform:/resource/CodeToModelSynch/CodeToModelSynch.emx#_BqxywBZdEeGFterdnTTgww|General|implementationEnding
13:25:46 : Qualified name: CodeToModelSynch::Class1::Operation1
13:25:46 : Updating checksums for /target_new/Class1.cpp
13:25:46 : Synchronization completed
13:25:46 : Updated 2 snippets
13:25:46 : Elapsed time : 980 ms (0 h 0 min 0 sec)
13:25:46 : Log file : C:\Workspace\runtime-oxygen\sync.log

If you want to automate the synchronization process, Model RealTime provides an Ant task. Here is an example how it can be invoked:

<project name="myProject" default="sync" basedir=".">
<target name = "sync">
<record name="sync.log" loglevel="verbose" action="start" />
<com.ibm.xtools.umldt.rt.transform.cpp.codeSync   
    transformConfig="/MyProject/HellowWorld.tc">
</com.ibm.xtools.umldt.rt.transform.cpp.codeSync>
</target>
</project>

The Ant task supports the following attributes:

[projects]
MyProject1=C:\Workspace\runtime-oxygen\CodeToModelSynch
[sources]
C:\Workspace\runtime-oxygen\target

All attributes are optional but one of transformConfig or mapFile must be set (but not both at the same time). If you run the code-to-model synchronization Ant task outside of Model RealTime, make sure to use the org.eclipse.ant.ui.antRunner application. The command-line should be like this:

C:\model-realtime\eclipse\eclipse.exe -nosplash -application org.eclipse.ant.ui.antRunner -data C:\empty-workspace -buildfile C:\temp\cm_synch.ant synch

More detailed information about this feature can be found here. Still have questions? Mail us: model-realtime@hcl-software.com