itom
Loading...
Searching...
No Matches
ito::ActuatorThreadCtrl Class Reference

Helper class to give plugin developers an easy access to actuators in other threads. More...

#include <pluginThreadCtrl.h>

Inheritance diagram for ito::ActuatorThreadCtrl:
ito::PluginThreadCtrl

Public Member Functions

 ActuatorThreadCtrl ()
 default constructor. No actuator instance is currently under control.
 
 ActuatorThreadCtrl (const ito::ParamBase &pluginParameter, ito::RetVal *retval=NULL)
 Creates the control object for an actuator plugin instance.
 
 ActuatorThreadCtrl (ito::AddInActuator *plugin, ito::RetVal *retval=NULL)
 Creates the control object for a actuator plugin instance.
 
 ActuatorThreadCtrl (const ActuatorThreadCtrl &other)
 copy constructor. The reference counter of the covered plugin by other will be incremented another time.
 
virtual ~ActuatorThreadCtrl ()
 destructor. Decrements the reference counter of the covered plugin and deletes it, if it drops to zero.
 
ito::RetVal setPosRel (const QVector< int > &axes, const QVector< double > &relPositions, int timeOutMS=PLUGINWAIT)
 
ito::RetVal setPosAbs (const QVector< int > &axes, const QVector< double > &absPositions, int timeOutMS=PLUGINWAIT)
 
ito::RetVal setPosRel (int axis, double relPosition, int timeOutMS=PLUGINWAIT)
 
ito::RetVal setPosAbs (int axis, double absPosition, int timeOutMS=PLUGINWAIT)
 
ito::RetVal getPos (QVector< int > axes, QVector< double > &positions, int timeOutMS=PLUGINWAIT)
 
ito::RetVal getPos (int axis, double &position, int timeOutMS=PLUGINWAIT)
 
ito::RetVal checkAxis (int axisNum)
 
- Public Member Functions inherited from ito::PluginThreadCtrl
 PluginThreadCtrl ()
 default constructor. No plugin instance is currently under control.
 
 PluginThreadCtrl (const ito::ParamBase &pluginParameter, ito::RetVal *retval=NULL)
 Creates the control object for a plugin instance.
 
 PluginThreadCtrl (ito::AddInBase *plugin, ito::RetVal *retval=NULL)
 Creates the control object for a plugin instance.
 
 PluginThreadCtrl (const PluginThreadCtrl &other)
 copy constructor. The reference counter of the covered plugin by other will be incremented another time.
 
virtual ~PluginThreadCtrl ()
 destructor. Decrements the reference counter of the covered plugin and deletes it, if it drops to zero.
 
PluginThreadCtrloperator= (const PluginThreadCtrl &other)
 assignment operator. Gets control over the plugin currently covered by other. Decrements the reference counter of the former plugin and increments it of the plugin controlled by other.
 
ito::RetVal getParam (ito::Param &val, int timeOutMS=PLUGINWAIT)
 
ito::RetVal setParam (ito::ParamBase val, int timeOutMS=PLUGINWAIT)
 
ito::RetVal waitForSemaphore (int timeOutMS=PLUGINWAIT)
 

Protected Attributes

int m_numAxes
 
- Protected Attributes inherited from ito::PluginThreadCtrl
ito::AddInBasem_pPlugin
 
ItomSharedSemaphoreLocker m_semaphoreLocker
 

Detailed Description

Helper class to give plugin developers an easy access to actuators in other threads.

The ActuatorThreadCtrl-Class can be used in filters and algorithms when an actuator plugin should be controlled by another thread. To create this controlling instance, at first, create an instance of the actuator plugin itself, then, pass it to the constructor of ActuatorThreadCtrl. In the following example, an instance of DummyMotor is passed as first mandatory argument to the init method of your plugin. You would like to create an easy thread control wrapper around this actuator plugin:

ito::RetVal retval;
ActuatorThreadCtrl motSave(paramsMand->at(0), &retval);
Helper class to give plugin developers an easy access to actuators in other threads.
Definition pluginThreadCtrl.h:240
Class for managing status values (like errors or warning)
Definition retVal.h:54

