From 313f8ac69b900ed7aac7a1d48f23b1505aa1fe15 Mon Sep 17 00:00:00 2001 From: ian Date: Sun, 27 Jul 2008 22:54:30 +0000 Subject: [PATCH] MARGIN_TRAINLENGTH --- hostside/resolve.c | 4 ++-- hostside/safety.c | 5 +++-- hostside/safety.h | 3 ++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/hostside/resolve.c b/hostside/resolve.c index 34f7b00..c9a4266 100644 --- a/hostside/resolve.c +++ b/hostside/resolve.c @@ -506,8 +506,8 @@ static void end_constraints(FindEndUserContext *u) { cons->min= lim.min; cons->max= lim.max; } else { - cons->max= -lim.min + tra->detectable; - cons->min= -lim.max + tra->detectable; + cons->max= -lim.min + ceil(tra->detectable * MARGIN_TRAINLENGTH); + cons->min= -lim.max + ceil(tra->detectable * MARGIN_TRAINLENGTH); } cons->lastdetect= u->lastdetect; cons->hardend= u->t.seg; diff --git a/hostside/safety.c b/hostside/safety.c index 1de3970..21e1d9e 100644 --- a/hostside/safety.c +++ b/hostside/safety.c @@ -772,7 +772,8 @@ ErrorCode predict(Train *tra, struct timeval tnow, unsigned flags, * so we must instead extend our idea of the length of the train. */ - int tail_walkback= MARGIN_NOSE + tail_length(tra) + tra->detectable; + int tail_walkback= MARGIN_NOSE + tail_length(tra) + + ceil(tra->detectable * MARGIN_TRAINLENGTH); int tail_advance_delaydist= MARGIN_TAIL; int effective_into_fdet= tra->maxinto - tra->uncertainty; @@ -1145,7 +1146,7 @@ ErrorCode safety_setdirection(Train *tra, int backwards, newfdet.remain= tra->maxinto; newfdet.backwards= !tra->foredetect->tr_backwards; - c.distance= tra->detectable + tra->uncertainty; + c.distance= ceil(tra->detectable * MARGIN_TRAINLENGTH) + tra->uncertainty; c.nextseg= reverse_nextseg; c.getmovpos= 0; c.trackend= reverse_trackend; diff --git a/hostside/safety.h b/hostside/safety.h index 6f918a5..263e219 100644 --- a/hostside/safety.h +++ b/hostside/safety.h @@ -48,7 +48,7 @@ struct Train { * foremost reference possibility, plus ->head, plus MARGIN_NOSE * (and if it is not stationary it may own more). It owns the * track backwards from the rearmost reference possibility for - * ->detectable plus ->tail plus MARGIN_NOSE. + * ceil(->detectable * MARGIN_TRAINLENGTH) + ->tail + MARGIN_NOSE. */ unsigned backwards:1, /* train is moving backwards wrt its own front and back */ @@ -402,6 +402,7 @@ int trackloc_set_exactinto(TrackLocation *t, TrackAdvanceContext *c, #define MARGIN_SPEED 1.2 /*ratio*/ #define MARGIN_AUTOPOINTTIME 500 /*ms*/ #define UNMARGIN_ROUNDING 1e-4 /* mm/ms; for 1s, leads to max err of 100um */ +#define MARGIN_TRAINLENGTH 1.05 #define MARGIN_STOPTIME 240 /*ms*/ #define MARGIN_POLARISETIME 120 /*ms*/ -- 2.30.2