gwTimeGet (Function)

Top  Previous  Next

Architecture:

X32 / NX32 / NX32L

Firmware version:

1.50 / 1.00.00

Deprecated:

Use rchTimeGet instead.


This function requests the current time, expressed as seconds since 1980-1-1 00:00:00 (LINSEC), from the RTCU Communication Hub.

The time requested can be either UTC or the Local time of the server.

 

Note: the time service functionality must be available and enabled in the connected RTCU Communication Hub.

 

 

Input:        

UTC : BOOL (Default FALSE)

The format of the time fetched from the RTCU Communication Hub.

TRUE:

Requests the UTC time.

FALSE:

Requests the Local time.

 

Returns: DINT

The current time as seconds since 1980-1-1 00:00:00 (LINSEC).

0

- Error retrieving the time.

 

Declaration:

FUNCTION gwTimeGet : DINT;
VAR_INPUT
   UTC : BOOL;
END_VAR;

 

 

Example:

INCLUDE rtcu.inc
 
VAR_INPUT
   update : BOOL;
END_VAR;
 
PROGRAM EthernetTest;
VAR
   upd_old : BOOL;
   time    : DINT;
END_VAR;
 
   // Init cellular network
   gsmPower(power:=ON);
   gprsOpen();
 
   DebugMsg(message:="Program running");
 
BEGIN
   ...
   // Update device clock
   IF update AND NOT upd_old THEN
      // Get time
      time := gwTimeGet(UTC := TRUE);
      // Set curent time
      IF time > 0 THEN
         clockSet(linsec := time);
      END_IF;
   END_IF;
   upd_old := update;
END;
END_PROGRAM;