Skip to content

Commit

Permalink
Still not working
Browse files Browse the repository at this point in the history
  • Loading branch information
geraw committed Feb 8, 2022
1 parent 77080ef commit 9930a9a
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 28 deletions.
45 changes: 21 additions & 24 deletions NodeLibrary.py
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand All @@ -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)
Expand All @@ -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


Expand All @@ -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, [])
Binary file modified Tests/TTT.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Tests/TTT3_run/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Tests/TTT3_run/2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Tests/TTT3_run/3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Tests/TTT3_run/4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Tests/TTT3_run/5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Tests/TTT3_run/6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Tests/TTT3_run/7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Tests/TTT3_run/8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 5 additions & 4 deletions Tests/TTT_maor.flow
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ 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)
"


st3 -> wa -> rq3;

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()"]



Expand All @@ -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'];

}
Binary file modified Tests/TTT_run/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Tests/TTT_run/2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 9930a9a

Please sign in to comment.