From b7319caf5778c52d9aafe69964b651da71b76b24 Mon Sep 17 00:00:00 2001 From: ian Date: Thu, 20 Mar 2008 01:44:06 +0000 Subject: [PATCH] before abandon own speed curve for shinkansen --- hostside/.cvsignore | 1 + hostside/Makefile | 3 +++ hostside/analyse-speeds | 4 +++- hostside/reprogram | 8 ++++--- hostside/shinkansen-motor.cv-s.gen | 36 ++++++++++++++++++++++++++++++ 5 files changed, 48 insertions(+), 4 deletions(-) create mode 100755 hostside/shinkansen-motor.cv-s.gen diff --git a/hostside/.cvsignore b/hostside/.cvsignore index 024a957..325f7ff 100644 --- a/hostside/.cvsignore +++ b/hostside/.cvsignore @@ -25,3 +25,4 @@ persist.data.new persist.conv.old persist.conv persist.conv.new +shinkansen-motor.cv-s diff --git a/hostside/Makefile b/hostside/Makefile index ab6d59c..8f6aa74 100644 --- a/hostside/Makefile +++ b/hostside/Makefile @@ -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 \ diff --git a/hostside/analyse-speeds b/hostside/analyse-speeds index e4dc53c..bc9d866 100755 --- a/hostside/analyse-speeds +++ b/hostside/analyse-speeds @@ -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; diff --git a/hostside/reprogram b/hostside/reprogram index 0203f85..17bbef8 100755 --- a/hostside/reprogram +++ b/hostside/reprogram @@ -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 index 0000000..716e24e --- /dev/null +++ b/hostside/shinkansen-motor.cv-s.gen @@ -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 () { 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: -- 2.30.2