From: ian Date: Thu, 15 Jun 2006 14:32:30 +0000 (+0000) Subject: wip X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ijackson/git?a=commitdiff_plain;h=1b3331140bd2566cc76f3006dda4460d22001b5e;p=trains.git wip --- diff --git a/cebpic/README.protocol b/cebpic/README.protocol index 4de741e..da40540 100644 --- a/cebpic/README.protocol +++ b/cebpic/README.protocol @@ -184,7 +184,8 @@ Bits which do not correspond to defined reversal segments will be ignored by the PICs. The host must send exactly as many bytes as are necessary to include all of the reversal segments for each reversers board (for every potential reversal segment, regardless of whether -that segment is a defined segment corresponding to some actual track). +that segment is a defined segment corresponding to some actual track; +however a board with _no_ reversers segments used does not count). For example, if there are 14 reversible segments (numbered 1 to 14) then the following message diff --git a/hostside/actual.c b/hostside/actual.c new file mode 100644 index 0000000..d97195b --- /dev/null +++ b/hostside/actual.c @@ -0,0 +1,18 @@ +/* + * realtime + * implementation of safety algorithm's decisions + */ + +static int maxbytechange; +static PicInsn polarityinsn= { { 0x90 }, 0 }; + +void actual_inversions_start(void) { + polarityinsn.l= 0; +} + +void actual_inversions_done(void) { + if (polarityinsn.l) + serial_transmit(&polarityinsn); +} + +void actual_inversions_segment(SegmentNum); diff --git a/hostside/realtime.c b/hostside/realtime.c index e636ed1..d94598e 100644 --- a/hostside/realtime.c +++ b/hostside/realtime.c @@ -113,7 +113,8 @@ static void *serial_readable(oop_source *evts, int fd, void serial_transmit(const PicInsn *pi) { const PicInsnInfo *pii; int objnum; - + + fixme decode polarity picinsn_decode(pi, pic_command_infos, &pii, &objnum); if (!pii) diff --git a/hostside/safety.c b/hostside/safety.c index 8edec10..487aefc 100644 --- a/hostside/safety.c +++ b/hostside/safety.c @@ -1,4 +1,6 @@ /* + * realtime + * safety core algorithm */ #include diff --git a/layout/data2safety b/layout/data2safety index ce477e9..13cd0f0 100755 --- a/layout/data2safety +++ b/layout/data2safety @@ -151,6 +151,7 @@ sub line_boards_reversers { my ($i,$objnum); for ($i=0; $i<6; $i++) { $objnum= boob2objnum($num,$i,'reverse',0); + fixme nreverses seems unused $nreverses= $objnum+1 if $objnum >= $nreverses; } } @@ -248,10 +249,11 @@ sub boob2objnum_pt { sub boob2objnum_reverse { my ($boardnum,$obj,$boardtype)=@_; +fixme need to map board num for reversers to # Converts board and object number (in canonical pic number plus - # and reverse0...reverse5 as seen on pinout diagrams), to - # object number for POLARITY command numbered as shown in + # and reverse0...reverse5 as seen on pinout diagrams), to the + # segment number for POLARITY command numbered as shown in # README.protocol. # # There are three basic stages: @@ -263,7 +265,7 @@ sub boob2objnum_reverse { # * We figure out which bit of which message byte the # object corresponds to. (see reverse.asm, polarity_decode_message) # - # * We compute the README.protocol bit and byte number. + # * We compute the README.protocol segment number. my ($cycle,$boardincycle,$cyclebasebyte,$byte,$bit); die unless $boardtype eq 'reversers'; @@ -362,6 +364,11 @@ sub mainread () { } } +sub redaction () { + for ($num=0, $mappednum=0; $num<@boardtype; $num++) { + next if $boardtype[$num] eq 'detectors'; + + sub nummap ($) { my ($p) = @_; $p =~ s/\d{1,6}/ sprintf "%06d%d",$&,$& /ge; @@ -616,5 +623,6 @@ sub writeasm () { o("\n end\n"); } mainread(); +redaction(); writeout(); writeasm();