source: svn/trunk/zasc/app_c/DST_WinOTC.c @ 21

Last change on this file since 21 was 21, checked in by megakiss, 11 years ago

업데이트 종료시 마지막 전원 상태에따라 재부팅을 하거나 끄도록 로직 수정

File size: 9.9 KB
Line 
1#include "DST_Window.h"
2#include "DST_WinManager.h"
3#include "DST_DataStrings.h"
4#include "DST_CommonAPI.h"
5#include "DST_EEPROM.h"
6#include "DST_ChannelTune.h"
7#include "DST_UserInterface.h"
8#include "DST_Updates.h"
9#include "DST_ISDBT_ChannelTask.h"
10//#include "DST_OTC_Main.h"
11#include "DST_OSDImage.h"
12
13#if 0
14____CMessageWin___()
15#endif
16
17
18char* DST_GetAppShortVersion();
19
20
21//class COTCDownLoadingWin : public CWindow
22//{
23//private:
24        static bool COTCDownLoadingWin_bDone;
25        static bool COTCDownLoadingWin_bNeedLine;
26        static int COTCDownLoadingWin_progress;
27        static int COTCDownLoadingWin_center_pos;
28        static int COTCDownLoadingWin_line_spacing;     
29
30        static int COTCDownLoadingWin_nErr;
31        static int COTCDownLoadingWin_ErrCategory;
32        static int COTCDownLoadingWin_category;
33//public:
34//      COTCDownLoadingWin(SWinEventMsg event):CWindow(event)
35        void COTCDownLoadingWin_Constructor(CWindow *this, SWinEventMsg event)
36        {
37                this->SetWinName(this,  "OTCDownload");
38                DST_g_RFUpdateState = 0;
39                this->rect.w = 382; 
40                this->rect.h = 241; 
41                this->rect.x = (DST_GetScreenWidth() - this->rect.w) / 2;
42                this->rect.y = (DST_GetScreenHeight()- this->rect.h) / 2;
43
44                DST_Printf("\n\n--------------------------WIN_OTC_DOWNLOADING----------------------------------\n\n");
45               
46
47                COTCDownLoadingWin_center_pos =  this->rect.h / 2; 
48                COTCDownLoadingWin_line_spacing = DST_GetFontHeight(fontItemSize) * 125 / 100;
49
50                COTCDownLoadingWin_nErr = 0;
51                COTCDownLoadingWin_ErrCategory = 0;
52                COTCDownLoadingWin_category = 0;
53                COTCDownLoadingWin_bNeedLine = false;
54                COTCDownLoadingWin_bDone = false;
55                COTCDownLoadingWin_progress = 0;
56               
57                this->SetTimeOut(this, 0);
58                this->SetTimer(this, 1, 5*60*1000);
59
60//              DHL_POWER_SetMode(nSleepState ? 2 : 0);
61        }
62
63        void COTCDownLoadingWin_Destructor(CWindow *this)
64        {
65        }
66       
67//      virtual void KeyInput(DS_U8 key, bool /*bRepeat*/)
68        void COTCDownLoadingWin_KeyInput(CWindow *this, DS_U8 key, bool bRepeat)
69        {
70                switch (key)
71                {
72                        case VK_KEY_PWR:
73                        case VK_PWR:
74                                if (DST_g_PowerOn) // ÄÑÁø»óÅÂ
75                                {
76                                        DST_g_PowerOn = false;
77                                }
78                                else // ²¨Áø»óÅÂ
79                                {
80                                        DST_g_PowerOn = true;
81                                } 
82                                JST_POWER_Display(DST_g_PowerOn);
83                                break;
84                }
85        }
86
87        void COTCDownLoadingWin_DrawProgressBar(CWindow *this, DS_U32 nPos, DS_U32 nTotal, int x, int y, DS_U32 width)
88        {
89                int line = DST_GetFontHeight(15);
90                int y_str = y+10;
91                char tmpProgStr[50] = {0,};
92
93                this->DrawBox32(this, x, y, width, 10, CONV32_16(0xffe5e5ff));
94                if(nPos == nTotal)
95                        this->DrawBox32(this, x, y, width, 10, CONV32_16(0xff65a5cc));
96                else
97                        this->DrawBox32(this, x, y, (nPos*width)/nTotal, 10, CONV32_16(0xff65a5cc));
98
99                this->setFontStyle(this, 15,0xFFE1E1E1,ALIGN_MIDDLE,ALIGN_CENTER);
100               
101                sprintf(tmpProgStr,"(%d%%)",(nPos == nTotal)?(100):(int)((nPos*100)/nTotal));
102                this->DrawBox32(this, x, y_str, width, line, CONV32_16(0xff24435e));
103                this->DrawTextUTF8(this, x, y_str, width, line, (DS_U8*)tmpProgStr, &(this->font)); 
104
105
106        }
107       
108//      virtual void OnMessage(SWinEventMsg event)
109        void COTCDownLoadingWin_OnMessage(CWindow *this, SWinEventMsg event)
110        {
111                static int old_count = -1;
112                switch (event.cmd)
113                {
114                        case WM_RF_UPDATE:
115                                switch(event.data32[0])
116                                {
117                                        case DATA_RECEIVING: // DATA RECEIVING
118                                                this->KillTimer(this, 1);
119                                                COTCDownLoadingWin_DrawProgressBar(this, event.data32[1],  100, this->rect.w/10, COTCDownLoadingWin_center_pos+2*COTCDownLoadingWin_line_spacing-10,this->rect.w*8/10);
120                                                if(old_count != (int)event.data32[1])
121                                                {
122                                                        old_count = event.data32[1];
123                                                        this->KillTimer(this, 2);
124                                                        this->SetTimer(this, 2, 15*60*1000);
125                                                }
126                                                break;
127                                        default: break;
128                                }
129                                break;         
130                }
131        }
132
133//      virtual void OnTimer(char nID)
134        void COTCDownLoadingWin_OnTimer(CWindow *this, char nID)
135        {
136                switch(nID)
137                {
138                        case 1:
139                                DST_CreateWin(WIN_OTC_DOWNLOAD_FAIL,WIN_NULL,(DST_g_Lock == true)?(OTC_WAIT_TIMEOUT_FAIL):(TUNING_FAIL),0 ,0, 0);
140                                this->Close(this);
141                                break;
142                        case 2:
143                                DST_CreateWin(WIN_OTC_DOWNLOAD_FAIL,WIN_NULL,OTC_COMPLETE_TIMEOUT_FAIL, 0, 0, 0);
144                                this->Close(this);
145                                break;
146#if 0  //test code             
147                        case 3:
148                                {
149                                        static int count = 0;
150                                        this->KillTimer(this, 3);
151                                       
152                                        COTCDownLoadingWin_DrawProgressBar(this, count,  100,rect.w/10,center_pos+2*line_spacing-10,rect.w*8/10);
153                                        count++;
154                                        if(count == 100) count = 0;
155                                       
156                                        this->SetTimer(this, 3,300);
157                                }
158                                break;
159#endif                         
160                        case 4:
161                                {
162                                        static int loading = 0;
163                                       
164                                        loading = loading%6;
165                                        switch(loading)
166                                        {
167                                                case 0: this->DrawImage(this, (this->rect.w-34)/2, 30, newcon2_gui_downaload_Wait1,true); break;
168                                                case 1: this->DrawImage(this, (this->rect.w-34)/2, 30, newcon2_gui_downaload_Wait2,true); break;
169                                                case 2: this->DrawImage(this, (this->rect.w-34)/2, 30, newcon2_gui_downaload_Wait3,true); break;
170                                                case 3: this->DrawImage(this, (this->rect.w-34)/2, 30, newcon2_gui_downaload_Wait4,true); break;
171                                                case 4: this->DrawImage(this, (this->rect.w-34)/2, 30, newcon2_gui_downaload_Wait5,true); break;
172                                                case 5: this->DrawImage(this, (this->rect.w-34)/2, 30, newcon2_gui_downaload_Wait6,true); break;
173                                        }
174                                        loading ++;
175                                       
176                                }
177                                break;
178                        default:  break;
179                }
180        }
181
182        void COTCDownLoadingWin_Draw(CWindow *this)
183        {
184                this->DrawBox32(this, 0, 0, this->rect.w, this->rect.h, CONV32_16(0xff24435e));
185               
186                this->setFontStyle(this, fontItemSize,0xFFE1E1E1,ALIGN_MIDDLE,ALIGN_CENTER);
187               
188                this->DrawTextUni(this, 0, COTCDownLoadingWin_center_pos-60+25, this->rect.w, COTCDownLoadingWin_line_spacing, pz_OTC_Download1[OSD_Lang], &(this->font)); 
189                this->DrawTextUni(this, 0, COTCDownLoadingWin_center_pos+COTCDownLoadingWin_line_spacing-50+25, this->rect.w, COTCDownLoadingWin_line_spacing, pz_OTC_Download2[OSD_Lang], &(this->font)); 
190//              this->SetTimer(this, 3,500);
191                this->SetTimer(this, 4,300);
192
193        }
194
195//      virtual void Show(void)
196        void COTCDownLoadingWin_Show(CWindow *this)
197        {
198                COTCDownLoadingWin_Draw(this);
199               
200                this->RegisterAllKey(this);
201        }
202
203
204//};
205
206
207
208//class COTCDownloadFailResetWin : public CWindow
209//{
210//private:
211        static int COTCDownloadFailResetWin_nErr;
212//public:
213//      COTCDownloadFailResetWin(SWinEventMsg event):CWindow(event)
214        void COTCDownloadFailResetWin_Constructor(CWindow *this, SWinEventMsg event)
215        {
216                this->SetWinName(this,  "OTCDownFail");
217                this->rect.w = 382; 
218                this->rect.h = 241; 
219                this->rect.x = (DST_GetScreenWidth() - this->rect.w) / 2;
220                this->rect.y = (DST_GetScreenHeight()- this->rect.h) / 2;
221                this->RegisterAllKey(this);
222                this->SetTimeOut(this, 0);
223                DST_g_bOTCMode = false;
224               
225                DST_g_LED_PowerState = 1;
226                COTCDownloadFailResetWin_nErr = event.data[2];;
227
228        }
229
230        void COTCDownloadFailResetWin_Destructor(CWindow *this)
231        {
232                if (DST_g_PowerOn)
233                {
234                        DST_Reset(__func__); // âÀÌ ´ÝÈ÷¸é¼­ ÀçºÎÆÃ
235                }
236                else
237                {
238                        DST_PowerDown();
239                }
240        }
241       
242//      virtual void OnTimer(char nID)
243        void COTCDownloadFailResetWin_OnTimer(CWindow *this, char nID)
244        {
245                switch(nID)
246                {
247                        case 1:
248                                this->KillTimer(this, 1);
249                                this->SetTimer(this, 2, 1000);
250                                this->Show(this);
251                                break;
252                        case 2:
253                                this->KillTimer(this, 2);
254                                this->Close(this);
255                                break;
256                        default:
257                                break;
258                }
259        }
260       
261       
262//      virtual void Show(void)
263        void COTCDownloadFailResetWin_Show(CWindow *this)
264        {
265                int     center_pos =  this->rect.h / 2; 
266                int line_spacing = DST_GetFontHeight(fontItemSize) * 150 / 100;
267
268                this->DrawBox32(this, 0, 0, this->rect.w, this->rect.h, CONV32_16(0xff24435e));
269                this->setFontStyle(this, 22,0xFFE1E1E1,ALIGN_MIDDLE,ALIGN_CENTER);
270
271                switch(COTCDownloadFailResetWin_nErr)
272                {
273                        case TUNING_FAIL:
274                                DST_Printf("OTCDownloadFail : ERROR %d TUNING_FAIL\n",COTCDownloadFailResetWin_nErr);
275                                this->DrawTextUni(this, 0, center_pos-2*line_spacing, this->rect.w, line_spacing, pz_Update_Err_101[OSD_Lang], &(this->font)); 
276                                break;
277                        case OTC_WAIT_TIMEOUT_FAIL:
278                                DST_Printf("OTCDownloadFail : ERROR %d OTC_WAIT_TIMEOUT_FAIL\n",COTCDownloadFailResetWin_nErr);
279                                this->DrawTextUni(this, 0, center_pos-2*line_spacing, this->rect.w, line_spacing, pz_Update_Err_201[OSD_Lang], &(this->font)); 
280                                break;
281                        case OTC_COMPLETE_TIMEOUT_FAIL:
282                                DST_Printf("OTCDownloadFail : ERROR %d OTC_COMPLETE_TIMEOUT_FAIL\n",COTCDownloadFailResetWin_nErr);
283                                this->DrawTextUni(this, 0, center_pos-2*line_spacing, this->rect.w, line_spacing, pz_Update_Err_202[OSD_Lang], &(this->font)); 
284                                break;
285                }
286
287                this->DrawTextUni(this, 0, center_pos-line_spacing, this->rect.w, line_spacing, pz_OTC_Download_Fail1[OSD_Lang], &(this->font)); 
288                this->DrawTextUni(this, 0, center_pos, this->rect.w, line_spacing, pz_OTC_Download_Fail2[OSD_Lang], &(this->font)); 
289                this->DrawTextUni(this, 0, center_pos+line_spacing, this->rect.w, line_spacing, pz_OTC_Download_Fail3[OSD_Lang], &(this->font)); 
290
291                this->UpdateScreen(this);
292               
293                this->RegisterAllKey(this);
294                this->SetTimer(this, 2, 5000);
295        }
296//};
297
298void DST_CreateOTCDownloadFailResetWin(SWinEventMsg event)
299{
300        DST_RemoveAllWindowExceptBasicWin();
301        CWindow*pWin = NewCWindow(event);
302        pWin->Destructor        = COTCDownloadFailResetWin_Destructor;
303        pWin->OnTimer           = COTCDownloadFailResetWin_OnTimer;
304        pWin->Show                      = COTCDownloadFailResetWin_Show;
305        // »ý¼ºÀÚ È£Ãâ
306        COTCDownloadFailResetWin_Constructor(pWin, event);
307        // À©µµ¿ì ¸Þ´ÏÀú¿¡ µî·Ï
308        DST_AddWin((WinID)(event.data[0]), pWin);       
309}
310
311
312void DST_CreateOTCDownLoadingWin(SWinEventMsg event)
313{
314        if (DST_GetWin(WIN_UPDATE)) return;
315        DST_RemoveAllWindowExceptBasicWin();
316        CWindow*pWin = NewCWindow(event);
317        pWin->Destructor        = COTCDownLoadingWin_Destructor;
318        pWin->KeyInput          = COTCDownLoadingWin_KeyInput;
319        pWin->OnTimer           = COTCDownLoadingWin_OnTimer;
320        pWin->OnMessage         = COTCDownLoadingWin_OnMessage;
321        pWin->Show                      = COTCDownLoadingWin_Show;
322        // »ý¼ºÀÚ È£Ãâ
323        COTCDownLoadingWin_Constructor(pWin, event);
324        // À©µµ¿ì ¸Þ´ÏÀú¿¡ µî·Ï
325        DST_AddWin((WinID)(event.data[0]), pWin);       
326}
327
328
329
Note: See TracBrowser for help on using the repository browser.