FB_HVACSetLocalTime
Application
The local NT system time and the date of a TwinCAT system can be set with the function block FB_HVACSetLocalTime (the local NT system time is shown in the taskbar). The system time can be specified either via the individual variables uiYear, uiMonth, uiDay, uiHour, uiMinute and uiSecond or the structure stSystemtime, see bEnableStruct.
Internally, an instance of the function block NT_SetLocalTime from the TcUtilities library is called in the function block.
Note The local NT system time can also be synchronized with a reference time with the aid of the SNTP protocol. More information can be found in the Beckhoff Information System under: Beckhoff Information System > Embedded PC > Operating systems > CE > SNTP: Simple Network Time Protocol |
VAR_INPUT
sNetId : T_AmsNetId;
bSetLocalTime : BOOL;
uiYear : UINT; 1970 - 2106
uiMonth : UINT; 1 - 12
uiDay : UINT; 1 - 31
uiHour : UINT; 0 - 23
uiMinute : UINT; 0 - 59
uiSecond : UINT; 0 - 59
bEnableStruct : BOOL;
stSystemtime : TIMESTRUCT;
tTimeout : TIME;
sNETID: this parameter can be used to specify the AmsNetID of the TwinCAT computer, whose local NT system time is to be set. If applicable, an empty string sNetId := ''; can be specified for the local computer.
bSetLocalTime: activation of the function block with a rising edge.
uiYear: the year: 1970 ~ 2106; ; the variable is active if bEnableStruct = FALSE. If specified incorrectly, bInvalidParameter = TRUE and the new local NT system time was not set.
uiMonth: the month: 1 ~ 12 (January = 1, February = 2 and so on); the variable is active if bEnableStruct = FALSE. If specified incorrectly, bInvalidParameter = TRUE and the new local NT system time was not set.
uiDay: day of the month: 1 ~ 31; February with 28 or 29 days and the months with 30 or 31 days are checked. The variable is active if bEnableStruct = FALSE. If specified incorrectly, bInvalidParameter = TRUE and the new local NT system time was not set.
uiHour: hour: 0 ~ 23; ; the variable is active if bEnableStruct = FALSE. If specified incorrectly, bInvalidParameter = TRUE and the new local NT system time was not set.
uiMinute: minute: 0 ~ 59; ; the variable is active if bEnableStruct = FALSE. If specified incorrectly, bInvalidParameter = TRUE and the new local NT system time was not set.
uiSecond: second: 0 ~ 59; ; the variable is active if bEnableStruct = FALSE. If specified incorrectly, bInvalidParameter = TRUE and the new local NT system time was not set.
bEnableStruct: if bEnableStruct = TRUE, the new local NT system time is set via the input variable stSystemtime. If bEnableStruct = FALSE, the new local NT system time is set via the input variables uiYear, uiMonth, uiDay, uiHour, uiMinute and uiSecond.
stSystemtime: structure with the new local NT system time. The structure is active if bEnableStruct = TRUE. The same ranges apply to the structure as to the input variables uiYear, uiMonth, uiDay, uiHour, uiMinute and uiSecond. If specified incorrectly, bInvalidParameter = TRUE and the new local NT system time was not set.
tTimeout: indicates the timeout time, which must not be exceeded during execution.
VAR_OUTPUT
bBusy : BOOL;
bError : BOOL;
udiErrorId : UDINT;
bInvalidParameter: BOOL;
bBusy: if the function block is activated via a rising edge at bSetLocalTime, this output is set and remains set until feedback occurs.
bError: if an error occurs during the transfer of the NT system time, this output is set. bError is reset with the activation of the function block via the input variable bSetLocalTime.
udiErrorId: returns the ADS error code if bError is set.
bInvalidParameter: bInvalidParameter is TRUE if the ranges of the variables for the time and date were not observed: uiYear, uiMonth, uiDay, uiHour, uiMinute and uiSecond. The same ranges apply to the time structure stSystemtime as to the input variables. If bInvalidParameter = TRUE, the new local NT system time was not set. bInvalidParameter is reset with the activation of the function block via the input variable bSetLocalTime.