Skip to content

Commit 4dba0b7

Browse files
committed
Marquee sample: add README.md, add test_viewer
test_viewer makes same output as test_graphics, but uses pmv so it is shorter also regenerate files in fsmpy/ and svg/
1 parent d07d015 commit 4dba0b7

12 files changed

Lines changed: 172 additions & 28 deletions

samples/Marquee/README.md

Lines changed: 44 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,20 @@ Marquee
44
This sample models a marquee with one line of text scrolling from
55
right to left.
66

7-
- *Marquee*: model program, defines *Load* and *Shift*,
8-
but only includes *Shift* in the *actions*. Initializes
9-
model state *display* with uninteresting text.
7+
This sample demonstrates how the size and structure of the data affect
8+
the number of states, how a configuration file can augment or replace
9+
items in the model, and how composition with a scenario machine can
10+
restrict the behavior of a model.
11+
12+
- *Marquee*: model program, defines *Load* and *Shift*, but only
13+
includes *Shift* in the *actions*. Initializes model state
14+
*display* with uninteresting text, a pattern of two characters
15+
repeated thirteen times: _'* * * * * * * * * * * * * '_
16+
17+
- *DisplayFive*: configuration, redefines *actions* to also include *Load*,
18+
defines *domains* for *Load* with slightly more interesting text,
19+
a *pattern* of five characters repeated five times: *'Bye Bye Bye Bye Bye '*
1020

11-
- *DisplayFive*: configuration, redefines *actions* to include *Load*,
12-
defines domain for *Load* with more interesting *pattern* argument.
13-
1421
- *LoadFirst*: scenario machine, forces the *Load* action to execute
1522
just once at the beginning of the run.
1623

@@ -22,7 +29,37 @@ right to left.
2229
appear on the command line in different orders (to show that
2330
doesn't matter).
2431

25-
- *fsmpy*, *svg*: directories of output files from *test_graphics*
32+
- *test_viewer*: Generate the same output as *test_graphics*, but this
33+
script is shorter because it uses *pmv* instead of *pma* + *pmg* +
34+
*dot*
35+
36+
- *fsmpy*, *svg*: directories of output files from *test_graphics* or
37+
*test_viewer*
38+
39+
You can view the generated *.svg* files in a browser. Hover the
40+
pointer over any state bubble to see a tooltip that shows the marquee
41+
display in that state.
42+
43+
- *MarqueeFSM*: the repeating *display* pattern with just two
44+
characters results in two states. Only *Select* is enabled.
45+
46+
- *DisplayFiveFSM*: here *Marquee* imports *DisplayFive*. The
47+
repeating *pattern* with five characters results in five states.
48+
*Load* is enabled in every state.
49+
50+
- *LoadFirst*: graph of the scenario machine, shows how the *Load* action
51+
executes just once at the beginning of the run.
52+
53+
- *PeriodFiveFSM*: compare to *DisplayFiveFSM*. Here *Marquee* is
54+
composed with *LoadFirst, so *Load* only executes once at the
55+
beginning.
56+
57+
- *DisplayFiveFSM1*, *PeriodFiveFSM1*, *PeriodFiveFSM2*: same as
58+
*DisplayFiveFSM* and *PeriodFiveFSM*, but modules appear on the *pma*
59+
(or *pmv*) command line in different order, to show that order
60+
doesn't matter. In particular, the configuration module
61+
*DisplayFive* can appear on the command line before or after
62+
*Marquee*, the model program it imports.
2663

2764
There is no stepper in this sample.
2865

samples/Marquee/fsmpy/DisplayFiveFSM.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
# pma.py DisplayFive Marquee
2+
# pma.py --maxTransitions 100 DisplayFive Marquee
33
# 7 states, 14 transitions, 7 accepting states, 0 unsafe states, 0 finished and 0 deadend states
44

55
# actions here are just labels, but must be symbols with __name__ attribute

samples/Marquee/fsmpy/DisplayFiveFSM1.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
# pma.py -o DisplayFiveFSM1 Marquee DisplayFive
2+
# pma.py --maxTransitions 100 --output DisplayFiveFSM1 Marquee DisplayFive
33
# 7 states, 14 transitions, 7 accepting states, 0 unsafe states, 0 finished and 0 deadend states
44

55
# actions here are just labels, but must be symbols with __name__ attribute
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
2+
# pma.py --maxTransitions 100 LoadFirst
3+
# 2 states, 2 transitions, 2 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
6+
7+
def Load(): pass
8+
def Shift(): pass
9+
10+
# states, key of each state here is its number in graph etc. below
11+
12+
states = {
13+
0 : {'LoadFirst': 0},
14+
1 : {'LoadFirst': 1},
15+
}
16+
17+
# initial state, accepting states, unsafe states, frontier states, deadend states
18+
19+
initial = 0
20+
accepting = [0, 1]
21+
unsafe = []
22+
frontier = []
23+
finished = []
24+
deadend = []
25+
runstarts = [0]
26+
27+
# finite state machine, list of tuples: (current, (action, args, result), next)
28+
29+
graph = (
30+
(0, (Load, (), None), 1),
31+
(1, (Shift, (), None), 1),
32+
)

samples/Marquee/fsmpy/MarqueeFSM.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
# pma.py Marquee
2+
# pma.py --maxTransitions 100 Marquee
33
# 2 states, 2 transitions, 2 accepting states, 0 unsafe states, 0 finished and 0 deadend states
44

55
# actions here are just labels, but must be symbols with __name__ attribute

samples/Marquee/fsmpy/PeriodFiveFSM.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
# pma.py -o PeriodFiveFSM Marquee DisplayFive LoadFirst
2+
# pma.py --maxTransitions 100 --output PeriodFiveFSM Marquee DisplayFive LoadFirst
33
# 6 states, 6 transitions, 6 accepting states, 0 unsafe states, 0 finished and 0 deadend states
44

55
# actions here are just labels, but must be symbols with __name__ attribute

samples/Marquee/fsmpy/PeriodFiveFSM1.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
# pma.py -o PeriodFiveFSM1 LoadFirst Marquee DisplayFive
2+
# pma.py --maxTransitions 100 --output PeriodFiveFSM1 LoadFirst Marquee DisplayFive
33
# 6 states, 6 transitions, 6 accepting states, 0 unsafe states, 0 finished and 0 deadend states
44

55
# actions here are just labels, but must be symbols with __name__ attribute

samples/Marquee/fsmpy/PeriodFiveFSM2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
# pma.py -o PeriodFiveFSM2 DisplayFive Marquee LoadFirst
2+
# pma.py --maxTransitions 100 --output PeriodFiveFSM2 DisplayFive Marquee LoadFirst
33
# 6 states, 6 transitions, 6 accepting states, 0 unsafe states, 0 finished and 0 deadend states
44

55
# actions here are just labels, but must be symbols with __name__ attribute
Lines changed: 45 additions & 0 deletions
Loading

samples/Marquee/test.py

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

55
cases = [
66
('One run',
7-
'pmt.py Marquee -n 10'),
7+
'pmt Marquee -n 10'),
88

99
('Request two runs, but no Reset function, so only one run executes',
10-
'pmt.py Marquee -n 10 -r 2')
10+
'pmt Marquee -n 10 -r 2')
1111
]

0 commit comments

Comments
 (0)