瀏覽代碼

Minor patches to bootstrap to allow for model_modify without providing metamodel name

Yentl Van Tendeloo 7 年之前
父節點
當前提交
eeaf7fdf4b
共有 4 個文件被更改,包括 36 次插入12 次删除
  1. 二進制
      bootstrap/bootstrap.m.gz
  2. 9 0
      bootstrap/core_algorithm.alc
  3. 26 11
      model/model.py
  4. 1 1
      model/operations

二進制
bootstrap/bootstrap.m.gz


+ 9 - 0
bootstrap/core_algorithm.alc

@@ -1597,6 +1597,15 @@ String function cmd_model_modify(model_name : String, metamodel_name : String):
 			type_id = set_pop(allAssociationDestinations(core, model_id, "instanceOf"))
 			if (allow_read(current_user_id, type_id)):
 				Element new_model
+
+				if (metamodel_name == ""):
+					// Try to find the metamodel ourselves, assuming there to be only one!
+					Element types
+					types = allAssociationDestinations(core, model_id, "instanceOf")
+					while (set_len(types) > 0):
+						metamodel_name = full_name(set_pop(types))
+						break!
+
 				new_model = get_full_model(model_id, get_entry_id(metamodel_name))
 				if (element_eq(new_model, read_root())):
 					return "No conformance relation can be found between these models"!

+ 26 - 11
model/model.py

@@ -406,7 +406,7 @@ class ModelverseInterface(AtomicDEVS):
                 if prev_output.startswith("Please edit this model before sending next input: "):
                     _, model_name = prev_output.split("Please edit this model before sending next input: ", 1)
                     self.state.do_additional_operations = True
-                    self.state.send_operations = [[], ["admin"], ["admin"], ["quiet"], ["model_modify", model_name, "formalisms/SimpleClassDiagrams"]] + self.state.additional_operations[0] + [["exit"]]
+                    self.state.send_operations = [[], ["admin"], ["admin"], ["quiet"], ["model_modify", model_name, ""]] + self.state.additional_operations[0] + [["exit"]]
                     self.state.additional_taskname = str(uuid.uuid4())
                     print("Modifying model " + str(model_name))
                     print("On taskname " + str(self.state.additional_taskname))
@@ -416,10 +416,29 @@ class ModelverseInterface(AtomicDEVS):
                     print("Spawned activity")
                     _, task_name = prev_output.split("Spawned activity on task: ", 1)
                     self.state.blocked = True
+                    self.state.allow_progress = False
+                    self.state.send_operations = [[], []]
+                    # We now know that there is something to do on an other task, so we just wait for that event to come in
+                else:
+                    print("UNKNOWN: " + str(prev_output))
 
             elif inp[0] != self.taskname:
                 # Got some output on another task
-                if self.state.send_operations == []:
+                if inp[1].startswith("Please edit this model before sending next input: "):
+                    _, model_name = inp[1].split("Please edit this model before sending next input: ", 1)
+                    self.state.do_additional_operations = True
+                    self.state.send_operations = [[], ["admin"], ["admin"], ["quiet"], ["model_modify", model_name, ""]] + self.state.keyed_operations[self.state.op_name] + [["exit"]]
+                    self.state.additional_taskname = str(uuid.uuid4())
+                    print("Modifying model " + str(model_name))
+                    print("On taskname " + str(self.state.additional_taskname))
+                    self.state.create_additional_task = True
+                    self.state.had_key = inp[0]
+                elif inp[1].startswith("Please perform manual operation "):
+                    _, op_name = inp[1].split("Please perform manual operation ", 1)
+                    self.state.op_name = op_name[1:-1]
+                elif inp[1].startswith("Success: ready for "):
+                    pass
+                elif self.state.send_operations == []:
                     # At the end of these operations, so finish up!
                     if self.state.had_key is not None:
                         self.state.keyed_operations.pop(self.state.had_key)
@@ -434,15 +453,6 @@ class ModelverseInterface(AtomicDEVS):
                         self.state.send_operations = None
                         self.state.operations.pop(0)
                         print("Clear up to the normal task!")
-                elif inp[1].startswith("Please edit this model before sending next input: "):
-                    _, model_name = inp[1].split("Please edit this model before sending next input: ", 1)
-                    self.state.do_additional_operations = True
-                    self.state.send_operations = [[], ["admin"], ["admin"], ["quiet"], ["model_modify", model_name, "formalisms/SimpleClassDiagrams"]] + self.state.keyed_operations[inp[0]] + [["exit"]]
-                    self.state.additional_taskname = str(uuid.uuid4())
-                    print("Modifying model " + str(model_name))
-                    print("On taskname " + str(self.state.additional_taskname))
-                    self.state.create_additional_task = True
-                    self.state.had_key = inp[0]
 
         return self.state
 
@@ -613,6 +623,7 @@ class System(CoupledDEVS):
 taskname = "test_task"
 
 operations = json.loads(open("model/operations", 'r').read())
+operations = json.loads(open("model/operations_simple", 'r').read())
 additional_operations = [[], # revise_req
                          [], # revise_environment
                          [], # revise_plant
@@ -624,11 +635,15 @@ additional_operations = [[], # revise_req
                          [["instantiate_edge", "Association", "CTRL2EPN_link", "PW_Control/State", "Encapsulated_PetriNet/Place"], ["instantiate_edge", "Association", "CTRL2EPN_tlink", "PW_Control/Transition", "Encapsulated_PetriNet/Transition"]], # control_to_EPN
                          [["instantiate_edge", "Association", "ENV2EPN_link", "PW_Environment/Event", "Encapsulated_PetriNet/Place"]], # environment_to_EPN
                          [["instantiate_edge", "Association", "EPN2PN_place_link", "Encapsulated_PetriNet/Place", "PetriNet/Place"], ["instantiate_edge", "Association", "EPN2PN_transition_link", "Encapsulated_PetriNet/Transition", "PetriNet/Transition"]], # EPN_to_PN
+                         [], # match
                          [], # reachability
                          [], # bfs
                          [], # merge
                         ]
+
+additional_operations = [[]]
 keyed_operations = {}
+keyed_operations = {"models/modify_lang": [["instantiate_node", "PN/Class", ""]]}
 finish_on = "FINISHED"
 
 args = {

文件差異過大導致無法顯示
+ 1 - 1
model/operations