Changeset View
Changeset View
Standalone View
Standalone View
src/core/atcore.cpp
Show First 20 Lines • Show All 57 Lines • ▼ Show 20 Line(s) | 50 | struct AtCore::AtCorePrivate { | |||
---|---|---|---|---|---|
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 | /** 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 | std::shared_ptr<Temperature> temperature = nullptr; | ||
67 | /** commandQueue: the list of commands to send to the printer */ | 67 | /** commandQueue: the list of commands to send to the printer */ | ||
68 | QStringList commandQueue; | 68 | QStringList commandQueue; | ||
69 | /** ready: True if printer is ready for a command */ | 69 | /** ready: True if printer is ready for a command */ | ||
70 | bool ready = false; | 70 | bool ready = false; | ||
71 | /** temperatureTimer: timer connected to the checkTemperature function */ | 71 | /** temperatureTimer: timer connected to the checkTemperature function */ | ||
72 | QTimer temperatureTimer; | 72 | QTimer temperatureTimer; | ||
73 | /** sdPrintProgressTimer: timer used to check in on sdJobs */ | 73 | /** sdPrintProgressTimer: timer used to check in on sdJobs */ | ||
74 | QTimer sdPrintProgressTimer; | 74 | QTimer sdPrintProgressTimer; | ||
Show All 18 Lines | |||||
93 | /** sdCardFileList: List of files on sd card. */ | 93 | /** sdCardFileList: List of files on sd card. */ | ||
94 | QStringList sdCardFileList; | 94 | QStringList sdCardFileList; | ||
95 | }; | 95 | }; | ||
96 | 96 | | |||
97 | AtCore::AtCore(QObject *parent) : | 97 | AtCore::AtCore(QObject *parent) : | ||
98 | QObject(parent), | 98 | QObject(parent), | ||
99 | d(new AtCorePrivate) | 99 | d(new AtCorePrivate) | ||
100 | { | 100 | { | ||
101 | d->temperature.reset(new Temperature); | ||||
101 | //Register MetaTypes | 102 | //Register MetaTypes | ||
102 | qRegisterMetaType<AtCore::STATES>("AtCore::STATES"); | 103 | qRegisterMetaType<AtCore::STATES>("AtCore::STATES"); | ||
103 | setState(AtCore::STATES::DISCONNECTED); | 104 | setState(AtCore::STATES::DISCONNECTED); | ||
104 | //Connect our Timers | 105 | //Connect our Timers | ||
105 | connect(&d->sdPrintProgressTimer, &QTimer::timeout, this, &AtCore::sdCardPrintStatus); | 106 | connect(&d->sdPrintProgressTimer, &QTimer::timeout, this, &AtCore::sdCardPrintStatus); | ||
106 | connect(&d->serialTimer, &QTimer::timeout, this, &AtCore::locateSerialPort); | 107 | connect(&d->serialTimer, &QTimer::timeout, this, &AtCore::locateSerialPort); | ||
107 | connect(&d->temperatureTimer, &QTimer::timeout, this, &AtCore::checkTemperature); | 108 | connect(&d->temperatureTimer, &QTimer::timeout, this, &AtCore::checkTemperature); | ||
108 | //Attempt to find our plugins | 109 | //Attempt to find our plugins | ||
Show All 30 Lines | 139 | { | |||
139 | return d->firmwarePlugin; | 140 | return d->firmwarePlugin; | ||
140 | } | 141 | } | ||
141 | 142 | | |||
142 | void AtCore::close() | 143 | void AtCore::close() | ||
143 | { | 144 | { | ||
144 | exit(0); | 145 | exit(0); | ||
145 | } | 146 | } | ||
146 | 147 | | |||
147 | Temperature &AtCore::temperature() const | 148 | std::shared_ptr<Temperature> AtCore::temperature() | ||
148 | { | 149 | { | ||
149 | return d->temperature; | 150 | return d->temperature; | ||
150 | } | 151 | } | ||
151 | 152 | | |||
152 | void AtCore::findFirmware(const QByteArray &message) | 153 | void AtCore::findFirmware(const QByteArray &message) | ||
153 | { | 154 | { | ||
154 | emit receivedMessage(message); | 155 | emit receivedMessage(message); | ||
155 | emit atcoreMessage(tr("Waiting for firmware detect.")); | 156 | emit atcoreMessage(tr("Waiting for firmware detect.")); | ||
▲ Show 20 Lines • Show All 199 Lines • ▼ Show 20 Line(s) | 355 | if (d->lastCommand.startsWith(GCode::toCommand(GCode::MCommands::M114)) | |||
355 | && d->lastMessage.startsWith(QString::fromLatin1("X:").toLocal8Bit())) { | 356 | && d->lastMessage.startsWith(QString::fromLatin1("X:").toLocal8Bit())) { | ||
356 | d->posString = message; | 357 | d->posString = message; | ||
357 | d->posString.resize(d->posString.indexOf('E')); | 358 | d->posString.resize(d->posString.indexOf('E')); | ||
358 | d->posString.replace(':', ""); | 359 | d->posString.replace(':', ""); | ||
359 | } | 360 | } | ||
360 | 361 | | |||
361 | //Check if have temperature info and decode it | 362 | //Check if have temperature info and decode it | ||
362 | if (d->lastMessage.contains("T:") || d->lastMessage.contains("B:")) { | 363 | if (d->lastMessage.contains("T:") || d->lastMessage.contains("B:")) { | ||
363 | temperature().decodeTemp(d->lastMessage); | 364 | temperature().get()->decodeTemp(d->lastMessage); | ||
364 | } | 365 | } | ||
365 | emit receivedMessage(d->lastMessage); | 366 | emit receivedMessage(d->lastMessage); | ||
366 | } | 367 | } | ||
367 | 368 | | |||
368 | void AtCore::newCommand(const QByteArray &command) | 369 | void AtCore::newCommand(const QByteArray &command) | ||
369 | { | 370 | { | ||
370 | emit pushedCommand(command); | 371 | emit pushedCommand(command); | ||
371 | } | 372 | } | ||
▲ Show 20 Lines • Show All 536 Lines • Show Last 20 Lines |