Changeset View
Changeset View
Standalone View
Standalone View
src/core/atcore.cpp
Show First 20 Lines • Show All 58 Lines • ▼ Show 20 Line(s) | 50 | struct AtCore::AtCorePrivate { | |||
---|---|---|---|---|---|
59 | /** lastMessage: lastMessage from the printer */ | 59 | /** lastMessage: lastMessage from the printer */ | ||
60 | QByteArray lastMessage; | 60 | QByteArray lastMessage; | ||
61 | /** lastCommand: the last command sent to the printer */ | 61 | /** lastCommand: the last command sent to the printer */ | ||
62 | QString lastCommand; | 62 | QString lastCommand; | ||
63 | /** extruderCount: extruder count */ | 63 | /** extruderCount: extruder count */ | ||
64 | int extruderCount = 1; | 64 | int extruderCount = 1; | ||
65 | /** temperature: Temperature object */ | 65 | /** temperature: Temperature object */ | ||
66 | std::shared_ptr<Temperature> temperature = nullptr; | 66 | std::shared_ptr<Temperature> temperature = nullptr; | ||
67 | /** autoTemperatureReport: True if using auto Temperature Reporting*/ | ||||
68 | bool autoTemperatureReport = false; | ||||
67 | /** commandQueue: the list of commands to send to the printer */ | 69 | /** commandQueue: the list of commands to send to the printer */ | ||
68 | QStringList commandQueue; | 70 | QStringList commandQueue; | ||
69 | /** ready: True if printer is ready for a command */ | 71 | /** ready: True if printer is ready for a command */ | ||
70 | bool ready = false; | 72 | bool ready = false; | ||
71 | /** temperatureTimer: timer connected to the checkTemperature function */ | 73 | /** temperatureTimer: timer connected to the checkTemperature function */ | ||
72 | QTimer temperatureTimer; | 74 | QTimer temperatureTimer; | ||
73 | /** sdPrintProgressTimer: timer used to check in on sdJobs */ | 75 | /** sdPrintProgressTimer: timer used to check in on sdJobs */ | ||
74 | QTimer sdPrintProgressTimer; | 76 | QTimer sdPrintProgressTimer; | ||
▲ Show 20 Lines • Show All 269 Lines • ▼ Show 20 Line(s) | 341 | { | |||
344 | } | 346 | } | ||
345 | if (!newTime && d->temperatureTimer.isActive()) { | 347 | if (!newTime && d->temperatureTimer.isActive()) { | ||
346 | d->temperatureTimer.stop(); | 348 | d->temperatureTimer.stop(); | ||
347 | } else { | 349 | } else { | ||
348 | d->temperatureTimer.start(newTime); | 350 | d->temperatureTimer.start(newTime); | ||
349 | } | 351 | } | ||
350 | } | 352 | } | ||
351 | 353 | | |||
354 | void AtCore::setAutoTemperatureReport(bool autoReport) | ||||
355 | { | ||||
356 | if (autoReport == d->autoTemperatureReport) { | ||||
357 | return; | ||||
358 | } | ||||
359 | | ||||
patrickelectric: This should be after `d->autoTemperatureReport = autoReport` no ? | |||||
360 | d->autoTemperatureReport = autoReport; | ||||
361 | emit autoTemperatureReportChanged(autoReport); | ||||
362 | | ||||
363 | if (autoReport) { | ||||
364 | setTemperatureTimerInterval(0); | ||||
365 | d->commandQueue.removeAll(GCode::toCommand(GCode::M105)); | ||||
366 | setAutoCheckTemperatureInterval(5); | ||||
367 | } else { | ||||
368 | setAutoCheckTemperatureInterval(0); | ||||
369 | setTemperatureTimerInterval(5000); | ||||
370 | } | ||||
371 | | ||||
372 | } | ||||
373 | | ||||
374 | void AtCore::setAutoCheckTemperatureInterval(int newTime) | ||||
375 | { | ||||
376 | if (state() >= 2 && state() != AtCore::ERRORSTATE) { | ||||
377 | pushCommand(GCode::toCommand(GCode::M155, QString::number(newTime))); | ||||
378 | } | ||||
379 | emit autoCheckTemperatureIntervalChanged(newTime); | ||||
380 | } | ||||
381 | | ||||
382 | bool AtCore::autoTemperatureReport() const | ||||
383 | { | ||||
384 | return d->autoTemperatureReport; | ||||
385 | } | ||||
386 | | ||||
352 | void AtCore::newMessage(const QByteArray &message) | 387 | void AtCore::newMessage(const QByteArray &message) | ||
353 | { | 388 | { | ||
354 | d->lastMessage = message; | 389 | d->lastMessage = message; | ||
390 | if (d->lastMessage.contains(QString::fromLatin1("Cap:AUTOREPORT_TEMP:1").toLocal8Bit())) { | ||||
391 | setAutoTemperatureReport(true); | ||||
392 | } | ||||
393 | | ||||
355 | //Check if the message has current coordinates. | 394 | //Check if the message has current coordinates. | ||
356 | if (d->lastCommand.startsWith(GCode::toCommand(GCode::MCommands::M114)) | 395 | if (d->lastCommand.startsWith(GCode::toCommand(GCode::MCommands::M114)) | ||
357 | && d->lastMessage.startsWith(QString::fromLatin1("X:").toLocal8Bit())) { | 396 | && d->lastMessage.startsWith(QString::fromLatin1("X:").toLocal8Bit())) { | ||
358 | d->posString = message; | 397 | d->posString = message; | ||
359 | d->posString.resize(d->posString.indexOf('E')); | 398 | d->posString.resize(d->posString.indexOf('E')); | ||
360 | d->posString.replace(':', ""); | 399 | d->posString.replace(':', ""); | ||
361 | } | 400 | } | ||
362 | 401 | | |||
▲ Show 20 Lines • Show All 81 Lines • ▼ Show 20 Line(s) | 482 | if (serialInitialized()) { | |||
444 | if (AtCore::state() == AtCore::STATES::BUSY && !d->sdCardPrinting) { | 483 | if (AtCore::state() == AtCore::STATES::BUSY && !d->sdCardPrinting) { | ||
445 | //We have to clean up the print job if printing from the host. | 484 | //We have to clean up the print job if printing from the host. | ||
446 | //However disconnecting while printing from sd card should not affect the print job. | 485 | //However disconnecting while printing from sd card should not affect the print job. | ||
447 | setState(AtCore::STATES::STOP); | 486 | setState(AtCore::STATES::STOP); | ||
448 | } | 487 | } | ||
449 | if (firmwarePluginLoaded()) { | 488 | if (firmwarePluginLoaded()) { | ||
450 | disconnect(firmwarePlugin(), &IFirmware::readyForCommand, this, &AtCore::processQueue); | 489 | disconnect(firmwarePlugin(), &IFirmware::readyForCommand, this, &AtCore::processQueue); | ||
451 | disconnect(d->serial, &SerialLayer::receivedCommand, this, &AtCore::newMessage); | 490 | disconnect(d->serial, &SerialLayer::receivedCommand, this, &AtCore::newMessage); | ||
452 | if (firmwarePlugin()->name() != QStringLiteral("Grbl")) { | 491 | if (d->autoTemperatureReport) { | ||
453 | setTemperatureTimerInterval(0); | 492 | blockSignals(true); | ||
493 | setAutoTemperatureReport(false); | ||||
494 | blockSignals(false); | ||||
454 | } | 495 | } | ||
496 | setTemperatureTimerInterval(0); | ||||
455 | //Attempt to unload the firmware plugin. | 497 | //Attempt to unload the firmware plugin. | ||
456 | QString name = firmwarePlugin()->name(); | 498 | QString name = firmwarePlugin()->name(); | ||
457 | QString msg = d->pluginLoader.unload() ? QStringLiteral("closed.") : QStringLiteral("Failed to close."); | 499 | QString msg = d->pluginLoader.unload() ? QStringLiteral("closed.") : QStringLiteral("Failed to close."); | ||
458 | qCDebug(ATCORE_CORE) << QStringLiteral("Firmware plugin %1 %2").arg(name, msg); | 500 | qCDebug(ATCORE_CORE) << QStringLiteral("Firmware plugin %1 %2").arg(name, msg); | ||
459 | d->firmwarePlugin = nullptr; | 501 | d->firmwarePlugin = nullptr; | ||
460 | } | 502 | } | ||
461 | //Do not reset the connect on disconnect when closing this will cause a reset on connect for the next connection. | 503 | //Do not reset the connect on disconnect when closing this will cause a reset on connect for the next connection. | ||
462 | disconnect(d->serial, &SerialLayer::serialError, this, &AtCore::handleSerialError); | 504 | disconnect(d->serial, &SerialLayer::serialError, this, &AtCore::handleSerialError); | ||
▲ Show 20 Lines • Show All 447 Lines • Show Last 20 Lines |
This should be after d->autoTemperatureReport = autoReport no ?