Pārlūkot izejas kodu

Updated everything for the new DSLs (and transformations)

Yentl Van Tendeloo 8 gadi atpakaļ
vecāks
revīzija
3e58ae5589

+ 13 - 9
models/control_PW.mvc

@@ -2,6 +2,7 @@ include "primitives.alh"
 
 SimpleClassDiagram Control_PW{
     SimpleAttribute Boolean {}
+    SimpleAttribute TriState {}
     SimpleAttribute String{
         constraint = $
             String function constraint(model : Element, name : String):
@@ -12,17 +13,20 @@ SimpleClassDiagram Control_PW{
             $
     }
 
-    Class Named {
+    Class State {
+        isInitial : Boolean
+        isError : Boolean
         name : String
     }
 
-    Class Transition : Named {}
-    Class State : Named {
-        initial : Boolean
-    }
+    Class Up : State {}
+    Class Down : State {}
+    Class Neutral : State {}
 
-    Association PortTransition (Port, Transition) {}
-    Association From (State, Transition) {}
-    Association To (Transition, State) {}
-    Association PortState (Port, State) {}
+    Association Transition (State, State) {
+        objectDetected : TriState
+    }
+    Association UpPressed : Transition {}
+    Association NonePressed : Transition {}
+    Association DownPressed : Transition {}
 }

+ 25 - 49
models/control_model.mvc

@@ -1,60 +1,36 @@
 Control_PW control_model_PW {
-    State neutral {
+    Up up {
+        isInitial = False
+        isError = False
+        name = "up"
+    }
+    Down down {
+        isInitial = False
+        isError = False
+        name = "down"
+    }
+    Neutral neutral {
+        isInitial = True
+        isError = True
         name = "neutral"
-        initial = True
-    }
-    State movingDown {
-        name = "movingDown"
-        initial = False
-    }
-    State emergency {
-        name = "emergency"
-        initial = False
-    }
-    State movingUp {
-        name = "movingUp"
-        initial = False
     }
 
-    Transition cmdStop1 {
-        name = "cmdStop"
+    UpPressed (down, neutral) {
+        objectDetected = "*"
     }
-    Transition cmdDown1 {
-        name = "cmdDown"
+    UpPressed (neutral, up) {
+        objectDetected = "N"
     }
-    Transition cmdUp1 {
-        name = "cmdUp"
+    DownPressed (up, neutral) {
+        objectDetected = "*"
     }
-    Transition cmdStop2 {
-        name = "cmdStop"
+    DownPressed (neutral, down) {
+        objectDetected = "*"
     }
-    Transition cmdDown2 {
-        name = "cmdDown"
+    NonePressed (up, neutral) {
+        objectDetected = "*"
     }
-    Transition cmdUp2 {
-        name = "cmdUp"
+    NonePressed (down, neutral) {
+        objectDetected = "*"
     }
-    Transition detectedObject {
-        name = "detectedObject"
-    }
-    Transition s_ {
-        name = ""
-    }
-
-    From (movingDown, cmdStop1) {}
-    To (cmdStop1, neutral) {}
-    From (neutral, cmdDown1) {}
-    To (cmdDown1, movingDown) {}
-    From (movingDown, cmdDown2) {}
-    To (cmdDown2, movingUp) {}
-    From (movingUp, cmdUp1) {}
-    To (cmdUp1, movingDown) {}
-    From (neutral, cmdUp2) {}
-    To (cmdUp2, movingUp) {}
-    From (movingUp, cmdStop2) {}
-    To (cmdStop2, neutral) {}
-    From (movingUp, detectedObject) {}
-    To (detectedObject, emergency) {}
-    From (emergency, s_) {}
-    To (s_, neutral) {}
 }

+ 7 - 34
models/environment_PW.mvc

@@ -1,42 +1,15 @@
 include "primitives.alh"
 
 SimpleClassDiagrams Environment_PW{
-    SimpleAttribute Natural{
-        constraint = $
-            String function constraint_Natural(model : Element, name : String):
-                if (is_physical_int(model["model"][name])):
-                    if (integer_gte(model["model"][name], 0)):
-                        return "OK"!
-                    else:
-                        return "Natural has negative value"!
-                else:
-                    return "Natural has non-integer value"!
-            $
-    }
-
-    SimpleAttribute String{
-        constraint = $
-            String function constraint_String(model : Element, name : String):
-                if (is_physical_string(model["model"][name])):
-                    return "OK"!
-                else:
-                    return "String has non-string value"!
-            $
-    }
+    SimpleAttribute Boolean {}
+    SimpleAttribute Natural{}
+    SimpleAttribute String{}
 
-    Class Named {
+    Class Group {name}
+    Class Event {
+        initial : Boolean
         name : String
     }
 
-    Class Activity : Named {
-        duration : Natural
-    }
-    Class CommunicationSequence : Activity {}
-    Class Parallel : Activity {}
-    Class Sequence : Activity {}
-    Class Alternative : Activity {}
-    Class Event : Activity {}
-
-    Association Contains (Activity, Activity) {}
-    Association Next (Activity, Activity) {}
+    Association Contains (Group, Event) {}
 }

+ 16 - 48
models/environment_model.mvc

@@ -1,54 +1,22 @@
 Environment_PW environment_model_PW {
-    Parallel {
-        name = "s_"
-        duration = 0
-
-        {Contains} CommunicationSequence {
-            name = "driver"
-            actor = "driver"
-            duration = 0
-
-            {Contains} Event cmdUpD {
-                name = "cmdUpD"
-                duration = 3
-            }
-            {Contains} Event cmdStopD {
-                name = "cmdStopD"
-                duration = 4
-            }
-            {Contains} Event cmdDownP {
-                name = "cmdDown"
-                duration = 3
-            }
-            {Contains} Event lockOut {
-                name = "lockOut"
-                duration = 1
-            }
+    Group {
+        Event {
+            name = "cmdUp"
         }
-
-        {Contains} CommunicationSequence {
-            name = "passenger"
-            duration = 0
-
-            {Contains} Event cmdUp1 {
-                name = "cmdUp"
-                duration = 3
-            }
-            {Contains} Event stickHead {
-                name = "stickHead"
-                duration = 3
-            }
-            {Contains} Event cmdUp2 {
-                name = "cmdUp"
-                duration = 2
-            }
+        Event {
+            name = "cmdNeutral"
+        }
+        Event {
+            name = "cmdDown"
         }
     }
 
-    Next (cmdUpD, cmdStopD) {}
-    Next (cmdStopD, cmdDownP) {}
-    Next (cmdDownP, lockOut) {}
-
-    Next (cmdUp1, stickHead) {}
-    Next (stickHead, cmdUp2) {}
+    Group {
+        Event {
+            name = "insertObject"
+        }
+        Event {
+            name = "removeObject"
+        }
+    }
 }

+ 114 - 0
models/environment_to_EPN.mvc

@@ -0,0 +1,114 @@
+include "primitives.alh"
+
+A B {
+    Composite schedule {
+        {Contains} Success success {}
+        {Contains} Failure failure {}
+        {Contains} ForAll create_ports {
+            LHS {
+                Pre_Environment_PW/Event {
+                    label = "0"
+                }
+            }
+            RHS {
+                Post_Environment_PW/Event {
+                    label = "0"
+                }
+                Post_Encapsulated_PetriNet/Place cp_place {
+                    label = "1"
+                    value_name = $
+                        String function value(model : Element, name : String, mapping : Element):
+                            return read_attribute(model, mapping["0"], "name")!
+                        $
+                }
+                Post_Encapsulated_PetriNet/Port cp_port {
+                    label = "2"
+                    value_name = $
+                        String function value(model : Element, name : String, mapping : Element):
+                            return read_attribute(model, mapping["0"], "name")!
+                        $
+                }
+                Post_Encapsulated_PetriNet/PortPlace (cp_port, cp_place) {
+                    label = "3"
+                }
+                Post_ENV2EPN_link (cp_evt, cp_place) {
+                    label = "4"
+                }
+            }
+        }
+        {Contains} ForAll create_switches {
+            LHS {
+                Pre_Environment_PW/Group pre_grp {
+                    label = "0"
+                }
+                Pre_Environment_PW/Event pre_evt_a {
+                    label = "1"
+                }
+                Pre_Environment_PW/Contains (pre_grp, pre_evt_a) {
+                    label = "2"
+                }
+                Pre_Environment_PW/Event pre_evt_b {
+                    label = "3"
+                }
+                Pre_Environment_PW/Contains (pre_grp, pre_evt_b) {
+                    label = "4"
+                }
+                Pre_Encapsulated_PetriNet/Place pre_place_a {
+                    label = "5"
+                }
+                Pre_Encapsulated_PetriNet/Place pre_place_b {
+                    label = "6"
+                }
+                Pre_ENV2EPN_link (pre_evt_a, pre_place_a) {
+                    label = "7"
+                }
+                Pre_ENV2EPN_link (pre_evt_b, pre_place_b) {
+                    label = "8"
+                }
+            }
+            RHS {
+                Post_Environment_PW/Group post_grp {
+                    label = "0"
+                }
+                Post_Environment_PW/Event post_evt_a {
+                    label = "1"
+                }
+                Post_Environment_PW/Contains (post_grp, post_evt_a) {
+                    label = "2"
+                }
+                Post_Environment_PW/Event post_evt_b {
+                    label = "3"
+                }
+                Post_Environment_PW/Contains (post_grp, post_evt_b) {
+                    label = "4"
+                }
+                Post_Encapsulated_PetriNet/Place post_place_a {
+                    label = "5"
+                }
+                Post_Encapsulated_PetriNet/Place post_place_b {
+                    label = "6"
+                }
+                Post_ENV2EPN_link (post_evt_a, post_place_a) {
+                    label = "7"
+                }
+                Post_ENV2EPN_link (post_evt_b, post_place_b) {
+                    label = "8"
+                }
+                Post_Encapsulated_PetriNet/Transition post_transition {
+                    label = "9"
+                }
+                Post_Encapsulated_PetriNet/P2T (post_place_a, post_transition) {
+                    label = "10"
+                }
+                Post_Encapsulated_PetriNet/T2P (post_transition, post_place_b) {
+                    label = "11"
+                }
+            }
+        }
+    }
+    Initial (schedule, create_ports) {}
+    Success (create_ports, create_switches) {}
+    Success (create_switches, success) {}
+    Failure (create_ports, failure) {}
+    Failure (create_switches, failure) {}
+}

+ 6 - 30
models/petrinet_ports.mvc

@@ -1,13 +1,13 @@
 include "primitives.alh"
 
 SimpleClassDiagrams PetriNetsPorts {
-    SimpleAttribute Integer{
+    SimpleAttribute Natural{
         constraint = $
             String function constraint(model : Element, name : String):
                 if (is_physical_int(model["model"][name])):
                     return "OK"!
                 else:
-                    return "Integer has non-integer value"!
+                    return "Natural has non-integer value"!
             $
     }
 
@@ -21,40 +21,16 @@ SimpleClassDiagrams PetriNetsPorts {
             $
     }
 
-    SimpleAttribute PlaceOrTransition{
-        constraint = $
-            String function constraint(model : Element, name : String):
-                if (is_physical_string(model["model"][name])):
-                    if (bool_or(value_eq(model["model"][name], "transition"), value_eq(model["model"][name], "place"))):
-                        return "OK"!
-                    else:
-                        return "PlaceOrTransition does not contain either 'place' or 'transition'"!
-                else:
-                    return "PlaceOrTransition has non-string value"!
-            $
-    }
-    Class Positionable {
-        x : Integer
-        y : Integer
-    }
     Class Named {
         name : String
     }
-    Class Boundary : Named, Positionable {}
-    Class Place : Positionable, Named {
-        nbTokens : Integer
-    }
-    Class Transition : Positionable, Named {}
-    Class Port : Named, Positionable {
-        sourceType : PlaceOrTransition
-        targetType : PlaceOrTransition
+    Class Place : Named {
+        nbTokens : Natural
     }
+    Class Transition : Named {}
+    Class Port : Named {}
 
-    Association Has1 (Boundary, Place) {}
-    Association Has2 (Boundary, Transition) {}
-    Association Has3 (Boundary, Port) {}
     Association P2T (Place, Transition) {}
     Association T2P (Transition, Place) {}
-    Association PortTransition (Port, Transition) {}
     Association PortPlace (Port, Place) {}
 }