chiark / gitweb /
before abandon own speed curve for shinkansen
authorian <ian>
Thu, 20 Mar 2008 01:44:06 +0000 (01:44 +0000)
committerian <ian>
Thu, 20 Mar 2008 01:44:06 +0000 (01:44 +0000)
hostside/.cvsignore
hostside/Makefile
hostside/analyse-speeds
hostside/reprogram
hostside/shinkansen-motor.cv-s.gen [new file with mode: 0755]

index 024a957c6eafb41f5830643884ce10afcbcdd556..325f7ff78dbfcc7b61e4b7a062c5c7af681d089f 100644 (file)
@@ -25,3 +25,4 @@ persist.data.new
 persist.conv.old
 persist.conv
 persist.conv.new
+shinkansen-motor.cv-s
index ab6d59c503be8b030e83ac3e9905b727f054a6a1..8f6aa74ef6eb7137f2889301635109c800b5a8a2 100644 (file)
@@ -65,6 +65,9 @@ safety:               safety.o utils.o trackloc.o ../layout/ours.layout-data.o
 %.speeds.ps %.speeds.record: ./analyse-speeds
                ./$^ $*
 
+%:             %.gen
+               ./$^ $o
+
 hostside:      hostside.o serialio.o client.o obc.o commands.o utils.o \
                 nmra.o encode.o retransmit.o output.o auproto-pic.o \
                 parseutils.o \
index e4dc53c80c3b1dd517d0f89f32058ccb9a89f455..bc9d866f1c6350497c8bcb966dc4a0aa4986484a 100755 (executable)
@@ -81,11 +81,13 @@ perl <$o.table.tmp >$o.record.tmp -ne '
        die unless m/^\s*(\d+)\s+([0-9.]+)\s/;
        ($step,$speed) = ($1,$2);
        die "$step $nxt" unless $step==$nxt;
+       if ($speed < $max) { push @decreases, $step; $speed= $max; }
        $speed[$step]= $speed;
-       die "decrease $step $nxt $max" if $speed < $max;
        $max= $speed;
        $nxt++;
  END {
+       warn "warning: '$train': decreases at steps @decreases\n"
+               if @decreases;
        $steps= $nxt-1;
        warn "warning: '$train': expected 126 steps, found $steps\n"
                unless $steps==126;
index 0203f85c8fb453a014f82f6107072a458d89cde5..17bbef89d82cba6252a27743e3e27f86d4e2ccc2 100755 (executable)
@@ -16,7 +16,9 @@ filename="$1"; shift
 
 case "$filename" in
 */*)   ;;
-*)     filename="$filename.cv-s";;
+*)     filename="$filename.cv-s"
+       make "$filename"
+       ;;
 esac
 exec <"$filename"
 
@@ -31,10 +33,10 @@ while read cv value; do
                value=$(( $value + 0 ))
                cvlist="$cvlist $cv=$value"
                ;;
-       '#'*)
+       '#'*|'')
                ;;
        *)
-               fail 'invalid syntax'
+               fail "invalid syntax: $cv $value"
                ;;
        esac
 done
diff --git a/hostside/shinkansen-motor.cv-s.gen b/hostside/shinkansen-motor.cv-s.gen
new file mode 100755 (executable)
index 0000000..716e24e
--- /dev/null
@@ -0,0 +1,36 @@
+#!/usr/bin/perl
+
+$nmax= 126;
+
+#$max= 117;
+#$max= 50;
+$max= 108.9;
+
+@steps= 67..94;
+
+$doublings= 0;
+$vmin= 40;
+$vmax= 255;
+
+for ($i=0; $i<@steps; $i++) {
+    push @vals, $i + @steps * (exp($i/@steps * log(2) * $doublings) - 1.0);
+}
+$maxval= $vals[$#val];
+grep { $_ *= ($vmax-$vmin)/$maxval * $max/$nmax; $_ += $vmin; } @vals;
+
+printf "# autogenerated!\n" or die $!;
+while (<DATA>) { print or die $!; }
+
+for ($i=0; $i<@steps; $i++) {
+    printf "%d %d\n", $steps[$i], $vals[$i]
+       or die $!;
+}
+
+__END__
+addr   1
+#2     1
+29     0x16
+51     0x07
+57     0x06
+
+# speed curve: