فهرست منبع

maybe a working version?

Simon Van Mierlo 9 سال پیش
والد
کامیت
b4d6dafce9
3فایلهای تغییر یافته به همراه262 افزوده شده و 12 حذف شده
  1. 1 1
      interface/PDEVS/interface.py
  2. 23 3
      models/example_PS.mvc
  3. 238 8
      models/ps_to_devs.mvc

+ 1 - 1
interface/PDEVS/interface.py

@@ -1,7 +1,7 @@
 """
 Generated by Statechart compiler by Glenn De Jonghe, Joeri Exelmans, Simon Van Mierlo, and Yentl Van Tendeloo (for the inspiration)
 
-Date:   Fri Oct 13 11:22:10 2017
+Date:   Sun Oct 15 20:24:57 2017
 
 Model author: Simon Van Mierlo
 Model name:   Translational Semantics Debugging Interface

+ 23 - 3
models/example_PS.mvc

@@ -44,12 +44,32 @@ Conv_To_M(b_g_to_assembler, assembler) {}
 Conv_To_M(mg_g_to_assembler, assembler) {}
 Conv_To_M(wc_g_to_assembler, assembler) {}
 
+QualityControl qualitycontrol {}
+ConveyorBelt assembler_to_qualitycontrol {
+    capacity = 3
+}
+M_To_Conv(assembler, assembler_to_qualitycontrol) {}
+Conv_To_M(assembler_to_qualitycontrol, qualitycontrol) {}
+
+Repair repair {}
+ConveyorBelt qualitycontrol_broken_to_repair {
+    capacity = 3
+}
+QC_To_Conv(qualitycontrol, qualitycontrol_broken_to_repair) {}
+Conv_To_M(qualitycontrol_broken_to_repair, repair) {}
+
 Collector collector {}
-ConveyorBelt assembler_to_collector {
+ConveyorBelt qualitycontrol_to_collector {
+    capacity = 3
+}
+M_To_Conv(qualitycontrol, qualitycontrol_to_collector) {}
+Conv_To_M(qualitycontrol_to_collector, collector) {}
+
+ConveyorBelt repair_to_collector {
     capacity = 3
 }
-M_To_Conv(assembler, assembler_to_collector) {}
-Conv_To_M(assembler_to_collector, collector) {}
+M_To_Conv(repair, repair_to_collector) {}
+Conv_To_M(repair_to_collector, collector) {}
 
 Operator op1 {}
 Operator op2 {}

+ 238 - 8
models/ps_to_devs.mvc

@@ -380,6 +380,119 @@ Composite schedule {
             }
         }
     }
+    {Contains} ForAll rep_to_adevs {
+        LHS {
+            Pre_ProductionSystem/Repair rep_to_adevs_pre_ass {
+                label = "rep"
+            }
+            Pre_ParallelDEVS/CoupledDEVSBlock rep_to_adevs_pre_root {
+                label = "root"
+                constraint_name = $
+                    Boolean function constraint(value: String):
+                        return (value == "Root")!
+                $
+            }
+        }
+        RHS {
+            Post_ProductionSystem/Repair rep_to_adevs_post_ass {
+                label = "rep"
+            }
+            Post_ParallelDEVS/AtomicDEVSBlock rep_to_adevs_post_adevs {
+                label = "adevs"
+                value_name = $
+                    String function value(model : Element, name : String, mapping : Element):
+                        return list_read(string_split(mapping["rep"], "/"), 1)!
+                $
+                value_initialState = $
+                    String function value(model : Element, name : String, mapping : Element):
+                        return "\t\treturn {'name': 'waiting', 'item': None}"!
+                $
+                value_intTransition = $
+                    String function value(model : Element, name : String, mapping : Element):
+                        return "\t\tif self.state['name'] == 'repairing':\n\t\t\tself.state['name'] = 'waiting'\n\t\treturn self.state"!
+                $
+                value_outputFnc = $
+                    String function value(model : Element, name : String, mapping : Element):
+                        return "\t\tif self.state['name'] == 'repairing' and self.state['item']:\n\t\t\treturn {self.my_ports['rep_out']: [self.state['item']]}\n\t\telse:\n\t\t\treturn AtomicDEVS.outputFnc(self)"!
+                $
+                value_extTransition = $
+                    String function value(model : Element, name : String, mapping : Element):
+                        return "\t\tif self.state['name'] == 'waiting':\n\t\t\tself.state['item'] = my_inputs[self.my_ports['rep_in']][0]\n\t\t\tself.state['item']['broken'] = False\n\t\t\tself.state['name'] = 'repairing'"!
+                $
+                value_confTransition = $
+                    String function value(model : Element, name : String, mapping : Element):
+                        return "\t\treturn AtomicDEVS.confTransition(self, my_inputs)"!
+                $
+                value_timeAdvance = $
+                    String function value(model : Element, name : String, mapping : Element):
+                        return "\t\tif self.state['name'] == 'waiting':\n\t\t\treturn INFINITY\n\t\telif self.state['name'] == 'repairing':\n\t\t\treturn 2"!
+                $
+            }
+            Post_ParallelDEVS/InputPort rep_to_adevs_post_iport {
+                label = "iport"
+                value_name = $
+                    String function value(model : Element, name : String, mapping : Element):
+                        return "rep_in"!
+                $
+            }            
+            Post_ParallelDEVS/DEVSBlockToPort(rep_to_adevs_post_adevs, rep_to_adevs_post_iport) {
+                label = "rep_to_iport"
+            }
+            Post_ParallelDEVS/OutputPort rep_to_adevs_post_oport {
+                label = "oport"
+                value_name = $
+                    String function value(model : Element, name : String, mapping : Element):
+                        return "rep_out"!
+                $
+            }            
+            Post_ParallelDEVS/DEVSBlockToPort(rep_to_adevs_post_adevs, rep_to_adevs_post_oport) {
+                label = "rep_to_oport"
+            }
+            Post_ParallelDEVS/DEVSInstance rep_to_adevs_post_devsi {
+                label = "devsi"
+                value_type = $
+                    String function value(model : Element, name : String, mapping : Element):
+                        return list_read(string_split(mapping["rep"], "/"), 1)!
+                $
+                value_name = $
+                    String function value(model : Element, name : String, mapping : Element):
+                        return (cast_i2s(list_read(string_split(mapping["rep"], "/"), 1)) + "_i")!
+                $
+            }
+            Post_ParallelDEVS/InputPort rep_to_adevs_post_iporti {
+                label = "iporti"
+                value_name = $
+                    String function value(model : Element, name : String, mapping : Element):
+                        return "rep_in"!
+                $
+            }            
+            Post_ParallelDEVS/DEVSInstanceToPort(rep_to_adevs_post_devsi, rep_to_adevs_post_iporti) {
+                label = "devsi_to_iporti"
+            }
+            Post_ParallelDEVS/OutputPort rep_to_adevs_post_oporti {
+                label = "oporti"
+                value_name = $
+                    String function value(model : Element, name : String, mapping : Element):
+                        return "rep_out"!
+                $
+            }            
+            Post_ParallelDEVS/DEVSInstanceToPort(rep_to_adevs_post_devsi, rep_to_adevs_post_oporti) {
+                label = "devsi_to_oporti"
+            }
+            Post_ParallelDEVS/CoupledDEVSBlock rep_to_adevs_post_root {
+                label = "root"
+            }
+            Post_ParallelDEVS/SubModel(rep_to_adevs_post_root, rep_to_adevs_post_devsi) {
+                label = "root_to_devsi"
+            }
+            Post_PS2DEVS_typelink(rep_to_adevs_post_ass, rep_to_adevs_post_adevs) {
+                label = "typelink"
+            }
+            Post_PS2DEVS_instancelink(rep_to_adevs_post_ass, rep_to_adevs_post_devsi) {
+                label = "instancelink"
+            }
+        }
+    }
     {Contains} ForAll qc_to_adevs {
         LHS {
             Pre_ProductionSystem/QualityControl qc_to_adevs_pre_qc {
@@ -452,7 +565,7 @@ Composite schedule {
                 label = "oport_working"
                 value_name = $
                     String function value(model : Element, name : String, mapping : Element):
-                        return "qc_out_broken"!
+                        return "qc_out_working"!
                 $
             }            
             Post_ParallelDEVS/DEVSBlockToPort(qc_to_adevs_post_adevs, qc_to_adevs_post_oport_working) {
@@ -493,7 +606,7 @@ Composite schedule {
                 label = "oport_workingi"
                 value_name = $
                     String function value(model : Element, name : String, mapping : Element):
-                        return "qc_out_broken"!
+                        return "qc_out_working"!
                 $
             }            
             Post_ParallelDEVS/DEVSInstanceToPort(qc_to_adevs_post_devsi, qc_to_adevs_post_oport_workingi) {
@@ -505,10 +618,123 @@ Composite schedule {
             Post_ParallelDEVS/SubModel(qc_to_adevs_post_root, qc_to_adevs_post_devsi) {
                 label = "root_to_devsi"
             }
-            Post_PS2DEVS_typelink(qc_to_adevs_post_ass, qc_to_adevs_post_adevs) {
+            Post_PS2DEVS_typelink(qc_to_adevs_post_qc, qc_to_adevs_post_adevs) {
+                label = "typelink"
+            }
+            Post_PS2DEVS_instancelink(qc_to_adevs_post_qc, qc_to_adevs_post_devsi) {
+                label = "instancelink"
+            }
+        }
+    }
+    {Contains} ForAll op_to_adevs {
+        LHS {
+            Pre_ProductionSystem/Operator op_to_adevs_pre_op {
+                label = "op"
+            }
+            Pre_ParallelDEVS/CoupledDEVSBlock op_to_adevs_pre_root {
+                label = "root"
+                constraint_name = $
+                    Boolean function constraint(value: String):
+                        return (value == "Root")!
+                $
+            }
+        }
+        RHS {
+            Post_ProductionSystem/QualityControl op_to_adevs_post_op {
+                label = "op"
+            }
+            Post_ParallelDEVS/AtomicDEVSBlock op_to_adevs_post_adevs {
+                label = "adevs"
+                value_name = $
+                    String function value(model : Element, name : String, mapping : Element):
+                        return list_read(string_split(mapping["op"], "/"), 1)!
+                $
+                value_initialState = $
+                    String function value(model : Element, name : String, mapping : Element):
+                        return "\t\treturn {'name': 'waiting', 'queue': [], 'item': None}"!
+                $
+                value_intTransition = $
+                    String function value(model : Element, name : String, mapping : Element):
+                        return "\t\tif self.state['name'] == 'allocating':\n\t\t\tself.state['name'] = 'allocated'\n\t\treturn self.state"!
+                $
+                value_outputFnc = $
+                    String function value(model : Element, name : String, mapping : Element):
+                        return "\t\tif self.state['name'] == 'allocating':\n\t\treturn {self.my_ports['op_out']: [{'type': 'allocate', 'value': self.state['item']}]}"!
+                $
+                value_extTransition = $
+                    String function value(model : Element, name : String, mapping : Element):
+                        return "\t\tif self.my_ports[self.my_ports['op_in']][0]['type'] == 'request':\n\t\t\tself.state['queue'].append(my_inputs[self.my_ports['op_in']][0]['value'])\n\t\telif self.my_ports[self.my_ports['op_in']][0]['type'] == 'release':\n\t\t\tself.state['name'] = 'waiting'\n\t\tif self.state['name'] == 'waiting' and self.state['queue']:\n\t\t\tself.state['name'] = 'allocating'\n\t\t\tself.state['item'] = self.state['queue'].pop()\n\t\treturn self.state"!
+                $
+                value_confTransition = $
+                    String function value(model : Element, name : String, mapping : Element):
+                        return "\t\treturn AtomicDEVS.confTransition(self, my_inputs)"!
+                $
+                value_timeAdvance = $
+                    String function value(model : Element, name : String, mapping : Element):
+                        return "\t\tif self.state['name'] == 'allocating' and self.state['queue']:\n\t\t\treturn 0\n\t\telse:\n\t\t\treturn INFINITY"!
+                $
+            }
+            Post_ParallelDEVS/InputPort op_to_adevs_post_iport {
+                label = "iport"
+                value_name = $
+                    String function value(model : Element, name : String, mapping : Element):
+                        return "op_in"!
+                $
+            }            
+            Post_ParallelDEVS/DEVSBlockToPort(op_to_adevs_post_adevs, op_to_adevs_post_iport) {
+                label = "op_to_iport"
+            }
+            Post_ParallelDEVS/OutputPort op_to_adevs_post_oport {
+                label = "oport"
+                value_name = $
+                    String function value(model : Element, name : String, mapping : Element):
+                        return "op_out"!
+                $
+            }            
+            Post_ParallelDEVS/DEVSBlockToPort(op_to_adevs_post_adevs, op_to_adevs_post_oport) {
+                label = "op_to_oport"
+            }
+            Post_ParallelDEVS/DEVSInstance op_to_adevs_post_devsi {
+                label = "devsi"
+                value_type = $
+                    String function value(model : Element, name : String, mapping : Element):
+                        return list_read(string_split(mapping["op"], "/"), 1)!
+                $
+                value_name = $
+                    String function value(model : Element, name : String, mapping : Element):
+                        return (cast_i2s(list_read(string_split(mapping["op"], "/"), 1)) + "_i")!
+                $
+            }
+            Post_ParallelDEVS/InputPort op_to_adevs_post_iporti {
+                label = "iporti"
+                value_name = $
+                    String function value(model : Element, name : String, mapping : Element):
+                        return "op_in"!
+                $
+            }            
+            Post_ParallelDEVS/DEVSInstanceToPort(op_to_adevs_post_devsi, op_to_adevs_post_iporti) {
+                label = "devsi_to_iporti"
+            }
+            Post_ParallelDEVS/OutputPort op_to_adevs_post_oporti {
+                label = "oporti"
+                value_name = $
+                    String function value(model : Element, name : String, mapping : Element):
+                        return "op_out"!
+                $
+            }            
+            Post_ParallelDEVS/DEVSInstanceToPort(op_to_adevs_post_devsi, op_to_adevs_post_oporti) {
+                label = "devsi_to_oporti"
+            }
+            Post_ParallelDEVS/CoupledDEVSBlock op_to_adevs_post_root {
+                label = "root"
+            }
+            Post_ParallelDEVS/SubModel(op_to_adevs_post_root, op_to_adevs_post_devsi) {
+                label = "root_to_devsi"
+            }
+            Post_PS2DEVS_typelink(op_to_adevs_post_op, op_to_adevs_post_adevs) {
                 label = "typelink"
             }
-            Post_PS2DEVS_instancelink(qc_to_adevs_post_ass, qc_to_adevs_post_devsi) {
+            Post_PS2DEVS_instancelink(op_to_adevs_post_op, op_to_adevs_post_devsi) {
                 label = "instancelink"
             }
         }
@@ -1028,8 +1254,10 @@ Initial (schedule, init) {}
 OnSuccess (init, gen_to_adevs) {}
 OnSuccess (gen_to_adevs, coll_to_adevs) {}
 OnSuccess (coll_to_adevs, ass_to_adevs) {}
-OnSuccess (ass_to_adevs, qc_to_adevs) {}
-OnSuccess (qc_to_adevs, convbelt_to_adevs_init) {}
+OnSuccess (ass_to_adevs, rep_to_adevs) {}
+OnSuccess (rep_to_adevs, qc_to_adevs) {}
+OnSuccess (qc_to_adevs, op_to_adevs) {}
+OnSuccess (op_to_adevs, convbelt_to_adevs_init) {}
 OnSuccess (convbelt_to_adevs_init, convbelt_to_adevs_next) {}
 OnSuccess (convbelt_to_adevs_next, convbelt_to_adevs_next) {}
 OnFailure (convbelt_to_adevs_next, connect_machine_to_convbelt) {}
@@ -1041,8 +1269,10 @@ OnSuccess (finish, success) {}
 OnFailure (init, gen_to_adevs) {}
 OnFailure (gen_to_adevs, coll_to_adevs) {}
 OnFailure (coll_to_adevs, ass_to_adevs) {}
-OnFailure (ass_to_adevs, qc_to_adevs) {}
-OnFailure (qc_to_adevs, convbelt_to_adevs_init) {}
+OnFailure (ass_to_adevs, rep_to_adevs) {}
+OnFailure (rep_to_adevs, qc_to_adevs) {}
+OnFailure (qc_to_adevs, op_to_adevs) {}
+OnFailure (op_to_adevs, convbelt_to_adevs_init) {}
 OnFailure (convbelt_to_adevs_init, connect_machine_to_convbelt) {}
 OnFailure (connect_machine_to_convbelt, connect_qc_to_convbelt) {}
 OnFailure (connect_qc_to_convbelt, connect_convbelt_to_machine) {}