FB_HVACSetLocalTime

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 via the structure stSystemtime, see bEnableStruct.
Internally, an instance of the function block NT_SetLocalTime from the TcUtilities library is called in the function block.
![]() | The local NT system time can also be synchronized with a reference time with the aid of the SNTP protocol. For further information please refer to the Beckhoff Information System under: Beckhoff Information System > Industrial PC > Operating systems > CE > SNTP: Simple Network Time Protocol |
VAR_INPUT
sNetId : T_AmsNetId;
bSetLocalTime : BOOL;
uiYear : UINT;
uiMonth : UINT;
uiDay : UINT;
uiHour : UINT;
uiMinute : UINT;
uiSecond : UINT;
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: The 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 [s], 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: This output is set if an error occurs during the transfer of the NT system time. bError is reset by the activation of the function block via the input variable bSetLocalTime.
udiErrorId: Returns the ADS error code if bError is set (see ADS Return Codes)
bInvalidParameter: bInvalidParameter is TRUE if the ranges of the variables for the time of day and the date are not adhered to: uiYear, uiMonth, uiDay, uiHour, uiMinute and uiSecond. The same ranges apply to the time structure stSystemtime as to the input variables. If bInvalidParameter = TRUE, then the new local NT system time was not set. bInvalidParameter is reset by the activation of the function block via the input variable bSetLocalTime.
Requirements
Development environment | required library | required function |
---|---|---|
TwinCAT 3.1 build 4022.16 or higher | Tc2_HVAC V3.3.1.0 | TF8000 | TC3 HVAC V1.0.0.0 |