From c5316018b90d5eb32a8b080e9cf46d2508af3287 Mon Sep 17 00:00:00 2001 From: kpetersn Date: Wed, 18 Apr 2018 14:41:19 -0500 Subject: [PATCH] Only require user to specify numAxes so any combination of controller modules can be used. --- iocBoot/iocWithAsyn/motor.cmd.ANF2 | 9 +++---- motorApp/AMCISrc/ANF2Driver.cpp | 41 ++++++++++-------------------- motorApp/AMCISrc/ANF2Driver.h | 9 +++---- 3 files changed, 21 insertions(+), 38 deletions(-) diff --git a/iocBoot/iocWithAsyn/motor.cmd.ANF2 b/iocBoot/iocWithAsyn/motor.cmd.ANF2 index de8248a7..f501ae27 100644 --- a/iocBoot/iocWithAsyn/motor.cmd.ANF2 +++ b/iocBoot/iocWithAsyn/motor.cmd.ANF2 @@ -50,8 +50,7 @@ dbLoadTemplate("templates/motor.substitutions.ANF2") # portName, The name of the asyn port that will be created by this driver # ANF2InPortName, The name of the In drvAsynIPPPort to read from the ANF2 controller # ANF2OutPortName, The name of the Out drvAsynIPPPort to write to the ANF2 controller -# numModules, The number of modules in the stack (Max=6) -# axesPerModule) The number of axes per module (ANF1=1, ANF2=2) +# numAxes) The number of axes in the stack (max=12) # # ANF2CreateAxis( # ANF2Name, The controller's asyn port @@ -64,10 +63,10 @@ dbLoadTemplate("templates/motor.substitutions.ANF2") # does correct the acceleration sent by the motor record to give the desired acceleration time. # Controller 1 (One ANF2E, Five ANF2's) -ANF2CreateController("$(PORT1)", "$(PORT1)_In", "$(PORT1)_Out", 6, 2) +ANF2CreateController("$(PORT1)", "$(PORT1)_In", "$(PORT1)_Out", 12) # Axes for Controller 1 ANF2CreateAxis("$(PORT1)", 0, "0x86280000", 100, 0) -ANF2CreateAxis("$(PORT1)", 1, "0x86000000", 57, 32) +ANF2CreateAxis("$(PORT1)", 1, "0x86000000", 100, 0) ANF2CreateAxis("$(PORT1)", 2, "0x84000000", 100, 0) ANF2CreateAxis("$(PORT1)", 3, "0x84000000", 100, 0) ANF2CreateAxis("$(PORT1)", 4, "0x84000000", 100, 0) @@ -80,7 +79,7 @@ ANF2CreateAxis("$(PORT1)", 10, "0x84000000", 100, 0) ANF2CreateAxis("$(PORT1)", 11, "0x84000000", 100, 0) # Controller 2 (One ANF1E, Five ANF1's) -ANF2CreateController("$(PORT2)", "$(PORT2)_In", "$(PORT2)_Out", 6, 1) +ANF2CreateController("$(PORT2)", "$(PORT2)_In", "$(PORT2)_Out", 6) # Axes for Controller 2 ANF2CreateAxis("$(PORT2)", 0, "0x84000000", 100, 0) ANF2CreateAxis("$(PORT2)", 1, "0x84000000", 100, 0) diff --git a/motorApp/AMCISrc/ANF2Driver.cpp b/motorApp/AMCISrc/ANF2Driver.cpp index d474ff85..83d258cd 100644 --- a/motorApp/AMCISrc/ANF2Driver.cpp +++ b/motorApp/AMCISrc/ANF2Driver.cpp @@ -32,12 +32,11 @@ static const char *driverName = "ANF2MotorDriver"; * \param[in] portName The name of the asyn port that will be created for this driver * \param[in] ANF2InPortName The name of the drvAsynSerialPort that was created previously to connect to the ANF2 controller * \param[in] ANF2OutPortName The name of the drvAsynSerialPort that was created previously to connect to the ANF2 controller - * \param[in] numModules The number of modules on the controller stack - * \param[in] axesPerModule The number of axes per module (ANF1=1, ANF2=2) + * \param[in] numAxes The number of axes on the controller stack */ ANF2Controller::ANF2Controller(const char *portName, const char *ANF2InPortName, const char *ANF2OutPortName, - int numModules, int axesPerModule) - : asynMotorController(portName, (numModules*axesPerModule), NUM_ANF2_PARAMS, + int numAxes) + : asynMotorController(portName, numAxes, NUM_ANF2_PARAMS, asynInt32ArrayMask, // One additional interface beyond those in base class asynInt32ArrayMask, // One additional callback interface beyond those in base class ASYN_CANBLOCK | ASYN_MULTIDEVICE, @@ -58,9 +57,7 @@ ANF2Controller::ANF2Controller(const char *portName, const char *ANF2InPortName, createParam(ANF2GetInfoString, asynParamInt32, &ANF2GetInfo_); //createParam(ANF2ReconfigString, asynParamInt32, &ANF2Reconfig_); - numModules_ = numModules; - axesPerModule_ = axesPerModule; - numAxes_ = numModules * axesPerModule; + numAxes_ = numAxes; for (j=0; j MAX_MODULES) { - numModules = MAX_MODULES; - } - if (axesPerModule > MAX_AXES_PER_MODULE) { - axesPerModule = MAX_AXES_PER_MODULE; + if (numAxes > MAX_AXES) { + numAxes = MAX_AXES; } - /* - ANF2Controller *pANF2Controller - = new ANF2Controller(portName, ANF2InPortName, ANF2OutPortName, numModules, axesPerModule); - pANF2Controller = NULL; - */ - new ANF2Controller(portName, ANF2InPortName, ANF2OutPortName, numModules, axesPerModule); + new ANF2Controller(portName, ANF2InPortName, ANF2OutPortName, numAxes); return(asynSuccess); } @@ -1047,17 +1034,15 @@ asynStatus ANF2Axis::poll(bool *moving) static const iocshArg ANF2CreateControllerArg0 = {"Port name", iocshArgString}; static const iocshArg ANF2CreateControllerArg1 = {"ANF2 In port name", iocshArgString}; static const iocshArg ANF2CreateControllerArg2 = {"ANF2 Out port name", iocshArgString}; -static const iocshArg ANF2CreateControllerArg3 = {"Number of modules", iocshArgInt}; -static const iocshArg ANF2CreateControllerArg4 = {"Axes per module", iocshArgInt}; +static const iocshArg ANF2CreateControllerArg3 = {"Number of axes", iocshArgInt}; static const iocshArg * const ANF2CreateControllerArgs[] = {&ANF2CreateControllerArg0, &ANF2CreateControllerArg1, &ANF2CreateControllerArg2, - &ANF2CreateControllerArg3, - &ANF2CreateControllerArg4}; -static const iocshFuncDef ANF2CreateControllerDef = {"ANF2CreateController", 5, ANF2CreateControllerArgs}; + &ANF2CreateControllerArg3}; +static const iocshFuncDef ANF2CreateControllerDef = {"ANF2CreateController", 4, ANF2CreateControllerArgs}; static void ANF2CreateControllerCallFunc(const iocshArgBuf *args) { - ANF2CreateController(args[0].sval, args[1].sval, args[2].sval, args[3].ival, args[4].ival); + ANF2CreateController(args[0].sval, args[1].sval, args[2].sval, args[3].ival); } /* ANF2StartPoller */ diff --git a/motorApp/AMCISrc/ANF2Driver.h b/motorApp/AMCISrc/ANF2Driver.h index 6cc241bb..3949e664 100644 --- a/motorApp/AMCISrc/ANF2Driver.h +++ b/motorApp/AMCISrc/ANF2Driver.h @@ -15,8 +15,7 @@ K. Goetze 2014-03-24 //#include #include -#define MAX_MODULES 6 -#define MAX_AXES_PER_MODULE 2 +#define MAX_AXES 12 #define MAX_INPUT_REGS 10 #define MAX_OUTPUT_REGS 10 @@ -115,14 +114,14 @@ friend class ANF2Controller; class ANF2Controller : public asynMotorController { public: - ANF2Controller(const char *portName, const char *ANF2InPortName, const char *ANF2OutPortName, int numModules, int axesPerModule); + ANF2Controller(const char *portName, const char *ANF2InPortName, const char *ANF2OutPortName, int numAxes); void doStartPoller(double movingPollPeriod, double idlePollPeriod); void report(FILE *fp, int level); ANF2Axis* getAxis(asynUser *pasynUser); ANF2Axis* getAxis(int axisNo); - asynUser *pasynUserInReg_[MAX_MODULES*MAX_AXES_PER_MODULE][MAX_INPUT_REGS]; - asynUser *pasynUserOutReg_[MAX_MODULES*MAX_AXES_PER_MODULE]; + asynUser *pasynUserInReg_[MAX_AXES][MAX_INPUT_REGS]; + asynUser *pasynUserOutReg_[MAX_AXES]; /* These are the methods that we override from asynMotorDriver */ asynStatus writeInt32(asynUser *pasynUser, epicsInt32 value);