Skip to content
Menu
Menu

Knowledge Base

KB050021 | SENDING THE TIME ON KNX/EIB

KB050021 | SENDING THE TIME ON KNX/EIB

Product: Elvis
Version: from 1.3
Booth: 2002-07-25

Summary

If the PC time is to be sent as telegrams to the bus (EIB: EIS3 and EIS4), the time available via the system port can be used. However, this time is localized and also contains the summer/winter time switch. Sometimes, however, you have to send the Greenwich Mean Time = Universal Time Coordinate (UTC) to the bus. The following functions determine the local time and UTC and their return value can be assigned directly to corresponding data points (types: EIB time and EIB date).

Details

1. Some functions are declared in the global script of the process server. Download script (3 KB).

Please do not copy from the web – this may contain special characters that lead to malfunctions!

Sub OnLoad()
Database.Datapoint(“date”). ActualValue = CDate(0)
Database.Datapoint(“time”). ActualValue = CDate(0)
End Sub

Type SYSTEMTIME
wYear As Integer
wMonth As Integer
wDayOfWeek As Integer
wDay As Integer
wHour As Integer
wMinute As Integer
wSecond As Integer
wMilliseconds As Integer
End Type

Declare Function SetSystemTime Lib “kernel32” (ByRef lpSystemTime _
As SYSTEMTIME) As Long
Declare Function VariantTimeToSystemTime Lib “oleaut32″(ByVal vtime As Date, _
ByRef lpSystemTime As SYSTEMTIME) As Long
Declare Function SystemTimeToVariantTime Lib “oleaut32″(ByRef lpSystemTime As SYSTEMTIME, ByRef vtime As Date) As Long
Declare Function GetSystemTime Lib “kernel32” (ByRef lpSystemTime As SYSTEMTIME) As Long
Declare Function GetLocalTime Lib “kernel32” (ByRef lpSystemTime As SYSTEMTIME) As Long

Function GetDateTimeUTC() As Date
Dim systime As SYSTEMTIME
Dim vartime As Date

GetSystemTime systime

If SystemTimeToVariantTime(systime, vartime) = 0 Then
Print “SystemTimeToVariantTime failed”
Else
GetDateTimeUTC = vartime
End If
End Function

Function GetDateTimeLocal() As Date
Dim localtime As SYSTEMTIME
Dim vartime As Date

GetLocalTime localtime

If SystemTimeToVariantTime(localtime, vartime) = 0 Then
Print “SystemTimeToVariantTime failed”
Else
GetDateTimeLocal = vartime
End If
End Function

2. Assign data points of type EIB time or EIB date to DateTimeLocal or DateTimeUTC. In this small example, the data point Local_UTC_Time_Switch is used to switch between local and UTC. The data point Zeit_jetzt_senden_Befehl serves only as an event to trigger the calculation. It can be changed, for example, via a timer, a time program or simply via the operator.

Please do not copy from the web – this may contain special characters that lead to malfunctions! It is faster and safer if you create the data points and then select them for your calculation from the list offered in the editor.

‘@(Zeit_jetzt_senden_Befehl). NominalValue

Dim dDateTime As Date
If Database.Datapoint(“Local_UTC_Time_Switch”). NominalValue Then
dDateTime = GetDateTimeUTC()
Else
dDateTime = GetDateTimeLocal()
End If
Database.Datapoint(“datum_UTC”). NominalValue = dDateTime
Database.Datapoint(“zeit_UTC”). NominalValue = dDateTime
Result = dDateTime

Support Area

KB050021 | SENDING THE TIME ON KNX/EIB

Knowledge Base

Here you will find answers, solutions to problems and examples of our products.
KB050021 | SENDING THE TIME ON KNX/EIB

Case Studies

Successful in use: practical examples of our products and individual developments.
KB050021 | SENDING THE TIME ON KNX/EIB

Support

Describe your concern using our support form.
KB050021 | SENDING THE TIME ON KNX/EIB

License registration

Register your Elvis license!

IT GmbH · An der Kaufleite 12 · D-90562 Kalchreuth

© Copyright 2024. IT GmbH | Webdesign by Appear Online