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

Last change on this file since 2 was 2, checked in by jglee, 11 years ago

first commit

File size: 9.8 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                                DHL_INFO_SetLastPowerState(DST_g_PowerOn);
84                                break;
85                }
86        }
87
88        void COTCDownLoadingWin_DrawProgressBar(CWindow *this, DS_U32 nPos, DS_U32 nTotal, int x, int y, DS_U32 width)
89        {
90                int line = DST_GetFontHeight(15);
91                int y_str = y+10;
92                char tmpProgStr[50] = {0,};
93
94                this->DrawBox32(this, x, y, width, 10, CONV32_16(0xffe5e5ff));
95                if(nPos == nTotal)
96                        this->DrawBox32(this, x, y, width, 10, CONV32_16(0xff65a5cc));
97                else
98                        this->DrawBox32(this, x, y, (nPos*width)/nTotal, 10, CONV32_16(0xff65a5cc));
99
100                this->setFontStyle(this, 15,0xFFE1E1E1,ALIGN_MIDDLE,ALIGN_CENTER);
101               
102                sprintf(tmpProgStr,"(%d%%)",(nPos == nTotal)?(100):(int)((nPos*100)/nTotal));
103                this->DrawBox32(this, x, y_str, width, line, CONV32_16(0xff24435e));
104                this->DrawTextUTF8(this, x, y_str, width, line, (DS_U8*)tmpProgStr, &(this->font)); 
105
106
107        }
108       
109//      virtual void OnMessage(SWinEventMsg event)
110        void COTCDownLoadingWin_OnMessage(CWindow *this, SWinEventMsg event)
111        {
112                static int old_count = -1;
113                switch (event.cmd)
114                {
115                        case WM_RF_UPDATE:
116                                switch(event.data32[0])
117                                {
118                                        case DATA_RECEIVING: // DATA RECEIVING
119                                                this->KillTimer(this, 1);
120                                                COTCDownLoadingWin_DrawProgressBar(this, event.data32[1],  100, this->rect.w/10, COTCDownLoadingWin_center_pos+2*COTCDownLoadingWin_line_spacing-10,this->rect.w*8/10);
121                                                if(old_count != (int)event.data32[1])
122                                                {
123                                                        old_count = event.data32[1];
124                                                        this->KillTimer(this, 2);
125                                                        this->SetTimer(this, 2, 15*60*1000);
126                                                }
127                                                break;
128                                        default: break;
129                                }
130                                break;         
131                }
132        }
133
134//      virtual void OnTimer(char nID)
135        void COTCDownLoadingWin_OnTimer(CWindow *this, char nID)
136        {
137                switch(nID)
138                {
139                        case 1:
140                                DST_CreateWin(WIN_OTC_DOWNLOAD_FAIL,WIN_NULL,(DST_g_Lock == true)?(OTC_WAIT_TIMEOUT_FAIL):(TUNING_FAIL),0 ,0, 0);
141                                this->Close(this);
142                                break;
143                        case 2:
144                                DST_CreateWin(WIN_OTC_DOWNLOAD_FAIL,WIN_NULL,OTC_COMPLETE_TIMEOUT_FAIL, 0, 0, 0);
145                                this->Close(this);
146                                break;
147#if 0  //test code             
148                        case 3:
149                                {
150                                        static int count = 0;
151                                        this->KillTimer(this, 3);
152                                       
153                                        COTCDownLoadingWin_DrawProgressBar(this, count,  100,rect.w/10,center_pos+2*line_spacing-10,rect.w*8/10);
154                                        count++;
155                                        if(count == 100) count = 0;
156                                       
157                                        this->SetTimer(this, 3,300);
158                                }
159                                break;
160#endif                         
161                        case 4:
162                                {
163                                        static int loading = 0;
164                                       
165                                        loading = loading%6;
166                                        switch(loading)
167                                        {
168                                                case 0: this->DrawImage(this, (this->rect.w-34)/2, 30, newcon2_gui_downaload_Wait1,true); break;
169                                                case 1: this->DrawImage(this, (this->rect.w-34)/2, 30, newcon2_gui_downaload_Wait2,true); break;
170                                                case 2: this->DrawImage(this, (this->rect.w-34)/2, 30, newcon2_gui_downaload_Wait3,true); break;
171                                                case 3: this->DrawImage(this, (this->rect.w-34)/2, 30, newcon2_gui_downaload_Wait4,true); break;
172                                                case 4: this->DrawImage(this, (this->rect.w-34)/2, 30, newcon2_gui_downaload_Wait5,true); break;
173                                                case 5: this->DrawImage(this, (this->rect.w-34)/2, 30, newcon2_gui_downaload_Wait6,true); break;
174                                        }
175                                        loading ++;
176                                       
177                                }
178                                break;
179                        default:  break;
180                }
181        }
182
183        void COTCDownLoadingWin_Draw(CWindow *this)
184        {
185                this->DrawBox32(this, 0, 0, this->rect.w, this->rect.h, CONV32_16(0xff24435e));
186               
187                this->setFontStyle(this, fontItemSize,0xFFE1E1E1,ALIGN_MIDDLE,ALIGN_CENTER);
188               
189                this->DrawTextUni(this, 0, COTCDownLoadingWin_center_pos-60+25, this->rect.w, COTCDownLoadingWin_line_spacing, pz_OTC_Download1[OSD_Lang], &(this->font)); 
190                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)); 
191//              this->SetTimer(this, 3,500);
192                this->SetTimer(this, 4,300);
193
194        }
195
196//      virtual void Show(void)
197        void COTCDownLoadingWin_Show(CWindow *this)
198        {
199                COTCDownLoadingWin_Draw(this);
200               
201                this->RegisterAllKey(this);
202        }
203
204
205//};
206
207
208
209//class COTCDownloadFailResetWin : public CWindow
210//{
211//private:
212        static int COTCDownloadFailResetWin_nErr;
213//public:
214//      COTCDownloadFailResetWin(SWinEventMsg event):CWindow(event)
215        void COTCDownloadFailResetWin_Constructor(CWindow *this, SWinEventMsg event)
216        {
217                this->SetWinName(this,  "OTCDownFail");
218                this->rect.w = 382; 
219                this->rect.h = 241; 
220                this->rect.x = (DST_GetScreenWidth() - this->rect.w) / 2;
221                this->rect.y = (DST_GetScreenHeight()- this->rect.h) / 2;
222                this->RegisterAllKey(this);
223                this->SetTimeOut(this, 0);
224                DST_g_bOTCMode = false;
225               
226                DST_g_LED_PowerState = 1;
227                COTCDownloadFailResetWin_nErr = event.data[2];;
228
229        }
230
231        void COTCDownloadFailResetWin_Destructor(CWindow *this)
232        {
233                DST_Reset(__func__); // âÀÌ ´ÝÈ÷¸é¼­ ÀçºÎÆÃ
234        }
235       
236//      virtual void OnTimer(char nID)
237        void COTCDownloadFailResetWin_OnTimer(CWindow *this, char nID)
238        {
239                switch(nID)
240                {
241                        case 1:
242                                this->KillTimer(this, 1);
243                                this->SetTimer(this, 2, 1000);
244                                this->Show(this);
245                                break;
246                        case 2:
247                                this->KillTimer(this, 2);
248                                this->Close(this);
249                                break;
250                        default:
251                                break;
252                }
253        }
254       
255       
256//      virtual void Show(void)
257        void COTCDownloadFailResetWin_Show(CWindow *this)
258        {
259                int     center_pos =  this->rect.h / 2; 
260                int line_spacing = DST_GetFontHeight(fontItemSize) * 150 / 100;
261
262                this->DrawBox32(this, 0, 0, this->rect.w, this->rect.h, CONV32_16(0xff24435e));
263                this->setFontStyle(this, 22,0xFFE1E1E1,ALIGN_MIDDLE,ALIGN_CENTER);
264
265                switch(COTCDownloadFailResetWin_nErr)
266                {
267                        case TUNING_FAIL:
268                                DST_Printf("OTCDownloadFail : ERROR %d TUNING_FAIL\n",COTCDownloadFailResetWin_nErr);
269                                this->DrawTextUni(this, 0, center_pos-2*line_spacing, this->rect.w, line_spacing, pz_Update_Err_101[OSD_Lang], &(this->font)); 
270                                break;
271                        case OTC_WAIT_TIMEOUT_FAIL:
272                                DST_Printf("OTCDownloadFail : ERROR %d OTC_WAIT_TIMEOUT_FAIL\n",COTCDownloadFailResetWin_nErr);
273                                this->DrawTextUni(this, 0, center_pos-2*line_spacing, this->rect.w, line_spacing, pz_Update_Err_201[OSD_Lang], &(this->font)); 
274                                break;
275                        case OTC_COMPLETE_TIMEOUT_FAIL:
276                                DST_Printf("OTCDownloadFail : ERROR %d OTC_COMPLETE_TIMEOUT_FAIL\n",COTCDownloadFailResetWin_nErr);
277                                this->DrawTextUni(this, 0, center_pos-2*line_spacing, this->rect.w, line_spacing, pz_Update_Err_202[OSD_Lang], &(this->font)); 
278                                break;
279                }
280
281                this->DrawTextUni(this, 0, center_pos-line_spacing, this->rect.w, line_spacing, pz_OTC_Download_Fail1[OSD_Lang], &(this->font)); 
282                this->DrawTextUni(this, 0, center_pos, this->rect.w, line_spacing, pz_OTC_Download_Fail2[OSD_Lang], &(this->font)); 
283                this->DrawTextUni(this, 0, center_pos+line_spacing, this->rect.w, line_spacing, pz_OTC_Download_Fail3[OSD_Lang], &(this->font)); 
284
285                this->UpdateScreen(this);
286               
287                this->RegisterAllKey(this);
288                this->SetTimer(this, 2, 5000);
289        }
290//};
291
292void DST_CreateOTCDownloadFailResetWin(SWinEventMsg event)
293{
294        DST_RemoveAllWindowExceptBasicWin();
295        CWindow*pWin = NewCWindow(event);
296        pWin->Destructor        = COTCDownloadFailResetWin_Destructor;
297        pWin->OnTimer           = COTCDownloadFailResetWin_OnTimer;
298        pWin->Show                      = COTCDownloadFailResetWin_Show;
299        // »ý¼ºÀÚ È£Ãâ
300        COTCDownloadFailResetWin_Constructor(pWin, event);
301        // À©µµ¿ì ¸Þ´ÏÀú¿¡ µî·Ï
302        DST_AddWin((WinID)(event.data[0]), pWin);       
303}
304
305
306void DST_CreateOTCDownLoadingWin(SWinEventMsg event)
307{
308        if (DST_GetWin(WIN_UPDATE)) return;
309        DST_RemoveAllWindowExceptBasicWin();
310        CWindow*pWin = NewCWindow(event);
311        pWin->Destructor        = COTCDownLoadingWin_Destructor;
312        pWin->KeyInput          = COTCDownLoadingWin_KeyInput;
313        pWin->OnTimer           = COTCDownLoadingWin_OnTimer;
314        pWin->OnMessage         = COTCDownLoadingWin_OnMessage;
315        pWin->Show                      = COTCDownLoadingWin_Show;
316        // »ý¼ºÀÚ È£Ãâ
317        COTCDownLoadingWin_Constructor(pWin, event);
318        // À©µµ¿ì ¸Þ´ÏÀú¿¡ µî·Ï
319        DST_AddWin((WinID)(event.data[0]), pWin);       
320}
321
322
323
Note: See TracBrowser for help on using the repository browser.