Fix 'not ready' error by removing needUpdate=1 on MotorStatus

use MotorStatus interface for all status calls
add start position to motor simulator
This commit is contained in:
Peter Denison
2006-08-10 08:12:47 +00:00
parent 2965527681
commit ede6b73b0e
5 changed files with 36 additions and 55 deletions
+7 -6
View File
@@ -2,9 +2,9 @@
FILENAME... drvMotorSim.c
USAGE... Simulated Motor Support.
Version: $Revision: 1.5 $
Version: $Revision: 1.6 $
Modified By: $Author: peterd $
Last Modified: $Date: 2006-07-01 20:08:55 $
Last Modified: $Date: 2006-08-10 08:12:47 $
*/
/*
@@ -539,7 +539,7 @@ static void motorSimTask( motorSim_t * pDrv )
}
}
static int motorSimCreateAxis( motorSim_t * pDrv, int card, int axis, double lowLimit, double hiLimit, double home )
static int motorSimCreateAxis( motorSim_t * pDrv, int card, int axis, double lowLimit, double hiLimit, double home, double start )
{
AXIS_HDL pAxis;
AXIS_HDL * ppLast = &(pDrv->pFirst);
@@ -567,7 +567,7 @@ static int motorSimCreateAxis( motorSim_t * pDrv, int card, int axis, double low
pars.axis[0].Vmax = 1.0;
pAxis->endpoint.T = 0;
pAxis->endpoint.axis[0].p = 0;
pAxis->endpoint.axis[0].p = start;
pAxis->endpoint.axis[0].v = 0;
if ((pAxis->route = routeNew( &(pAxis->endpoint), &pars )) != NULL &&
@@ -581,6 +581,7 @@ static int motorSimCreateAxis( motorSim_t * pDrv, int card, int axis, double low
pAxis->home = home;
pAxis->print = motorSimLogMsg;
pAxis->logParam = NULL;
motorParam->setDouble(pAxis->params, motorAxisPosition, start);
*ppLast = pAxis;
pAxis->print( pAxis->logParam, TRACE_FLOW, "Created motor for card %d, signal %d OK", card, axis );
}
@@ -615,7 +616,7 @@ static int motorSimCreateAxis( motorSim_t * pDrv, int card, int axis, double low
}
void motorSimCreate( int card, int axis, int lowLimit, int hiLimit, int home, int nCards, int nAxes )
void motorSimCreate( int card, int axis, int lowLimit, int hiLimit, int home, int nCards, int nAxes, int startPosn )
{
int i;
int j;
@@ -645,7 +646,7 @@ void motorSimCreate( int card, int axis, int lowLimit, int hiLimit, int home, in
{
for (j = axis; j < axis+nAxes; j++ )
{
motorSimCreateAxis( &drv, i, j, (double) lowLimit, (double) hiLimit, (double) home );
motorSimCreateAxis( &drv, i, j, (double) lowLimit, (double) hiLimit, (double) home, (double) startPosn );
}
}
}
+1 -1
View File
@@ -5,7 +5,7 @@
extern "C" {
#endif
void motorSimCreate( int card, int axis, int hiLimit, int lowLimit, int home, int nCards, int nAxes );
void motorSimCreate( int card, int axis, int hiLimit, int lowLimit, int home, int nCards, int nAxes, int startPosn );
#ifdef __cplusplus
}
+4 -2
View File
@@ -11,6 +11,7 @@ static const iocshArg motorSimCreateArg3 = { "Low limit", iocshArgInt};
static const iocshArg motorSimCreateArg4 = { "Home position", iocshArgInt};
static const iocshArg motorSimCreateArg5 = { "Num cards", iocshArgInt};
static const iocshArg motorSimCreateArg6 = { "Num signals", iocshArgInt};
static const iocshArg motorSimCreateArg7 = { "Start posn", iocshArgInt};
static const iocshArg *const motorSimCreateArgs[] = {
&motorSimCreateArg0,
@@ -20,12 +21,13 @@ static const iocshArg *const motorSimCreateArgs[] = {
&motorSimCreateArg4,
&motorSimCreateArg5,
&motorSimCreateArg6,
&motorSimCreateArg7,
};
static const iocshFuncDef motorSimCreateDef ={"motorSimCreate",7,motorSimCreateArgs};
static const iocshFuncDef motorSimCreateDef ={"motorSimCreate",8,motorSimCreateArgs};
static void motorSimCreateCallFunc(const iocshArgBuf *args)
{
motorSimCreate(args[0].ival, args[1].ival, args[2].ival, args[3].ival, args[4].ival, args[5].ival, args[6].ival);
motorSimCreate(args[0].ival, args[1].ival, args[2].ival, args[3].ival, args[4].ival, args[5].ival, args[6].ival, args[7].ival);
}
void motorSimRegister(void)
+16 -41
View File
@@ -11,9 +11,9 @@
* Notwithstanding the above, explicit permission is granted for APS to
* redistribute this software.
*
* Version: $Revision: 1.12 $
* Version: $Revision: 1.13 $
* Modified by: $Author: peterd $
* Last Modified: $Date: 2006-07-20 17:10:37 $
* Last Modified: $Date: 2006-08-10 08:12:47 $
*
* Original Author: Peter Denison
* Current Author: Peter Denison
@@ -80,12 +80,7 @@ typedef struct
{
struct motorRecord * pmr;
int moveRequestPending;
epicsUInt32 status; /**< bit mask of errors and other binary information. The
bit positions are in motor.h */
epicsInt32 position; /**< Current motor position in motor steps (if not
servoing) or demand position (if servoing) */
epicsInt32 encoder_position; /**< Current motor position in encoder units
(only available if a servo system). */
struct MotorStatus status;
motor_cmnd move_cmd;
double param;
int needUpdate;
@@ -221,14 +216,8 @@ static long init_record(struct motorRecord * pmr )
resolution);
*/
pasynUser->reason = motorStatus;
pPvt->pasynInt32->read(pPvt->asynInt32Pvt, pasynUser,
&pPvt->status);
pasynUser->reason = motorPosition;
pPvt->pasynInt32->read(pPvt->asynInt32Pvt, pasynUser,
&pPvt->position);
pasynUser->reason = motorEncoderPosition;
pPvt->pasynInt32->read(pPvt->asynInt32Pvt, pasynUser,
&pPvt->encoder_position);
pPvt->pasynMotorStatus->read(pPvt->asynMotorStatusPvt, pasynUser,
&pPvt->status);
pasynManager->freeAsynUser(pasynUser);
pPvt->needUpdate = 1;
@@ -246,10 +235,10 @@ CALLBACK_VALUE update_values(struct motorRecord * pmr)
rc = NOTHING_DONE;
if ( pPvt->needUpdate ) {
pmr->rmp = pPvt->position;
pmr->rep = pPvt->encoder_position;
/* pmr->rvel = ptrans->vel; */
pmr->msta = pPvt->status;
pmr->rmp = (epicsInt32)round(pPvt->status.position);
pmr->rep = (epicsInt32)round(pPvt->status.encoder_posn);
/* pmr->rvel = (epicsInt32)round(pPvt->status.velocity); */
pmr->msta = pPvt->status.status;
rc = CALLBACK_DATA;
pPvt->needUpdate = 0;
}
@@ -393,9 +382,6 @@ static RTN_STATUS build_trans( motor_cmnd command,
case GET_INFO:
pmsg->command = motorStatus;
pmsg->interface = float64ArrayType;
/* Check this - needUpdate can cause the callback mechanism to get
stuck. Must ensure that the record will be processed after this */
pPvt->needUpdate = 1;
break;
case SET_RESOLUTION:
pmsg->command = motorResolution;
@@ -446,14 +432,8 @@ static void asynCallback(asynUser *pasynUser)
switch (pmsg->command) {
case motorStatus:
/* Read the current status of the device */
pPvt->pasynInt32->read(pPvt->asynInt32Pvt, pasynUser,
&pPvt->status);
pasynUser->reason = motorPosition;
pPvt->pasynInt32->read(pPvt->asynInt32Pvt, pasynUser,
&pPvt->position);
pasynUser->reason = motorEncoderPosition;
pPvt->pasynInt32->read(pPvt->asynInt32Pvt, pasynUser,
&pPvt->encoder_position);
pPvt->pasynMotorStatus->read(pPvt->asynMotorStatusPvt, pasynUser,
&pPvt->status);
break;
case motorMoveAbs:
@@ -502,25 +482,20 @@ static void statusCallback(void *drvPvt, asynUser *pasynUser,
motorRecord *pmr = pPvt->pmr;
asynPrint(pasynUser, ASYN_TRACEIO_DEVICE,
"%s devMotorAsyn::statusCallback new value=0x%x\n",
pmr->name, value);
"%s devMotorAsyn::statusCallback new value=[p:%f,s:%x] %c%c\n",
pmr->name, value->position, value->status,
pPvt->needUpdate?'N':' ', pPvt->moveRequestPending?'P':' ');
if (dbScanLockOK) {
dbScanLock((dbCommon *)pmr);
pPvt->status = value->status;
pPvt->position = (epicsInt32)floor(value->position+0.5);
pPvt->encoder_position = (epicsInt32)floor(value->encoder_posn+0.5);
/* pPvt->velocity = (epicsInt32)floor(value->velocity+0.5);*/
pPvt->status = *value;
if (!pPvt->needUpdate && !pPvt->moveRequestPending) {
pPvt->needUpdate = 1;
pmr->rset->process((dbCommon*)pmr);
}
dbScanUnlock((dbCommon*)pmr);
} else {
pPvt->status = value->status;
pPvt->position = (epicsInt32)floor(value->position+0.5);
pPvt->encoder_position = (epicsInt32)floor(value->encoder_posn+0.5);
/* pPvt->veolcity = (epicsInt32)floor(value->velocity+0.5);*/
pPvt->status = *value;
pPvt->needUpdate = 1;
}
}
+8 -5
View File
@@ -19,9 +19,9 @@
* of this distribution.
* ************************************************************************
*
* Version: $Revision: 1.11 $
* Version: $Revision: 1.12 $
* Modified by: $Author: peterd $
* Last Modified: $Date: 2006-07-07 20:50:19 $
* Last Modified: $Date: 2006-08-10 08:12:47 $
*
* Original Author: Peter Denison
* Current Author: Peter Denison
@@ -400,7 +400,8 @@ static asynStatus readInt32(void *drvPvt, asynUser *pasynUser,
break;
}
asynPrint(pasynUser, ASYN_TRACEIO_DRIVER,
"drvMotorAsyn::readInt32, value=%d\n", *value);
"drvMotorAsyn::readInt32, reason=%d, value=%d\n",
command, *value);
return(asynSuccess);
}
@@ -450,7 +451,8 @@ static asynStatus readFloat64(void *drvPvt, asynUser *pasynUser,
break;
}
asynPrint(pasynUser, ASYN_TRACEIO_DRIVER,
"drvMotorAsyn::readFloat64, value=%f\n", *value);
"drvMotorAsyn::readFloat64, reason=%d, value=%f\n",
command, *value);
return(status);
}
@@ -510,7 +512,8 @@ static asynStatus writeInt32(void *drvPvt, asynUser *pasynUser,
break;
}
asynPrint(pasynUser, ASYN_TRACEIO_DRIVER,
"drvMotorAsyn::writeInt32, value=%d\n", value);
"drvMotorAsyn::writeInt32, reason=%d, value=%d\n",
command, value);
return(status);
}