controlboardinterfacesimpl.inl
来自「一个语言识别引擎」· INL 代码 · 共 1,307 行 · 第 1/3 页
INL
1,307 行
return ret;
}
template <class DERIVED, class IMPLEMENT>
bool ImplementPositionControl<DERIVED, IMPLEMENT>::stop(int j)
{
int k;
k=castToMapper(helper)->toHw(j);
return iPosition->stopRaw(k);
}
template <class DERIVED, class IMPLEMENT>
bool ImplementPositionControl<DERIVED, IMPLEMENT>::stop()
{
return iPosition->stopRaw();
}
template <class DERIVED, class IMPLEMENT>
bool ImplementPositionControl<DERIVED, IMPLEMENT>::getAxes(int *axis)
{
(*axis)=castToMapper(helper)->axes();
return true;
}
template <class DERIVED, class IMPLEMENT>
bool ImplementPositionControl<DERIVED, IMPLEMENT>:: initialize (int size, const int *amap, const double *enc, const double *zos)
{
if (helper!=0)
return false;
helper=(void *)(new ControlBoardHelper(size, amap, enc, zos));
ACE_ASSERT (helper != 0);
temp=new double [size];
ACE_ASSERT (temp != 0);
return true;
}
/**
* Clean up internal data and memory.
* @return true if uninitialization is executed, false otherwise.
*/
template <class DERIVED, class IMPLEMENT>
bool ImplementPositionControl<DERIVED, IMPLEMENT>::uninitialize ()
{
if (helper!=0)
{
delete castToMapper(helper);
helper=0;
}
checkAndDestroy(temp);
return true;
}
/////////////////// Implement PostionControl
//////////////////// Implement VelocityControl
template <class DERIVED, class IMPLEMENT> ImplementVelocityControl<DERIVED, IMPLEMENT>::
ImplementVelocityControl(DERIVED *y)
{
iVelocity = dynamic_cast<IVelocityControlRaw *> (y);
helper = 0;
temp=0;
}
template <class DERIVED, class IMPLEMENT> ImplementVelocityControl<DERIVED, IMPLEMENT>::
~ImplementVelocityControl()
{
uninitialize();
}
template <class DERIVED, class IMPLEMENT>
bool ImplementVelocityControl<DERIVED, IMPLEMENT>:: initialize (int size, const int *amap, const double *enc, const double *zos)
{
if (helper!=0)
return false;
helper=(void *)(new ControlBoardHelper(size, amap, enc, zos));
ACE_ASSERT (helper != 0);
temp=new double [size];
ACE_ASSERT (temp != 0);
return true;
}
/**
* Clean up internal data and memory.
* @return true if uninitialization is executed, false otherwise.
*/
template <class DERIVED, class IMPLEMENT>
bool ImplementVelocityControl<DERIVED, IMPLEMENT>::uninitialize ()
{
if (helper!=0)
{
delete castToMapper(helper);
helper=0;
}
checkAndDestroy(temp);
return true;
}
template <class DERIVED, class IMPLEMENT>
bool ImplementVelocityControl<DERIVED, IMPLEMENT>::getAxes(int *axes)
{
(*axes)=castToMapper(helper)->axes();
return true;
}
template <class DERIVED, class IMPLEMENT>
bool ImplementVelocityControl<DERIVED, IMPLEMENT>::setVelocityMode()
{
return iVelocity->setVelocityMode();
}
template <class DERIVED, class IMPLEMENT>
bool ImplementVelocityControl<DERIVED, IMPLEMENT>::velocityMove(int j, double sp)
{
int k;
double enc;
castToMapper(helper)->velA2E(sp, j, enc, k);
return iVelocity->velocityMoveRaw(k, enc);
}
template <class DERIVED, class IMPLEMENT>
bool ImplementVelocityControl<DERIVED, IMPLEMENT>::velocityMove(const double *sp)
{
castToMapper(helper)->velA2E(sp, temp);
return iVelocity->velocityMoveRaw(temp);
}
template <class DERIVED, class IMPLEMENT>
bool ImplementVelocityControl<DERIVED, IMPLEMENT>::setRefAcceleration(int j, double acc)
{
int k;
double enc;
castToMapper(helper)->accA2E(acc, j, enc, k);
return iVelocity->setRefAccelerationRaw(k, enc);
}
template <class DERIVED, class IMPLEMENT>
bool ImplementVelocityControl<DERIVED, IMPLEMENT>::setRefAccelerations(const double *accs)
{
castToMapper(helper)->accA2E(accs, temp);
return iVelocity->setRefAccelerationsRaw(temp);
}
template <class DERIVED, class IMPLEMENT>
bool ImplementVelocityControl<DERIVED, IMPLEMENT>::getRefAccelerations(double *accs)
{
bool ret=iVelocity->getRefAccelerationsRaw(temp);
castToMapper(helper)->accE2A(temp, accs);
return true;
}
template <class DERIVED, class IMPLEMENT>
bool ImplementVelocityControl<DERIVED, IMPLEMENT>::getRefAcceleration(int j, double *acc)
{
int k;
double enc;
k=castToMapper(helper)->toHw(j);
bool ret = iVelocity->getRefAccelerationRaw(k, &enc);
*acc=castToMapper(helper)->accE2A(enc, k);
return ret;
}
template <class DERIVED, class IMPLEMENT>
bool ImplementVelocityControl<DERIVED, IMPLEMENT>::stop(int j)
{
int k;
k=castToMapper(helper)->toHw(j);
return iVelocity->stopRaw(k);
}
template <class DERIVED, class IMPLEMENT>
bool ImplementVelocityControl<DERIVED, IMPLEMENT>::stop()
{
return iVelocity->stopRaw();
}
/////////////////////////////////////////////////////////////////
//////////////////// Implement PidControl interface
template <class DERIVED, class IMPLEMENT> ImplementPidControl<DERIVED, IMPLEMENT>::
ImplementPidControl(DERIVED *y)
{
iPid= dynamic_cast<IPidControlRaw *> (y);
helper = 0;
temp=0;
tmpPids=0;
}
template <class DERIVED, class IMPLEMENT> ImplementPidControl<DERIVED, IMPLEMENT>::
~ImplementPidControl()
{
uninitialize();
}
template <class DERIVED, class IMPLEMENT>
bool ImplementPidControl<DERIVED, IMPLEMENT>:: initialize (int size, const int *amap, const double *enc, const double *zos)
{
if (helper!=0)
return false;
helper=(void *)(new ControlBoardHelper(size, amap, enc, zos));
ACE_ASSERT (helper != 0);
temp=new double [size];
ACE_ASSERT (temp != 0);
tmpPids=new Pid[size];
ACE_ASSERT (tmpPids != 0);
return true;
}
/**
* Clean up internal data and memory.
* @return true if uninitialization is executed, false otherwise.
*/
template <class DERIVED, class IMPLEMENT>
bool ImplementPidControl<DERIVED, IMPLEMENT>::uninitialize ()
{
if (helper!=0)
delete castToMapper(helper);
helper=0;
checkAndDestroy(tmpPids);
checkAndDestroy(temp);
return true;
}
template<class DERIVED, class IMPLEMENT>
bool ImplementPidControl<DERIVED, IMPLEMENT>::setPid(int j, const Pid &pid)
{
int k=castToMapper(helper)->toHw(j);
return iPid->setPidRaw(k,pid);
}
template<class DERIVED, class IMPLEMENT>
bool ImplementPidControl<DERIVED, IMPLEMENT>::setPids(const Pid *pids)
{
int tmp=0;
int nj=castToMapper(helper)->axes();
for(int j=0;j<nj;j++)
{
tmp=castToMapper(helper)->toHw(j);
tmpPids[tmp]=pids[j];
}
return iPid->setPidsRaw(tmpPids);
}
template<class DERIVED, class IMPLEMENT>
bool ImplementPidControl<DERIVED, IMPLEMENT>::setReference(int j, double ref)
{
int k=0;
double enc;
castToMapper(helper)->posA2E(ref, j, enc, k);
return iPid->setReferenceRaw(k, enc);
}
template<class DERIVED, class IMPLEMENT>
bool ImplementPidControl<DERIVED, IMPLEMENT>::setReferences(const double *refs)
{
castToMapper(helper)->posA2E(refs, temp);
return iPid->setReferencesRaw(temp);
}
template<class DERIVED, class IMPLEMENT>
bool ImplementPidControl<DERIVED, IMPLEMENT>::setErrorLimit(int j, double limit)
{
int k;
double enc;
castToMapper(helper)->posA2E(limit, j, enc, k);
return iPid->setErrorLimitRaw(k, enc);
}
template<class DERIVED, class IMPLEMENT>
bool ImplementPidControl<DERIVED, IMPLEMENT>::setErrorLimits(const double *limits)
{
castToMapper(helper)->posA2E(limits, temp);
return iPid->setErrorLimitsRaw(temp);
}
template<class DERIVED, class IMPLEMENT>
bool ImplementPidControl<DERIVED, IMPLEMENT>::getError(int j, double *err)
{
int k;
double enc;
k=castToMapper(helper)->toHw(j);
bool ret=iPid->getErrorRaw(k, &enc);
*err=castToMapper(helper)->velE2A(enc, k);
return ret;
}
template<class DERIVED, class IMPLEMENT>
bool ImplementPidControl<DERIVED, IMPLEMENT>::getErrors(double *errs)
{
bool ret;
ret=iPid->getErrorsRaw(temp);
castToMapper(helper)->velE2A(temp, errs);
return ret;
}
template<class DERIVED, class IMPLEMENT>
bool ImplementPidControl<DERIVED, IMPLEMENT>::getOutput(int j, double *out)
{
int k;
k=castToMapper(helper)->toHw(j);
bool ret=iPid->getOutputRaw(k, out);
return ret;
}
template<class DERIVED, class IMPLEMENT>
bool ImplementPidControl<DERIVED, IMPLEMENT>::getOutputs(double *outs)
{
bool ret=iPid->getOutputsRaw(temp);
castToMapper(helper)->toUser(temp, outs);
return ret;
}
template<class DERIVED, class IMPLEMENT>
bool ImplementPidControl<DERIVED, IMPLEMENT>::getPid(int j, Pid *pid)
{
int k;
k=castToMapper(helper)->toHw(j);
return iPid->getPidRaw(k, pid);
}
template<class DERIVED, class IMPLEMENT>
bool ImplementPidControl<DERIVED, IMPLEMENT>::getPids(Pid *pids)
{
bool ret=iPid->getPidsRaw(tmpPids);
int nj=castToMapper(helper)->axes();
for(int j=0;j<nj;j++)
pids[castToMapper(helper)->toUser(j)]=tmpPids[j];
return ret;
}
template<class DERIVED, class IMPLEMENT>
bool ImplementPidControl<DERIVED, IMPLEMENT>::getReference(int j, double *ref)
{
bool ret;
int k;
double enc;
k=castToMapper(helper)->toHw(j);
ret=iPid->getReferenceRaw(k, &enc);
*ref=castToMapper(helper)->posE2A(enc, k);
return ret;
}
template<class DERIVED, class IMPLEMENT>
bool ImplementPidControl<DERIVED, IMPLEMENT>::getReferences(double *refs)
{
bool ret;
ret=iPid->getReferencesRaw(temp);
castToMapper(helper)->posE2A(temp, refs);
return ret;
}
template<class DERIVED, class IMPLEMENT>
bool ImplementPidControl<DERIVED, IMPLEMENT>::getErrorLimit(int j, double *ref)
{
bool ret;
int k;
double enc;
k=castToMapper(helper)->toHw(j);
ret=iPid->getErrorLimitRaw(k, &enc);
*ref=castToMapper(helper)->posE2A(enc, k);
return ret;
}
template<class DERIVED, class IMPLEMENT>
bool ImplementPidControl<DERIVED, IMPLEMENT>::getErrorLimits(double *refs)
{
bool ret;
ret=iPid->getErrorLimitsRaw(temp);
castToMapper(helper)->posE2A(temp, refs);
return ret;
}
template<class DERIVED, class IMPLEMENT>
bool ImplementPidControl<DERIVED, IMPLEMENT>::resetPid(int j)
{
int k=0;
k=castToMapper(helper)->toHw(j);
return iPid->resetPidRaw(k);
}
template<class DERIVED, class IMPLEMENT>
bool ImplementPidControl<DERIVED, IMPLEMENT>::enablePid(int j)
{
int k=0;
k=castToMapper(helper)->toHw(j);
return iPid->enablePidRaw(k);
}
template<class DERIVED, class IMPLEMENT>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?