فهرست منبع

Merge branch 'master' into testing

Yentl Van Tendeloo 8 سال پیش
والد
کامیت
9a5238a437

+ 75 - 0
addis/PM_Example.mvc

@@ -0,0 +1,75 @@
+Start start {
+    id = "start"
+    {Next} Exec A {
+        name = "A"
+        id = "A"
+        {Next} Fork fork_1 {
+            {Next} Exec B {
+                name = "A"
+                id = "A"
+            }
+            {Next} Exec C {
+                name = "C"
+                id = "C"
+            }
+            {Next} Exec E {
+                name = "E"
+                id = "E"
+                {Produces} Data data {
+                    id = "data"
+                    name = "True"
+                    type = "Boolean"
+                }
+            }
+        }
+    }
+}
+Join join_1 {
+    id = "join_1"
+}
+Join join_2 {
+    id = "join_2"
+}
+Next (B,join_1){
+    id = "B_join_1"
+}
+Next (C,join_1){
+    id = "C_join_1"
+}
+Exec D {
+    name = "D"
+    id = "D"
+}
+Next (join_1, D){
+    id = "join_1_D"
+}
+Next (D, join_2){
+    id = "D_join_2"
+}
+Next (E, join_2){
+    id = "E_join_2"
+}
+Exec F {
+    name = "F"
+    id = "F"
+}
+Decision decision_1 {
+    id = "decision_1"
+}
+DecisionConsumes (decision_1, data) {
+    id = "decision_1_data"
+}
+Next (F, decision_1){
+    id = "F_decision_1"
+}
+Next (decision_1, A){
+    id = "decision_1_A"
+    value = "True"
+}
+Finish end {
+    id = "finish"
+}
+Next (decision_1, end){
+    id = "decision_1_end"
+    value = "False"
+}

+ 167 - 0
addis/PM_MetaModel.mvc

