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 | std::shared_ptr<Temperature> temperature = nullptr; | 66 | std::shared_ptr<Temperature> temperature = nullptr; | ||
67 | /** bedDeform: BedDeform object */ | ||||
68 | std::shared_ptr<BedDeform> bedDeform = nullptr; | ||||
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 | d->temperature.reset(new Temperature); | 105 | d->temperature.reset(new Temperature); | ||
106 | d->bedDeform.reset(new BedDeform); | ||||
102 | //Register MetaTypes | 107 | //Register MetaTypes | ||
103 | qRegisterMetaType<AtCore::STATES>("AtCore::STATES"); | 108 | qRegisterMetaType<AtCore::STATES>("AtCore::STATES"); | ||
104 | setState(AtCore::STATES::DISCONNECTED); | 109 | setState(AtCore::STATES::DISCONNECTED); | ||
105 | //Connect our Timers | 110 | //Connect our Timers | ||
106 | connect(&d->sdPrintProgressTimer, &QTimer::timeout, this, &AtCore::sdCardPrintStatus); | 111 | connect(&d->sdPrintProgressTimer, &QTimer::timeout, this, &AtCore::sdCardPrintStatus); | ||
107 | connect(&d->serialTimer, &QTimer::timeout, this, &AtCore::locateSerialPort); | 112 | connect(&d->serialTimer, &QTimer::timeout, this, &AtCore::locateSerialPort); | ||
108 | connect(&d->temperatureTimer, &QTimer::timeout, this, &AtCore::checkTemperature); | 113 | connect(&d->temperatureTimer, &QTimer::timeout, this, &AtCore::checkTemperature); | ||
114 | | ||||
115 | //<<<<<<TESTING FUNCTION ONLY REMOVE AFTER TESTING IS COMPLETE>>>>>>>> | ||||
116 | connect(d->bedDeform.get(), &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. | |||||
117 | qDebug() << bedData; | ||||
118 | }); | ||||
119 | | ||||
109 | //Attempt to find our plugins | 120 | //Attempt to find our plugins | ||
110 | qCDebug(ATCORE_PLUGIN) << "Detecting Plugin path"; | 121 | qCDebug(ATCORE_PLUGIN) << "Detecting Plugin path"; | ||
111 | QStringList paths = AtCoreDirectories::pluginDir; | 122 | QStringList paths = AtCoreDirectories::pluginDir; | ||
112 | //add our current runtime path | 123 | //add our current runtime path | ||
113 | paths.prepend(qApp->applicationDirPath() + QStringLiteral("/../Plugins/AtCore")); | 124 | paths.prepend(qApp->applicationDirPath() + QStringLiteral("/../Plugins/AtCore")); | ||
114 | paths.prepend(qApp->applicationDirPath() + QStringLiteral("/AtCore")); | 125 | paths.prepend(qApp->applicationDirPath() + QStringLiteral("/AtCore")); | ||
115 | paths.prepend(qApp->applicationDirPath() + QStringLiteral("/plugins")); | 126 | paths.prepend(qApp->applicationDirPath() + QStringLiteral("/plugins")); | ||
116 | for (const auto &path : paths) { | 127 | for (const auto &path : paths) { | ||
▲ Show 20 Lines • Show All 230 Lines • ▼ Show 20 Line(s) | 350 | { | |||
347 | } else { | 358 | } else { | ||
348 | d->temperatureTimer.start(newTime); | 359 | d->temperatureTimer.start(newTime); | ||
349 | } | 360 | } | ||
350 | } | 361 | } | ||
351 | 362 | | |||
352 | void AtCore::newMessage(const QByteArray &message) | 363 | void AtCore::newMessage(const QByteArray &message) | ||
353 | { | 364 | { | ||
354 | d->lastMessage = message; | 365 | d->lastMessage = message; | ||
366 | if (d->lastCommand.startsWith(GCode::toCommand(GCode::GCode::G29))) { | ||||
367 | if (d->lastMessage.contains("ok")) { | ||||
368 | d->bedDeform.get()->decodeDeform(d->tempMultiString); | ||||
369 | } | ||||
370 | d->tempMultiString.append(QString::fromLatin1(d->lastMessage)); | ||||
371 | } | ||||
355 | //Check if the message has current coordinates. | 372 | //Check if the message has current coordinates. | ||
356 | if (d->lastCommand.startsWith(GCode::toCommand(GCode::MCommands::M114)) | 373 | if (d->lastCommand.startsWith(GCode::toCommand(GCode::MCommands::M114)) | ||
357 | && d->lastMessage.startsWith(QString::fromLatin1("X:").toLocal8Bit())) { | 374 | && d->lastMessage.startsWith(QString::fromLatin1("X:").toLocal8Bit())) { | ||
358 | d->posString = message; | 375 | d->posString = message; | ||
359 | d->posString.resize(d->posString.indexOf('E')); | 376 | d->posString.resize(d->posString.indexOf('E')); | ||
360 | d->posString.replace(':', ""); | 377 | d->posString.replace(':', ""); | ||
361 | } | 378 | } | ||
362 | 379 | | |||
▲ Show 20 Lines • Show All 539 Lines • ▼ Show 20 Line(s) | 913 | default: | |||
902 | //QSerialPort::ParityError, Obsolete. Qt Docs "We strongly advise against using it in new code." | 919 | //QSerialPort::ParityError, Obsolete. Qt Docs "We strongly advise against using it in new code." | ||
903 | //QSerialPort::FramingError, Obsolete. Qt Docs "We strongly advise against using it in new code." | 920 | //QSerialPort::FramingError, Obsolete. Qt Docs "We strongly advise against using it in new code." | ||
904 | //QSerialPort::BreakConditionError, Obsolete. Qt Docs "We strongly advise against using it in new code." | 921 | //QSerialPort::BreakConditionError, Obsolete. Qt Docs "We strongly advise against using it in new code." | ||
905 | return; | 922 | return; | ||
906 | };//End of Switch | 923 | };//End of Switch | ||
907 | qCDebug(ATCORE_CORE) << "SerialError:" << errorString; | 924 | qCDebug(ATCORE_CORE) << "SerialError:" << errorString; | ||
908 | emit atcoreMessage(QStringLiteral("SerialError: %1").arg(errorString)); | 925 | emit atcoreMessage(QStringLiteral("SerialError: %1").arg(errorString)); | ||
909 | } | 926 | } | ||
927 | | ||||
928 | std::shared_ptr<BedDeform> AtCore::bedDeform() | ||||
929 | { | ||||
930 | return d->bedDeform; | ||||
931 | } |
if this is just for debugging purposes, remove?