Changeset View
Changeset View
Standalone View
Standalone View
src/plugins/teacupplugin.cpp
Show All 38 Lines | |||||
39 | 39 | | |||
40 | TeacupPlugin::TeacupPlugin() | 40 | TeacupPlugin::TeacupPlugin() | ||
41 | { | 41 | { | ||
42 | qCDebug(TEACUP_PLUGIN) << name() << " plugin loaded!"; | 42 | qCDebug(TEACUP_PLUGIN) << name() << " plugin loaded!"; | ||
43 | } | 43 | } | ||
44 | 44 | | |||
45 | void TeacupPlugin::extractTemp(const QString &lastMessage) | 45 | void TeacupPlugin::extractTemp(const QString &lastMessage) | ||
46 | { | 46 | { | ||
47 | // ok T:185.5 B:60 | ||||
47 | // ok T:185.4 /185.0 B:60.5 /60.0 | 48 | // ok T:185.4/185.0 B:60.5/60.0 | ||
48 | QStringList list = lastMessage.split(QChar::fromLatin1(' ')); | 49 | QStringList list = lastMessage.split(QChar::fromLatin1(' ')); | ||
49 | // T:185.4 - current temperature | 50 | // T:185.4 - current temperature | ||
51 | if (list[0].indexOf(QStringLiteral("/")) != 0) { | ||||
52 | //T:185.4/185 | ||||
53 | core()->temperature().setExtruderTemperature(list[0].mid(2, list[0].size() - list[0].indexOf(QStringLiteral("/")) + 2).toFloat()); | ||||
54 | core()->temperature().setExtruderTargetTemperature(list[0].mid(list[0].indexOf(QStringLiteral("/")) + 1).toFloat()); | ||||
55 | } else { | ||||
50 | core()->temperature().setExtruderTemperature(list[0].mid(2).toFloat()); | 56 | core()->temperature().setExtruderTemperature(list[0].mid(2).toFloat()); | ||
51 | // /185.0 - target temperature | 57 | } | ||
52 | core()->temperature().setExtruderTargetTemperature(list[1].mid(1).toFloat()); | | |||
53 | if (lastMessage.contains(_bedTemp)) { | 58 | if (lastMessage.contains(_bedTemp)) { | ||
59 | if (list[1].indexOf(QStringLiteral("/")) != 0) { | ||||
patrickelectric: I think that is a else if | |||||
we enter this if bed temp then like above based on if there is a / in the string we parse one way or the other rizzitello: we enter this if bed temp then like above based on if there is a / in the string we parse one… | |||||
60 | //T:185.4/185 | ||||
61 | core()->temperature().setBedTemperature(list[1].mid(2, list[0].size() - list[1].indexOf(QStringLiteral("/")) + 2).toFloat()); | ||||
62 | core()->temperature().setBedTargetTemperature(list[1].mid(list[1].indexOf(QStringLiteral("/")) + 1).toFloat()); | ||||
63 | } else { | ||||
54 | // B:185.4 - current temperature | 64 | // B:185.4 - current temperature | ||
55 | core()->temperature().setBedTemperature(list[2].mid(2).toFloat()); | 65 | core()->temperature().setBedTemperature(list[1].mid(2).toFloat()); | ||
56 | // /60.0 - target temperature | 66 | } | ||
57 | core()->temperature().setBedTargetTemperature(list[3].mid(1).toFloat()); | | |||
58 | } | 67 | } | ||
59 | } | 68 | } | ||
60 | 69 | | |||
61 | void TeacupPlugin::validateCommand(const QString &lastMessage) | 70 | void TeacupPlugin::validateCommand(const QString &lastMessage) | ||
62 | { | 71 | { | ||
63 | if (lastMessage.contains(_extruderTemp) || lastMessage.contains(_bedTemp)) { | 72 | if (lastMessage.contains(_extruderTemp) || lastMessage.contains(_bedTemp)) { | ||
64 | extractTemp(lastMessage); | 73 | extractTemp(lastMessage); | ||
65 | } | 74 | } | ||
Show All 9 Lines |
I think that is a else if