S2OPC OPCUA Toolkit
sopc_platform_time.h
Go to the documentation of this file.
1 /*
2  * Licensed to Systerel under one or more contributor license
3  * agreements. See the NOTICE file distributed with this work
4  * for additional information regarding copyright ownership.
5  * Systerel licenses this file to you under the Apache
6  * License, Version 2.0 (the "License"); you may not use this
7  * file except in compliance with the License. You may obtain
8  * a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  */
19 
26 #ifndef SOPC_PLATFORM_TIME_H_
27 #define SOPC_PLATFORM_TIME_H_
28 
40 #ifndef SOPC_MONOTONIC_CLOCK
41 #define SOPC_MONOTONIC_CLOCK true
42 #endif
43 
53 #include "p_sopc_time.h"
54 
55 #include <stdbool.h>
56 #include <stdint.h>
57 #include <time.h>
58 
59 #include "sopc_builtintypes.h"
60 #include "sopc_enums.h"
61 
65 typedef uint64_t SOPC_TimeReference;
66 
72 void SOPC_Sleep(unsigned int milliseconds);
73 
83 
93 
103 
113 
121 
129 int64_t SOPC_RealTime_DeltaUs(const SOPC_RealTime* tRef, const SOPC_RealTime* t);
130 
147 void SOPC_RealTime_AddSynchedDuration(SOPC_RealTime* t, uint64_t duration_us, int32_t offset_us);
148 
159 
167 
177 
192 
202 bool SOPC_RealTime_IsExpired(const SOPC_RealTime* t, const SOPC_RealTime* now);
203 
204 #endif /* SOPC_PLATFORM_TIME_H_ */
SOPC_Time_GetCurrentTimeUTC
SOPC_DateTime SOPC_Time_GetCurrentTimeUTC(void)
return the current time in DateTime format which is 100 nanoseconds from 1601/01/01 00:00:00 UTC
SOPC_RealTime_Copy
bool SOPC_RealTime_Copy(SOPC_RealTime *to, const SOPC_RealTime *from)
A copy of a non-NULL SOPC_RealTime structure.
SOPC_RealTime_IsExpired
bool SOPC_RealTime_IsExpired(const SOPC_RealTime *t, const SOPC_RealTime *now)
Checks is a date is in the future (relatively to another date)
SOPC_RealTime_GetTime
bool SOPC_RealTime_GetTime(SOPC_RealTime *t)
Store the current time in t.
SOPC_Sleep
void SOPC_Sleep(unsigned int milliseconds)
Suspend current thread execution for (at least) a millisecond interval.
sopc_enums.h
sopc_builtintypes.h
SOPC_RealTime
Definition: p_sopc_time.h:33
SOPC_Time_Breakdown_UTC
SOPC_ReturnStatus SOPC_Time_Breakdown_UTC(time_t t, struct tm *tm)
Breaks down a timestamp to its structured representation in UTC time.
SOPC_RealTime_SleepUntil
bool SOPC_RealTime_SleepUntil(const SOPC_RealTime *date)
Precise sleep until specified date.
SOPC_Time_Breakdown_Local
SOPC_ReturnStatus SOPC_Time_Breakdown_Local(time_t t, struct tm *tm)
Breaks down a timestamp to its structured representation in local time.
SOPC_RealTime_DeltaUs
int64_t SOPC_RealTime_DeltaUs(const SOPC_RealTime *tRef, const SOPC_RealTime *t)
Compare two SOPC_RealTime elements into microseconds.
SOPC_DateTime
int64_t SOPC_DateTime
Definition: sopc_builtintypes.h:158
SOPC_TimeReference_GetCurrent
SOPC_TimeReference SOPC_TimeReference_GetCurrent(void)
return the current time reference
SOPC_RealTime_AddSynchedDuration
void SOPC_RealTime_AddSynchedDuration(SOPC_RealTime *t, uint64_t duration_us, int32_t offset_us)
Adds an offset to a SOPC_RealTime object, ensuring a specific time offset towards a synchronized cloc...
SOPC_RealTime_Delete
void SOPC_RealTime_Delete(SOPC_RealTime **t)
Deletes a time reference.
SOPC_TimeReference
uint64_t SOPC_TimeReference
Definition: sopc_platform_time.h:65
SOPC_RealTime_Create
SOPC_RealTime * SOPC_RealTime_Create(const SOPC_RealTime *copy)
Create a new time reference.
SOPC_ReturnStatus
SOPC_ReturnStatus
Definition: libs2opc_client.h:64