Changeset View
Changeset View
Standalone View
Standalone View
src/core/atcore.cpp
Show First 20 Lines • Show All 56 Lines • ▼ Show 20 Line(s) | 50 | struct AtCore::AtCorePrivate { | |||
---|---|---|---|---|---|
57 | /** plugins: Map of plugins name / path */ | 57 | /** plugins: Map of plugins name / path */ | ||
58 | QMap<QString, QString> plugins; | 58 | QMap<QString, QString> plugins; | ||
59 | /** lastMessage: lastMessage from the printer */ | 59 | /** lastMessage: lastMessage from the printer */ | ||
60 | QByteArray lastMessage; | 60 | QByteArray lastMessage; | ||
61 | /** extruderCount: extruder count */ | 61 | /** extruderCount: extruder count */ | ||
62 | int extruderCount = 1; | 62 | int extruderCount = 1; | ||
63 | /** temperature: Temperature object */ | 63 | /** temperature: Temperature object */ | ||
64 | Temperature temperature; | 64 | Temperature temperature; | ||
65 | /** bedDeform: BedDeform object */ | ||||
66 | BedDeform bedDeform; | ||||
65 | /** commandQueue: the list of commands to send to the printer */ | 67 | /** commandQueue: the list of commands to send to the printer */ | ||
66 | QStringList commandQueue; | 68 | QStringList commandQueue; | ||
67 | /** ready: True if printer is ready for a command */ | 69 | /** ready: True if printer is ready for a command */ | ||
68 | bool ready = false; | 70 | bool ready = false; | ||
69 | /** temperatureTimer: timer connected to the checkTemperature function */ | 71 | /** temperatureTimer: timer connected to the checkTemperature function */ | ||
70 | QTimer temperatureTimer; | 72 | QTimer temperatureTimer; | ||
71 | /** sdPrintProgressTimer: timer used to check in on sdJobs */ | 73 | /** sdPrintProgressTimer: timer used to check in on sdJobs */ | ||
72 | QTimer sdPrintProgressTimer; | 74 | QTimer sdPrintProgressTimer; | ||
Show All 12 Lines | |||||
85 | /** sdCardReadingFileList: True while getting file names from sd card */ | 87 | /** sdCardReadingFileList: True while getting file names from sd card */ | ||
86 | bool sdCardReadingFileList = false; | 88 | bool sdCardReadingFileList = false; | ||
87 | /** sdCardPrinting: True if currently printing from sd card. */ | 89 | /** sdCardPrinting: True if currently printing from sd card. */ | ||
88 | bool sdCardPrinting = false; | 90 | bool sdCardPrinting = false; | ||
89 | /** sdCardFileName: name of file being used from sd card. */ | 91 | /** sdCardFileName: name of file being used from sd card. */ | ||
90 | QString sdCardFileName; | 92 | QString sdCardFileName; | ||
91 | /** sdCardFileList: List of files on sd card. */ | 93 | /** sdCardFileList: List of files on sd card. */ | ||
92 | QStringList sdCardFileList; | 94 | QStringList sdCardFileList; | ||
95 | /** tempMultiString: Hold temp returns for multiline returns when needed */ | ||||
96 | QStringList tempMultiString; | ||||
93 | }; | 97 | }; | ||
94 | 98 | | |||
95 | AtCore::AtCore(QObject *parent) : | 99 | AtCore::AtCore(QObject *parent) : | ||
96 | QObject(parent), | 100 | QObject(parent), | ||
97 | d(new AtCorePrivate) | 101 | d(new AtCorePrivate) | ||
98 | { | 102 | { | ||
99 | //Register MetaTypes | 103 | //Register MetaTypes | ||
100 | qRegisterMetaType<AtCore::STATES>("AtCore::STATES"); | 104 | qRegisterMetaType<AtCore::STATES>("AtCore::STATES"); | ||
101 | setState(AtCore::STATES::DISCONNECTED); | 105 | setState(AtCore::STATES::DISCONNECTED); | ||
102 | //Connect our Timers | 106 | //Connect our Timers | ||
103 | connect(&d->sdPrintProgressTimer, &QTimer::timeout, this, &AtCore::sdCardPrintStatus); | 107 | connect(&d->sdPrintProgressTimer, &QTimer::timeout, this, &AtCore::sdCardPrintStatus); | ||
104 | connect(&d->serialTimer, &QTimer::timeout, this, &AtCore::locateSerialPort); | 108 | connect(&d->serialTimer, &QTimer::timeout, this, &AtCore::locateSerialPort); | ||
105 | connect(&d->temperatureTimer, &QTimer::timeout, this, &AtCore::checkTemperature); | 109 | connect(&d->temperatureTimer, &QTimer::timeout, this, &AtCore::checkTemperature); | ||
110 | | ||||
111 | //<<<<<<TESTING FUNCTION ONLY REMOVE AFTER TESTING IS COMPLETE>>>>>>>> | ||||
112 | connect(&d->bedDeform, &BedDeform::dataChanged, this, [](const QList<QList<double>> &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. | |||||
113 | qDebug() << bedData; | ||||
114 | }); | ||||
115 | | ||||
106 | //Attempt to find our plugins | 116 | //Attempt to find our plugins | ||
107 | qCDebug(ATCORE_PLUGIN) << "Detecting Plugin path"; | 117 | qCDebug(ATCORE_PLUGIN) << "Detecting Plugin path"; | ||
108 | QStringList paths = AtCoreDirectories::pluginDir; | 118 | QStringList paths = AtCoreDirectories::pluginDir; | ||
109 | //add our current runtime path | 119 | //add our current runtime path | ||
110 | paths.prepend(qApp->applicationDirPath() + QStringLiteral("/../Plugins/AtCore")); | 120 | paths.prepend(qApp->applicationDirPath() + QStringLiteral("/../Plugins/AtCore")); | ||
111 | paths.prepend(qApp->applicationDirPath() + QStringLiteral("/AtCore")); | 121 | paths.prepend(qApp->applicationDirPath() + QStringLiteral("/AtCore")); | ||
112 | paths.prepend(qApp->applicationDirPath() + QStringLiteral("/plugins")); | 122 | paths.prepend(qApp->applicationDirPath() + QStringLiteral("/plugins")); | ||
113 | for (const auto &path : paths) { | 123 | for (const auto &path : paths) { | ||
▲ Show 20 Lines • Show All 230 Lines • ▼ Show 20 Line(s) | 353 | } else { | |||
344 | d->temperatureTimer.start(newTime); | 354 | d->temperatureTimer.start(newTime); | ||
345 | } | 355 | } | ||
346 | } | 356 | } | ||
347 | 357 | | |||
348 | void AtCore::newMessage(const QByteArray &message) | 358 | void AtCore::newMessage(const QByteArray &message) | ||
349 | { | 359 | { | ||
350 | //Evaluate the messages coming from the printer. | 360 | //Evaluate the messages coming from the printer. | ||
351 | d->lastMessage = message; | 361 | d->lastMessage = message; | ||
362 | if (d->lastCommand.startsWith(GCode::toCommand(GCode::GCode::G29))) { | ||||
363 | if (d->lastMessage.contains("ok")) { | ||||
364 | d->bedDeform.decodeDeform(d->tempMultiString); | ||||
365 | } | ||||
366 | d->tempMultiString.append(QString::fromLatin1(d->lastMessage)); | ||||
367 | } | ||||
352 | //Check if the message has current coordinates. | 368 | //Check if the message has current coordinates. | ||
353 | if (message.startsWith(QString::fromLatin1("X:").toLocal8Bit())) { | 369 | if (message.startsWith(QString::fromLatin1("X:").toLocal8Bit())) { | ||
354 | d->posString = message; | 370 | d->posString = message; | ||
355 | d->posString.resize(d->posString.indexOf('E')); | 371 | d->posString.resize(d->posString.indexOf('E')); | ||
356 | d->posString.replace(':', ""); | 372 | d->posString.replace(':', ""); | ||
357 | } | 373 | } | ||
358 | 374 | | |||
359 | //Check if have temperature info and decode it | 375 | //Check if have temperature info and decode it | ||
▲ Show 20 Lines • Show All 538 Lines • ▼ Show 20 Line(s) | 908 | default: | |||
898 | //QSerialPort::ParityError, Obsolete. Qt Docs "We strongly advise against using it in new code." | 914 | //QSerialPort::ParityError, Obsolete. Qt Docs "We strongly advise against using it in new code." | ||
899 | //QSerialPort::FramingError, Obsolete. Qt Docs "We strongly advise against using it in new code." | 915 | //QSerialPort::FramingError, Obsolete. Qt Docs "We strongly advise against using it in new code." | ||
900 | //QSerialPort::BreakConditionError, Obsolete. Qt Docs "We strongly advise against using it in new code." | 916 | //QSerialPort::BreakConditionError, Obsolete. Qt Docs "We strongly advise against using it in new code." | ||
901 | return; | 917 | return; | ||
902 | };//End of Switch | 918 | };//End of Switch | ||
903 | qCDebug(ATCORE_CORE) << "SerialError:" << errorString; | 919 | qCDebug(ATCORE_CORE) << "SerialError:" << errorString; | ||
904 | emit atcoreMessage(QStringLiteral("SerialError: %1").arg(errorString)); | 920 | emit atcoreMessage(QStringLiteral("SerialError: %1").arg(errorString)); | ||
905 | } | 921 | } | ||
922 | | ||||
923 | BedDeform &AtCore::bedDeform() const | ||||
924 | { | ||||
925 | return d->bedDeform; | ||||
926 | } |
if this is just for debugging purposes, remove?