auproto-*
gui-plan-bot
selectors.h
+retransmit-table.h
#
-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
%.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)
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
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
#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 ----------*/
--- /dev/null
+#!/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 $!;
* 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);
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);
#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) {
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)
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?) */
}