Using this class, all main methods of the actuator plugin can be directly called with an optional timeout value (in ms). The thread control, timeout checks... is then done by this helper class.

Use getPos to obtain the current position (in mm or degree) for one multiple axes. Inversely, setPosRel or setPosAbs will set the absolute or relative position(s) of one or multiple axes. Usually, setPosXXX will only return after the position has been reached. If you want to continue within your code while the actuator is still moving, check if your specific actuator has the 'async' parameter defined. If so, set it to 1 (see example below):

double position;
motSave.setParam(ito::ParamBase("async", ito::ParamBase::Int, 1))
motSave.getPos(0, position);
motSave.setPosAbs(0, 10.5); //long movement
//since the movement is asynchrone, setPosAbs
//will immediately return. However, every subsequent
//call to the motSave instance will block until the previous
//movement is finished. E.g. another call of getPos will wait
//for this and you can therefore check if the movement has been
//done:
motSave.getPos(0, position);
<
Definition param.h:95
@ Int
double (float64) parameter
Definition param.h:152

Constructor & Destructor Documentation

◆ ActuatorThreadCtrl() [1/2]

ito::ActuatorThreadCtrl::ActuatorThreadCtrl ( const ito::ParamBase & pluginParameter,
ito::RetVal * retval = NULL )

Creates the control object for an actuator plugin instance.

This implementation gets the controlled instance from a ito::ParamBase object of param type ito::ParamBase::HWRef. Use this version, if the controlled plugin is passed to an algorithm or other plugin via a vector of mandatory or optional parameters in terms of ito::ParamBase objects.

This constructor increments the reference of the controlled plugin such that the plugin is not deleted until the reference has been decremented in the destructor of this class.

Parameters
pluginParameteris a plugin parameter of type ito::ParamBase::HWRef.
retvalis an optional pointer to ito::RetVal. An error is set to this retval if the given plugin is no valid actuator plugin instance.

◆ ActuatorThreadCtrl() [2/2]

ito::ActuatorThreadCtrl::ActuatorThreadCtrl ( ito::AddInActuator * plugin,
ito::RetVal * retval = NULL )

Creates the control object for a actuator plugin instance.

This implementation gets the controlled instance from the real pointer to a ito::Actuator instance.

This constructor increments the reference of the controlled plugin such that the plugin is not deleted until the reference has been decremented in the destructor of this class.

Parameters
pluginis the pointer to the controlled plugin.
retvalis an optional pointer to ito::RetVal. An error is set to this retval if the given plugin is no valid actuator plugin instance.

Member Function Documentation

◆ checkAxis()

ito::RetVal ito::ActuatorThreadCtrl::checkAxis ( int axisNum)

Check if an axis is within the axis-range

\detail Check if a specific axis is within the axisSpace of this actuator

Parameters
[in]axisNumaxis index to be checked
Returns
retOk or retError

◆ getPos() [1/2]

ito::RetVal ito::ActuatorThreadCtrl::getPos ( int axis,
double & position,
int timeOutMS = PLUGINWAIT )

Get the position of a single axis

\detail Get the position of a single axis specified by axis.

Parameters
[in]axisNumber of the axis
[out]posposition of the axis
[in]timeOutMSTimeOut for the semaphore-wait
Returns
retOk or retError

◆ getPos() [2/2]

ito::RetVal ito::ActuatorThreadCtrl::getPos ( QVector< int > axes,
QVector< double > & positions,
int timeOutMS = PLUGINWAIT )

Get the position of more than one axis

\detail Get the position of a number of axis specified by axisVec.

Parameters
[in]axisVecNumber of the axis
[out]posVecVector with position of the axis
[in]timeOutMSTimeOut for the semaphore-wait
Returns
retOk or retError

◆ setPosAbs() [1/2]

ito::RetVal ito::ActuatorThreadCtrl::setPosAbs ( const QVector< int > & axes,
const QVector< double > & absPositions,
int timeOutMS = PLUGINWAIT )

