-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakePic.py
127 lines (113 loc) · 5.27 KB
/
makePic.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
from graphviz import Digraph
# 目标系统OTA - accept
def makeOTA(data, filePath, fileName):
dot = Digraph()
for state in data.states:
if state in data.acceptStates:
dot.node(name=str(state), label=str(state), shape='doublecircle')
else:
dot.node(name=str(state), label=str(state))
for tran in data.trans:
tranLabel = " " + str(tran.input) + " " + tran.showGuards() + " " + str(tran.isReset)
dot.edge(str(tran.source), str(tran.target), tranLabel)
newFilePath = filePath + fileName
dot.render(newFilePath, view=True)
# 猜想OTA - accept
def makeLearnedOTA(data, filePath, fileName):
dot = Digraph()
states = []
for state in data.states:
if state != data.sinkState:
states.append(state)
for s in states:
if s in data.acceptStates:
dot.node(name=str(s), label=str(s), shape='doublecircle')
else:
dot.node(name=str(s), label=str(s))
for tran in data.trans:
if tran.source != data.sinkState and tran.target != data.sinkState:
tranLabel = " " + str(tran.input) + " " + tran.showGuards() + " " + str(tran.isReset)
dot.edge(str(tran.source), str(tran.target), tranLabel)
newFilePath = filePath + fileName
dot.render(newFilePath, view=True)
# 补全OTA - accept+sink
def makeFullOTA(data, filePath, fileName):
dot = Digraph()
for s in data.states:
if s in data.acceptStates:
dot.node(name=str(s), label=str(s), shape='doublecircle')
elif s == data.sinkState:
dot.node(name=str(s), label=str(s), shape='diamond')
else:
dot.node(name=str(s), label=str(s))
for tran in data.trans:
tranLabel = " " + str(tran.input) + " " + tran.showGuards() + " " + str(tran.isReset)
dot.edge(str(tran.source), str(tran.target), tranLabel)
newFilePath = filePath + fileName
dot.render(newFilePath, view=True)
# 两个自动机的交集OTA - accept+sink
def makeMergeOTA(data, filePath, fileName):
dot = Digraph()
for state in data.states:
if state.stateName in data.acceptStates:
dot.node(name=str(state.stateName), label=str(state.stateName), shape='doublecircle')
elif state.stateName == data.sinkState:
dot.node(name=str(state.stateName), label=str(state.stateName), shape='diamond')
else:
dot.node(name=str(state.stateName), label=str(state.stateName))
for tran in data.trans:
tranLabel = " " + str(tran.input) + " " + tran.showGuards() + " " + str(tran.isReset)
dot.edge(str(tran.source), str(tran.target), tranLabel)
newFilePath = filePath + fileName
dot.render(newFilePath, view=True)
# 两个自动机的交集OTA - accept+sink
def makeMergeOTA1(data, filePath, fileName):
dot = Digraph()
for state in data.states:
if state.stateName in data.acceptStates:
dot.node(name=str(state.stateName), label=str(state.stateName), shape='doublecircle')
elif state.stateName == data.sinkState:
pass
else:
dot.node(name=str(state.stateName), label=str(state.stateName))
for tran in data.trans:
if tran.source != data.sinkState and tran.target != data.sinkState:
tranLabel = " " + str(tran.input) + " " + tran.showGuards() + " " + str(tran.isReset)
dot.edge(str(tran.source), str(tran.target), tranLabel)
newFilePath = filePath + fileName
dot.render(newFilePath, view=True)
# 交集OTA的补 - accept+sink+error
def makeComplementOTA(data, filePath, fileName):
dot = Digraph()
for state in data.states:
if state.stateName in data.acceptStates:
dot.node(name=str(state.stateName), label=str(state.stateName), shape='doublecircle')
elif state.stateName == data.sinkState:
dot.node(name=str(state.stateName), label=str(state.stateName), shape='diamond')
elif state.stateName == data.errorState:
dot.node(name=str(state.stateName), label=str(state.stateName), shape='box')
else:
dot.node(name=str(state.stateName), label=str(state.stateName))
for tran in data.trans:
tranLabel = " " + str(tran.input) + " " + tran.showGuards() + " " + str(tran.isReset)
dot.edge(str(tran.source), str(tran.target), tranLabel)
newFilePath = filePath + fileName
dot.render(newFilePath, view=True)
# 交集OTA的补 - accept+error
def makeComplementOTA1(data, filePath, fileName):
dot = Digraph()
for state in data.states:
if state.stateName in data.acceptStates:
dot.node(name=str(state.stateName), label=str(state.stateName), shape='doublecircle')
elif state.stateName == data.sinkState:
pass
elif state.stateName == data.errorState:
dot.node(name=str(state.stateName), label=str(state.stateName), shape='box')
else:
dot.node(name=str(state.stateName), label=str(state.stateName))
for tran in data.trans:
if tran.source != data.sinkState and tran.target != data.sinkState:
tranLabel = " " + str(tran.input) + " " + tran.showGuards() + " " + str(tran.isReset)
dot.edge(str(tran.source), str(tran.target), tranLabel)
newFilePath = filePath + fileName
dot.render(newFilePath, view=True)