chiark / gitweb /
retransmit.c and safety.c now compile but loads of link errors for unwritten stuff
authorian <ian>
Wed, 14 Jun 2006 17:33:55 +0000 (17:33 +0000)
committerian <ian>
Wed, 14 Jun 2006 17:33:55 +0000 (17:33 +0000)
hostside/.cvsignore
hostside/Makefile
hostside/hostside.h
hostside/realtime.h
hostside/retransmit-table.h.gen [new file with mode: 0755]
hostside/retransmit.c
hostside/safety.c
hostside/startup.c

index 7536abfbea1baf2342bcaa6d46d14f9ba2a82f20..34d7554e52d4faf19761fd3af6a5016bbed4ffdc 100644 (file)
@@ -9,3 +9,4 @@ proto-expanded
 auproto-*
 gui-plan-bot
 selectors.h
+retransmit-table.h
index 8650c61c96ca786e79b11fa5547db35c742387bb..d6646dc585accfdcabb7ef9bc086ca054de0031c 100644 (file)
@@ -1,6 +1,6 @@
 #
 
-AUTOINCS=      auproto-pic.h layoutinfo.h selectors.h
+AUTOINCS=      auproto-pic.h layoutinfo.h selectors.h retransmit-table.h
 TARGETS=       hostside-old gui-plan-bot realtime
 
 include ../common.make
@@ -22,9 +22,10 @@ on-bessar:   $(TARGETS)
 %.on-bessar:   %
                RSYNC_RSH=fsh rsync $^ $(BESSAR)
 
-realtime:      realtime.o startup.o cdumgr.o                   \
+realtime:      realtime.o startup.o cdumgr.o safety.o          \
                 cmdinput.o obc.o eventhelp.o                   \
                 utils.o serialio.o parseutils.o auproto-pic.o  \
+                ../layout/ours.layout-data.o                   \
                 __oop-read-copy.o -loop
                $(LINK)
 
@@ -43,7 +44,7 @@ auproto-pic.c auproto-pic.h: auproto-%: \
 layoutinfo.h:  ../layout/ours.layout-data.c Makefile
                sed -e '/^#include/,$$d' $< $o
 
-selectors.h:   selectors.h.gen
+selectors.h retransmit-table.h:        %: %.gen
                ./$< $o
 
 safety:                safety.o utils.o trackloc.o ../layout/ours.layout-data.o
index b6fbdc6fc5d956e6878ff8be400ecb76dde9b2c8..d350c070916cafcdf8be38e6db671b8efda1a899 100644 (file)
@@ -17,15 +17,4 @@ struct OrdinaryPicMessage {
   int operand_bits; /* 0: no operand.  >=7, insn is a 2-byte message */
 };
      
-/*---------- from retransmit.c ----------*/
-
-struct RetransmitNode {
-  /* set by caller: */
-  PicInsn pi;
-  /* internal: */
-};
-
-void retransmit_queue(RetransmitNode *rn);
-void retransmit_cancel(RetransmitNode *rn);
-
 #endif
index 2aa2b3bd9aa3f8cdc6e91ede07bc256880cf18ca..fbaafb65db2c8c2036079c28d32e692638885563 100644 (file)
@@ -6,7 +6,9 @@
 #define REALTIME_H
 
 #include "daemons.h"
+#include "safety.h"
 #include "auproto-pic.h"
+#include "dliste.h"
 
 #include <stdarg.h>
 #include <string.h>
 
 /*---------- from retransmit.c ----------*/
 
