From 972131d86ae3eaeaf3921cf39f8b745adbafd673 Mon Sep 17 00:00:00 2001 From: koennecke Date: Tue, 8 Jan 2019 11:35:09 +0100 Subject: [PATCH] Added new system disconnect reporting to the phytron driver --- sinqEPICSApp/src/PhytronDriver.cpp | 27 ++++++++++++++++----------- sinqEPICSApp/src/PhytronDriver.h | 2 +- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/sinqEPICSApp/src/PhytronDriver.cpp b/sinqEPICSApp/src/PhytronDriver.cpp index 2b2d5f1..3c7123d 100644 --- a/sinqEPICSApp/src/PhytronDriver.cpp +++ b/sinqEPICSApp/src/PhytronDriver.cpp @@ -139,12 +139,14 @@ PhytronAxis* PhytronController::getAxis(int axisNo) * \param[out] reply The controllers reply */ -asynStatus PhytronController::transactController(char command[COMLEN], char reply[COMLEN]) +asynStatus PhytronController::transactController(int axisNo,char command[COMLEN], char reply[COMLEN]) { asynStatus status; size_t in, out; int reason; char myReply[COMLEN+10], myCommand[COMLEN+10], *pPtr; + SINQAxis *axis = getAxis(axisNo); + pasynOctetSyncIO->flush(pasynUserController_); @@ -160,6 +162,9 @@ asynStatus PhytronController::transactController(char command[COMLEN], char repl status = pasynOctetSyncIO->writeRead(pasynUserController_, myCommand, strlen(myCommand), myReply,sizeof(myReply), 1.,&out,&in,&reason); if(status != asynSuccess){ + if(axis!= NULL){ + axis->updateMsgTxtFromDriver("Lost connection to motor controller"); + } return status; } @@ -241,7 +246,7 @@ asynStatus PhytronAxis::move(double position, int relative, double minVelocity, } homing = 0; sprintf(command, "%s%cA%f", pC_->selector,phytronChar,position/1000.); - status = pC_->transactController(command,reply); + status = pC_->transactController(axisNo_,command,reply); if(strstr(reply,"NACK") != NULL){ errlogSevPrintf(errlogMajor, "Drive command not acknowledged on %d", axisNo_); updateMsgTxtFromDriver("Drive command not acknowledged"); @@ -263,7 +268,7 @@ asynStatus PhytronAxis::home(double minVelocity, double maxVelocity, double acce sprintf(command, "%s%cO-",pC_->selector,phytronChar); homing = 1; next_poll= -1; - status = pC_->transactController(command,reply); + status = pC_->transactController(axisNo_,command,reply); if(strstr(reply,"NACK") != NULL){ errlogSevPrintf(errlogMajor, "Home command not acknowledged on %d", axisNo_); setIntegerParam(pC_->motorStatusProblem_, true); @@ -306,7 +311,7 @@ asynStatus PhytronAxis::stop(double acceleration ) char command[COMLEN], reply[COMLEN]; sprintf(command, "%s%cSN", pC_->selector,phytronChar); - status = pC_->transactController(command,reply); + status = pC_->transactController(axisNo_,command,reply); errlogPrintf("Sent STOP on Axis %d\n", axisNo_); updateMsgTxtFromDriver("Axis interrupted"); @@ -320,9 +325,9 @@ asynStatus PhytronAxis::setPosition(double position) char command[COMLEN], reply[COMLEN]; sprintf(command, "%s%cP22S%f", pC_->selector,phytronChar, position/1000.); - status = pC_->transactController(command,reply); + status = pC_->transactController(axisNo_,command,reply); sprintf(command, "%s%cP20S%f", pC_->selector,phytronChar, position/1000.); - status = pC_->transactController(command,reply); + status = pC_->transactController(axisNo_,command,reply); next_poll = -1; return status; @@ -366,7 +371,7 @@ asynStatus PhytronAxis::poll(bool *moving) sprintf(command,"%s%cP20R",pC_->selector,phytronChar); } - comStatus = pC_->transactController(command,reply); + comStatus = pC_->transactController(axisNo_,command,reply); if(comStatus) goto skip; if(strstr(reply,"NACK") != NULL){ @@ -386,7 +391,7 @@ asynStatus PhytronAxis::poll(bool *moving) // Read the moving status of this motor sprintf(command,"%s%c=H",pC_->selector,phytronChar); - comStatus = pC_->transactController(command,reply); + comStatus = pC_->transactController(axisNo_,command,reply); if(comStatus) goto skip; /* errlogPrintf("Axis %d, status reply %s, position %lf\n", axisNo_, reply, position); */ if(strstr(reply,"ACKN") != NULL){ @@ -410,7 +415,7 @@ asynStatus PhytronAxis::poll(bool *moving) check limits and errors, upper */ sprintf(command,"%s%c=I+",pC_->selector,phytronChar); - comStatus = pC_->transactController(command,reply); + comStatus = pC_->transactController(axisNo_,command,reply); if(comStatus) goto skip; if(strstr(reply,"ACKE") != NULL){ setIntegerParam(pC_->motorStatusHighLimit_, true); @@ -423,7 +428,7 @@ asynStatus PhytronAxis::poll(bool *moving) lower limit */ sprintf(command,"%s%c=I-",pC_->selector,phytronChar); - comStatus = pC_->transactController(command,reply); + comStatus = pC_->transactController(axisNo_,command,reply); if(comStatus) goto skip; if(strstr(reply,"ACKE") != NULL){ setIntegerParam(pC_->motorStatusLowLimit_, true); @@ -436,7 +441,7 @@ asynStatus PhytronAxis::poll(bool *moving) error */ sprintf(command,"%s%c=E",pC_->selector,phytronChar); - comStatus = pC_->transactController(command,reply); + comStatus = pC_->transactController(axisNo_,command,reply); if(comStatus) goto skip; if(strstr(reply,"ACKE") != NULL){ setIntegerParam(pC_->motorStatusProblem_, true); diff --git a/sinqEPICSApp/src/PhytronDriver.h b/sinqEPICSApp/src/PhytronDriver.h index 7934694..9b0e07b 100644 --- a/sinqEPICSApp/src/PhytronDriver.h +++ b/sinqEPICSApp/src/PhytronDriver.h @@ -56,7 +56,7 @@ friend class PhytronAxis; private: asynUser *pasynUserController_; - asynStatus transactController(char command[COMLEN], char reply[COMLEN]); + asynStatus transactController(int axisNo, char command[COMLEN], char reply[COMLEN]); const char *selector;