Преглед изворни кода

Automatically choose the horizontal scale for the trace plotter

Ian Goldberg пре 1 година
родитељ
комит
5313a77081
1 измењених фајлова са 12 додато и 8 уклоњено
  1. 12 8
      plot_traces

+ 12 - 8
plot_traces

@@ -8,16 +8,9 @@
 # Outputs trace.tex (and the files pdflatex builds, including the target
 # trace.pdf) into the log directory
 
-# Timescale (cm per second)
-timescale = .5
-
-# Nodescale (cm between nodes)
-nodescale = 1
-
-# Seconds between time label ticks
-time_tick = 2
 
 import glob
+import math
 import os
 import re
 import sys
@@ -172,6 +165,17 @@ for nodelog in nodelogs:
 
 # Write a latex file that draws the messages
 
+# ((max_ts-min_ts)*timescale) must be at most 570
+
+# Timescale (cm per second)
+timescale = min(570/(max_ts-min_ts), 2)
+
+# Nodescale (cm between nodes)
+nodescale = 1
+
+# Seconds between time label ticks
+time_tick = math.ceil(1/timescale)
+
 with open("trace.tex", "w") as tf:
     print(r'''\documentclass{article}
 \usepackage[paperwidth=%fcm,paperheight=%fcm,margin=1cm]{geometry}