-typedef struct RetransmitNode RetransmitNode;
-struct RetransmitNode {
-  /* set by caller: */
-  PicInsn pi;
-  /* internal: */
-  unsigned long speedyduetime;
-  struct { RetransmitNode *back, *next; } relaxed, speedy;
+typedef struct RetransmitRelaxedNode RetransmitRelaxedNode;
+typedef union RetransmitUrgentNode RetransmitUrgentNode;
+typedef unsigned Retransmit__Time;
+
+struct RetransmitRelaxedNode {
+  PicInsn pi; /* callers must touch only this */
+  DLIST_NODE(RetransmitRelaxedNode) rr;
+};
+union RetransmitUrgentNode {
+  PicInsn pi; /* callers must touch only this */
+  struct {
+    RetransmitRelaxedNode relaxed;
+    int ix;
+    Retransmit__Time when;
+    DLIST_NODE(RetransmitUrgentNode) queue;
+  } u;
 };
 
-void retransmit_queue(RetransmitNode *rn);
-void retransmit_cancel(RetransmitNode *rn);
+void retransmit_relaxed_queue(RetransmitRelaxedNode *rn);
+void retransmit_relaxed_cancel(RetransmitRelaxedNode *rn);
+void retransmit_urgent_queue(RetransmitUrgentNode *rn);
+void retransmit_urgent_cancel(RetransmitUrgentNode *rn);
 
 /*---------- global variables, in realtime.c ----------*/
 
diff --git a/hostside/retransmit-table.h.gen b/hostside/retransmit-table.h.gen
new file mode 100755 (executable)
index 0000000..781bd26
--- /dev/null
@@ -0,0 +1,30 @@
+#!/usr/bin/perl
+
+$count= 20;
+$exp= 1.3;
+$first= 1.0;
+
+print <<END or die $!;
+/* autogenerated - do not edit */
+#define SPEEDYCOUNT $count
+
+typedef struct {
+  Retransmit__Time interval; /* interval after this retransmission */
+  DLIST2_HEAD(RetransmitUrgentNode) queue; /* msgs transmitted ix times */
+} PerSpeedyTrans;
+
+END
+
+for ($ix=0, $accum=0; $ix<$count; $ix++) {
+    $val= int($first * $exp**$ix + 0.49);
+    $accum += $val;
+    push @s, sprintf("  { %3d } /* %3s cum=%3d cumforother=%3d".
+                    " use=%3d%% cumuse=%3d%% */",
+                    $val, "#$ix", $accum, $accum-($ix+1),
+                    (100.0/$val), (100.0*($ix+1))/$accum);
+}
+
+print("#define SPEEDIESINIT { \\\n",
+      join(", \\\n", @s),
+      "  \\\n }\n")
+    or die $!;
index 9306209416fa0f0a3dd393b960af714ea7cb7c4e..7cb3836fee7c1059fed836ec9f791473e30594f2 100644 (file)
  *  it in chronological order of dueness.
  */
 
-#define RETRANS_SPEEDYCOUNT 20
-#define RETRANS_SPEEDYEXP 1.3
-
-#define HALFWAY ((~(Retransmit__Time)0) >> 1)
+#include "realtime.h"
+#include "retransmit-table.h"
 
-typedef struct {
-  DLIST2_HEAD(RetransmitUrgentNode) queue; /* msgs transmitted ix times */
-  Retransmit__Time interval; /* interval after this retransmission */
-} PerSpeedyTrans;
+#define RETRANSMIT_TIME_SIGNED_MAX ((~(Retransmit__Time)0) >> 1)
 
 static const PicInsn linefill= { { 0xff, 0x7f }, 2 };
 
 static DLIST2_HEAD(RetransmitRelaxedNode) relaxed;
 static elapsed;
-static PerSpeedyTrans speedies[RETRANS_SPEEDYCOUNT];
+static PerSpeedyTrans speedies[] = SPEEDIESINIT;
 
 static void retransmit_this(const PicInsn *pi) {
   serial_transmit(pi);
@@ -69,7 +64,7 @@ static void retransmit_something() {
        ix++, spd++) {
     urg= spd->head;
     if (!urg) continue;
-    if (elapsed - urg->u.when > HALFWAY) continue;
+    if (elapsed - urg->u.when > RETRANSMIT_TIME_SIGNED_MAX) continue;
 
     /* found one to transmit: */
     DLIST2_REMOVE(spd->queue,urg,u.queue);
index 41c16187999994d23931d38a087bc77ba37abd74..8edec108d6bb697ef6dd554bfae37faf9fb6a5c2 100644 (file)
@@ -4,8 +4,7 @@
 #include <stdio.h>
 #include <assert.h>
 
-#include "layoutinfo.h"
-#include "safety.h"
+#include "realtime.h"
 
 static void seg_clear_stale(SegmentState *seg) {
   if (!seg->tr_updated) {
@@ -283,7 +282,7 @@ void safety_requestspeed(TrainNum tran, long newspeed) {
       logmsg(ec, tran, NOTA(Segment), "countermanded motion start");
     }
     setspeed(tran, oldspeed);
-    oprintf(UPO, "countermanded %s %l %l\n",
+    oprintf(UPO, "countermanded %s %ld %ld\n",
            info_trains[tran].pname, oldspeed, newspeed);
     ec= lay_train(tran, 0);
     if (ec)
index 8a5b98b80deffc9a8815ec46528b824ae131bde4..9f8a0fe23a1fb4897d2bd77402ebbaa81a18f976 100644 (file)
@@ -200,6 +200,7 @@ void on_pic_detect1(const PicInsnInfo *pii, const PicInsn *pi, int segn) {
 void on_pic_nmradone(const PicInsnInfo *pii, const PicInsn *pi, int objnum) {
   if (sta_state <= Sta_Settling) return;
   if (sta_state != Sta_Run) die("PIC sent NMRADONE in Resolving");
+  
   /* fixme transmit something else (move this to another file?) */
 }