*/
/*
* The following states exist for each Method
- * I Initialising corresponds to global states other than Sta_Run
+ * S Starting corresponds to global states other than Sta_Run
* T Tentative changes have been made but may yet be undone
* Y Yes proposed changes have been checked and are OK
* E Executing the method is executing
ErrorCode (*check)(Method *m); /* TYE->Y; err: TYE->TYE */
void (*execute)(Method *m); /* EY->E */
- void (*all_abandon)(Method *m); /* I */
+ void (*all_abandon)(Method *m); /* TYE->S */
};
/*========== general utility functions ==========*/
typedef unsigned FsqSlot;
typedef int FsqSlotSigned;
-/* We think there are three states: Allocated, Reserved and Confirmed.
- * (plus of course Unallocated where we don't have a request at all).
- * These correspond to the indep code as follows:
- *
- * indep state pt state queues checked and plan viable
- * Unallocated n/a yes
- * Allocated Allocated yes
- * Reserved Reserved yes
- * Confirmed Confirmed yes
- * Erroneous A/R/C no
- *
- * Erroneous exists only after a failed reserve() or confirm() so it's
- * not that confusing to have this slightly malleable terminology.
- */
-
#define FSQDN (~(FsqSlot)0)
-typedef struct { /* PR QR PC QC */
- /* in queue? absent reserved absent confirmed */
- Change h;
- FsqSlot deadline; /* relative relative absolute absolute */
- int n_motions; /* 1 1 alloc'd num undone */
- Motion motions[];
- /* [0].i: 0 0 non-0 non-0 */
- /* .posn: undef undef defined defined */
+typedef struct { /* state Prep Resv Inst Resv Prep Conf Inst Conf */
+ Change h; /* in queue? absent reserved absent confirmed */
+ FsqSlot deadline; /* relative relative absolute absolute */
+ int n_motions; /* 1 1 num undone num undone */
+ Motion motions[]; /* [0].i: 0 0 non-0 non-0 */
+ /* .posn: undef undef defined defined */
} FsqReq;
- /* We can determine the the state by looking at the two
- * `statedet' fields, marked <- above.
- * There are also intermediate states where the req's
- * statedet fields do not agree with the queue it's on.
- * We write these as, for example,
- * AR to mean statedet says Allocated, but queued on fsq_reserved
- * A? to mean statedet says Allocated, but may be queued
- * etc. They are only allowed while we are in a fsq_... method function.
- */
#define FSQ_MAX_QUEUE 15
}
}
-static ErrorCode fsq_enqueue(FsqMethod *m, FsqReq *r) { /* P->Q; err: P->P */
+static ErrorCode fsq_enqueue(FsqMethod *m, FsqReq *r) { /* P->I; err: P->P */
if (!r) return 0;
fsq_item_debug(m,r,"enqueue:",r->h.indep.move);
return fsq_queue_insert_item(fsq_item_queue(m,r), r);
}
-static void fsq_dequeue(FsqMethod *m, FsqReq *r) { /* Q->P */
+static void fsq_dequeue(FsqMethod *m, FsqReq *r) { /* I->P */
if (!r) return 0;
fsq_item_debug(m,r,"dequeue:",r->h.indep.move);
fsq_remove_item(fsq_item_queue(m,r), r);
if (!r->n_motions) {
fsq_queue_remove_index(&m->f.confirmed, 0);
- indep_change_done(&m->m, &r->h);
+ method_change_done(&m->m, &r->h);
m->h.dispose(&m->m, &r->h);
ec= fsq_check_plan(m); assert(!ec);
static FsqMethod points_method= {
{ "point", mfk_point,
- point_prepare, fsq_consider, fsq_dispose,
+ point_prepare, fsq_dispose,
+ fsq_install, fsq_remove,
fsq_check, fsq_execute, points_all_abandon },
{ .lag_ms= POINT_MOVEMENT, .slot_ms= CDU_RECHARGE, .move= point_move }
};
waggle.f.ready= 1;
waggle_settle_check();
}
-
+
void on_pic_waggled(const PicInsnInfo *pii, const PicInsn *pi, int objnum) {
if (sta_state == Sta_Settling) {
waggle.f.ready= 1;
static FsqMethod waggle= {
{ "relay", mfk_relay,
- fsq_prepare, fsq_consider, fsq_dispose,
+ fsq_prepare, fsq_dispose,
+ fsq_install, fsq_remove,
fsq_check, fsq_execute, ignore_all_abandon },
{ .lag_ms= 5, .slot_ms= 50, .move= waggle_do }
};
}
DPRINTF(movpos,change, "%s/%s maxdelay=%dms actual=%s\n",
- move->i->pname, movpos_pname(move,target),
+ move->i->pname, movpos_pname(move, target),
maxdelay_ms, movpos_pname(move, actual));
- if (resv) DPRINTF(movpos,change, " chg=%s:%s/%s\n",
- chg->meth->pname, chg->move->i->pname,
- movpos_pname(chg->move, chg->intent));
+ if (resv) DPRINTF(movpos,change, " resv=%s:%s/%s\n",
+ resv->meth->pname, resv->move->i->pname,
+ movpos_pname(resv->move, resv->target));
MovPosChange *inst= 0;
move->motion= inst;
indep_check_execute();
+
+ DPRINTF(movpos,change, "%s/%s maxdelay=%dms ok\n",
+ move->i->pname, movpos_pname(move, target),
+ maxdelay_ms);
return 0;
x:
ec= indep_install(move->motion, 0); assert(!ec);
ec= indep_install(resv, 0); assert(!ec);
indep_check_execute();
+
+ DPRINTF(movpos,change, "%s/%s maxdelay=%dms err=%s\n",
+ move->i->pname, movpos_pname(move, target),
+ maxdelay_ms, ec2str(ec));
return ec;
}
void motions_all_abandon(void) {
Method **meth;
+ SEG_IV
+ FOR_SEG {
+ if (!seg->moving) continue;
+
+ MovPosChange *abandon= seg->motion;
+ indep_remove(abandon);
+ indep_dispose(abandon);
+ seg->movposcomb= abandon->actual;
+ seg->moving= 0;
+ }
for (meth=methods; *meth; meth++)
(*meth)->all_abandon(*meth);
}
- STUFF BEYOND HERE IS FUNCTIONALITY WHICH NEEDS MOVING TO INDEP
- AND/OR CHECKING THAT WE STILL HAVE IT
+ STUFF BEYOND HERE IS JUST KEPT FOR GETTING DPRINTFS OUT OF
static ErrorCode fsq_confirm(Method *mm, Change *chg, Segment *move,
- r->actual= movposcomb_update_feature(r->actual,mo->i,mo->posn);
- if (r->h.actual >= 0 || !r->n_motions)
- r->h.actual= r->actual;
- ouposn_moving(&r->h);
-
-
-
-
- /* look for something to report
- * we can get things here other than from the above
- * eg if we are asked to move the
- */
- Segment *move= r->h.move;
- assert(move->moving && move->motion == (Change*)r);
- fsq_mark_as_allocated(r); /* now state A aka Done */
- motion_done(move,r->h.actual);
- free(r);
-
/*---------- entrypoints from rest of program ----------*/
static void fsq_all_abandon(Method *mm) {