itom 2.2.1
|
00001 /* ******************************************************************** 00002 itom software 00003 URL: http://www.uni-stuttgart.de/ito 00004 Copyright (C) 2016, Institut fuer Technische Optik (ITO), 00005 Universitaet 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 fuer 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 MOTORAXISCONTROLLER_H 00029 #define MOTORAXISCONTROLLER_H 00030 00031 00032 #include "commonWidgets.h" 00033 #include <qwidget.h> 00034 #include <qstring.h> 00035 #include <qpoint.h> 00036 #include <qpointer.h> 00037 #include <qstringlist.h> 00038 #include "common/retVal.h" 00039 #include "common/interval.h" 00040 00041 class ItomSharedSemaphore; //forward declaration 00042 00043 class MotorAxisControllerPrivate; //forward declaration 00044 00045 namespace ito { 00046 class AddInActuator; //forward declaration 00047 }; 00048 00049 class ITOMWIDGETS_EXPORT MotorAxisController : public QWidget 00050 { 00051 Q_OBJECT 00052 00053 #if QT_VERSION < 0x050500 00054 //for >= Qt 5.5.0 see Q_ENUM definition below 00055 Q_ENUMS(AxisUnit) 00056 Q_ENUMS(AxisType) 00057 Q_ENUMS(MovementType) 00058 #endif 00059 00060 Q_PROPERTY(QPointer<ito::AddInActuator> actuator READ actuator WRITE setActuator) 00061 Q_PROPERTY(int numAxis READ numAxis WRITE setNumAxis) 00062 Q_PROPERTY(AxisUnit defaultAxisUnit READ defaultAxisUnit WRITE setDefaultAxisUnit) 00063 Q_PROPERTY(AxisType defaultAxisType READ defaultAxisType WRITE setDefaultAxisType) 00064 Q_PROPERTY(bool refreshAvailable READ refreshAvailable WRITE setRefreshAvailable) 00065 Q_PROPERTY(bool cancelAvailable READ cancelAvailable WRITE setCancelAvailable) 00066 Q_PROPERTY(bool startAllAvailable READ startAllAvailable WRITE setStartAllAvailable) 00067 Q_PROPERTY(double defaultRelativeStepSize READ defaultRelativeStepSize WRITE setDefaultRelativeStepSize) 00068 Q_PROPERTY(QStringList axisNames READ axisNames WRITE setAxisNames) 00069 Q_PROPERTY(int defaultDecimals READ defaultDecimals WRITE setDefaultDecimals) 00070 Q_PROPERTY(MovementType movementType READ movementType WRITE setMovementType) 00071 Q_PROPERTY(bool movementTypeVisible READ movementTypeVisible WRITE setMovementTypeVisible) 00072 Q_PROPERTY(QString arbitraryUnit READ arbitraryUnit WRITE setArbitraryUnit) 00073 00074 public: 00075 enum AxisUnit { 00076 UnitNm = 0, 00077 UnitMum, 00078 UnitMm, 00079 UnitCm, 00080 UnitM, 00081 UnitDeg, 00082 UnitAU /*Arbitrary unit*/ 00083 }; 00084 00085 enum AxisType { 00086 TypeRotational = 0, 00087 TypeLinear = 1 00088 }; 00089 00090 enum MovementType { 00091 MovementAbsolute = 0, 00092 MovementRelative = 1, 00093 MovementBoth = 2, 00094 MovementNo = 3 00095 }; 00096 00097 #if QT_VERSION >= 0x050500 00098 //Q_ENUM exposes a meta object to the enumeration types, such that the key names for the enumeration 00099 //values are always accessible. 00100 Q_ENUM(AxisUnit); 00101 Q_ENUM(AxisType); 00102 Q_ENUM(MovementType); 00103 #endif 00104 00105 MotorAxisController(QWidget *parent = NULL); 00106 ~MotorAxisController(); 00107 00108 void setActuator(const QPointer<ito::AddInActuator> &actuator); 00109 QPointer<ito::AddInActuator> actuator() const; 00110 00111 int numAxis() const; 00112 AxisUnit axisUnit(int axisIndex) const; 00113 AxisUnit defaultAxisUnit() const; 00114 AxisType axisType(int axisIndex) const; 00115 AxisType defaultAxisType() const; 00116 bool refreshAvailable() const; 00117 bool cancelAvailable() const; 00118 bool startAllAvailable() const; 00119 double defaultRelativeStepSize() const; 00120 QStringList axisNames() const; 00121 QString axisName(int axisIndex) const; 00122 int defaultDecimals() const; 00123 int axisDecimals(int axisIndex) const; 00124 MovementType movementType() const; 00125 bool movementTypeVisible() const; 00126 bool axisEnabled(int axisIndex) const; 00127 QString arbitraryUnit() const; 00128 00129 private: 00130 void retValToMessageBox(const ito::RetVal &retval, const QString &methodName) const; 00131 QString suffixFromAxisUnit(const AxisUnit &unit) const; 00132 double baseUnitToUnit(const double &value, const AxisUnit &unit) const; 00133 double unitToBaseUnit(const double &value, const AxisUnit &unit) const; 00134 ito::RetVal observeInvocation(ItomSharedSemaphore *waitCond) const; 00135 void moveRelOrAbs(int axis, double value, bool relNotAbs); 00136 00137 MotorAxisControllerPrivate *d; 00138 00139 public slots: 00140 virtual void actuatorStatusChanged(QVector<int> status, QVector<double> actPosition); 00141 virtual void targetChanged(QVector<double> targetPositions); 00142 00143 ito::RetVal setAxisUnit(int axisIndex, AxisUnit unit); 00144 ito::RetVal setAxisEnabled(int axisIndex, bool enabled); 00145 ito::RetVal setAxisDecimals(int axisIndex, int decimals); 00146 ito::RetVal setAxisType(int axisIndex, AxisType type); 00147 ito::RetVal setAxisName(int axisIndex, const QString &name); 00148 00149 void setDefaultAxisUnit(AxisUnit unit); 00150 void setMovementTypeVisible(bool visible); 00151 void setMovementType(MovementType type); 00152 void setDefaultDecimals(int decimals); 00153 void setAxisNames(const QStringList &names); 00154 void setDefaultRelativeStepSize(double defaultRelativeStepSize); /*in mm or degree*/ 00155 void setCancelAvailable(bool available); 00156 void setStartAllAvailable(bool available); 00157 void setRefreshAvailable(bool available); 00158 void setDefaultAxisType(AxisType type); 00159 void setNumAxis(int numAxis); 00160 void setArbitraryUnit(const QString &unit); 00161 00162 ito::AutoInterval stepSizeInterval(int axisIndex) const; 00163 ito::AutoInterval targetInterval(int axisIndex) const; 00164 00165 ito::RetVal setStepSizeInterval(int axisIndex, const ito::AutoInterval &interval); 00166 ito::RetVal setTargetInterval(int axisIndex, const ito::AutoInterval &interval); 00167 00168 00169 private slots: 00170 void on_btnCancel_clicked(); 00171 void on_btnStart_clicked(); 00172 void on_btnRefresh_clicked(); 00173 void on_comboType_currentIndexChanged(int index); 00174 void stepUpClicked(int index); 00175 void stepDownClicked(int index); 00176 void runSingleClicked(int index); 00177 void customContextMenuRequested(const QPoint &pos); 00178 }; 00179 00180 #endif