@@ -84,17 +84,17 @@ function histGraphStateMachineTransitions(stateVisits, allStates::Vector{Symbol}
84
84
end
85
85
86
86
87
- function renderStateMachineFrame (vg,
88
- frame:: Int ;
89
- title:: String = " " ,
90
- viewerapp:: String = " eog" ,
91
- fext:: String = " png" ,
92
- engine:: String = " dot" ,
93
- show:: Bool = true ,
94
- folder:: String = " fsm_animation" ,
95
- folderpath = " /tmp/$folder /" ,
96
- timest:: String = " " ,
97
- rmfirst:: Bool = false )
87
+ function renderStateMachineFrame ( vg,
88
+ frame:: Int ;
89
+ title:: String = " " ,
90
+ viewerapp:: String = " eog" ,
91
+ fext:: String = " png" ,
92
+ engine:: String = " dot" ,
93
+ show:: Bool = true ,
94
+ folder:: String = " fsm_animation" ,
95
+ folderpath = " /tmp/$folder /" ,
96
+ timest:: String = " " ,
97
+ rmfirst:: Bool = false )
98
98
#
99
99
if rmfirst
100
100
@warn " removing contents of $(folderpath) "
@@ -113,7 +113,7 @@ function renderStateMachineFrame(vg,
113
113
fid = open (" $folderpath /dotscript.sh" ," w" )
114
114
str = " head -n `wc -l $dotfile | awk '{print \$ 1-1}'` $dotfile > $folderpath /tmpdot.dot"
115
115
println (fid, str)
116
- println (fid, " echo \" graph [label=\\\" $title , # $step , $(timest) \\\" , labelloc=t];\" >> $folderpath /tmpdot.dot" )
116
+ println (fid, " echo \" graph [label=\\\" $title , $(timest) \\\" , labelloc=t];\" >> $folderpath /tmpdot.dot" )
117
117
println (fid, " echo \" }\" >> $folderpath /tmpdot.dot" )
118
118
close (fid)
119
119
run (` chmod u+x $folderpath /dotscript.sh` )
@@ -128,10 +128,10 @@ function renderStateMachineFrame(vg,
128
128
return filepath
129
129
end
130
130
131
- function setVisGraphOnState! (vg, vertid;
132
- xlabel:: String = " " ,
133
- appendxlabel:: String = " " ,
134
- vertColor:: AbstractString = " red" )
131
+ function setVisGraphOnState! ( vg, vertid;
132
+ xlabel:: String = " " ,
133
+ appendxlabel:: String = " " ,
134
+ vertColor:: AbstractString = " red" )
135
135
#
136
136
vg. vertices[vertid]. attributes[" fillcolor" ] = vertColor
137
137
vg. vertices[vertid]. attributes[" style" ] = " filled"
@@ -154,18 +154,18 @@ function clearVisGraphAttributes!(vg)
154
154
nothing
155
155
end
156
156
157
- function drawStateTransitionStep (hist,
158
- step:: Int ,
159
- vg,
160
- lookup:: Dict{Symbol,Int} ;
161
- title:: String = " " ,
162
- viewerapp:: String = " eog" ,
163
- fext:: String = " png" ,
164
- engine:: String = " dot" ,
165
- show:: Bool = true ,
166
- folder:: String = " " ,
167
- frame:: Int = step,
168
- vertColor:: AbstractString = " red" )
157
+ function drawStateTransitionStep ( hist,
158
+ step:: Int ,
159
+ vg,
160
+ lookup:: Dict{Symbol,Int} ;
161
+ title:: String = " " ,
162
+ viewerapp:: String = " eog" ,
163
+ fext:: String = " png" ,
164
+ engine:: String = " dot" ,
165
+ show:: Bool = true ,
166
+ folder:: String = " " ,
167
+ frame:: Int = step,
168
+ vertColor:: AbstractString = " red" )
169
169
#
170
170
171
171
lbl = getStateLabel (hist[step][3 ])
@@ -179,26 +179,26 @@ function drawStateTransitionStep(hist,
179
179
# delete!(vert.attributes, "style")
180
180
181
181
# identify and set the node
182
- xlabel = length (title) > 0 ? (xlabelbefore != nothing ? xlabelbefore* " ," : " " )* title : " "
182
+ xlabel = length (title) > 0 ? (xlabelbefore != = nothing ? xlabelbefore* " ," : " " )* title : " "
183
183
setVisGraphOnState! (vg, vertid, xlabel= xlabel, vertColor= vertColor )
184
184
185
185
# render state machine frame
186
- filepath = renderStateMachineFrame (vg,
187
- frame,
188
- title= title,
189
- viewerapp= viewerapp,
190
- fext= fext,
191
- engine= engine,
192
- show= show,
193
- folder= folder,
194
- timest= string (split (string (hist[step][1 ]),' T' )[end ]),
195
- rmfirst= false )
186
+ filepath = renderStateMachineFrame ( vg,
187
+ frame,
188
+ title= title,
189
+ viewerapp= viewerapp,
190
+ fext= fext,
191
+ engine= engine,
192
+ show= show,
193
+ folder= folder,
194
+ timest= string (split (string (hist[step][1 ]),' T' )[end ]),
195
+ rmfirst= false )
196
196
#
197
197
198
198
# clean up the vg structure
199
- fillcolorbefore == nothing ? delete! (vert. attributes, " fillcolor" ) : (vert. attributes[" fillcolor" ]= fillcolorbefore)
200
- stylebefore == nothing ? delete! (vert. attributes, " style" ) : (vert. attributes[" style" ]= stylebefore)
201
- xlabelbefore == nothing ? delete! (vert. attributes, " xlabel" ) : (vert. attributes[" xlabel" ]= xlabelbefore)
199
+ fillcolorbefore === nothing ? delete! (vert. attributes, " fillcolor" ) : (vert. attributes[" fillcolor" ]= fillcolorbefore)
200
+ stylebefore === nothing ? delete! (vert. attributes, " style" ) : (vert. attributes[" style" ]= stylebefore)
201
+ xlabelbefore === nothing ? delete! (vert. attributes, " xlabel" ) : (vert. attributes[" xlabel" ]= xlabelbefore)
202
202
203
203
return filepath
204
204
end
398
398
# @async run(`totem /tmp/caesar/csmCompound/out.ogv`)
399
399
# draw_more_cb(::Tuple, ::Int, ::String)
400
400
function animateStateMachineHistoryIntervalCompound (hists:: Dict{Symbol, Vector{Tuple{DateTime, Int, <: Function, T}}} ;
401
- interval :: Int = 2 , # frames
402
- # frames ::Int=100 ,
401
+ easyNames :: Dict{Symbol,N} = Dict {Symbol,Nothing} (),
402
+ interval :: Int = 2 ,
403
403
folderpath= " /tmp/animatestate" ,
404
404
title:: String = " " ,
405
405
show:: Bool = false ,
@@ -408,7 +408,7 @@ function animateStateMachineHistoryIntervalCompound(hists::Dict{Symbol, Vector{T
408
408
draw_more_cb:: Function = (x... )-> (),
409
409
fsmColors:: Dict{Symbol,String} = Dict {Symbol,String} (),
410
410
defaultColor:: AbstractString = " red" ,
411
- autocolor_cb:: Function = (histstep,csym,aniT)-> (haskey (fsmColors, csym) ? fsmColors[csym] : defaultColor) ) where T
411
+ autocolor_cb:: Function = (histstep,csym,aniT)-> (haskey (fsmColors, csym) ? fsmColors[csym] : defaultColor) ) where {T, N}
412
412
#
413
413
# Dict{Symbol, Vector{Symbol}}
414
414
stateVisits = Dict {Symbol, Vector{Symbol}} ()
@@ -433,6 +433,7 @@ function animateStateMachineHistoryIntervalCompound(hists::Dict{Symbol, Vector{T
433
433
prevList = Dict {Symbol, Vector{Int}} ()
434
434
latestList = Dict {Symbol, Int} (whId => fsmStep)
435
435
436
+ prevT = aniT
436
437
frameCount = 0
437
438
# loop across time
438
439
@showprogress " exporting state machine images, $title " for stepCount in 1 : totSteps
@@ -451,18 +452,20 @@ function animateStateMachineHistoryIntervalCompound(hists::Dict{Symbol, Vector{T
451
452
lbl = getStateLabel (hists[csym][lstep][3 ])
452
453
vertid = lookup[lbl]
453
454
vertColor= autocolor_cb (hists[csym][lstep], csym, aniT)
454
- # vertColor = haskey(fsmColors, csym) ? fsmColors [csym] : defaultColor
455
- setVisGraphOnState! (vg, vertid, appendxlabel= string (csym) * " ," , vertColor= vertColor )
455
+ easyn = haskey (easyNames, csym) ? easyNames [csym] : csym
456
+ setVisGraphOnState! (vg, vertid, appendxlabel= " ( $easyn . $lstep ) ," , vertColor= vertColor )
456
457
end
457
458
458
459
# and draw as many frames for that setup
459
460
for itr in 1 : interval
460
461
# increment frame counter
461
462
frameCount += 1
463
+ deltaT = (aniT - prevT). value
464
+ prevT = aniT
462
465
# finally render one frame
463
466
renderStateMachineFrame (vg,
464
467
frameCount,
465
- title= title,
468
+ title= title* " || dt= $deltaT ms || " ,
466
469
show= false ,
467
470
folderpath= folderpath,
468
471
timest= string (split (string (aniT),' ' )[1 ]),
0 commit comments