Commit 538041ab9f387145513beaa0d487a6899c78e59c
1 parent
42410a75c2
Exists in
master
and in
2 other branches
소스 코드 구조 개선
- UdpHandler를 싱글톤 구조로 변경 - MainWindow 생성자에서 수행하던 초기화 작업을 main 함수로 이전 - Oven의 생성자를 private으로 지정
Showing
28 changed files
with
133 additions
and
114 deletions
Show diff stats
app/gui/oven_control/burnertestwindow.cpp
| @@ -3,15 +3,17 @@ | @@ -3,15 +3,17 @@ | ||
| 3 | 3 | ||
| 4 | #include <QTimer> | 4 | #include <QTimer> |
| 5 | 5 | ||
| 6 | -BurnerTestWindow::BurnerTestWindow(QWidget *parent, UdpHandler *udp) : | 6 | +BurnerTestWindow::BurnerTestWindow(QWidget *parent) : |
| 7 | QMainWindow(parent), | 7 | QMainWindow(parent), |
| 8 | - ui(new Ui::BurnerTestWindow), udp(udp) | 8 | + ui(new Ui::BurnerTestWindow) |
| 9 | { | 9 | { |
| 10 | ui->setupUi(this); | 10 | ui->setupUi(this); |
| 11 | 11 | ||
| 12 | ui->clockContainer->setParent(ui->upperStack); | 12 | ui->clockContainer->setParent(ui->upperStack); |
| 13 | setAttribute(Qt::WA_DeleteOnClose); | 13 | setAttribute(Qt::WA_DeleteOnClose); |
| 14 | 14 | ||
| 15 | + udp = UdpHandler::getInstance(); | ||
| 16 | + | ||
| 15 | steamTimer.setInterval(5 * 60 * 1000); | 17 | steamTimer.setInterval(5 * 60 * 1000); |
| 16 | upperTimer.setInterval(5 * 60 * 1000); | 18 | upperTimer.setInterval(5 * 60 * 1000); |
| 17 | lowerTimer.setInterval(5 * 60 * 1000); | 19 | lowerTimer.setInterval(5 * 60 * 1000); |
app/gui/oven_control/burnertestwindow.h
| @@ -15,7 +15,7 @@ class BurnerTestWindow : public QMainWindow | @@ -15,7 +15,7 @@ class BurnerTestWindow : public QMainWindow | ||
| 15 | Q_OBJECT | 15 | Q_OBJECT |
| 16 | 16 | ||
| 17 | public: | 17 | public: |
| 18 | - explicit BurnerTestWindow(QWidget *parent = 0, UdpHandler *udp = 0); | 18 | + explicit BurnerTestWindow(QWidget *parent = 0); |
| 19 | ~BurnerTestWindow(); | 19 | ~BurnerTestWindow(); |
| 20 | 20 | ||
| 21 | private slots: | 21 | private slots: |
app/gui/oven_control/componenttestwindow.cpp
| 1 | #include "componenttestwindow.h" | 1 | #include "componenttestwindow.h" |
| 2 | #include "ui_componenttestwindow.h" | 2 | #include "ui_componenttestwindow.h" |
| 3 | 3 | ||
| 4 | -ComponentTestWindow::ComponentTestWindow(QWidget *parent, UdpHandler *udp) : | 4 | +ComponentTestWindow::ComponentTestWindow(QWidget *parent) : |
| 5 | QMainWindow(parent), | 5 | QMainWindow(parent), |
| 6 | - ui(new Ui::ComponentTestWindow), udp(udp) | 6 | + ui(new Ui::ComponentTestWindow) |
| 7 | { | 7 | { |
| 8 | ui->setupUi(this); | 8 | ui->setupUi(this); |
| 9 | 9 | ||
| 10 | ui->clockContainer->setParent(ui->upperStack); | 10 | ui->clockContainer->setParent(ui->upperStack); |
| 11 | setAttribute(Qt::WA_DeleteOnClose); | 11 | setAttribute(Qt::WA_DeleteOnClose); |
| 12 | 12 | ||
| 13 | + udp = UdpHandler::getInstance(); | ||
| 13 | connect(udp, SIGNAL(changed()), this, SLOT(onDataChanged())); | 14 | connect(udp, SIGNAL(changed()), this, SLOT(onDataChanged())); |
| 14 | 15 | ||
| 15 | damperTimer.setInterval(10 * 1000); | 16 | damperTimer.setInterval(10 * 1000); |
app/gui/oven_control/componenttestwindow.h
| @@ -15,7 +15,7 @@ class ComponentTestWindow : public QMainWindow | @@ -15,7 +15,7 @@ class ComponentTestWindow : public QMainWindow | ||
| 15 | Q_OBJECT | 15 | Q_OBJECT |
| 16 | 16 | ||
| 17 | public: | 17 | public: |
| 18 | - explicit ComponentTestWindow(QWidget *parent = 0, UdpHandler *udp = 0); | 18 | + explicit ComponentTestWindow(QWidget *parent = 0); |
| 19 | ~ComponentTestWindow(); | 19 | ~ComponentTestWindow(); |
| 20 | 20 | ||
| 21 | private slots: | 21 | private slots: |
app/gui/oven_control/configwindow.cpp
| @@ -3,9 +3,9 @@ | @@ -3,9 +3,9 @@ | ||
| 3 | 3 | ||
| 4 | #include "functiontestwindow.h" | 4 | #include "functiontestwindow.h" |
| 5 | 5 | ||
| 6 | -ConfigWindow::ConfigWindow(QWidget *parent, UdpHandler *udp) : | 6 | +ConfigWindow::ConfigWindow(QWidget *parent) : |
| 7 | QMainWindow(parent), | 7 | QMainWindow(parent), |
| 8 | - ui(new Ui::ConfigWindow), udp(udp) | 8 | + ui(new Ui::ConfigWindow) |
| 9 | { | 9 | { |
| 10 | ui->setupUi(this); | 10 | ui->setupUi(this); |
| 11 | 11 | ||
| @@ -20,7 +20,7 @@ ConfigWindow::~ConfigWindow() | @@ -20,7 +20,7 @@ ConfigWindow::~ConfigWindow() | ||
| 20 | 20 | ||
| 21 | void ConfigWindow::on_pushButton_clicked() | 21 | void ConfigWindow::on_pushButton_clicked() |
| 22 | { | 22 | { |
| 23 | - FunctionTestWindow *w = new FunctionTestWindow(this, udp); | 23 | + FunctionTestWindow *w = new FunctionTestWindow(this); |
| 24 | w->setAttribute((Qt::WA_DeleteOnClose)); | 24 | w->setAttribute((Qt::WA_DeleteOnClose)); |
| 25 | w->showFullScreen(); | 25 | w->showFullScreen(); |
| 26 | } | 26 | } |
app/gui/oven_control/configwindow.h
| @@ -14,7 +14,7 @@ class ConfigWindow : public QMainWindow | @@ -14,7 +14,7 @@ class ConfigWindow : public QMainWindow | ||
| 14 | Q_OBJECT | 14 | Q_OBJECT |
| 15 | 15 | ||
| 16 | public: | 16 | public: |
| 17 | - explicit ConfigWindow(QWidget *parent = 0, UdpHandler *udp = 0); | 17 | + explicit ConfigWindow(QWidget *parent = 0); |
| 18 | ~ConfigWindow(); | 18 | ~ConfigWindow(); |
| 19 | 19 | ||
| 20 | private slots: | 20 | private slots: |
| @@ -22,7 +22,6 @@ private slots: | @@ -22,7 +22,6 @@ private slots: | ||
| 22 | 22 | ||
| 23 | private: | 23 | private: |
| 24 | Ui::ConfigWindow *ui; | 24 | Ui::ConfigWindow *ui; |
| 25 | - UdpHandler *udp; | ||
| 26 | }; | 25 | }; |
| 27 | 26 | ||
| 28 | #endif // CONFIGWINDOW_H | 27 | #endif // CONFIGWINDOW_H |
app/gui/oven_control/engineermenuwindow.cpp
| @@ -6,9 +6,9 @@ | @@ -6,9 +6,9 @@ | ||
| 6 | #include "functiontestwindow.h" | 6 | #include "functiontestwindow.h" |
| 7 | #include "ovenstatics.h" | 7 | #include "ovenstatics.h" |
| 8 | 8 | ||
| 9 | -engineermenuwindow::engineermenuwindow(QWidget *parent, UdpHandler *udp) : | 9 | +engineermenuwindow::engineermenuwindow(QWidget *parent) : |
| 10 | QMainWindow(parent), | 10 | QMainWindow(parent), |
| 11 | - ui(new Ui::engineermenuwindow), udp(udp) | 11 | + ui(new Ui::engineermenuwindow) |
| 12 | { | 12 | { |
| 13 | ui->setupUi(this); | 13 | ui->setupUi(this); |
| 14 | 14 | ||
| @@ -47,7 +47,7 @@ void engineermenuwindow::on_realdatabutton_clicked() | @@ -47,7 +47,7 @@ void engineermenuwindow::on_realdatabutton_clicked() | ||
| 47 | 47 | ||
| 48 | void engineermenuwindow::on_functiontestbutton_clicked() | 48 | void engineermenuwindow::on_functiontestbutton_clicked() |
| 49 | { | 49 | { |
| 50 | - FunctionTestWindow *w = new FunctionTestWindow(this, udp); | 50 | + FunctionTestWindow *w = new FunctionTestWindow(this); |
| 51 | w->setWindowModality(Qt::WindowModal); | 51 | w->setWindowModality(Qt::WindowModal); |
| 52 | w->showFullScreen(); | 52 | w->showFullScreen(); |
| 53 | w->raise(); | 53 | w->raise(); |
app/gui/oven_control/engineermenuwindow.h
| @@ -2,7 +2,6 @@ | @@ -2,7 +2,6 @@ | ||
| 2 | #define ENGINEERMENUWINDOW_H | 2 | #define ENGINEERMENUWINDOW_H |
| 3 | 3 | ||
| 4 | #include <QMainWindow> | 4 | #include <QMainWindow> |
| 5 | -#include "udphandler.h" | ||
| 6 | 5 | ||
| 7 | namespace Ui { | 6 | namespace Ui { |
| 8 | class engineermenuwindow; | 7 | class engineermenuwindow; |
| @@ -13,7 +12,7 @@ class engineermenuwindow : public QMainWindow | @@ -13,7 +12,7 @@ class engineermenuwindow : public QMainWindow | ||
| 13 | Q_OBJECT | 12 | Q_OBJECT |
| 14 | 13 | ||
| 15 | public: | 14 | public: |
| 16 | - explicit engineermenuwindow(QWidget *parent = 0 , UdpHandler *udp = 0); | 15 | + explicit engineermenuwindow(QWidget *parent = 0); |
| 17 | ~engineermenuwindow(); | 16 | ~engineermenuwindow(); |
| 18 | 17 | ||
| 19 | private slots: | 18 | private slots: |
| @@ -27,7 +26,6 @@ private slots: | @@ -27,7 +26,6 @@ private slots: | ||
| 27 | 26 | ||
| 28 | private: | 27 | private: |
| 29 | Ui::engineermenuwindow *ui; | 28 | Ui::engineermenuwindow *ui; |
| 30 | - UdpHandler *udp; | ||
| 31 | }; | 29 | }; |
| 32 | 30 | ||
| 33 | #endif // ENGINEERMENUWINDOW_H | 31 | #endif // ENGINEERMENUWINDOW_H |
app/gui/oven_control/fantestwindow.cpp
| 1 | #include "fantestwindow.h" | 1 | #include "fantestwindow.h" |
| 2 | #include "ui_fantestwindow.h" | 2 | #include "ui_fantestwindow.h" |
| 3 | 3 | ||
| 4 | -FanTestWindow::FanTestWindow(QWidget *parent, UdpHandler *udp) : | 4 | +FanTestWindow::FanTestWindow(QWidget *parent) : |
| 5 | QMainWindow(parent), | 5 | QMainWindow(parent), |
| 6 | - ui(new Ui::FanTestWindow), udp(udp) | 6 | + ui(new Ui::FanTestWindow) |
| 7 | { | 7 | { |
| 8 | ui->setupUi(this); | 8 | ui->setupUi(this); |
| 9 | 9 | ||
| 10 | ui->clockContainer->setParent(ui->upperStack); | 10 | ui->clockContainer->setParent(ui->upperStack); |
| 11 | setAttribute(Qt::WA_DeleteOnClose); | 11 | setAttribute(Qt::WA_DeleteOnClose); |
| 12 | 12 | ||
| 13 | + udp = UdpHandler::getInstance(); | ||
| 13 | connect(udp, SIGNAL(changed()), this, SLOT(onDataChanged())); | 14 | connect(udp, SIGNAL(changed()), this, SLOT(onDataChanged())); |
| 14 | 15 | ||
| 15 | currentFan = Fan1; | 16 | currentFan = Fan1; |
app/gui/oven_control/fantestwindow.h
| @@ -17,7 +17,7 @@ class FanTestWindow : public QMainWindow | @@ -17,7 +17,7 @@ class FanTestWindow : public QMainWindow | ||
| 17 | enum Direction { ClockWise, CounterClockWise }; | 17 | enum Direction { ClockWise, CounterClockWise }; |
| 18 | 18 | ||
| 19 | public: | 19 | public: |
| 20 | - explicit FanTestWindow(QWidget *parent = 0, UdpHandler *udp = 0); | 20 | + explicit FanTestWindow(QWidget *parent = 0); |
| 21 | ~FanTestWindow(); | 21 | ~FanTestWindow(); |
| 22 | 22 | ||
| 23 | private slots: | 23 | private slots: |
app/gui/oven_control/functiontestwindow.cpp
| @@ -8,9 +8,9 @@ | @@ -8,9 +8,9 @@ | ||
| 8 | #include "fantestwindow.h" | 8 | #include "fantestwindow.h" |
| 9 | #include "gastestwindow.h" | 9 | #include "gastestwindow.h" |
| 10 | 10 | ||
| 11 | -FunctionTestWindow::FunctionTestWindow(QWidget *parent, UdpHandler *udp) : | 11 | +FunctionTestWindow::FunctionTestWindow(QWidget *parent) : |
| 12 | QMainWindow(parent), | 12 | QMainWindow(parent), |
| 13 | - ui(new Ui::FunctionTestWindow), udp(udp) | 13 | + ui(new Ui::FunctionTestWindow) |
| 14 | { | 14 | { |
| 15 | ui->setupUi(this); | 15 | ui->setupUi(this); |
| 16 | 16 | ||
| @@ -27,31 +27,31 @@ FunctionTestWindow::~FunctionTestWindow() | @@ -27,31 +27,31 @@ FunctionTestWindow::~FunctionTestWindow() | ||
| 27 | 27 | ||
| 28 | void FunctionTestWindow::on_burnerTestButton_clicked() | 28 | void FunctionTestWindow::on_burnerTestButton_clicked() |
| 29 | { | 29 | { |
| 30 | - BurnerTestWindow *w = new BurnerTestWindow(this, udp); | 30 | + BurnerTestWindow *w = new BurnerTestWindow(this); |
| 31 | w->showFullScreen(); | 31 | w->showFullScreen(); |
| 32 | } | 32 | } |
| 33 | 33 | ||
| 34 | void FunctionTestWindow::on_componentTestButton_clicked() | 34 | void FunctionTestWindow::on_componentTestButton_clicked() |
| 35 | { | 35 | { |
| 36 | - ComponentTestWindow *w = new ComponentTestWindow(this, udp); | 36 | + ComponentTestWindow *w = new ComponentTestWindow(this); |
| 37 | w->showFullScreen(); | 37 | w->showFullScreen(); |
| 38 | } | 38 | } |
| 39 | 39 | ||
| 40 | void FunctionTestWindow::on_valveTestButton_clicked() | 40 | void FunctionTestWindow::on_valveTestButton_clicked() |
| 41 | { | 41 | { |
| 42 | - ValveTestWindow *w = new ValveTestWindow(this, udp); | 42 | + ValveTestWindow *w = new ValveTestWindow(this); |
| 43 | w->showFullScreen(); | 43 | w->showFullScreen(); |
| 44 | } | 44 | } |
| 45 | 45 | ||
| 46 | void FunctionTestWindow::on_washTestButton_clicked() | 46 | void FunctionTestWindow::on_washTestButton_clicked() |
| 47 | { | 47 | { |
| 48 | - WashTestWindow *w = new WashTestWindow(this, udp); | 48 | + WashTestWindow *w = new WashTestWindow(this); |
| 49 | w->showFullScreen(); | 49 | w->showFullScreen(); |
| 50 | } | 50 | } |
| 51 | 51 | ||
| 52 | void FunctionTestWindow::on_fanTestButton_clicked() | 52 | void FunctionTestWindow::on_fanTestButton_clicked() |
| 53 | { | 53 | { |
| 54 | - FanTestWindow *w = new FanTestWindow(this, udp); | 54 | + FanTestWindow *w = new FanTestWindow(this); |
| 55 | w->showFullScreen(); | 55 | w->showFullScreen(); |
| 56 | } | 56 | } |
| 57 | 57 |
app/gui/oven_control/functiontestwindow.h
| @@ -3,8 +3,6 @@ | @@ -3,8 +3,6 @@ | ||
| 3 | 3 | ||
| 4 | #include <QMainWindow> | 4 | #include <QMainWindow> |
| 5 | 5 | ||
| 6 | -#include "udphandler.h" | ||
| 7 | - | ||
| 8 | namespace Ui { | 6 | namespace Ui { |
| 9 | class FunctionTestWindow; | 7 | class FunctionTestWindow; |
| 10 | } | 8 | } |
| @@ -14,7 +12,7 @@ class FunctionTestWindow : public QMainWindow | @@ -14,7 +12,7 @@ class FunctionTestWindow : public QMainWindow | ||
| 14 | Q_OBJECT | 12 | Q_OBJECT |
| 15 | 13 | ||
| 16 | public: | 14 | public: |
| 17 | - explicit FunctionTestWindow(QWidget *parent = 0, UdpHandler *udp = 0); | 15 | + explicit FunctionTestWindow(QWidget *parent = 0); |
| 18 | ~FunctionTestWindow(); | 16 | ~FunctionTestWindow(); |
| 19 | 17 | ||
| 20 | private slots: | 18 | private slots: |
| @@ -32,7 +30,6 @@ private slots: | @@ -32,7 +30,6 @@ private slots: | ||
| 32 | 30 | ||
| 33 | private: | 31 | private: |
| 34 | Ui::FunctionTestWindow *ui; | 32 | Ui::FunctionTestWindow *ui; |
| 35 | - UdpHandler *udp; | ||
| 36 | }; | 33 | }; |
| 37 | 34 | ||
| 38 | #endif // FUNCTIONTESTWINDOW_H | 35 | #endif // FUNCTIONTESTWINDOW_H |
app/gui/oven_control/main.cpp
| 1 | #include "mainwindow.h" | 1 | #include "mainwindow.h" |
| 2 | -#include "manualcookwindow.h" | ||
| 3 | -#include "functiontestwindow.h" | ||
| 4 | -#include "autocookselectionwindow.h" | 2 | +#include "oven.h" |
| 3 | +#include "ovencontroller.h" | ||
| 5 | #include "udphandler.h" | 4 | #include "udphandler.h" |
| 6 | #include <QApplication> | 5 | #include <QApplication> |
| 7 | 6 | ||
| @@ -9,19 +8,18 @@ int main(int argc, char *argv[]) | @@ -9,19 +8,18 @@ int main(int argc, char *argv[]) | ||
| 9 | { | 8 | { |
| 10 | QApplication a(argc, argv); | 9 | QApplication a(argc, argv); |
| 11 | 10 | ||
| 12 | - MainWindow w; | ||
| 13 | - w.showFullScreen(); | 11 | + Oven *oven = Oven::getInstance(); |
| 12 | + | ||
| 13 | + OvenController *interface = new OvenController(oven, oven); | ||
| 14 | + oven->setInterface(interface); | ||
| 14 | 15 | ||
| 15 | -// AutoCookSelectionWindow w; | ||
| 16 | -// w.showFullScreen(); | ||
| 17 | -// ManualCookWindow w; | ||
| 18 | -// w.show(); | 16 | + UdpHandler *udp = UdpHandler::getInstance(); |
| 17 | + interface->setUdpHandler(udp); | ||
| 19 | 18 | ||
| 20 | -// UdpHandler *udp = new UdpHandler; | ||
| 21 | -// udp->init(); | 19 | + OvenStatistics::getInstance(oven); |
| 22 | 20 | ||
| 23 | -// FunctionTestWindow *w = new FunctionTestWindow(0, udp); | ||
| 24 | -// w->showFullScreen(); | 21 | + MainWindow w; |
| 22 | + w.showFullScreen(); | ||
| 25 | 23 | ||
| 26 | return a.exec(); | 24 | return a.exec(); |
| 27 | } | 25 | } |
app/gui/oven_control/mainwindow.cpp
| @@ -18,38 +18,6 @@ MainWindow::MainWindow(QWidget *parent) : | @@ -18,38 +18,6 @@ MainWindow::MainWindow(QWidget *parent) : | ||
| 18 | ui(new Ui::MainWindow) | 18 | ui(new Ui::MainWindow) |
| 19 | { | 19 | { |
| 20 | ui->setupUi(this); | 20 | ui->setupUi(this); |
| 21 | - | ||
| 22 | - oven = Oven::getInstance(); | ||
| 23 | - | ||
| 24 | - OvenController *interface = new OvenController(this, oven); | ||
| 25 | - oven->setInterface(interface); | ||
| 26 | - | ||
| 27 | - udp = new UdpHandler(this); | ||
| 28 | - | ||
| 29 | - qDebug() << udp->init(); | ||
| 30 | - interface->setUdpHandler(udp); | ||
| 31 | - | ||
| 32 | - ovenStatistics = OvenStatistics::getInstance(this,udp,oven); | ||
| 33 | - | ||
| 34 | - QSignalMapper *sm = new QSignalMapper(this); | ||
| 35 | - sm->setMapping(ui->steamButton, (int) Oven::SteamMode); | ||
| 36 | - sm->setMapping(ui->combiButton, (int) Oven::CombinationMode); | ||
| 37 | - sm->setMapping(ui->dryheatButton, (int) Oven::HeatMode); | ||
| 38 | - connect(ui->steamButton, SIGNAL(clicked()), sm, SLOT(map())); | ||
| 39 | - connect(ui->combiButton, SIGNAL(clicked()), sm, SLOT(map())); | ||
| 40 | - connect(ui->dryheatButton, SIGNAL(clicked()), sm, SLOT(map())); | ||
| 41 | - connect(sm, SIGNAL(mapped(int)), this, SLOT(onModeButtonClicked(int))); | ||
| 42 | - | ||
| 43 | - ManualCookWindow *window = new ManualCookWindow(this); | ||
| 44 | - window->setWindowModality(Qt::WindowModal); | ||
| 45 | - window->hide(); | ||
| 46 | - | ||
| 47 | - connect(ui->steamButton, SIGNAL(clicked()), this, SIGNAL(modeButtonClicked())); | ||
| 48 | - connect(ui->combiButton, SIGNAL(clicked()), this, SIGNAL(modeButtonClicked())); | ||
| 49 | - connect(ui->dryheatButton, SIGNAL(clicked()), this, SIGNAL(modeButtonClicked())); | ||
| 50 | - | ||
| 51 | - connect(this, SIGNAL(modeButtonClicked()), window, SLOT(showFullScreen())); | ||
| 52 | - connect(this, SIGNAL(modeButtonClicked()), window, SLOT(raise())); | ||
| 53 | } | 21 | } |
| 54 | 22 | ||
| 55 | MainWindow::~MainWindow() | 23 | MainWindow::~MainWindow() |
| @@ -57,6 +25,14 @@ MainWindow::~MainWindow() | @@ -57,6 +25,14 @@ MainWindow::~MainWindow() | ||
| 57 | delete ui; | 25 | delete ui; |
| 58 | } | 26 | } |
| 59 | 27 | ||
| 28 | +void MainWindow::showManualCookWindow(Oven::Mode mode) | ||
| 29 | +{ | ||
| 30 | + ManualCookWindow *w = new ManualCookWindow(this, mode); | ||
| 31 | + w->setWindowModality(Qt::WindowModal); | ||
| 32 | + w->showFullScreen(); | ||
| 33 | + w->raise(); | ||
| 34 | +} | ||
| 35 | + | ||
| 60 | void MainWindow::showAutoCookSelectionWindow(Define::CookType type) | 36 | void MainWindow::showAutoCookSelectionWindow(Define::CookType type) |
| 61 | { | 37 | { |
| 62 | AutoCookSelectionWindow *w = new AutoCookSelectionWindow(this, type); | 38 | AutoCookSelectionWindow *w = new AutoCookSelectionWindow(this, type); |
| @@ -65,17 +41,19 @@ void MainWindow::showAutoCookSelectionWindow(Define::CookType type) | @@ -65,17 +41,19 @@ void MainWindow::showAutoCookSelectionWindow(Define::CookType type) | ||
| 65 | w->raise(); | 41 | w->raise(); |
| 66 | } | 42 | } |
| 67 | 43 | ||
| 68 | -void MainWindow::onModeButtonClicked(int mode) | 44 | +void MainWindow::on_steamButton_clicked() |
| 69 | { | 45 | { |
| 70 | - oven->setDefault((Oven::Mode) mode); | 46 | + showManualCookWindow(Oven::SteamMode); |
| 71 | } | 47 | } |
| 72 | 48 | ||
| 73 | -void MainWindow::on_configButton_clicked() | 49 | +void MainWindow::on_combiButton_clicked() |
| 74 | { | 50 | { |
| 75 | - engineermenuwindow *w = new engineermenuwindow(this, udp); | ||
| 76 | - w->setWindowModality(Qt::WindowModal); | ||
| 77 | - w->showFullScreen(); | ||
| 78 | - w->raise(); | 51 | + showManualCookWindow(Oven::CombinationMode); |
| 52 | +} | ||
| 53 | + | ||
| 54 | +void MainWindow::on_dryheatButton_clicked() | ||
| 55 | +{ | ||
| 56 | + showManualCookWindow(Oven::HeatMode); | ||
| 79 | } | 57 | } |
| 80 | 58 | ||
| 81 | void MainWindow::on_poultryButton_clicked() | 59 | void MainWindow::on_poultryButton_clicked() |
| @@ -88,14 +66,42 @@ void MainWindow::on_meatButton_clicked() | @@ -88,14 +66,42 @@ void MainWindow::on_meatButton_clicked() | ||
| 88 | showAutoCookSelectionWindow(Define::Meat); | 66 | showAutoCookSelectionWindow(Define::Meat); |
| 89 | } | 67 | } |
| 90 | 68 | ||
| 69 | +void MainWindow::on_fishButton_clicked() | ||
| 70 | +{ | ||
| 71 | + showAutoCookSelectionWindow(Define::Fish); | ||
| 72 | +} | ||
| 73 | + | ||
| 74 | +void MainWindow::on_dessertButton_clicked() | ||
| 75 | +{ | ||
| 76 | + showAutoCookSelectionWindow(Define::Desert); | ||
| 77 | +} | ||
| 78 | + | ||
| 79 | +void MainWindow::on_grainButton_clicked() | ||
| 80 | +{ | ||
| 81 | + showAutoCookSelectionWindow(Define::Vegetable); | ||
| 82 | +} | ||
| 83 | + | ||
| 91 | void MainWindow::on_breadButton_clicked() | 84 | void MainWindow::on_breadButton_clicked() |
| 92 | { | 85 | { |
| 93 | showAutoCookSelectionWindow(Define::Bread); | 86 | showAutoCookSelectionWindow(Define::Bread); |
| 94 | } | 87 | } |
| 95 | 88 | ||
| 89 | +void MainWindow::on_etcButton_clicked() | ||
| 90 | +{ | ||
| 91 | + showAutoCookSelectionWindow(Define::Etc); | ||
| 92 | +} | ||
| 93 | + | ||
| 96 | void MainWindow::on_washButton_clicked() | 94 | void MainWindow::on_washButton_clicked() |
| 97 | { | 95 | { |
| 98 | - WashWindow *w = new WashWindow(this, udp); | 96 | + WashWindow *w = new WashWindow(this); |
| 97 | + w->setWindowModality(Qt::WindowModal); | ||
| 98 | + w->showFullScreen(); | ||
| 99 | + w->raise(); | ||
| 100 | +} | ||
| 101 | + | ||
| 102 | +void MainWindow::on_configButton_clicked() | ||
| 103 | +{ | ||
| 104 | + engineermenuwindow *w = new engineermenuwindow(this); | ||
| 99 | w->setWindowModality(Qt::WindowModal); | 105 | w->setWindowModality(Qt::WindowModal); |
| 100 | w->showFullScreen(); | 106 | w->showFullScreen(); |
| 101 | w->raise(); | 107 | w->raise(); |
app/gui/oven_control/mainwindow.h
| @@ -21,31 +21,29 @@ public: | @@ -21,31 +21,29 @@ public: | ||
| 21 | explicit MainWindow(QWidget *parent = 0); | 21 | explicit MainWindow(QWidget *parent = 0); |
| 22 | ~MainWindow(); | 22 | ~MainWindow(); |
| 23 | 23 | ||
| 24 | -signals: | ||
| 25 | - void modeButtonClicked(); | ||
| 26 | - | ||
| 27 | private slots: | 24 | private slots: |
| 25 | + void showManualCookWindow(Oven::Mode mode); | ||
| 28 | void showAutoCookSelectionWindow(Define::CookType type); | 26 | void showAutoCookSelectionWindow(Define::CookType type); |
| 29 | - void onModeButtonClicked(int mode); | ||
| 30 | 27 | ||
| 31 | - void on_configButton_clicked(); | 28 | + void on_steamButton_clicked(); |
| 29 | + void on_combiButton_clicked(); | ||
| 30 | + void on_dryheatButton_clicked(); | ||
| 32 | 31 | ||
| 33 | void on_poultryButton_clicked(); | 32 | void on_poultryButton_clicked(); |
| 34 | - | ||
| 35 | void on_meatButton_clicked(); | 33 | void on_meatButton_clicked(); |
| 36 | - | 34 | + void on_fishButton_clicked(); |
| 35 | + void on_dessertButton_clicked(); | ||
| 36 | + void on_grainButton_clicked(); | ||
| 37 | void on_breadButton_clicked(); | 37 | void on_breadButton_clicked(); |
| 38 | + void on_etcButton_clicked(); | ||
| 38 | 39 | ||
| 39 | void on_washButton_clicked(); | 40 | void on_washButton_clicked(); |
| 40 | 41 | ||
| 42 | + void on_configButton_clicked(); | ||
| 41 | void on_helpButton_clicked(); | 43 | void on_helpButton_clicked(); |
| 42 | 44 | ||
| 43 | private: | 45 | private: |
| 44 | Ui::MainWindow *ui; | 46 | Ui::MainWindow *ui; |
| 45 | - | ||
| 46 | - Oven *oven; | ||
| 47 | - UdpHandler *udp; | ||
| 48 | - OvenStatistics* ovenStatistics; | ||
| 49 | }; | 47 | }; |
| 50 | 48 | ||
| 51 | #endif // MAINWINDOW_H | 49 | #endif // MAINWINDOW_H |
app/gui/oven_control/manualcookwindow.cpp
| @@ -8,7 +8,7 @@ | @@ -8,7 +8,7 @@ | ||
| 8 | #include "preheatpopup.h" | 8 | #include "preheatpopup.h" |
| 9 | #include "cooldownpopup.h" | 9 | #include "cooldownpopup.h" |
| 10 | 10 | ||
| 11 | -ManualCookWindow::ManualCookWindow(QWidget *parent) : | 11 | +ManualCookWindow::ManualCookWindow(QWidget *parent, Oven::Mode mode) : |
| 12 | QMainWindow(parent), | 12 | QMainWindow(parent), |
| 13 | ui(new Ui::ManualCookWindow) | 13 | ui(new Ui::ManualCookWindow) |
| 14 | { | 14 | { |
| @@ -105,6 +105,8 @@ ManualCookWindow::ManualCookWindow(QWidget *parent) : | @@ -105,6 +105,8 @@ ManualCookWindow::ManualCookWindow(QWidget *parent) : | ||
| 105 | ui->openDoorAnimation->load(":/images/animation/door_big_02.png"); | 105 | ui->openDoorAnimation->load(":/images/animation/door_big_02.png"); |
| 106 | ui->openDoorAnimation->load(":/images/animation/door_big_01.png"); | 106 | ui->openDoorAnimation->load(":/images/animation/door_big_01.png"); |
| 107 | ui->openDoorAnimation->start(300); | 107 | ui->openDoorAnimation->start(300); |
| 108 | + | ||
| 109 | + oven->setDefault(mode); | ||
| 108 | } | 110 | } |
| 109 | 111 | ||
| 110 | ManualCookWindow::~ManualCookWindow() | 112 | ManualCookWindow::~ManualCookWindow() |
app/gui/oven_control/manualcookwindow.h
| @@ -15,7 +15,7 @@ class ManualCookWindow : public QMainWindow | @@ -15,7 +15,7 @@ class ManualCookWindow : public QMainWindow | ||
| 15 | Q_OBJECT | 15 | Q_OBJECT |
| 16 | 16 | ||
| 17 | public: | 17 | public: |
| 18 | - explicit ManualCookWindow(QWidget *parent = 0); | 18 | + explicit ManualCookWindow(QWidget *parent, Oven::Mode mode); |
| 19 | ~ManualCookWindow(); | 19 | ~ManualCookWindow(); |
| 20 | 20 | ||
| 21 | signals: | 21 | signals: |
app/gui/oven_control/oven.h
| @@ -54,6 +54,8 @@ public: | @@ -54,6 +54,8 @@ public: | ||
| 54 | enum Mode { HeatMode, SteamMode, CombinationMode }; | 54 | enum Mode { HeatMode, SteamMode, CombinationMode }; |
| 55 | 55 | ||
| 56 | private: | 56 | private: |
| 57 | + explicit Oven(QObject *parent = 0); | ||
| 58 | + | ||
| 57 | Mode mode_; | 59 | Mode mode_; |
| 58 | int humidity_; | 60 | int humidity_; |
| 59 | int temp_; | 61 | int temp_; |
| @@ -109,8 +111,6 @@ private: | @@ -109,8 +111,6 @@ private: | ||
| 109 | static Oven *instance; | 111 | static Oven *instance; |
| 110 | 112 | ||
| 111 | public: | 113 | public: |
| 112 | - explicit Oven(QObject *parent = 0); | ||
| 113 | - | ||
| 114 | static Oven *getInstance() { | 114 | static Oven *getInstance() { |
| 115 | if (instance == 0) | 115 | if (instance == 0) |
| 116 | instance = new Oven(); | 116 | instance = new Oven(); |
app/gui/oven_control/ovenstatics.cpp
| @@ -11,12 +11,11 @@ | @@ -11,12 +11,11 @@ | ||
| 11 | 11 | ||
| 12 | OvenStatistics* OvenStatistics::p_singletonInstance=NULL; | 12 | OvenStatistics* OvenStatistics::p_singletonInstance=NULL; |
| 13 | 13 | ||
| 14 | -OvenStatistics* OvenStatistics::getInstance(QObject *parent, UdpHandler* udp, Oven* oven){ | 14 | +OvenStatistics* OvenStatistics::getInstance(QObject *parent){ |
| 15 | if(!p_singletonInstance){ | 15 | if(!p_singletonInstance){ |
| 16 | - if(udp==NULL) return NULL; | ||
| 17 | p_singletonInstance = new OvenStatistics(parent); | 16 | p_singletonInstance = new OvenStatistics(parent); |
| 18 | - p_singletonInstance->udp = udp; | ||
| 19 | - p_singletonInstance->oven = oven; | 17 | + p_singletonInstance->udp = UdpHandler::getInstance(); |
| 18 | + p_singletonInstance->oven = Oven::getInstance(); | ||
| 20 | //for singletone event debug | 19 | //for singletone event debug |
| 21 | // MainWindow* mw = (MainWindow*)parent; | 20 | // MainWindow* mw = (MainWindow*)parent; |
| 22 | // connect(mw->pcombiButton, SIGNAL(clicked()),p_singtonInstance, SLOT(onDataChanged())); | 21 | // connect(mw->pcombiButton, SIGNAL(clicked()),p_singtonInstance, SLOT(onDataChanged())); |
app/gui/oven_control/ovenstatics.h
| @@ -166,7 +166,7 @@ class OvenStatistics : public QObject | @@ -166,7 +166,7 @@ class OvenStatistics : public QObject | ||
| 166 | public: | 166 | public: |
| 167 | servicedatas* srvdatas; | 167 | servicedatas* srvdatas; |
| 168 | 168 | ||
| 169 | - static OvenStatistics* getInstance(QObject* parent = 0,UdpHandler * udp=0, Oven* oven=0); | 169 | + static OvenStatistics* getInstance(QObject* parent = 0); |
| 170 | static void destroy(); | 170 | static void destroy(); |
| 171 | bool getNeedErrorClear(); | 171 | bool getNeedErrorClear(); |
| 172 | void clearNeedErrorClear(); | 172 | void clearNeedErrorClear(); |
app/gui/oven_control/udphandler.cpp
| @@ -11,6 +11,8 @@ typedef struct { | @@ -11,6 +11,8 @@ typedef struct { | ||
| 11 | char body[]; | 11 | char body[]; |
| 12 | } STRUCT_PACK packet_t; | 12 | } STRUCT_PACK packet_t; |
| 13 | 13 | ||
| 14 | +UdpHandler *UdpHandler::instance = 0; | ||
| 15 | + | ||
| 14 | UdpHandler::UdpHandler(QObject *parent) : QObject(parent) | 16 | UdpHandler::UdpHandler(QObject *parent) : QObject(parent) |
| 15 | { | 17 | { |
| 16 | bzero(&control, sizeof(control)); | 18 | bzero(&control, sizeof(control)); |
app/gui/oven_control/udphandler.h
| @@ -14,8 +14,20 @@ class UdpHandler : public QObject | @@ -14,8 +14,20 @@ class UdpHandler : public QObject | ||
| 14 | oven_control_t control; | 14 | oven_control_t control; |
| 15 | oven_state_t state; | 15 | oven_state_t state; |
| 16 | 16 | ||
| 17 | + static UdpHandler *instance; | ||
| 18 | + | ||
| 17 | public: | 19 | public: |
| 18 | - explicit UdpHandler(QObject *parent = 0); | 20 | + static UdpHandler *getInstance() { |
| 21 | + if (instance == 0) | ||
| 22 | + { | ||
| 23 | + UdpHandler *u = new UdpHandler; | ||
| 24 | + if (u->init()) | ||
| 25 | + instance = u; | ||
| 26 | + } | ||
| 27 | + | ||
| 28 | + return instance; | ||
| 29 | + } | ||
| 30 | + | ||
| 19 | bool init(); | 31 | bool init(); |
| 20 | 32 | ||
| 21 | 33 | ||
| @@ -52,6 +64,8 @@ public slots: | @@ -52,6 +64,8 @@ public slots: | ||
| 52 | void fillData(oven_state_t &container); | 64 | void fillData(oven_state_t &container); |
| 53 | 65 | ||
| 54 | private: | 66 | private: |
| 67 | + explicit UdpHandler(QObject *parent = 0); | ||
| 68 | + | ||
| 55 | void processDatagram(QByteArray &datagram); | 69 | void processDatagram(QByteArray &datagram); |
| 56 | void processControl(oven_control_t *control); | 70 | void processControl(oven_control_t *control); |
| 57 | void processState(oven_state_t *state); | 71 | void processState(oven_state_t *state); |
app/gui/oven_control/valvetestwindow.cpp
| 1 | #include "valvetestwindow.h" | 1 | #include "valvetestwindow.h" |
| 2 | #include "ui_valvetestwindow.h" | 2 | #include "ui_valvetestwindow.h" |
| 3 | 3 | ||
| 4 | -ValveTestWindow::ValveTestWindow(QWidget *parent, UdpHandler *udp) : | 4 | +ValveTestWindow::ValveTestWindow(QWidget *parent) : |
| 5 | QMainWindow(parent), | 5 | QMainWindow(parent), |
| 6 | - ui(new Ui::ValveTestWindow), udp(udp) | 6 | + ui(new Ui::ValveTestWindow) |
| 7 | { | 7 | { |
| 8 | ui->setupUi(this); | 8 | ui->setupUi(this); |
| 9 | 9 | ||
| 10 | ui->clockContainer->setParent(ui->upperStack); | 10 | ui->clockContainer->setParent(ui->upperStack); |
| 11 | setAttribute(Qt::WA_DeleteOnClose); | 11 | setAttribute(Qt::WA_DeleteOnClose); |
| 12 | 12 | ||
| 13 | + udp = UdpHandler::getInstance(); | ||
| 13 | connect(udp, SIGNAL(changed()), this, SLOT(onDataChanged())); | 14 | connect(udp, SIGNAL(changed()), this, SLOT(onDataChanged())); |
| 14 | 15 | ||
| 15 | udp->set(TG_OVEN_MODE, 4); | 16 | udp->set(TG_OVEN_MODE, 4); |
app/gui/oven_control/valvetestwindow.h
| @@ -14,7 +14,7 @@ class ValveTestWindow : public QMainWindow | @@ -14,7 +14,7 @@ class ValveTestWindow : public QMainWindow | ||
| 14 | Q_OBJECT | 14 | Q_OBJECT |
| 15 | 15 | ||
| 16 | public: | 16 | public: |
| 17 | - explicit ValveTestWindow(QWidget *parent = 0, UdpHandler *udp = 0); | 17 | + explicit ValveTestWindow(QWidget *parent = 0); |
| 18 | ~ValveTestWindow(); | 18 | ~ValveTestWindow(); |
| 19 | 19 | ||
| 20 | private slots: | 20 | private slots: |
app/gui/oven_control/washtestwindow.cpp
| 1 | #include "washtestwindow.h" | 1 | #include "washtestwindow.h" |
| 2 | #include "ui_washtestwindow.h" | 2 | #include "ui_washtestwindow.h" |
| 3 | 3 | ||
| 4 | -WashTestWindow::WashTestWindow(QWidget *parent, UdpHandler *udp) : | 4 | +WashTestWindow::WashTestWindow(QWidget *parent) : |
| 5 | QMainWindow(parent), | 5 | QMainWindow(parent), |
| 6 | - ui(new Ui::WashTestWindow), udp(udp) | 6 | + ui(new Ui::WashTestWindow) |
| 7 | { | 7 | { |
| 8 | ui->setupUi(this); | 8 | ui->setupUi(this); |
| 9 | 9 | ||
| 10 | ui->clockContainer->setParent(ui->upperStack); | 10 | ui->clockContainer->setParent(ui->upperStack); |
| 11 | setAttribute(Qt::WA_DeleteOnClose); | 11 | setAttribute(Qt::WA_DeleteOnClose); |
| 12 | 12 | ||
| 13 | + udp = UdpHandler::getInstance(); | ||
| 13 | connect(udp, SIGNAL(changed()), this, SLOT(onDataChanged())); | 14 | connect(udp, SIGNAL(changed()), this, SLOT(onDataChanged())); |
| 14 | 15 | ||
| 15 | udp->set(TG_OVEN_MODE, 4); | 16 | udp->set(TG_OVEN_MODE, 4); |
app/gui/oven_control/washtestwindow.h
| @@ -14,7 +14,7 @@ class WashTestWindow : public QMainWindow | @@ -14,7 +14,7 @@ class WashTestWindow : public QMainWindow | ||
| 14 | Q_OBJECT | 14 | Q_OBJECT |
| 15 | 15 | ||
| 16 | public: | 16 | public: |
| 17 | - explicit WashTestWindow(QWidget *parent = 0, UdpHandler *udp = 0); | 17 | + explicit WashTestWindow(QWidget *parent = 0); |
| 18 | ~WashTestWindow(); | 18 | ~WashTestWindow(); |
| 19 | 19 | ||
| 20 | private slots: | 20 | private slots: |
app/gui/oven_control/washwindow.cpp
| @@ -3,10 +3,9 @@ | @@ -3,10 +3,9 @@ | ||
| 3 | 3 | ||
| 4 | #include <QSignalMapper> | 4 | #include <QSignalMapper> |
| 5 | 5 | ||
| 6 | -WashWindow::WashWindow(QWidget *parent, UdpHandler *udp) : | 6 | +WashWindow::WashWindow(QWidget *parent) : |
| 7 | QMainWindow(parent), | 7 | QMainWindow(parent), |
| 8 | ui(new Ui::WashWindow), | 8 | ui(new Ui::WashWindow), |
| 9 | - udp(udp), | ||
| 10 | selected(false), | 9 | selected(false), |
| 11 | opened(false), | 10 | opened(false), |
| 12 | started(false), | 11 | started(false), |
| @@ -20,6 +19,7 @@ WashWindow::WashWindow(QWidget *parent, UdpHandler *udp) : | @@ -20,6 +19,7 @@ WashWindow::WashWindow(QWidget *parent, UdpHandler *udp) : | ||
| 20 | ui->progressContainer->setParent(ui->upperStack); | 19 | ui->progressContainer->setParent(ui->upperStack); |
| 21 | setAttribute(Qt::WA_DeleteOnClose); | 20 | setAttribute(Qt::WA_DeleteOnClose); |
| 22 | 21 | ||
| 22 | + udp = UdpHandler::getInstance(); | ||
| 23 | udp->turnOff(TG_SYSTEM); | 23 | udp->turnOff(TG_SYSTEM); |
| 24 | connect(udp, SIGNAL(changed()), SLOT(onChanged())); | 24 | connect(udp, SIGNAL(changed()), SLOT(onChanged())); |
| 25 | 25 |
app/gui/oven_control/washwindow.h
| @@ -15,7 +15,7 @@ class WashWindow : public QMainWindow | @@ -15,7 +15,7 @@ class WashWindow : public QMainWindow | ||
| 15 | Q_OBJECT | 15 | Q_OBJECT |
| 16 | 16 | ||
| 17 | public: | 17 | public: |
| 18 | - explicit WashWindow(QWidget *parent = 0, UdpHandler *udp = 0); | 18 | + explicit WashWindow(QWidget *parent = 0); |
| 19 | ~WashWindow(); | 19 | ~WashWindow(); |
| 20 | 20 | ||
| 21 | private slots: | 21 | private slots: |