IDateTime
- Namespace
- ZCore
Because a PLC might have multiple DateTime instances that are connected to different targets, DateTime objects are not implemented as singleton classes (i.e. a PRG). This Interface is implemented by datetime providers (e.g. DateTime, DateTimeUM) and can be used to make these function blocks available throughout the application by simply assigning these instances to a locally instantiated IDateTime.
Keep in mind that some of the methods that are available from this interface are only yielding meaningful outputs if the corresponding DateTime objects are done with their booting process, which may take several cyclics and can be checked by using the Synchronized property. The object that instanciates implementations of IDateTime is responsible to wait for the booting process of the implementation to finish.
INTERFACE IDateTime
Properties
Bias
This property returns the bias of the localtime to UTC in ms once DateTime is done with its booting process and thus,
DateTime is in its Idle state. The bias is between localtime to UTC is defined as UTC = localtime + bias
PROPERTY Bias : LINT
Property Value
- LINT
SynchronizationPeriod
Controls the period (in seconds) in which the current time is synchronized with reported by the operating system.
PROPERTY SynchronizationPeriod : LREAL
Property Value
- LREAL
Synchronized
This property returns TRUE
if the object has a valid connection to a time syncing service, and the sync process
has been successfully completed at least once. This usually occurs in the booting process and/or automatically
after a period of time.
PROPERTY Synchronized : BOOL
Property Value
- BOOL
UtcOffset
Returns the actual Utc Offset which gets retrieved from the local OS Timezone information
PROPERTY UtcOffset : LINT
Property Value
- LINT
Methods
CalendarInfo
Returns an interface to a Calendar info data object represented by IDateTimeCalendarInfo based on the actual date shifted by a given utc-offset.
METHOD CalendarInfo (
offset : LINT) : IDateTimeCalendarInfo
Inputs
Returns
DeltaSecondsOs
Returns the time difference now - unixTimestamp
in seconds. The parameter
unixTimestamp
is usually previously stored from a call to UnixTimestamp.
This method should be prefered to calls to DeltaSecondsPlc that
uses PLC-Time
timestamps in the local PLC context in contrast to this method. The PLC-Time timestamps can differ in resolution and starting
point depending on your used PLC-system (e.g. TwinCAT, Ctrl-X,...)
Note
This method only returns valid information if the booting process of the object is finished, which can be checked with the State method.
METHOD DeltaSecondsOs (
unixTimestamp : ULINT) : LREAL
Inputs
Returns
- LREAL
DeltaSecondsPlc
see DeltaSecondsOs
METHOD DeltaSecondsPlc (
filetime : ULINT) : LREAL
Inputs
Returns
- LREAL
Now
METHOD Now (
offset : LINT) : REFERENCE TO DateTimeRecord
Inputs
Returns
- REFERENCE TO DateTimeRecord
TimestampLocalPlc
Returns the current timestamp in the filetime format with 100ns resolution. This time may differ vastly from the time information that the operation system shows, because over time PLC time and OS time may drift appart. If the actual time information is more important than tick counts, UnixTimestamp method should be used which is returning a timestamp that is synchronized to OS time.
METHOD TimestampLocalPlc () : ULINT
Returns
- ULINT
UnixTimestamp
Returns the actual timestamp in unix time format (beginning on 1.1.1970) cyclically corrected with the generated time lag between OS-time (which gets cyclically synced with the internet time) and the plc-runtime-time which gets just incremented over the CPU-Tick-Counter. The returned timestamp has a resolution of 1ms.
If the UnixTimestamp needs to be corrected via UTC-Offset, just add the value of UtcOffset to the return of this method.
METHOD UnixTimestamp () : ULINT
Returns
- ULINT