Changeset View
Changeset View
Standalone View
Standalone View
src/core/atcore.cpp
Show First 20 Lines • Show All 371 Lines • ▼ Show 20 Line(s) | 342 | { | |||
---|---|---|---|---|---|
372 | connect(thread, &QThread::finished, printThread, &PrintThread::deleteLater); | 372 | connect(thread, &QThread::finished, printThread, &PrintThread::deleteLater); | ||
373 | if (!thread->isRunning()) { | 373 | if (!thread->isRunning()) { | ||
374 | thread->start(); | 374 | thread->start(); | ||
375 | } | 375 | } | ||
376 | } | 376 | } | ||
377 | 377 | | |||
378 | void AtCore::pushCommand(const QString &comm) | 378 | void AtCore::pushCommand(const QString &comm) | ||
379 | { | 379 | { | ||
380 | //Append command to the commandQueue | 380 | //Be sure our M112 is first in the queue. | ||
381 | if (comm == GCode::toCommand(GCode::MCommands::M112)) { | ||||
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 | d->commandQueue.prepend(comm); | ||||
383 | } else { | ||||
381 | d->commandQueue.append(comm); | 384 | d->commandQueue.append(comm); | ||
385 | } | ||||
382 | if (d->ready) { | 386 | if (d->ready) { | ||
383 | //The printer is ready for a command now so push one. | 387 | //The printer is ready for a command now so push one. | ||
384 | processQueue(); | 388 | processQueue(); | ||
385 | } | 389 | } | ||
386 | } | 390 | } | ||
387 | 391 | | |||
388 | void AtCore::closeConnection() | 392 | void AtCore::closeConnection() | ||
389 | { | 393 | { | ||
▲ Show 20 Lines • Show All 68 Lines • ▼ Show 20 Line(s) | 458 | { | |||
458 | //Less chance of movement after the restart. | 462 | //Less chance of movement after the restart. | ||
459 | d->commandQueue.clear(); | 463 | d->commandQueue.clear(); | ||
460 | if (AtCore::state() == AtCore::STATES::BUSY) { | 464 | if (AtCore::state() == AtCore::STATES::BUSY) { | ||
461 | if (!d->sdCardPrinting) { | 465 | if (!d->sdCardPrinting) { | ||
462 | //Stop our running print thread | 466 | //Stop our running print thread | ||
463 | setState(AtCore::STATES::STOP); | 467 | setState(AtCore::STATES::STOP); | ||
464 | } | 468 | } | ||
465 | } | 469 | } | ||
466 | //push command through serial to bypass atcore's queue. | 470 | pushCommand(GCode::toCommand(GCode::MCommands::M112)); | ||
467 | d->serial->pushCommand(GCode::toCommand(GCode::MCommands::M112).toLocal8Bit()); | | |||
468 | } | 471 | } | ||
469 | 472 | | |||
470 | void AtCore::stopSdPrint() | 473 | void AtCore::stopSdPrint() | ||
471 | { | 474 | { | ||
472 | //Stop an SdCard Print. | 475 | //Stop an SdCard Print. | ||
473 | pushCommand(GCode::toCommand(GCode::MCommands::M25)); | 476 | pushCommand(GCode::toCommand(GCode::MCommands::M25)); | ||
474 | d->sdCardFileName = QString(); | 477 | d->sdCardFileName = QString(); | ||
475 | pushCommand(GCode::toCommand(GCode::MCommands::M23, d->sdCardFileName)); | 478 | pushCommand(GCode::toCommand(GCode::MCommands::M23, d->sdCardFileName)); | ||
476 | AtCore::setState(AtCore::STATES::FINISHEDPRINT); | 479 | AtCore::setState(AtCore::STATES::FINISHEDPRINT); | ||
477 | AtCore::setState(AtCore::STATES::IDLE); | 480 | AtCore::setState(AtCore::STATES::IDLE); | ||
478 | } | 481 | } | ||
479 | 482 | | |||
480 | void AtCore::requestFirmware() | 483 | void AtCore::requestFirmware() | ||
481 | { | 484 | { | ||
482 | if (serialInitialized()) { | 485 | if (serialInitialized()) { | ||
486 | //ensure M115 is sent on cold connect. | ||||
487 | d->ready = true; | ||||
483 | qCDebug(ATCORE_CORE) << "Sending " << GCode::description(GCode::MCommands::M115); | 488 | qCDebug(ATCORE_CORE) << "Sending " << GCode::description(GCode::MCommands::M115); | ||
484 | d->serial->pushCommand(GCode::toCommand(GCode::MCommands::M115).toLocal8Bit()); | 489 | pushCommand(GCode::toCommand(GCode::MCommands::M115)); | ||
485 | } else { | 490 | } else { | ||
486 | qCDebug(ATCORE_CORE) << "There is no open device to send commands"; | 491 | qCDebug(ATCORE_CORE) << "There is no open device to send commands"; | ||
487 | } | 492 | } | ||
488 | } | 493 | } | ||
489 | 494 | | |||
490 | bool AtCore::firmwarePluginLoaded() const | 495 | bool AtCore::firmwarePluginLoaded() const | ||
491 | { | 496 | { | ||
492 | if (firmwarePlugin()) { | 497 | if (firmwarePlugin()) { | ||
▲ Show 20 Lines • Show All 364 Lines • Show Last 20 Lines |
You should use the gcode enum.