ThymioFlasher.h
Go to the documentation of this file.
00001 #ifndef THYMIO_FLASHER_H
00002 #define THYMIO_FLASHER_H
00003 
00004 #include <QWidget>
00005 #include <QFuture>
00006 #include <QFutureWatcher>
00007 #include <dashel/dashel.h>
00008 #include "../utils/BootloaderInterface.h"
00009 
00010 class QVBoxLayout;
00011 class QHBoxLayout;
00012 class QProgressBar;
00013 class QPushButton;
00014 class QLineEdit;
00015 class QListWidget;
00016 class QGroupBox;
00017 
00018 namespace Aseba
00019 {
00022         
00023         class QtBootloaderInterface:public QObject, public BootloaderInterface
00024         {
00025                 Q_OBJECT
00026                 
00027         public:
00028                 QtBootloaderInterface(Dashel::Stream* stream, int dest);
00029                 
00030         protected:
00031                 virtual void writeHexGotDescription(unsigned pagesCount);
00032                 virtual void writePageStart(unsigned pageNumber, const uint8* data, bool simple);
00033                 virtual void errorWritePageNonFatal(unsigned pageNumber);
00034         
00035         protected:
00036                 unsigned pagesCount;
00037                 unsigned pagesDoneCount;
00038                 
00039         signals:
00040                 void flashProgress(int percentage);
00041         };
00042         
00043         class ThymioFlasherDialog : public QWidget
00044         {
00045                 Q_OBJECT
00046                 
00047         private:
00048                 struct FlashResult
00049                 {
00050                         enum Status
00051                         {
00052                                 SUCCESS = 0,
00053                                 WARNING,
00054                                 FAILURE
00055                         } status;
00056                         QString title;
00057                         QString text;
00058                         
00059                         FlashResult():status(SUCCESS) {}
00060                         FlashResult(Status status, const QString& title, const QString& text):status(status), title(title), text(text) {}
00061                 };
00062                 
00063         private:
00064                 std::string target;
00065                 QVBoxLayout* mainLayout;
00066                 QHBoxLayout* fileLayout;
00067                 QHBoxLayout* flashLayout;
00068                 QLineEdit* lineEdit;
00069                 QPushButton* fileButton;
00070                 QProgressBar* progressBar;
00071                 QPushButton* flashButton;
00072                 QPushButton* quitButton;
00073                 QFuture<FlashResult> flashFuture;
00074                 QFutureWatcher<FlashResult> flashFutureWatcher;
00075 
00076         public:
00077                 ThymioFlasherDialog(const std::string& target);
00078                 ~ThymioFlasherDialog();
00079                 
00080         private:
00081                 FlashResult flashThread(const std::string& _target, const std::string& hexFileName) const;
00082         
00083         private slots:
00084                 void setupFlashButtonState();
00085                 void openFile(void);
00086                 void doFlash(void);
00087                 void flashProgress(int percentage);
00088                 void flashFinished();
00089         };
00090         
00092 }; // Aseba
00093 
00094 #endif // THYMIO_FLASHER_H
00095 


aseba
Author(s): Stéphane Magnenat
autogenerated on Sun Oct 5 2014 23:46:39