@@ -0,0 +1,167 @@
+include "primitives.alh"
+include "object_operations.alh"
+include "modelling.alh"
+
+
+SimpleAttribute String {}
+SimpleAttribute MvCName {
+    constraint = $
+        String function constraint(model : Element, name : String):
+            if (bool_not(is_physical_string(model["model"][name]))):
+                return "MvCName has no string value"!
+            else:
+                return "OK"!
+        $
+}
+SimpleAttribute Natural {
+    constraint =$
+    String function constraint(model: Element, id: String):
+        if (bool_not(is_physical_int(model["model"][id]))):
+            return "Natural has no integer value at " + id!
+        elif (integer_lt(model["model"][id], 0)):
+            return "Natural does not have a positive or zero value at " + id!
+        else:
+            return "OK"!
+     $
+}
+Class Model {
+    items_creation_order ?: String
+    SCCD_id : String
+}
+Class Activity {
+    id : String
+}
+Class Edge {
+    id : String
+}
+Class Start : Activity {
+    lower_cardinality = 1
+    upper_cardinality = 1
+    constraint = $
+        String function constraint(model : Element, name : String):
+            Element outgoing_edges
+            outgoing_edges = allOutgoingAssociationInstances(model, name, "Next")
+            if list_len(outgoing_edges) !=1:
+                return "A start node should have one outgoing control flow"!
+            else:
+                return "OK"!
+        $
+}
+Class Finish : Activity {
+    lower_cardinality = 1
+    constraint = $
+        String function constraint(model : Element, name : String):
+            Element incoming_edges
+            incoming_edges = allIncomingAssociationInstances(model, name, "Next")
+            if (list_len(incoming_edges) !=1):
+                return "A finish node should have either one incoming control flow or decision flow"!
+            else:
+                return "OK"!
+        $
+}
+Class Fork : Activity {
+    constraint = $
+        String function constraint(model : Element, name : String):
+            Element outgoing_edges
+            Element incoming_edges
+            outgoing_edges = allOutgoingAssociationInstances(model, name, "Next")
+            incoming_edges = allIncomingAssociationInstances(model, name, "Next")
+            if bool_or(list_len(outgoing_edges) <2, list_len(incoming_edges) !=1):
+                return "All Fork nodes should have one incoming control flow and at least two outgoing control flows"!
+            else:
+                return "OK"!
+        $
+}
+
+Class Join : Activity {
+    constraint = $
+        String function constraint(model : Element, name : String):
+            Element outgoing_edges
+            Element incoming_edges
+            outgoing_edges = allOutgoingAssociationInstances(model, name, "Next")
+            incoming_edges = allIncomingAssociationInstances(model, name, "Next")
+            if bool_or(list_len(outgoing_edges) !=1, list_len(incoming_edges) <2):
+                return "All Join nodes should have at least two incoming and one outgoing control flow"!
+            else:
+                return "OK"!
+        $
+}
+Class Decision : Activity {
+    constraint = $
+        String function constraint(model : Element, name : String):
+            Element outgoing_edges
+            Element incoming_edges
+            Element consumes
+            consumes = allOutgoingAssociationInstances(model, name, "DecisionConsumes")
+            outgoing_edges = allOutgoingAssociationInstances(model, name, "Next")
+            incoming_edges = allIncomingAssociationInstances(model, name, "Next")
+            if bool_or(list_len(outgoing_edges) <2, list_len(incoming_edges) !=1):
+                return "All Decision nodes should have at least one incoming flow and two outgoing flows"!
+            elif list_len(consumes) != 1:
+                return "All Decision nodes should have exactly one incoming data flow"!
+            else:
+                return "OK"!
+        $
+}
+
+Class Exec : Activity {
+    name : MvCName
+    sccd_class_id ?: String
+    lower_cardinality = 1
+    constraint = $
+        String function constraint(model : Element, name : String):
+            Element outgoing_edges
+            Element incoming_edges
+            outgoing_edges = allOutgoingAssociationInstances(model, name, "Next")
+            incoming_edges = allIncomingAssociationInstances(model, name, "Next")
+            if bool_or(list_len(outgoing_edges) !=1, list_len(incoming_edges) !=1):
+                return "All Executable nodes should have exactly one incoming and one outgoing control flow"!
+            else:
+                return "OK"!
+        $
+}
+
+Class Data {
+    id : String
+    name : MvCName
+    type : MvCName
+    constraint = $
+        String function constraint(model : Element, name : String):
+            Element outgoing_edges
+            Element incoming_edges
+            outgoing_edges = allIncomingAssociationInstances(model, name, "Consumes")
+            incoming_edges = allIncomingAssociationInstances(model, name, "Produces")
+            if bool_or(list_len(outgoing_edges) <1, list_len(incoming_edges) <1):
+                return "All Data nodes should have al-least one incoming Produces and one outgoing Consumes flow"!
+            else:
+                return "OK"!
+        $
+}
+
+Association Produces : Edge (Exec, Data) {}
+Association Consumes : Edge (Exec, Data) {}
+Association DecisionConsumes : Edge (Decision, Data) {}
+Association Next : Edge (Activity, Activity) {
+    value ?: MvCName
+}
+
+Class CanvasPosition{
+    x1: Natural
+    y1: Natural
+    x2 ?: Natural
+    y2 ?: Natural
+}
+Association activity_position (Activity, CanvasPosition){}
+Association data_position (Data, CanvasPosition){}
+Association produces_positions (Produces, CanvasPosition){
+    order: Natural
+}
+Association consumes_positions (Consumes, CanvasPosition){
+    order: Natural
+}
+Association decision_consumes_positions (DecisionConsumes, CanvasPosition){
+    order: Natural
+}
+Association next_positions (Next, CanvasPosition){
+    order: Natural
+}

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 1412 - 0
addis/PM_to_SCCD.mvc


+ 16 - 0
addis/SCCD_Example.mvc

@@ -0,0 +1,16 @@
+
+Diagram SCCD_Example {
+    name = "SCCD example "
+    {diagram_classes} Class A {
+        name = "A"
+
+        {behaviour} CompositeState manager_main {
+            name = "main"
+            isInitial = True
+            {composite_children} BasicState manager_main_start {
+                name = "start"
+                isInitial = True
+            }
+        }
+    }
+}

