Changeset View
Changeset View
Standalone View
Standalone View
src/plugins/repetierplugin.cpp
Show All 20 Lines | |||||
21 | #include "repetierplugin.h" | 21 | #include "repetierplugin.h" | ||
22 | #include "temperature.h" | 22 | #include "temperature.h" | ||
23 | #include "atcore.h" | 23 | #include "atcore.h" | ||
24 | 24 | | |||
25 | #include <QLoggingCategory> | 25 | #include <QLoggingCategory> | ||
26 | #include <QString> | 26 | #include <QString> | ||
27 | 27 | | |||
28 | QString RepetierPlugin::_ok = QStringLiteral("ok"); | 28 | QString RepetierPlugin::_ok = QStringLiteral("ok"); | ||
29 | QString RepetierPlugin::_extruderTemp = QStringLiteral("T:"); | | |||
30 | QString RepetierPlugin::_bedTemp = QStringLiteral("B:"); | | |||
31 | 29 | | |||
32 | Q_LOGGING_CATEGORY(REPETIER_PLUGIN, "org.kde.atelier.core.firmware.repetier"); | 30 | Q_LOGGING_CATEGORY(REPETIER_PLUGIN, "org.kde.atelier.core.firmware.repetier"); | ||
33 | 31 | | |||
34 | QString RepetierPlugin::name() const | 32 | QString RepetierPlugin::name() const | ||
35 | { | 33 | { | ||
36 | return QStringLiteral("Repetier"); | 34 | return QStringLiteral("Repetier"); | ||
37 | } | 35 | } | ||
38 | 36 | | |||
39 | RepetierPlugin::RepetierPlugin() | 37 | RepetierPlugin::RepetierPlugin() | ||
40 | { | 38 | { | ||
41 | qCDebug(REPETIER_PLUGIN) << name() << " plugin loaded!"; | 39 | qCDebug(REPETIER_PLUGIN) << name() << " plugin loaded!"; | ||
42 | } | 40 | } | ||
43 | 41 | | |||
44 | void RepetierPlugin::extractTemp(const QString &lastMessage) | | |||
45 | { | | |||
46 | // ok T:185.4 /185.0 B:60.5 /60.0 | | |||
47 | QStringList list = lastMessage.split(QChar::fromLatin1(' ')); | | |||
48 | // T:185.4 - current temperature | | |||
49 | core()->temperature().setExtruderTemperature(list[0].mid(2).toFloat()); | | |||
50 | // /185.0 - target temperature | | |||
51 | core()->temperature().setExtruderTargetTemperature(list[1].mid(1).toFloat()); | | |||
52 | if (lastMessage.contains(_bedTemp)) { | | |||
53 | // B:185.4 - current temperature | | |||
54 | core()->temperature().setBedTemperature(list[2].mid(2).toFloat()); | | |||
55 | // /60.0 - target temperature | | |||
56 | core()->temperature().setBedTargetTemperature(list[3].mid(1).toFloat()); | | |||
57 | } | | |||
58 | } | | |||
59 | | ||||
60 | void RepetierPlugin::validateCommand(const QString &lastMessage) | 42 | void RepetierPlugin::validateCommand(const QString &lastMessage) | ||
61 | { | 43 | { | ||
62 | if (lastMessage.contains(_extruderTemp) || lastMessage.contains(_bedTemp)) { | | |||
63 | extractTemp(lastMessage); | | |||
64 | } | | |||
65 | | ||||
66 | if (lastMessage.contains(_ok)) { | 44 | if (lastMessage.contains(_ok)) { | ||
67 | emit readyForCommand(); | 45 | emit readyForCommand(); | ||
68 | } | 46 | } | ||
69 | } | 47 | } | ||
70 | 48 | | |||
71 | QByteArray RepetierPlugin::translate(const QString &command) | 49 | QByteArray RepetierPlugin::translate(const QString &command) | ||
72 | { | 50 | { | ||
73 | return command.toLocal8Bit(); | 51 | return command.toLocal8Bit(); | ||
74 | } | 52 | } |