DVBCore  1.0
Open source DVB engine
midware/stb/inc/stbgc.h
Go to the documentation of this file.
00001 /*******************************************************************************
00002  * Copyright © 2014 The DTVKit Open Software Foundation Ltd (www.dtvkit.org)
00003  * Copyright © 2004 Ocean Blue Software Ltd
00004  *
00005  * This file is part of a DTVKit Software Component
00006  * You are permitted to copy, modify or distribute this file subject to the terms
00007  * of the DTVKit 1.0 Licence which can be found in licence.txt or at www.dtvkit.org
00008  * 
00009  * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
00010  * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
00011  * OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
00012  * 
00013  * If you or your organisation is not a member of DTVKit then you have access
00014  * to this source code outside of the terms of the licence agreement
00015  * and you are expected to delete this and any associated files immediately.
00016  * Further information on DTVKit, membership and terms can be found at www.dtvkit.org
00017  *******************************************************************************/
00024 #ifndef _STBGC_H
00025 
00026 #define _STBGC_H
00027 
00028 //---Constant and macro definitions for public use-----------------------------
00029 
00030 /* Macros for DHMS formatted date/time - a 32 bit value where components of time
00031  * are held and extracted with bit-shifting. */
00032 #define D_DSHFT                     17
00033 #define D_HSHFT                     12
00034 #define D_MSHFT                     6
00035 
00036 /* DHMS Creation macros */
00037 #if defined(DEBUG_ASSERT) || defined(DEBUG_ASSERT_STANDARD)
00038  #define DHMS_CREATE(dt, hr, mn, sc)   STB_GCCreateDebugDHMS(dt, hr, mn, sc)
00039 #else
00040  #define DHMS_CREATE(dy, hr, mn, sc)   ((U32DHMS)dy << D_DSHFT | (U32DHMS)hr << D_HSHFT | (U32DHMS)mn << D_MSHFT | (sc))
00041 #endif
00042 
00043 /* DHMS extraction macros */
00044 #define DHMS_DAYS(dhms)              (dhms >> D_DSHFT)
00045 #define DHMS_DATE32(dhms)           ((dhms >> D_DSHFT) | 0x8000)
00046 #define DHMS_HOUR32(dhms)           ((dhms >> D_HSHFT) & 0x1f)
00047 #define DHMS_MINS32(dhms)           ((dhms >> D_MSHFT) & 0x3f)
00048 #define DHMS_SECS32(dhms)           (dhms & 0x3f)
00049 #define DHMS_DATE(dhms)             (U16BIT)DHMS_DATE32(dhms)
00050 #define DHMS_HOUR(dhms)             (U8BIT) DHMS_HOUR32(dhms)
00051 #define DHMS_MINS(dhms)             (U8BIT) DHMS_MINS32(dhms)
00052 #define DHMS_SECS(dhms)             (U8BIT) DHMS_SECS32(dhms)
00053 
00054 //---Enumerations for public use-----------------------------------------------
00055 
00056 typedef enum
00057 {
00058    WEEKDAY_MONDAY = 1,
00059    WEEKDAY_TUESDAY = 2,
00060    WEEKDAY_WEDNESDAY = 3,
00061    WEEKDAY_THURSDAY = 4,
00062    WEEKDAY_FRIDAY = 5,
00063    WEEKDAY_SATURDAY = 6,
00064    WEEKDAY_SUNDAY = 7
00065 } E_STB_GC_WEEKDAY;
00066 
00067 typedef enum
00068 {
00069    CALC_ADD = 0,
00070    CALC_SUB = 1
00071 } E_STB_GC_CALCTYPE;
00072 
00073 typedef enum
00074 {
00075    CONV_LOCAL = 0,
00076    CONV_GMT = 1
00077 } E_STB_GC_CONVTYPE;
00078 
00079 /* CQ99999:PRM:06/02/28 - CHANGED COMP_EQUAL to COMP_MATCH multiple Definition */
00080 typedef enum
00081 {
00082    COMP_MATCH = 0,
00083    COMP_1GT2 = 1,
00084    COMP_1GE2 = 2,
00085    COMP_1LT2 = 3,
00086    COMP_1LE2 = 4,
00087    COMP_2GT1 = 5,
00088    COMP_2GE1 = 6,
00089    COMP_2LT1 = 7,
00090    COMP_2LE1 = 8
00091 } E_STB_GC_COMPTYPE;
00092 
00093 typedef enum
00094 {
00095    TIME_12H = 0,
00096    TIME_24H = 1
00097 } E_STB_GC_TIMETYPE;
00098 
00099 typedef enum
00100 {
00101    DATE_DMY = 0,
00102    DATE_YMD = 1
00103 } E_STB_GC_DATETYPE;
00104 
00105 typedef enum
00106 {
00107    CLOCK_HMS = 0,
00108    CLOCK_SMH = 1,
00109    CLOCK_HM = 2,
00110    CLOCK_MH = 3
00111 } E_STB_GC_CLOCKTYPE;
00112 
00113 //---Global type defs for public use-------------------------------------------
00114 
00115 typedef U32BIT U32DHMS;
00116 
00117 //---Global Function prototypes for public use---------------------------------
00118 
00119 void STB_GCInitialise(void);
00120 
00121 void STB_GCSetSearchLangCode(U32BIT lang);
00122 U32BIT STB_GCGetSearchLangCode(void);
00123 U8BIT* STB_GCGetLangCodeString(U32BIT lang);
00124 
00125 void STB_GCSetCIStandby(BOOLEAN standby);
00126 
00127 U8BIT* STB_GCGetFullSerialString(void);
00128 U8BIT* STB_GCGetVersionNumberString(void);
00129 
00130 void STB_GCSetAudioSignal(BOOLEAN state);
00131 BOOLEAN STB_GCGetAudioSignal(void);
00132 
00133 void STB_GCSetLocalTimeOffset(U8BIT ohour, U8BIT omin, BOOLEAN neg);
00134 void STB_GCGetLocalTimeOffset(U8BIT *ohour, U8BIT *omin, BOOLEAN *neg);
00135 void STB_GCSetLocalTimeChange(U16BIT code, U8BIT hour, U8BIT min, U8BIT secs,
00136    U8BIT ohour1, U8BIT omin1, U8BIT ohour2, U8BIT omin2, BOOLEAN neg);
00137 void STB_GCGetLocalTimeChange(U16BIT code, U8BIT hour, U8BIT min, U8BIT secs,
00138    U8BIT *ohour, U8BIT *omin, BOOLEAN *neg);
00139 
00140 void STB_GCSetGMTTime(U8BIT hour, U8BIT min, U8BIT secs);
00141 U8BIT STB_GCGetGMTHour(void);
00142 U8BIT STB_GCGetGMTMin(void);
00143 U8BIT STB_GCGetGMTSecs(void);
00144 
00145 void STB_GCSetGMTDate(U16BIT code);
00146 U16BIT STB_GCGetGMTDate(void);
00147 E_STB_GC_WEEKDAY STB_GCGetGMTWeekDay(void);
00148 U8BIT STB_GCGetGMTDay(void);
00149 U8BIT STB_GCGetGMTMonth(void);
00150 U16BIT STB_GCGetGMTYear(void);
00151 
00152 void STB_GCGetGMTDateTime(U16BIT *code, U8BIT *hour, U8BIT *min, U8BIT *secs);
00153 BOOLEAN STB_GCIsFutureDateTime(U16BIT code, U8BIT hour, U8BIT min, U8BIT secs);
00154 
00155 E_STB_GC_WEEKDAY STB_GCGetDateWeekDay(U16BIT code);
00156 BOOLEAN STB_GCIsDateDayWeek(U16BIT code);
00157 BOOLEAN STB_GCIsDateDayWeekend(U16BIT code);
00158 
00159 void STB_GCCalculateDateTime(U16BIT code, U8BIT hour, U8BIT min, U8BIT secs,
00160    U8BIT ohour, U8BIT omin, U8BIT osecs,
00161    U16BIT *rcode, U8BIT *rhour, U8BIT *rmin, U8BIT *rsecs,
00162    E_STB_GC_CALCTYPE calc);
00163 void STB_GCConvertDateTime(U16BIT code, U8BIT hour, U8BIT min, U8BIT secs,
00164    U16BIT *rcode, U8BIT *rhour, U8BIT *rmin, U8BIT *rsecs,
00165    E_STB_GC_CONVTYPE conv);
00166 BOOLEAN STB_GCCompareDateTime(U16BIT code1, U8BIT hour1, U8BIT min1, U8BIT secs1,
00167    U16BIT code2, U8BIT hour2, U8BIT min2, U8BIT secs2,
00168    E_STB_GC_COMPTYPE comp);
00169 S32BIT STB_GCDateTimeDiff(U16BIT code1, U8BIT hour1, U8BIT min1, U8BIT secs1,
00170    U16BIT code2, U8BIT hour2, U8BIT min2, U8BIT secs2);
00171 
00172 U8BIT* STB_GCGetTimeString(U16BIT code, U8BIT hour, U8BIT min, E_STB_GC_TIMETYPE format);
00173 U8BIT* STB_GCGetDateString(U16BIT code, U8BIT hour, U8BIT min, E_STB_GC_DATETYPE format);
00174 U8BIT* STB_GCGetClockString(U8BIT hour, U8BIT min, U8BIT secs, E_STB_GC_CLOCKTYPE format);
00175 
00176 void STB_GCGetDateInfo(U16BIT code, U8BIT hour, U8BIT min, U8BIT *day, U8BIT *wday,
00177    U8BIT *month, U16BIT *year);
00178 
00179 void STB_GCGetMJDDateInfo(U16BIT code, U8BIT *day, U8BIT *wday, U8BIT *month, U16BIT *year);
00180 
00181 void STB_GCGetLocalDateTime(U16BIT *year, U8BIT *month, U8BIT *day, U8BIT *hour, U8BIT *mins);
00182 
00183 /*!**************************************************************************
00184  * @brief   Sets whether the date/time are taken from the broadcast or the system.
00185  *          The default is to use the broadcast for date/time.
00186  * @param   state - FALSE to use date/time from the system
00187  ****************************************************************************/
00188 void STB_GCUseBroadcastTime(BOOLEAN state);
00189 
00190 /*
00191  * Functions that create/use DHMS formatted date/time
00192  * Note: 'Compare' functionality is simply done with standard integer compare operators
00193  */
00194 U32DHMS STB_GCCreateDebugDHMS( U32BIT date, U32BIT hour, U32BIT mins, U32BIT secs );
00195 U32DHMS STB_GCCreateDHMS( U16BIT date, U8BIT hour, U8BIT mins, U8BIT secs );
00196 
00206 U32DHMS STB_GCCalculateDHMS(U32DHMS dhms, U32DHMS period, E_STB_GC_CALCTYPE calc);
00207 
00216 U32DHMS STB_GCConvertDHMS(U32DHMS dhms, E_STB_GC_CONVTYPE conv);
00217 
00218 U32DHMS STB_GCNowDHMSGmt(void);
00219 U32DHMS STB_GCNowDHMSLocal(void);
00220 U8BIT* STB_GCGetDateStringDHMS(U32DHMS dhms, E_STB_GC_DATETYPE format);
00221 U8BIT* STB_GCGetTimeStringDHMS(U32DHMS dhms, E_STB_GC_TIMETYPE format);
00222 
00228 U32DHMS STB_GCConvertTimestamp(U32BIT timestamp);
00229 
00235 U32BIT STB_GCConvertToTimestamp(U32DHMS time);
00236 
00237 #endif //  _STBGC_H
00238 
 All Data Structures Files Functions Typedefs Defines