Example: Migrate Petri net models with Epsilon Flock

migrate Transition {
  for (source in original.src) {
    var arc = new Migrated!PTArc;
    arc.src = source.equivalent();
    arc.dst = migrated;
    arc.net = migrated.net;
  }
  
  for (destination in original.dst) {
    var arc = new Migrated!TPArc;
    arc.src = migrated;
    arc.dst = destination.equivalent();
    arc.net = migrated.net;
  }
}
@namespace(uri="petrinets1", prefix="petrinets1")
package petrinets;

class Net {
   val Place[*]#net places;
   val Transition[*]#net transitions;
}

class Place {
  ref Net[1]#places net;
   attr String name;
   
   ref Transition[*]#dst src;
   ref Transition[*]#src dst;
}

class Transition {
  ref Net[1]#transitions net;
  attr String name;
  
  ref Place[1..*]#dst src;
   ref Place[1..*]#src dst;
}
@namespace(uri="petrinets2", prefix="petrinets2")
package petrinets;

class Net {
   val Place[*]#net places;
   val Transition[*]#net transitions;
   val Arc[*]#net arcs;
}

class Place {
  ref Net[1]#places net;
   attr String name;
   
   ref TPArc[*]#dst in;
   ref PTArc[*]#src out;
}

class Transition {
  ref Net[1]#transitions net;
  attr String name;
  
  ref PTArc[1..*]#dst in;
   ref TPArc[1..*]#src out;
}


abstract class Arc {
   ref Net[1]#arcs net;
}

class PTArc extends Arc {
   ref Place[1]#out src;
   ref Transition[1]#in dst;
}

class TPArc extends Arc {
   ref Transition[1]#out src;
   ref Place[1]#in dst;
}

Check out the code from the SVN:

  • go to the SVN repository
  • navigate to trunk/examples
  • check out the org.eclipse.epsilon.examples.flock.petrinets project

Once you have checked out/imported the code, to run the example you need to go through the following steps:

  1. register any .ecore metamodels in the org.eclipse.epsilon.examples.flock.petrinets project
  2. right click the .launch file in the org.eclipse.epsilon.examples.flock.petrinets project
  3. select Run as... and click the first item in the menu that pops up

What's this?

In this example we demonstrate how to migrate a model in response to metamodel changes with Epsilon Flock.

What are .emf files?

.emf files are Ecore metamodels expressed using the Emfatic textual syntax.

More examples...

Epsilon Object Language
Epsilon Transformation Language
Epsilon Generation Language
Epsilon Validation Language
Epsilon Merging Language
Epsilon Flock
Combining the Epsilon Languages
EuGENia
EUnit

Even more examples...

More examples are available in the examples folder of the SVN repository.