sub calcwait ($$) {
my ($step,$wholetime) = @_;
return 0 if $step<0 || $step>=$steps;
- return $wholetime *
+ return $wholetime * 1000 *
($speed[$step+1] - $speed[$step]) / $max;
}
for ($step=0; $step<$nxt; $step++) {
- printf "train %s step %d=%f %f/%f\n",
- "'$train'", $step, $speed[$step]*1e3,
+ printf "train %s step %d=%f %d/%d\n",
+ "'$train'", $step, $speed[$step],
calcwait($step-1,'$acceltime'),
calcwait($step,'$deceltime')
or die $!;
if (!tra->pname || !tra->foredetect ||
!tra->foredetect->i || !tra->foredetect->i->pname)
continue;
- printf("train %s at %s%s:%f+-%f\n",
+ printf("train %s at %s%s:%d+-%d\n",
tra->pname, tra->backwards ? "-" : "",
tra->foredetect->i->pname, tra->maxinto, tra->uncertainty);
}
void record_train_at(Train *tra, int backw, Segment *seg, int maxi, int unc);
void record_train_is(Train *tra, int addr, int head, int det, int tail);
-void record_train_step(Train *tra, int step, int speed, int upw, int downw);
+void record_train_step(Train *tra, int step, double speed, int upw, int downw);
void record_train_step_count(void);
void record_train_home(Train *tra, int backw, Segment *seg);
void record_seg_has(Segment *seg, int backw, Train *tra);
| line NL { record_tempzone_clear(); } file
line: /* empty */
- | TRAIN train IS NUM dbl '+' dbl '+' dbl
+ | TRAIN train IS NUM NUM '+' NUM '+' NUM
{ if ($2) record_train_is($2,$4,$5,$7,$9);
}
- | TRAIN train AT backwards seg ':' dbl '+' '-' dbl
+ | TRAIN train AT backwards seg ':' NUM '+' '-' NUM
{ if ($2) record_train_at($2,$4,$5,$7,$10);
}
| TRAIN train HOME { cur_train=$2; } segments
{
}
- | TRAIN train STEP NUM '=' dbl dbl '/' dbl
+ | TRAIN train STEP NUM '=' dbl NUM '/' NUM
{ if (!trains) record_train_step_count();
else if ($2) record_train_step($2,$4,$6,$7,$9);
}
curvebufsz++;
}
-void record_train_step(Train *tra, int step, int speed, int upw, int downw) {
+void record_train_step(Train *tra, int step, double speed,
+ int upw, int downw) {
Train *other;
SpeedCurveEntry *new;
int i;
#define RR_H 2u
/* We record R in tra->resolution,
- * U in segi->tr_updated and D in segi->res_detect */
+ * U in segi->mark0 and D in segi->res_detect */
+#define iselem_u mark0
void resolve_begin(void) {
SEG_IV;
actual_inversions_start();
FOR_SEG {
seg->res_detect= 0;
- seg->tr_updated= 0;
+ seg->iselem_u= 0;
if (segi->invertible)
actual_inversions_segment(seg);
else
ADDTO_U_EH(owner, RR_E, "as-expected");
assert(updated<=1);
- d->tr_updated= updated;
+ d->iselem_u= updated;
}
oprintf(UPO, "resolving searching\n");
FOR_SEGMENT(d, NOOP, NOOP) {
- if (!(d->res_detect && !d->tr_updated))
+ if (!(d->res_detect && !d->iselem_u))
continue;
/* 3. we have a violation of D \subset U, namely d */
/* check E(t) \disjoint U */
int clashes= 0;
FOR_SEGMENT(d1, NOOP, NOOP) {
- if (d1->owner == t && d1->tr_updated) {
+ if (d1->owner == t && d1->iselem_u) {
FOR_TRAIN(t2, NOOP, NOOP) {
if (t2->resolution == RR_H && d1->owner == t2) {
oprintf(UPO, "resolving clash @%s %s\n",
FOR_SEGMENT(dplus, NOOP,NOOP) {
Train *tplus= dplus->owner;
if (!(tplus && tplus->resolution == RR_E)) continue;
- dplus->tr_updated= 0;
+ dplus->iselem_u= 0;
}
t1->resolution= RR_H;
if (problems)
goto x_problems;
- d->tr_updated= 0;
+ d->iselem_u= 0;
d->cm_autostop= 0;
MovPosComb target= -1;
}
if (d->owner)
- d->until_detect= 1e-3;
+ d->until_here= 1e-3;
if (d->i->n_poscombs>1) {
d->movposcomb= -1;
/*========== more basic types etc. ==========*/
-typedef double TimeInterval; /*s*/
+typedef long TimeInterval; /*ms*/
/*---------- units and scales ----------*/
ho_backwards:1, /* home train has its front and rear backwards wrt track */
cm_autostop:1, /* train should stop on detection */
seg_inverted:1, /* polarity is inverted */
- det_ignore:1, det_expected:1, pred_enter:1, pred_vacate:1, /* safety.c */
+ det_ignore:1, det_expected:1, /* safety.c */
+ mark0,mark1,mark2,mark3, /* for temporary private uses */
res_detect:1; /* detection noticed here during resolution */
TimeInterval until_here; /* ) nonnegative; */ /* ) always valid but */
/* ) 0 if already */ /* ) meaningful iff owner */
/*---------- safety margin parameters ----------*/
#define CLEAR_FORESIGHT_TIME 500 /*ms*/
-#define AUTOSTOP_MAXSPEED 50.0 /*mm/s*/
+#define AUTOSTOP_MAXSPEED 0.050 /*m/s*/
#define AUTOSTOP_UNCERTAINTY 20 /*mm*/
#define ESTOP_UNCERTAINTY 300 /*mm*/
#define ESTOP_DEADTIME 2000 /*ms*/
-#define TIMEINTERVAL2MS(ti) ((ti) * 1000.0)
+#define TIMEINTERVAL2MS(ti) (ti)
#define SPEED_CLEAR_MULT SPEED_CALC_DIST(1,CLEAR_FORESIGHT_TIME,UP)
#endif /*SAFETY_H*/
($comb / $featr->{Weight}) % $featr->{Posns});
}
o("$delim\n");
- o(sprintf " { %-7s%7.3f",
+ o(sprintf " { %-7s%4d",
'"'.$pi.'",',
$segr->{Dist}[$comb]);
for ($end=0; $end<2; $end++) {
typedef short SegmentNumInMap;
typedef double Speed;
-typedef double Distance;
+typedef int Distance;
typedef enum {
mfk_none,