itom
Loading...
Searching...
No Matches
motorAxisController.h
1/* ********************************************************************
2 itom software
3 URL: http://www.uni-stuttgart.de/ito
4 Copyright (C) 2020, Institut für Technische Optik (ITO),
5 Universität Stuttgart, Germany
6
7 This file is part of itom and its software development toolkit (SDK).
8
9 itom is free software; you can redistribute it and/or modify it
10 under the terms of the GNU Library General Public Licence as published by
11 the Free Software Foundation; either version 2 of the Licence, or (at
12 your option) any later version.
13
14 In addition, as a special exception, the Institut für Technische
15 Optik (ITO) gives you certain additional rights.
16 These rights are described in the ITO LGPL Exception version 1.0,
17 which can be found in the file LGPL_EXCEPTION.txt in this package.
18
19 itom is distributed in the hope that it will be useful, but
20 WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library
22 General Public Licence for more details.
23
24 You should have received a copy of the GNU Library General Public License
25 along with itom. If not, see <http://www.gnu.org/licenses/>.
26*********************************************************************** */
27
28#ifndef MOTORAXISCONTROLLER_H
29#define MOTORAXISCONTROLLER_H
30
31
32#include "commonWidgets.h"
33#include <qwidget.h>
34#include <qstring.h>
35#include <qpoint.h>
36#include <qpointer.h>
37#include <qcolor.h>
38#include <qstringlist.h>
39#include "common/retVal.h"
40#include "common/interval.h"
41
42#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
43// https://stackoverflow.com/questions/66581395/q-property-must-be-fully-defined-error-in-qt-6
44Q_MOC_INCLUDE("common/addInInterface.h")
45#endif
46
47class ItomSharedSemaphore; //forward declaration
48
49class MotorAxisControllerPrivate; //forward declaration
50
51namespace ito {
52 class AddInActuator; //forward declaration
53
54};
55
56class ITOMWIDGETS_EXPORT MotorAxisController : public QWidget
57{
58 Q_OBJECT
59
60 Q_PROPERTY(QPointer<ito::AddInActuator> actuator READ actuator WRITE setActuator)
61 Q_PROPERTY(int numAxis READ numAxis WRITE setNumAxis)
62 Q_PROPERTY(AxisUnit defaultAxisUnit READ defaultAxisUnit WRITE setDefaultAxisUnit)
63 Q_PROPERTY(AxisType defaultAxisType READ defaultAxisType WRITE setDefaultAxisType)
64 Q_PROPERTY(bool refreshAvailable READ refreshAvailable WRITE setRefreshAvailable)
65 Q_PROPERTY(bool cancelAvailable READ cancelAvailable WRITE setCancelAvailable)
66 Q_PROPERTY(bool startAllAvailable READ startAllAvailable WRITE setStartAllAvailable)
67 Q_PROPERTY(double defaultRelativeStepSize READ defaultRelativeStepSize WRITE setDefaultRelativeStepSize)
68 Q_PROPERTY(QStringList axisNames READ axisNames WRITE setAxisNames)
69 Q_PROPERTY(int defaultDecimals READ defaultDecimals WRITE setDefaultDecimals)
70 Q_PROPERTY(MovementType movementType READ movementType WRITE setMovementType)
71 Q_PROPERTY(bool movementTypeVisible READ movementTypeVisible WRITE setMovementTypeVisible)
72 Q_PROPERTY(QString arbitraryUnit READ arbitraryUnit WRITE setArbitraryUnit)
73 Q_PROPERTY(QColor backgroundColorMoving READ backgroundColorMoving WRITE setBackgroundColorMoving)
74 Q_PROPERTY(QColor backgroundColorInterrupted READ backgroundColorInterrupted WRITE setBackgroundColorInterrupted)
75 Q_PROPERTY(QColor backgroundColorTimeout READ backgroundColorTimeout WRITE setBackgroundColorTimeout)
76
77 Q_CLASSINFO("prop://actuator", "Actuator instance that is monitored and controlled by this widget (or None in order to remove a previous actuator).")
78 Q_CLASSINFO("prop://numAxis", "Number of axes that are monitored.")
79 Q_CLASSINFO("prop://defaultAxisUnit", "Default unit for all axes. A different unit can be set for distinct axes using the slot 'setAxisUnit'.")
80 Q_CLASSINFO("prop://defaultAxisType", "Default type for all axes. A different type can be set for any axis using the slot 'setAxisType'.")
81 Q_CLASSINFO("prop://refreshAvailable", "Hide or show a button to manually refresh the positions of all covered axes.")
82 Q_CLASSINFO("prop://cancelAvailable", "Hide or show a button to cancel a running movement of any axis (should only be used, if the specific actuator is able to handle interrupts).")
83 Q_CLASSINFO("prop://startAllAvailable", "Hide or show a button to start a simultaneous movement of all covered axes to their current target positions.")
84 Q_CLASSINFO("prop://defaultRelativeStepSize", "Default relative step size for all axes (in mm or degree, depending on their types).")
85 Q_CLASSINFO("prop://axisNames", "Names of all axes as string list.")
86 Q_CLASSINFO("prop://defaultDecimals", "Default number of decimals of all axes. The number of decimals can also be set individually for each axis using the slot 'setAxisDecimals'.")
87 Q_CLASSINFO("prop://movementType", "Style of the widget depending if it should be optimized for an absolute movement, relative movement, both or no movement.")
88 Q_CLASSINFO("prop://movementTypeVisible", "Hide or show a combobox above the axes values that can be used to select an appropriate movement type.")
89 Q_CLASSINFO("prop://arbitraryUnit", "Unit name that is used for axes, whose unit is set to UnitAU (Arbitrary unit).")
90 Q_CLASSINFO("prop://backgroundColorMoving", "Background color for spinboxes of axes that are currently moving.")
91 Q_CLASSINFO("prop://backgroundColorInterrupted", "Background color for spinboxes of axes that were interrupted.")
92 Q_CLASSINFO("prop://backgroundColorTimeout", "Background color for spinboxes of axes that run into a timeout.")
93
94public:
95 enum AxisUnit {
96 UnitNm = 0,
97 UnitMum,
98 UnitMm,
99 UnitCm,
100 UnitM,
101 UnitDeg,
102 UnitAU /*Arbitrary unit*/
103 };
104
105 enum AxisType {
106 TypeRotational = 0,
107 TypeLinear = 1
108 };
109
110 enum MovementType {
111 MovementAbsolute = 0,
112 MovementRelative = 1,
113 MovementBoth = 2,
114 MovementNo = 3
115 };
116
117 //Q_ENUM exposes a meta object to the enumeration types, such that the key names for the enumeration
118 //values are always accessible.
119 Q_ENUM(AxisUnit);
120 Q_ENUM(AxisType);
121 Q_ENUM(MovementType);
122
123 MotorAxisController(QWidget *parent = NULL);
125
126 void setActuator(const QPointer<ito::AddInActuator> &actuator);
127 QPointer<ito::AddInActuator> actuator() const;
128
129 int numAxis() const;
130 AxisUnit axisUnit(int axisIndex) const;
131 AxisUnit defaultAxisUnit() const;
132 AxisType axisType(int axisIndex) const;
133 AxisType defaultAxisType() const;
134 bool refreshAvailable() const;
135 bool cancelAvailable() const;
136 bool startAllAvailable() const;
137 double defaultRelativeStepSize() const;
138 QStringList axisNames() const;
139 QString axisName(int axisIndex) const;
140 int defaultDecimals() const;
141 int axisDecimals(int axisIndex) const;
142 MovementType movementType() const;
143 bool movementTypeVisible() const;
144 bool axisEnabled(int axisIndex) const;
145 QString arbitraryUnit() const;
146
147 QColor backgroundColorMoving() const;
148 void setBackgroundColorMoving(const QColor &color);
149
150 QColor backgroundColorInterrupted() const;
151 void setBackgroundColorInterrupted(const QColor &color);
152
153 QColor backgroundColorTimeout() const;
154 void setBackgroundColorTimeout(const QColor &color);
155
156private:
157 void retValToMessageBox(const ito::RetVal &retval, const QString &methodName) const;
158 QString suffixFromAxisUnit(const AxisUnit &unit) const;
159 double baseUnitToUnit(const double &value, const AxisUnit &unit) const;
160 double unitToBaseUnit(const double &value, const AxisUnit &unit) const;
161 ito::RetVal observeInvocation(ItomSharedSemaphore *waitCond) const;
162 void moveRelOrAbs(int axis, double value, bool relNotAbs);
163
165
166public slots:
167 virtual void actuatorStatusChanged(QVector<int> status, QVector<double> actPosition);
168 virtual void targetChanged(QVector<double> targetPositions);
169
170 ito::RetVal setAxisUnit(int axisIndex, AxisUnit unit);
171 ito::RetVal setAxisEnabled(int axisIndex, bool enabled);
172 ito::RetVal setAxisDecimals(int axisIndex, int decimals);
173 ito::RetVal setAxisType(int axisIndex, AxisType type);
174 ito::RetVal setAxisName(int axisIndex, const QString &name);
175
176 void setDefaultAxisUnit(AxisUnit unit);
177 void setMovementTypeVisible(bool visible);
178 void setMovementType(MovementType type);
179 void setDefaultDecimals(int decimals);
180 void setAxisNames(const QStringList &names);
181 void setDefaultRelativeStepSize(double defaultRelativeStepSize); /*in mm or degree*/
182 void setCancelAvailable(bool available);
183 void setStartAllAvailable(bool available);
184 void setRefreshAvailable(bool available);
185 void setDefaultAxisType(AxisType type);
186 void setNumAxis(int numAxis);
187 void setArbitraryUnit(const QString &unit);
188
189 ito::AutoInterval stepSizeInterval(int axisIndex) const;
190 ito::AutoInterval targetInterval(int axisIndex) const;
191
192 ito::RetVal setStepSizeInterval(int axisIndex, const ito::AutoInterval &interval);
193 ito::RetVal setTargetInterval(int axisIndex, const ito::AutoInterval &interval);
194
195
196private slots:
197 void on_btnCancel_clicked();
198 void on_btnStart_clicked();
199 void on_btnRefresh_clicked();
200 void on_comboType_currentIndexChanged(int index);
201 void stepUpClicked(int index);
202 void stepDownClicked(int index);
203 void runSingleClicked(int index);
204 void customContextMenuRequested(const QPoint &pos);
205};
206
207#endif
semaphore which can be used for asynchronous thread communication. By using this class it is possible...
Definition sharedStructuresQt.h:58
Definition motorAxisController.h:57
Definition motorAxisController.cpp:46
class for a interval type containing a min-max-range and an auto-flag.
Definition interval.h:50
Class for managing status values (like errors or warning)
Definition retVal.h:54
Definition apiFunctionsGraph.cpp:40