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 | Temperature temperature; | 66 | Temperature temperature; | ||
67 | /** bedDeform: BedDeform object */ | ||||
68 | BedDeform bedDeform; | ||||
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 All 12 Lines | |||||
87 | /** sdCardReadingFileList: True while getting file names from sd card */ | 89 | /** sdCardReadingFileList: True while getting file names from sd card */ | ||
88 | bool sdCardReadingFileList = false; | 90 | bool sdCardReadingFileList = false; | ||
89 | /** sdCardPrinting: True if currently printing from sd card. */ | 91 | /** sdCardPrinting: True if currently printing from sd card. */ | ||
90 | bool sdCardPrinting = false; | 92 | bool sdCardPrinting = false; | ||
91 | /** sdCardFileName: name of file being used from sd card. */ | 93 | /** sdCardFileName: name of file being used from sd card. */ | ||
92 | QString sdCardFileName; | 94 | QString sdCardFileName; | ||
93 | /** sdCardFileList: List of files on sd card. */ | 95 | /** sdCardFileList: List of files on sd card. */ | ||
94 | QStringList sdCardFileList; | 96 | QStringList sdCardFileList; | ||
97 | /** tempMultiString: Hold temp returns for multiline returns when needed */ | ||||
98 | QStringList tempMultiString; | ||||
95 | }; | 99 | }; | ||
96 | 100 | | |||
97 | AtCore::AtCore(QObject *parent) : | 101 | AtCore::AtCore(QObject *parent) : | ||
98 | QObject(parent), | 102 | QObject(parent), | ||
99 | d(new AtCorePrivate) | 103 | d(new AtCorePrivate) | ||
100 | { | 104 | { | ||
101 | //Register MetaTypes | 105 | //Register MetaTypes | ||
102 | qRegisterMetaType<AtCore::STATES>("AtCore::STATES"); | 106 | qRegisterMetaType<AtCore::STATES>("AtCore::STATES"); | ||
103 | setState(AtCore::STATES::DISCONNECTED); | 107 | setState(AtCore::STATES::DISCONNECTED); | ||
104 | //Connect our Timers | 108 | //Connect our Timers | ||
105 | connect(&d->sdPrintProgressTimer, &QTimer::timeout, this, &AtCore::sdCardPrintStatus); | 109 | connect(&d->sdPrintProgressTimer, &QTimer::timeout, this, &AtCore::sdCardPrintStatus); | ||
106 | connect(&d->serialTimer, &QTimer::timeout, this, &AtCore::locateSerialPort); | 110 | connect(&d->serialTimer, &QTimer::timeout, this, &AtCore::locateSerialPort); | ||
107 | connect(&d->temperatureTimer, &QTimer::timeout, this, &AtCore::checkTemperature); | 111 | connect(&d->temperatureTimer, &QTimer::timeout, this, &AtCore::checkTemperature); | ||
112 | | ||||
113 | //<<<<<<TESTING FUNCTION ONLY REMOVE AFTER TESTING IS COMPLETE>>>>>>>> | ||||
114 | connect(&d->bedDeform, &BedDeform::dataChanged, this, [](const QVariantList & bedData) { | ||||
tcanabrava: if this is just for debugging purposes, remove? | |||||
Yes, Its for testing / debugging since there Is currently no other way to check that data was read correctly. rizzitello: Yes, Its for testing / debugging since there Is currently no other way to check that data was… | |||||
patrickelectric: Just to make sure, this will be removed before the merge right ? | |||||
rizzitello: Yes. | |||||
115 | qDebug() << bedData; | ||||
116 | }); | ||||
117 | | ||||
108 | //Attempt to find our plugins | 118 | //Attempt to find our plugins | ||
109 | qCDebug(ATCORE_PLUGIN) << "Detecting Plugin path"; | 119 | qCDebug(ATCORE_PLUGIN) << "Detecting Plugin path"; | ||
110 | QStringList paths = AtCoreDirectories::pluginDir; | 120 | QStringList paths = AtCoreDirectories::pluginDir; | ||
111 | //add our current runtime path | 121 | //add our current runtime path | ||
112 | paths.prepend(qApp->applicationDirPath() + QStringLiteral("/../Plugins/AtCore")); | 122 | paths.prepend(qApp->applicationDirPath() + QStringLiteral("/../Plugins/AtCore")); | ||
113 | paths.prepend(qApp->applicationDirPath() + QStringLiteral("/AtCore")); | 123 | paths.prepend(qApp->applicationDirPath() + QStringLiteral("/AtCore")); | ||
114 | paths.prepend(qApp->applicationDirPath() + QStringLiteral("/plugins")); | 124 | paths.prepend(qApp->applicationDirPath() + QStringLiteral("/plugins")); | ||
115 | for (const auto &path : paths) { | 125 | for (const auto &path : paths) { | ||
▲ Show 20 Lines • Show All 229 Lines • ▼ Show 20 Line(s) | 347 | { | |||
345 | } else { | 355 | } else { | ||
346 | d->temperatureTimer.start(newTime); | 356 | d->temperatureTimer.start(newTime); | ||
347 | } | 357 | } | ||
348 | } | 358 | } | ||
349 | 359 | | |||
350 | void AtCore::newMessage(const QByteArray &message) | 360 | void AtCore::newMessage(const QByteArray &message) | ||
351 | { | 361 | { | ||
352 | d->lastMessage = message; | 362 | d->lastMessage = message; | ||
363 | if (d->lastCommand.startsWith(GCode::toCommand(GCode::GCode::G29))) { | ||||
364 | if (d->lastMessage.contains("ok")) { | ||||
365 | d->bedDeform.decodeDeform(d->tempMultiString); | ||||
366 | } | ||||
367 | d->tempMultiString.append(QString::fromLatin1(d->lastMessage)); | ||||
368 | } | ||||
353 | //Check if the message has current coordinates. | 369 | //Check if the message has current coordinates. | ||
354 | if (d->lastCommand.startsWith(GCode::toCommand(GCode::MCommands::M114)) | 370 | if (d->lastCommand.startsWith(GCode::toCommand(GCode::MCommands::M114)) | ||
355 | && d->lastMessage.startsWith(QString::fromLatin1("X:").toLocal8Bit())) { | 371 | && d->lastMessage.startsWith(QString::fromLatin1("X:").toLocal8Bit())) { | ||
356 | d->posString = message; | 372 | d->posString = message; | ||
357 | d->posString.resize(d->posString.indexOf('E')); | 373 | d->posString.resize(d->posString.indexOf('E')); | ||
358 | d->posString.replace(':', ""); | 374 | d->posString.replace(':', ""); | ||
359 | } | 375 | } | ||
360 | 376 | | |||
▲ Show 20 Lines • Show All 539 Lines • ▼ Show 20 Line(s) | 910 | default: | |||
900 | //QSerialPort::ParityError, Obsolete. Qt Docs "We strongly advise against using it in new code." | 916 | //QSerialPort::ParityError, Obsolete. Qt Docs "We strongly advise against using it in new code." | ||
901 | //QSerialPort::FramingError, Obsolete. Qt Docs "We strongly advise against using it in new code." | 917 | //QSerialPort::FramingError, Obsolete. Qt Docs "We strongly advise against using it in new code." | ||
902 | //QSerialPort::BreakConditionError, Obsolete. Qt Docs "We strongly advise against using it in new code." | 918 | //QSerialPort::BreakConditionError, Obsolete. Qt Docs "We strongly advise against using it in new code." | ||
903 | return; | 919 | return; | ||
904 | };//End of Switch | 920 | };//End of Switch | ||
905 | qCDebug(ATCORE_CORE) << "SerialError:" << errorString; | 921 | qCDebug(ATCORE_CORE) << "SerialError:" << errorString; | ||
906 | emit atcoreMessage(QStringLiteral("SerialError: %1").arg(errorString)); | 922 | emit atcoreMessage(QStringLiteral("SerialError: %1").arg(errorString)); | ||
907 | } | 923 | } | ||
924 | | ||||
925 | BedDeform &AtCore::bedDeform() const | ||||
926 | { | ||||
927 | return d->bedDeform; | ||||
928 | } |
if this is just for debugging purposes, remove?