2 * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
19 File name : _pbMisc.cpp
20 System name : 05 Integration Platform
21 Subsystem name : System common functions
22 Title : System API Time-of-day operations related processing group
23 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
26 #include <vehicle_service/positioning_base_library.h>
27 #include "WPF_STD_private.h"
30 Declaration of constant data type
31 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
33 DWORD time_on_january1_1970; /* Time on January 1, 1970 when it expressed */
34 /* with the total second number from January 1, 1601 */
38 Internal function prototype declaration
39 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
40 static DWORD FileTimeToSeonds(FILETIME* p_ft);
43 Global Variable Definitions
44 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
45 BTIME_INSTANCE g_instance; // NOLINT(readability/nolint) global class instance
47 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
49 * ABSTRACT : Time-related processing instance initialization processing
50 * NOTE : Assign and hold 1/1/1970 to FILETIME variables
52 * RETURN : RET_API RET_NORMAL Normal completion Note: Always this value
53 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
55 MiscInit(void) { // LCOV_EXCL_START 8:dead code
56 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
57 BTIME_INSTANCE *p_inst = &g_instance;
62 /* Set the system time to the default value (January 1, 1970, 00:00:00). */
72 /* Converting System Time to File Time */
73 bret = PbSystemTimeToFileTime(&st, &ft);
75 /* If the conversion fails, */
76 p_inst->time_on_january1_1970 = 0; /* Save to instance with zero elapsed seconds */
78 /* If the conversion is successful, */
79 p_inst->time_on_january1_1970 = FileTimeToSeonds(&ft); /* Save File Time Elapsed Seconds to Instance */
86 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
87 * MODULE : FileTimeToSeonds()
88 * ABSTRACT : File Time -> Time Conversion Processing
89 * NOTE : Convert the file time to seconds
90 * ARGUMENT : FILETIME *p_ft Pointer to the file time structure
91 * RETURN : DWORD Elapsing time(In seconds)
92 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
94 FileTimeToSeonds(FILETIME* p_ft) { // LCOV_EXCL_START 8:dead code
95 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
100 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
101 * MODULE : MiscTerm()
102 * ABSTRACT : Time-related processing instance release processing
105 * RETURN : RET_API RET_NORMAL Normal completion Note: Always this value
106 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
108 MiscTerm(void) { // LCOV_EXCL_START 8:dead code
109 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
114 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
116 * ABSTRACT : Sleep Processing
117 * NOTE : Cause the caller to sleep at the number of ticks specified by the argument
118 * ARGUMENT : u_int32 ticks Sleep time(Specify in ticks)
119 * : 0 Sleep permanently
120 * : 1 Discard the time slice
121 * RETURN : RET_API Normal completion Note: Always this value
122 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
124 Sleep(u_int32 ticks) { // LCOV_EXCL_START 8:dead code
125 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
129 case 0: /* infinite delay. */
131 milliseconds = INFINITE;
134 case 1: /* the thread to relinquish the remainder of its time slice */
135 /* to any other thread of equal priority that is ready to run. */
136 /* If there are no other threads of equal priority ready to run, */
137 /* the function returns immediately, and the thread continues execution. */
142 default: /* Time tranrate from per 10ms tick count to per milli second. */
143 milliseconds = (DWORD)ticks * 10;
146 PbMilliSecSleep(static_cast<u_int32>(milliseconds));
152 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
153 * MODULE : PbMilliSecSleep()
154 * ABSTRACT : Sleep Processing(Units of ms)
155 * NOTE : Cause the caller to sleep at the number of ticks specified by the argument
156 * ARGUMENT : u_int32 ul_mill_time Sleep time(Specified in millimeters)
157 * : 0 Discard the time slice
158 * : INFINITE Sleep permanently
159 * RETURN : RET_API Normal completion Note: Always this value
160 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
161 RET_API PbMilliSecSleep(u_int32 ul_mill_time) { // LCOV_EXCL_START 8:dead code
162 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
163 switch (ul_mill_time) {
166 /* Discard the time slice */
172 /* Abort processing indefinitely */
178 /* Sleep for Specified Time */
179 usleep(ul_mill_time * 1000);
187 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
188 * MODULE : SecSleep()
189 * ABSTRACT : Sleep Processing(s unit)
190 * NOTE : Cause the caller to sleep at the number of ticks specified by the argument
191 * ARGUMENT : u_int32 ul_time Sleep time(Specify in seconds)
192 * : 0 Discard the time slice
193 * : INFINITE Sleep permanently
194 * RETURN : RET_API Normal completion Note: Always this value
195 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
196 RET_API SecSleep(u_int32 ul_time) { // LCOV_EXCL_START 8:dead code
197 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
201 /* Discard the time slice */
207 /* Abort processing indefinitely */
213 /* Sleep for Specified Time */
223 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
224 End of File : _sysMisc.cpp
225 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *