The `ConnectionParameters` class lets you configure which protocols to enable before connecting to the robot. Each protocol is optional and can be enabled independently.

## Quick connection

The simplest way to connect is to pass an IP address directly. This enables only the CGTP protocol by default.

**C# : ConnectQuick**
```csharp
using UnderAutomation.Fanuc;

public class ConnectQuick
{
    static void Main()
    {
        /**/
        var robot = new FanucRobot();
        robot.Connect("192.168.0.1");
        /**/
    }
}
```

**Python : ConnectQuick**
```python
from underautomation.fanuc.fanuc_robot import FanucRobot

##
robot = FanucRobot()
robot.connect("192.168.0.1")
##
```

## Full connection with multiple protocols

To use multiple protocols, create a `ConnectionParameters` object and enable each protocol you need.

**C# : Connect**
```csharp
using UnderAutomation.Fanuc;
using UnderAutomation.Fanuc.Common;

public class Connect
{
  static void Main()
  {
    // Create a robot instance
    FanucRobot robot = new FanucRobot();

    // Configure connection parameters
    ConnectionParameters parameters = new ConnectionParameters("192.168.0.1");

    /**/
    // Enable Telnet KCL for remote commands
    parameters.Telnet.Enable = true;
    parameters.Telnet.TelnetKclPassword = "your_password";

    // Enable FTP for file and variable access
    parameters.Ftp.Enable = true;
    parameters.Ftp.FtpUser = "";
    parameters.Ftp.FtpPassword = "";

    // Enable SNPX for high-speed register and I/O access
    parameters.Snpx.Enable = true;

    // Enable CGTP Web Server (enabled by default)
    parameters.Cgtp.Enable = true;

    // Enable RMI for remote motion commands
    parameters.Rmi.Enable = true;

    // Connect to the robot
    robot.Connect(parameters);

    // Check connection status
    bool isConnected = robot.Enabled;

    // Disconnect when done
    robot.Disconnect();
    /**/
  }
}
```

**Python : Connect**
```python
from underautomation.fanuc.fanuc_robot import FanucRobot
from underautomation.fanuc.connection_parameters import ConnectionParameters
from underautomation.fanuc.common.languages import Languages

# Create a robot instance
robot = FanucRobot()

# Configure connection parameters
parameters = ConnectionParameters("192.168.0.1")

##
# Enable Telnet KCL for remote commands
parameters.telnet.enable = True
parameters.telnet.telnet_kcl_password = "your_password"

# Enable FTP for file and variable access
parameters.ftp.enable = True
parameters.ftp.ftp_user = ""
parameters.ftp.ftp_password = ""

# Enable SNPX for high-speed register and I/O access
parameters.snpx.enable = True

# Enable CGTP Web Server (enabled by default)
parameters.cgtp.enable = True

# Enable RMI for remote motion commands
parameters.rmi.enable = True

# Connect to the robot
robot.connect(parameters)

# Check connection status
is_connected = robot.enabled

# Disconnect when done
robot.disconnect()
##
```

## Connect to ROBOGUIDE

Instead of an IP address, you can pass the path to a ROBOGUIDE workcell robot folder. The SDK reads the `services.txt` file in that folder to discover the TCP ports used by the simulator.

**C# : ConnectRoboguide**
```csharp
using UnderAutomation.Fanuc;

public class ConnectRoboguide
{
    static void Main()
    {
        FanucRobot robot = new FanucRobot();

        /**/
        var parameters = new ConnectionParameters(@"C:\Users\you\Documents\My Workcells\CRX 10iA L\Robot_1");
        parameters.Telnet.Enable = true;
        parameters.Telnet.TelnetKclPassword = "";
        parameters.Ftp.Enable = true;
        parameters.Ftp.FtpUser = "";
        parameters.Ftp.FtpPassword = "";
        robot.Connect(parameters);
        /**/
    }
}
```

**Python : ConnectRoboguide**
```python
from underautomation.fanuc.fanuc_robot import FanucRobot
from underautomation.fanuc.connection_parameters import ConnectionParameters

robot = FanucRobot()

##
parameters = ConnectionParameters(r"C:\Users\you\Documents\My Workcells\CRX 10iA L\Robot_1")
parameters.telnet.enable = True
parameters.telnet.telnet_kcl_password = ""
parameters.ftp.enable = True
parameters.ftp.ftp_user = ""
parameters.ftp.ftp_password = ""
robot.connect(parameters)
##
```


## Connection options

When `PingBeforeConnect` is `true` (default), the SDK sends a ping to the robot before attempting any connection. If the robot does not respond, an exception is thrown immediately. Set it to `false` when connecting to ROBOGUIDE or when ICMP is blocked on your network.

Set the `Language` property to match your controller's language so that strings are decoded correctly.

**C# : ConnectOptions**
```csharp
using UnderAutomation.Fanuc;
using UnderAutomation.Fanuc.Common;

public class ConnectOptions
{
    static void Main()
    {
        FanucRobot robot = new FanucRobot();
        ConnectionParameters parameters = new ConnectionParameters("192.168.0.1");

        /**/
        // Ping before connecting (default: true)
        parameters.PingBeforeConnect = true;
        // Set to false for ROBOGUIDE or when ICMP is blocked

        // Controller language for correct string decoding
        parameters.Language = Languages.English;   // default (ASCII)
                                                   // parameters.Language = Languages.Japanese; // Shift-JIS
                                                   // parameters.Language = Languages.Chinese;  // GB2312
        /**/

        robot.Connect(parameters);
    }
}
```

