File indexing completed on 2024-05-12 04:41:10
0001 /* AtCore KDE Libary for 3D Printers 0002 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0003 SPDX-FileCopyrightText: 2016, 2018 Tomaz Canabrava <tcanabrava@kde.org> 0004 SPDX-FileCopyrightText: 2016-2019 Chris Rizzitello <rizzitello@kde.org> 0005 SPDX-FileCopyrightText: 2016-2019 Patrick José Pereira <patrickjp@kde.org> 0006 SPDX-FileCopyrightText: 2016, 2019 Lays Rodrigues <lays.rodrigues@kde.org> 0007 SPDX-FileCopyrightText: 2018 Leandro Santiago <leandrosansilva@gmail.com> 0008 */ 0009 0010 #pragma once 0011 0012 #include <QObject> 0013 #include <QString> 0014 0015 #include "atcore_export.h" 0016 0017 class Temperature; 0018 class AtCore; 0019 0020 /** 0021 * @brief The IFirmware class 0022 * Base Class for Firmware Plugins 0023 */ 0024 class ATCORE_EXPORT IFirmware : public QObject 0025 { 0026 Q_OBJECT 0027 Q_PROPERTY(QString name READ name CONSTANT) 0028 Q_PROPERTY(bool sdSupport READ isSdSupported CONSTANT) 0029 public: 0030 IFirmware(); 0031 void init(AtCore *parent); 0032 ~IFirmware() override; 0033 0034 /** 0035 * @brief Check for plugin support of sd cards. 0036 * @return True if firmware plugin supports sd cards. 0037 */ 0038 virtual bool isSdSupported() const = 0; 0039 0040 /** 0041 * @brief Virtual name to be reimplemented by Firmware plugin 0042 * 0043 * Return the name the firmware the plugin is for 0044 * @return Firmware Name 0045 */ 0046 virtual QString name() const = 0; 0047 0048 /** 0049 * @brief Virtual validateCommand to filter commands from messages 0050 * @param lastMessage: last Message from printer 0051 */ 0052 virtual void validateCommand(const QString &lastMessage); 0053 0054 /** 0055 * @brief Virtual translate to be reimplemented by Firmwareplugin 0056 * 0057 * Translate common commands to firmware specific command. 0058 * @param command: Command command to translate 0059 * @return firmware specific translated command 0060 */ 0061 virtual QByteArray translate(const QString &command); 0062 0063 /** 0064 * @brief AtCore Parent of the firmware plugin 0065 * @return 0066 */ 0067 AtCore *core() const; 0068 0069 private: 0070 struct IFirmwarePrivate; 0071 IFirmwarePrivate *d; 0072 public slots: 0073 /** 0074 * @brief call Validate Command 0075 * @param lastMessage: last message from printer 0076 */ 0077 void checkCommand(const QByteArray &lastMessage); 0078 signals: 0079 /** 0080 * @brief emit when firmware is ready for a command 0081 */ 0082 void readyForCommand(void); 0083 }; 0084 0085 Q_DECLARE_INTERFACE(IFirmware, "org.kde.atelier.core.firmware")