diff --git a/src/core/ifirmware.h b/src/core/ifirmware.h index 626929d..51831b1 100644 --- a/src/core/ifirmware.h +++ b/src/core/ifirmware.h @@ -1,92 +1,99 @@ /* AtCore Copyright (C) <2016> Authors: Tomaz Canabrava Chris Rizzitello Patrick José Pereira This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) version 3, or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 6 of version 3 of the license. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ #pragma once #include #include #include "atcore_export.h" class Temperature; class AtCore; struct IFirmwarePrivate; /** * @brief The IFirmware class * Base Class for Firmware Plugins */ class ATCORE_EXPORT IFirmware : public QObject { Q_OBJECT Q_PROPERTY(QString name READ name) + Q_PROPERTY(bool sdSupport READ isSdSupported) public: IFirmware(); void init(AtCore *parent); ~IFirmware() override; + /** + * @brief Check for plugin support of sd cards. + * @return True if firmware plugin supports sd cards. + */ + virtual bool isSdSupported() const = 0; + /** * @brief Virtual name to be reimplemnted by Firmware plugin * * Return the name the firmware the plugin is for * @return Firmware Name */ virtual QString name() const = 0; /** * @brief Vitural validateCommand to filter commands from messages * @param lastMessage: last Message from printer */ virtual void validateCommand(const QString &lastMessage); /** * @brief Virtual translate to be reimplemnted by Firmwareplugin * * Translate common commands to firmware specific command. * @param command: Command command to translate * @return firmware specific translated command */ virtual QByteArray translate(const QString &command); /** * @brief AtCore Parent of the firmware plugin * @return */ AtCore *core() const; private: IFirmwarePrivate *d; public slots: /** * @brief call Validate Command * @param lastMessage: last message from printer */ void checkCommand(const QByteArray &lastMessage); signals: /** * @brief emit when firmware is ready for a command */ void readyForCommand(void); }; Q_DECLARE_INTERFACE(IFirmware, "org.kde.atelier.core.firmware") diff --git a/src/plugins/aprinterplugin.cpp b/src/plugins/aprinterplugin.cpp index 8280059..a592cea 100644 --- a/src/plugins/aprinterplugin.cpp +++ b/src/plugins/aprinterplugin.cpp @@ -1,41 +1,46 @@ /* AtCore KDE Libary for 3D Printers Copyright (C) <2016> Authors: Tomaz Canabrava Chris Rizzitello Patrick José Pereira This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) version 3, or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 6 of version 3 of the license. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ #include #include #include "aprinterplugin.h" #include "atcore.h" Q_LOGGING_CATEGORY(APRINTER_PLUGIN, "org.kde.atelier.core.firmware.aprinter") QString AprinterPlugin::name() const { return QStringLiteral("Aprinter"); } +bool AprinterPlugin::isSdSupported() const +{ + return false; +} + AprinterPlugin::AprinterPlugin() { qCDebug(APRINTER_PLUGIN) << name() << " plugin loaded!"; } diff --git a/src/plugins/aprinterplugin.h b/src/plugins/aprinterplugin.h index a4fa07d..783ae6e 100644 --- a/src/plugins/aprinterplugin.h +++ b/src/plugins/aprinterplugin.h @@ -1,51 +1,57 @@ /* AtCore KDE Libary for 3D Printers Copyright (C) <2016> Authors: Tomaz Canabrava Chris Rizzitello Patrick José Pereira This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) version 3, or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 6 of version 3 of the license. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ #pragma once #include #include "ifirmware.h" /** * @brief The AprinterPlugin class * Plugin for Aprinter */ class AprinterPlugin : public IFirmware { Q_OBJECT Q_PLUGIN_METADATA(IID "org.kde.atelier.core.firmware") Q_INTERFACES(IFirmware) public: /** * @brief Create new AprinterPlugin */ AprinterPlugin(); + /** + * @brief Check for plugin support of sd cards. + * @return True if firmware plugin supports sd cards. + */ + virtual bool isSdSupported() const override; + /** * @brief Return Plugin name * @return Aprinter */ QString name() const override; }; diff --git a/src/plugins/grblplugin.cpp b/src/plugins/grblplugin.cpp index 945d2b4..845a18c 100644 --- a/src/plugins/grblplugin.cpp +++ b/src/plugins/grblplugin.cpp @@ -1,72 +1,77 @@ /* AtCore KDE Libary for 3D Printers Copyright (C) <2016> Authors: Tomaz Canabrava Chris Rizzitello Patrick José Pereira This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) version 3, or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 6 of version 3 of the license. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ #include #include #include #include "grblplugin.h" Q_LOGGING_CATEGORY(GRBL_PLUGIN, "org.kde.atelier.core.firmware.grbl") QString GrblPlugin::name() const { return QStringLiteral("Grbl"); } GrblPlugin::GrblPlugin() { qCDebug(GRBL_PLUGIN) << name() << " plugin loaded!"; } +bool GrblPlugin::isSdSupported() const +{ + return false; +} + void GrblPlugin::validateCommand(const QString &lastMessage) { if (lastMessage.contains(QStringLiteral("ok"))) { emit readyForCommand(); } } QByteArray GrblPlugin::translate(const QString &command) { QString temp = command; //Match all G and M commands followed by one or more digits up to and include the space, //if thats followed by a letter capture any non G or M starting text //else just grab the digits that follow. //ex: G28 X Y M1 would capture "G28 X Y" and "M1" static const auto regEx = QRegularExpression(QStringLiteral("[GM]\\d+.(?(?=\\D)[^GM]+|\\d+)?")); QRegularExpressionMatch secondCommand = regEx.match(temp, 1); if (secondCommand.hasMatch()) { QRegularExpressionMatchIterator commandMatch = regEx.globalMatch(temp); temp.clear(); while (commandMatch.hasNext()) { QRegularExpressionMatch t = commandMatch.next(); temp.append(t.captured().simplified()); if (commandMatch.hasNext()) { temp.append(QStringLiteral("\r\n")); } } } return temp.toLocal8Bit(); } diff --git a/src/plugins/grblplugin.h b/src/plugins/grblplugin.h index e29bdaf..6c7acfc 100644 --- a/src/plugins/grblplugin.h +++ b/src/plugins/grblplugin.h @@ -1,64 +1,70 @@ /* AtCore KDE Libary for 3D Printers Copyright (C) <2016> Authors: Tomaz Canabrava Chris Rizzitello Patrick José Pereira This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) version 3, or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 6 of version 3 of the license. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ #pragma once #include #include "ifirmware.h" /** * @brief The GrblPlugin class * Plugin for Grbl */ class GrblPlugin : public IFirmware { Q_OBJECT Q_PLUGIN_METADATA(IID "org.kde.atelier.core.firmware") Q_INTERFACES(IFirmware) public: /** * @brief Create new GrblPlugin */ GrblPlugin(); /** * @brief Return Plugin name * @return Grbl */ QString name() const override; /** - * @brief Grbl does not return anything on command execution - * @param lastMessage: last message from printer + * @brief sdSupport + * @return True if plugins supports sd cards */ - void validateCommand(const QString &lastMessage) override; + bool isSdSupported() const override; /** * @brief Translate common commands to firmware specific command. * @param command: command to translate * @return firmware specific translated command */ QByteArray translate(const QString &command) override; + + /** + * @brief Grbl does not return anything on command execution + * @param lastMessage: last message from printer + */ + void validateCommand(const QString &lastMessage) override; }; diff --git a/src/plugins/marlinplugin.cpp b/src/plugins/marlinplugin.cpp index 57e57bd..d4f7375 100644 --- a/src/plugins/marlinplugin.cpp +++ b/src/plugins/marlinplugin.cpp @@ -1,93 +1,98 @@ /* AtCore KDE Libary for 3D Printers Copyright (C) <2016> Authors: Tomaz Canabrava Chris Rizzitello Patrick José Pereira This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) version 3, or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 6 of version 3 of the license. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ #include #include #include "marlinplugin.h" #include "atcore.h" Q_LOGGING_CATEGORY(MARLIN_PLUGIN, "org.kde.atelier.core.firmware.marlin") QString MarlinPlugin::name() const { return QStringLiteral("Marlin"); } +bool MarlinPlugin::isSdSupported() const +{ + return true; +} + MarlinPlugin::MarlinPlugin() { qCDebug(MARLIN_PLUGIN) << name() << " plugin loaded!"; } void MarlinPlugin::validateCommand(const QString &lastMessage) { if (lastMessage.contains(QStringLiteral("End file list"))) { core()->setReadingSdCardList(false); } else if (core()->isReadingSdCardList()) { // Below is to not add directories if (!lastMessage.endsWith(QChar::fromLatin1('/'))) { QString fileName = lastMessage; fileName.chop(fileName.length() - fileName.lastIndexOf(QChar::fromLatin1(' '))); core()->appendSdCardFileList(fileName); } } else { if (lastMessage.contains(QStringLiteral("SD card ok"))) { core()->setSdMounted(true); } else if (lastMessage.contains(QStringLiteral("SD init fail"))) { core()->setSdMounted(false); } else if (lastMessage.contains(QStringLiteral("Begin file list"))) { core()->setSdMounted(true); core()->clearSdCardFileList(); core()->setReadingSdCardList(true); } else if (lastMessage.contains(QStringLiteral("SD printing byte"))) { if (core()->state() != AtCore::BUSY) { //This should only happen if Attached to an Sd printing machine. //Just tell the client were starting a job like normal. //For this to work the client should check if sdCardPrintStatus() //Upon the Connection to a known firmware with sdSupport core()->setState(AtCore::STARTPRINT); core()->setState(AtCore::BUSY); } QString temp = lastMessage; temp.replace(QStringLiteral("SD printing byte"), QString()); qlonglong total = temp.mid(temp.lastIndexOf(QChar::fromLatin1('/')) + 1, temp.length() - temp.lastIndexOf(QChar::fromLatin1('/'))).toLongLong(); if (total) { temp.chop(temp.length() - temp.lastIndexOf(QChar::fromLatin1('/'))); qlonglong remaining = total - temp.toLongLong(); float progress = float(total - remaining) * 100 / float(total); core()->printProgressChanged(progress); if (progress >= 100) { core()->setState(AtCore::FINISHEDPRINT); core()->setState(AtCore::IDLE); } } else { core()->setState(AtCore::FINISHEDPRINT); core()->setState(AtCore::IDLE); } } if (lastMessage.contains(QStringLiteral("ok"))) { emit readyForCommand(); } } } diff --git a/src/plugins/marlinplugin.h b/src/plugins/marlinplugin.h index 3fa5306..fabd709 100644 --- a/src/plugins/marlinplugin.h +++ b/src/plugins/marlinplugin.h @@ -1,57 +1,63 @@ /* AtCore KDE Libary for 3D Printers Copyright (C) <2016> Authors: Tomaz Canabrava Chris Rizzitello Patrick José Pereira This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) version 3, or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 6 of version 3 of the license. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ #pragma once #include #include "ifirmware.h" /** * @brief The MarlinPlugin class * Plugin for Marlin */ class MarlinPlugin : public IFirmware { Q_OBJECT Q_PLUGIN_METADATA(IID "org.kde.atelier.core.firmware") Q_INTERFACES(IFirmware) public: /** * @brief Create new MarlinPlugin */ MarlinPlugin(); + /** + * @brief Check for plugin support of sd cards. + * @return True if firmware plugin supports sd cards. + */ + virtual bool isSdSupported() const override; + /** * @brief Return Plugin name * @return Marlin */ QString name() const override; /** * @brief validateCommand to filter commands from messages * @param lastMessage: last Message from printer */ void validateCommand(const QString &lastMessage) override; }; diff --git a/src/plugins/repetierplugin.cpp b/src/plugins/repetierplugin.cpp index 5a58d4a..26c0e61 100644 --- a/src/plugins/repetierplugin.cpp +++ b/src/plugins/repetierplugin.cpp @@ -1,99 +1,104 @@ /* AtCore KDE Libary for 3D Printers Copyright (C) <2016> Authors: Tomaz Canabrava Chris Rizzitello Patrick José Pereira This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) version 3, or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 6 of version 3 of the license. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ #include #include #include "repetierplugin.h" #include "atcore.h" Q_LOGGING_CATEGORY(REPETIER_PLUGIN, "org.kde.atelier.core.firmware.repetier") QString RepetierPlugin::name() const { return QStringLiteral("Repetier"); } +bool RepetierPlugin::isSdSupported() const +{ + return true; +} + RepetierPlugin::RepetierPlugin() { qCDebug(REPETIER_PLUGIN) << name() << " plugin loaded!"; } void RepetierPlugin::validateCommand(const QString &lastMessage) { if (lastMessage.contains(QStringLiteral("End file list"))) { core()->setReadingSdCardList(false); } else if (core()->isReadingSdCardList()) { // Below is to not add directories if (!lastMessage.endsWith(QChar::fromLatin1('/'))) { QString fileName = lastMessage; fileName.chop(fileName.length() - fileName.lastIndexOf(QChar::fromLatin1(' '))); core()->appendSdCardFileList(fileName); } } else { if (lastMessage.contains(QStringLiteral("SD card"))) { if (lastMessage.contains(QStringLiteral("inserted"))) { core()->setSdMounted(true); } else if (lastMessage.contains(QStringLiteral("removed"))) { core()->setSdMounted(false); } } else if (lastMessage.contains(QStringLiteral("Begin file list"))) { core()->setSdMounted(true); core()->setReadingSdCardList(true); core()->clearSdCardFileList(); } else if (lastMessage.contains(QStringLiteral("SD printing byte"))) { if (lastMessage.contains(QStringLiteral("SD printing byte 0/0"))) { //not printing a file return; } if (core()->state() != AtCore::BUSY) { //This should only happen if Attached to an Sd printing machine. //Just tell the client were starting a job like normal. //For this to work the client should check if sdCardPrintStatus() //Upon the Connection to a known firmware with sdSupport core()->setState(AtCore::STARTPRINT); core()->setState(AtCore::BUSY); } QString temp = lastMessage; temp.replace(QStringLiteral("SD printing byte"), QString()); qlonglong total = temp.mid(temp.lastIndexOf(QChar::fromLatin1('/')) + 1, temp.length() - temp.lastIndexOf(QChar::fromLatin1('/'))).toLongLong(); if (total) { temp.chop(temp.length() - temp.lastIndexOf(QChar::fromLatin1('/'))); qlonglong remaining = total - temp.toLongLong(); float progress = float(total - remaining) * 100 / float(total); core()->printProgressChanged(progress); if (progress >= 100) { core()->setState(AtCore::FINISHEDPRINT); core()->setState(AtCore::IDLE); } } else { core()->setState(AtCore::FINISHEDPRINT); core()->setState(AtCore::IDLE); } } if (lastMessage.contains(QStringLiteral("ok"))) { emit readyForCommand(); } } } diff --git a/src/plugins/repetierplugin.h b/src/plugins/repetierplugin.h index 91239b7..a00a2ec 100644 --- a/src/plugins/repetierplugin.h +++ b/src/plugins/repetierplugin.h @@ -1,57 +1,63 @@ /* AtCore KDE Libary for 3D Printers Copyright (C) <2016> Authors: Tomaz Canabrava Chris Rizzitello Patrick José Pereira This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) version 3, or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 6 of version 3 of the license. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ #pragma once #include #include "ifirmware.h" /** * @brief The RepetierPlugin class * Plugin for Repetier */ class RepetierPlugin : public IFirmware { Q_OBJECT Q_PLUGIN_METADATA(IID "org.kde.atelier.core.firmware") Q_INTERFACES(IFirmware) public: /** * @brief Create new RepetierPlugin */ RepetierPlugin(); + /** + * @brief Check for plugin support of sd cards. + * @return True if firmware plugin supports sd cards. + */ + virtual bool isSdSupported() const override; + /** * @brief Return Plugin name * @return Repetier */ QString name() const override; /** * @brief validateCommand to filter commands from messages * @param lastMessage: last Message from printer */ void validateCommand(const QString &lastMessage) override; }; diff --git a/src/plugins/smoothieplugin.cpp b/src/plugins/smoothieplugin.cpp index 3ea803e..f335fb0 100644 --- a/src/plugins/smoothieplugin.cpp +++ b/src/plugins/smoothieplugin.cpp @@ -1,41 +1,46 @@ /* AtCore KDE Libary for 3D Printers Copyright (C) <2016> Authors: Tomaz Canabrava Chris Rizzitello Patrick José Pereira This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) version 3, or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 6 of version 3 of the license. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ #include #include #include "smoothieplugin.h" #include "atcore.h" Q_LOGGING_CATEGORY(SMOOTHIE_PLUGIN, "org.kde.atelier.core.firmware.smoothie") QString SmoothiePlugin::name() const { return QStringLiteral("Smoothie"); } +bool SmoothiePlugin::isSdSupported() const +{ + return false; +} + SmoothiePlugin::SmoothiePlugin() { qCDebug(SMOOTHIE_PLUGIN) << name() << " plugin loaded!"; } diff --git a/src/plugins/smoothieplugin.h b/src/plugins/smoothieplugin.h index a0d3355..47f1675 100644 --- a/src/plugins/smoothieplugin.h +++ b/src/plugins/smoothieplugin.h @@ -1,51 +1,57 @@ /* AtCore KDE Libary for 3D Printers Copyright (C) <2016> Authors: Tomaz Canabrava Chris Rizzitello Patrick José Pereira This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) version 3, or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 6 of version 3 of the license. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ #pragma once #include #include "ifirmware.h" /** * @brief The SmoothiePlugin class * Plugin for Smoothie */ class SmoothiePlugin : public IFirmware { Q_OBJECT Q_PLUGIN_METADATA(IID "org.kde.atelier.core.firmware") Q_INTERFACES(IFirmware) public: /** * @brief Create new SmoothiePlugin */ SmoothiePlugin(); + /** + * @brief Check for plugin support of sd cards. + * @return True if firmware plugin supports sd cards. + */ + virtual bool isSdSupported() const override; + /** * @brief Return Plugin name * @return Smoothie */ QString name() const override; }; diff --git a/src/plugins/sprinterplugin.cpp b/src/plugins/sprinterplugin.cpp index 0d3dc66..90c57cd 100644 --- a/src/plugins/sprinterplugin.cpp +++ b/src/plugins/sprinterplugin.cpp @@ -1,41 +1,46 @@ /* AtCore KDE Libary for 3D Printers Copyright (C) <2016> Authors: Tomaz Canabrava Chris Rizzitello Patrick José Pereira This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) version 3, or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 6 of version 3 of the license. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ #include #include #include "sprinterplugin.h" #include "atcore.h" Q_LOGGING_CATEGORY(SPRINTER_PLUGIN, "org.kde.atelier.core.firmware.sprinter") QString SprinterPlugin::name() const { return QStringLiteral("Sprinter"); } +bool SprinterPlugin::isSdSupported() const +{ + return false; +} + SprinterPlugin::SprinterPlugin() { qCDebug(SPRINTER_PLUGIN) << name() << " plugin loaded!"; } diff --git a/src/plugins/sprinterplugin.h b/src/plugins/sprinterplugin.h index 0edd93c..5b74b5e 100644 --- a/src/plugins/sprinterplugin.h +++ b/src/plugins/sprinterplugin.h @@ -1,51 +1,58 @@ /* AtCore KDE Libary for 3D Printers Copyright (C) <2016> Authors: Tomaz Canabrava Chris Rizzitello Patrick José Pereira This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) version 3, or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 6 of version 3 of the license. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ #pragma once #include #include "ifirmware.h" /** * @brief The SprinterPlugin class * Plugin for Sprinter */ class SprinterPlugin : public IFirmware { Q_OBJECT Q_PLUGIN_METADATA(IID "org.kde.atelier.core.firmware") Q_INTERFACES(IFirmware) public: /** * @brief Create new SprinterPlugin */ SprinterPlugin(); + /** + * @brief Check for plugin support of sd cards. + * @return True if firmware plugin supports sd cards. + */ + virtual bool isSdSupported() const override; + /** * @brief Return Plugin name * @return Sprinter */ QString name() const override; + }; diff --git a/src/plugins/teacupplugin.cpp b/src/plugins/teacupplugin.cpp index 86423f9..dee9a70 100644 --- a/src/plugins/teacupplugin.cpp +++ b/src/plugins/teacupplugin.cpp @@ -1,54 +1,59 @@ /* AtCore KDE Libary for 3D Printers Copyright (C) <2016> Authors: Tomaz Canabrava Chris Rizzitello Patrick José Pereira This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) version 3, or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 6 of version 3 of the license. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ #include #include #include "teacupplugin.h" #include "atcore.h" Q_LOGGING_CATEGORY(TEACUP_PLUGIN, "org.kde.atelier.core.firmware.teacup") QString TeacupPlugin::name() const { return QStringLiteral("Teacup"); } +bool TeacupPlugin::isSdSupported() const +{ + return false; +} + TeacupPlugin::TeacupPlugin() { qCDebug(TEACUP_PLUGIN) << name() << " plugin loaded!"; } QByteArray TeacupPlugin::translate(const QString &command) { QString temp = command; if (command.contains(QStringLiteral("M109"))) { temp.replace(QStringLiteral("M109"), QStringLiteral("M104")); temp.append(QStringLiteral("\r\nM116")); } else if (command.contains(QStringLiteral("M190"))) { temp.replace(QStringLiteral("M190"), QStringLiteral("M140")); temp.append(QStringLiteral("\r\nM116")); } return temp.toLocal8Bit(); } diff --git a/src/plugins/teacupplugin.h b/src/plugins/teacupplugin.h index ef857db..f5d88a3 100644 --- a/src/plugins/teacupplugin.h +++ b/src/plugins/teacupplugin.h @@ -1,58 +1,64 @@ /* AtCore KDE Libary for 3D Printers Copyright (C) <2016> Authors: Tomaz Canabrava Chris Rizzitello Patrick José Pereira This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) version 3, or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 6 of version 3 of the license. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ #pragma once #include #include "ifirmware.h" /** * @brief The TeacupPlugin class * Plugin for Teacup */ class TeacupPlugin : public IFirmware { Q_OBJECT Q_PLUGIN_METADATA(IID "org.kde.atelier.core.firmware") Q_INTERFACES(IFirmware) public: /** * @brief Create new TeacupPlugin */ TeacupPlugin(); + /** + * @brief Check for plugin support of sd cards. + * @return True if firmware plugin supports sd cards. + */ + virtual bool isSdSupported() const override; + /** * @brief Return Plugin name * @return Teacup */ QString name() const override; /** * @brief Translate common commands to firmware specific command. * @param command: command to translate * @return firmware specific translated command */ QByteArray translate(const QString &command) override; };