If you want to create a plugin in order to access piezo- or motor-stages, multi-axes-machines,... it is intended to derive your plugin class from ito::AddInActuator.
The actuator interface has been developped with the following base ideas:
In order to program the actuator plugin, follow these steps:
Create the header and source file for your plugin “MyAlgoPlugin”.
Create the interface (or factory) class “MyAlgoPluginInterface”. For details about how to create such an interface class, see Plugin interface class.
Create the plugin class “MyAlgoPlugin” with respect to the exemplary implementation, given in the next section.
- Consider which internal parameters, that can be read and/or written by the user, your plugin has. Add these parameters in the constructor of your plugin to the m_params-vector.
- Implement the init-method that gets the initial parameters, defined in the interface class.
- Implement the methods getParam and setParam, which are the getter- and setter-methods for the internal parameters.
- Implement the motor-specific methods, including waitForDone
A sample header file of the actuator’s plugin class is illustrated in the following code snippet:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | #include "../../common/addInInterface.h"
#include "dialogMyMotor.h"
#include "dockWidgetMyMotor.h"
class MyMotor : public ito::AddInActuator
{
Q_OBJECT
protected:
~MyMotor() {}; /*! < Destructor*/
MyMotor(int uniqueID);/*! < Constructor*/
public:
friend class MyMotorInterface;
const ito::RetVal showConfDialog(void); /*!< Opens the modal configuration dialog (called from main thread) */
int hasConfDialog(void) { return 1; }; /*!< indicates that this plugin has got a configuration dialog */
private:
ito::RetVal waitForDone(int timeoutMS = -1, QVector<int> axis = QVector<int>() /*if empty -> all axis*/, int flags = 0 /*for your use*/);
signals:
void parametersChanged(QMap<QString, ito::tParam> params); /*!< Sends a signal if parameters have changes */
public slots:
//! get/set parameters
ito::RetVal getParam(QSharedPointer<ito::tParam> val, ItomSharedSemaphore *waitCond = NULL);
ito::RetVal setParam(QSharedPointer<ito::tParam> val, ItomSharedSemaphore *waitCond = NULL);
//! init/close method
ito::RetVal init(QVector<ito::tParam> *paramsMand, QVector<ito::tParam> *paramsOpt, ItomSharedSemaphore *waitCond = NULL);
ito::RetVal close(ItomSharedSemaphore *waitCond);
//! calibration for single or multiple axis
ito::RetVal calib(const int axis, ItomSharedSemaphore *waitCond = NULL);
ito::RetVal calib(const QVector<int> axis, ItomSharedSemaphore *waitCond = NULL);
//! current axis position is new zero-position
ito::RetVal setOrigin(const int axis, ItomSharedSemaphore *waitCond = NULL);
ito::RetVal setOrigin(const QVector<int> axis, ItomSharedSemaphore *waitCond = NULL);
//! Reads out status request answer and gives back ito::retOk or ito::retError
ito::RetVal getStatus(QSharedPointer<QVector<int> > status, ItomSharedSemaphore *waitCond);
//! get current position of single or multiple axis (in mm or degree)
ito::RetVal getPos(const int axis, QSharedPointer<double> pos, ItomSharedSemaphore *waitCond);
ito::RetVal getPos(const QVector<int> axis, QSharedPointer<QVector<double> > pos, ItomSharedSemaphore *waitCond);
//! move one or more axis to certain absolute positions (in mm or degree)
ito::RetVal setPosAbs(const int axis, const double pos, ItomSharedSemaphore *waitCond = NULL);
ito::RetVal setPosAbs(const QVector<int> axis, QVector<double> pos, ItomSharedSemaphore *waitCond = NULL);
//! move one or more axis by certain relative distances (in mm or degree)
ito::RetVal setPosRel(const int axis, const double pos, ItomSharedSemaphore *waitCond = NULL);
ito::RetVal setPosRel(const QVector<int> axis, QVector<double> pos, ItomSharedSemaphore *waitCond = NULL);
//! if this slot is triggered, the current status and position is emitted (e.g. for actualizing a dock widget)
ito::RetVal RequestStatusAndPosition(bool sendActPosition, bool sendTargetPos);
private slots:
void dockWidgetVisibilityChanged( bool visible ); /*!< this slot is invoked if the visibility of the dock widget has changed */
};
|
In order to have a unique behaviour of all plugins, respect the following unit conditions: