Set more status bits in the SMChydra poller.

This commit is contained in:
kmpeters
2012-12-17 23:18:58 +00:00
parent 846e1247ed
commit 3b4a24ea82
+14 -3
View File
@@ -343,12 +343,14 @@ asynStatus SMChydraAxis::poll(bool *moving)
{
int done;
int driveOn;
int direction;
int lowLimit;
int highLimit;
int ignoreLowLimit;
int ignoreHighLimit;
int axisStatus=-1;
double position=0.0;
double newposition;
asynStatus comStatus;
static const char *functionName = "SMChydraAxis::poll";
@@ -359,7 +361,13 @@ asynStatus SMChydraAxis::poll(bool *moving)
if (comStatus) goto skip;
// The response string is a double
position = atof( (char *) &pC_->inString_);
newposition = position / axisRes_;
// Simulate the direction bit
direction = (newposition >= pC_->motorPosition_) ? 1 : 0;
setIntegerParam(pC_->motorStatusDirection_, direction);
// Update position, now that is is no longer needed for direction calc
setDoubleParam(pC_->motorPosition_, (position / axisRes_) );
setDoubleParam(pC_->motorEncoderPosition_, (position / axisRes_) );
// Read the status of this motor
sprintf(pC_->outString_, "%i nst", (axisNo_ + 1));
@@ -381,7 +389,6 @@ asynStatus SMChydraAxis::poll(bool *moving)
sprintf(pC_->outString_, "%i gna", (axisNo_ + 1));
comStatus = pC_->writeReadController();
// Check the limit bit (0x40)
if (axisStatus & 0x40)
{
@@ -406,6 +413,10 @@ asynStatus SMChydraAxis::poll(bool *moving)
asynPrint(this->pasynUser_, ASYN_TRACEIO_DRIVER,
"%s: axis %i emergency stop switch active.\n",
functionName, (axisNo_ + 1));
setIntegerParam(pC_->motorStatusProblem_, 1);
}
else{
setIntegerParam(pC_->motorStatusProblem_, 0);
}
// Check the device busy bit (0x400)
@@ -452,10 +463,10 @@ asynStatus SMChydraAxis::poll(bool *moving)
// Check the drive power bit (0x100)
driveOn = (axisStatus & 0x100) ? 0 : 1;
setIntegerParam(pC_->motorStatusPowerOn_, driveOn);
setIntegerParam(pC_->motorStatusProblem_, 0);
setIntegerParam(pC_->motorStatusCommsError_, 0);
skip:
setIntegerParam(pC_->motorStatusProblem_, comStatus ? 1:0);
setIntegerParam(pC_->motorStatusCommsError_, comStatus ? 1:0);
callParamCallbacks();
return comStatus ? asynError : asynSuccess;
}