From 7ee34a791bb8486340a283e61c3aa1f5d656be13 Mon Sep 17 00:00:00 2001 From: Vintar Rok Date: Mon, 22 Aug 2016 09:59:03 +0200 Subject: [PATCH] Velocity, baseVelocity and acceleration read only when needed. Fix for #37 --- motorApp/MotorSrc/asynMotorController.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/motorApp/MotorSrc/asynMotorController.cpp b/motorApp/MotorSrc/asynMotorController.cpp index 13d16ebe..612b993e 100644 --- a/motorApp/MotorSrc/asynMotorController.cpp +++ b/motorApp/MotorSrc/asynMotorController.cpp @@ -277,15 +277,14 @@ asynStatus asynMotorController::writeFloat64(asynUser *pasynUser, epicsFloat64 v /* Set the parameter and readback in the parameter library. */ status = pAxis->setDoubleParam(function, value); - getDoubleParam(axis, motorVelBase_, &baseVelocity); - getDoubleParam(axis, motorVelocity_, &velocity); - getDoubleParam(axis, motorAccel_, &acceleration); - if (function == motorMoveRel_) { if (autoPower == 1) { status = pAxis->setClosedLoop(true); epicsThreadSleep(autoPowerOnDelay); } + getDoubleParam(axis, motorVelBase_, &baseVelocity); + getDoubleParam(axis, motorVelocity_, &velocity); + getDoubleParam(axis, motorAccel_, &acceleration); status = pAxis->move(value, 1, baseVelocity, velocity, acceleration); pAxis->setIntegerParam(motorStatusDone_, 0); pAxis->callParamCallbacks(); @@ -299,6 +298,9 @@ asynStatus asynMotorController::writeFloat64(asynUser *pasynUser, epicsFloat64 v status = pAxis->setClosedLoop(true); epicsThreadSleep(autoPowerOnDelay); } + getDoubleParam(axis, motorVelBase_, &baseVelocity); + getDoubleParam(axis, motorVelocity_, &velocity); + getDoubleParam(axis, motorAccel_, &acceleration); status = pAxis->move(value, 0, baseVelocity, velocity, acceleration); pAxis->setIntegerParam(motorStatusDone_, 0); pAxis->callParamCallbacks(); @@ -312,6 +314,8 @@ asynStatus asynMotorController::writeFloat64(asynUser *pasynUser, epicsFloat64 v status = pAxis->setClosedLoop(true); epicsThreadSleep(autoPowerOnDelay); } + getDoubleParam(axis, motorVelBase_, &baseVelocity); + getDoubleParam(axis, motorAccel_, &acceleration); status = pAxis->moveVelocity(baseVelocity, value, acceleration); pAxis->setIntegerParam(motorStatusDone_, 0); pAxis->callParamCallbacks(); @@ -326,6 +330,9 @@ asynStatus asynMotorController::writeFloat64(asynUser *pasynUser, epicsFloat64 v status = pAxis->setClosedLoop(true); epicsThreadSleep(autoPowerOnDelay); } + getDoubleParam(axis, motorVelBase_, &baseVelocity); + getDoubleParam(axis, motorVelocity_, &velocity); + getDoubleParam(axis, motorAccel_, &acceleration); forwards = (value == 0) ? 0 : 1; status = pAxis->home(baseVelocity, velocity, acceleration, forwards); pAxis->setIntegerParam(motorStatusDone_, 0);