Skip to content

Commit 57771ac

Browse files
committed
add pma etc. in bin directory, run pma.py etc. in pymodel
revise test*.py in all samples to use pma etc. not pma.py etc. remove bin/tpath and tpath.bat, now included in pymodel_paths
1 parent 5e4bd8b commit 57771ac

36 files changed

+235
-151
lines changed

bin/pma

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env python
2+
"""
3+
This is pma command in bin directory, runs pma.py module in pymodel directory
4+
"""
5+
6+
import pma # find pma.py anywhere on Python path
7+
8+
pma.main()

bin/pmg

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env python
2+
"""
3+
This is pmg command in bin directory, runs pmg.py module in pymodel directory
4+
"""
5+
6+
import pmg # find pmg.py anywhere on Python path
7+
8+
pmg.main()

bin/pmv

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env python
2+
"""
3+
This is pmv command in bin directory, runs pmv.py module in pymodel directory
4+
"""
5+
6+
import pmv # find pmv.py anywhere on Python path
7+
8+
pmv.main()

bin/tpath

Lines changed: 0 additions & 1 deletion
This file was deleted.

bin/tpath.bat

Lines changed: 0 additions & 3 deletions
This file was deleted.

bin/trun

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env python
2+
3+
import sys
4+
import os
5+
6+
# argv[1] is name of module containing test cases
7+
# dir containing this module must be on PYTHONPATH
8+
9+
test = __import__(sys.argv[1])
10+
11+
# Test cases are in 'cases', a list of pairs of strings, descrip. and commmand:
12+
# cases = [
13+
# ('Test PowerOn, PowerOff alternate due to enabling conditions',
14+
# 'pct.py -n 10 PowerSwitch'),
15+
# ... ]
16+
17+
for (description, cmd) in test.cases:
18+
print description
19+
os.system(cmd)
20+
print

bin/wsgirunner

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env python
2+
"""
3+
This is wsgirunner command in bin directory, runs wsgirunner.py module in pymodel directory
4+
"""
5+
6+
import wsgirunner # find wsgirunner.py anywhere on Python path
7+
8+
wsgirunner.main()

pymodel/pmv.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,16 @@ def command(cmd):
3232
if status:
3333
print 'Failed: %s' % cmd # status 0 means success
3434

35-
(options, args) = ViewerOptions.parse_args()
36-
basename = options.__dict__['output'] if options.__dict__['output'] else '%sFSM' % args[0]
37-
pma = 'pma.py ' + make_opts(pma_keys, options) + ' ' + ' '.join(args)
38-
command(pma)
39-
pmg = 'pmg.py ' + make_opts(pmg_keys, options) + ' %s' % basename
40-
command(pmg)
41-
dot = 'dot -T%(type)s -o %(name)s.%(type)s %(name)s.dot' % \
42-
{'type': options.__dict__['fileType'], 'name': basename}
43-
command(dot)
35+
def main():
36+
(options, args) = ViewerOptions.parse_args()
37+
basename = options.__dict__['output'] if options.__dict__['output'] else '%sFSM' % args[0]
38+
pma = 'pma ' + make_opts(pma_keys, options) + ' ' + ' '.join(args)
39+
command(pma)
40+
pmg = 'pmg ' + make_opts(pmg_keys, options) + ' %s' % basename
41+
command(pmg)
42+
dot = 'dot -T%(type)s -o %(name)s.%(type)s %(name)s.dot' % \
43+
{'type': options.__dict__['fileType'], 'name': basename}
44+
command(dot)
45+
46+
if __name__ == ' __main__':
47+
main()
Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,33 @@
1-
"""
2-
SpeedControl defined by FSM, no shared actions with PowerSwitch
3-
"""
1+
2+
# pma --maxTransitions 100 --output SpeedControl SpeedControl
3+
# 3 states, 3 transitions, 1 accepting states, 0 unsafe states, 0 finished and 0 deadend states
4+
5+
# actions here are just labels, but must be symbols with __name__ attribute
46

57
def IncrementSpeed(): pass
68

7-
cleanup = (IncrementSpeed,)
9+
# states, key of each state here is its number in graph etc. below
10+
11+
states = {
12+
0 : {'SpeedControl': 0},
13+
1 : {'SpeedControl': 1},
14+
2 : {'SpeedControl': 2},
15+
}
16+
17+
# initial state, accepting states, unsafe states, frontier states, deadend states
818

919
initial = 0
10-
accepting = (0,)
20+
accepting = [0]
21+
unsafe = []
22+
frontier = []
23+
finished = []
24+
deadend = []
25+
runstarts = [0]
26+
27+
# finite state machine, list of tuples: (current, (action, args, result), next)
1128

12-
graph = ((0, (IncrementSpeed, (), None), 1),
13-
(1, (IncrementSpeed, (), None), 2),
14-
(2, (IncrementSpeed, (), None), 0))
29+
graph = (
30+
(0, (IncrementSpeed, (), None), 1),
31+
(1, (IncrementSpeed, (), None), 2),
32+
(2, (IncrementSpeed, (), None), 0),
33+
)

samples/PowerSwitch/test_graphics.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,25 @@
44

55
cases = [
66
('Generate FSM from PowerSwitch model program',
7-
'pma.py PowerSwitch'),
7+
'pma PowerSwitch'),
88

99
('Generate dot graphics commands from generated PowerSwitchFSM',
10-
'pmg.py PowerSwitchFSM'),
10+
'pmg PowerSwitchFSM'),
1111

1212
('Generate SVG file from dot commands',
1313
'dotsvg PowerSwitchFSM'),
1414

1515
('Generate dot commands from SpeedControl FSM',
16-
'pmg.py SpeedControl'),
16+
'pmg SpeedControl'),
1717

1818
('Generate SVG file from dot commands',
1919
'dotsvg SpeedControl'),
2020

2121
('Generate FSM from composition of PowerSwitch and SpeedControl, show interleaving',
22-
'pma.py SpeedControl PowerSwitch -o PowerSpeed'),
22+
'pma SpeedControl PowerSwitch -o PowerSpeed'),
2323

2424
('Generate dot commands from composed FSM',
25-
'pmg.py PowerSpeed'),
25+
'pmg PowerSpeed'),
2626

2727
('Generate SVG from dot',
2828
'dotsvg PowerSpeed')

0 commit comments

Comments
 (0)