gwOpen (Function)

Top  Previous  Next

Architecture:

X32 / NX32 / NX32L

Device support:

All

Firmware version:

4.60 / 1.00.00


This function will open a connection to the RTCU Communication Hub, using the configuration set with sockSetGWParm, rchConfigSet or rchFallbackSet.

Also see gwClose for closing the connection to the RTCU Communication Hub.

 

 

Input:        

None.

 

Returns: INT

1

- Success.

0

- Not available.

-1

- The RTCU Communication Hub connection is already open.

-2

- Invalid RTCU Communication Hub configuration.

 

Declaration:

FUNCTION gwOpen : INT;
 

 

Example:

INCLUDE rtcu.inc
 
PROGRAM test;
VAR
  timer   : clockDayTimer;
  rc       : INT;
END_VAR;

 
  // Initialize
  timer(enable:=ON, start_hour:=12, start_minute:=0, stop_hour:=13, stop_minute:=30);
 
BEGIN
  // Manage RTCU Communication Hub connection
  timer();
  IF timer.q THEN
    IF NOT gwIsOpen() THEN
        DebugMsg(message := "Starting connection");
        rc := gwOpen();
        IF rc < 1 THEN
          DebugFmt(message := "  gwOpen=\1", v1 := rc);
        END_IF;
    END_IF;
  ELSE
    IF gwIsOpen() THEN
        DebugMsg(message := "Stopping connection");
        rc := gwClose();
        IF rc < 1 THEN
          DebugFmt(message := "  gwClose=\1", v1 := rc);
        END_IF;
    END_IF;
  END_IF;

 
  IF gwConnected() THEN
    // Connection is ready for work
  END_IF;
END;
END_PROGRAM;