Browse Source

Added first draft of control and environment DSLs

Yentl Van Tendeloo 8 years ago
parent
commit
1520cd86dd
2 changed files with 104 additions and 0 deletions
  1. 42 0
      models/control_PW.mvc
  2. 62 0
      models/environment_PW.mvc

+ 42 - 0
models/control_PW.mvc

@@ -0,0 +1,42 @@
+SimpleClassDiagram Control_PW{
+    SimpleAttribute Integer{
+        constraint = $
+            String function constraint(model : Element, name : String):
+                if (is_physical_int(model["model"][name])):
+                    return "OK"!
+                else:
+                    return "Integer has non-integer value"!
+    }
+
+    SimpleAttribute String{
+        constraint = $
+            String function constraint(model : Element, name : String):
+                if (is_physical_string(model["model"][name])):
+                    return "OK"!
+                else:
+                    return "String has non-string value"!
+            $
+    }
+
+    Class Named {
+        name : String
+    }
+
+    Class Positionable {
+        x : Integer
+        y : Integer
+    }
+
+    Class Boundary : Named, Positionable {}
+    Class Port : Named, Positionable {}
+    Class Transition : Named, Positionable {}
+    Class State : Named, Positionable {}
+
+    Association Has1 (Boundary, State) {}
+    Association Has2 (Boundary, Port) {}
+    Association Has3 (Boundary, Transition) {}
+    Association PortTransition (Port, Transition) {}
+    Association From (State, Transition) {}
+    Association To (Transition, State) {}
+    Association PortState (Port, State) {}
+}

+ 62 - 0
models/environment_PW.mvc

@@ -0,0 +1,62 @@
+SimpleClassDiagrams Environment_PW{
+    SimpleAttribute Integer{
+        constraint = $
+            String function constraint(model : Element, name : String):
+                if (is_physical_int(model["model"][name])):
+                    return "OK"!
+                else:
+                    return "Integer has non-integer value"!
+    }
+
+    SimpleAttribute Natural{
+        constraint = $
+            String function constraint(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(model : Element, name : String):
+                if (is_physical_string(model["model"][name])):
+                    return "OK"!
+                else:
+                    return "String has non-string value"!
+            $
+    }
+
+    Class Named {
+        name : String
+    }
+
+    Class Positionable {
+        x : Integer
+        y : Integer
+    }
+
+    Class Port : Named, Positionable {}
+    Class Boundary : Named, Positionable {}
+    Class Activity : Named, Positionable {}
+    Class CommunicationSequence : Activity {}
+    Class TopActivity : Activity {}
+    Class Parallel : TopActivity {}
+    Class Sequence : TopActivity {}
+    Class Alternative : TopActivity {}
+    Class Input : Event {}
+    Class Output : Event {
+        duration : Natural
+    }
+
+    Association Has1 (Boundary, TopActivity) {}
+    Association Has2 (Boundary, Event) {}
+    Association Has3 (Boundary, Port) {}
+    Association HasActivity (TopActivity, Activity) {}
+    Association HasEventSequence (CommunicationSequence, Event) {}
+    Association NextEvent (Event, Event) {}
+    Association PortEvent (Port, Event) {}
+}