Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
timeclk.c
Package: ST_5105DTV.rar [view]
Upload User: fy98168
Upload Date: 2015-06-26
Package Size: 13771k
Code Size: 5k
Category:
DVD
Development Platform:
C/C++
- #include "timeclk.h"
- #include "sipsi.h"
- #include "osd.h"
- #include "avplay.h"
- #include "db.h"
- #include <string.h>
- #include "db.h"
- #include "osp.h"
- #include "dmd.h"
- #include "flash.h"
- #include "appltype.h"
- #include "timer.h"
- #define INVALID_OFFSET -13
- #define MAX_TMS 128
- typedef struct {
- UINT32 freq;
- UINT32 symbol;
- UINT8 qam;
- time_t tm;
- INT8 offset;
- BOOL tm_valid;
- BOOL offset_valid;
- BOOL used;
- } TM_OFFSET;
- static TM_OFFSET tm_offset[MAX_TMS];
- KB_SIBatStruct recBat;
- static KB_TimeVariables g_stTimeVars;
- static UINT32 current_freq;
- static UINT32 current_symbol;
- static UINT32 current_qam;
- static KB_TimeClkCallbackFunc gptTimeClkCallbackFunction = NULL;
- static void KD_AppTimer(void);
- int KB_TimeInit(void)
- {
- static UINT32 hClockTimer;
- current_freq = 0;
- current_symbol = 0;
- current_qam = 0;
- memset(tm_offset, 0, sizeof(tm_offset));
- g_stTimeVars.cTimeMsgEnable = 0;
- g_stTimeVars.cTimeValidity = 0;
- g_stTimeVars.dwCurrentTime = 0;
- g_stTimeVars.offset = INVALID_OFFSET;
- hClockTimer = KB_TimerCreate(KB_TIMER_REPEAT, (KB_TIMER_FUNC_POINTER)KD_AppTimer,NULL);
- KB_TimerEnable(hClockTimer, 1000);
- return KB_DB_DTV_SUCCESS;
- }
- void KB_TimeSetCurTime(time_t lTime)
- {
- if(g_stTimeVars.offset == INVALID_OFFSET)
- {
- g_stTimeVars.dwCurrentTime = lTime;
- }
- g_stTimeVars.cTimeValidity = 1;
- }
- void KB_TimeSetCurOffSet(INT8 offset)
- {
- if(g_stTimeVars.offset == INVALID_OFFSET)
- {
- g_stTimeVars.offset = offset;
- }
- }
- INT8 KB_TimeGetCurOffSet(void)
- {
- return g_stTimeVars.offset ;
- }
- time_t KB_TimeGetCurGMTTime(void)
- {
- return g_stTimeVars.dwCurrentTime;
- }
- int KB_TimeGetCurTime(time_t *plTime)
- {
- //printf("KB_TimeGetCurTime:g_stTimeVars.offset = %d",g_stTimeVars.offset);
- if (g_stTimeVars.cTimeValidity == 0)
- {
- return KB_DB_DTV_FAILURE;
- }
- if(g_stTimeVars.offset != INVALID_OFFSET)
- {
- *plTime = g_stTimeVars.dwCurrentTime + g_stTimeVars.offset * 3600;
- }
- else
- {
- unsigned char res;
- signed char zone;
- res = KB_DBGetZone(&zone);
- //printf("KB_TimeGetCurTime:g_stTimeVars.zone = %d",zone);
- if (res == KB_DB_DTV_SUCCESS)
- {
- *plTime = (time_t)(g_stTimeVars.dwCurrentTime + zone * 3600);
- }
- else
- {
- *plTime = g_stTimeVars.dwCurrentTime;
- //Print("[TIMECLK.C KB_TimeGetCurTime] Get time zone error.n");
- }
- }
- return KB_DB_DTV_SUCCESS;
- }
- //*****************************************************************************
- //名称:Time_2_Local_Tiem
- //
- //功能:将系统中的时间转换成当地时间
- //
- //输入:当前的格林威治时间
- //
- //返回:返回的时间是当前时区的当地时间
- //
- //*****************************************************************************
- time_t Time_2_Local_Tiem(time_t timeStamp)
- {
- //首先要根据系统设置页面中的设置来获得时区
- //这里假设时区是8,如果有更改的话,请重新获得
- INT8 offset = INVALID_OFFSET;
- KB_DBGetZone(&offset);
- if (offset != INVALID_OFFSET)
- {
- timeStamp = (time_t)(timeStamp + offset * 3600);
- }
- return timeStamp;
- }
- time_t KB_TimeGMTTime(time_t tt)
- {
- if (tt != 0)
- {
- INT8 offset;
- offset = KB_TimeGetCurOffSet();
- if (offset == INVALID_OFFSET)
- {
- if (KB_DBGetZone(&offset) != KB_DB_DTV_SUCCESS)
- {
- offset = 0;
- Print("[TIMECLK.C KB_TimeGMTTime] Get time zone error.n");
- }
- }
- tt += (time_t)(offset * 3600);
- }
- return tt;
- }
- void KB_TimeEnableTimer(void)
- {
- g_stTimeVars.cTimeMsgEnable = 1;
- }
- void KB_TimeDisableTimer(void)
- {
- g_stTimeVars.cTimeMsgEnable = 0;
- }
- static void KD_AppTimer(void)
- {
- KB_OSPMsgNode timeMsg;
- int i;
- int ret;
- g_stTimeVars.dwCurrentTime ++;
- for(i=0; i<MAX_TMS; i++)
- {
- if(tm_offset[i].used && tm_offset[i].tm_valid)
- {
- tm_offset[i].tm++;
- }
- }
- if(g_stTimeVars.cTimeMsgEnable == 1)
- {
- timeMsg.Word1 = J_TIME_MODULE;
- if (gptTimeClkCallbackFunction != NULL)
- {
- gptTimeClkCallbackFunction(&timeMsg);
- }
- }
- }
- BOOL KB_TimeSetPrgOffset(INT8 offset, UINT32 freq, UINT32 symbol, UINT8 qam)
- {
- int i;
- int index = -1;
- for(i=0; i<MAX_TMS; i++)
- {
- if( (tm_offset[i].used) &&
- (tm_offset[i].freq == freq) &&
- (tm_offset[i].symbol == symbol) &&
- (tm_offset[i].qam == qam))
- {
- tm_offset[i].offset_valid = TRUE;
- tm_offset[i].offset = offset;
- return TRUE;
- }
- if((!tm_offset[i].used) && (index == -1))
- {
- index = i;
- }
- }
- if(index == -1)
- {
- KB_TimeResetPrgTimes();
- index = 0;
- }
- tm_offset[index].used = TRUE;
- tm_offset[index].freq = freq;
- tm_offset[index].symbol = symbol;
- tm_offset[index].qam = qam;
- tm_offset[index].offset = offset;
- tm_offset[index].offset_valid = FALSE;
- return TRUE;
- }
- void KB_TimeResetPrgTimes(void)
- {
- memset(tm_offset, 0, sizeof(tm_offset));
- g_stTimeVars.cTimeMsgEnable = 0;
- g_stTimeVars.cTimeValidity = 0;
- g_stTimeVars.dwCurrentTime = 0;
- g_stTimeVars.offset = INVALID_OFFSET;
- current_freq = 0;
- current_symbol = 0;
- current_qam = 0;
- }
- KB_TimeClkCallbackFunc KB_TimerCallBack(KB_TimeClkCallbackFunc callback)
- {
- KB_TimeClkCallbackFunc ptPrvCallback;
- ptPrvCallback = gptTimeClkCallbackFunction;
- gptTimeClkCallbackFunction = callback;
- return ptPrvCallback;
- }