source: svn/trunk/zasc/app_c/DST_WinUpdate.c

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

DHL_SYS_Off 함수로 바로 끄도록 함

File size: 11.5 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_OSDImage.h"
10
11#if 0
12____CMessageWin___()
13#endif
14
15
16//class CUpdateWin : public CWindow
17//{
18//private:
19        static bool CUpdateWin_bDone;
20        static bool CUpdateWin_bNeedLine;
21        static int CUpdateWin_progress;
22        static int CUpdateWin_center_pos;
23        static int CUpdateWin_line_spacing;     
24
25//      static int CUpdateWin_nBlock;
26        static int CUpdateWin_nErr;
27        static int CUpdateWin_ErrCategory;
28        static int CUpdateWin_category;
29       
30//public:
31//      CUpdateWin(SWinEventMsg event):CWindow(event)
32        void CUpdateWin_Constructor(CWindow *this, SWinEventMsg event)
33        {
34                this->SetWinName(this,  "Update");
35                DST_g_RFUpdateState = 0;
36                this->rect.w = 382; 
37                this->rect.h = 241; 
38                this->rect.x = (DST_GetScreenWidth() - this->rect.w) / 2;
39                this->rect.y = (DST_GetScreenHeight()- this->rect.h) / 2;
40
41                DST_Printf("\n\n--------------------------WIN_UPDATE----------------------------------\n\n");
42               
43
44                CUpdateWin_center_pos =  this->rect.h / 2; 
45                CUpdateWin_line_spacing = DST_GetFontHeight(fontItemSize) * 150 / 100;
46
47                CUpdateWin_nErr = 0;
48                CUpdateWin_ErrCategory = 0;
49                CUpdateWin_category = 0;
50                CUpdateWin_bNeedLine = false;
51//              RegisterAllKey();
52                this->SetTimeOut(this, 0);
53                CUpdateWin_bDone = false;
54                CUpdateWin_progress = 0;
55        }
56
57        void CUpdateWin_Destructor(CWindow *this)
58        {
59       
60        }
61       
62        void CUpdateWin_DrawProgressBar(CWindow *this, DS_U32 nPos, DS_U32 nTotal, int x, int y, DS_U32 width)
63        {
64                this->DrawBox32(this, x, y, width, 10, CONV32_16(0xffe5e5ff));
65                if(nPos == nTotal)
66                        this->DrawBox32(this, x, y, width, 10, CONV32_16(0xff65a5cc));
67                else
68                        this->DrawBox32(this, x, y, (nPos*width)/nTotal, 10, CONV32_16(0xff65a5cc));
69                this->UpdateScreen(this);
70        }
71
72        void CUpdateWin_Draw(CWindow *this, DS_U16 * category)
73        {
74                this->DrawBox32(this, 0, 0, this->rect.w, this->rect.h, CONV32_16(0xff24435e));
75               
76                this->setFontStyle(this, fontItemSize,0xFFE1E1E1,ALIGN_MIDDLE,ALIGN_CENTER);
77
78                this->DrawTextUni(this, 0, CUpdateWin_center_pos-2*CUpdateWin_line_spacing-10, this->rect.w, CUpdateWin_line_spacing, category, &(this->font)); 
79                this->DrawTextUni(this, 0, CUpdateWin_center_pos-CUpdateWin_line_spacing-10, this->rect.w, CUpdateWin_line_spacing, pz_Updating_1[OSD_Lang], &(this->font)); 
80                this->DrawTextUni(this, 0, CUpdateWin_center_pos-10, this->rect.w, CUpdateWin_line_spacing, pz_Updating_2[OSD_Lang], &(this->font)); 
81                this->DrawTextUni(this, 0, CUpdateWin_center_pos+CUpdateWin_line_spacing-10, this->rect.w, CUpdateWin_line_spacing, pz_Updating_3[OSD_Lang], &(this->font)); 
82        }
83
84//      virtual void OnTimer(char nID)
85        void CUpdateWin_OnTimer(CWindow *this, char nID)
86        {
87                switch(nID)
88                {
89                        case 1:
90                                DST_Printf("CUpdateWin_nErr : %d \n",CUpdateWin_nErr);
91                                this->KillTimer(this, 1);
92                                this->DrawBox32(this, 0, 0, this->rect.w, this->rect.h, CONV32_16(0xff24435e));
93                                switch(CUpdateWin_ErrCategory)
94                                {
95                                        case UPDATE_BOOTLOADER:
96                                                this->DrawTextUni(this, 0, CUpdateWin_center_pos-CUpdateWin_line_spacing, this->rect.w, CUpdateWin_line_spacing, pz_Updating_Cat_1[OSD_Lang], &(this->font)); 
97                                                break;
98                                        case UPDATE_APPLICATION:
99                                                this->DrawTextUni(this, 0, CUpdateWin_center_pos-CUpdateWin_line_spacing, this->rect.w, CUpdateWin_line_spacing, pz_Updating_Cat_4[OSD_Lang], &(this->font)); 
100                                                break;
101                                        case UPDATE_APPLICATION0:
102                                                this->DrawTextUni(this, 0, CUpdateWin_center_pos-CUpdateWin_line_spacing, this->rect.w, CUpdateWin_line_spacing, pz_Updating_Cat_4_1[OSD_Lang], &(this->font)); 
103                                                break;
104                                        case UPDATE_APPLICATION1:
105                                                this->DrawTextUni(this, 0, CUpdateWin_center_pos-CUpdateWin_line_spacing, this->rect.w, CUpdateWin_line_spacing, pz_Updating_Cat_4_2[OSD_Lang], &(this->font)); 
106                                                break;
107                                        case UPDATE_VERSION_READ:
108                                                this->DrawTextUni(this, 0, CUpdateWin_center_pos-CUpdateWin_line_spacing, this->rect.w, CUpdateWin_line_spacing, pz_Updating_Cat_5[OSD_Lang], &(this->font)); 
109                                                break;
110                                        default:
111                                                break;
112                                }
113                               
114                                switch(CUpdateWin_nErr)
115                                {
116                                        case WRITE_FLASH_FAIL:
117                                                this->DrawTextUni(this, 0, (CUpdateWin_bNeedLine?CUpdateWin_center_pos:0), this->rect.w, (CUpdateWin_bNeedLine?CUpdateWin_line_spacing:this->rect.h), pz_Update_Err_301[OSD_Lang], &(this->font));
118                                                break;
119                                        case CRC_FLASH_BOOTLOADER_FAIL:
120                                                this->DrawTextUni(this, 0, (CUpdateWin_bNeedLine?CUpdateWin_center_pos:0), this->rect.w, (CUpdateWin_bNeedLine?CUpdateWin_line_spacing:this->rect.h), pz_Update_Err_401[OSD_Lang], &(this->font));
121                                                break;
122                                        case CRC_FLASH_APPLICATION_FAIL:
123                                                this->DrawTextUni(this, 0, (CUpdateWin_bNeedLine?CUpdateWin_center_pos:0), this->rect.w, (CUpdateWin_bNeedLine?CUpdateWin_line_spacing:this->rect.h), pz_Update_Err_402[OSD_Lang], &(this->font));
124                                                break;
125                                        case CRC_READ_BOOTLOADER_FAIL:
126                                                this->DrawTextUni(this, 0, (CUpdateWin_bNeedLine?CUpdateWin_center_pos:0), this->rect.w, (CUpdateWin_bNeedLine?CUpdateWin_line_spacing:this->rect.h), pz_Update_Err_403[OSD_Lang], &(this->font));
127                                                break;
128                                        case CRC_READ_APPLICATION_FAIL:
129                                                this->DrawTextUni(this, 0, (CUpdateWin_bNeedLine?CUpdateWin_center_pos:0), this->rect.w, (CUpdateWin_bNeedLine?CUpdateWin_line_spacing:this->rect.h), pz_Update_Err_404[OSD_Lang], &(this->font));
130                                                break;
131                                        case CRC_READ_TOTAL_FAIL:
132                                                this->DrawTextUni(this, 0, (CUpdateWin_bNeedLine?CUpdateWin_center_pos:0), this->rect.w, (CUpdateWin_bNeedLine?CUpdateWin_line_spacing:this->rect.h), pz_Update_Err_405[OSD_Lang], &(this->font));
133                                                break;
134                                        case UPDATE_CHECKING_CRC:
135                                                this->DrawTextUni(this, 0, CUpdateWin_center_pos-CUpdateWin_line_spacing, this->rect.w, CUpdateWin_line_spacing, pz_Updating_4[OSD_Lang], &(this->font)); 
136                                                this->DrawTextUni(this, 0, CUpdateWin_center_pos, this->rect.w, CUpdateWin_line_spacing, pz_Updating_5[OSD_Lang], &(this->font)); 
137                                                break;
138                                        case UPDATE_FINISHED:
139                                                this->DrawTextUni(this, 0, CUpdateWin_center_pos-CUpdateWin_line_spacing, this->rect.w, CUpdateWin_line_spacing, pz_Updating_6[OSD_Lang], &(this->font)); 
140                                                this->DrawTextUni(this, 0, CUpdateWin_center_pos, this->rect.w, CUpdateWin_line_spacing, pz_sysreset[OSD_Lang], &(this->font));         
141
142                                                break;
143                                        default:
144                                                break;
145                                }
146                                if(CUpdateWin_nErr == UPDATE_FINISHED || CUpdateWin_nErr == UPDATE_CHECKING_CRC)
147                                {
148                                        DST_g_LED_PowerState = 2;
149                                       
150                                        this->SetTimer(this, 2,5000);
151                                }
152                                else
153                                {
154                                        DST_g_LED_PowerState = 1;
155                                }
156                                this->UpdateScreen(this);       
157                                break;
158                        case 2:
159                                this->Close(this);
160                                DST_CreateWin(WIN_UPDATE_RESET, 0, 0, 0, 0, 0);
161                                break;
162                        default:
163                                break;
164                }
165        }
166
167//      virtual void OnMessage(SWinEventMsg event)
168        void CUpdateWin_OnMessage(CWindow *this, SWinEventMsg event)
169        {
170                switch (event.cmd)
171                {
172                        case WM_RF_UPDATE:
173                                switch(event.data32[0])
174                                {
175                                        case FLASH_WRITING: // FLASH WRITING
176                                                if(CUpdateWin_category != (int)event.data32[2])
177                                                {
178                                                        CUpdateWin_category = event.data32[2];
179                                                        switch(CUpdateWin_category)
180                                                        {
181                                                                case UPDATE_BOOTLOADER: CUpdateWin_Draw(this, pz_Updating_Cat_str_1[OSD_Lang]); break;
182                                                                case UPDATE_APPLICATION0: CUpdateWin_Draw(this, pz_Updating_Cat_str_4_1[OSD_Lang]); break;
183                                                                case UPDATE_APPLICATION1: CUpdateWin_Draw(this, pz_Updating_Cat_str_4_2[OSD_Lang]); break;
184                                                        }
185                                                       
186                                                }
187                                               
188                                                CUpdateWin_DrawProgressBar(this, event.data32[1], 100,this->rect.w/10,CUpdateWin_center_pos+2*CUpdateWin_line_spacing-10,this->rect.w*8/10);           
189                                               
190                                                DST_g_RFUpdateState = 1;
191                                                break;
192                                        case FLASH_WRITING_COMPLETE: // FLASH WRITING COMPLETE
193                                        case FLASH_WRITING_FAIL:
194                                                CUpdateWin_nErr = event.data32[1];
195                                                CUpdateWin_ErrCategory = event.data32[2];
196                                                if(CUpdateWin_ErrCategory != UPDATE_OK) CUpdateWin_bNeedLine = true;
197                                                else CUpdateWin_bNeedLine = false;
198                                                if (CUpdateWin_nErr != 0) this->SetTimer(this, 1, 500);                                         
199                                                break;
200                                                default: break;
201                                               
202                                }
203                                break;
204                                default: break;
205                               
206                }
207        }
208
209       
210//      virtual void Show(void)
211        void CUpdateWin_Show(CWindow *this)
212        {
213               
214                CUpdateWin_Draw(this, pz_Updating_Cat_str_system[OSD_Lang]);
215                this->RegisterAllKey(this);
216        }
217
218//      virtual void KeyInput(DS_U8 key, bool /*bRepeat*/)
219        void CUpdateWin_KeyInput(CWindow *this, DS_U8 key, bool bRepeat)
220        {
221                switch (key)
222                {
223                        case VK_KEY_PWR:
224                        case VK_PWR:
225                                if (DST_g_PowerOn) // ÄÑÁø»óÅÂ
226                                {
227                                        DST_g_PowerOn = false;// È­¸éÀ» ²ö´Ù.
228                                }
229                                else // ²¨Áø»óÅÂ
230                                {
231                                        DST_g_PowerOn = true;// È­¸éÀ» ÄÒ´Ù
232                                } 
233                                JST_POWER_Display(DST_g_PowerOn);
234                                break;
235                        default: break;
236                }
237        }
238
239//};
240
241void DST_CreateUpdateWin(SWinEventMsg event)
242{
243        if (DST_GetWin(WIN_UPDATE)) return;
244        DST_RemoveAllWindowExceptBasicWin();
245        CWindow*pWin = NewCWindow(event);
246        pWin->Destructor        = CUpdateWin_Destructor;
247        pWin->KeyInput          = CUpdateWin_KeyInput;
248        pWin->OnMessage         = CUpdateWin_OnMessage;
249        pWin->OnTimer           = CUpdateWin_OnTimer;
250        pWin->Show                      = CUpdateWin_Show;
251        // »ý¼ºÀÚ È£Ãâ
252        CUpdateWin_Constructor(pWin, event);
253        // À©µµ¿ì ¸Þ´ÏÀú¿¡ µî·Ï
254        DST_AddWin((WinID)(event.data[0]), pWin);
255
256}
257
258
259//class CUpdateResetWin : public CWindow
260//{
261//private:
262//      static DS_U8 winParentID;
263//      static DS_U8 msg;
264       
265//public:
266//      CUpdateResetWin(SWinEventMsg event):CWindow(event)
267        void CUpdateResetWin_Constructor(CWindow *this, SWinEventMsg event)
268        {
269                this->SetWinName(this,  "UpdateReset");
270                this->rect.w = 382; 
271                this->rect.h = 241; 
272
273                this->rect.x = (DST_GetScreenWidth() - this->rect.w) / 2;
274                this->rect.y = (DST_GetScreenHeight()- this->rect.h) / 2;
275                this->SetTimeOut(this, 0);
276               
277
278        }
279        void CUpdateResetWin_Destructor(CWindow *this)
280        {
281                DST_g_bUpdateCompleted = true;
282                if (DST_g_PowerOn)
283                {
284                        T();
285                        DST_Reset(__func__); // âÀÌ ´ÝÈ÷¸é¼­ ÀçºÎÆÃ
286                }
287                else
288                {
289                        T();
290                        DHL_SYS_Off();
291                }
292        }
293       
294//      virtual void OnTimer(char nID)
295        void CUpdateResetWin_OnTimer(CWindow *this, char nID)
296        {
297                switch(nID)
298                {
299                        case 1:
300                                this->KillTimer(this, 1);
301                                this->Close(this);
302                                break;
303                        default:
304                                break;
305                }
306        }
307       
308//      virtual void Show(void)
309        void CUpdateResetWin_Show(CWindow *this)
310        {
311                this->RegisterAllKey(this);
312                this->DrawBox32(this, 0, 0, this->rect.w, this->rect.h, CONV32_16(0xff24435e));
313                this->setFontStyle(this, 22,0xFFFFFFFF,ALIGN_MIDDLE,ALIGN_CENTER);
314                this->DrawTextUni(this, 0, 0, this->rect.w, this->rect.h, pz_sysreset[OSD_Lang], &(this->font));
315                this->UpdateScreen(this);
316               
317                this->SetTimer(this, 1, 1000);
318        }
319
320//      virtual void KeyInput(DS_U8 key, bool /*bRepeat*/)
321        void CUpdateResetWin_KeyInput(CWindow *this, DS_U8 key, bool bRepeat)
322        {
323                switch (key)
324                {
325                        case VK_KEY_PWR:
326                        case VK_PWR:
327                                if (DST_g_PowerOn) // ÄÑÁø»óÅÂ
328                                {
329                                        DST_g_PowerOn = false; // È­¸éÀ» ²ö´Ù.
330                                }
331                                else // ²¨Áø»óÅÂ
332                                {
333                                        DST_g_PowerOn = true;// È­¸éÀ» ÄÒ´Ù
334                                } 
335                                JST_POWER_Display(DST_g_PowerOn);
336                                break;
337                        default:
338                                break;
339                }
340        }
341
342//};
343void DST_CreateUpdateResetWin(SWinEventMsg event)
344{
345        DST_RemoveAllWindowExceptBasicWin();
346        CWindow*pWin = NewCWindow(event);
347        pWin->Destructor        = CUpdateResetWin_Destructor;
348        pWin->KeyInput          = CUpdateResetWin_KeyInput;
349        pWin->OnTimer           = CUpdateResetWin_OnTimer;
350        pWin->Show                      = CUpdateResetWin_Show;
351        // »ý¼ºÀÚ È£Ãâ
352        CUpdateResetWin_Constructor(pWin, event);
353        // À©µµ¿ì ¸Þ´ÏÀú¿¡ µî·Ï
354        DST_AddWin((WinID)(event.data[0]), pWin);
355}
356
357
Note: See TracBrowser for help on using the repository browser.