Transformations are an important part of Time4Sys. They enable the derivation of model into a (usually) simpler analysable model. A transformation is thus a resulting transformed model but also a Mapping linking the elements of the original model to the elements of the resulting model. Transformation are not limited of Design to Design, but from any model to any model, eg from a Simulation to a Design.
Some examples of transformations are:
org.polarsys.time4sys.transformations.PriorityUrgencyInverter
.org.polarsys.time4sys.transformations.TaskSplitter
.org.polarsys.time4sys.transformations.ToPeriodicDerivation
.Another related model transformation is the org.polarsys.time4sys.transformations.RemoveAndReplaceDeprecated
.
It is not really a Time4Sys Transformation because it modify
in-place the model by removing deprecated model elements.
The org.polarsys.time4sys.transformations.IdentityDerivation
is based on a modified version of the org.eclipse.emf.ecore.util.EcoreUtil.Copier
.
It does indeed copy the original model but it also create a mapping model from original to copied elements. This identity transformation has been derived in an AbstractTransformation
class so as to make it easy to track Link from an original element to a copied element that would require further processing.
You thus shall derived your transformation from the org.polarsys.time4sys.transformations.AbstractTransformation
class.
For instance, the PriorityUrgencyInverter
works in two-phases. In the first phase, it uses the void copied(EObject source, Link lnk, EObject theCopy)
hook to keep the list of Links that will need to be further modified but also track the minimum and maximum values used. In the second phase, the transformation iterates over the tracked links and modified the target as expected. It is done in the void finalize(final DesignModel target)
hook.
While it is possible to modified the target model during the first phase, it might be easier to do it in the second one, especially when creating new Links. For instance, the TaskDuplicator (that duplicate the task configuration for each original steps) is the easier non-trivial transformation to study.
EcoreUtil.Copier
), update rationale of the link and its targets, and finally deletes the first copied Task (because it shall be orphan now, ie contains no step).