Make finite state machine the default. Make blocked motors fail the default. Add "data" to display computed data for motor. Improve blocked motor test message.

r1962 | dcl | 2007-05-15 12:35:24 +1000 (Tue, 15 May 2007) | 2 lines
This commit is contained in:
Douglas Clowes
2007-05-15 12:35:24 +10:00
parent 1eb1698d79
commit c47e4ad45c

View File

@@ -1075,8 +1075,11 @@ static int checkMotion(void *pData) {
ratio_cmp > self->blockage_ratio ||
(1.0 / ratio_cmp) > self->blockage_ratio) {
char msg[132];
snprintf(msg, sizeof(msg), "Motion check fail: obs=%f, exp=%f",
ratio_obs, ratio_exp);
float cmp = ratio_cmp;
if (fabs(cmp) > 0 && fabs(cmp) < 1)
cmp = 1.0 / cmp;
snprintf(msg, sizeof(msg), "Motor %s fail: obs=%f, exp=%f, cmp=%f",
self->name, ratio_obs, ratio_exp, cmp);
SICSLogWrite(msg, eError);
snprintf(msg, sizeof(msg), "steps=%f-%f, counts=%f-%f, exp=%f/%f",
steps, self->lastSteps, counts, self->lastCounts,
@@ -1089,8 +1092,11 @@ static int checkMotion(void *pData) {
} else {
if (self->debug) {
char msg[132];
snprintf(msg, sizeof(msg), "Motion check pass: obs=%f, exp=%f",
ratio_obs, ratio_exp);
float cmp = ratio_cmp;
if (fabs(cmp) > 0 && fabs(cmp) < 1)
cmp = 1.0 / cmp;
snprintf(msg, sizeof(msg), "Motor %s pass: obs=%f, exp=%f, cmp=%f",
self->name, ratio_obs, ratio_exp, cmp);
SICSLogWrite(msg, eError);
}
set_lastMotion(pData, steps, counts);
@@ -2957,9 +2963,9 @@ MotorDriver *CreateDMC2280(SConnection *pCon, char *motor, char *params) {
pNew->KillPrivate = KillDMC2280;
pNew->GetDriverTextPar = NULL;
pNew->blockage_ckInterval = 0.5;
pNew->blockage_thresh = 0.5;
pNew->blockage_ratio = 2.0;
pNew->blockage_fail = 0;
pNew->blockage_thresh = 0.5; /* minimum distance in units */
pNew->blockage_ratio = 2.0; /* maximum ratio observed/expected */
pNew->blockage_fail = 1; /* fail the motor */
pNew->backlash_offset = 0.0;
pNew->myState = DMCState_Unknown;
@@ -2974,7 +2980,7 @@ MotorDriver *CreateDMC2280(SConnection *pCon, char *motor, char *params) {
/* FSM: this driver uses the finite state machine model */
if ((pPtr=getParam(pCon, interp, params,"fsm",_OPTIONAL)) == NULL)
pNew->has_fsm=0;
pNew->has_fsm=1;
else {
sscanf(pPtr,"%d",&(pNew->has_fsm));
}
@@ -3147,7 +3153,22 @@ int DMC2280Action(SConnection *pCon, SicsInterp *pSics, void *pData,
SCWrite(pCon, rsp, eValue);
return 1;
}
if (strcasecmp("units", argv[1]) == 0) {
else if(strcasecmp("data", argv[1]) == 0) {
char line[132];
snprintf(line, 132, "%s.motor_step = %f %s", self->name,
1.0 / self->stepsPerX, self->units);
SCWrite(pCon, line, eValue);
if (self->abs_encoder) {
snprintf(line, 132, "%s.encoder_count = %f %s", self->name,
1.0 / self->cntsPerX, self->units);
SCWrite(pCon, line, eValue);
snprintf(line, 132, "%s.steps_per_count = %f steps", self->name,
self->stepsPerX / self->cntsPerX);
SCWrite(pCon, line, eValue);
}
return 1;
}
else if (strcasecmp("units", argv[1]) == 0) {
if (argc > 2) {
strncpy(self->units, argv[2], sizeof(self->units));
self->units[sizeof(self->units) - 1] = '\0';