From ab94807a3b6df0263d1c88f569b9c4b10427ddfb Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Thu, 6 Jan 2011 02:05:27 +0000 Subject: [PATCH] hostside: rename nmra functions etc. from "features" to "adjuncts" (name chosen from NAMES-FOR-FEATURE) --- hostside/NAMES-FOR-FEATURE | 43 +++++++++++++++++ hostside/README.commands | 2 +- hostside/actual.c | 38 +++++++-------- hostside/homes.record | 24 +++++----- hostside/realtime.h | 38 +++++++-------- hostside/record-i.h | 8 ++-- hostside/record-l.l | 2 +- hostside/record-y.y | 22 ++++----- hostside/record.c | 96 +++++++++++++++++++------------------- hostside/startup.c | 2 +- 10 files changed, 159 insertions(+), 116 deletions(-) create mode 100644 hostside/NAMES-FOR-FEATURE diff --git a/hostside/NAMES-FOR-FEATURE b/hostside/NAMES-FOR-FEATURE new file mode 100644 index 0000000..e19c27f --- /dev/null +++ b/hostside/NAMES-FOR-FEATURE @@ -0,0 +1,43 @@ +perk +ability +facility +aspect +facet +member +piece +unit +element +provision +resource +property +talent +capability +capacity +particle +part +member +factor +constituent +limb +lamp +auxiliary +attachment +fragment +fraction +hunk +quantum +beacon +digit +factor +fraction +member +action +behaviour +service +manifestation +accessory +adjunct +trim +trimming +frill +supplement diff --git a/hostside/README.commands b/hostside/README.commands index ef9bfaa..07c60b6 100644 --- a/hostside/README.commands +++ b/hostside/README.commands @@ -191,7 +191,7 @@ CHIEF COMMANDS noop [...] - feature -|+|^ |* [[-|+|^] ...] + adjunct -|+|^ |* [[-|+|^] ...] !nmrafeat | -|+|^ [[-|+|^] ...] route [] diff --git a/hostside/actual.c b/hostside/actual.c index d4d03dc..3fd5e75 100644 --- a/hostside/actual.c +++ b/hostside/actual.c @@ -54,52 +54,52 @@ void actual_inversions_done(void) { /*---------- features ----------*/ -static void feat_updated_cmd(FeaturesAddr *a, int ix, Nmra *n /*destroyed*/) { +static void adj_updated_cmd(AdjunctsAddr *a, int ix, Nmra *n /*destroyed*/) { assert(a->rn[ix].pi.l); retransmit_relaxed_cancel(&a->rn[ix]); retransmit_relaxed_queue(&a->rn[ix], n); } -static void feat_updated_funcs(FeaturesAddr *a, int ix, - void (*enco)(Nmra *n, int addr, unsigned map), - unsigned thiscmd) { +static void adj_updated_funcs(AdjunctsAddr *a, int ix, + void (*enco)(Nmra *n, int addr, unsigned map), + unsigned thiscmd) { Nmra n; if (!(a->all & thiscmd)) return; enco(&n,a->addr,a->current); - feat_updated_cmd(a,ix,&n); + adj_updated_cmd(a,ix,&n); } -void features_updated(FeaturesAddr *a) { +void adjuncts_updated(AdjunctsAddr *a) { /* idempotent; call this after updating a->current */ - feat_updated_funcs(a,0, enco_nmra_funcs0to4, 0x0001f); - feat_updated_funcs(a,1, enco_nmra_funcs5to8, 0x001e0); - feat_updated_funcs(a,2, enco_nmra_funcs9to12, 0x01e00); + adj_updated_funcs(a,0, enco_nmra_funcs0to4, 0x0001f); + adj_updated_funcs(a,1, enco_nmra_funcs5to8, 0x001e0); + adj_updated_funcs(a,2, enco_nmra_funcs9to12, 0x01e00); - if (a->all & FEATS_SPEEDSTEP_BIT) { + if (a->all & ADJS_SPEEDSTEP_BIT) { Nmra n; enco_nmra_speed126(&n, a->addr, - a->current & FEATS_SPEEDSTEP_BIT + a->current & ADJS_SPEEDSTEP_BIT ? a->speedstep : 0, - !!(a->all & FEATS_SPEEDSTEP_REVERSE)); - feat_updated_cmd(a,3, &n); + !!(a->all & ADJS_SPEEDSTEP_REVERSE)); + adj_updated_cmd(a,3, &n); } } -void features_start_xmit(void) { - FeaturesAddr **ap; +void adjuncts_start_xmit(void) { + AdjunctsAddr **ap; Nmra n; int ix, ai; - for (ai=0,ap=feataddrs; airn[ix]; if (!rn->pi.l) { enco_nmra_idle(&n); retransmit_relaxed_queue(rn,&n); } } - features_updated(a); + adjuncts_updated(a); } } diff --git a/hostside/homes.record b/hostside/homes.record index 4ec5b30..23c0296 100644 --- a/hostside/homes.record +++ b/hostside/homes.record @@ -2,20 +2,20 @@ train santafe home -B7 -B6 train shinkansen home -C10 -C9 -C8 -C7 -C6 -C5 -C4 -C3 train bavarian home -B10 -B9 -feature shinkansen head is 1 5 -feature shinkansen head-red is 1 6 -feature shinkansen tail is 1 7 -feature shinkansen tail-red is 1 8 -feature - is 1 4 +adjunct shinkansen head is 1 5 +adjunct shinkansen head-red is 1 6 +adjunct shinkansen tail is 1 7 +adjunct shinkansen tail-red is 1 8 +adjunct - is 1 4 -feature santafe head is 2 5 -feature santafe tail is 2 6 -feature - is 2 4 +adjunct santafe head is 2 5 +adjunct santafe tail is 2 6 +adjunct - is 2 4 -feature bavarian head is 4 5 -feature bavarian tail is 4 6 -feature - is 4 4 +adjunct bavarian head is 4 5 +adjunct bavarian tail is 4 6 +adjunct - is 4 4 -feature hoover motor is 5 step 60 +adjunct hoover motor is 5 step 60 end diff --git a/hostside/realtime.h b/hostside/realtime.h index 05e1c75..1b4c63d 100644 --- a/hostside/realtime.h +++ b/hostside/realtime.h @@ -67,41 +67,41 @@ void retransmit_relaxed_cancel(RetransmitRelaxedNode *rn); * urgent_requeue if it's queued and has changed and must get a new * quota of urgency; _requeue is just _cancel followed by queue. */ -/*---------- features, filled in by record, used by features.c ----------*/ +/*---------- adjuncts, filled in by record, used by adjuncts.c ----------*/ -#define FEATURESADDR_TRANSMITS 4 +#define ADJUNCTSADDR_TRANSMITS 4 /* 0..2 are func0to4 func5to8 func9to12 and speed cmd * pi.l is 0 if not transmitting */ -#define FEATS_SPEEDSTEP_BIT 0x4000u /* a->{current,all,permit}, f->bits */ -#define FEATS_SPEEDSTEP_REVERSE 0x8000u /* in a->all */ +#define ADJS_SPEEDSTEP_BIT 0x4000u /* a->{current,all,permit}, f->bits */ +#define ADJS_SPEEDSTEP_REVERSE 0x8000u /* in a->all */ -typedef struct FeaturesAddr { - struct FeaturesAddr *next; +typedef struct AdjunctsAddr { + struct AdjunctsAddr *next; int addr, speedstep; unsigned current, permit, all; - RetransmitRelaxedNode rn[FEATURESADDR_TRANSMITS]; -} FeaturesAddr; + RetransmitRelaxedNode rn[ADJUNCTSADDR_TRANSMITS]; +} AdjunctsAddr; typedef struct { char *pname; /* first, for pname1st_compar */ - FeaturesAddr *a; + AdjunctsAddr *a; unsigned bits; /* may have no or several bits set */ -} FeaturesFeature; +} AdjunctsAdjunct; -typedef struct FeaturesTarget { +typedef struct AdjunctsTarget { char *pname; /* first, for pname1st_compar */ - int n_feats; - FeaturesFeature *feats; -} FeaturesTarget; + int n_adjs; + AdjunctsAdjunct *adjs; +} AdjunctsTarget; extern int n_trains; extern Train *trains; extern Segment *segments; -extern int n_feattargs, n_feataddrs; -extern FeaturesTarget *feattargs; -extern FeaturesAddr **feataddrs; +extern int n_adjtargs, n_adjaddrs; +extern AdjunctsTarget *adjtargs; +extern AdjunctsAddr **adjaddrs; /*---------- global variables, in realtime.c ----------*/ @@ -186,8 +186,8 @@ int picinsn_polarity_testbit(const PicInsn *pi, const SegmentInfo *segi); /* this belongs in {au,skel}proto-pic.[ch] really but it's * more convenient here. */ -void features_start_xmit(void); -void features_updated(FeaturesAddr *a); +void adjuncts_start_xmit(void); +void adjuncts_updated(AdjunctsAddr *a); /*---------- from movpos.c ----------*/ diff --git a/hostside/record-i.h b/hostside/record-i.h index 3db3d91..dae8b4b 100644 --- a/hostside/record-i.h +++ b/hostside/record-i.h @@ -14,13 +14,13 @@ void record_train_stopregime_count(void); void record_train_stopregime(Train *tra, int step, int xs, int ts); void record_seg_has(Segment *seg, int backw, Train *tra, int inverted); void record_seg_at(Segment *seg, const char *movposcomb_pname); -void record_feature_nmrafeat(FeaturesFeature*, FeaturesAddr*, int num); -void record_feature_motor(FeaturesFeature*, FeaturesAddr*, int speed); +void record_adjunct_nmrafunc(AdjunctsAdjunct*, AdjunctsAddr*, int num); +void record_adjunct_motor(AdjunctsAdjunct*, AdjunctsAddr*, int speed); Train *record_pname2train(const char *pname); Segment *record_pname2seg(const char *pname); -FeaturesFeature *record_pname2feature(const char *pname, const char *letter); -FeaturesAddr *record_feataddr(int addr); +AdjunctsAdjunct *record_pname2adjunct(const char *pname, const char *letter); +AdjunctsAddr *record_adjaddr(int addr); char *record_tempzone_strdup(const char *s); void record_yyerror(const char *m); void record_tempzone_clear(void); diff --git a/hostside/record-l.l b/hostside/record-l.l index 77c0952..5949b76 100644 --- a/hostside/record-l.l +++ b/hostside/record-l.l @@ -19,7 +19,7 @@ train { STRT TRAIN; } seg { STRT SEG; } -feature { STRT FEATURE; } +adjunct { STRT ADJUNCT; } is { STRT IS; } at { STRT AT; } has { STRT HAS; } diff --git a/hostside/record-y.y b/hostside/record-y.y index b71c55e..787bf23 100644 --- a/hostside/record-y.y +++ b/hostside/record-y.y @@ -11,13 +11,13 @@ static Train *cur_train; const char *name; Train *train; Segment *seg; - FeaturesFeature *feature; - FeaturesAddr *feataddr; + AdjunctsAdjunct *adjunct; + AdjunctsAddr *adjaddr; int num; double dbl; } -%token TRAIN FEATURE SEG IS AT HAS INVERTED STEP STOPS HOME END +%token TRAIN ADJUNCT SEG IS AT HAS INVERTED STEP STOPS HOME END %token IDENT %token NL %token NUM @@ -28,8 +28,8 @@ static Train *cur_train; %type seg %type backwards inverted %type dbl -%type feature -%type feataddr +%type adjunct +%type adjaddr %defines %error-verbose @@ -60,11 +60,11 @@ line: /* empty */ | SEG seg AT ident { if ($2) record_seg_at($2,$4); } - | FEATURE feature IS feataddr NUM - { if (trains) record_feature_nmrafeat($2,$4,$5); + | ADJUNCT adjunct IS adjaddr NUM + { if (trains) record_adjunct_nmrafunc($2,$4,$5); } - | FEATURE feature IS feataddr STEP NUM - { if (trains) record_feature_motor($2,$4,$6); + | ADJUNCT adjunct IS adjaddr STEP NUM + { if (trains) record_adjunct_motor($2,$4,$6); } backwards: /* empty */ { $$= 0; } @@ -86,9 +86,9 @@ dbl: DBL seg: ident { $$= record_pname2seg($1); } train: ident { $$= record_pname2train($1); } -feature: ident ident { $$= record_pname2feature($1,$2); } +adjunct: ident ident { $$= record_pname2adjunct($1,$2); } | '-' { $$= 0; } -feataddr: NUM { $$= record_feataddr($1); } +adjaddr: NUM { $$= record_adjaddr($1); } end: END NL diff --git a/hostside/record.c b/hostside/record.c index 7687649..9d7d973 100644 --- a/hostside/record.c +++ b/hostside/record.c @@ -10,10 +10,10 @@ * train stops at after * seg has [-] [inverted] * seg at - * feature is - * feature is step [-] - * feature - is } prevents enabling feature; - * feature - is step [-] } xmits turning it off + * adjunct is + * adjunct is step [-] + * adjunct - is } prevents enabling adjunct; + * adjunct - is step [-] } xmits turning it off * * speed is floating point in m/s */ @@ -23,9 +23,9 @@ #include "record-i.h" #include "record-l.h" -int n_feattargs, n_feataddrs; -FeaturesTarget *feattargs; -FeaturesAddr **feataddrs; +int n_adjtargs, n_adjaddrs; +AdjunctsTarget *adjtargs; +AdjunctsAddr **adjaddrs; /*---------- input and error handling ----------*/ @@ -90,16 +90,16 @@ Segment *record_pname2seg(const char *pname) { } \ }while(0) -FeaturesAddr *record_feataddr(int num) { - FeaturesAddr **search; +AdjunctsAddr *record_adjaddr(int num) { + AdjunctsAddr **search; int ix; - if (num<1 || num>0x3ff) record_yyerror("feature address out of range"); + if (num<1 || num>0x3ff) record_yyerror("adjunct address out of range"); ARY_FIND_OR_APPEND - (feataddrs,n_feataddrs, ix,search, (*search)->addr == num, ({ + (adjaddrs,n_adjaddrs, ix,search, (*search)->addr == num, ({ int i; - FeaturesAddr *item= mmalloc(sizeof(*item)); + AdjunctsAddr *item= mmalloc(sizeof(*item)); item->next= 0; item->addr= num; item->speedstep= 0; @@ -111,26 +111,26 @@ FeaturesAddr *record_feataddr(int num) { return *search; } -FeaturesFeature *record_pname2feature(const char *targpn, const char *featpn) { +AdjunctsAdjunct *record_pname2adjunct(const char *targpn, const char *adjpn) { int i; - FeaturesTarget *targ; - FeaturesFeature *feat; + AdjunctsTarget *targ; + AdjunctsAdjunct *adj; ARY_FIND_OR_APPEND - (feattargs,n_feattargs,i,targ, !strcmp(targ->pname, targpn), ({ + (adjtargs,n_adjtargs,i,targ, !strcmp(targ->pname, targpn), ({ targ->pname= mstrdup(targpn); - targ->n_feats= 0; - targ->feats= 0; + targ->n_adjs= 0; + targ->adjs= 0; })); ARY_FIND_OR_APPEND - (targ->feats,targ->n_feats,i,feat, !strcmp(feat->pname, featpn), ({ - feat->pname= mstrdup(featpn); - feat->a= 0; - feat->bits= 0; + (targ->adjs,targ->n_adjs,i,adj, !strcmp(adj->pname, adjpn), ({ + adj->pname= mstrdup(adjpn); + adj->a= 0; + adj->bits= 0; })); - return feat; + return adj; } /*---------- zone allocator for strings ----------*/ @@ -231,21 +231,21 @@ found: seg->movposcomb= poscomb; } -/*---------- features ----------*/ +/*---------- adjuncts ----------*/ -static void record_feature_bits(FeaturesFeature *feat, FeaturesAddr *addr, +static void record_adjunct_bits(AdjunctsAdjunct *adj, AdjunctsAddr *addr, unsigned bits) { - if (!feat) /* `-' feature */ + if (!adj) /* `-' adjunct */ return; - if (feat->a && feat->a != addr) - record_yyerror("feature includes multiple decoder addresses"); - feat->a= addr; - feat->bits |= bits; + if (adj->a && adj->a != addr) + record_yyerror("adjunct includes multiple decoder addresses"); + adj->a= addr; + adj->bits |= bits; addr->permit |= bits; addr->all |= bits; } -void record_feature_nmrafeat(FeaturesFeature *feat, FeaturesAddr *addr, +void record_adjunct_nmrafunc(AdjunctsAdjunct *adj, AdjunctsAddr *addr, int num) { int bitval; @@ -253,22 +253,22 @@ void record_feature_nmrafeat(FeaturesFeature *feat, FeaturesAddr *addr, bitval= 1<all & bitval) - record_yyerror("feature bit respecified"); + record_yyerror("adjunct bit respecified"); - record_feature_bits(feat,addr,bitval); + record_adjunct_bits(adj,addr,bitval); } -void record_feature_motor(FeaturesFeature *feat, FeaturesAddr *addr, +void record_adjunct_motor(AdjunctsAdjunct *adj, AdjunctsAddr *addr, int speed) { if (speed<-126 || speed>126) record_yyerror("motor speed out of range"); if (!speed) record_yyerror("zero motor speed?!"); - if (addr->speedstep) record_yyerror("feature specifies multiple speeds"); + if (addr->speedstep) record_yyerror("adjunct specifies multiple speeds"); - record_feature_bits(feat,addr,FEATS_SPEEDSTEP_BIT); + record_adjunct_bits(adj,addr,ADJS_SPEEDSTEP_BIT); addr->speedstep= speed; if (addr->speedstep<0) { - addr->all |= FEATS_SPEEDSTEP_REVERSE; + addr->all |= ADJS_SPEEDSTEP_REVERSE; addr->speedstep= -addr->speedstep; } } @@ -279,23 +279,23 @@ static int pname1st_compar(const void *av, const void *bv) { return strcmp(*a,*b); } -static int feataddrp_compar(const void *av, const void *bv) { - const FeaturesAddr *const *a= av; - const FeaturesAddr *const *b= bv; +static int adjaddrp_compar(const void *av, const void *bv) { + const AdjunctsAddr *const *a= av; + const AdjunctsAddr *const *b= bv; return (*a)->addr - (*b)->addr; } -static void features_postprocess(void) { +static void adjuncts_postprocess(void) { int i; - FeaturesTarget *targ; + AdjunctsTarget *targ; - qsort(feattargs, n_feattargs, sizeof(*feattargs), pname1st_compar); - qsort(feataddrs, n_feataddrs, sizeof(*feataddrs), feataddrp_compar); + qsort(adjtargs, n_adjtargs, sizeof(*adjtargs), pname1st_compar); + qsort(adjaddrs, n_adjaddrs, sizeof(*adjaddrs), adjaddrp_compar); - for (i=0, targ=feattargs; - ifeats, targ->n_feats, sizeof(*targ->feats), pname1st_compar); + qsort(targ->adjs, targ->n_adjs, sizeof(*targ->adjs), pname1st_compar); } /*---------- speed curves ----------*/ @@ -508,7 +508,7 @@ void records_parse(const char **argv) { parse_pass(argv); /* trains!=0: populates data area */ record_tempzone_clear(); speeds_postprocess(); - features_postprocess(); + adjuncts_postprocess(); record_tempzone_freeall(); record_yylex_destroy(); } diff --git a/hostside/startup.c b/hostside/startup.c index 5fadd1a..cab2995 100644 --- a/hostside/startup.c +++ b/hostside/startup.c @@ -134,7 +134,7 @@ static void sta_goto(StartupState new_state) { case Sta_Resolving: resolve_begin(); points_turning_on(); - features_start_xmit(); + adjuncts_start_xmit(); enco_pic_on(&piob); break; case Sta_Finalising: -- 2.30.2