source: svn/newcon3bcm2_21bu/dst/app/src/Function/App_Fnc_Time.c

Last change on this file was 76, checked in by megakiss, 10 years ago

1W 대기전력을 만족시키기 위하여 POWEROFF시 튜너를 Standby 상태로 함

  • Property svn:executable set to *
File size: 24.3 KB
Line 
1/****************************************************************************
2* NAME: App_Fnc_Time.c
3*----------------------------------------------------------------------------
4* Copyright (c) DIGITAL STREAM Technology Inc.
5*----------------------------------------------------------------------------
6* CREATED_BY: Do Gon Lee
7* CREATION_DATE: 2009/08/25
8* $Author: foxhunt $
9* $Revision: 1.0 $
10* $Date: 2009/08/25 16:20:41 $
11*----------------------------------------------------------------------------
12* PURPOSE:
13* - implement all system time functions
14*       - implement all timer related functions (periodic timer)
15* DEPENDENCY:
16* - SYS MW
17*****************************************************************************/
18
19/*_____ I N C L U D E __________________________________________*/
20
21#include "App_Main.h"
22
23#if SUPPORT_TIME
24
25#include "App_Fnc_Common.h"
26
27#include "App_Fnc_Time.h"
28
29
30#include "App_Res_Resources.h"
31
32#if SUPPORT_POD
33#include "SCTESI_Tables.h"
34#endif
35
36
37
38
39
40/*_____ D E F I N I T I O N ____________________________________*/
41
42#if COMMENT
43____DbgPrint____(){}
44#endif
45
46DHL_MODULE("@f_tim", 0);
47
48
49
50
51
52#if COMMENT
53____Config____(){}
54#endif
55
56#define DEF_TIME_OFFSET   788598000             /* 630687600 */
57
58#define TIMEPERIOD_FOR_MANUAL_FRONTREAD 600             /* sec */
59#define TIMEPERIOD_FOR_AUTO_FRONTSYNC           30
60
61
62
63
64
65#if COMMENT
66____Types____(){}
67#endif
68
69#if SUPPORT_MANUAL_TIMER
70/* µÎ°³ÀÇ time context¸¦ °ü¸®ÇÑ´Ù.
71         Çϳª´Â manual ¼³Á¤¿¡ ÀÇÇÑ °Í, ¶Ç Çϳª´Â STT·ÎºÎÅÍ ÀÚµ¿ sync µÇ´Â °Í.. */
72         
73SysTimeContext g_stcManual =
74{
75        1,                                                              /* BOOL bTimeAdjusted */
76        DEF_TIME_OFFSET,        /* int nTimeSystemBase */
77       
78        DEF_TIME_SHIFT,                                                         /* int nTimeZone */
79
80#if SUPPORT_DAYLIGHT_SAVING
81        1,                                                              /* BOOL bDaylightSavingOn */
82#else
83        0,                                                              /* BOOL bDaylightSavingOn */
84#endif 
85        13,                                                             /* int GPS_UTC_offset */
86};
87#endif  /* #if SUPPORT_MANUAL_TIMER */
88
89
90SysTimeContext g_stcAutoSync = 
91{
92        1,                                                              /* BOOL bTimeAdjusted */
93        DEF_TIME_OFFSET,        /* int nTimeSystemBase */
94       
95        DEF_TIME_ZONE,                                                          /* int nTimeZone */
96
97#if SUPPORT_DAYLIGHT_SAVING
98        1,                                                              /* BOOL bDaylightSavingOn */
99#else
100        0,                                                              /* BOOL bDaylightSavingOn */
101#endif
102
103        13,                                                             /* int GPS_UTC_offset */
104};
105
106
107static struct
108{
109        BOOL bManualMode;
110        BOOL bDayLightSaving;
111        APP_TIMEZONE timeZone;
112        UINT8 sleepTimer; /* 1 means 5 min and value 0 means no use*/
113        UINT8 menuTimeout; /* menu timeout, 0-254 sec, 255 means forever */
114        UINT8 noKeyInputPowerDownTimeout; /* power down timeout 1 means 10min , 255 means forever*/
115        UINT8 noSigPowerDownTimeout; /* power down timeout 1 means 10min , 255 means forever*/
116} p_time_nvm_param;
117
118
119
120#if COMMENT
121____Variables____(){}
122#endif
123
124
125
126
127
128SysTimeContext *g_TimeContext = &g_stcAutoSync;
129        /* Âü°í : g_TimeContext´Â µÎ°¡Áö context ÁßÀÇ ÇϳªÀÌ´Ù.
130                  1. g_stcAutoSync
131                  2. g_stcManual
132        */
133
134#if 1
135        // ´ëºÎºÐÀÇ ½Ã°£ °ü¸®´Â MWÀÇ stc¸¦ ÀÌ¿ëÇϱ⠶§¹®¿¡ ±»ÀÌ stt »çº»À» À¯ÁöÇÒ ÇÊ¿ä´Â ¾ø´Ù.
136        // ³ªÁß¿¡ »èÁ¦ Á¤¸® ÇÊ¿ä..
137#else
138/*************************************
139  Variables for Setting by STT Value
140*************************************/
141sttSection_t g_FlatStt; /* °¡Àå ÃÖ±Ù¿¡ setµÈ STT »çº». */
142#endif // #if 1
143
144
145
146#if COMMENT
147____Local_Func____(){}
148#endif
149
150/*_____ F U N C T I O N ________________________________________*/
151
152const char *TimeString(STime_t *t, char *buf)
153{
154        static char _buf[64];
155       
156        if (buf == NULL) buf = _buf;
157       
158        sprintf(buf, "%d/%d/%d %s %d:%02d:%02d", 
159                t->year, t->month, t->day, DayOfWeakString(t->wday), t->hour, t->min, t->sec);
160               
161        return buf;
162}
163
164
165static void p_format_time_param(void)
166{
167        p_time_nvm_param.bManualMode=eAPP_TIME_MANUALMODE;
168        p_time_nvm_param.timeZone=APP_DEF_TIMEZONE;
169        p_time_nvm_param.bDayLightSaving=SUPPORT_DAYLIGHT_SAVING;
170        p_time_nvm_param.menuTimeout=60;
171        p_time_nvm_param.sleepTimer=0;
172        p_time_nvm_param.noKeyInputPowerDownTimeout=6*4; //4½Ã°£ ±âº»
173        p_time_nvm_param.noSigPowerDownTimeout=6*4; //4½Ã°£ ±âº».
174       
175        App_NVM_SaveModuleParam(eAPP_NVR_TIME, &p_time_nvm_param);
176}
177
178
179
180#if COMMENT
181____Legacy_API____(){}
182#endif
183
184/******************************************************************************************
185FUNCTION:
186  - AppTime_GetCurTime
187 
188Arguments:
189  - [in]nMode
190     0 -> ÀÚµ¿ÀûÀ¸·Î ¼ÂÆÃµÈ ½Ã°£À» Àоî¿È.
191     1 -> °­Á¦·Î ¹«Á¶°Ç STT ½Ã°£¸¸À» Àоî¿È.
192     2 -> °­Á¦·Î ¹«Á¶°Ç user ½Ã°£¸¸À» Àоî¿È.
193Purpose:
194  - ÇöÀç ½Ã°£À» return ÇØ ÁÖ´Â ÇÔ¼ö. (return ÇüÀº »ç¿ëÀÚ ½Ã°£ ±¸Á¶Ã¼ : APP_TIME_T)
195        - ÇѹøÀÌ¶óµµ Adjust ÇØ ÁÖÁö ¾ÊÀ¸¸é error return.
196        - GPS ½Ã°£À» ¿øÇÑ´Ù¸é APP_TIME_T ±¸Á¶Ã¼ÀÇ sys_timeÀ» ÂüÁ¶.
197*******************************************************************************************/
198STATUS AppTime_GetCurTime(APP_TIME_T *tm, int nMode)
199{
200        UINT32 utc;
201        SysTimeContext *stc = g_TimeContext; 
202        STime_t system_time;
203        STATUS status;
204
205        /* ¸ÕÀú utc¸¦ ¾ò°í, gps·Î º¯È¯.. */
206        if(nMode == 0)
207                stc = g_TimeContext;
208        else if(nMode == 1) 
209                stc = &g_stcAutoSync;
210#if SUPPORT_MANUAL_TIMER
211        else if(nMode == 2)
212                stc = &g_stcManual;
213#endif  /* #if SUPPORT_MANUAL_TIMER */
214        else {
215                dprint(0, "!! invalid systime mode %d\n", nMode);
216                return statusInvalidArgument;
217        }
218       
219        status=DMW_GetUTCTime(stc, &utc);
220        tm->sys_time = DMW_ConvertUTC2GPS(stc, utc);
221       
222        /* local timeÀ¸·Î º¯È¯.. */
223        DMW_ConvertUTC2LocalTime(stc, utc, &system_time);
224       
225        tm->year = system_time.year;
226        tm->month = system_time.month;
227        tm->date = system_time.day;
228        tm->day = system_time.wday;
229       
230        tm->hour = system_time.hour;
231        tm->minute = system_time.min;
232        tm->second = system_time.sec;
233        tm->bDaySave = DMW_GetDayLightSaving(stc);
234
235        return status;
236}
237
238
239/******************************************************************************************
240FUNCTION:
241  - AppTime_SetTimeByUserTime
242
243Purpose:
244  -
245******************************************************************************************/
246void AppTime_SetTimeByUserTime(int nMode, APP_TIME_T *t)
247{
248#if SUPPORT_MANUAL_TIMER
249
250        if(nMode)       /* UserTime */
251        {
252                /* AppTime_AdjustTimeWithUserLocalTime(&DateTime); */
253                DMW_SetLocalTime2(&g_stcManual, t->year, t->month, t->date, t->hour, t->minute, t->second);
254        }
255
256#endif  /* #if SUPPORT_MANUAL_TIMER */
257}
258
259
260/******************************************************************************************
261FUNCTION:
262  - AppTime_GetTimeFromGPS
263
264Purpose:
265  - GPS ½Ã°£À» »ç¿ëÀÚ ½Ã°£(APP_TIME_T ±¸Á¶Ã¼)·Î ÀüȯÇÏ´Â ÇÔ¼ö
266        - ÇѹøÀÌ¶óµµ STT¿¡ ÀÇÇØ setµÇÁö ¾Ê¾ÒÀ» °æ¿ì GPS_UTC_offset °ú DS_Status´Â ¹«½ÃµÈ´Ù.
267        - Á¤ÇØÁø Time ZoneÀÌ ¹Ý¿µµÇ¾î Ç¥½ÃµÈ´Ù.
268Note : ÁÖÀÇ!
269             ÀÌ ÇÔ¼ö´Â ManualTimeContext¸¦ »ç¿ëÇÏÁö ¾Ê°í Ç×»ó AutoSync context¸¸À» »ç¿ëÇÑ´Ù.
270******************************************************************************************/
271void AppTime_GetTimeFromGPS(UINT32 nGPSTime, APP_TIME_T *tm)
272{
273        UINT32 utc;
274        STime_t t;
275        SysTimeContext *stc = &g_stcAutoSync;   /* <-- cafrii 041004 change */
276
277        utc = DMW_ConvertGPS2UTC(stc, nGPSTime);
278
279        /* local timeÀ¸·Î º¯È¯.. */
280        DMW_ConvertUTC2LocalTime(stc, utc, &t);
281       
282        tm->sys_time = nGPSTime;
283        tm->year = t.year;
284        tm->month = t.month;
285        tm->date = t.day;
286        tm->day = t.wday;
287        tm->hour = t.hour;
288        tm->minute = t.min;
289        tm->second = t.sec;
290        tm->bDaySave = DMW_GetDayLightSaving(stc);
291}
292
293
294/******************************************************************************************
295FUNCTION:
296  - AppTime_DmwTime2STime
297
298Purpose:
299  - DMW_TIME_T´Â ´õÀÌ»ó Á¦°øÇÏÁö ¾Ê´Â typeÀε¥, ±âÁ¸ app code°¡ ÀÌ typeÀ» ¸¹ÀÌ »ç¿ëÇϰí
300   ÀÖÀ¸¹Ç·Î ÀÏ´Ü º¯È¯ ÇÔ¼ö Á¦°ø.
301******************************************************************************************/
302void AppTime_DmwTime2STime(APP_TIME_T *t1, STime_t *t2)
303{
304        t2->year  = t1->year;
305        t2->month = t1->month;
306        t2->day   = t1->date;   /* date°¡ day of month¸¦ ÀǹÌÇßÀ½. */
307        t2->wday  = t1->day;
308        t2->hour  = t1->hour;
309        t2->min   = t1->minute;
310        t2->sec   = t1->second;
311}
312
313
314void AppTime_STime2DmwTime(STime_t *t2, APP_TIME_T *t1)
315{
316        t1->year   = t2->year;
317        t1->month  = t2->month;
318        t1->day    = t2->day;
319        t1->day    = t2->wday;
320        t1->hour   = t2->hour;
321        t1->minute = t2->min;
322        t1->second = t2->sec;
323}
324
325
326
327
328
329#if COMMENT
330____API____(){}
331#endif
332
333/******************************************************************************************
334FUNCTION:
335  - AdjustTimeWithSTT
336
337Purpose:
338  - STTÀÇ µ¥ÀÌÅ͸¦ ÀÌ¿ëÇÏ¿© ÇöÀç µ¹¾Æ°¡°í ÀÖ´Â system timeÀ» °íÄ£´Ù.
339        - Tick count ¿¡ ÀÇÇÑ timer´Â Á¤È®¼ºÀÌ ¶³¾îÁö¹Ç·Î ÀÏÁ¤ÇÑ Áֱ⺰·Î stt·Î
340          updateÇØÁÖ¾î¾ß ÇÔ.
341Note : cafrii 081121, make public API
342******************************************************************************************/
343static void AdjustTimeWithSTT(sttSectionPtr_t sttSectPtr)
344{
345        /* GPS/UTC º¯È¯ÀÇ ±âº»ÀÌ µÇ´Â ÀÌ °ªÀ» stt·ÎºÎÅÍ °¡Á®¿Â´Ù. */
346        DMW_SetGPS_UTC_offset(&g_stcAutoSync, sttSectPtr->GPS_UTC_offset);
347
348        DMW_SetDayLightSavingParam(&g_stcAutoSync, 
349                        sttSectPtr->daylight_savings.DS_status ? 1 : 0,
350                        sttSectPtr->daylight_savings.DS_day_of_month,
351                        sttSectPtr->daylight_savings.DS_hour);
352       
353        /* ÀÚµ¿ DST sync ¸ðµå¶ó¸é STTÀÇ °ü·Ã ÇÊµå °ªÀ» ÀÌ¿ëÇØ Àû¿ëÇÑ´Ù.
354                 ¼öµ¿ DST ¸ðµå¶ó¸é º°µµÀÇ API¸¦ »ç¿ëÇÏ¿© º¯°æÇϱâ Àü±îÁö´Â ±×´ë·Î À¯ÁöµÈ´Ù. */
355
356        DMW_SetDayLightSaving(&g_stcAutoSync, p_time_nvm_param.bDayLightSaving);
357
358        /* STT¸¦ ÀÌ¿ëÇÏ¿© ÇöÀç ½Ã°£À» Àû¿ëÇÑ´Ù. */
359        DMW_SetUTCTime(&g_stcAutoSync, DMW_ConvertGPS2UTC(&g_stcAutoSync, sttSectPtr->system_time));
360}
361
362#if SUPPORT_POD
363/*
364        SCTE SIÀÇ stt¸¦ ÀÌ¿ëÇÏ¿© system ½Ã°£À» syncÇÑ´Ù.
365        PSIP stt¿Í´Â syntax°¡ ´Ù¸£¹Ç·Î, º°µµÀÇ ÇÔ¼ö°¡ ÇÊ¿äÇÏ´Ù.
366*/
367static void AdjustTimeWithSiStt(scteSiSttSectionPtr_t siStt)
368{
369        /* GPS/UTC º¯È¯ÀÇ ±âº»ÀÌ µÇ´Â ÀÌ °ªÀ» stt·ÎºÎÅÍ °¡Á®¿Â´Ù. */
370        DMW_SetGPS_UTC_offset(&g_stcAutoSync, siStt->GPS_UTC_offset);
371       
372        DMW_SetDayLightSavingParam(&g_stcAutoSync, 
373                        siStt->DS_status ? 1 : 0,
374                        siStt->DS_day_of_month,
375                        siStt->DS_hour);
376
377        /* ÀÚµ¿ DST sync ¸ðµå¶ó¸é STTÀÇ °ü·Ã ÇÊµå °ªÀ» ÀÌ¿ëÇØ Àû¿ëÇÑ´Ù.
378                 ¼öµ¿ DST ¸ðµå¶ó¸é º°µµÀÇ API¸¦ »ç¿ëÇÏ¿© º¯°æÇϱâ Àü±îÁö´Â ±×´ë·Î À¯ÁöµÈ´Ù. */
379       
380        DMW_SetDayLightSaving(&g_stcAutoSync, p_time_nvm_param.bDayLightSaving);
381
382        /* STT¸¦ ÀÌ¿ëÇÏ¿© ÇöÀç ½Ã°£À» Àû¿ëÇÑ´Ù. */
383        DMW_SetUTCTime(&g_stcAutoSync, DMW_ConvertGPS2UTC(&g_stcAutoSync, siStt->system_time));
384}
385#endif
386
387
388/******************************************************************************************
389FUNCTION:
390  - App_SetManualTimeContext
391
392Arguments:
393  - [in]bManualMode
394      TRUE : manual time
395      FALSE: autosync time
396  - [in]bUpdateToNvRam : TRUE À̸é NvRam¿¡ ¹Ù·Î ÀúÀå.
397Purpose:
398  -
399******************************************************************************************/
400void App_SetManualTimeContext(BOOL bManualMode, BOOL bUpdateToNvRam)
401{
402#if SUPPORT_MANUAL_TIMER
403
404        /* DST_bUseManualTime = bManualMode; */
405        /* AppTime_SetManualTimeContext(bManualMode); */
406
407        if (bManualMode)
408                g_TimeContext = &g_stcManual;
409        else
410                g_TimeContext = &g_stcAutoSync; 
411               
412        if(bUpdateToNvRam) {
413                App_NVM_SaveModuleParam(eAPP_NVR_TIME, &p_time_nvm_param);
414        }
415#endif  /* #if SUPPORT_MANUAL_TIMER */
416}
417
418
419/******************************************************************************************
420FUNCTION:
421  - App_IsManualTimeContext
422
423Purpose:
424  - ¸¶Áö¸·À¸·Î ¼³Á¤µÈ context°¡ ¾î¶² °ÍÀ̾ú´ÂÁö¸¦ ¸®ÅÏ.
425    ±×·¯³ª ½Ã°è´Â Ç×»ó µÎ°³ ´Ù °¡µ¿ÁßÀÓ¿¡ À¯ÀÇ.
426******************************************************************************************/
427BOOL App_IsManualTimeContext()
428{
429#if SUPPORT_MANUAL_TIMER
430
431        /* DST_bUseManualTime º¯¼ö¸¦ ÀÌ¿ëÇØµµ µÇÁö¸¸, context¸¦ ÀÌ¿ëÇØ¼­ ¾Ë¾Æ³»ÀÚ. */
432        if (g_TimeContext == &g_stcManual)
433                return TRUE;
434        else
435                return FALSE;
436
437#else
438
439        return FALSE;
440
441#endif  /* #if SUPPORT_MANUAL_TIMER */
442}
443
444
445/******************************************************************************************
446FUNCTION:
447  - App_Get/SetLocalTime
448
449Purpose:
450  - ÇöÀç ½Ã°¢ get,set query ÇÔ¼ö.
451******************************************************************************************/
452void App_SetLocalTime(STime_t *t)
453{
454#if SUPPORT_MANUAL_TIMER
455        if (App_IsManualTimeContext())
456                DMW_SetLocalTime(&g_stcManual, t);
457        else
458#endif  /* #if SUPPORT_MANUAL_TIMER */
459                DMW_SetLocalTime(&g_stcAutoSync, t);
460}
461
462void App_GetLocalTime(STime_t *t)
463{
464#if SUPPORT_MANUAL_TIMER
465        if (App_IsManualTimeContext()) {
466                DMW_GetLocalTime(&g_stcManual, t);
467        }
468        else 
469#endif  /* #if SUPPORT_MANUAL_TIMER */
470                DMW_GetLocalTime(&g_stcAutoSync, t);
471}
472
473
474/******************************************************************************************
475FUNCTION:
476  - App_Get/SetTimeZone
477
478Purpose:
479  - ÇöÀç ¼³Á¤µÈ time zone Á¤º¸¸¦ ¸®ÅÏ. »õ·Î¿î time zoneÀ» ¼³Á¤.
480******************************************************************************************/
481int App_GetTimeZone(void)
482{
483        return p_time_nvm_param.timeZone;
484}
485
486void App_SetTimeZone(APP_TIMEZONE nTimeZone, BOOL bUpdateToNvRam)
487{
488        /*-----------------------------------------------------------------------
489        * nTimeZone
490        * 0: "Atlantic", 1: "Eastern", 2: "Central", 3: "Mountain", 4: "Pacific",
491        * 5: "Alaska", 6:"Hawaii",      7:"Korea"
492        -----------------------------------------------------------------------*/
493        int tzone_table[8] = {
494                -4,  /* 0: "Atlantic", */
495                -5,  /* 1: "Eastern", */
496                -6,  /* 2: "Central", */
497                -7,  /* 3: "Mountain", */
498                -8,  /* 4: "Pacific", */
499                -9,  /* 5: "Alaska", */
500                -10, /* 6: "Hawaii", */
501                +9,  /* 7: "Korea" */
502        };
503       
504        if (nTimeZone < APP_TIMEZONE_MIN || nTimeZone >= APP_TIMEZONE_MAX) {
505                dprint(1, "!! timeZone code %d invalid! set to default '4'\n", nTimeZone);
506                nTimeZone = APP_DEF_TIMEZONE;
507        }
508       
509        p_time_nvm_param.timeZone = nTimeZone;
510       
511        if (bUpdateToNvRam)
512                App_NVM_SaveModuleParam(eAPP_NVR_TIME, &p_time_nvm_param);
513
514        /* timezone °ªÀº ¸ðµç context¿¡ µ¿ÀÏÇÏ´Ù.. */
515#if SUPPORT_MANUAL_TIMER
516        DMW_SetLocalTimeZone(&g_stcManual, tzone_table[nTimeZone]);
517#endif  /* #if SUPPORT_MANUAL_TIMER */
518
519        DMW_SetLocalTimeZone(&g_stcAutoSync, tzone_table[nTimeZone]);
520        /* DMW_SetLocalTimeZone(&g_stcSTT, tzone_table[nTimeZone]);     */     
521}
522
523
524/******************************************************************************************
525FUNCTION:
526  - App_Get/SetDayLightSaving
527
528Purpose:
529  - App_GetDayLightSaving
530   a. ÇöÀçÀÇ Daylight savings Á¤Ã¥À» ¸®ÅÏÇÑ´Ù.
531   b. Auto À̸é TRUE, OFF À̸é FALSEÀÌ´Ù.
532   c. ÁÖÀÇ! ÇöÀç daylight saving »óÅÂÀÎÁö¸¦ ÀǹÌÇÏ´Â°Ô ¾Æ´Ô!!
533   d. ÇöÀç daylight saving ÁßÀÎÁö¸¦ ¾Ë¾Æº¸·Á¸é DMW_CheckDayLightSavingActive()¸¦ Âü°íÇÑ´Ù.
534
535  - App_SetDayLightSaving
536   a. Daylight saving Á¤Ã¥À» º¯°æÇÑ´Ù.
537   b. @bDayLightSavingAuto °¡ TRUE À̸é STTÀÇ dayligt savingÀ» ÁؼöÇÑ´Ù.
538
539        manual time »óȲ¿¡¼­´Â ÀÌ ÇÔ¼ö¸¦ È£ÃâÇÏ´Â °Í ÀÚü°¡ À߸øµÈ °ÍÀÏ ¼ö ÀÖ´Ù.
540        ÇÏÁö¸¸ »ç¿ëÀÚ ¸Þ´º ¼³Á¤ ÀúÀåÀº ÇÊ¿äÇϹǷÎ, stc¿¡ Àû¿ëÀº ¾ÈÇÏ´õ¶óµµ nvm ÀúÀåÀº ÇÊ¿ä.
541       
542******************************************************************************************/
543int App_GetDayLightSaving()
544{
545        return p_time_nvm_param.bDayLightSaving;
546}
547
548void App_SetDayLightSaving(BOOL bDayLightSavingAuto, BOOL bUpdateToNvRam)
549{       
550        p_time_nvm_param.bDayLightSaving = bDayLightSavingAuto;
551       
552        if (bUpdateToNvRam)
553                App_NVM_SaveModuleParam(eAPP_NVR_TIME, &p_time_nvm_param);
554
555#if SUPPORT_MANUAL_TIMER
556        if (App_IsManualTimeContext()) {
557                dprint(0, "!! manual time mode. daylight saving not applied\n");
558                return;
559        }
560#endif  /* #if SUPPORT_MANUAL_TIMER */
561
562        DMW_SetDayLightSaving(&g_stcAutoSync, bDayLightSavingAuto);
563
564        // daylight saving parameter´Â ÀÌ¹Ì stt ¹Þ´Â ¼ø°£ ´Ù Àû¿ëÇϰí ÀÖÀ¸¹Ç·Î,
565        // ¿©±â¼­ ´Ù½Ã ¼³Á¤ ºÒÇÊ¿äÇÏ´Ù.
566        // »ç½Ç stt¸¦ ÀúÀåÇØ µÎÁöµµ ¾ÊÀ¸¹Ç·Î, parameter °ªµµ ¾Ë ¼ö ¾ø´Ù.
567       
568}
569
570static UINT8 p_sleep_time;
571
572UINT8 App_GetSleepTimer() //sleep timer don't have to be stored in NVRAM
573{
574        return p_sleep_time;
575}
576
577
578void App_SetSleepTimer(UINT8 timer)
579{
580        p_sleep_time=timer;
581}
582
583
584BOOL App_IsSleepTimerOn() 
585{
586        return p_time_nvm_param.sleepTimer>0;
587}
588
589
590
591UINT8 App_GetMenuTimeout()
592{
593        if(p_time_nvm_param.menuTimeout!=15 && p_time_nvm_param.menuTimeout!=30 && p_time_nvm_param.menuTimeout!=60) {
594                p_time_nvm_param.menuTimeout=60;
595                App_NVM_SaveModuleParam(eAPP_NVR_TIME, &p_time_nvm_param);
596        }
597        return p_time_nvm_param.menuTimeout;
598}
599
600
601void App_SetMenuTimeout(UINT8 timeout, BOOL bSave)
602{
603        p_time_nvm_param.menuTimeout=timeout;
604       
605        if(bSave)
606                App_NVM_SaveModuleParam(eAPP_NVR_TIME, &p_time_nvm_param);
607}
608
609
610UINT8 App_GetNoKeyPowerDownTimeout() /* Ű ÀÔ·ÂÀÌ ¾øÀ» ¶§ ÀÚµ¿ powerdownµÇ´Â timeout */
611{
612        if(p_time_nvm_param.noKeyInputPowerDownTimeout==0) {
613                p_time_nvm_param.noKeyInputPowerDownTimeout=0xff;
614                App_NVM_SaveModuleParam(eAPP_NVR_TIME, &p_time_nvm_param);
615        }
616        return p_time_nvm_param.noKeyInputPowerDownTimeout;
617}
618
619
620void App_SetNoKeyPowerDownTimeout(UINT8 timeout, BOOL bSave)
621{
622        p_time_nvm_param.noKeyInputPowerDownTimeout=timeout;
623       
624        if(bSave)
625                App_NVM_SaveModuleParam(eAPP_NVR_TIME, &p_time_nvm_param);
626}
627
628
629UINT8 App_GetNoSigPowerDownTimeout() //10ºÐ ´ÜÀ§ÀÓ. ¸®Åϰª 23Àº->230ºÐ.
630{
631        if(p_time_nvm_param.noSigPowerDownTimeout==0) {
632                p_time_nvm_param.noSigPowerDownTimeout=0xff;
633                App_NVM_SaveModuleParam(eAPP_NVR_TIME, &p_time_nvm_param);
634        }
635        return p_time_nvm_param.noSigPowerDownTimeout;
636}
637
638
639void App_SetNoSigPowerDownTimeout(UINT8 timeout, BOOL bSave)
640{
641        p_time_nvm_param.noSigPowerDownTimeout=timeout;
642       
643        if(bSave)
644                App_NVM_SaveModuleParam(eAPP_NVR_TIME, &p_time_nvm_param);
645}
646
647
648/******************************************************************************************
649FUNCTION:
650  - App_SetTimeBySTT
651
652Purpose:
653  - STT¸¦ ¼ö½ÅÇÏ¿© TimeSync¸¦ ¼öÇàÇÏ´Â ÇÔ¼ö.
654  - µÎ°³ÀÇ ½Ã°è Áß¿¡ AutoSync context¿¡¸¸ Àû¿ëÀÌ µÈ´Ù. Áï »ç¿ëÀÚ manual ½Ã°è´Â
655  À̰Ϳ¡ ¿µÇâÀ» ¹ÞÁö ¾Ê´Â´Ù.
656******************************************************************************************/
657int App_SetTimeBySTT(void)
658{
659        int err;
660        /*
661                cafrii 050528 add
662                New EPG ±â´ÉÀ» ÀÌ¿ëÇÑ »õ·Î¿î ¹æ¹ý.
663                ÀÌ ÇÔ¼ö´Â ½Ã°èÀÇ Á¤È®ÇÑ µ¿±â¸¦ À§ÇØ ÁÖ±âÀûÀ¸·Î È£ÃâÇØÁÖ¸é ÁÁ´Ù.
664                ±×¸®°í Epg MW¿¡¼­ Stt Jump À̺¥Æ®°¡ ¿À¸é ¶Ç ´Ù½Ã È£ÃâÇØ Áà¾ß ÇÑ´Ù.
665        */
666       
667#if SUPPORT_POD
668        if (App_Op_IsOobMode())
669        {
670                scteSiSttSection_t flat_si_stt;
671                STATUS err;
672                UINT32 age;
673
674                err = Dmc_ScteSiGetEstimatedSttSection(&flat_si_stt, &age);
675               
676                /* age°¡ ³Ê¹« Ŭ °æ¿ì´Â ¸ø¹ÞÀº °æ¿ì¶ó°í °£ÁÖÇÏ´Â°Ô ³ªÀ» ¼ö ÀÖÀ½.. */
677               
678                if (err == statusOK) {
679                        AdjustTimeWithSiStt(&flat_si_stt);
680                }
681                else {
682                        dprint(1, "[SetTimeBySTT] in oob mode err %d\n", err);
683                }
684
685                AdjustTimeWithSiStt(&flat_si_stt);
686        }
687        else
688#endif // #if SUPPORT_POD
689
690        sttSection_t flat_stt;
691        DST_CURCHANNEL ChannelInfo;
692        int rf;
693        UINT32 age;
694
695        App_Ucm_GetCurChInfo(&ChannelInfo);
696        rf = ChannelInfo.nRF;   /* ÇöÀç ä³Î */
697       
698        err = Dmc_EpgGetEstimatedSttSection(rf, &flat_stt, &age);
699       
700        /* age°¡ ³Ê¹« Ŭ °æ¿ì´Â ¸ø¹ÞÀº °æ¿ì¶ó°í °£ÁÖÇÏ´Â°Ô ³ªÀ» ¼ö ÀÖÀ½.. */
701       
702        if (err == statusOK) {
703                AdjustTimeWithSTT(&flat_stt);
704        }
705        else {
706                dprint(1, "[SetTimeBySTT] rf %d, err %d\n", rf, err);
707        }
708       
709        return err;
710}
711
712/******************************************************************************************
713FUNCTION:
714  - App_SetTimeBySTT2
715
716Purpose:
717  - ¼öµ¿À¸·Î rf¸¦ ÁöÁ¤ÇÏ¿© STT¸¦ ¼ö½ÅÇÏ¿© TimeSync¸¦ ¼öÇàÇÏ´Â ÇÔ¼ö.
718  - µÎ°³ÀÇ ½Ã°è Áß¿¡ AutoSync context¿¡¸¸ Àû¿ëÀÌ µÈ´Ù. Áï »ç¿ëÀÚ manual ½Ã°è´Â
719  À̰Ϳ¡ ¿µÇâÀ» ¹ÞÁö ¾Ê´Â´Ù.
720******************************************************************************************/
721int App_SetTimeBySTT2(int rf)
722{
723        int err;
724        /*
725                cafrii 050528 add
726                New EPG ±â´ÉÀ» ÀÌ¿ëÇÑ »õ·Î¿î ¹æ¹ý.
727                ÀÌ ÇÔ¼ö´Â ½Ã°èÀÇ Á¤È®ÇÑ µ¿±â¸¦ À§ÇØ ÁÖ±âÀûÀ¸·Î È£ÃâÇØÁÖ¸é ÁÁ´Ù.
728                ±×¸®°í Epg MW¿¡¼­ Stt Jump À̺¥Æ®°¡ ¿À¸é ¶Ç ´Ù½Ã È£ÃâÇØ Áà¾ß ÇÑ´Ù.
729        */
730       
731#if SUPPORT_POD
732        if (App_Op_IsOobMode())
733        {
734                scteSiSttSection_t flat_si_stt;
735                STATUS err;
736                UINT32 age;
737
738                err = Dmc_ScteSiGetEstimatedSttSection(&flat_si_stt, &age);
739               
740                /* age°¡ ³Ê¹« Ŭ °æ¿ì´Â ¸ø¹ÞÀº °æ¿ì¶ó°í °£ÁÖÇÏ´Â°Ô ³ªÀ» ¼ö ÀÖÀ½.. */
741               
742                if (err == statusOK) {
743                        AdjustTimeWithSiStt(&flat_si_stt);
744                }
745                else {
746                        dprint(1, "[SetTimeBySTT] in oob mode err %d\n", err);
747                }
748
749                AdjustTimeWithSiStt(&flat_si_stt);
750        }
751        else
752#endif // #if SUPPORT_POD
753        {
754                sttSection_t flat_stt;
755                UINT32 age;
756
757                err = Dmc_EpgGetEstimatedSttSection(rf, &flat_stt, &age);
758               
759                /* age°¡ ³Ê¹« Ŭ °æ¿ì´Â ¸ø¹ÞÀº °æ¿ì¶ó°í °£ÁÖÇÏ´Â°Ô ³ªÀ» ¼ö ÀÖÀ½.. */
760               
761                if (err == statusOK) {
762                        AdjustTimeWithSTT(&flat_stt);
763                }
764                else {
765                        dprint(1, "[SetTimeBySTT] rf %d, err %d\n", rf, err);
766                }
767        }
768        return err;
769}
770
771
772int App_SetTimebySTTAtSetupWizard()
773{
774        STATUS status = statusOK;
775               
776        sttSectionPtr_t stt=NULL;
777        tDHL_TSD *tsd = DHL_DMX_GetTsd();
778       
779        status = Dmc_GetSttSection(tsd, &stt, 1200, NULL);
780       
781        dprint(0, "[App_SetTimebySTTAtSetupWizard] status %d\n", status);
782       
783        if(status==statusOK && stt) {
784               
785                // GPS/UTC º¯È¯ÀÇ ±âº»ÀÌ µÇ´Â ÀÌ °ªÀ» stt·ÎºÎÅÍ °¡Á®¿Â´Ù.       
786                DMW_SetGPS_UTC_offset(&g_stcAutoSync, stt->GPS_UTC_offset);
787               
788                // ÀÚµ¿ DST sync ¸ðµå¶ó¸é STTÀÇ °ü·Ã ÇÊµå °ªÀ» ÀÌ¿ëÇØ Àû¿ëÇÑ´Ù.
789                // ¼öµ¿ DST ¸ðµå¶ó¸é º°µµÀÇ API¸¦ »ç¿ëÇÏ¿© º¯°æÇϱâ Àü±îÁö´Â ±×´ë·Î À¯ÁöµÈ´Ù.
790                //
791                if (stt->daylight_savings.DS_status == 1)
792                        DMW_SetDayLightSaving(&g_stcAutoSync, TRUE);
793                else
794                        DMW_SetDayLightSaving(&g_stcAutoSync, FALSE);
795
796                // STT¸¦ ÀÌ¿ëÇÏ¿© ÇöÀç ½Ã°£À» Àû¿ëÇÑ´Ù.
797                DMW_SetUTCTime(&g_stcAutoSync,
798                        DMW_ConvertGPS2UTC(&g_stcAutoSync, stt->system_time));
799        }
800       
801        return status;
802}
803
804/******************************************************************************************
805FUNCTION:
806  - App_DeferredSyncSTT
807
808Purpose:
809  - STT Sync¸¦ ŸÀ̸ӿ¡ µî·Ï½ÃÄÑ ´ë±â½ÃŲ´Ù. ŸÀÌ¸Ó task priority°¡ ³·À¸¹Ç·Î
810  ´Ù¸¥ ÀÛ¾÷ÀÌ ¾øÀ» °æ¿ì STT Sync°¡ ÀÌ·ç¾îÁú °ÍÀÓ.
811******************************************************************************************/
812void App_DeferredSyncSTT()
813{
814        DMW_SYS_SetTimer (DST_STTSYNC_TIMER_ID, 30*1000 /* 5*60*1000 */
815                                ,(DMW_TIMER_PROC)App_SetTimeBySTT, 0, 0);
816}
817
818void App_CancelSyncSTT()
819{
820        DMW_SYS_KillTimer(DST_STTSYNC_TIMER_ID);
821}
822
823
824/******************************************************************************************
825FUNCTION:
826  - App_PrintCurrentTime
827
828Purpose:
829  - system¿¡¼­ »ç¿ëÇÏ´Â ¸ðµç ½Ã°£À» Ãâ·Â.
830
831        daylight saving °ü·ÃÇÏ¿© ¾à°£ÀÇ º¯°æ »çÇ×.
832                daylight savingÀ» ¸Þ´º ¼³Á¤¿¡¼­ off ÇÑ´Ù¸é ¾Æ¹« Ç¥½Ã ÇÏÁö ¾ÊÀ½.
833                daylight savingÀ» ÁؼöÇÑ´Ù¸é ÇöÀçÀÇ ds µ¿ÀÛ »óŸ¦ Ç¥½Ã.
834                manual time ¿¡¼­´Â daylight saving ÀÚüÀÇ °³³äÀÌ ¾øÀ½. »ç¿ëÀÚ°¡ Á÷Á¢ ½Ã°£ ¼³Á¤.
835******************************************************************************************/
836void App_PrintCurrentTime(int level)
837{
838        STime_t s;
839        UINT32 utc;
840        int err;
841
842        /* dprint(1, "Currently %s time mode\n", App_IsManualTimeMode() ? "Manual" : "Auto"); */
843       
844        err = DMW_GetLocalTime(&g_stcAutoSync, &s);
845        DMW_GetUTCTime(&g_stcAutoSync, &utc);
846
847        dprint(level, "%cAuto: %s %d/%d/%d %s %d:%02d:%02d [tz %+d] %s UTC 0x%x\n", 
848                        App_IsManualTimeContext() ? ' ' : '+',
849                        err ? "!!" : "", 
850                        s.year, s.month, s.day, DayOfWeakString(s.wday), s.hour, s.min, s.sec, 
851                        DMW_GetLocalTimeZone(&g_stcAutoSync), 
852                        !DMW_GetDayLightSaving(&g_stcAutoSync) ? "" : /* dst Áؼö ¾ÈÇϸé Á¤º¸ Ç¥½Ã ºÒÇÊ¿ä */
853                        DMW_CheckDayLightSavingActive(&g_stcAutoSync) ? "DS on" : "DS off",
854                        utc);
855
856#if SUPPORT_MANUAL_TIMER
857        if (App_IsManualTimeContext())  /* cafrii 050611 add, ¸Å´º¾ó ½Ã°è´Â manual ¸ðµå¿¡¼­¸¸ º¸¿©ÁÜ */
858        {
859                err = DMW_GetLocalTime(&g_stcManual, &s);
860                DMW_GetUTCTime(&g_stcManual, &utc);
861       
862                dprint(level, "%cMan.: %s %d/%d/%d %s %d:%02d:%02d [tz %+d] UTC 0x%x\n", 
863                                App_IsManualTimeContext() ? '+' : ' ',
864                                err ? "!!" : "", 
865                                s.year, s.month, s.day, DayOfWeakString(s.wday), s.hour, s.min, s.sec, 
866                                DMW_GetLocalTimeZone(&g_stcManual), 
867                                utc);
868        }
869#endif  /* #if SUPPORT_MANUAL_TIMER */
870}
871
872
873
874
875
876#if COMMENT
877____Init____(){}
878#endif
879
880/******************************************************************************************
881FUNCTION:
882  - App_TimeInit
883
884Purpose:
885  - ŸÀÓ ¸ðµâ °ü·Ã ±â´ÉÀ» ÃʱâÈ­ ÇÑ´Ù.
886  - ŸÀÌ¸Ó Å½ºÅ©¸¦ ÃʱâÈ­ ÇÑ´Ù.
887  - ½Ã°¢ Á¤º¸°¡ ¾Æ´Ï¶ó Áֱ⠟ÀÌ¸Ó ¼­ºñ½º¸¦ Á¦°øÇϴ ŽºÅ©ÀÌ´Ù.
888  - ºÎÆÃ °úÁ¤ Áß¿¡ ²À ÃʱâÈ­¸¦ ÇØ Áà¾ß ÀÌÈÄ¿¡ SetTimer µîÀÇ ¼­ºñ¸¦ »ç¿ëÇÒ ¼ö ÀÖ´Ù.
889******************************************************************************************/
890void App_TimeInit(void)
891{
892        /* timer is essential for eeprom. so we init dmw timer very early stage in app_main. */
893        /* DMW_SYS_TimerInit(); */
894       
895        App_NVM_LoadModuleParam(eAPP_NVR_TIME, &p_time_nvm_param);
896       
897        App_SetTimeZone(p_time_nvm_param.timeZone, FALSE);
898
899        /* cafrii 081121, °ªÀº nvram ¸ðµâ¿¡¼­ Àаí, ¼³Á¤Àº ¿©±â¼­.. */
900        App_SetDayLightSaving(p_time_nvm_param.bDayLightSaving, FALSE); 
901
902        return;
903}
904
905
906
907void App_TimeParamInit(void)
908{
909        App_NVM_RegisterModule(eAPP_NVR_TIME, sizeof(p_time_nvm_param), p_format_time_param);
910}
911
912
913
914#endif /* SUPPORT_TIME */
915
916
917/* end of file */
Note: See TracBrowser for help on using the repository browser.