itom 1.3.0
|
00001 /* ******************************************************************** 00002 itom software 00003 URL: http://www.uni-stuttgart.de/ito 00004 Copyright (C) 2013, Institut für Technische Optik (ITO), 00005 Universität Stuttgart, Germany 00006 00007 This file is part of itom and its software development toolkit (SDK). 00008 00009 itom is free software; you can redistribute it and/or modify it 00010 under the terms of the GNU Library General Public Licence as published by 00011 the Free Software Foundation; either version 2 of the Licence, or (at 00012 your option) any later version. 00013 00014 In addition, as a special exception, the Institut für Technische 00015 Optik (ITO) gives you certain additional rights. 00016 These rights are described in the ITO LGPL Exception version 1.0, 00017 which can be found in the file LGPL_EXCEPTION.txt in this package. 00018 00019 itom is distributed in the hope that it will be useful, but 00020 WITHOUT ANY WARRANTY; without even the implied warranty of 00021 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library 00022 General Public Licence for more details. 00023 00024 You should have received a copy of the GNU Library General Public License 00025 along with itom. If not, see <http://www.gnu.org/licenses/>. 00026 *********************************************************************** */ 00027 00028 #ifndef ADDININTERFACE_H 00029 #define ADDININTERFACE_H 00030 00031 #include "commonGlobal.h" 00032 00033 #include "apiFunctionsInc.h" 00034 #include "apiFunctionsGraphInc.h" 00035 00036 #include "sharedStructuresQt.h" 00037 #include "sharedStructures.h" 00038 00039 #include <qlist.h> 00040 #include <qmap.h> 00041 #include <qpair.h> 00042 #include <qset.h> 00043 #include <qthread.h> 00044 #include <qsharedpointer.h> 00045 #include <qmutex.h> 00046 00047 #if QT_VERSION < 0x050000 00048 #include <qpluginloader.h> 00049 #include <qdockwidget.h> 00050 #else 00051 #include <QtCore/qpluginloader.h> 00052 #include <QtWidgets/qdockwidget.h> 00053 #endif 00054 00055 //plugins define VISUAL_LEAK_DETECTOR_CMAKE in their CMake configuration file 00056 #if defined _DEBUG && defined(_MSC_VER) && defined(VISUAL_LEAK_DETECTOR_CMAKE) 00057 #define NOMINMAX //instead min, max is defined as macro in winDef.h, included by vld.h 00058 #include "vld.h" 00059 #endif 00060 00061 #if !defined(Q_MOC_RUN) || defined(ITOMCOMMONQT_MOC) //only moc this file in itomCommonQtLib but not in other libraries or executables linking against this itomCommonQtLib 00062 00063 //write this macro right after Q_INTERFACE(...) in your interface class definition 00064 #define PLUGIN_ITOM_API \ 00065 protected: \ 00066 void importItomApi(void** apiPtr) \ 00067 {ito::ITOM_API_FUNCS = apiPtr;} \ 00068 void importItomApiGraph(void** apiPtr) \ 00069 { ito::ITOM_API_FUNCS_GRAPH = apiPtr;} \ 00070 public: \ 00071 //. 00072 00074 00078 #define NEW_PLUGININSTANCE(PluginClass) \ 00079 PluginClass* newInst = new PluginClass(); \ 00080 newInst->setBasePlugin(this); \ 00081 *addInInst = qobject_cast<ito::AddInBase*>(newInst); \ 00082 m_InstList.append(*addInInst); 00083 00085 00090 #define REMOVE_PLUGININSTANCE(PluginClass) \ 00091 if (*addInInst) \ 00092 { \ 00093 delete ((PluginClass *)*addInInst); \ 00094 m_InstList.removeOne(*addInInst); \ 00095 } 00096 00098 00102 #define REGISTER_FILTERS_AND_WIDGETS \ 00103 foreach(ito::AddInAlgo::FilterDef *f, newInst->m_filterList) \ 00104 { \ 00105 f->m_pBasePlugin = this; \ 00106 } \ 00107 foreach(ito::AddInAlgo::AlgoWidgetDef *w, newInst->m_algoWidgetList) \ 00108 { \ 00109 w->m_pBasePlugin = this; \ 00110 } 00111 00112 00113 namespace ito 00114 { 00115 //---------------------------------------------------------------------------------------------------------------------------------- 00117 00121 enum tPluginType { 00122 typeDataIO = 0x1, 00123 typeActuator = 0x2, 00124 typeAlgo = 0x4, 00125 typeGrabber = 0x80, 00126 typeADDA = 0x100, 00127 typeRawIO = 0x200 00128 }; 00129 00131 00140 enum tActuatorStatus { 00141 //moving flags 00142 actuatorUnknown = 0x0001, 00143 actuatorInterrupted = 0x0002, 00144 actuatorMoving = 0x0004, 00145 actuatorAtTarget = 0x0008, 00146 actuatorTimeout = 0x0010, 00147 //switches 00148 actuatorEndSwitch = 0x0100, 00149 actuatorLeftEndSwitch = 0x0200, 00150 actuatorRightEndSwitch = 0x0400, 00151 actuatorRefSwitch = 0x0800, 00152 actuatorLeftRefSwitch = 0x1000, 00153 actuatorRightRefSwitch = 0x2000, 00154 //status flags 00155 actuatorAvailable = 0x4000, 00156 actuatorEnabled = 0x8000, 00158 actMovingMask = actuatorUnknown | actuatorInterrupted | actuatorMoving | actuatorAtTarget | actuatorTimeout, 00159 actEndSwitchMask = actuatorEndSwitch | actuatorLeftEndSwitch | actuatorRightEndSwitch, 00160 actRefSwitchMask = actuatorRefSwitch | actuatorLeftRefSwitch | actuatorRightRefSwitch, 00161 actSwitchesMask = actEndSwitchMask | actRefSwitchMask, 00162 actStatusMask = actuatorAvailable | actuatorEnabled 00163 }; 00164 00165 enum tAutoLoadPolicy { 00166 autoLoadAlways = 0x1, 00167 autoLoadNever = 0x2, 00168 autoLoadKeywordDefined = 0x4 00169 }; 00170 00171 enum tAutoSavePolicy { 00172 autoSaveAlways = 0x1, 00173 autoSaveNever = 0x2 00174 }; 00175 00176 struct ExecFuncParams{ 00177 ExecFuncParams() : infoString("") {} 00178 QVector<Param> paramsMand; 00179 QVector<Param> paramsOpt; 00180 QVector<Param> paramsOut; 00181 QString infoString; 00182 }; 00183 00184 struct FilterParams { 00185 QVector<Param> paramsMand; 00186 QVector<Param> paramsOpt; 00187 QVector<Param> paramsOut; 00188 }; 00189 00190 class AddInBase; 00191 class DataObject; 00192 00193 //---------------------------------------------------------------------------------------------------------------------------------- 00217 class ITOMCOMMONQT_EXPORT AddInInterfaceBase : public QObject 00218 { 00219 Q_OBJECT 00220 00221 private: 00223 virtual ito::RetVal closeThisInst(ito::AddInBase **addInInst) = 0; 00224 00225 protected: 00226 int m_type; 00227 int m_version; 00228 QString m_filename; 00229 int m_maxItomVer; 00230 int m_minItomVer; 00231 QString m_author; 00232 QString m_description; 00233 QString m_detaildescription; 00234 QString m_license; 00235 QString m_aboutThis; 00236 QList<ito::AddInBase *> m_InstList; 00237 QVector<ito::Param> m_initParamsMand; 00238 QVector<ito::Param> m_initParamsOpt; 00239 //bool m_enableAutoLoad; //* Varialbe to enable autoload for plugin. Standard value is false. Must be overwritten in AddInConstructor */ 00240 tAutoLoadPolicy m_autoLoadPolicy; 00241 tAutoSavePolicy m_autoSavePolicy; 00242 bool m_callInitInNewThread; 00243 QPluginLoader *m_loader; 00244 00245 virtual void importItomApi(void** apiPtr) = 0; //this methods are implemented in the plugin itsself. Therefore place ITOM_API right after Q_INTERFACE in the header file and replace Q_EXPORT_PLUGIN2 by Q_EXPORT_PLUGIN2_ITOM in the source file. 00246 virtual void importItomApiGraph(void** apiPtr) = 0; 00247 00248 public: 00249 void **m_apiFunctionsBasePtr; 00250 void **m_apiFunctionsGraphBasePtr; 00251 00252 virtual ~AddInInterfaceBase(); 00253 00255 AddInInterfaceBase() : 00256 m_type(0), m_version(CREATEVERSION(0,0,0)), m_filename(""), 00257 m_maxItomVer(MAXVERSION), m_minItomVer(MINVERSION), 00258 m_author(""), m_description(""), m_detaildescription(""), m_license("LGPL with ITO itom-exception"), m_aboutThis(""), 00259 /*m_enableAutoLoad(false),*/ m_autoLoadPolicy(ito::autoLoadNever), 00260 m_autoSavePolicy(ito::autoSaveNever), m_callInitInNewThread(true), m_apiFunctionsBasePtr(NULL), m_apiFunctionsGraphBasePtr(NULL), m_loader(NULL) 00261 { } 00262 00264 inline int getType(void) const { return m_type; } 00266 inline int getVersion(void) const { return m_version; } 00268 inline int getMinItomVer(void) const { return m_minItomVer; } 00270 inline int getMaxItomVer(void) const { return m_maxItomVer; } 00271 00273 inline bool getCallInitInNewThread(void) const { return m_callInitInNewThread; } 00274 00276 inline tAutoLoadPolicy getAutoLoadPolicy(void) const { return m_autoLoadPolicy; } 00277 00279 inline tAutoSavePolicy getAutoSavePolicy(void) const { return m_autoSavePolicy; } 00280 00282 const QString getAuthor(void) const { return m_author; } 00284 const QString getDescription(void) const { return m_description; } 00286 const QString getDetailDescription(void) const { return m_detaildescription; } 00288 const QString getLicenseInfo(void) const { return m_license; } 00290 const QString getAboutInfo(void) const { return m_aboutThis; } 00292 const QString getFilename(void) const { return m_filename; } 00293 00294 const ito::RetVal setFilename(const QString &name) { m_filename = name; return ito::retOk; } 00296 inline QList<ito::AddInBase *> getInstList(void) { return m_InstList; } 00297 inline const QList<ito::AddInBase *> getInstList(void) const { return m_InstList; } 00299 ito::RetVal closeInst(ito::AddInBase **addInInst); 00301 virtual QVector<ito::Param>* getInitParamsMand(void) { return &m_initParamsMand; } 00303 virtual QVector<ito::Param>* getInitParamsOpt(void) { return &m_initParamsOpt; } 00305 virtual ito::RetVal getAddInInst(ito::AddInBase **addInInst) = 0; 00307 void incRef(ito::AddInBase *addIn); 00309 void decRef(ito::AddInBase *addIn); 00311 int getRef(ito::AddInBase *addIn); 00313 int getInstCount() { return m_InstList.length(); } 00315 void setApiFunctions(void **apiFunctions); 00316 void setApiFunctionsGraph(void ** apiFunctionsGraph); 00317 inline void setLoader(QPluginLoader *loader) { m_loader = loader; } 00318 inline QPluginLoader * getLoader(void) { return m_loader; } 00319 00320 bool event(QEvent *e); 00321 00322 00323 }; 00324 00325 //---------------------------------------------------------------------------------------------------------------------------------- 00339 class ITOMCOMMONQT_EXPORT AddInBase : public QObject 00340 { 00341 Q_OBJECT 00342 00343 public: 00344 00345 struct AddInRef { 00346 AddInRef() : type(-1), ptr(0) {} 00347 AddInRef(void *p, int t) : type(t), ptr(p) {} 00348 int type; 00349 void *ptr; 00350 }; 00351 00353 00370 const Param getParamRec(const QString name, bool *nameCheckOk = NULL) const 00371 { 00372 QRegExp rx("^([a-zA-Z]+\\w*)(\\[(\\d+)\\]){0,1}(:(.*)){0,1}$"); 00373 if (rx.indexIn(name) == -1) 00374 { 00375 if (nameCheckOk) 00376 { 00377 *nameCheckOk = false; 00378 } 00379 return Param(); 00380 } 00381 else 00382 { 00383 QStringList pname = rx.capturedTexts(); 00384 if (pname.length() > 1) 00385 { 00386 if (nameCheckOk) 00387 { 00388 *nameCheckOk = true; 00389 } 00390 ito::Param tempParam = m_params.value(pname[1]); 00391 if (pname[2].length()) 00392 { 00393 } 00394 if (pname[4].length()) 00395 { 00396 } 00397 return tempParam; //returns default constructor if value not available in m_params. Default constructor has member isValid() => false 00398 } 00399 } 00400 return Param(); 00401 } 00402 00404 inline AddInInterfaceBase* getBasePlugin(void) const { return m_pBasePlugin; } 00405 00407 inline ito::RetVal MoveToThread(void) 00408 { 00409 m_pThread = new QThread(); 00410 moveToThread(m_pThread); 00411 m_pThread->start(); 00412 return retOk; 00413 } 00414 00416 /* 00417 Use the method setParam in order to change any parameter. 00418 00419 \param paramNames [out]. The pointer contains a pointer to the map after the call of this function 00420 \return RetVal returns retOk. 00421 */ 00422 inline const ito::RetVal getParamList(QMap<QString, Param> **paramNames) { *paramNames = &m_params; return ito::retOk; } 00423 00425 /* 00426 \param [out] funcs is the pointer to a map, that points to the internal map of additional functions after the method-call. 00427 \return retOk 00428 \sa registerExecFunc 00429 */ 00430 inline const ito::RetVal getExecFuncList(QMap<QString, ExecFuncParams> **funcs) { *funcs = &m_execFuncList; return ito::retOk; } 00431 00433 inline int getID() const { return m_uniqueID; } 00434 00436 inline QString getIdentifier() const { return m_identifier; } 00437 00439 virtual int hasConfDialog(void); 00440 00442 virtual const ito::RetVal showConfDialog(void); 00443 00445 inline int createdByGUI() const { return m_createdByGUI; } 00446 00448 inline void setCreatedByGUI(int value) { m_createdByGUI = value; } 00449 00451 /* 00452 The reference counter is zero-based, hence, the value zero means that one reference is pointing to this instance 00453 */ 00454 inline int getRefCount(void) 00455 { 00456 return m_refCount; 00457 } 00458 00460 /* 00461 \sa getDockWidget 00462 */ 00463 inline bool hasDockWidget(void) const { return m_dockWidget ? true : false; } 00464 00466 /* 00467 \sa hasDockWidget 00468 */ 00469 inline QDockWidget* getDockWidget(void) const { return m_dockWidget; } 00470 00471 // doc in source 00472 virtual void dockWidgetDefaultStyle(bool &floating, bool &visible, Qt::DockWidgetArea &defaultArea) const; 00473 00475 /* 00476 Any time-consuming operation of the plugin should regularly set the alive-flag to true 00477 by calling setAlive. The state of this flag is returned by this method and afterwards 00478 reset to 0. This method is thread-safe. 00479 00480 \return current status of alive-flag (1 if "still alive", else 0) 00481 \sa setAlive 00482 */ 00483 int isAlive(void) 00484 { 00485 // QMutexLocker locker(&m_atomicMutex); 00486 int wasalive = m_alive; 00487 m_alive = 0; 00488 return wasalive; 00489 } 00490 00492 /* 00493 This method is thread-safe. 00494 00495 \sa isAlive 00496 */ 00497 void setAlive(void) 00498 { 00499 // QMutexLocker locker(&m_atomicMutex); 00500 m_alive = 1; 00501 } 00502 00504 bool isInitialized(void) 00505 { 00506 // QMutexLocker locker(&m_atomicMutex); 00507 return m_initialized; 00508 } 00509 00511 /* 00512 \param [in] initialized is the value to set 00513 */ 00514 void setInitialized(bool initialized) 00515 { 00516 // QMutexLocker locker(&m_atomicMutex); 00517 m_initialized = initialized; 00518 } 00519 00521 /* 00522 This vector contains all plugin-instances, that have been passed to the init 00523 method of this plugin. The reference counter of these plugin is incremented at 00524 initialization of this plugin and decremented if this plugin will be destroyed. 00525 00526 \sa AddInRef, init 00527 */ 00528 QVector<ito::AddInBase::AddInRef *> * getArgAddIns(void) { return &m_hwDecList; } 00529 00530 protected: 00531 // constructor (doc in source) 00532 AddInBase(); 00533 00534 // destructor (doc in source) 00535 virtual ~AddInBase(); 00536 00538 void setIdentifier(const QString &identifier); 00539 00540 //doc in source 00541 void createDockWidget(QString title, QDockWidget::DockWidgetFeatures features, Qt::DockWidgetAreas allowedAreas = Qt::AllDockWidgetAreas, QWidget *content = NULL); 00542 00543 // doc in source 00544 ito::RetVal registerExecFunc(const QString funcName, const QVector<ito::Param> ¶msMand, const QVector<ito::Param> ¶msOpt, const QVector<ito::Param> ¶msOut, const QString infoString); 00545 00547 inline void setBasePlugin(AddInInterfaceBase *base) { m_pBasePlugin = base; } 00548 00549 QThread *m_pThread; 00550 AddInInterfaceBase *m_pBasePlugin; 00551 QMap<QString, Param> m_params; 00552 00553 QString m_identifier; 00554 int m_refCount; 00555 int m_createdByGUI; 00556 QVector<ito::AddInBase::AddInRef *> m_hwDecList; 00557 QMap<QString, ExecFuncParams> m_execFuncList; 00558 00559 private: 00560 Q_DISABLE_COPY (AddInBase) 00561 00562 00563 inline void incRefCount(void) 00564 { 00565 m_refCountMutex.lock(); 00566 m_refCount++; 00567 m_refCountMutex.unlock(); 00568 } 00569 00571 inline void decRefCount(void) 00572 { 00573 m_refCountMutex.lock(); 00574 m_refCount--; 00575 m_refCountMutex.unlock(); 00576 } 00577 00578 int m_uniqueID; 00579 00580 QMutex m_refCountMutex; 00581 QDockWidget *m_dockWidget; 00582 int m_alive; 00583 QMutex m_atomicMutex; 00584 bool m_initialized; 00585 00586 friend class AddInInterfaceBase; 00587 00588 static int m_instCounter; 00589 00590 signals: 00592 00600 void parametersChanged(QMap<QString, ito::Param> params); 00601 00602 public slots: 00604 virtual ito::RetVal init(QVector<ito::ParamBase> *paramsMand, QVector<ito::ParamBase> *paramsOpt, ItomSharedSemaphore *waitCond = NULL) = 0; 00606 virtual ito::RetVal close(ItomSharedSemaphore *waitCond) = 0; 00607 00609 virtual ito::RetVal getParam(QSharedPointer<ito::Param> val, ItomSharedSemaphore *waitCond = NULL) = 0; 00611 virtual ito::RetVal setParam(QSharedPointer<ito::ParamBase> val, ItomSharedSemaphore *waitCond = NULL) = 0; 00612 00613 // doc in source-file 00614 ito::RetVal setParamVector(const QVector<QSharedPointer<ito::ParamBase> > values, ItomSharedSemaphore *waitCond = NULL); 00615 00616 // doc in source-file 00617 virtual ito::RetVal execFunc(const QString funcName, QSharedPointer<QVector<ito::ParamBase> > paramsMand, QSharedPointer<QVector<ito::ParamBase> > paramsOpt, QSharedPointer<QVector<ito::ParamBase> > paramsOut, ItomSharedSemaphore *waitCond = NULL); 00618 00619 private slots: 00621 00628 void sendParameterRequest(){ emit parametersChanged(m_params); }; 00629 00631 00639 virtual void dockWidgetVisibilityChanged(bool /*visible*/) {}; 00640 00642 00647 void dockWidgetDestroyed() { m_dockWidget = NULL; } 00648 }; 00649 00650 //---------------------------------------------------------------------------------------------------------------------------------- 00677 class ITOMCOMMONQT_EXPORT AddInDataIO : public AddInBase 00678 { 00679 Q_OBJECT 00680 00681 private: 00682 Q_DISABLE_COPY (AddInDataIO) 00683 00684 protected: 00685 virtual ~AddInDataIO() = 0; 00686 AddInDataIO(); 00687 00688 void runStatusChanged(bool deviceStarted); 00689 00690 //void timerEvent (QTimerEvent *event) = 0; //implement this event in your plugin, if you are a device, which is accessible by any liveImage!!! 00691 00692 QSet<QObject*> m_autoGrabbingListeners; 00693 int m_timerID; 00694 int m_timerIntervalMS; 00695 bool m_autoGrabbingEnabled; 00697 public: 00698 inline int getAutoGrabbing() { return m_autoGrabbingEnabled; } 00700 signals: 00701 00702 public slots: 00704 virtual ito::RetVal startDevice(ItomSharedSemaphore *waitCond); 00706 virtual ito::RetVal stopDevice(ItomSharedSemaphore *waitCond); 00708 virtual ito::RetVal acquire(const int trigger, ItomSharedSemaphore *waitCond = NULL); 00710 virtual ito::RetVal getVal(void* data, ItomSharedSemaphore *waitCond = NULL); 00712 virtual ito::RetVal getVal(QSharedPointer<char> data, QSharedPointer<int> length, ItomSharedSemaphore *waitCond = NULL); 00714 virtual ito::RetVal copyVal(void *dObj, ItomSharedSemaphore *waitCond); 00715 00717 virtual ito::RetVal setVal(const char *data, const int length, ItomSharedSemaphore *waitCond = NULL); 00718 00720 ito::RetVal enableAutoGrabbing(ItomSharedSemaphore *waitCond = NULL); //consider this method as final 00721 00723 ito::RetVal disableAutoGrabbing(ItomSharedSemaphore *waitCond = NULL); //consider this method as final 00724 00726 ito::RetVal startDeviceAndRegisterListener(QObject* obj, ItomSharedSemaphore *waitCond = NULL); //consider this method as final 00727 00729 ito::RetVal stopDeviceAndUnregisterListener(QObject* obj, ItomSharedSemaphore *waitCond = NULL); //consider this method as final 00730 }; 00731 00732 //---------------------------------------------------------------------------------------------------------------------------------- 00733 00734 00741 class ITOMCOMMONQT_EXPORT AddInActuator : public AddInBase 00742 { 00743 Q_OBJECT 00744 00745 private: 00746 Q_DISABLE_COPY (AddInActuator) 00747 00748 int m_nrOfStatusChangedConnections; 00749 int m_nrOfTargetChangedConnections; 00750 bool m_interruptFlag; 00751 QMutex m_interruptMutex; 00753 protected: 00754 virtual ~AddInActuator() = 0; 00755 AddInActuator(); 00756 00757 virtual void connectNotify (const char * signal); 00758 virtual void disconnectNotify (const char * signal); 00759 int nrOfStatusChangedConnections() const { return m_nrOfStatusChangedConnections; } 00760 int nrOfTargetChangedConnections() const { return m_nrOfTargetChangedConnections; } 00761 int nrOfConnections() const { return m_nrOfStatusChangedConnections + m_nrOfTargetChangedConnections; } 00763 QVector<int> m_currentStatus; 00764 QVector<double> m_currentPos; 00765 QVector<double> m_targetPos; 00767 00768 bool isMotorMoving() const 00769 { 00770 foreach(const int &i, m_currentStatus) 00771 { 00772 if (i & ito::actuatorMoving) 00773 { 00774 return true; 00775 } 00776 } 00777 return false; 00778 } 00779 00780 void sendStatusUpdate(const bool statusOnly = false); 00781 void sendTargetUpdate(); 00782 00784 00788 virtual ito::RetVal waitForDone(const int timeoutMS = -1, const QVector<int> axis = QVector<int>() /*if empty -> all axis*/, const int flags = 0 /*for your use*/) = 0; 00789 00791 00801 inline void setStatus(int &status, const int newFlags, const int keepMask = 0) { status = (status & keepMask) | newFlags; } 00802 00804 00814 inline void setStatus(const QVector<int> &axis, const int newFlags, const int keepMask = 0) 00815 { 00816 foreach(const int &i, axis) 00817 { 00818 setStatus(m_currentStatus[i], newFlags, keepMask); 00819 } 00820 } 00821 00823 00832 inline void replaceStatus(int &status, const int existingFlag, const int replaceFlag) { if (status & existingFlag) { status = (status ^ existingFlag) | replaceFlag; } } 00833 00835 00845 inline void replaceStatus(const QVector<int> &axis, const int existingFlag, const int replaceFlag) 00846 { 00847 foreach(const int &i, axis) 00848 { 00849 replaceStatus(m_currentStatus[i], existingFlag, replaceFlag); 00850 } 00851 } 00852 00854 00860 bool isInterrupted() 00861 { 00862 QMutexLocker locker(&m_interruptMutex); 00863 bool res = m_interruptFlag; 00864 m_interruptFlag = false; 00865 return res; 00866 } 00867 00868 public: 00870 00877 void setInterrupt() 00878 { 00879 QMutexLocker locker(&m_interruptMutex); 00880 m_interruptFlag = true; 00881 } 00882 00883 00884 00885 signals: 00887 00896 void actuatorStatusChanged(QVector<int> status, QVector<double> actPosition); 00897 00899 00907 void targetChanged(QVector<double> targetPositions); 00908 00909 public slots: 00911 virtual ito::RetVal calib(const int axis, ItomSharedSemaphore *waitCond = NULL) = 0; 00913 virtual ito::RetVal calib(const QVector<int> axis, ItomSharedSemaphore *waitCond = NULL) = 0; 00915 virtual ito::RetVal setOrigin(const int axis, ItomSharedSemaphore *waitCond = NULL) = 0; 00917 virtual ito::RetVal setOrigin(const QVector<int> axis, ItomSharedSemaphore *waitCond = NULL) = 0; 00919 virtual ito::RetVal getStatus(QSharedPointer<QVector<int> > status, ItomSharedSemaphore *waitCond) = 0; 00921 virtual ito::RetVal getPos(const int axis, QSharedPointer<double> pos, ItomSharedSemaphore *waitCond) = 0; 00923 virtual ito::RetVal getPos(const QVector<int> axis, QSharedPointer<QVector<double> > pos, ItomSharedSemaphore *waitCond) = 0; 00925 virtual ito::RetVal setPosAbs(const int axis, const double pos, ItomSharedSemaphore *waitCond = NULL) = 0; 00927 virtual ito::RetVal setPosAbs(const QVector<int> axis, QVector<double> pos, ItomSharedSemaphore *waitCond = NULL) = 0; 00929 virtual ito::RetVal setPosRel(const int axis, const double pos, ItomSharedSemaphore *waitCond = NULL) = 0; 00931 virtual ito::RetVal setPosRel(const QVector<int> axis, QVector<double> pos, ItomSharedSemaphore *waitCond = NULL) = 0; 00932 00934 virtual ito::RetVal requestStatusAndPosition(bool sendCurrentPos, bool sendTargetPos); //added 2014-03-04 00935 }; 00936 00937 //---------------------------------------------------------------------------------------------------------------------------------- 00946 class ITOMCOMMONQT_EXPORT AddInAlgo : public AddInBase 00947 { 00948 Q_OBJECT 00949 00950 Q_ENUMS(tAlgoCategory) 00951 Q_ENUMS(tAlgoInterface) 00952 00953 private: 00954 Q_DISABLE_COPY(AddInAlgo) 00955 00956 public: 00957 typedef ito::RetVal (* t_filter)(QVector<ito::ParamBase> *paramsMand, QVector<ito::ParamBase> *paramsOpt, QVector<ito::ParamBase> *paramsOut); 00958 typedef QWidget* (* t_algoWidget)(QVector<ito::ParamBase> *paramsMand, QVector<ito::ParamBase> *paramsOpt, ito::RetVal &retValue); 00959 typedef ito::RetVal (* t_filterParam)(QVector<ito::Param> *paramsMand, QVector<ito::Param> *paramsOpt, QVector<ito::Param> *paramsOut); 00960 00962 enum tAlgoCategory 00963 { 00964 catNone = 0x0000, 00965 catDiskIO = 0x0001, 00966 catAnalyseDataObject = 0x0002, 00967 catPlotDataObject = 0x0004 00968 }; 00969 00971 enum tAlgoInterface 00972 { 00973 iNotSpecified = 0x0000, 00974 iReadDataObject = 0x0001, 00975 iWriteDataObject = 0x0002, 00976 iReadPointCloud = 0x0004, 00977 iWritePointCloud = 0x0008, 00978 iReadPolygonMesh = 0x0010, 00979 iWritePolygonMesh = 0x0020, 00980 iPlotSingleObject = 0x0040 00981 }; 00982 00984 class FilterDef 00985 { 00986 public: 00988 FilterDef() : 00989 m_filterFunc(NULL), 00990 m_paramFunc(NULL), 00991 m_pBasePlugin(NULL), 00992 m_category(ito::AddInAlgo::catNone), 00993 m_interface(ito::AddInAlgo::iNotSpecified) 00994 {} 00995 00997 FilterDef(AddInAlgo::t_filter filterFunc, AddInAlgo::t_filterParam filterParamFunc, QString description = QString(), ito::AddInAlgo::tAlgoCategory category = ito::AddInAlgo::catNone, ito::AddInAlgo::tAlgoInterface interf = ito::AddInAlgo::iNotSpecified, QString interfaceMeta = QString()) : 00998 m_filterFunc(filterFunc), 00999 m_paramFunc(filterParamFunc), 01000 m_pBasePlugin(NULL), 01001 m_description(description), 01002 m_category(category), 01003 m_interface(interf), 01004 m_interfaceMeta(interfaceMeta) 01005 {} 01006 01007 virtual ~FilterDef() {} 01008 01009 t_filter m_filterFunc; 01010 t_filterParam m_paramFunc; 01011 ito::AddInInterfaceBase *m_pBasePlugin; 01012 QString m_name; 01013 QString m_description; 01014 ito::AddInAlgo::tAlgoCategory m_category; 01015 ito::AddInAlgo::tAlgoInterface m_interface; 01016 QString m_interfaceMeta; 01017 private: 01018 FilterDef (const FilterDef & /*p*/); //disable copy constructor 01019 }; 01020 01022 class AlgoWidgetDef 01023 { 01024 public: 01026 AlgoWidgetDef() : 01027 m_widgetFunc(NULL), 01028 m_paramFunc(NULL), 01029 m_pBasePlugin(NULL), 01030 m_category(ito::AddInAlgo::catNone), 01031 m_interface(ito::AddInAlgo::iNotSpecified) 01032 {} 01033 01035 AlgoWidgetDef(AddInAlgo::t_algoWidget algoWidgetFunc, AddInAlgo::t_filterParam algoWidgetParamFunc, QString description = QString(), ito::AddInAlgo::tAlgoCategory category = ito::AddInAlgo::catNone, ito::AddInAlgo::tAlgoInterface interf = ito::AddInAlgo::iNotSpecified, QString interfaceMeta = QString()) : 01036 m_widgetFunc(algoWidgetFunc), 01037 m_paramFunc(algoWidgetParamFunc), 01038 m_pBasePlugin(NULL), 01039 m_description(description), 01040 m_category(category), 01041 m_interface(interf), 01042 m_interfaceMeta(interfaceMeta) 01043 {} 01044 01045 virtual ~AlgoWidgetDef() {} 01046 01047 t_algoWidget m_widgetFunc; 01048 t_filterParam m_paramFunc; 01049 ito::AddInInterfaceBase *m_pBasePlugin; 01050 QString m_name; 01051 QString m_description; 01052 ito::AddInAlgo::tAlgoCategory m_category; 01053 ito::AddInAlgo::tAlgoInterface m_interface; 01054 QString m_interfaceMeta; 01055 01056 private: 01057 AlgoWidgetDef (const AlgoWidgetDef & /*p*/); //disable copy constructor 01058 }; 01059 01060 ito::RetVal getFilterList(QHash<QString, FilterDef *> &fList) const; 01061 ito::RetVal getAlgoWidgetList(QHash<QString, AlgoWidgetDef *> &awList) const; 01062 ito::RetVal rejectFilter(const QString &name); 01063 ito::RetVal rejectAlgoWidget(const QString &name); 01064 01065 protected: 01066 virtual ~AddInAlgo(); 01067 AddInAlgo(); 01068 QHash<QString, FilterDef *> m_filterList; 01069 QHash<QString, AlgoWidgetDef *> m_algoWidgetList; 01070 01071 static ito::RetVal prepareParamVectors(QVector<ito::Param> *paramsMand, QVector<ito::Param> *paramsOpt, QVector<ito::Param> *paramsOut) 01072 { 01073 if (!paramsMand) 01074 { 01075 return RetVal(ito::retError, 0, tr("uninitialized vector for mandatory parameters!").toLatin1().data()); 01076 } 01077 if (!paramsOpt) 01078 { 01079 return RetVal(ito::retError, 0, tr("uninitialized vector for optional parameters!").toLatin1().data()); 01080 } 01081 if (!paramsOut) 01082 { 01083 return RetVal(ito::retError, 0, tr("uninitialized vector for output parameters!").toLatin1().data()); 01084 } 01085 paramsMand->clear(); 01086 paramsOpt->clear(); 01087 paramsOut->clear(); 01088 return ito::retOk; 01089 } 01090 01091 public slots: 01092 virtual ito::RetVal getParam(QSharedPointer<ito::Param> /*val*/, ItomSharedSemaphore * /*waitCond*/ = NULL) { return ito::retOk; } 01093 virtual ito::RetVal setParam(QSharedPointer<ito::ParamBase> /*val*/, ItomSharedSemaphore * /*waitCond*/ = NULL) { return ito::retOk; } 01094 }; 01095 01096 //---------------------------------------------------------------------------------------------------------------------------------- 01097 } // namespace ito 01098 01099 #endif //#if !defined(Q_MOC_RUN) || defined(ITOMCOMMONQT_MOC) 01100 01101 //########################################################################################################### 01102 // Interface version: 01103 //########################################################################################################### 01104 // 01105 // 01106 // Please change the interface version, if you made any changes to this interface, files located in the common folder or to the dataObject. 01107 // 01108 // To add a new version, do the following steps 01109 // 01110 // 1. append the string behind the variable ito_AddInInterface_CurrentVersion (e.g. ito.AddIn.InterfaceBase/1.1) to the array ito_AddInInterface_OldVersions 01111 // 2. change the version number in the string ito_AddInInterface_CurrentVersion 01112 // 3. if the AddInInterface version number is incremented, the ito.AbstractItomDesignerPlugin number in AbstractItomDesignerPlugin.h must be incremented as well. 01113 // 01114 // 01115 // This helps, that deprecated or "future" plugins, which fit not to the current implementation of the interface will not be loaded 01116 // but a sophisticated error message is shown. 01117 01118 static const char* ito_AddInInterface_OldVersions[] = { 01119 "ito.AddIn.InterfaceBase/1.0", //version from start of development until 2012-10-11 01120 "ito.AddIn.InterfaceBase/1.1", //version until 2012-10-15 (outdated due to changes in dataObject) 01121 "ito.AddIn.InterfaceBase/1.1.1", //version until 2012-10-21 (outdated due to small changes in addInInterface) 01122 "ito.AddIn.InterfaceBase/1.1.2", //version until 2012-10-30 (outdated due to small changes in addInInterface) 01123 "ito.AddIn.InterfaceBase/1.1.3", //version until 2012-11-09 (outdated due to changes in the checkData()-function in addInGrabber) 01124 "ito.AddIn.InterfaceBase/1.1.4", //version until 2012-11-12 (outdated due to changes in the DataObject) 01125 "ito.AddIn.InterfaceBase/1.1.5", //version until 2012-11-18 (outdated: changes in the API structure) 01126 "ito.AddIn.InterfaceBase/1.1.6", //version until 2012-12-20 (outdated: added paramBase metatype) 01127 "ito.AddIn.InterfaceBase/1.1.7", //version until 2013-01-17 (outdated: last version for itom version 1.0.5) 01128 "ito.AddIn.InterfaceBase/1.1.8", //version until 2013-01-23 (outdated: changes in auto-grabbing of cameras, first interface for itom version 1.0.6) 01129 "ito.AddIn.InterfaceBase/1.1.9", //version until 2013-03-04 (outdated: changes in dataObjectHelper) 01130 "ito.AddIn.InterfaceBase/1.1.10",//version until 2013-03-12 (outdated: Added license and about string to the plugin) 01131 "ito.AddIn.InterfaceBase/1.1.11",//version until 2013-03-22 (outdated: bugfix in ito::ParamBase) 01132 "ito.AddIn.InterfaceBase/1.1.12",//version until 2013-03-25 (outdated: changes in api) 01133 "ito.AddIn.InterfaceBase/1.1.13",//version until 2013-04-08 (outdated: removed transpose flag in dataObject) 01134 "ito.AddIn.InterfaceBase/1.1.14",//version until 2013-04-17 (outdated: uniqueID and identifier inserted/changed) 01135 "ito.AddIn.InterfaceBase/1.1.15",//version until 2013-04-23 (outdated: made some tag-space related methods non-inline (due to linker errors in MSVC)) 01136 "ito.AddIn.InterfaceBase/1.1.16",//version until 2013-06-07 (outdated: added qpluginloader to the interface for cleaner unloading of plugins) 01137 "ito.AddIn.InterfaceBase/1.1.17",//version until 2013-06-11 (outdated: apis extended, changes in param-class) 01138 "ito.AddIn.InterfaceBase/1.1.18",//version until 2013-06-18 (outdated: iterator and constIterator introduced for dataObject) 01139 "ito.AddIn.InterfaceBase/1.1.19",//version until 2013-08-15 (outdated: operators +, +=, -, -= introduced for scalar operands) 01140 "ito.AddIn.InterfaceBase/1.1.20",//version until 2013-10-10 (outdated: RGBA-type introduced into dataObjectTypes) 01141 "ito.AddIn.InterfaceBase/1.1.21",//version until 2013-10-15 (outdated: getSize(..) and getTotalSize(..) return int now and -1 if error. Consistency to documented behaviour) 01142 "ito.AddIn.InterfaceBase/1.1.22",//version until 2013-10-27 (outdated: class Rgba32Base in typedefs.h and inherited class Rgba32 in color.h introduced, improved data() method in dataObj) 01143 "ito.AddIn.InterfaceBase/1.1.23",//version until 2013-12-17 (outdated: changed dataObject internal size parameters (back) from size_t to int - hopfully last time) 01144 "ito.AddIn.InterfaceBase/1.1.24",//version until 2014-02-09 (outdated: restructuring to itomCommonLib and itomCommonQtLib for a better binary compatibility) 01145 "ito.AddIn.InterfaceBase/1.2.0", //outdated on 2014-03-14 due to change in AddInDataIO::setVal(const char *data, const int length, ItomSharedSemaphore *waitCond = NULL); (const void *data changed to const char *data) (Qt5 bugfix) 01146 "ito.AddIn.InterfaceBase/1.2.1", //outdated on 2014-10-06 due to changes in APIs, retVal.h and itomWidgets-project. The next version 1.3.0 is the version for the setup 1.3.0. 01147 NULL 01148 }; 01149 01150 static const char* ito_AddInInterface_CurrentVersion = "ito.AddIn.InterfaceBase/1.3.0"; 01151 01152 //this define exists since itom 1.3.0 01153 #define ITOM_ADDININTERFACE_VERSION 0x010300 01154 01156 Q_DECLARE_INTERFACE(ito::AddInInterfaceBase, ito_AddInInterface_CurrentVersion /*"ito.AddIn.InterfaceBase/1.1"*/) 01157 01158 #endif