File indexing completed on 2024-10-13 04:13:44
0001 /* AtCore KDE Libary for 3D Printers 0002 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0003 SPDX-FileCopyrightText: 2016 Lays Rodrigues <lays.rodrigues@kde.org> 0004 SPDX-FileCopyrightText: 2016 Patrick José Pereira <patrickjp@kde.org> 0005 SPDX-FileCopyrightText: 2016, 2018 Tomaz Canabrava <tcanabrava@kde.org> 0006 SPDX-FileCopyrightText: 2016-2020 Chris Rizzitello <rizzitello@kde.org> 0007 */ 0008 0009 #pragma once 0010 0011 #include <QObject> 0012 0013 #include "atcore_export.h" 0014 0015 /** 0016 * @brief The GCode class 0017 * Provides Descriptions and Commands strings for G and M Commands 0018 */ 0019 class ATCORE_EXPORT GCode 0020 { 0021 Q_GADGET 0022 friend class GCodeTests; 0023 0024 public: 0025 /** 0026 * @brief The GCommands enum 0027 */ 0028 enum GCommands { G0, G1, G2, G3, G4, G10 = 10, G11, G20 = 20, G21, G22, G23, G28 = 28, G29, G30, G31, G32, G33, G90 = 90, G91, G92, G100 = 100, G130 = 130, G131, G132, G133, G161 = 161, G162 }; 0029 Q_ENUM(GCommands) 0030 0031 /** 0032 * @brief The MCommands enum 0033 */ 0034 enum MCommands { 0035 M0, 0036 M1, 0037 M2, 0038 M6 = 6, 0039 M17 = 17, 0040 M18, 0041 M20 = 20, 0042 M21, 0043 M22, 0044 M23, 0045 M24, 0046 M25, 0047 M26, 0048 M27, 0049 M28, 0050 M29, 0051 M30, 0052 M31, 0053 M32, 0054 M33, 0055 M34, 0056 M36 = 36, 0057 M37, 0058 M38, 0059 M40 = 40, 0060 M41, 0061 M42, 0062 M43, 0063 M48 = 48, 0064 M70 = 70, 0065 M72 = 72, 0066 M73, 0067 M80 = 80, 0068 M81, 0069 M82, 0070 M83, 0071 M84, 0072 M85, 0073 M92 = 92, 0074 M93, 0075 M98 = 98, 0076 M99, 0077 M101 = 101, 0078 M102, 0079 M103, 0080 M104, 0081 M105, 0082 M106, 0083 M107, 0084 M108, 0085 M109, 0086 M110, 0087 M111, 0088 M112, 0089 M113, 0090 M114, 0091 M115, 0092 M116, 0093 M117, 0094 M118, 0095 M119, 0096 M120, 0097 M121, 0098 M122, 0099 M123, 0100 M124, 0101 M126 = 126, 0102 M127, 0103 M128, 0104 M129, 0105 M130, 0106 M131, 0107 M132, 0108 M133, 0109 M134, 0110 M135, 0111 M136, 0112 M140 = 140, 0113 M141, 0114 M142, 0115 M143, 0116 M144, 0117 M146 = 146, 0118 M149 = 149, 0119 M150 = 150, 0120 M155 = 155, 0121 M160 = 160, 0122 M163 = 163, 0123 M164 = 164, 0124 M190 = 190, 0125 M191, 0126 M200 = 200, 0127 M201, 0128 M202, 0129 M203, 0130 M204, 0131 M205, 0132 M206, 0133 M207, 0134 M208, 0135 M209, 0136 M210, 0137 M211, 0138 M212, 0139 M218 = 218, 0140 M220 = 220, 0141 M221, 0142 M222, 0143 M223, 0144 M224, 0145 M225, 0146 M226, 0147 M227, 0148 M228, 0149 M229, 0150 M230, 0151 M231, 0152 M232, 0153 M240 = 240, 0154 M241, 0155 M245 = 245, 0156 M246, 0157 M250 = 250, 0158 M251, 0159 M280 = 280, 0160 M300 = 300, 0161 M301, 0162 M302, 0163 M303, 0164 M304, 0165 M305, 0166 M306, 0167 M320 = 320, 0168 M321, 0169 M322, 0170 M323, 0171 M340 = 340, 0172 M350 = 350, 0173 M351, 0174 M355 = 355, 0175 M360 = 360, 0176 M361, 0177 M362, 0178 M363, 0179 M364, 0180 M365, 0181 M366, 0182 M370 = 370, 0183 M371, 0184 M372, 0185 M373, 0186 M374, 0187 M375, 0188 M380 = 380, 0189 M381, 0190 M400 = 400, 0191 M401, 0192 M402, 0193 M404 = 404, 0194 M405, 0195 M406, 0196 M407, 0197 M408, 0198 M420 = 420, 0199 M421, 0200 M450 = 450, 0201 M451, 0202 M452, 0203 M453, 0204 M460 = 460, 0205 M500 = 500, 0206 M501, 0207 M502, 0208 M503, 0209 M540 = 540, 0210 M550 = 550, 0211 M551, 0212 M552, 0213 M553, 0214 M554, 0215 M555, 0216 M556, 0217 M557, 0218 M558, 0219 M559, 0220 M560, 0221 M561, 0222 M562, 0223 M563, 0224 M564, 0225 M565, 0226 M566, 0227 M567, 0228 M568, 0229 M569, 0230 M570, 0231 M571, 0232 M572, 0233 M573, 0234 M574, 0235 M575, 0236 M577 = 577, 0237 M578, 0238 M579, 0239 M580 = 580, 0240 M581, 0241 M582, 0242 M583, 0243 M584, 0244 M600 = 600, 0245 M605 = 605, 0246 M665 = 665, 0247 M666 = 666, 0248 M667, 0249 M668, 0250 M700 = 700, 0251 M701, 0252 M702, 0253 M703, 0254 M710 = 710, 0255 M800 = 800, 0256 M801, 0257 M851 = 851, 0258 M906 = 906, 0259 M907, 0260 M908, 0261 M910 = 910, 0262 M911, 0263 M912, 0264 M913, 0265 M928 = 928, 0266 M997 = 997, 0267 M998, 0268 M999 0269 }; 0270 Q_ENUM(MCommands) 0271 0272 /** 0273 * @brief Return Description of command \p gcode 0274 * @param gcode: Command to describe 0275 * @return description of GCommand 0276 */ 0277 static QString description(GCommands gcode); 0278 0279 /** 0280 * @brief Return Description of command \p gcode 0281 * @param gcode: Command to describe 0282 * @return description of MCommand 0283 */ 0284 static QString description(MCommands gcode); 0285 /** 0286 * @brief Convert GCode::GCommands to command 0287 * @param gcode: GCode::GCommands 0288 * @param value1: Value of argument 0289 * @return Command String to send to printer 0290 */ 0291 static QString toCommand(GCommands gcode, const QString &value1 = QString()); 0292 0293 /** 0294 * @brief Convert GCode::MCommands to command 0295 * @param gcode: GCode::MCommands 0296 * @param value1: Value of argument 1 0297 * @param value2: Value of argument 2 0298 * @return Command String to send to printer 0299 */ 0300 static QString toCommand(MCommands gcode, const QString &value1 = QString(), const QString &value2 = QString()); 0301 0302 protected: 0303 static const QString commandRequiresArgument; 0304 static const QString commandNotSupported; 0305 };