Changeset View
Changeset View
Standalone View
Standalone View
src/core/printthread.cpp
Show First 20 Lines • Show All 116 Lines • ▼ Show 20 Line(s) | 82 | { | |||
---|---|---|---|---|---|
117 | default: | 117 | default: | ||
118 | qCDebug(PRINT_THREAD) << "Unknown State"; | 118 | qCDebug(PRINT_THREAD) << "Unknown State"; | ||
119 | break; | 119 | break; | ||
120 | } | 120 | } | ||
121 | } | 121 | } | ||
122 | 122 | | |||
123 | void PrintThread::endPrint() | 123 | void PrintThread::endPrint() | ||
124 | { | 124 | { | ||
125 | emit(printProgressChanged(100)); | 125 | emit printProgressChanged(100); | ||
126 | qCDebug(PRINT_THREAD) << "atEnd"; | 126 | qCDebug(PRINT_THREAD) << "atEnd"; | ||
127 | disconnect(d->core->firmwarePlugin(), &IFirmware::readyForCommand, this, &PrintThread::processJob); | 127 | disconnect(d->core->firmwarePlugin(), &IFirmware::readyForCommand, this, &PrintThread::processJob); | ||
128 | disconnect(this, &PrintThread::nextCommand, d->core, &AtCore::pushCommand); | 128 | disconnect(this, &PrintThread::nextCommand, d->core, &AtCore::pushCommand); | ||
129 | disconnect(d->core, &AtCore::stateChanged, this, &PrintThread::setState); | 129 | disconnect(d->core, &AtCore::stateChanged, this, &PrintThread::setState); | ||
130 | emit(stateChanged(AtCore::FINISHEDPRINT)); | 130 | emit stateChanged(AtCore::FINISHEDPRINT); | ||
131 | emit(stateChanged(AtCore::IDLE)); | 131 | emit stateChanged(AtCore::IDLE); | ||
132 | disconnect(this, &PrintThread::stateChanged, d->core, &AtCore::setState); | 132 | disconnect(this, &PrintThread::stateChanged, d->core, &AtCore::setState); | ||
133 | emit finished(); | 133 | emit finished(); | ||
134 | 134 | | |||
135 | } | 135 | } | ||
136 | void PrintThread::nextLine() | 136 | void PrintThread::nextLine() | ||
137 | { | 137 | { | ||
138 | d->cline = d->gcodestream->readLine(); | 138 | d->cline = d->gcodestream->readLine(); | ||
139 | qCDebug(PRINT_THREAD) << "Nextline:" << d->cline; | 139 | qCDebug(PRINT_THREAD) << "Nextline:" << d->cline; | ||
140 | d->stillSize -= d->cline.size() + 1; //remove read chars | 140 | d->stillSize -= d->cline.size() + 1; //remove read chars | ||
141 | d->printProgress = float(d->totalSize - d->stillSize) * 100.0 / float(d->totalSize); | 141 | d->printProgress = float(d->totalSize - d->stillSize) * 100.0 / float(d->totalSize); | ||
142 | qCDebug(PRINT_THREAD) << "progress:" << QString::number(d->printProgress); | 142 | qCDebug(PRINT_THREAD) << "progress:" << QString::number(d->printProgress); | ||
143 | emit(printProgressChanged(d->printProgress)); | 143 | emit printProgressChanged(d->printProgress); | ||
144 | 144 | | |||
145 | if (d->cline.startsWith(QStringLiteral(";-"))) { | 145 | if (d->cline.startsWith(QStringLiteral(";-"))) { | ||
146 | injectCommand(d->cline); | 146 | injectCommand(d->cline); | ||
147 | d->cline = QStringLiteral(""); | 147 | d->cline = QStringLiteral(""); | ||
148 | return; | 148 | return; | ||
149 | } | 149 | } | ||
150 | //Remove Comments from the gcode. | 150 | //Remove Comments from the gcode. | ||
151 | //Type 1: Anything after ; is comment. | 151 | //Type 1: Anything after ; is comment. | ||
Show All 23 Lines | 173 | ) { | |||
175 | return; | 175 | return; | ||
176 | } | 176 | } | ||
177 | if (newState != d->state) { | 177 | if (newState != d->state) { | ||
178 | qCDebug(PRINT_THREAD) << QStringLiteral("State changed from [%1] to [%2]") | 178 | qCDebug(PRINT_THREAD) << QStringLiteral("State changed from [%1] to [%2]") | ||
179 | .arg(QVariant::fromValue(d->state).value<QString>()) | 179 | .arg(QVariant::fromValue(d->state).value<QString>()) | ||
180 | .arg(QVariant::fromValue(newState).value<QString>()); | 180 | .arg(QVariant::fromValue(newState).value<QString>()); | ||
181 | disconnect(d->core, &AtCore::stateChanged, this, &PrintThread::setState); | 181 | disconnect(d->core, &AtCore::stateChanged, this, &PrintThread::setState); | ||
182 | d->state = newState; | 182 | d->state = newState; | ||
183 | emit(stateChanged(d->state)); | 183 | emit stateChanged(d->state); | ||
184 | connect(d->core, &AtCore::stateChanged, this, &PrintThread::setState, Qt::QueuedConnection); | 184 | connect(d->core, &AtCore::stateChanged, this, &PrintThread::setState, Qt::QueuedConnection); | ||
185 | } | 185 | } | ||
186 | } | 186 | } | ||
187 | 187 | | |||
188 | void PrintThread::injectCommand(QString &command) | 188 | void PrintThread::injectCommand(QString &command) | ||
189 | { | 189 | { | ||
190 | //remove the ; | 190 | //remove the ; | ||
191 | command.remove(0, 1); | 191 | command.remove(0, 1); | ||
Show All 38 Lines |