From 3b4a24ea82a8a118f878cbf5619000583c683244 Mon Sep 17 00:00:00 2001 From: kmpeters Date: Mon, 17 Dec 2012 23:18:58 +0000 Subject: [PATCH] Set more status bits in the SMChydra poller. --- motorApp/MicosSrc/SMChydraDriver.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/motorApp/MicosSrc/SMChydraDriver.cpp b/motorApp/MicosSrc/SMChydraDriver.cpp index c82f25ed..2b328fdd 100644 --- a/motorApp/MicosSrc/SMChydraDriver.cpp +++ b/motorApp/MicosSrc/SMChydraDriver.cpp @@ -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; }