Fixed Nanotex driver to work with the real HW and the simulation

This commit is contained in:
2016-05-03 11:58:24 +02:00
parent 047b0d8c74
commit 4b377d1b2e
4 changed files with 44 additions and 18 deletions

View File

@ -36,6 +36,7 @@ July 2015
#define IDLEPOLL 60
#define ABS(x) (x < 0 ? -(x) : (x))
/** Creates a new NanotecController object.
* \param[in] portName The name of the asyn port that will be created for this driver
@ -206,6 +207,9 @@ asynStatus NanotecAxis::move(double position, int relative, double minVelocity,
}
homing = 0;
setIntegerParam(pC_->motorStatusAtHome_, false);
setIntegerParam(pC_->motorStatusHighLimit_, false);
setIntegerParam(pC_->motorStatusLowLimit_, false);
/*
set mode
@ -244,15 +248,8 @@ asynStatus NanotecAxis::home(double minVelocity, double maxVelocity, double acce
//static const char *functionName = "NanotecAxis::home";
char command[COMLEN], reply[COMLEN];
/*
set mode
*/
snprintf(command,sizeof(command),"#%dp4",busAddress);
status = pC_->transactController(command,reply);
if(status != asynSuccess){
return status;
}
setIntegerParam(pC_->motorStatusAtHome_, false);
/*
reset positioning errors
*/
@ -261,6 +258,16 @@ asynStatus NanotecAxis::home(double minVelocity, double maxVelocity, double acce
if(status != asynSuccess){
return status;
}
/*
set mode
*/
snprintf(command,sizeof(command),"#%dp4",busAddress);
status = pC_->transactController(command,reply);
if(status != asynSuccess){
return status;
}
/*
set direction
@ -362,6 +369,7 @@ asynStatus NanotecAxis::poll(bool *moving)
char command[COMLEN], reply[COMLEN];
char *pPtr;
int posVal, statVal;
double lowLim, highLim;
// protect against excessive polling
@ -397,13 +405,16 @@ asynStatus NanotecAxis::poll(bool *moving)
setIntegerParam(pC_->motorStatusDone_, false);
*moving = true;
pC_->getDoubleParam(axisNo_,pC_->motorLowLimit_,&lowLim);
pC_->getDoubleParam(axisNo_,pC_->motorHighLimit_,&highLim);
if(homing){
/*
code for homing
*/
switch(statVal) {
case 164:
setPosition(.0);
break;
case 163:
case 161:
setPosition(lowLim);
*moving = false;
setIntegerParam(pC_->motorStatusAtHome_, true);
setIntegerParam(pC_->motorStatusDone_, true);
@ -417,10 +428,23 @@ asynStatus NanotecAxis::poll(bool *moving)
break;
}
} else {
/*
code for normal movement
*/
if(statVal & 1) {
*moving = false;
setIntegerParam(pC_->motorStatusDone_, true);
}
} else if (statVal & 4) {
setIntegerParam(pC_->motorStatusDone_, true);
setIntegerParam(pC_->motorStatusProblem_, true);
errlogSevPrintf(errlogMajor, "Limit or other positioning problem at %d", axisNo_);
if(ABS(posVal - lowLim) < ABS(posVal - highLim)){
setIntegerParam(pC_->motorStatusLowLimit_, true);
} else {
setIntegerParam(pC_->motorStatusHighLimit_, true);
}
*moving = false;
}
}
if(*moving == true){