Skip to content

Commit

Permalink
adding the fuctuality for remove the token if it get out of the group
Browse files Browse the repository at this point in the history
  • Loading branch information
maor226 committed Apr 6, 2022
1 parent 0626099 commit 4ec24a6
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 13 deletions.
23 changes: 19 additions & 4 deletions Tests/group_test.flow
Original file line number Diff line number Diff line change
@@ -1,22 +1,37 @@
blockdiag {
st -> req1 -> req2;
st -> wt2;
wt1 -> req3;
st -> wt1 -> req3;
bl3;

st [type=start];
req1 [type=sync, req="['1']"];
req2 [type=sync, req="['2']"];
req3 [type=sync, req="['3']"];

wt1 [type=sync, wait="['1']"];
wt2 [type=sync, wait="['2']"];
bl3 [type=sync, block="['3']"];

group {
req1;
req2;
wt2;
wt1;
bl3
}


######################################################################################

# For debugging
class hidden [color = none, style = none, textcolor = white];
stt -> listener -> logger -> listener [style = "none"];

listener [type=sync,
wait="lambda e: True",
class = "hidden", autoformat='false'];

logger [type=logger, label="Events log", autoformat='false', width=200]
stt [type=start, class = "hidden", autoformat='false'];



}
Binary file modified Tests/group_test.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 13 additions & 9 deletions flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,19 +161,12 @@ def step_to_next_state(diagram):
t["ID"] = _id
_id += 1
tmp[sn].extend(trans)

tmp[n].extend(trans)

tmp[n].extend(n.node_type.keep(n.tokens, n))

# for g in nodes_group:
# for n in g.conn_nodes:
# for t in n.tokens + n.sync:
# for sn in g.groupStop:
# if t["ID"] not in [tt["ID"] for tt in (sn.tokens + sn.sync)]:
# if t in n.tokens:
# n.tokens.remove(t)
# elif t in n.sync:
# n.sync.remove(t)


for n in nodes:
tmp[n], n.sync = n.node_type.synchronization(tmp[n], n.sync, n)
Expand All @@ -190,6 +183,17 @@ def step_to_next_state(diagram):
n.tokens.remove(t)
elif t in n.sync:
n.sync.remove(t)
for g in nodes_group:
ids =[]
for n in g.conn_nodes:
ids.extend([t["ID"] for t in (n.tokens + n.sync)])
for n in g.groupStop:
for t in n.tokens +n.sync:
if t["ID"] not in ids:
if t in n.tokens:
n.tokens.remove(t)
elif t in n.sync:
n.sync.remove(t)
return changed


Expand Down

0 comments on commit 4ec24a6

Please sign in to comment.