**Python : ConnectOptions**
```python
from underautomation.fanuc.fanuc_robot import FanucRobot
from underautomation.fanuc.connection_parameters import ConnectionParameters
from underautomation.fanuc.common.languages import Languages

robot = FanucRobot()
parameters = ConnectionParameters("192.168.0.1")

##
# Ping before connecting (default: True)
parameters.ping_before_connect = True
# Set to False for ROBOGUIDE or when ICMP is blocked

# Controller language for correct string decoding
parameters.language = Languages.English   # default (ASCII)
# parameters.language = Languages.Japanese  # Shift-JIS
# parameters.language = Languages.Chinese   # GB2312
##

robot.connect(parameters)
```

## Standalone protocol clients

Each protocol can also be used independently without `FanucRobot`. This is useful when you only need a single protocol:

**C# : ConnectStandalone**
```csharp
using UnderAutomation.Fanuc;
using UnderAutomation.Fanuc.Snpx;
using UnderAutomation.Fanuc.Telnet;
using UnderAutomation.Fanuc.Cgtp;

public class ConnectStandalone
{
    static void Main()
    {
        /**/
        // Standalone SNPX client
        var snpx = new SnpxClient();
        snpx.Connect("192.168.0.1");

        // Standalone Telnet client
        var telnet = new TelnetClient();
        telnet.Connect("192.168.0.1", "telnet_password");

        // Standalone CGTP client
        var cgtp = new CgtpClient();
        cgtp.Connect("192.168.0.1");
        /**/
    }
}
```

**Python : ConnectStandalone**
```python
from underautomation.fanuc.snpx.snpx_client import SnpxClient
from underautomation.fanuc.telnet.telnet_client import TelnetClient
from underautomation.fanuc.cgtp.cgtp_client import CgtpClient

##
# Standalone SNPX client
snpx = SnpxClient()
snpx.connect("192.168.0.1")

# Standalone Telnet client
telnet = TelnetClient()
telnet.connect("192.168.0.1", "telnet_password")

# Standalone CGTP client
cgtp = CgtpClient()
cgtp.connect("192.168.0.1")
##
```

## Disconnect

Always disconnect when you are done to release resources.

**C# : ConnectDisconnect**
```csharp
using UnderAutomation.Fanuc;

public class ConnectDisconnect
{
    static void Main()
    {
        FanucRobot robot = new FanucRobot();
        robot.Connect("192.168.0.1");

        /**/
        robot.Disconnect();
        /**/
    }
}
```

**Python : ConnectDisconnect**
```python
from underautomation.fanuc.fanuc_robot import FanucRobot

robot = FanucRobot()
robot.connect("192.168.0.1")

##
robot.disconnect()
##
```

## API reference

**Members of ConnectionParameters**
```csharp
public class ConnectionParameters {
    // Instanciate a new connection parameters
    public ConnectionParameters()

    // Instanciate a new connection parameters with a specified address
    public ConnectionParameters(string address)

    // Address of the robot (IP, host name, or path to ROBOGUIDE project folder)
    public string Address { get; set; }

    // Parameters for CGTP Web Server (HTTP-based COMET RPC interface)
    public CgtpConnectParameters Cgtp { get; set; }

    // Access controller internal memory to read variables, IO, positions, diagnosis, ...
    public FtpConnectParameters Ftp { get; set; }

    // Controller language (default: English)
    public Languages Language { get; set; }

    // Send a ping command before initializing any connections
    public bool PingBeforeConnect { get; set; }

    // Parameters for RMI (Remote Motion Interface)
    public RmiConnectParameters Rmi { get; set; }

    // Read and write IOs, read and clear alarms, read current program tasks
    public SnpxConnectParameters Snpx { get; set; }

    // Parameters for Stream Motion (J519 option) - real-time streaming motion control over UDP
    public StreamMotionConnectParameters StreamMotion { get; set; }

    // Sends commands to the robot for remote control
    public TelnetConnectParameters Telnet { get; set; }
}
```

**Members of Common.TelnetConnectParameters**
```csharp
public class TelnetConnectParameters : TelnetConnectParametersBase {
    public TelnetConnectParameters()

    // Should use this service (default: false)
    public bool Enable { get; set; }
}
```

**Members of Common.FtpConnectParameters**
```csharp
public class FtpConnectParameters : FtpConnectParametersBase {
    public FtpConnectParameters()

    // Should enable memory access for this connection (default: true)
    public bool Enable { get; set; }
}
```

**Members of Common.SnpxConnectParameters**
```csharp
public class SnpxConnectParameters : SnpxConnectParametersBase {
    public SnpxConnectParameters()

    // Should enable SNPX for this connection (default: false)
    public bool Enable { get; set; }
}
```

**Members of Common.CgtpConnectParameters**
```csharp
public class CgtpConnectParameters : CgtpConnectParametersBase {
    public CgtpConnectParameters()

    // Should enable CGTP Web Server for this connection (default: true)
    public bool Enable { get; set; }
}
```

**Members of Common.RmiConnectParameters**
```csharp
public class RmiConnectParameters : RmiConnectParametersBase {
    public RmiConnectParameters()

    // Should enable RMI for this connection (default: false)
    public bool Enable { get; set; }
}
```

**Members of Common.StreamMotionConnectParameters**
```csharp
public class StreamMotionConnectParameters : StreamMotionConnectParametersBase {
    public StreamMotionConnectParameters()

    // Should enable Stream Motion for this connection (default: false)
    public bool Enable { get; set; }

    // IP address of the robot for standalone Stream Motion connections
    public string Ip { get; set; }
}
```