chiark / gitweb /
realtime: movpos: debug output: exclude some more stuff from the default movpos output
[trains.git] / hostside / retransmit-table.h.gen
1 #!/usr/bin/perl
2
3 $count= 17;
4 $exp= 1.3;
5 $first= 6.0; # units are bytes of command NMRADATA command sent to PICs.
6 # A 3-byte (including checksum) NMRA command (which is the
7 # smallest possible) produces 6 bytes.
8
9 print <<END or die $!;
10 #define SPEEDYCOUNT $count
11
12 typedef struct {
13   Retransmit__Time interval; /* interval after this retransmission */
14   DLIST2_HEAD(RetransmitUrgentNode) queue; /* msgs transmitted ix times */
15 } PerSpeedyTrans;
16
17 END
18
19 for ($ix=0, $accum=0; $ix<$count; $ix++) {
20     $val= int($first * $exp**$ix + 0.49);
21     $accum += $val;
22     push @s, sprintf("  { %3d } /* %3s cum=%3d cumforother=%3d".
23                      " use=%3d%% cumuse=%3d%% */",
24                      $val, "#$ix", $accum, $accum-($ix+1),
25                      (100.0/$val), (100.0*($ix+1))/$accum);
26 }
27
28 print("#define SPEEDIESINIT { \\\n",
29       join(", \\\n", @s),
30       "  \\\n }\n")
31     or die $!;