diff --git a/NodeLibrary.py b/NodeLibrary.py index 767fc70..e48639c 100644 --- a/NodeLibrary.py +++ b/NodeLibrary.py @@ -342,8 +342,8 @@ def state_visualization(self, n: DiagramNode) -> None: t = copy.deepcopy(t) # if "WAITALL" in t: # del t["WAITALL"] - if "WAIT" in t: - del t["WAIT"] + # if "WAIT" in t: + # del t["WAIT"] n.label += "\n" + str(t) n.height += 20 elif n.tokens_display == 'count only': @@ -358,13 +358,21 @@ def genF(self, l): def synchronization(self, tokens: Sequence[Dict], sync: Sequence[Dict], node: DiagramNode) -> Sequence[Dict]: sync = copy.deepcopy(sync) for t in tokens: + t = copy.deepcopy(t) + + if "event" in t.keys(): + e = t["event"] + t["le"] = e + for waitlist in t["WAITALL"]: + waitlist.remove(e) + del t["event"] if node.waitall is not "[]": if "WAITALL" not in t.keys(): t['WAITALL']= eval(node.waitall, globals(), t) - t = copy.deepcopy(t) - t['WAIT'] =(lambda w : w if callable(w) else self.genF(w))(list(itertools.chain(copy.deepcopy(t['WAITALL'])))) # need to be the union + + t['WAIT'] = self.genF(list(itertools.chain(copy.deepcopy(t['WAITALL'])))) # need to be the union # t['WAITALL']= [(lambda w :w if callable(w) else self.genF(w))(eval(w, globals(), t)) for w in node.waitall] sync.append(t) @@ -374,32 +382,21 @@ def synchronization(self, tokens: Sequence[Dict], sync: Sequence[Dict], node: Di # except KeyError: # t["COUNT"] = int(node.count) - return (sync, sync) + print(f"SYNC={sync}") + return (copy.deepcopy(sync), copy.deepcopy(sync)) def transformation(self, tokens: Sequence[Dict], node: DiagramNode, port: str) -> Sequence[Dict]: nxtt = [] for t in tokens: - - try: - e = t["event"] - t["le"] = e - if e is not None: - del t["event"] - for waitlist in t["WAITALL"]: - waitlist.remove(e) - if len(waitlist) == 0: - nxtt.append(copy.deepcopy(t)) + if [] in t["WAITALL"]: + nxtt.append(copy.deepcopy(t)) + except KeyError: pass - - - # if not t["WAITALL"]: - # nxtt.append(t) - return nxtt @@ -411,21 +408,21 @@ def type_string(self) -> str: def node_manipulator(self, node: DiagramNode) -> None: node.label = 'LOG' - node.log = [] + node.loog = [] super().node_manipulator(node) def state_visualization(self, n: DiagramNode) -> None: n.label = n.org_label - n.height = 50 + n.height = 100 n.label += "\n---------------------" - for t in n.log: + for t in n.loog: n.label += "\n" + str(t) n.height += 10 def synchronization(self, tokens: Sequence[Dict], sync: Sequence[Dict], node: DiagramNode) -> ( Sequence[Dict], Sequence[Dict]): if len(tokens) != 0: - node.log.append(tokens) + node.loog += tokens return (tokens, []) diff --git a/Tests/TTT.png b/Tests/TTT.png index 889b938..1854aa4 100644 Binary files a/Tests/TTT.png and b/Tests/TTT.png differ diff --git a/Tests/TTT3_run/1.png b/Tests/TTT3_run/1.png index 2b2eaf5..3855e81 100644 Binary files a/Tests/TTT3_run/1.png and b/Tests/TTT3_run/1.png differ diff --git a/Tests/TTT3_run/2.png b/Tests/TTT3_run/2.png index 2418f9c..3e3f09c 100644 Binary files a/Tests/TTT3_run/2.png and b/Tests/TTT3_run/2.png differ diff --git a/Tests/TTT3_run/3.png b/Tests/TTT3_run/3.png index e6b4b95..34516a6 100644 Binary files a/Tests/TTT3_run/3.png and b/Tests/TTT3_run/3.png differ diff --git a/Tests/TTT3_run/4.png b/Tests/TTT3_run/4.png index 5d7ae1b..41aceeb 100644 Binary files a/Tests/TTT3_run/4.png and b/Tests/TTT3_run/4.png differ diff --git a/Tests/TTT3_run/5.png b/Tests/TTT3_run/5.png index 447026a..e3d9a77 100644 Binary files a/Tests/TTT3_run/5.png and b/Tests/TTT3_run/5.png differ diff --git a/Tests/TTT3_run/6.png b/Tests/TTT3_run/6.png index f28aab8..0cdc8dc 100644 Binary files a/Tests/TTT3_run/6.png and b/Tests/TTT3_run/6.png differ diff --git a/Tests/TTT3_run/7.png b/Tests/TTT3_run/7.png index a063d56..9dcc916 100644 Binary files a/Tests/TTT3_run/7.png and b/Tests/TTT3_run/7.png differ diff --git a/Tests/TTT3_run/8.png b/Tests/TTT3_run/8.png index a063d56..9dcc916 100644 Binary files a/Tests/TTT3_run/8.png and b/Tests/TTT3_run/8.png differ diff --git a/Tests/TTT_maor.flow b/Tests/TTT_maor.flow index 008989c..f85c7a6 100644 --- a/Tests/TTT_maor.flow +++ b/Tests/TTT_maor.flow @@ -21,7 +21,7 @@ global All All= lambda A:[A(i) for i in range(1,9)] global AllMove -AllMove=lambda : All(X).extern(All(O)) +AllMove=lambda : All(X) + All(O) " @@ -29,7 +29,7 @@ AllMove=lambda : All(X).extern(All(O)) st3 [type=start, initial="[{'path':path} for path in Path ]", width=400]; wa [type=waitall, waitall="[[X(i) for i in path]]"] - rq3 [type=sync, req="['Player X wins'], block =[AllMove()]"] + rq3 [type=sync, req="['Player X wins']", block="AllMove()"] @@ -42,12 +42,13 @@ AllMove=lambda : All(X).extern(All(O)) # For debugging class hidden [color = none, style = none, textcolor = white]; - stt -> listener -> "Event viewer" -> listener [style = "none"]; + stt -> listener -> logger -> listener [style = "none"]; listener [type=sync, - wait="['X'+str(i) for i in range(1,9)]+['O'+str(i) for i in range(1,9)]", + wait="['X'+str(i) for i in range(1,9)]+['O'+str(i) for i in range(1,9)] + ['@']", class = "hidden", autoformat='false']; + logger [type=logger, label="Events log", autoformat='false'] stt [type=start, class = "hidden", autoformat='false']; } diff --git a/Tests/TTT_run/1.png b/Tests/TTT_run/1.png index 311f33f..c5bf561 100644 Binary files a/Tests/TTT_run/1.png and b/Tests/TTT_run/1.png differ diff --git a/Tests/TTT_run/2.png b/Tests/TTT_run/2.png index 38af28a..14c9658 100644 Binary files a/Tests/TTT_run/2.png and b/Tests/TTT_run/2.png differ