DVBCore  17.9.0
Open Source DVB Engine
 All Data Structures Files Functions Typedefs Macros Pages
stbgc.h
Go to the documentation of this file.
1 /*******************************************************************************
2  * Copyright © 2014 The DTVKit Open Software Foundation Ltd (www.dtvkit.org)
3  * Copyright © 2004 Ocean Blue Software Ltd
4  *
5  * This file is part of a DTVKit Software Component
6  * You are permitted to copy, modify or distribute this file subject to the terms
7  * of the DTVKit 1.0 Licence which can be found in licence.txt or at www.dtvkit.org
8  *
9  * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
10  * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
11  * OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
12  *
13  * If you or your organisation is not a member of DTVKit then you have access
14  * to this source code outside of the terms of the licence agreement
15  * and you are expected to delete this and any associated files immediately.
16  * Further information on DTVKit, membership and terms can be found at www.dtvkit.org
17  *******************************************************************************/
24 #ifndef _STBGC_H
25 
26 #define _STBGC_H
27 
28 #include "techtype.h"
29 
30 //---Constant and macro definitions for public use-----------------------------
31 
32 /* Macros for DHMS formatted date/time - a 32 bit value where components of time
33  * are held and extracted with bit-shifting. */
34 #define D_DSHFT 17
35 #define D_HSHFT 12
36 #define D_MSHFT 6
37 
38 /* DHMS Creation macros */
39 #if defined(DEBUG_ASSERT) || defined(DEBUG_ASSERT_STANDARD)
40  #define DHMS_CREATE(dt, hr, mn, sc) STB_GCCreateDebugDHMS(dt, hr, mn, sc)
41 #else
42  #define DHMS_CREATE(dy, hr, mn, sc) ((U32DHMS)dy << D_DSHFT | (U32DHMS)hr << D_HSHFT | (U32DHMS)mn << D_MSHFT | (sc))
43 #endif
44 
45 /* DHMS extraction macros */
46 #define DHMS_DAYS(dhms) (dhms >> D_DSHFT)
47 #define DHMS_DATE32(dhms) ((dhms >> D_DSHFT) | 0x8000)
48 #define DHMS_HOUR32(dhms) ((dhms >> D_HSHFT) & 0x1f)
49 #define DHMS_MINS32(dhms) ((dhms >> D_MSHFT) & 0x3f)
50 #define DHMS_SECS32(dhms) (dhms & 0x3f)
51 #define DHMS_DATE(dhms) (U16BIT)DHMS_DATE32(dhms)
52 #define DHMS_HOUR(dhms) (U8BIT) DHMS_HOUR32(dhms)
53 #define DHMS_MINS(dhms) (U8BIT) DHMS_MINS32(dhms)
54 #define DHMS_SECS(dhms) (U8BIT) DHMS_SECS32(dhms)
55 
56 //---Enumerations for public use-----------------------------------------------
57 
58 typedef enum
59 {
60  WEEKDAY_MONDAY = 1,
61  WEEKDAY_TUESDAY = 2,
62  WEEKDAY_WEDNESDAY = 3,
63  WEEKDAY_THURSDAY = 4,
64  WEEKDAY_FRIDAY = 5,
65  WEEKDAY_SATURDAY = 6,
66  WEEKDAY_SUNDAY = 7
67 } E_STB_GC_WEEKDAY;
68 
69 typedef enum
70 {
71  CALC_ADD = 0,
72  CALC_SUB = 1
73 } E_STB_GC_CALCTYPE;
74 
75 typedef enum
76 {
77  CONV_LOCAL = 0,
78  CONV_GMT = 1
79 } E_STB_GC_CONVTYPE;
80 
81 /* CQ99999:PRM:06/02/28 - CHANGED COMP_EQUAL to COMP_MATCH multiple Definition */
82 typedef enum
83 {
84  COMP_MATCH = 0,
85  COMP_1GT2 = 1,
86  COMP_1GE2 = 2,
87  COMP_1LT2 = 3,
88  COMP_1LE2 = 4,
89  COMP_2GT1 = 5,
90  COMP_2GE1 = 6,
91  COMP_2LT1 = 7,
92  COMP_2LE1 = 8
93 } E_STB_GC_COMPTYPE;
94 
95 typedef enum
96 {
97  TIME_12H = 0,
98  TIME_24H = 1
99 } E_STB_GC_TIMETYPE;
100 
101 typedef enum
102 {
103  DATE_DMY = 0,
104  DATE_YMD = 1
105 } E_STB_GC_DATETYPE;
106 
107 typedef enum
108 {
109  CLOCK_HMS = 0,
110  CLOCK_SMH = 1,
111  CLOCK_HM = 2,
112  CLOCK_MH = 3
113 } E_STB_GC_CLOCKTYPE;
114 
115 //---Global type defs for public use-------------------------------------------
116 
117 typedef U32BIT U32DHMS;
118 
119 //---Global Function prototypes for public use---------------------------------
120 
121 void STB_GCInitialise(void);
122 
123 void STB_GCSetSearchLangCode(U32BIT lang);
124 U32BIT STB_GCGetSearchLangCode(void);
125 U8BIT* STB_GCGetLangCodeString(U32BIT lang);
126 
127 void STB_GCSetCIStandby(BOOLEAN standby);
128 
129 U8BIT* STB_GCGetFullSerialString(void);
130 U8BIT* STB_GCGetVersionNumberString(void);
131 
132 void STB_GCSetAudioSignal(BOOLEAN state);
133 BOOLEAN STB_GCGetAudioSignal(void);
134 
135 void STB_GCSetLocalTimeOffset(U8BIT ohour, U8BIT omin, BOOLEAN neg);
136 void STB_GCGetLocalTimeOffset(U8BIT *ohour, U8BIT *omin, BOOLEAN *neg);
137 void STB_GCSetLocalTimeChange(U16BIT code, U8BIT hour, U8BIT min, U8BIT secs,
138  U8BIT ohour1, U8BIT omin1, U8BIT ohour2, U8BIT omin2, BOOLEAN neg);
139 void STB_GCGetLocalTimeChange(U16BIT code, U8BIT hour, U8BIT min, U8BIT secs,
140  U8BIT *ohour, U8BIT *omin, BOOLEAN *neg);
141 
142 void STB_GCSetGMTTime(U8BIT hour, U8BIT min, U8BIT secs);
143 U8BIT STB_GCGetGMTHour(void);
144 U8BIT STB_GCGetGMTMin(void);
145 U8BIT STB_GCGetGMTSecs(void);
146 
147 void STB_GCSetGMTDate(U16BIT code);
148 U16BIT STB_GCGetGMTDate(void);
149 E_STB_GC_WEEKDAY STB_GCGetGMTWeekDay(void);
150 U8BIT STB_GCGetGMTDay(void);
151 U8BIT STB_GCGetGMTMonth(void);
152 U16BIT STB_GCGetGMTYear(void);
153 
154 void STB_GCGetGMTDateTime(U16BIT *code, U8BIT *hour, U8BIT *min, U8BIT *secs);
155 BOOLEAN STB_GCIsFutureDateTime(U16BIT code, U8BIT hour, U8BIT min, U8BIT secs);
156 
157 E_STB_GC_WEEKDAY STB_GCGetDateWeekDay(U16BIT code);
158 BOOLEAN STB_GCIsDateDayWeek(U16BIT code);
159 BOOLEAN STB_GCIsDateDayWeekend(U16BIT code);
160 
161 void STB_GCCalculateDateTime(U16BIT code, U8BIT hour, U8BIT min, U8BIT secs,
162  U8BIT ohour, U8BIT omin, U8BIT osecs,
163  U16BIT *rcode, U8BIT *rhour, U8BIT *rmin, U8BIT *rsecs,
164  E_STB_GC_CALCTYPE calc);
165 void STB_GCConvertDateTime(U16BIT code, U8BIT hour, U8BIT min, U8BIT secs,
166  U16BIT *rcode, U8BIT *rhour, U8BIT *rmin, U8BIT *rsecs,
167  E_STB_GC_CONVTYPE conv);
168 BOOLEAN STB_GCCompareDateTime(U16BIT code1, U8BIT hour1, U8BIT min1, U8BIT secs1,
169  U16BIT code2, U8BIT hour2, U8BIT min2, U8BIT secs2,
170  E_STB_GC_COMPTYPE comp);
171 S32BIT STB_GCDateTimeDiff(U16BIT code1, U8BIT hour1, U8BIT min1, U8BIT secs1,
172  U16BIT code2, U8BIT hour2, U8BIT min2, U8BIT secs2);
173 
174 U8BIT* STB_GCGetTimeString(U16BIT code, U8BIT hour, U8BIT min, E_STB_GC_TIMETYPE format);
175 U8BIT* STB_GCGetDateString(U16BIT code, U8BIT hour, U8BIT min, E_STB_GC_DATETYPE format);
176 U8BIT* STB_GCGetClockString(U8BIT hour, U8BIT min, U8BIT secs, E_STB_GC_CLOCKTYPE format);
177 
178 void STB_GCGetDateInfo(U16BIT code, U8BIT hour, U8BIT min, U8BIT *day, U8BIT *wday,
179  U8BIT *month, U16BIT *year);
180 
181 void STB_GCGetMJDDateInfo(U16BIT code, U8BIT *day, U8BIT *wday, U8BIT *month, U16BIT *year);
182 
183 void STB_GCGetLocalDateTime(U16BIT *year, U8BIT *month, U8BIT *day, U8BIT *hour, U8BIT *mins);
184 
185 /*!**************************************************************************
186  * @brief Sets whether the date/time are taken from the broadcast or the system.
187  * The default is to use the broadcast for date/time.
188  * @param state - FALSE to use date/time from the system
189  ****************************************************************************/
190 void STB_GCUseBroadcastTime(BOOLEAN state);
191 
192 /*
193  * Functions that create/use DHMS formatted date/time
194  * Note: 'Compare' functionality is simply done with standard integer compare operators
195  */
196 U32DHMS STB_GCCreateDebugDHMS( U32BIT date, U32BIT hour, U32BIT mins, U32BIT secs );
197 U32DHMS STB_GCCreateDHMS( U16BIT date, U8BIT hour, U8BIT mins, U8BIT secs );
198 
208 U32DHMS STB_GCCalculateDHMS(U32DHMS dhms, U32DHMS period, E_STB_GC_CALCTYPE calc);
209 
218 U32DHMS STB_GCConvertDHMS(U32DHMS dhms, E_STB_GC_CONVTYPE conv);
219 
220 U32DHMS STB_GCNowDHMSGmt(void);
221 U32DHMS STB_GCNowDHMSLocal(void);
222 U8BIT* STB_GCGetDateStringDHMS(U32DHMS dhms, E_STB_GC_DATETYPE format);
223 U8BIT* STB_GCGetTimeStringDHMS(U32DHMS dhms, E_STB_GC_TIMETYPE format);
224 
230 U32DHMS STB_GCConvertTimestamp(U32BIT timestamp);
231 
237 U32BIT STB_GCConvertToTimestamp(U32DHMS time);
238 
239 #endif // _STBGC_H
240 
BOOLEAN STB_GCIsDateDayWeek(U16BIT code)
Tests whether the weekday of the specified date code is during the week.
Definition: stbgc.c:1471
U32DHMS STB_GCConvertTimestamp(U32BIT timestamp)
Converts a timestamp expressed in number of seconds since midnight (UTC) 1 January 1970...
Definition: stbgc.c:2409
U32DHMS STB_GCCalculateDHMS(U32DHMS dhms, U32DHMS period, E_STB_GC_CALCTYPE calc)
Calculates the date/time when the period is added/subtracted to/from dhms.
Definition: stbgc.c:2113
U8BIT STB_GCGetGMTDay(void)
Reads the current GMT day number.
Definition: stbgc.c:1272
void STB_GCInitialise(void)
Initialises general control.
Definition: stbgc.c:582
U32DHMS STB_GCNowDHMSLocal(void)
Reads the current Local date code and time.
Definition: stbgc.c:2273
U8BIT STB_GCGetGMTMin(void)
Reads the current GMT minute.
Definition: stbgc.c:1111
void STB_GCSetGMTDate(U16BIT code)
Sets current GMT date.
Definition: stbgc.c:1173
U8BIT * STB_GCGetDateString(U16BIT code, U8BIT hour, U8BIT min, E_STB_GC_DATETYPE format)
Supplies specifed date as local date string, in format requested.
Definition: stbgc.c:1808
U8BIT * STB_GCGetLangCodeString(U32BIT lang)
Converts the given 24bit ISO language code to a null-terminated string.
Definition: stbgc.c:665
U32DHMS STB_GCNowDHMSGmt(void)
Reads the current GMT date code and time.
Definition: stbgc.c:2241
void STB_GCGetLocalTimeChange(U16BIT code, U8BIT hour, U8BIT min, U8BIT secs, U8BIT *ohour, U8BIT *omin, BOOLEAN *neg)
Reads local time offset from GMT.
Definition: stbgc.c:985
void STB_GCGetDateInfo(U16BIT code, U8BIT hour, U8BIT min, U8BIT *day, U8BIT *wday, U8BIT *month, U16BIT *year)
Get the day, weekday, month and the year from a date code and hour / minute offset.
Definition: stbgc.c:1866
void STB_GCSetLocalTimeChange(U16BIT code, U8BIT hour, U8BIT min, U8BIT secs, U8BIT ohour1, U8BIT omin1, U8BIT ohour2, U8BIT omin2, BOOLEAN neg)
Sets new and old local time offset from GMT.
Definition: stbgc.c:924
void STB_GCCalculateDateTime(U16BIT code, U8BIT hour, U8BIT min, U8BIT secs, U8BIT ohour, U8BIT omin, U8BIT osecs, U16BIT *rcode, U8BIT *rhour, U8BIT *rmin, U8BIT *rsecs, E_STB_GC_CALCTYPE calc)
Adds or subtracts offset from a date/time.
Definition: stbgc.c:1539
U8BIT * STB_GCGetFullSerialString(void)
Retrieves and returns the fulls serial string, incorporating the hardware version box serial number a...
Definition: stbgc.c:723
U32BIT STB_GCConvertToTimestamp(U32DHMS time)
Returns the number of seconds from midnight (UTC) 1 January 1970 to the specified U32DHMS time...
Definition: stbgc.c:2430
void STB_GCConvertDateTime(U16BIT code, U8BIT hour, U8BIT min, U8BIT secs, U16BIT *rcode, U8BIT *rhour, U8BIT *rmin, U8BIT *rsecs, E_STB_GC_CONVTYPE conv)
Converts specified date / time to another.
Definition: stbgc.c:1590
U32DHMS STB_GCCreateDHMS(U16BIT date, U8BIT hour, U8BIT mins, U8BIT secs)
Makes U32DHMS formated date/time from date code, hour, minutes, seconds.
Definition: stbgc.c:2079
U8BIT * STB_GCGetTimeStringDHMS(U32DHMS dhms, E_STB_GC_TIMETYPE format)
Supplies specified time as local time string, in format requested.
Definition: stbgc.c:2365
void STB_GCSetLocalTimeOffset(U8BIT ohour, U8BIT omin, BOOLEAN neg)
Sets local time offset from GMT.
Definition: stbgc.c:821
U32DHMS STB_GCConvertDHMS(U32DHMS dhms, E_STB_GC_CONVTYPE conv)
Converts the given date/time to local or GMT.
Definition: stbgc.c:2183
U8BIT * STB_GCGetVersionNumberString(void)
Retrieves and returns the library version number as a string.
Definition: stbgc.c:745
BOOLEAN STB_GCIsDateDayWeekend(U16BIT code)
Tests whether the weekday of the specified date code is during the weekend.
Definition: stbgc.c:1500
U8BIT * STB_GCGetClockString(U8BIT hour, U8BIT min, U8BIT secs, E_STB_GC_CLOCKTYPE format)
Supplies specified time as clock string, in format requested.
Definition: stbgc.c:1924
BOOLEAN STB_GCGetAudioSignal(void)
Reads the current audio signal bleep state from general control store.
Definition: stbgc.c:795
U8BIT STB_GCGetGMTMonth(void)
Reads the current GMT month number.
Definition: stbgc.c:1304
void STB_GCUseBroadcastTime(BOOLEAN state)
Sets whether the date/time are taken from the broadcast or the system. The default is to use the broa...
Definition: stbgc.c:2006
U16BIT STB_GCGetGMTYear(void)
Reads the current GMT year number.
Definition: stbgc.c:1336
void STB_GCSetAudioSignal(BOOLEAN state)
Enables/disables audio signal bleep and writes value into general control store.
Definition: stbgc.c:767
void STB_GCGetGMTDateTime(U16BIT *code, U8BIT *hour, U8BIT *min, U8BIT *secs)
Reads the current GMT date code and time.
Definition: stbgc.c:1371
void STB_GCGetLocalDateTime(U16BIT *year, U8BIT *month, U8BIT *day, U8BIT *hour, U8BIT *mins)
Get the local year, month, day, hour and minute.
Definition: stbgc.c:1968
E_STB_GC_WEEKDAY STB_GCGetGMTWeekDay(void)
Reads the current GMT weekday number.
Definition: stbgc.c:1237
BOOLEAN STB_GCIsFutureDateTime(U16BIT code, U8BIT hour, U8BIT min, U8BIT secs)
Tests given date and time against current GMT date and time.
Definition: stbgc.c:1410
U8BIT * STB_GCGetDateStringDHMS(U32DHMS dhms, E_STB_GC_DATETYPE format)
Supplies specifed date as local date string, in format requested.
Definition: stbgc.c:2326
System Wide Global Technical Data Type Definitions.
U8BIT STB_GCGetGMTHour(void)
Reads the current GMT hour.
Definition: stbgc.c:1080
void STB_GCSetGMTTime(U8BIT hour, U8BIT min, U8BIT secs)
Sets current GMT time.
Definition: stbgc.c:1041
U8BIT STB_GCGetGMTSecs(void)
Reads the current GMT seconds.
Definition: stbgc.c:1142
void STB_GCGetMJDDateInfo(U16BIT code, U8BIT *day, U8BIT *wday, U8BIT *month, U16BIT *year)
Returns the date info from the given MJD date code.
Definition: stbgc.c:1901
void STB_GCSetCIStandby(BOOLEAN standby)
Enables / disables CI standby state.
Definition: stbgc.c:690
U32DHMS STB_GCCreateDebugDHMS(U32BIT date, U32BIT hour, U32BIT mins, U32BIT secs)
Makes U32DHMS formated date/time from date code, hour, minutes, seconds.
Definition: stbgc.c:2048
U16BIT STB_GCGetGMTDate(void)
Reads the current GMT date code.
Definition: stbgc.c:1206
BOOLEAN STB_GCCompareDateTime(U16BIT code1, U8BIT hour1, U8BIT min1, U8BIT secs1, U16BIT code2, U8BIT hour2, U8BIT min2, U8BIT secs2, E_STB_GC_COMPTYPE comp)
Compares one date/time to another.
Definition: stbgc.c:1646
void STB_GCGetLocalTimeOffset(U8BIT *ohour, U8BIT *omin, BOOLEAN *neg)
Reads local time offset from GMT.
Definition: stbgc.c:868
U32BIT STB_GCGetSearchLangCode(void)
Reads the SI search language code from general control store.
Definition: stbgc.c:641
U8BIT * STB_GCGetTimeString(U16BIT code, U8BIT hour, U8BIT min, E_STB_GC_TIMETYPE format)
Supplies specified time as local time string, in format requested.
Definition: stbgc.c:1742
S32BIT STB_GCDateTimeDiff(U16BIT code1, U8BIT hour1, U8BIT min1, U8BIT secs1, U16BIT code2, U8BIT hour2, U8BIT min2, U8BIT secs2)
Returns the difference in seconds between the two dates/times, as time1 - time2, so the result will b...
Definition: stbgc.c:1713
void STB_GCSetSearchLangCode(U32BIT lang)
Writes SI search language code into general control store.
Definition: stbgc.c:621
E_STB_GC_WEEKDAY STB_GCGetDateWeekDay(U16BIT code)
Returns the weekday number of the specified date code.
Definition: stbgc.c:1447