Skip to content

Commit 4e31797

Browse files
committed
update readme
1 parent b71376e commit 4e31797

File tree

1 file changed

+28
-24
lines changed

1 file changed

+28
-24
lines changed

README.md

+28-24
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,34 @@ hist = statemachine.history
8989
drawStateMachineHistory(hist, show=true)
9090
```
9191

92+
Multiple state machines can be visualized together
93+
```julia
94+
using Graphs, FunctionalStateMachine
95+
96+
#...
97+
98+
# start multiple concurrent FSMs (this is only one)
99+
## they are likely interdependent
100+
statemachine = StateMachine{Nothing}(next=foo!)
101+
while statemachine(nothing, recordhistory=true); end
102+
103+
# add all histories to the `hists::Dict` as follows
104+
## ths example has userdata of type ::Nothing
105+
hists = Dict{Symbol,Vector{Tuple{DateTime,Int,Function,Nothing}}}(:first => statemachine.history)
106+
107+
# generate all the images that will make up the video
108+
animateStateMachineHistoryIntervalCompound(hists, interval=1)
109+
110+
# and convert images to video with ffmpeg as shell command
111+
fps = 5
112+
run(`ffmpeg -r 10 -i /tmp/caesar/csmCompound/csm_%d.png -c:v libtheora -vf fps=$fps -pix_fmt yuv420p -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" -q 10 /tmp/caesar/csmCompound/out.ogv`)
113+
@async run(`totem /tmp/caesar/csmCompound/out.ogv`)
114+
```
115+
can combine multiple concurrent histories of the state machine execution into the same image frames. See function for more details.
116+
117+
118+
# Lower Level Visualization tools
119+
92120
## Animate Asyncronous State Machine Transitions
93121

94122
The following example function shows several state machines that were run asyncronously can be synchronously animated as separate frames (see below for single frame with multiple information):
@@ -149,30 +177,6 @@ A closely related function
149177
animateStateMachineHistoryByTime
150178
```
151179

152-
Multiple state machines can be visualized together
153-
```julia
154-
using Graphs, FunctionalStateMachine
155-
156-
#...
157-
158-
# start multiple concurrent FSMs (this is only one)
159-
## they are likely interdependent
160-
statemachine = StateMachine{Nothing}(next=foo!)
161-
while statemachine(nothing, recordhistory=true); end
162-
163-
# add all histories to the `hists::Dict` as follows
164-
## ths example has userdata of type ::Nothing
165-
hists = Dict{Symbol,Vector{Tuple{DateTime,Int,Function,Nothing}}}(:first => statemachine.history)
166-
167-
# generate all the images that will make up the video
168-
animateStateMachineHistoryIntervalCompound(hists, interval=1)
169-
170-
# and convert images to video with ffmpeg as shell command
171-
fps = 5
172-
run(`ffmpeg -r 10 -i /tmp/caesar/csmCompound/csm_%d.png -c:v libtheora -vf fps=$fps -pix_fmt yuv420p -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" -q 10 /tmp/caesar/csmCompound/out.ogv`)
173-
@async run(`totem /tmp/caesar/csmCompound/out.ogv`)
174-
```
175-
can combine multiple concurrent histories of the state machine execution into the same image frames. See function for more details.
176180

177181
# Contribute
178182

0 commit comments

Comments
 (0)