Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions uk.ac.kcl.inf.gts_morpher.examples/src/pls.ecore
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,10 @@
<eClassifiers xsi:type="ecore:EClass" name="Hammer" eSuperTypes="#//Part"/>
<eClassifiers xsi:type="ecore:EClass" name="Head" eSuperTypes="#//Part"/>
<eClassifiers xsi:type="ecore:EClass" name="Handle" eSuperTypes="#//Part"/>
<eClassifiers xsi:type="ecore:EClass" name="PLSModel">
<eStructuralFeatures xsi:type="ecore:EReference" name="machines" upperBound="-1"
eType="#//Machine" containment="true"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="containers" upperBound="-1"
eType="#//Container" containment="true"/>
</eClassifiers>
</ecore:EPackage>
2 changes: 1 addition & 1 deletion uk.ac.kcl.inf.gts_morpher.examples/src/pls.henshin_diagram
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<notation:Diagram xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:henshin="http://www.eclipse.org/emf/2011/Henshin" xmlns:notation="http://www.eclipse.org/gmf/runtime/1.0.2/notation" xmi:id="_teZqEBJqEeiGBuuAusJIMQ" type="Henshin" measurementUnit="Pixel">
<notation:Diagram xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:henshin="http://www.eclipse.org/emf/2011/Henshin" xmlns:notation="http://www.eclipse.org/gmf/runtime/1.0.3/notation" xmi:id="_teZqEBJqEeiGBuuAusJIMQ" type="Henshin" measurementUnit="Pixel">
<children xmi:type="notation:Shape" xmi:id="_a7D1QBJrEeiGBuuAusJIMQ" type="2001" fontName="Segoe UI" italic="true" lineColor="0">
<eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_dD9bcxJrEeiGBuuAusJIMQ" source="defaultAction">
<details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_dD9bdBJrEeiGBuuAusJIMQ" key="value" value="create"/>
Expand Down
11 changes: 11 additions & 0 deletions uk.ac.kcl.inf.gts_morpher.examples/src/server.ecore
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,15 @@
<eClassifiers xsi:type="ecore:EClass" name="Output" eSuperTypes="#//Element">
<eAnnotations source="Interface"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="ServerModel">
<eAnnotations source="Interface"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="servers" upperBound="-1"
eType="#//Server" containment="true">
<eAnnotations source="Interface"/>
</eStructuralFeatures>
<eStructuralFeatures xsi:type="ecore:EReference" name="queues" upperBound="-1"
eType="#//Queue" containment="true">
<eAnnotations source="Interface"/>
</eStructuralFeatures>
</eClassifiers>
</ecore:EPackage>
1 change: 1 addition & 0 deletions uk.ac.kcl.inf.gts_morpher.examples/src/server_polish.gts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ auto-complete unique map Server2PLS {
class server.Server => pls.Polisher
class server.InputQueue => pls.Tray
class server.OutputQueue => pls.Conveyor
reference server.ServerModel.servers => pls.PLSModel.machines
}
}

Expand Down
6 changes: 3 additions & 3 deletions uk.ac.kcl.inf.gts_morpher.tests/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4">
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="test" value="true"/>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package uk.ac.kcl.inf.gts_morpher.tests;

import java.lang.reflect.InvocationTargetException;

import org.hamcrest.Description;
import org.hamcrest.Factory;
import org.hamcrest.Matcher;
import org.hamcrest.TypeSafeMatcher;

