Skip to content

Commit

Permalink
print_stats works
Browse files Browse the repository at this point in the history
  • Loading branch information
Uwe Fechner committed Mar 28, 2024
1 parent 85aa839 commit 4de21ce
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 7 deletions.
10 changes: 5 additions & 5 deletions examples/autopilot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ end
using Timers; tic()

using KiteControllers, KiteViewers, KiteModels, StatsBase, ControlPlots, NativeFileDialog, LaTeXStrings
# using Gtk4, Printf
using Printf
import KiteViewers.GLMakie

kcu::KCU = KCU(se())
kps4::KPS4 = KPS4(kcu)
Expand Down Expand Up @@ -288,13 +289,12 @@ end
function plot_side_view()
end

# include("stats.jl")
include("stats.jl")
function print_stats()
log = load_log(PARTICLES, basename(KiteViewers.plot_file[]))
sl = log.syslog
# stats = Stats(sl[end].e_mech, 3900, 25)
fig = KiteViewers.GLMakie.Figure(size = (400, 400))
display(KiteViewers.GLMakie.Screen(), fig)
stats = Stats(sl[end].e_mech, maximum(sl.force), minimum(log.z))
show_stats(stats)
end

function plot_elev_az()
Expand Down
31 changes: 31 additions & 0 deletions examples/stats.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
struct Stats
e_mech::Float64
max_force::Float64
min_height::Float64
end

function show_stats(stats::Stats)
fig = GLMakie.Figure(size = (400, 400))
lscene = GLMakie.LScene(fig[1, 1], show_axis=false)
if Sys.islinux()
lin_font="/usr/share/fonts/truetype/ttf-bitstream-vera/VeraMono.ttf"
if isfile(lin_font)
font=lin_font
else
font="/usr/share/fonts/truetype/freefont/FreeMono.ttf"
end
else
font="Courier New"
end
function print(lbl::String, value::String; line, font=font)
GLMakie.text!(lscene, position = GLMakie.Point2f( 10, 360-line*32), lbl; fontsize = 24, space=:pixel)
GLMakie.text!(lscene, position = GLMakie.Point2f(250, 360-line*32), value; fontsize = 24, font, space=:pixel)
line +=1
end
line = print("energy: ", @sprintf("%5.0f Wh", stats.e_mech); line = 1)
line = print("max force: ", @sprintf("%5.0f N", stats.max_force); line)
line = print("min height:", @sprintf("%5.0f m", stats.min_height); line)

display(GLMakie.Screen(), fig)
nothing
end
2 changes: 0 additions & 2 deletions mwes/mwe_04.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,3 @@ function show_stats(stats::Stats)
display(GLMakie.Screen(), fig)
nothing
end


0 comments on commit 4de21ce

Please sign in to comment.