Changeset View
Changeset View
Standalone View
Standalone View
src/plugins/repetierplugin.cpp
Show All 33 Lines | |||||
34 | { | 34 | { | ||
35 | return QStringLiteral("Repetier"); | 35 | return QStringLiteral("Repetier"); | ||
36 | } | 36 | } | ||
37 | 37 | | |||
38 | RepetierPlugin::RepetierPlugin() | 38 | RepetierPlugin::RepetierPlugin() | ||
39 | { | 39 | { | ||
40 | qCDebug(REPETIER_PLUGIN) << name() << " plugin loaded!"; | 40 | qCDebug(REPETIER_PLUGIN) << name() << " plugin loaded!"; | ||
41 | } | 41 | } | ||
42 | | ||||
43 | void RepetierPlugin::validateCommand(const QString &lastMessage) | ||||
44 | { | ||||
45 | if (lastMessage.contains(QStringLiteral("End file list"))) { | ||||
46 | core()->setReadingSdCardList(false); | ||||
47 | } else if (core()->isReadingSdCardList()) { | ||||
48 | // Below is to not add directories | ||||
49 | if (!lastMessage.endsWith(QChar::fromLatin1('/'))) { | ||||
50 | QString fileName = lastMessage; | ||||
51 | fileName.chop(fileName.length() - fileName.lastIndexOf(QChar::fromLatin1(' '))); | ||||
52 | core()->appendSdCardFileList(fileName); | ||||
53 | } | ||||
54 | } else { | ||||
55 | if (lastMessage.contains(QStringLiteral("SD card"))) { | ||||
56 | if (lastMessage.contains(QStringLiteral("inserted"))) { | ||||
57 | core()->setSdMounted(true); | ||||
58 | } else if (lastMessage.contains(QStringLiteral("removed"))) { | ||||
59 | core()->setSdMounted(false); | ||||
60 | } | ||||
61 | } else if (lastMessage.contains(QStringLiteral("Begin file list"))) { | ||||
62 | core()->setSdMounted(true); | ||||
63 | core()->setReadingSdCardList(true); | ||||
64 | core()->clearSdCardFileList(); | ||||
65 | } else if (lastMessage.contains(QStringLiteral("SD printing byte"))) { | ||||
66 | QString temp = lastMessage; | ||||
67 | temp.replace(QStringLiteral("SD printing byte"), QString()); | ||||
68 | qlonglong total = temp.mid(temp.lastIndexOf(QChar::fromLatin1('/')) + 1, temp.length() - temp.lastIndexOf(QChar::fromLatin1('/'))).toLongLong(); | ||||
69 | if (total) { | ||||
70 | temp.chop(temp.length() - temp.lastIndexOf(QChar::fromLatin1('/'))); | ||||
71 | qlonglong remaining = total - temp.toLongLong(); | ||||
patrickelectric: same things in marlin | |||||
72 | float progress = float(total - remaining) * 100 / float(total); | ||||
73 | core()->printProgressChanged(progress); | ||||
74 | if (progress >= 100) { | ||||
75 | core()->setState(AtCore::FINISHEDPRINT); | ||||
76 | core()->setState(AtCore::IDLE); | ||||
77 | } | ||||
78 | } else { | ||||
79 | core()->setState(AtCore::FINISHEDPRINT); | ||||
80 | core()->setState(AtCore::IDLE); | ||||
81 | } | ||||
82 | } | ||||
83 | if (lastMessage.contains(QStringLiteral("ok"))) { | ||||
84 | emit readyForCommand(); | ||||
85 | } | ||||
86 | } | ||||
87 | } |
same things in marlin