+ 270 - 0
addis/SCCD_MetaModel.mvc

@@ -0,0 +1,270 @@
+include "primitives.alh"
+include "object_operations.alh"
+include "modelling.alh"
+
+
+SimpleAttribute Neutral {}
+SimpleAttribute Boolean {
+    constraint = $
+    String function constraint(model: Element, id: String):
+        if (bool_not(is_physical_boolean(model["model"][id]))):
+            return "Boolean has no boolean value at " + id!
+        else:
+            return "OK"!
+    $
+}
+SimpleAttribute String {
+    constraint = $
+    String function constraint(model: Element, id: String):
+        if (bool_not(is_physical_string(model["model"][id]))):
+            return "String has no string value at " + id!
+        else:
+            return "OK"!
+    $
+}
+SimpleAttribute Natural {
+    constraint =$
+    String function constraint(model: Element, id: String):
+        if (bool_not(is_physical_int(model["model"][id]))):
+            return "Natural has no integer value at " + id!
+        elif (integer_lt(model["model"][id], 0)):
+            return "Natural does not have a positive or zero value at " + id!
+        else:
+            return "OK"!
+     $
+}
+SimpleAttribute PositiveFloat {
+    constraint =$
+    String function constraint(model: Element, id: String):
+        if (bool_not(is_physical_float(model["model"][id]))):
+            return "PositiveFloat has no float value at " + id!
+        elif (integer_lt(model["model"][id], 0)):
+            return "PositiveFloat does not have a positive or zero value at " + id!
+        else:
+            return "OK"!
+     $
+}
+SimpleAttribute EventScope {
+    constraint =$
+    String function constraint(model: Element, id: String):
+        String self
+        self = model["model"][id]
+        if (bool_not(is_physical_string(self))):
+            return "EventScope has no string value at " + id!
+        elif (bool_or(bool_or(bool_or(self != "broad", self != "cd"), bool_or(self != "narrow", self != "output")), self != 'local')):
+            return "EventScope can be either 'local', 'broad', 'cd', 'narrow' or 'output' and it does not have a proper value at " + id!
+        else:
+            return "OK"!
+    $
+}
+
+Class Diagram{
+    name : String
+    author ?: String
+    description ?: String
+    top ?: String
+    class_reference_items ?: String
+    lower_cardinality = 1
+    upper_cardinality = 1
+}
+Class Inport{
+    name: String
+}
+Class Outport{
+    name: String
+}
+Association diagram_inports(Diagram, Inport){}
+Association diagram_outports(Diagram, Outport){}
+
+Class Class{
+    name : String
+    constructor_body ?: String
+    destructor ?: String
+    default ?: Boolean
+    external ?: Boolean
+    class_behaviour_items ?: String
+}
+Association diagram_classes(Diagram, Class){
+    target_lower_cardinality = 1
+}
+
+Class Attribute{
+    name : String
+    type ?: String
+}
+Association class_attributes(Class, Attribute){}
+
+Class Method{
+    name : String
+    body : String
+    return_type ?: String
+}
+
+Class FormalParameter{
+    name: String
+    type ?: String
+    default ?: String
+}
+Association method_parameters(Method, FormalParameter){}
+Association class_methods(Class, Method){}
+Association class_constructor_parameters(Class, FormalParameter){}
+
+Class CanvasPosition{
+    x1: Natural
+    y1: Natural
+    x2 ?: Natural
+    y2 ?: Natural
+}
+Association class_ref_position(Class, CanvasPosition){
+    target_upper_cardinality = 1
+}
+Association class_beh_position(Class, CanvasPosition){
+    target_upper_cardinality = 1
+}
+
+Association association(Class, Class){
+    name : String
+    min ?: Natural
+    max ?: Natural
+    source_upper_cardinality = 1
+}
+Association association_positions(association, CanvasPosition){
+    order: Natural
+}
+
+Association inheritance(Class, Class){
+    priority ?: Natural
+    source_upper_cardinality = 1
+}
+
+Class SuperClassConstructorParameter{
+    value : Neutral
+}
+Association inheritance_parent_constructor_parameters(inheritance, SuperClassConstructorParameter){
+    order : Natural
+}
+Association inheritance_positions(inheritance, CanvasPosition){
+    order: Natural
+}
+
+Class State{
+    name : String
+    state_reference_path ?: String
+}
+Association state_position(State, CanvasPosition){
+    target_upper_cardinality = 1
+}
+
+Class BasicState : State{
+    isInitial : Boolean
+    onEntryScript ?: String
+    onExitScript ?: String
+}
+
+Class ActualParameter{
+    exp: String
+}
+
+Class Raise{
+    event: String
+    scope ?: EventScope
+    port ?: String
+    target ?: String
+}
+Association raise_parameters(Raise, ActualParameter){
+    order : Natural
+}
+Association state_onentry_raises(BasicState, Raise){
+    order : Natural
+}
+Association state_onexit_raises(BasicState, Raise){
+    order : Natural
+}
+
+Class CompositeState : BasicState{}
+Association composite_children(CompositeState, State){
+    source_upper_cardinality = 1
+}
+Association behaviour(Class, CompositeState){
+    target_lower_cardinality = 1
+    target_upper_cardinality = 1
+}
+Association behaviour_positions(behaviour, CanvasPosition){
+    order: Natural
+}
+
+Class ParallelState : BasicState{}
+Association parallel_children(ParallelState, CompositeState){
+    source_upper_cardinality = 1
+}
+
+Class HistoryState : State{
+    type : String
+}
+
+Association transition(State, State){
+    name: String
+    cond ?: String
+    script ?: String
+    after ?: PositiveFloat
+    event ?: String
+    port ?: String
+    source_upper_cardinality = 1
+}
+Association transition_parameters(transition, FormalParameter){
+    order : Natural
+}
+Association transition_raises(transition, Raise){
+    order : Natural
+}
+Association transition_positions(transition, CanvasPosition){
+    order: Natural
+}
+
+GlobalConstraint {
+        global_constraint = $
+            String function constraint(model : Element):
+                Element composite_states
+                Element parallel_states
+                Element children
+                String state
+                String child
+                String name
+                Boolean CompInitialFound
+                Element encountered_names
+
+                composite_states = allInstances(model, "CompositeState")
+                parallel_states = allInstances(model, "ParallelState")
+
+                while (list_len(composite_states) >0):
+                    CompInitialFound = False
+                    encountered_names = create_node()
+                    state = set_pop(composite_states)
+                    children = allAssociationDestinations(model, state, "composite_children")
+                    while (list_len(children)>0):
+                        child = set_pop(children)
+                        name = read_attribute(model, child, 'name')
+                        if (set_in(encountered_names, name)):
+                            return "Unique state identifier names on the same level/parent violated"!
+                        else:
+                            set_add(encountered_names, name)
+                        if bool_and(read_type(model, child) != 'HistoryState' , read_attribute(model, child, 'isInitial')):
+                            CompInitialFound = True
+                    if CompInitialFound == False:
+                        return "Composite state does not have an initial child state"!
+
+                while (list_len(parallel_states) >0):
+                    encountered_names = create_node()
+                    state = set_pop(parallel_states)
+                    children = allAssociationDestinations(model, state, "parallel_children")
+                    while (list_len(children)>0):
+                        child = set_pop(children)
+                        name = read_attribute(model, child, 'name')
+                        if (set_in(encountered_names, name)):
+                            return "Unique state identifier names on the same level/parent violated"!
+                        else:
+                            set_add(encountered_names, name)
+
+                return "OK"!
+        $
+    }

