|
|
@@ -449,12 +449,13 @@ class PNInterface(tk.Tk):
|
|
|
|
|
|
def setup(self):
|
|
|
free = PlaceVis(self.pn_canvas, 100, 200, "free", 3)
|
|
|
+ max_items = PlaceVis(self.pn_canvas, 150, 400, "maximum items", 3)
|
|
|
producing = PlaceVis(self.pn_canvas, 200, 200, "producing", 0)
|
|
|
produced = PlaceVis(self.pn_canvas, 300, 200, "produced", 0)
|
|
|
waiting = PlaceVis(self.pn_canvas, 400, 200, "waiting", 2)
|
|
|
consuming = PlaceVis(self.pn_canvas, 500, 200, "consuming", 0)
|
|
|
global places
|
|
|
- places = [free, producing, produced, waiting, consuming]
|
|
|
+ places = [free, producing, produced, waiting, consuming, max_items]
|
|
|
|
|
|
start_produce = TransitionVis(self.pn_canvas, 150, 100, "start producing")
|
|
|
end_produce = TransitionVis(self.pn_canvas, 150, 300, "end producing")
|
|
|
@@ -466,6 +467,7 @@ class PNInterface(tk.Tk):
|
|
|
f_to_s_p = PlaceToTransitionVis(self.pn_canvas, free, start_produce)
|
|
|
s_p_to_p = TransitionToPlaceVis(self.pn_canvas, start_produce, producing)
|
|
|
p_to_e_p = PlaceToTransitionVis(self.pn_canvas, producing, end_produce)
|
|
|
+ m_i_to_e_p = PlaceToTransitionVis(self.pn_canvas, max_items, end_produce)
|
|
|
e_p_to_f = TransitionToPlaceVis(self.pn_canvas, end_produce, free)
|
|
|
|
|
|
w_to_s_c = PlaceToTransitionVis(self.pn_canvas, waiting, start_consume)
|
|
|
@@ -476,7 +478,7 @@ class PNInterface(tk.Tk):
|
|
|
e_p_to_p = TransitionToPlaceVis(self.pn_canvas, end_produce, produced)
|
|
|
p_to_s_c = PlaceToTransitionVis(self.pn_canvas, produced, start_consume)
|
|
|
global p2ts
|
|
|
- p2ts = [f_to_s_p, p_to_e_p, w_to_s_c, c_to_e_c, p_to_s_c]
|
|
|
+ p2ts = [f_to_s_p, p_to_e_p, w_to_s_c, c_to_e_c, p_to_s_c, m_i_to_e_p]
|
|
|
global t2ps
|
|
|
t2ps = [s_p_to_p, e_p_to_f, s_c_to_c, e_c_to_w, e_p_to_p]
|
|
|
|
|
|
@@ -558,12 +560,21 @@ class PNInterface(tk.Tk):
|
|
|
except ModelExists:
|
|
|
pass
|
|
|
|
|
|
+ def executeAL():
|
|
|
+ print("Execute AL")
|
|
|
+ status = transformation_execute_AL("analyseReachability", {"PetriNet": "my_pn"}, {"ReachabilityGraph": "my_reachability"}, callback=self.callback)
|
|
|
+ print("Reachability generation success: " + str(status))
|
|
|
+
|
|
|
+ print("Execute MT")
|
|
|
+ def print_mv(value):
|
|
|
+ print(value)
|
|
|
+ status = transformation_execute_MT("printReachability", {"ReachabilityGraph": "my_reachability"}, {}, callback=print_mv)
|
|
|
+ print("Reachability printing success: " + str(status))
|
|
|
+
|
|
|
# Start the reachability graph generation
|
|
|
- print("Execute AL")
|
|
|
- thrd = threading.Thread(target=transformation_execute_AL, args=["analyseReachability", {"PetriNet": "my_pn"}, {"ReachabilityGraph": "my_reachability"}, self.callback])
|
|
|
+ thrd = threading.Thread(target=executeAL)
|
|
|
thrd.daemon = True
|
|
|
thrd.start()
|
|
|
- # status = transformation_execute_AL("analyseReachability", {"PetriNet": "my_pn"}, {"ReachabilityGraph": "my_reachability"}, callback=self.callback)
|
|
|
|
|
|
def callback(self, value):
|
|
|
if value.startswith("{"):
|
|
|
@@ -576,6 +587,11 @@ class PNInterface(tk.Tk):
|
|
|
m2 = [m for m in self.markings if m.node_id == parsed_value['link_info']['target']][0]
|
|
|
t = [t for t in transitions if t.name == parsed_value['link_info']['transition']][0]
|
|
|
self.m2ms.append(MarkingToMarkingVis(self.rg_canvas, m1, m2, t))
|
|
|
+ elif parsed_value["msg_type"] == "reachable_nodes":
|
|
|
+ for n in parsed_value["nodes"]:
|
|
|
+ node_id = n['node_id']
|
|
|
+ if len([m for m in self.markings if m.node_id == node_id]) == 0:
|
|
|
+ self.markings.append(MarkingVis(self.rg_canvas, 100, 50, node_id, n['node_marking']))
|
|
|
return
|
|
|
if value.startswith("#"):
|
|
|
value = value[1:]
|