Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEd Willink2017-02-09 07:15:06 -0500
committerEd Willink2017-02-10 06:09:17 -0500
commitf079ab89bcb687d25b76a20d2c62f61fc587c248 (patch)
treef646214c9b53b69c1581dff77f93156a6fd0521b
parente36928f2a2dac202a57cd83e4d543084eb531a63 (diff)
downloadorg.eclipse.qvtd-ewillink/511782.tar.gz
org.eclipse.qvtd-ewillink/511782.tar.xz
org.eclipse.qvtd-ewillink/511782.zip
[509858] Refine PN2SCewillink/511782
-rw-r--r--tests/org.eclipse.qvtd.doc.exe2016.tests/src/org/eclipse/qvtd/doc/exe2016/tests/atl/Forward2Reverse.atl6
-rw-r--r--tests/org.eclipse.qvtd.umlx.tests/src/org/eclipse/qvtd/umlx/tests/UMLXSerializeTests.java2
-rw-r--r--tests/org.eclipse.qvtd.xtext.qvtrelation.tests/src/org/eclipse/qvtd/xtext/qvtrelation/tests/forward2reverse/.gitignore1
-rw-r--r--tests/org.eclipse.qvtd.xtext.qvtrelation.tests/src/org/eclipse/qvtd/xtext/qvtrelation/tests/forward2reverse/Forward2Reverse.qvtr4
-rw-r--r--tests/org.eclipse.qvtd.xtext.qvtrelation.tests/src/org/eclipse/qvtd/xtext/qvtrelation/tests/pn2sc/.gitignore1
-rw-r--r--tests/org.eclipse.qvtd.xtext.qvtrelation.tests/src/org/eclipse/qvtd/xtext/qvtrelation/tests/pn2sc/PetriNet2StateChart.qvtr200
6 files changed, 207 insertions, 7 deletions
diff --git a/tests/org.eclipse.qvtd.doc.exe2016.tests/src/org/eclipse/qvtd/doc/exe2016/tests/atl/Forward2Reverse.atl b/tests/org.eclipse.qvtd.doc.exe2016.tests/src/org/eclipse/qvtd/doc/exe2016/tests/atl/Forward2Reverse.atl
index 7f43f4680..188e94d12 100644
--- a/tests/org.eclipse.qvtd.doc.exe2016.tests/src/org/eclipse/qvtd/doc/exe2016/tests/atl/Forward2Reverse.atl
+++ b/tests/org.eclipse.qvtd.doc.exe2016.tests/src/org/eclipse/qvtd/doc/exe2016/tests/atl/Forward2Reverse.atl
@@ -28,7 +28,7 @@ rule element2element {
to
reverseElement : ReverseList!Element (
name <- forwardElement.name,
- list <- forwardElement.list,
- source <- forwardElement.target
+ list <- forwardElement.list, -- resolveTemp
+ source <- forwardElement.target -- resolveTemp
)
-} \ No newline at end of file
+}
diff --git a/tests/org.eclipse.qvtd.umlx.tests/src/org/eclipse/qvtd/umlx/tests/UMLXSerializeTests.java b/tests/org.eclipse.qvtd.umlx.tests/src/org/eclipse/qvtd/umlx/tests/UMLXSerializeTests.java
index eb2a4f815..68535a89a 100644
--- a/tests/org.eclipse.qvtd.umlx.tests/src/org/eclipse/qvtd/umlx/tests/UMLXSerializeTests.java
+++ b/tests/org.eclipse.qvtd.umlx.tests/src/org/eclipse/qvtd/umlx/tests/UMLXSerializeTests.java
@@ -304,7 +304,7 @@ public class UMLXSerializeTests extends LoadTestCase
public void testUMLXRoundtrip_Forward2Reverse_qvtr() throws Exception {
URI inputURI1 = URI.createPlatformResourceURI("/org.eclipse.qvtd.xtext.qvtrelation.tests/src/org/eclipse/qvtd/xtext/qvtrelation/tests/forward2reverse/Forward2Reverse.qvtr", true);
URI pivotURI1 = getProjectFileURI("Forward2Reverse.qvtras");
- URI umlxURI = getProjectFileURI("Forward2Reverse.umlx");
+ URI umlxURI = URI.createPlatformResourceURI("/org.eclipse.qvtd.xtext.qvtrelation.tests/src/org/eclipse/qvtd/xtext/qvtrelation/tests/forward2reverse/Forward2Reverse.umlx", true);
URI pivotURI2 = getProjectFileURI("Forward2Reverse.regenerated.qvtras");
doRoundTripTest(inputURI1, pivotURI1, umlxURI, pivotURI2, false);
}
diff --git a/tests/org.eclipse.qvtd.xtext.qvtrelation.tests/src/org/eclipse/qvtd/xtext/qvtrelation/tests/forward2reverse/.gitignore b/tests/org.eclipse.qvtd.xtext.qvtrelation.tests/src/org/eclipse/qvtd/xtext/qvtrelation/tests/forward2reverse/.gitignore
new file mode 100644
index 000000000..76a7da0f0
--- /dev/null
+++ b/tests/org.eclipse.qvtd.xtext.qvtrelation.tests/src/org/eclipse/qvtd/xtext/qvtrelation/tests/forward2reverse/.gitignore
@@ -0,0 +1 @@
+/Forward2Reverse.umlx
diff --git a/tests/org.eclipse.qvtd.xtext.qvtrelation.tests/src/org/eclipse/qvtd/xtext/qvtrelation/tests/forward2reverse/Forward2Reverse.qvtr b/tests/org.eclipse.qvtd.xtext.qvtrelation.tests/src/org/eclipse/qvtd/xtext/qvtrelation/tests/forward2reverse/Forward2Reverse.qvtr
index 1c6007a3e..cbfc28f9d 100644
--- a/tests/org.eclipse.qvtd.xtext.qvtrelation.tests/src/org/eclipse/qvtd/xtext/qvtrelation/tests/forward2reverse/Forward2Reverse.qvtr
+++ b/tests/org.eclipse.qvtd.xtext.qvtrelation.tests/src/org/eclipse/qvtd/xtext/qvtrelation/tests/forward2reverse/Forward2Reverse.qvtr
@@ -23,7 +23,7 @@ package org::eclipse::qvtd::xtext::qvtrelation::tests::forward2reverse {
* Map each hierarchical StateMachine to a flat StateMachine
*/
top relation list2list {
- listName : String;
+ listName : String[1];
domain forward forwardList : DoublyLinkedList {
name = listName
};
@@ -50,7 +50,7 @@ package org::eclipse::qvtd::xtext::qvtrelation::tests::forward2reverse {
* Map each Leaf State to a Flat State in the corresponding StateMachine.
*/
top relation element2element {
- elementName : String;
+ elementName : String[1];
domain forward forwardElement : Element {
list = forwardList : DoublyLinkedList{},
name = elementName,
diff --git a/tests/org.eclipse.qvtd.xtext.qvtrelation.tests/src/org/eclipse/qvtd/xtext/qvtrelation/tests/pn2sc/.gitignore b/tests/org.eclipse.qvtd.xtext.qvtrelation.tests/src/org/eclipse/qvtd/xtext/qvtrelation/tests/pn2sc/.gitignore
new file mode 100644
index 000000000..34a1b98c2
--- /dev/null
+++ b/tests/org.eclipse.qvtd.xtext.qvtrelation.tests/src/org/eclipse/qvtd/xtext/qvtrelation/tests/pn2sc/.gitignore
@@ -0,0 +1 @@
+/PetriNet2StateChart.umlx
diff --git a/tests/org.eclipse.qvtd.xtext.qvtrelation.tests/src/org/eclipse/qvtd/xtext/qvtrelation/tests/pn2sc/PetriNet2StateChart.qvtr b/tests/org.eclipse.qvtd.xtext.qvtrelation.tests/src/org/eclipse/qvtd/xtext/qvtrelation/tests/pn2sc/PetriNet2StateChart.qvtr
index 9e14df726..98361d91c 100644
--- a/tests/org.eclipse.qvtd.xtext.qvtrelation.tests/src/org/eclipse/qvtd/xtext/qvtrelation/tests/pn2sc/PetriNet2StateChart.qvtr
+++ b/tests/org.eclipse.qvtd.xtext.qvtrelation.tests/src/org/eclipse/qvtd/xtext/qvtrelation/tests/pn2sc/PetriNet2StateChart.qvtr
@@ -16,8 +16,11 @@ package org::eclipse::qvtd::xtext::qvtrelation::tests::pn2sc {
* Transform a PetriNet into a StateChart.
* See: https://github.com/louismrose/ttc_pn2sc/ and https://arxiv.org/pdf/1312.0342.pdf
*/
- transformation PetriNet2StateChart(pn:pnMM, sc:scMM)
+ transformation PetriNet2StateChart(pn:pnMM, pn1:pnMM, sc1:scMM, pn2:pnMM, sc2:scMM, sc:scMM)
{
+ key scMM::AND{contains};
+ key scMM::OR{contains};
+
top relation Net2StateChart {
domain pn net : Net {};
enforce domain sc statechart : Statechart {
@@ -89,6 +92,201 @@ package org::eclipse::qvtd::xtext::qvtrelation::tests::pn2sc {
Transition2HyperEdge(t, e);
}
}
+
+ top relation Roots2Roots {
+ domain pn1 fromNet : Net{};
+ domain sc1 fromTopState : AND{Statechart = fromStatechart : Statechart{}};
+ enforce domain pn2 toNet : Net{};
+ enforce domain sc2 toTopState : AND{Statechart = toStatechart : Statechart{}};
+ }
+
+ /**
+ * Return the maximal Set of Places that can be ANDed with a given Place.
+ * An AND of shared post-Transitions is preferred to an AND of shared pre-Transitions.
+ * Returns an empty Set if no AND is possible.
+ */
+ query getAndSet(place : pnMM::Place) : OrderedSet(pnMM::Place) {
+ let preTransitions = place.pret->asOrderedSet() in
+ let postTransitions = place.postt->asOrderedSet() in
+ let prePostPlaces = preTransitions.postp->asOrderedSet() in
+ let postPrePlaces = postTransitions.prep->asOrderedSet() in
+ if postPrePlaces->forAll(p | p.postt = postTransitions) and prePostPlaces->forAll(p | p.pret->includesAll(preTransitions)) then postPrePlaces
+ elseif prePostPlaces->forAll(p | p.pret = preTransitions) and postPrePlaces->forAll(p | p.postt->includesAll(postTransitions)) then prePostPlaces
+ else OrderedSet{}
+ endif
+ }
+
+ /**
+ * Return the first pair of Places that can be ORed with a given Place.
+ * Within a region of eligible OR candidates, only the first candidate is
+ * considered. This avoids complexity with overlapping concurrent ORs at the expense of
+ * only resolving one OR per candidate region per pass. Returns an empty Set if this
+ * place is not part of the firsr candidate.
+ */
+ query getOrPair(place : pnMM::Place) : OrderedSet(pnMM::Place) {
+ let preTransitions = place.pret->asOrderedSet() in
+ let postTransitions = place.postt->asOrderedSet() in
+ let prePostPlaces = preTransitions.postp->asOrderedSet() in
+ let postPrePlaces = postTransitions.prep->asOrderedSet() in
+ if postPrePlaces->forAll(p | p.postt = postTransitions) and prePostPlaces->forAll(p | p.pret->includesAll(preTransitions)) then postPrePlaces
+ elseif prePostPlaces->forAll(p | p.pret = preTransitions) and postPrePlaces->forAll(p | p.postt->includesAll(postTransitions)) then prePostPlaces
+ else OrderedSet{}
+ endif
+ }
+
+ top relation PlaceState2PlaceState {
+ fromNet : pnMM::Net[1];
+ fromTopState : scMM::AND[1];
+ toNet : pnMM::Net[1];
+ toTopState : scMM::AND[1];
+ domain pn1 fromPlace:Place{
+ cnet = fromNet
+ };
+ domain sc1 fromState:State{
+ rcontains = fromTopState
+ };
+ enforce domain pn2
+ toPlace:Place{
+ cnet = toNet
+ };
+ enforce domain sc2
+ toState:State{
+ rcontains = toTopState
+ };
+ when {
+ Roots2Roots(fromNet, fromTopState, toNet, toTopState);
+ }
+ }
+
+ top relation PlaceState2AndPlaceState overrides PlaceState2PlaceState{
+ fromNet : pnMM::Net[1];
+ fromTopState : scMM::AND[1];
+-- fromParentState : scMM::State[1];
+ toNet : pnMM::Net[1];
+ toTopState : scMM::AND[1];
+-- toParentState : scMM::State[1];
+ fromPlaces : OrderedSet(pnMM::Place)[1] = getAndSet(fromPlace);
+ toAndState : scMM::AND[1];
+ domain pn1
+ fromPlace:Place{
+ cnet = fromNet
+ };
+ domain sc1
+ fromState:State{
+ rcontains = fromTopState
+ };
+ enforce domain pn2
+ toPlace:Place{
+ cnet = toNet
+ };
+ enforce domain sc2
+ toOrState:OR{
+ rcontains = toTopState,
+ contains = toAndState
+ };
+ when {
+ fromPlaces->notEmpty();
+ Roots2Roots(fromNet, fromTopState, toNet, toTopState);
+-- AndPlaces2AndPlaceStates(fromPlaces, toPlace, toStates);
+ AndPlaces2AndState(fromPlaces, toAndState);
+ }
+ }
+
+ relation AndPlaces2AndState {
+ domain pn1
+ fromPlaces : OrderedSet(Place){fromPlace:Place{} ++ _};
+-- domain pn2
+-- toPlace:Place{};
+ enforce domain sc2
+ toState:AND{
+ contains = toStates : OrderedSet(State){aState:State{} ++ _}
+ };
+ when {
+ fromPlaces->indexOf(fromPlace) = toStates->indexOf(toState);
+ Places2States(fromPlaces, toStates);
+ Place2State(fromPlace, aState);
+ }
+ }
+
+ relation Places2States {
+ domain pn1
+ places : OrderedSet(Place){place:Place{} ++ _};
+ domain sc1
+ states : OrderedSet(State){state:State{} ++ _};
+ when {
+ Place2State(place, state);
+ }
+ }
+
+ relation Place2State {
+ domain pn1 place:Place{};
+ enforce domain sc2 state:State{};
+ }
+
+
+ top relation PlaceState2OrPlaceState overrides PlaceState2PlaceState{
+ fromNet : pnMM::Net[1];
+ fromTopState : scMM::AND[1];
+-- fromParentState : scMM::State[1];
+ toNet : pnMM::Net[1];
+ toTopState : scMM::AND[1];
+-- toParentState : scMM::State[1];
+ orPlaces : OrderedSet(pnMM::Place)[1] = getOrPair(fromPlace);
+ orStates : OrderedSet(scMM::State)[1];
+ domain pn1
+ fromPlace:Place{
+ cnet = fromNet
+ };
+ domain sc1
+ fromState:State{
+ rcontains = fromTopState
+ };
+ enforce domain pn2
+ toPlace:Place{
+ cnet = toNet
+ };
+ enforce domain sc2
+ toState:OR{
+-- rcontains = toParentState,
+ rcontains = toTopState,
+ contains = orStates
+ };
+ when {
+ orPlaces->notEmpty();
+ Roots2Roots(fromNet, fromTopState, toNet, toTopState);
+ Places2States(orPlaces, orStates);
+ }
+ }
+
+
+/* top relation CreateAND {
+ otherTtoPs:OrderedSet(pnMM::Place);
+ domain pnsc1
+ pTot:PlaceToTransition{
+ place = q:Place{},
+ transition = t:Transition{
+ TransitionToPlace = :OrderedSet(TransitionToPlace){r:Place{} ++ otherTtoPs}
+ }
+ }
+ {
+ pn_qs->forAll(pret = pn_q1.pret) and
+ pn_qs->forAll(postt = pn_q1.postt)
+ };
+ enforce domain pnsc2
+ pn_t_out:Transition{
+ prep = pn_qs:Set(Place){pn_q1:Place{} ++ pn_qs}
+ }
+ {
+ pn_qs->forAll(pret = pn_q1.pret) and
+ pn_qs->forAll(postt = pn_q1.postt)
+ };
+ pn_p:Place{},
+ sc_p:OR{
+ contains = sc_a:AND{
+-- contains = sc_a_qs:Sequence(State){sc_q1,sc_q2 ++ _}
+ }
+ };
+ } */
/*retype Place to Basic
migrate Place {

Back to the top