Can set and read enable, something broken with movements and status

This commit is contained in:
Michele Brambilla
2022-03-10 12:57:14 +01:00
committed by brambilla_m
parent 403eecafae
commit 92364a1de8
3 changed files with 21 additions and 14 deletions

View File

@ -927,8 +927,10 @@ asynStatus pmacV3Axis::getAxisStatus(bool *moving) {
updateMsgTxtFromDriver("Cannot read Axis position and status"); updateMsgTxtFromDriver("Cannot read Axis position and status");
} }
// printf("axStat: %d\n", axStat);
setIntegerParam(p3C_->axisState_, axStat); int st = setIntegerParam(p3C_->axisEnabled_, axStat >= 0);
// st = callParamCallbacks();
// printf("axStat: callParamCallbacks -> ok: %d\n", st == asynSuccess);
setDoubleParam(pC_->motorPosition_, position * MULT); setDoubleParam(pC_->motorPosition_, position * MULT);
setDoubleParam(pC_->motorEncoderPosition_, position * MULT); setDoubleParam(pC_->motorEncoderPosition_, position * MULT);
@ -969,6 +971,7 @@ asynStatus pmacV3Axis::getAxisStatus(bool *moving) {
errlogPrintf("Axis %d did not start within 10 seconds!! BROKEN\n", axisNo_); errlogPrintf("Axis %d did not start within 10 seconds!! BROKEN\n", axisNo_);
updateMsgTxtFromDriver("Axis did not start within 10 seconds"); updateMsgTxtFromDriver("Axis did not start within 10 seconds");
starting = 0; starting = 0;
callParamCallbacks();
return asynSuccess; return asynSuccess;
} }
@ -994,6 +997,7 @@ asynStatus pmacV3Axis::getAxisStatus(bool *moving) {
updateMsgTxtFromDriver( updateMsgTxtFromDriver(
"Axis stayed in 5,6 for more then 60 seconds: BROKEN"); "Axis stayed in 5,6 for more then 60 seconds: BROKEN");
status6Time = 0; status6Time = 0;
callParamCallbacks();
return asynSuccess; return asynSuccess;
} else { } else {
status6Time = time(NULL); status6Time = time(NULL);

View File

@ -32,7 +32,7 @@
using std::cout; using std::cout;
using std::endl; using std::endl;
#include <epicsTime.h> #include "epicsTime.h"
#include <epicsThread.h> #include <epicsThread.h>
#include <epicsExport.h> #include <epicsExport.h>
#include <epicsString.h> #include <epicsString.h>
@ -148,8 +148,6 @@ pmacController::pmacController(const char *portName, const char *lowLevelPortNam
{ {
static const char *functionName = "pmacController::pmacController"; static const char *functionName = "pmacController::pmacController";
printf(" Constructor: %s\n", functionName);
//Initialize non static data members //Initialize non static data members
lowLevelPortUser_ = NULL; lowLevelPortUser_ = NULL;
debugFlag_ = 0; debugFlag_ = 0;
@ -366,8 +364,11 @@ asynStatus pmacController::writeFloat64(asynUser *pasynUser, epicsFloat64 value)
/* Set the parameter and readback in the parameter library. */ /* Set the parameter and readback in the parameter library. */
status = pAxis->setDoubleParam(function, value); status = pAxis->setDoubleParam(function, value);
printf("%s: pAxis->setDoubleParam(%d, %lf)\n", functionName, function, value);
// if (function == motorPosition_) { if (function == motorPosition_) {
printf("%s: pAxis->setDoubleParam(%d, %lf)\n", functionName, function, value);
}
// /*Set position on motor axis.*/ // /*Set position on motor axis.*/
// epicsInt32 position = (epicsInt32) floor(value*32/pAxis->scale_ + 0.5); // epicsInt32 position = (epicsInt32) floor(value*32/pAxis->scale_ + 0.5);
@ -580,7 +581,7 @@ SeleneController::SeleneController(const char *portName, const char *lowLevelPor
pmacController(portName, lowLevelPortName, lowLevelPortAddress, numAxes, movingPollPeriod, idlePollPeriod, extraParams) { pmacController(portName, lowLevelPortName, lowLevelPortAddress, numAxes, movingPollPeriod, idlePollPeriod, extraParams) {
static const char *functionName = "pmacV3Controller::pmacV3Controller"; static const char *functionName = "pmacV3Controller::pmacV3Controller";
createParam(EnableAxisString, asynParamInt32, &enableAxis_); createParam(EnableAxisString, asynParamInt32, &enableAxis_);
createParam(AxisStateString, asynParamInt32, &axisState_); createParam(AxisEnabledString, asynParamInt32, &axisEnabled_);
callParamCallbacks(); callParamCallbacks();
} }
@ -815,6 +816,7 @@ asynStatus SeleneController::writeFloat64(asynUser *pasynUser, epicsFloat64 valu
} }
asynStatus pmacV3Controller::writeInt32(asynUser *pasynUser, epicsInt32 value) { asynStatus pmacV3Controller::writeInt32(asynUser *pasynUser, epicsInt32 value) {
int function = pasynUser->reason; int function = pasynUser->reason;
asynStatus status = asynError; asynStatus status = asynError;
@ -845,13 +847,14 @@ asynStatus pmacV3Controller::writeInt32(asynUser *pasynUser, epicsInt32 value) {
// Execute the command. // Execute the command.
if (command[0] != 0 && status == asynSuccess) { if (command[0] != 0 && status == asynSuccess) {
status = lowLevelWriteRead(pAxis->axisNo_, command, response); status = lowLevelWriteRead(pAxis->axisNo_, command, response);
printf("%s: lowLevelWriteRead: success=%d\n (function == enableAxis_? %d)\n",functionName, status==asynSuccess, function == enableAxis_);
} }
// Call base class method // Call base class method
// This will handle callCallbacks even if the function was handled here. // This will handle callCallbacks even if the function was handled here.
status = asynMotorController::writeInt32(pasynUser, value); // status = asynMotorController::writeInt32(pasynUser, value);
return status; return pmacController::writeInt32(pasynUser, value);
} }
asynStatus pmacV3Controller::readInt32(asynUser *pasynUser, epicsInt32 *value) { asynStatus pmacV3Controller::readInt32(asynUser *pasynUser, epicsInt32 *value) {
@ -869,14 +872,14 @@ asynStatus pmacV3Controller::readInt32(asynUser *pasynUser, epicsInt32 *value) {
if (!pAxis) { if (!pAxis) {
return asynError; return asynError;
} }
if (function == axisState_) { if (function == axisEnabled_) {
snprintf(command, sizeof(command), "P%2.2d00", pAxis->axisNo_); snprintf(command, sizeof(command), "P%2.2d00", pAxis->axisNo_);
status = this->lowLevelWriteRead(pAxis->axisNo_, command, response); status = this->lowLevelWriteRead(pAxis->axisNo_, command, response);
*value = strtol(response, NULL, 10); *value = strtol(response, NULL, 10);
setIntegerParam(axisState_, *value); int st = setIntegerParam(axisEnabled_, *value);
// printf("%s: setIntegerParam(%d, %d) -> success=%d\n", functionName,axisEnabled_, *value, st==asynSuccess);
callParamCallbacks(); callParamCallbacks();
return status;
} }
return pmacController::readInt32(pasynUser, value); return pmacController::readInt32(pasynUser, value);
} }

View File

@ -165,7 +165,7 @@ class SeleneController : public pmacController {
}; };
#define EnableAxisString "ENABLE_AXIS" #define EnableAxisString "ENABLE_AXIS"
#define AxisStateString "AXIS_STATE" #define AxisEnabledString "AXIS_ENABLED"
class pmacV3Controller : public pmacController { class pmacV3Controller : public pmacController {
public: public:
@ -186,7 +186,7 @@ protected:
pmacV3Axis **pAxes_; /**< Array of pointers to axis objects */ pmacV3Axis **pAxes_; /**< Array of pointers to axis objects */
int enableAxis_; int enableAxis_;
int axisState_; int axisEnabled_;
}; };
#endif /* pmacController_H */ #endif /* pmacController_H */