Changeset View
Changeset View
Standalone View
Standalone View
src/core/atcore.h
1 | /* AtCore | 1 | /* AtCore | ||
---|---|---|---|---|---|
2 | Copyright (C) <2016 - 2018> | 2 | Copyright (C) <2016 - 2019> | ||
3 | 3 | | |||
4 | Authors: | 4 | Authors: | ||
5 | Tomaz Canabrava <tcanabrava@kde.org> | 5 | Tomaz Canabrava <tcanabrava@kde.org> | ||
6 | Chris Rizzitello <rizzitello@kde.org> | 6 | Chris Rizzitello <rizzitello@kde.org> | ||
7 | Patrick José Pereira <patrickjp@kde.org> | 7 | Patrick José Pereira <patrickjp@kde.org> | ||
8 | Lays Rodrigues <lays.rodrigues@kde.org> | 8 | Lays Rodrigues <lays.rodrigues@kde.org> | ||
9 | 9 | | |||
10 | This library is free software; you can redistribute it and/or | 10 | This library is free software; you can redistribute it and/or | ||
Show All 26 Lines | |||||
37 | class IFirmware; | 37 | class IFirmware; | ||
38 | class QTime; | 38 | class QTime; | ||
39 | 39 | | |||
40 | /** | 40 | /** | ||
41 | * @brief The AtCore class | 41 | * @brief The AtCore class | ||
42 | * aims to provides a high level interface for serial based gcode devices<br /> | 42 | * aims to provides a high level interface for serial based gcode devices<br /> | ||
43 | * | 43 | * | ||
44 | * #### General Workflow | 44 | * #### General Workflow | ||
45 | * - Connect to a serial port with initSerial() | 45 | * - Connect to a serial port with newConnection() | ||
46 | * - Firmware will be auto detected. Use loadFirmwarePLugin() to force load a firmware. | | |||
47 | * - Send commands to the device (pushCommand(),print(),...) | 46 | * - Send commands to the device (pushCommand(), print(), ...) | ||
48 | * - AtCore::close() when you are all done. | 47 | * - AtCore::close() when you are all done. | ||
49 | 48 | | |||
50 | * #### How AtCore Finds Plugins. | 49 | * #### How AtCore Finds Plugins. | ||
51 | * AtCore will check each directory below for plugins. | 50 | * AtCore will check each directory below for plugins. | ||
52 | * 1. QApplication::applicationDirPath/plugins (runtime) | 51 | * 1. QApplication::applicationDirPath/plugins (runtime) | ||
53 | * 2. QApplication::applicationDirPath/AtCore (runtime) | 52 | * 2. QApplication::applicationDirPath/AtCore (runtime) | ||
54 | * 3. QApplication::applicationDirPath/../PlugIns/AtCore (runtime) | 53 | * 3. QApplication::applicationDirPath/../PlugIns/AtCore (runtime) | ||
55 | * 4. Fullpath of KDE_PLUGIN_DIR (buildtime) | 54 | * 4. Fullpath of KDE_PLUGIN_DIR (buildtime) | ||
▲ Show 20 Lines • Show All 71 Lines • ▼ Show 20 Line(s) | 84 | public: | |||
127 | * @brief version | 126 | * @brief version | ||
128 | * @return Version number | 127 | * @return Version number | ||
129 | */ | 128 | */ | ||
130 | QString version() const; | 129 | QString version() const; | ||
131 | 130 | | |||
132 | /** | 131 | /** | ||
133 | * @brief Returns a List of detected serial ports | 132 | * @brief Returns a List of detected serial ports | ||
134 | * @return List of detected ports | 133 | * @return List of detected ports | ||
135 | * @sa initSerial(),serial(),closeConnection() | 134 | * @sa newConnection(), serial(), closeConnection() | ||
136 | */ | 135 | */ | ||
137 | QStringList serialPorts() const; | 136 | QStringList serialPorts() const; | ||
138 | 137 | | |||
139 | /** | 138 | /** | ||
140 | * @brief connectedPort | 139 | * @brief connectedPort | ||
141 | * @return the port atcore is connected to or empty string if none | 140 | * @return the port atcore is connected to or empty string if none | ||
142 | */ | 141 | */ | ||
143 | QString connectedPort() const; | 142 | QString connectedPort() const; | ||
144 | 143 | | |||
145 | /** | 144 | /** | ||
146 | * @brief Initialize a connection to \p port at a speed of \p baud <br /> | 145 | * @brief Connect to a device. | ||
147 | * @param port: the port to initialize | 146 | * @param port: the port to initialize | ||
148 | * @param baud: the baud of the port | 147 | * @param baud: the baud of the port | ||
148 | * @param fwName: Firmware name of plugin to use (will try to autodetect if fwName is unknown) | ||||
yurchor: Doxygen complains that "fwPlugin" is an unknown variable which seems to be right when looking… | |||||
149 | * @param disableROC: atcore will attempt to disable reset on connect for this device. | 149 | * @param disableROC: atcore will attempt to disable reset on connect for this device. | ||
150 | * @return True is connection was successful | 150 | * @return True is connection was successful | ||
151 | * @sa serialPorts(),serial(),closeConnection() | 151 | * @sa serialPorts(), serial(), closeConnection() | ||
152 | */ | 152 | */ | ||
153 | Q_INVOKABLE bool initSerial(const QString &port, int baud, bool disableROC = false); | 153 | Q_INVOKABLE bool newConnection(const QString &port, int baud, const QString &fwName, bool disableROC = false); | ||
154 | 154 | | |||
155 | /** | 155 | /** | ||
156 | * @brief Returns a list of valid baud speeds | 156 | * @brief Returns a list of valid baud speeds | ||
157 | */ | 157 | */ | ||
158 | QStringList portSpeeds() const; | 158 | QStringList portSpeeds() const; | ||
159 | 159 | | |||
160 | /** | 160 | /** | ||
161 | * @brief Close the current serial connection | 161 | * @brief Close the current serial connection | ||
162 | * @sa initSerial(),serial(),serialPorts(),AtCore::close() | 162 | * @sa newConnection(), serial(), serialPorts(), close() | ||
163 | */ | 163 | */ | ||
164 | Q_INVOKABLE void closeConnection(); | 164 | Q_INVOKABLE void closeConnection(); | ||
165 | 165 | | |||
166 | /** | 166 | /** | ||
167 | * @brief Main access to the loaded firmware plugin | 167 | * @brief Main access to the loaded firmware plugin | ||
168 | * @return IFirmware * to currently loaded plugin | 168 | * @return IFirmware * to currently loaded plugin | ||
169 | * @sa availableFirmwarePlugins(),loadFirmwarePlugin() | 169 | * @sa availableFirmwarePlugins(), loadFirmwarePlugin() | ||
170 | */ | 170 | */ | ||
171 | Q_INVOKABLE IFirmware *firmwarePlugin() const; | 171 | Q_INVOKABLE IFirmware *firmwarePlugin() const; | ||
172 | 172 | | |||
173 | /** | 173 | /** | ||
174 | * @brief List of available firmware plugins | 174 | * @brief List of available firmware plugins | ||
175 | * @sa loadFirmwarePlugin(),firmwarePlugin() | 175 | * @sa loadFirmwarePlugin(), firmwarePlugin() | ||
176 | */ | 176 | */ | ||
177 | QStringList availableFirmwarePlugins() const; | 177 | QStringList availableFirmwarePlugins() const; | ||
178 | 178 | | |||
179 | /** | 179 | /** | ||
180 | * @brief Load A firmware plugin | | |||
181 | * @param fwName : name of the firmware | | |||
182 | * @sa firmwarePlugin(),availableFirmwarePlugins() | | |||
183 | */ | | |||
184 | Q_INVOKABLE void loadFirmwarePlugin(const QString &fwName); | | |||
185 | | ||||
186 | /** | | |||
187 | * @brief Get Printer state | 180 | * @brief Get Printer state | ||
188 | * @return State of the printer | 181 | * @return State of the printer | ||
189 | * @sa setState(),stateChanged(),AtCore::STATES | 182 | * @sa setState(), stateChanged(), AtCore::STATES | ||
190 | */ | 183 | */ | ||
191 | AtCore::STATES state(); | 184 | AtCore::STATES state(); | ||
192 | 185 | | |||
193 | /** | 186 | /** | ||
194 | * @brief extruderCount | 187 | * @brief extruderCount | ||
195 | * @return The number of detected Extruders Default is 1 | 188 | * @return The number of detected Extruders Default is 1 | ||
196 | * @sa setExtruderCount(int newCount), extruderCountChanged(int newCount) | 189 | * @sa setExtruderCount(int newCount), extruderCountChanged(int newCount) | ||
197 | */ | 190 | */ | ||
▲ Show 20 Lines • Show All 87 Lines • ▼ Show 20 Line(s) | 238 | signals: | |||
285 | * @brief New interval for temperature timer | 278 | * @brief New interval for temperature timer | ||
286 | * @sa setTemperatureTimerInterval() | 279 | * @sa setTemperatureTimerInterval() | ||
287 | */ | 280 | */ | ||
288 | void temperatureTimerIntervalChanged(const int newTime); | 281 | void temperatureTimerIntervalChanged(const int newTime); | ||
289 | 282 | | |||
290 | /** | 283 | /** | ||
291 | * @brief The Printer's State Changed | 284 | * @brief The Printer's State Changed | ||
292 | * @param newState : the new state of the printer | 285 | * @param newState : the new state of the printer | ||
293 | * @sa setState(),state(),AtCore::STATES | 286 | * @sa setState(), state(), AtCore::STATES | ||
294 | */ | 287 | */ | ||
295 | void stateChanged(AtCore::STATES newState); | 288 | void stateChanged(AtCore::STATES newState); | ||
296 | 289 | | |||
297 | /** | 290 | /** | ||
298 | * @brief Available serialports Changed | 291 | * @brief Available serialports Changed | ||
299 | */ | 292 | */ | ||
300 | void portsChanged(const QStringList &portList); | 293 | void portsChanged(const QStringList &portList); | ||
301 | 294 | | |||
Show All 13 Lines | |||||
315 | */ | 308 | */ | ||
316 | void pushedCommand(const QByteArray &comm); | 309 | void pushedCommand(const QByteArray &comm); | ||
317 | 310 | | |||
318 | public slots: | 311 | public slots: | ||
319 | 312 | | |||
320 | /** | 313 | /** | ||
321 | * @brief Set the printers state | 314 | * @brief Set the printers state | ||
322 | * @param state : printer state. | 315 | * @param state : printer state. | ||
323 | * @sa state(),stateChanged(),AtCore::STATES | 316 | * @sa state(), stateChanged(), AtCore::STATES | ||
324 | */ | 317 | */ | ||
325 | void setState(AtCore::STATES state); | 318 | void setState(AtCore::STATES state); | ||
326 | 319 | | |||
327 | /** | 320 | /** | ||
328 | * @brief Push a command into the command queue | 321 | * @brief Push a command into the command queue | ||
329 | * | 322 | * | ||
330 | * @param comm : Command | 323 | * @param comm : Command | ||
331 | */ | 324 | */ | ||
332 | Q_INVOKABLE void pushCommand(const QString &comm); | 325 | Q_INVOKABLE void pushCommand(const QString &comm); | ||
333 | 326 | | |||
334 | /** | 327 | /** | ||
335 | * @brief Public Interface for printing a file | 328 | * @brief Public Interface for printing a file | ||
336 | * @param fileName: the gcode file to print. | 329 | * @param fileName: the gcode file to print. | ||
337 | * @param sdPrint: set true to print fileName from Sd card | 330 | * @param sdPrint: set true to print fileName from Sd card | ||
338 | */ | 331 | */ | ||
339 | Q_INVOKABLE void print(const QString &fileName, bool sdPrint = false); | 332 | Q_INVOKABLE void print(const QString &fileName, bool sdPrint = false); | ||
340 | 333 | | |||
341 | /** | 334 | /** | ||
342 | * @brief Stop the Printer by empting the queue and aborting the print job (if running) | 335 | * @brief Stop the Printer by empting the queue and aborting the print job (if running) | ||
343 | * @sa emergencyStop(),pause(),resume() | 336 | * @sa emergencyStop(), pause(), resume() | ||
344 | */ | 337 | */ | ||
345 | Q_INVOKABLE void stop(); | 338 | Q_INVOKABLE void stop(); | ||
346 | 339 | | |||
347 | /** | 340 | /** | ||
348 | * @brief stop the printer via the emergency stop Command (M112) | 341 | * @brief stop the printer via the emergency stop Command (M112) | ||
349 | * @sa stop(),pause(),resume() | 342 | * @sa stop(), pause(), resume() | ||
350 | */ | 343 | */ | ||
351 | Q_INVOKABLE void emergencyStop(); | 344 | Q_INVOKABLE void emergencyStop(); | ||
352 | 345 | | |||
353 | /** | 346 | /** | ||
354 | * @brief pause an in process print job | 347 | * @brief pause an in process print job | ||
355 | * | 348 | * | ||
356 | * Sends M114 on pause to store the location where the head stoped. | 349 | * Sends M114 on pause to store the location where the head stoped. | ||
357 | * This is known to cause problems on fake printers | 350 | * This is known to cause problems on fake printers | ||
358 | * @param pauseActions: Gcode to run after pausing commands are ',' separated | 351 | * @param pauseActions: Gcode to run after pausing commands are ',' separated | ||
359 | * @sa resume(),stop(),emergencyStop() | 352 | * @sa resume(), stop(), emergencyStop() | ||
360 | */ | 353 | */ | ||
361 | void pause(const QString &pauseActions); | 354 | void pause(const QString &pauseActions); | ||
362 | 355 | | |||
363 | /** | 356 | /** | ||
364 | * @brief resume a paused print job. | 357 | * @brief resume a paused print job. | ||
365 | * After returning to location pause was triggered. | 358 | * After returning to location pause was triggered. | ||
366 | * @sa pause(),stop(),emergencyStop() | 359 | * @sa pause(), stop(), emergencyStop() | ||
367 | */ | 360 | */ | ||
368 | Q_INVOKABLE void resume(); | 361 | Q_INVOKABLE void resume(); | ||
369 | 362 | | |||
370 | /** | 363 | /** | ||
371 | * @brief Send home \p axis command | 364 | * @brief Send home \p axis command | ||
372 | * @param axis: the axis(es) to home (use X Y Z or any combo of) | 365 | * @param axis: the axis(es) to home (use X Y Z or any combo of) | ||
373 | * @sa home(), move() | 366 | * @sa home(), move() | ||
374 | */ | 367 | */ | ||
▲ Show 20 Lines • Show All 163 Lines • ▼ Show 20 Line(s) | 487 | private slots: | |||
538 | void getSDFileList(); | 531 | void getSDFileList(); | ||
539 | 532 | | |||
540 | /** | 533 | /** | ||
541 | * @brief Handle serial Errors. | 534 | * @brief Handle serial Errors. | ||
542 | */ | 535 | */ | ||
543 | void handleSerialError(QSerialPort::SerialPortError error); | 536 | void handleSerialError(QSerialPort::SerialPortError error); | ||
544 | 537 | | |||
545 | private: | 538 | private: | ||
539 | | ||||
540 | /** | ||||
541 | * @brief Load A firmware plugin | ||||
542 | * @param fwName : name of the firmware | ||||
543 | * @sa firmwarePlugin(), availableFirmwarePlugins() | ||||
yurchor: It's a very minor problem (and not yours, but all AtCore Doxygen docs) but comma lists without… | |||||
rizzitello: I fixed it for the whole file. Thanks for the catch | |||||
544 | */ | ||||
545 | Q_INVOKABLE void loadFirmwarePlugin(const QString &fwName); | ||||
546 | | ||||
546 | /** | 547 | /** | ||
547 | * @brief True if a firmware plugin is loaded | 548 | * @brief True if a firmware plugin is loaded | ||
548 | */ | 549 | */ | ||
549 | bool firmwarePluginLoaded() const; | 550 | bool firmwarePluginLoaded() const; | ||
550 | 551 | | |||
551 | /** | 552 | /** | ||
552 | * @brief True if a serial port is initialized | 553 | * @brief True if a serial port is initialized | ||
553 | */ | 554 | */ | ||
Show All 14 Lines | |||||
568 | /** | 569 | /** | ||
569 | * @brief returns AtCorePrivate::sdCardReadingFileList | 570 | * @brief returns AtCorePrivate::sdCardReadingFileList | ||
570 | * @return True if printer is returning sd card file list | 571 | * @return True if printer is returning sd card file list | ||
571 | */ | 572 | */ | ||
572 | bool isReadingSdCardList() const; | 573 | bool isReadingSdCardList() const; | ||
573 | 574 | | |||
574 | /** | 575 | /** | ||
575 | * @brief stops print just for sd prints used internally | 576 | * @brief stops print just for sd prints used internally | ||
576 | * @sa stop(),emergencyStop() | 577 | * @sa stop(), emergencyStop() | ||
577 | */ | 578 | */ | ||
578 | void stopSdPrint(); | 579 | void stopSdPrint(); | ||
579 | 580 | | |||
580 | /** | 581 | /** | ||
582 | * @brief New connections need to wait for the machine to be ready if it needs reboot | ||||
583 | * @param message: message from the firmware | ||||
584 | * @param fwName: fwName to load | ||||
585 | */ | ||||
586 | void waitForPrinterReboot(const QByteArray &message, const QString &fwName); | ||||
587 | | ||||
588 | /** | ||||
581 | * @brief Hold private data of AtCore. | 589 | * @brief Hold private data of AtCore. | ||
582 | */ | 590 | */ | ||
583 | struct AtCorePrivate; | 591 | struct AtCorePrivate; | ||
584 | AtCorePrivate *d; | 592 | AtCorePrivate *d; | ||
585 | 593 | | |||
586 | protected: | 594 | protected: | ||
587 | /** | 595 | /** | ||
588 | * @brief Set the number of extruders on the machine. | 596 | * @brief Set the number of extruders on the machine. | ||
Show All 27 Lines |
Doxygen complains that "fwPlugin" is an unknown variable which seems to be right when looking into line 153.