Move more than on axis absolute

\detail Move the axis in axisVec to the positions given in posVec. The axisVec and posVec must be same size. After the invoke-command this thread must wait / synchronize with the actuator-thread. Therefore the semaphore->wait is called via the function threadActuator::waitForSemaphore(timeOutMS) To enable the algorithm to process data during movement, the waitForSemaphore(timeOutMS) can be skipped by callWait = false. The threadActuator::waitForSemaphore(timeOutMS)-function must than be called by the algorithms afterwards / before the next command is send to the actuator.

Parameters
[in]axisVecVector with the axis to move
[in]posVecVector with the new absolute positions
[in]timeOutMSTimeOut for the semaphore-wait, if (0) the waitForSemaphore is not called and must be called separate by the algorithm
Returns
retOk or retError
See also
ActuatorThreadCtrl::setPosRel

◆ setPosAbs() [2/2]

ito::RetVal ito::ActuatorThreadCtrl::setPosAbs ( int axis,
double absPosition,
int timeOutMS = PLUGINWAIT )

Move a single axi absolute

\detail Move a single axis specified by axis to the position pos. After the invoke-command this thread must wait / synchronize with the actuator-thread. Therefore the semaphore->wait is called via the function threadActuator::waitForSemaphore(timeOutMS) To enable the algorithm to process data during movement, the waitForSemaphore(timeOutMS) can be skipped by callWait = false. The threadActuator::waitForSemaphore(timeOutMS)-function must than be called by the algorithms afterwards / before the next command is send to the actuator.

Parameters
[in]axisNumber of the axis
[in]posNew position of the axis
[in]timeOutMSTimeOut for the semaphore-wait, if (0) the waitForSemaphore is not called and must be called separate by the algorithm
Returns
retOk or retError
See also
ActuatorThreadCtrl::setPosRel

◆ setPosRel() [1/2]

ito::RetVal ito::ActuatorThreadCtrl::setPosRel ( const QVector< int > & axes,
const QVector< double > & relPositions,
int timeOutMS = PLUGINWAIT )

Move more than on axis relative to current position

\detail Move the axis in axisVec with a distance defined in stepSizeVec relative to current position. The axisVec and stepSizeVec must be same size. After the invoke-command this thread must wait / synchronize with the actuator-thread. Therefore the semaphore->wait is called via the function threadActuator::waitForSemaphore(timeOutMS) To enable the algorithm to process data during movement, the waitForSemaphore(timeOutMS) can be skipped by callWait = false. The threadActuator::waitForSemaphore(timeOutMS)-function must than be called by the algorithms afterwards / before the next command is send to the actuator.

Parameters
[in]axisVecVector with the axis to move
[in]stepSizeVecVector with the distances for every axis
[in]timeOutMSTimeOut for the semaphore-wait, if (0) the waitForSemaphore is not called and must be called separate by the algorithm
Returns
retOk or retError
See also
ActuatorThreadCtrl::setPosAbs

◆ setPosRel() [2/2]

ito::RetVal ito::ActuatorThreadCtrl::setPosRel ( int axis,
double relPosition,
int timeOutMS = PLUGINWAIT )

Move a single axis relative to current position

\detail Move a single axis specified by axis with a distance defined in stepSize relative to current position. After the invoke-command this thread must wait / synchronize with the actuator-thread. Therefore the semaphore->wait is called via the function threadActuator::waitForSemaphore(timeOutMS) To enable the algorithm to process data during movement, the waitForSemaphore(timeOutMS) can be skipped by callWait = false. The threadActuator::waitForSemaphore(timeOutMS)-function must than be called by the algorithms afterwards / before the next command is send to the actuator.

Parameters
[in]axisNumber of the axis
[in]stepSizeDistances from current position
[in]timeOutMSTimeOut for the semaphore-wait, if (0) the waitForSemaphore is not called and must be called separate by the algorithm
Returns
retOk or retError
See also
ActuatorThreadCtrl::setPosAbs

The documentation for this class was generated from the following files: