Example: Find pattern matches in railway models using EPL

pattern ConnectedSegments
  sensor : Sensor

  in: Sensor.all.select(s|s.monitors.select(s:Segment|true).size() > 5),

  segment1 : Segment from: sensor.monitors,
  segment2 : Segment from: segment1.connectsTo.select(s|s.monitoredBy.includes(sensor)),
  segment3 : Segment from: segment2.connectsTo.select(s|s.monitoredBy.includes(sensor)),
  segment4 : Segment from: segment3.connectsTo.select(s|s.monitoredBy.includes(sensor)),
  segment5 : Segment from: segment4.connectsTo.select(s|s.monitoredBy.includes(sensor)),
  segment6 : Segment from: segment5.connectsTo.select(s|s.monitoredBy.includes(sensor)) {

  do {
    Sequence {
      sensor,
      segment1, segment2, segment3,
      segment4, segment5, segment6
    }.println('ConnectedSegments: ');
  }

}

pattern PosLength
  segment : Segment in: Segment.all.select(s|s.length <= 0) {

  do {
    segment.println('PosLength: ');
  }
}

pattern RouteSensor
  route: Route,
  swP: SwitchPosition from: route.follows,
  sw: Switch from: swP.target,
  sensor: Sensor from: sw.monitoredBy.select(s|route.gathers.excludes(s))
{
  do {
    Sequence {
      route, swP, sw, sensor
    }.println('RouteSensor: ');
  }
}

pattern SwitchMonitored
  sw : Switch from: Switch.all.select(sw|sw.monitoredBy.size = 0) {

  do {
    sw.println('SwitchMonitored: ');
  }
}

pattern SwitchSet
  route: Route,
  semaphore: Semaphore from: route.entry.select(e | e.isDefined() and e.signal = 'GO'),
  swP: SwitchPosition from: route.follows,
  sw: Switch from: swP.target.select(t | t.currentPosition <> swP.position)
{
  do {
    Sequence {
      route, semaphore, swP, sw
    }.println('SwitchSet: ');
  }
}

Clone Epsilon's Git repository and then:

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

  1. register all .ecore metamodels in the org.eclipse.epsilon.examples.metamodels project (select all of them and then right click and select Register EPackages)
  2. register any .ecore metamodels in the org.eclipse.epsilon.examples.epl project
  3. right click the .launch file in the org.eclipse.epsilon.examples.epl project
  4. select Run as... and click the first item in the menu that pops up

What's this?

In this example we demonstrate how to find matches of the patterns in the Train Benchmark models with EPL.

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
Epsilon Model Generation Language
Epsilon Pattern Language
Combining the Epsilon Languages
EuGENia
EUnit

Even more examples...

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