wiring to gui display
things not yet considered at all in safety code
- coming up against points the wrong way
min. curve specifications
return;
}
}
- if (check->movposcomb < 0)
- l->ec= safety_problem(l->tra, report, "track route not set");
}
static void lay_train_pass(LayTrainState *l,
*(check_clash ? &seg->until_here : &seg->until_detect)= time_until;
if (!remain) break;
- trackloc_further(&tloc, &remain);
+ int r= trackloc_further(&tloc, &remain);
+
+ if (r==-2) {
+ l->ec= safety_problem(l->tra, seg, "end of track");
+ return;
+ }
+ if (r==-1) {
+ l->ec= safety_problem(l->tra, seg, "track route not set");
+ return;
+ }
+ if (r>1) {
+ const SegPosCombInfo *pci= trackloc_segposcomb(&tloc);
+ const SegmentLinkInfo *link= trackloc_segmentlink(&tloc,pci,0);
+ if (link->next+segments != seg) {
+ l->ec= safety_problem(l->tra, link->next+segments,
+ "track route set against us");
+ return;
+ }
+ }
}
}
long trackloc_remaininseg(const TrackLocation *tloc);
/* Returns dist that tloc can advance before it goes into next segment. */
-void trackloc_further(TrackLocation *tloc, long *remain_io);
- /* Advances tloc, decrementing *remain_io, until either
- * *remain_io becomes zero, or tloc->segn changes. */
+int trackloc_further(TrackLocation *tloc, long *remain_io);
+ /* Advances tloc, decrementing *remain_io, until one of the
+ * following happens:
+ * tloc->segn changes returns +1
+ * *remain_io becomes zero returns 0
+ * unknown movpos found returns -1
+ * end of track reached returns -2
+ * Does _not_ check that the movposcomb of the segment we
+ * are moving into is correct.
+ */
void trackloc_reverse(TrackLocation *tloc);
/* Reverses tloc without changing its actual location. */
const SegPosCombInfo *trackloc_segposcomb(const TrackLocation *tloc) {
Segment *seg= tloc->seg;
+ if (seg->movposcomb<0) return 0;
assert(seg->movposcomb < seg->i->n_poscombs);
return &seg->i->poscombs[seg->movposcomb];
}
unsigned far) {
return (tloc->backwards ^ far) ? &pci->backwards : &pci->forwards;
}
-
+
long trackloc_remaininseg(const TrackLocation *tloc) {
const SegPosCombInfo *pci;
long segment_len;
return segment_len - tloc->into;
}
-void trackloc_further(TrackLocation *tloc, long *remain_io) {
+int trackloc_further(TrackLocation *tloc, long *remain_io) {
const SegPosCombInfo *pci;
const SegmentLinkInfo *lnki_far;
long segment_remain;
if (*remain_io <= segment_remain) {
tloc->into += *remain_io;
*remain_io= 0;
+ return 0;
} else {
+ *remain_io -= segment_remain;
+ tloc->into += segment_remain;
pci= trackloc_segposcomb(tloc);
+ if (!pci) return -1;
lnki_far= trackloc_segmentlink(tloc, pci, 1);
- *remain_io -= segment_remain;
+ if (!SOMEP(lnki_far->next)) return -2;
tloc->seg= &segments[lnki_far->next];
tloc->into= 0;
tloc->backwards ^= lnki_far->next_backwards;
+ return +1;
}
}