Allow enable/disable (tentative)
This commit is contained in:
@@ -133,7 +133,10 @@ extern "C" {
|
||||
int numAxes, int movingPollPeriod, int idlePollPeriod);
|
||||
asynStatus SeleneCreateController(const char *portName, const char *lowLevelPortName, int lowLevelPortAddress,
|
||||
int numAxes, int movingPollPeriod, int idlePollPeriod);
|
||||
|
||||
asynStatus pmacV3CreateController(const char *portName,
|
||||
const char *lowLevelPortName,
|
||||
int lowLevelPortAddress, int numAxes,
|
||||
int movingPollPeriod, int idlePollPeriod);
|
||||
asynStatus pmacCreateAxis(const char *pmacName, int axis);
|
||||
asynStatus pmacCreateAxis(const char *pmacName, int numAxis);
|
||||
|
||||
@@ -546,6 +549,19 @@ asynStatus SeleneCreateController(const char *portName, const char *lowLevelPort
|
||||
return asynSuccess;
|
||||
}
|
||||
|
||||
asynStatus pmacV3CreateController(const char *portName,
|
||||
const char *lowLevelPortName,
|
||||
int lowLevelPortAddress, int numAxes,
|
||||
int movingPollPeriod, int idlePollPeriod) {
|
||||
|
||||
pmacV3Controller *ppmacController = new pmacV3Controller(
|
||||
portName, lowLevelPortName, lowLevelPortAddress, numAxes,
|
||||
movingPollPeriod / 1000., idlePollPeriod / 1000.);
|
||||
ppmacController = NULL;
|
||||
|
||||
return asynSuccess;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------------------------------------------------*/
|
||||
SeleneController::SeleneController(const char *portName, const char *lowLevelPortName, int lowLevelPortAddress,
|
||||
int numAxes, double movingPollPeriod, double idlePollPeriod) : pmacController(portName,
|
||||
@@ -559,33 +575,46 @@ SeleneController::SeleneController(const char *portName, const char *lowLevelPor
|
||||
callParamCallbacks();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* C wrapper for the pmacAxis constructor.
|
||||
* See pmacAxis::pmacAxis.
|
||||
*
|
||||
*/
|
||||
asynStatus pmacCreateAxis(const char *pmacName, /* specify which controller by port name */
|
||||
int axis) /* axis number (start from 1). */
|
||||
{
|
||||
pmacController *pC;
|
||||
pmacAxis *pAxis;
|
||||
|
||||
static const char *functionName = "pmacCreateAxis";
|
||||
|
||||
pC = (pmacController*) findAsynPortDriver(pmacName);
|
||||
if (!pC) {
|
||||
printf("%s:%s: Error port %s not found\n",
|
||||
driverName, functionName, pmacName);
|
||||
return asynError;
|
||||
pmacV3Controller::pmacV3Controller(const char *portName,
|
||||
const char *lowLevelPortName,
|
||||
int lowLevelPortAddress, int numAxes,
|
||||
double movingPollPeriod,
|
||||
double idlePollPeriod,
|
||||
const int &extraParams){
|
||||
pmacController(portName, lowLevelPortName, lowLevelPortAddress, numAxes,
|
||||
movingPollPeriod, idlePollPeriod, extraParams);
|
||||
static const char *functionName = "pmacV3Controller::pmacV3Controller";
|
||||
createParam(EnableAxisString, asynParamInt32, &enableAxis_);
|
||||
callParamCallbacks();
|
||||
}
|
||||
|
||||
/**
|
||||
* C wrapper for the pmacAxis constructor.
|
||||
* See pmacAxis::pmacAxis.
|
||||
*
|
||||
*/
|
||||
asynStatus pmacCreateAxis(
|
||||
const char *pmacName, /* specify which controller by port name */
|
||||
int axis) /* axis number (start from 1). */
|
||||
{
|
||||
pmacController *pC;
|
||||
pmacAxis *pAxis;
|
||||
|
||||
static const char *functionName = "pmacCreateAxis";
|
||||
|
||||
pC = (pmacController *)findAsynPortDriver(pmacName);
|
||||
if (!pC) {
|
||||
printf("%s:%s: Error port %s not found\n", driverName, functionName,
|
||||
pmacName);
|
||||
return asynError;
|
||||
}
|
||||
|
||||
pC->lock();
|
||||
pAxis = new pmacAxis(pC, axis);
|
||||
pAxis = NULL;
|
||||
pC->unlock();
|
||||
return asynSuccess;
|
||||
}
|
||||
|
||||
pC->lock();
|
||||
pAxis = new pmacAxis(pC, axis);
|
||||
pAxis = NULL;
|
||||
pC->unlock();
|
||||
return asynSuccess;
|
||||
}
|
||||
/**
|
||||
* C wrapper for the pmacHRPTAxis constructor.
|
||||
* See pmacHRPTAxis::pmacHRPTAxis.
|
||||
@@ -752,6 +781,8 @@ asynStatus SeleneController::writeFloat64(asynUser *pasynUser, epicsFloat64 valu
|
||||
status = lowLevelWriteRead(pAxis->axisNo_,command, response);
|
||||
}
|
||||
|
||||
// What if now status != asynSuccess
|
||||
|
||||
//Call base class method
|
||||
//This will handle callCallbacks even if the function was handled here.
|
||||
status = asynMotorController::writeFloat64(pasynUser, value);
|
||||
@@ -760,6 +791,42 @@ asynStatus SeleneController::writeFloat64(asynUser *pasynUser, epicsFloat64 valu
|
||||
|
||||
}
|
||||
|
||||
asynStatus pmacV3Controller::writeInt32(asynUser *pasynUser, epicsInt32 value) {
|
||||
int function = pasynUser->reason;
|
||||
asynStatus status = asynError;
|
||||
pmacAxis *pAxis = NULL;
|
||||
static const char *functionName = "pmacV3Controller::writeInt32";
|
||||
|
||||
debugFlow(functionName);
|
||||
|
||||
pAxis = this->getAxis(pasynUser);
|
||||
if (!pAxis) {
|
||||
return asynError;
|
||||
}
|
||||
|
||||
/* Set the parameter and readback in the parameter library. This may be
|
||||
* overwritten when we read back the status at the end, but that's OK */
|
||||
status = pAxis->setIntegerParam(function, value);
|
||||
|
||||
if (function == enableAxis_) {
|
||||
sprintf(command, "M%2.2d14=%d\n", pAxis->axisNo_, value);
|
||||
asynPrint(this->pasynUserSelf, ASYN_TRACE_FLOW,
|
||||
"%s: Enable axis on controller %s, axis %d enable=%d\n",
|
||||
functionName, portName, pAxis->axisNo_, value);
|
||||
errlogPrintf("Enable axis %d: %d, command = %s\n", pAxis->axisNo_, value, command);
|
||||
}
|
||||
|
||||
// Execute the command.
|
||||
if (command[0] != 0 && status == asynSuccess) {
|
||||
status = lowLevelWriteRead(pAxis->axisNo_, command, response);
|
||||
}
|
||||
|
||||
// Call base class method
|
||||
// This will handle callCallbacks even if the function was handled here.
|
||||
status = asynMotorController::writeInt32(pasynUser, value);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/* Code for iocsh registration */
|
||||
|
||||
@@ -790,7 +857,13 @@ static void configSeleneCreateControllerCallFunc(const iocshArgBuf *args)
|
||||
{
|
||||
SeleneCreateController(args[0].sval, args[1].sval, args[2].ival, args[3].ival, args[4].ival, args[5].ival);
|
||||
}
|
||||
|
||||
static const iocshFuncDef configpmacV3CreateController = {
|
||||
"pmacV3CreateController", 6, pmacCreateControllerArgs
|
||||
};
|
||||
static void configpmacV3CreateControllerCallFunc(const iocshArgBuf *args) {
|
||||
pmacV3CreateController(args[0].sval, args[1].sval, args[2].ival, args[3].ival,
|
||||
args[4].ival, args[5].ival);
|
||||
}
|
||||
|
||||
/* pmacCreateAxis */
|
||||
static const iocshArg pmacCreateAxisArg0 = {"Controller port name", iocshArgString};
|
||||
|
||||
Reference in New Issue
Block a user