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

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

OTC RESET 전에 마지막 POWER 상태 저장하도록 함

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                                DHL_INFO_SetLastPowerState(DST_g_PowerOn);
235                                break;
236                        default: break;
237                }
238        }
239
240//};
241
242void DST_CreateUpdateWin(SWinEventMsg event)
243{
244        if (DST_GetWin(WIN_UPDATE)) return;
245        DST_RemoveAllWindowExceptBasicWin();
246        CWindow*pWin = NewCWindow(event);
247        pWin->Destructor        = CUpdateWin_Destructor;
248        pWin->KeyInput          = CUpdateWin_KeyInput;
249        pWin->OnMessage         = CUpdateWin_OnMessage;
250        pWin->OnTimer           = CUpdateWin_OnTimer;
251        pWin->Show                      = CUpdateWin_Show;
252        // »ý¼ºÀÚ È£Ãâ
253        CUpdateWin_Constructor(pWin, event);
254        // À©µµ¿ì ¸Þ´ÏÀú¿¡ µî·Ï
255        DST_AddWin((WinID)(event.data[0]), pWin);
256
257}
258
259
260//class CUpdateResetWin : public CWindow
261//{
262//private:
263//      static DS_U8 winParentID;
264//      static DS_U8 msg;
265       
266//public:
267//      CUpdateResetWin(SWinEventMsg event):CWindow(event)
268        void CUpdateResetWin_Constructor(CWindow *this, SWinEventMsg event)
269        {
270                this->SetWinName(this,  "UpdateReset");
271                this->rect.w = 382; 
272                this->rect.h = 241; 
273
274                this->rect.x = (DST_GetScreenWidth() - this->rect.w) / 2;
275                this->rect.y = (DST_GetScreenHeight()- this->rect.h) / 2;
276                this->SetTimeOut(this, 0);
277               
278
279        }
280        void CUpdateResetWin_Destructor(CWindow *this)
281        {
282                DST_g_bUpdateCompleted = true;
283                DHL_INFO_SetLastPowerState(DST_g_PowerOn);
284                DST_Reset(__func__); // âÀÌ ´ÝÈ÷¸é¼­ ÀçºÎÆÃ
285        }
286       
287//      virtual void OnTimer(char nID)
288        void CUpdateResetWin_OnTimer(CWindow *this, char nID)
289        {
290                switch(nID)
291                {
292                        case 1:
293                                this->KillTimer(this, 1);
294                                this->Close(this);
295                                break;
296                        default:
297                                break;
298                }
299        }
300       
301//      virtual void Show(void)
302        void CUpdateResetWin_Show(CWindow *this)
303        {
304                this->RegisterAllKey(this);
305                this->DrawBox32(this, 0, 0, this->rect.w, this->rect.h, CONV32_16(0xff24435e));
306                this->setFontStyle(this, 22,0xFFFFFFFF,ALIGN_MIDDLE,ALIGN_CENTER);
307                this->DrawTextUni(this, 0, 0, this->rect.w, this->rect.h, pz_sysreset[OSD_Lang], &(this->font));
308                this->UpdateScreen(this);
309               
310                this->SetTimer(this, 1, 1000);
311        }
312
313//      virtual void KeyInput(DS_U8 key, bool /*bRepeat*/)
314        void CUpdateResetWin_KeyInput(CWindow *this, DS_U8 key, bool bRepeat)
315        {
316                switch (key)
317                {
318                        case VK_KEY_PWR:
319                        case VK_PWR:
320                                if (DST_g_PowerOn) // ÄÑÁø»óÅÂ
321                                {
322                                        DST_g_PowerOn = false; // È­¸éÀ» ²ö´Ù.
323                                }
324                                else // ²¨Áø»óÅÂ
325                                {
326                                        DST_g_PowerOn = true;// È­¸éÀ» ÄÒ´Ù
327                                } 
328                                JST_POWER_Display(DST_g_PowerOn);
329                                DHL_INFO_SetLastPowerState(DST_g_PowerOn);
330                                break;
331                        default:
332                                break;
333                }
334        }
335
336//};
337void DST_CreateUpdateResetWin(SWinEventMsg event)
338{
339        DST_RemoveAllWindowExceptBasicWin();
340        CWindow*pWin = NewCWindow(event);
341        pWin->Destructor        = CUpdateResetWin_Destructor;
342        pWin->KeyInput          = CUpdateResetWin_KeyInput;
343        pWin->OnTimer           = CUpdateResetWin_OnTimer;
344        pWin->Show                      = CUpdateResetWin_Show;
345        // »ý¼ºÀÚ È£Ãâ
346        CUpdateResetWin_Constructor(pWin, event);
347        // À©µµ¿ì ¸Þ´ÏÀú¿¡ µî·Ï
348        DST_AddWin((WinID)(event.data[0]), pWin);
349}
350
351
Note: See TracBrowser for help on using the repository browser.