/* Matches any class that has a <code>size()</code> method
* that returns an <code>int</code> */
public class HasSize<T> extends TypeSafeMatcher<T>
{
@Factory
public static <T> Matcher<T> hasSize(int val)
{
return new HasSize<T>(val);
}

private int val;

private HasSize(int val) {
this.val = val;
}

@Override
protected boolean matchesSafely(final T item)
{
try { return ((int) item.getClass().getMethod("size", (Class<?>[]) null).invoke(item) == val); }
catch (final NoSuchMethodException e) { return false; }
catch (final InvocationTargetException | IllegalAccessException e) { throw new RuntimeException(e); }
}

@Override
public void describeTo(final Description description) { description.appendText("is of size " + val); }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package uk.ac.kcl.inf.gts_morpher.tests;

import java.lang.reflect.InvocationTargetException;

import org.hamcrest.Description;
import org.hamcrest.Factory;
import org.hamcrest.Matcher;
import org.hamcrest.TypeSafeMatcher;

/* Matches any class that has an <code>isEmpty()</code> method
* that returns a <code>boolean</code> */
public class IsEmpty<T> extends TypeSafeMatcher<T>
{
@Factory
public static <T> Matcher<T> empty()
{
return new IsEmpty<T>();
}

@Override
protected boolean matchesSafely(final T item)
{
try { return (boolean) item.getClass().getMethod("isEmpty", (Class<?>[]) null).invoke(item); }
catch (final NoSuchMethodException e) { return false; }
catch (final InvocationTargetException | IllegalAccessException e) { throw new RuntimeException(e); }
}

@Override
public void describeTo(final Description description) { description.appendText("is empty"); }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package uk.ac.kcl.inf.gts_morpher.tests;

import org.hamcrest.Description;
import org.hamcrest.Factory;
import org.hamcrest.Matcher;
import org.hamcrest.TypeSafeMatcher;

import uk.ac.kcl.inf.gts_morpher.gtsMorpher.GTSTraceMember;
import uk.ac.kcl.inf.gts_morpher.modelcaster.GTSTrace;

/* Checks trace equality */
public class IsTraceWith extends TypeSafeMatcher<GTSTrace>
{
@Factory
public static Matcher<GTSTrace> isTraceWith(GTSTraceMember... members)
{
return new IsTraceWith(members);
}

private GTSTraceMember[] members;

private IsTraceWith(GTSTraceMember... members) {
this.members = members;
}

@Override
protected boolean matchesSafely(final GTSTrace item)
{
if (item.size() == members.length) {
for (int i = 0; i < item.size(); i++) {
if (item.get(i) != members[i]) {
return false;
}
}

return true;
} else {
return false;
}
}

@Override
public void describeTo(final Description description) { description.appendText("is trae of " + members); }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="devsmm" nsURI="http://devsmm/1.0" nsPrefix="devsmm">
<eClassifiers xsi:type="ecore:EClass" name="Machine">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="pt" lowerBound="1" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="defective_rate" lowerBound="1"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="in" eType="#//Tray"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="out" lowerBound="1" eType="#//Conveyor"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Generator" eSuperTypes="#//Machine">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="counter" lowerBound="1"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="GenHead" eSuperTypes="#//Generator"/>
<eClassifiers xsi:type="ecore:EClass" name="GenHandle" eSuperTypes="#//Generator"/>
<eClassifiers xsi:type="ecore:EClass" name="Assemble" eSuperTypes="#//Machine"/>
<eClassifiers xsi:type="ecore:EClass" name="Container">
<eStructuralFeatures xsi:type="ecore:EReference" name="parts" upperBound="-1"
eType="#//Part" containment="true"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Tray" eSuperTypes="#//LimitedContainer"/>
<eClassifiers xsi:type="ecore:EClass" name="User" eSuperTypes="#//Container"/>
<eClassifiers xsi:type="ecore:EClass" name="Conveyor" eSuperTypes="#//LimitedContainer">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="speed" lowerBound="1" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="out" lowerBound="1" eType="#//Tray"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="outParts" upperBound="-1"
eType="#//Part" containment="true"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="LimitedContainer" eSuperTypes="#//Container">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="capacity" lowerBound="1"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Part">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="defective" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBoolean"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Head" eSuperTypes="#//Part"/>
<eClassifiers xsi:type="ecore:EClass" name="Handle" eSuperTypes="#//Part"/>
<eClassifiers xsi:type="ecore:EClass" name="Hammer" eSuperTypes="#//Part"/>
<eClassifiers xsi:type="ecore:EClass" name="DEVSModel">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="machines" upperBound="-1"
eType="#//Machine" containment="true"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="containers" upperBound="-1"
eType="#//Container" containment="true"/>
</eClassifiers>
</ecore:EPackage>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<devsmm:DEVSModel
xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:devsmm="http://devsmm/1.0"
xsi:schemaLocation="http://devsmm/1.0 DEVSMM.ecore"
name="devsmodel">
<machines
xsi:type="devsmm:GenHead"
out="//@containers.1"/>
<containers
xsi:type="devsmm:Tray"/>
<containers
xsi:type="devsmm:Conveyor"
out="//@containers.0"/>
</devsmm:DEVSModel>
Loading