iCub-main
mainwindow.h
Go to the documentation of this file.
1 #ifndef MAINWINDOW_H
2 #define MAINWINDOW_H
3 
4 #include <QMutex>
5 #include <QMainWindow>
6 #include "firmwareupdatercore.h"
7 #include "selectioncheckbox.h"
8 #include <QTreeWidgetItem>
9 #include <QProgressBar>
10 #include <QLabel>
11 #include <QPair>
12 #include <QFutureWatcher>
13 #include "calibrationwindow.h"
14 #include "customtreewidgetitem.h"
15 namespace Ui {
16 class MainWindow;
17 }
18 
19 
20 class MainWindow : public QMainWindow
21 {
22  Q_OBJECT
23 
24 public:
25  explicit MainWindow(FirmwareUpdaterCore *core,bool adminMode/*,bool strainCalibMode = false*/,QWidget *parent = 0);
26  ~MainWindow();
27 
28  void refreshDevices();
29 
30 private:
31  void removeChildren(QTreeWidgetItem *);
32 
33  void checkConnectionButton(QTreeWidgetItem*);
34  void checkSelButton(QTreeWidgetItem*);
35  void emptyNode(QTreeWidgetItem *it);
36  void populateInfo(int boardNum);
37  void populateCANinfo(sBoard canboard);
38  void getCanBoards(QTreeWidgetItem *it, bool refresh = false);
39  void checkEnableButtons();
40  void setEthBoardInfo(int index,QString info, QTreeWidgetItem *refreshNode = NULL);
41  void setCanBoardInfo (QPair<int, int> canData, QString info, QString address = "", int deviceId = -1, QTreeWidgetItem *refreshNode = NULL);
42  void setCanBoardAddress(QPair<int, int> canData, int canType, QPair<QString,QString>addr, int deviceId = -1, QTreeWidgetItem *refreshNode = NULL);
43  void setEthBoardAddress(int index,QString address, QTreeWidgetItem *refreshNode = NULL);
44 
45  //void loading(bool, bool disableAll = false);
46  void setNodeRestartNeed(QTreeWidgetItem *refreshNode, bool need = true);
47  void uploadEthApplication(QString);
48  void uploadCanApplication(QString filename, QString address = "", int deviceId = -1, CustomTreeWidgetItem *node = NULL);
49  void uploadLoader(QString);
50  void uploadUpdater(QString);
51  void checkSelection(bool selected, CustomTreeWidgetItem *c);
52 
53 
54 private:
55  Ui::MainWindow *ui;
56  CalibrationWindow *calibDlg;
57  FirmwareUpdaterCore *core;
58  QProgressBar *progress;
59  QLabel *infoResult;
60  QMutex loadingMutex;
61  QMutex mutex1;
62  QList<CustomTreeWidgetItem *> selectedNodes;
63  bool isLoading;
64  QTreeWidget *infoTreeWidget;
65  int loadCounter;
66  QFutureWatcher<bool> watcher;
67  icubCanProto_boardType_t sgboardtype;
68  QString device;
69 
70 signals:
71  void appendInfo(boardInfo2_t,eOipv4addr_t);
72  void appendInfo(QString = "");
73  void appendInfo(sBoard canboard);
74  void canBoardsRetrieved(QTreeWidgetItem *it, bool refresh);
75  void refreshEthBoardsNode(QTreeWidgetItem*, bool refresh = false, bool refreshAll = false);
76  void setInfoRes(QString);
79  void refreshCanBoardsFromEth(QTreeWidgetItem*);
80  void needLoading(bool,bool,QString = "",bool = true);
81 
82 
83 
84 private slots:
85  void onFutureFinished();
86  void loading(bool, bool disableAll = false, QString msg = "", bool infiniteLoad = true);
87  void onNeedSetRestartOnSelected();
88  void onUpdateProgressBar(float fraction);
89  void onUploadApplication(bool);
90  void onUploadLoader(bool);
91  void onUploadUpdater(bool);
92  void onBootUpdater(bool);
93  void onJumpToUpdater(bool click);
94  void onGoToMaintenance(bool click);
95  void onGoToApplication(bool click);
96  void onEraseEprom(bool click);
97  void onStrainCalib(bool click);
98  void onBootApplication(bool);
99  void onCalibrate(bool);
100  void populateEthBoardsNode(QTreeWidgetItem*, bool refreshSingleNode = false, bool refreshAll = false);
101  void onDeviceSelectionChanged();
102  void onConnect();
103  void onSel(void);
104  void onDes(void);
105  void onAppendInfo(sBoard);
106  void onAppendInfo(QString);
107  void onAppendInfo(boardInfo2_t, eOipv4addr_t address);
108  void onSelectionChanged(bool selected);
109  void onDeviceExpanded(QTreeWidgetItem*);
110  void onCanBoardsRetrieved(QTreeWidgetItem *it, bool refresh);
111  void onBlinkPressed(bool);
112  void onChangeInfo(bool);
113  void onSelectionCheckDestroy(QObject*);
114  void onChangeAddress(bool);
115  void onRestartBoards(bool click);
116 
117  //void onRestartBoards5Secs(bool click);
118  void onSetInfoRes(QString);
119  bool getCANaddress(CustomTreeWidgetItem *child, int &cbus, int &adr, QString &cbustr, QString &cadrstr);
120  bool getDeviceID(QTreeWidgetItem *child, QString &idstr, QString &devicestr);
121  bool getDeviceID(QString devicefullstring, QString &idstr, QString &devicestr);
122 };
123 
124 #endif // MAINWINDOW_H
void refreshDevices()
void appendInfo(sBoard canboard)
void needSetRestartOnSelected()
void refreshCanBoardsFromEth(QTreeWidgetItem *)
void deviceSelectionChanged()
void setInfoRes(QString)
void appendInfo(QString="")
MainWindow(FirmwareUpdaterCore *core, bool adminMode, QWidget *parent=0)
Definition: mainwindow.cpp:13
void needLoading(bool, bool, QString="", bool=true)
void canBoardsRetrieved(QTreeWidgetItem *it, bool refresh)
void appendInfo(boardInfo2_t, eOipv4addr_t)
void refreshEthBoardsNode(QTreeWidgetItem *, bool refresh=false, bool refreshAll=false)