+ 36 - 0
addis/Test_PM2SCCD.py

@@ -0,0 +1,36 @@
+import sys
+sys.path.append("wrappers")
+from  modelverse import *
+
+try:
+    init()
+    login('admin', 'admin')
+    model_add('PM', "SimpleClassDiagrams", open("addis/PM_MetaModel.mvc", "r").read())
+except Exception as e:
+    print e
+try:
+    model_add('SCCD', "SimpleClassDiagrams", open("addis/SCCD_MetaModel.mvc", "r").read())
+except Exception as e:
+    print e
+
+if "my_PM" in [i[0] for i in model_list()]:
+    model_delete("my_PM")
+model_add("my_PM", "PM", open("addis/PM_Example.mvc", 'r').read())
+if "SCCD_my_PM" in [i[0] for i in model_list()]:
+    model_delete("SCCD_my_PM")
+model_add("SCCD_my_PM", "SCCD", open("addis/SCCD_Example.mvc", 'r').read())
+
+
+def Activity2State():
+    instantiate(None, "Association", ("PM/Activity", "SCCD/CompositeState"), ID="Activity2State_link")
+print "before mt"
+transformation_add_MT({"PM":"PM","SCCD":"SCCD"}, {"SCCD":"SCCD"}, "PM2SCCD", open("addis/PM_to_SCCD.mvc", "r").read(), Activity2State)
+print model_list()
+transformation_execute_MT("PM2SCCD", {"PM":"my_PM", "SCCD":"SCCD_my_PM"}, {"SCCD":"PM_2_SCCD_output"})
+
+
+
+
+
+
+

