Changeset View
Changeset View
Standalone View
Standalone View
src/core/atcore.cpp
Show First 20 Lines • Show All 370 Lines • ▼ Show 20 Line(s) | 341 | { | |||
---|---|---|---|---|---|
371 | connect(thread, &QThread::finished, printThread, &PrintThread::deleteLater); | 371 | connect(thread, &QThread::finished, printThread, &PrintThread::deleteLater); | ||
372 | if (!thread->isRunning()) { | 372 | if (!thread->isRunning()) { | ||
373 | thread->start(); | 373 | thread->start(); | ||
374 | } | 374 | } | ||
375 | } | 375 | } | ||
376 | 376 | | |||
377 | void AtCore::pushCommand(const QString &comm) | 377 | void AtCore::pushCommand(const QString &comm) | ||
378 | { | 378 | { | ||
379 | //Append command to the commandQueue | | |||
380 | d->commandQueue.append(comm); | 379 | d->commandQueue.append(comm); | ||
381 | if (d->ready) { | 380 | if (d->ready) { | ||
patrickelectric: You should use the gcode enum. | |||||
patrickelectric: m112 is not compatible in all firmwares. | |||||
Looking more into this i don't even need to do this since in the emergencyStop function the queue is cleared. rizzitello: Looking more into this i don't even need to do this since in the emergencyStop function the… | |||||
rizzitello: Adjusted to use GCode enum. Clear only happens when printing. | |||||
382 | //The printer is ready for a command now so push one. | 381 | //The printer is ready for a command now so push one. | ||
383 | processQueue(); | 382 | processQueue(); | ||
384 | } | 383 | } | ||
385 | } | 384 | } | ||
386 | 385 | | |||
387 | void AtCore::closeConnection() | 386 | void AtCore::closeConnection() | ||
388 | { | 387 | { | ||
389 | if (serialInitialized()) { | 388 | if (serialInitialized()) { | ||
▲ Show 20 Lines • Show All 66 Lines • ▼ Show 20 Line(s) | 451 | { | |||
456 | //Less chance of movement after the restart. | 455 | //Less chance of movement after the restart. | ||
457 | d->commandQueue.clear(); | 456 | d->commandQueue.clear(); | ||
458 | if (AtCore::state() == AtCore::BUSY) { | 457 | if (AtCore::state() == AtCore::BUSY) { | ||
459 | if (!d->sdCardPrinting) { | 458 | if (!d->sdCardPrinting) { | ||
460 | //Stop our running print thread | 459 | //Stop our running print thread | ||
461 | setState(AtCore::STOP); | 460 | setState(AtCore::STOP); | ||
462 | } | 461 | } | ||
463 | } | 462 | } | ||
464 | //push command through serial to bypass atcore's queue. | 463 | pushCommand(GCode::toCommand(GCode::M112)); | ||
465 | serial()->pushCommand(GCode::toCommand(GCode::M112).toLocal8Bit()); | | |||
466 | } | 464 | } | ||
467 | 465 | | |||
468 | void AtCore::stopSdPrint() | 466 | void AtCore::stopSdPrint() | ||
469 | { | 467 | { | ||
470 | //Stop an SdCard Print. | 468 | //Stop an SdCard Print. | ||
471 | pushCommand(GCode::toCommand(GCode::M25)); | 469 | pushCommand(GCode::toCommand(GCode::M25)); | ||
472 | d->sdCardFileName = QString(); | 470 | d->sdCardFileName = QString(); | ||
473 | pushCommand(GCode::toCommand(GCode::M23, d->sdCardFileName)); | 471 | pushCommand(GCode::toCommand(GCode::M23, d->sdCardFileName)); | ||
474 | AtCore::setState(AtCore::FINISHEDPRINT); | 472 | AtCore::setState(AtCore::FINISHEDPRINT); | ||
475 | AtCore::setState(AtCore::IDLE); | 473 | AtCore::setState(AtCore::IDLE); | ||
476 | } | 474 | } | ||
477 | 475 | | |||
478 | void AtCore::requestFirmware() | 476 | void AtCore::requestFirmware() | ||
479 | { | 477 | { | ||
480 | if (serialInitialized()) { | 478 | if (serialInitialized()) { | ||
479 | //ensure M115 is sent on cold connect. | ||||
480 | d->ready = true; | ||||
481 | qCDebug(ATCORE_CORE) << "Sending " << GCode::description(GCode::M115); | 481 | qCDebug(ATCORE_CORE) << "Sending " << GCode::description(GCode::M115); | ||
482 | serial()->pushCommand(GCode::toCommand(GCode::M115).toLocal8Bit()); | 482 | pushCommand(GCode::toCommand(GCode::M115)); | ||
483 | } else { | 483 | } else { | ||
484 | qCDebug(ATCORE_CORE) << "There is no open device to send commands"; | 484 | qCDebug(ATCORE_CORE) << "There is no open device to send commands"; | ||
485 | } | 485 | } | ||
486 | } | 486 | } | ||
487 | 487 | | |||
488 | bool AtCore::firmwarePluginLoaded() const | 488 | bool AtCore::firmwarePluginLoaded() const | ||
489 | { | 489 | { | ||
490 | if (firmwarePlugin()) { | 490 | if (firmwarePlugin()) { | ||
▲ Show 20 Lines • Show All 364 Lines • Show Last 20 Lines |
You should use the gcode enum.