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