From 7778ca336b7a5bb7c1f62950255c6a1b0b9a56a0 Mon Sep 17 00:00:00 2001 From: ian Date: Fri, 10 Mar 2006 20:00:39 +0000 Subject: [PATCH] fixes from live bessar --- hostside/gui-displayer | 2 +- hostside/stopgap-controller | 24 ++++++++++++++---------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/hostside/gui-displayer b/hostside/gui-displayer index 30751b3..ea03098 100755 --- a/hostside/gui-displayer +++ b/hostside/gui-displayer @@ -1,4 +1,4 @@ -#!/usr/bin/wish8.2 +#!/usr/bin/wish8.3 proc widgets {} { global widg_pipe diff --git a/hostside/stopgap-controller b/hostside/stopgap-controller index bfed278..e331b7d 100755 --- a/hostside/stopgap-controller +++ b/hostside/stopgap-controller @@ -1,4 +1,4 @@ -#!/usr/bin/tclsh8.2 +#!/usr/bin/tclsh8.3 # used like this: # liberator:hostside> ssh bessar 'cd things/trains-bessar/hostside && ./stopgap-controller' | ./gui-displayer - @@ -15,7 +15,7 @@ set ch(scale) 1 set ch(minint) 5000 -set pointprobs {0 0x010 0x080 0x0f0 0x100} +set pointprobs {0 0x020 0x080 0x0e0 0x100} set pointprobix 0 set pointabs 1 ;# 0 or 1 @@ -33,8 +33,8 @@ set segs {xx yy} set segsasgot {xx yy} set pq {} ;# unset: cdu charged and waiting set speeddirn ff7f -#unset askspeedix -set askspeeds {10 30 50 80 100 126} +set askspeedix -1 +set askspeeds {1 30 50 80 100 126} #set speeddirn ffff80c3fbcced7f #set speeddirn_fixed {speed126 2 80 0} set speeddirn_fixed {} @@ -379,9 +379,13 @@ proc onreadp {} { } proc newspeeddirn {} { - global loco + global loco askspeedix + set maxspeed [expr {$askspeedix == -1 ? 126.0 : 50.0}] + set minspeed 26.0 set b1 0x[randbyte] - set speed [expr {round(($b1 * $b1) / 65535.0 * 100.0 + 26.0)}] + set speed [expr { + round(($b1 * $b1) / 65535.0 * ($maxspeed - $minspeed) + $minspeed) + }] set b2 0x[randbyte] set dirn [expr {$b2 / 128}] set dirn 0 @@ -546,7 +550,8 @@ proc updownfromlist {wholelistv ixv updown} { } proc ask_speed {updown} { - global speeddirn_fixed loco + global speeddirn_fixed loco askspeedix + if {$askspeedix < 0} { unset askspeedix } set speed [updownfromlist askspeeds askspeedix $updown] set speeddirn_fixed [list speed126 $loco $speed 0] maybechange speeddirn 1 @@ -554,8 +559,8 @@ proc ask_speed {updown} { proc ask_randspeed {} { global speeddirn_fixed askspeedix + set askspeedix [expr {$askspeedix == -1 ? -2 : -1}] catch { unset speeddirn_fixed } - catch { unset askspeedix } maybechange speeddirn 1 } @@ -583,12 +588,11 @@ proc ask_show {} { global loco stateshowpipe pointprob pointabs askspeedix upvar #0 funcsr$loco fr upvar #0 funcsl$loco fl - if {[info exists askspeedix]} { set spd $askspeedix } { set spd r } puts -nonewline $stateshowpipe [format \ "\nL$loco P%03x%s F%03x S%s" \ $pointprob [lindex {R A} $pointabs] \ [expr {[lindex $fr 0] | [lindex $fl 0]}] \ - $spd] + $askspeedix] } setup -- 2.30.2