Commit dbfe7c9eac1ff7d061e49fa3bfb062c0f133f57d
1 parent
2c27c52f82
Exists in
master
and in
2 other branches
설정 저장 기능 추가
- 설정 저장 기능 추가 -> /prime/config/config.ini
Showing
4 changed files
with
106 additions
and
4 deletions
Show diff stats
app/gui/oven_control/config.cpp
1 | #include <QDebug> | 1 | #include <QDebug> |
2 | #include <QDateTime> | 2 | #include <QDateTime> |
3 | +#include <QFile> | ||
4 | +#include <QIODevice> | ||
3 | #include "config.h" | 5 | #include "config.h" |
4 | #include "configdatetimedlg.h" | 6 | #include "configdatetimedlg.h" |
5 | #include "configlanguagedlg.h" | 7 | #include "configlanguagedlg.h" |
@@ -19,11 +21,15 @@ | @@ -19,11 +21,15 @@ | ||
19 | 21 | ||
20 | using namespace Define; | 22 | using namespace Define; |
21 | 23 | ||
24 | +#define CONFIG_FILE_NAME "/prime/config/config.ini" | ||
25 | +#define FAVORITE_FILE_NAME "/prime/config/favorite.ini" | ||
26 | + | ||
22 | Config* Config::instance = NULL; | 27 | Config* Config::instance = NULL; |
23 | 28 | ||
24 | Config::Config(QObject *parent) : QObject(parent) | 29 | Config::Config(QObject *parent) : QObject(parent) |
25 | { | 30 | { |
26 | memcpy(config_format,config_format_kr,MAX_CONFIG_COUNT*64); | 31 | memcpy(config_format,config_format_kr,MAX_CONFIG_COUNT*64); |
32 | + loadConfig(); | ||
27 | // m_setFavorite.insert(2); | 33 | // m_setFavorite.insert(2); |
28 | // m_setFavorite.insert(3); | 34 | // m_setFavorite.insert(3); |
29 | // m_setFavorite.insert(1); | 35 | // m_setFavorite.insert(1); |
@@ -49,11 +55,95 @@ Config* Config::getInstance(QObject *parent){ | @@ -49,11 +55,95 @@ Config* Config::getInstance(QObject *parent){ | ||
49 | return instance; | 55 | return instance; |
50 | } | 56 | } |
51 | 57 | ||
52 | -bool Config::saveConfig(){ | 58 | +void Config::initConfig(){ |
59 | + memset(configlist.data,0x00,MAX_CONFIG_COUNT * 4); | ||
60 | + configlist.items.language.d32=0; | ||
61 | + configlist.items.datetime.d32=0; | ||
62 | + configlist.items.temptype.d32=0; | ||
63 | + configlist.items.backlight.d32=7; | ||
64 | + configlist.items.stop_delay.d32=10; | ||
65 | + configlist.items.best_dish_weight.d32=0; | ||
66 | + configlist.items.party_dish_weight.d32=0; | ||
67 | + configlist.items.ilc_rack_number.d32=10; | ||
68 | + configlist.items.ilc_rack_sequnece.d32=0x30201; | ||
69 | + configlist.items.ilc_cook_wait_time.d32=30; | ||
70 | + configlist.items.cooktime_format.d32=0; | ||
71 | + configlist.items.time_type.d32=1; | ||
72 | + configlist.items.resttime_format.d32=0; | ||
73 | + configlist.items.marster_vol.d32=7; | ||
74 | + configlist.items.keypad_sound1.d32=0; | ||
75 | + configlist.items.keypad_sound2.d32=0; | ||
76 | + configlist.items.request_loadexec.d32=6; | ||
77 | + configlist.items.programstep_finish.d32=7; | ||
78 | + configlist.items.cooktime_finish.d32=8; | ||
79 | + configlist.items.stoperror_distinguish.d32=9; | ||
80 | + configlist.items.sound_factory_reset.d32=0; | ||
81 | + configlist.items.haccp_data_download.d32=0; | ||
82 | + configlist.items.info_data_download.d32=0; | ||
83 | + configlist.items.service_data_download.d32=0; | ||
84 | + configlist.items.program_download.d32=0; | ||
85 | + configlist.items.program_upload.d32=0; | ||
86 | + configlist.items.program_initialize.d32=0; | ||
87 | + configlist.items.ip.d32=0xC0A80002; | ||
88 | + configlist.items.gateway.d32=0xC0A80001; | ||
89 | + configlist.items.netmask.d32=0xffffff01; | ||
90 | + configlist.items.set_download.d32=0; | ||
91 | + configlist.items.set_upload.d32=0; | ||
92 | + configlist.items.set_half_energy.d32=0; | ||
93 | + configlist.items.set_auto_darkness.d32=5; | ||
94 | + configlist.items.set_ilc_cook_temphumi_ready.d32=0; | ||
95 | + configlist.items.set_load_ready.d32=5; | ||
96 | + configlist.items.duty_wash.d32=0; | ||
97 | + configlist.items.loading_door_monitoring.d32=0; | ||
98 | + configlist.items.cooking_door_monitoring.d32=0; | ||
99 | + configlist.items.software_info.d32=0; | ||
100 | + configlist.items.hotline_chef.d32=0; | ||
101 | + configlist.items.hotline_service.d32=0; | ||
102 | + configlist.items.steam_wash.d32=0; | ||
103 | + configlist.items.demo_mode.d32=0; | ||
104 | + configlist.items.enter_engineer_mode.d32=0; | ||
105 | + configlist.items.model.d32 = model_electric_20; | ||
106 | + qDebug() << "Init Config lists"; | ||
107 | +} | ||
108 | + | ||
109 | +bool Config::saveConfig(void){ | ||
110 | + char buff[sizeof(config_lists)+1]; | ||
111 | + qint64 writelen; | ||
112 | + QFile file(CONFIG_FILE_NAME);+ | ||
113 | + memcpy(buff, configlist.data, sizeof(config_lists)); | ||
114 | + buff[sizeof(config_lists)] = 0x9C; | ||
115 | + if(file.open(QIODevice::WriteOnly)){ | ||
116 | + writelen = file.write(buff,sizeof(config_lists)+1); | ||
117 | + file.close(); | ||
118 | + if(writelen == (sizeof(config_lists)+1)){ | ||
119 | + qDebug() << "config file saved"; | ||
120 | + return true; | ||
121 | + } | ||
122 | + } | ||
123 | + qDebug() << "saving config file is fail!"; | ||
53 | return false; | 124 | return false; |
54 | } | 125 | } |
55 | 126 | ||
56 | bool Config::loadConfig(){ | 127 | bool Config::loadConfig(){ |
128 | + char buff[sizeof(config_lists)+1]; | ||
129 | + qint64 readlen; | ||
130 | + QFile file(CONFIG_FILE_NAME); | ||
131 | + initConfig(); | ||
132 | + if(file.open(QIODevice::ReadOnly)){ | ||
133 | + readlen = file.read(buff,sizeof(config_lists)+1); | ||
134 | + file.close(); | ||
135 | + if(buff[sizeof(config_lists)] ==0x9c && readlen == (sizeof(config_lists)+1) ){ | ||
136 | + memcpy(configlist.data,buff,sizeof(config_lists)); | ||
137 | + qDebug() << "loading config file success"; | ||
138 | + } | ||
139 | + else { | ||
140 | + qDebug()<<"loading config file fail"; | ||
141 | + return true; | ||
142 | + } | ||
143 | + } | ||
144 | + else{ | ||
145 | + saveConfig(); | ||
146 | + } | ||
57 | return false; | 147 | return false; |
58 | } | 148 | } |
59 | 149 | ||
@@ -163,6 +253,7 @@ QList<uint32_t> Config::getConstSortedFavorite(){ | @@ -163,6 +253,7 @@ QList<uint32_t> Config::getConstSortedFavorite(){ | ||
163 | } | 253 | } |
164 | 254 | ||
165 | bool Config::loadFavorite(void){ | 255 | bool Config::loadFavorite(void){ |
256 | + | ||
166 | return false; | 257 | return false; |
167 | } | 258 | } |
168 | 259 | ||
@@ -287,3 +378,5 @@ void Config::execConfigWindow(QWidget *parent, Define::ConfigType idx){ | @@ -287,3 +378,5 @@ void Config::execConfigWindow(QWidget *parent, Define::ConfigType idx){ | ||
287 | 378 | ||
288 | 379 | ||
289 | 380 | ||
381 | + | ||
382 | + |
app/gui/oven_control/config.h
@@ -386,7 +386,7 @@ class Config : public QObject | @@ -386,7 +386,7 @@ class Config : public QObject | ||
386 | public: | 386 | public: |
387 | static Config *getInstance(QObject *parent=0); | 387 | static Config *getInstance(QObject *parent=0); |
388 | //static void init(); | 388 | //static void init(); |
389 | - bool initConfig(void); | 389 | + void initConfig(void); |
390 | bool loadConfig(void); | 390 | bool loadConfig(void); |
391 | bool saveConfig(void); | 391 | bool saveConfig(void); |
392 | Define::config_item getConfigValue(Define::ConfigType idx); | 392 | Define::config_item getConfigValue(Define::ConfigType idx); |
app/gui/oven_control/configwindow.cpp
@@ -6,6 +6,7 @@ | @@ -6,6 +6,7 @@ | ||
6 | #include "engineermenuwindow.h" | 6 | #include "engineermenuwindow.h" |
7 | #include "config.h" | 7 | #include "config.h" |
8 | #include "configinfodlg.h" | 8 | #include "configinfodlg.h" |
9 | +#include "yesnopopupdlg.h" | ||
9 | 10 | ||
10 | 11 | ||
11 | 12 | ||
@@ -53,6 +54,16 @@ void ConfigWindow::on_pushButton_clicked() | @@ -53,6 +54,16 @@ void ConfigWindow::on_pushButton_clicked() | ||
53 | 54 | ||
54 | void ConfigWindow::on_backButton_clicked() | 55 | void ConfigWindow::on_backButton_clicked() |
55 | { | 56 | { |
57 | + Config* cfg = Config::getInstance(); | ||
58 | + QDialog* dlg = new YesNoPopupDlg(this,tr("현재 설정을 적용하시겠습니까?")); | ||
59 | + dlg->setModal(true); | ||
60 | + dlg->exec(); | ||
61 | + if(dlg->result() == QDialog::Accepted){ | ||
62 | + cfg->saveConfig(); | ||
63 | + } | ||
64 | + else{ | ||
65 | + cfg->loadConfig(); | ||
66 | + } | ||
56 | close(); | 67 | close(); |
57 | } | 68 | } |
58 | 69 |
app/gui/oven_control/servicedata.cpp