+ 3 - 0
bootstrap/ramify.alc

@@ -150,6 +150,7 @@ Element function ramify(model : Element):
 			else:
 				// Queue for later
 				list_append(keys, key)
+				continue!
 
 		elif (type_name == "Association"):
 			old_source = reverseKeyLookup(model["model"], read_edge_src(entry))
@@ -165,6 +166,7 @@ Element function ramify(model : Element):
 			else:
 				// Queue for later
 				list_append(keys, key)
+				continue!
 				
 			local_copied_attributes = set_copy(copied_attributes)
 			while (set_len(local_copied_attributes) > 0):
@@ -184,6 +186,7 @@ Element function ramify(model : Element):
 			else:
 				// Queue for later
 				list_append(keys, key)
+				continue!
 
 	// Define schedule over these elements
 

+ 0 - 4
interface/HUTN/hutn_compiler/compiler.py

@@ -24,8 +24,6 @@ def md5digest(filename):
     return hasher.hexdigest()
 
 def fetch_cached(filename, mode=None):
-    if mode is not None:
-        return None
     try:
         md5 = md5digest(filename)
         cache_folder = os.path.abspath("%s/../caches/" % (os.path.dirname(os.path.abspath(__file__))))
@@ -39,8 +37,6 @@ def fetch_cached(filename, mode=None):
         return None
 
 def make_cached(filename, data, mode=None):
-    if mode is not None:
-        return
     md5 = md5digest(filename)
     cache_folder = os.path.abspath("%s/../caches/" % (os.path.dirname(os.path.abspath(__file__))))
     if mode is None:

+ 7 - 0
wrappers/modelverse.py

@@ -438,11 +438,15 @@ def transformation_add_MT(source_metamodels, target_metamodels, operation_name,
     """Create a new model transformation."""
     global mode
     _goto_mode(MODE_MODELLING)
+    import time
 
+    start = time.time()
     try:
         compiled = _compile_model(code)
     except Exception as e:
         raise CompilationError(e)
+    #print("Compilation took: %ss" % (time.time() - start))
+    start = time.time()
 
     mv_dict_rep = _dict_to_list(source_metamodels) + [""] + _dict_to_list(target_metamodels) + [""]
     _input(["transformation_add_MT"] + mv_dict_rep + [operation_name])
@@ -454,11 +458,14 @@ def transformation_add_MT(source_metamodels, target_metamodels, operation_name,
         callback()
         _input("exit")
         mode = MODE_MODELLING
+    #print("Callbacks took: %ss" % (time.time() - start))
+    start = time.time()
 
     # Done, so RAMify and upload the model
     _handle_output("Waiting for model constructors...")
     _input(compiled)
     _handle_output("Success")
+    #print("Upload and RAMify took: %ss" % (time.time() - start))
 
 def transformation_add_AL(source_metamodels, target_metamodels, operation_name, code, callback=lambda: None):
     """Create a new action language model, which can be executed."""