CGTP provides access to register and I/O comments, user alarms, and file listing/download from the controller.

## Register & I/O comments

Read and write descriptive comments for registers:

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

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

        /**/
        // Read register comments
        string[] regComments = robot.Cgtp.GetComments(CgtpCommentType.NumericRegister);
        string[] posComments = robot.Cgtp.GetComments(CgtpCommentType.PositionRegister);
        string[] strComments = robot.Cgtp.GetComments(CgtpCommentType.StringRegister);

        // Write a register comment
        robot.Cgtp.SetComment(CgtpCommentType.NumericRegister, 1, "Speed setpoint");
        robot.Cgtp.SetComment(CgtpCommentType.PositionRegister, 1, "Home position");

        // Read I/O comments
        IOComments robotIo = robot.Cgtp.GetIoComments(CgtpCommentIoType.RobotIO);
        IOComments digitalIo = robot.Cgtp.GetIoComments(CgtpCommentIoType.DigitalIO);
        IOComments analogIo = robot.Cgtp.GetIoComments(CgtpCommentIoType.AnalogIO);
        /**/
    }
}
```

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

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

##
# Read register comments
reg_comments = robot.cgtp.get_comments("NumericRegister")
pos_comments = robot.cgtp.get_comments("PositionRegister")
str_comments = robot.cgtp.get_comments("StringRegister")

# Write a register comment
robot.cgtp.set_comment("NumericRegister", 1, "Speed setpoint")
robot.cgtp.set_comment("PositionRegister", 1, "Home position")

# Read I/O comments
robot_io = robot.cgtp.get_io_comments("RobotIO")
digital_io = robot.cgtp.get_io_comments("DigitalIO")
analog_io = robot.cgtp.get_io_comments("AnalogIO")
##
```

## User alarms

Read and configure user alarm definitions:

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

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

        /**/
        // Read all user alarms
        UserAlarmDefinition[] alarms = robot.Cgtp.ReadUserAlarms();
        foreach (var alarm in alarms)
        {
            Console.WriteLine($"Alarm: {alarm.Comment} (Severity: {alarm.Severity})");
        }

        // Set user alarm severity
        robot.Cgtp.SetUserAlarmSeverity(1, 2);
        /**/
    }
}
```

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

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

##
# Read all user alarms
alarms = robot.cgtp.read_user_alarms()
for alarm in alarms:
    print(f"Alarm {alarm.index}: {alarm.comment} (Severity: {alarm.severity})")

# Set user alarm severity
robot.cgtp.set_user_alarm_severity(1, 2)
##
```

## File listing

List files on the controller using CGTP HTTP:

**C# : CgtpAlarmsFilesFiles**
```csharp
using UnderAutomation.Fanuc;
using UnderAutomation.Fanuc.Cgtp;

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

        /**/
        // List files in a directory
        string[] files = robot.Cgtp.ListFiles("MD:");

        // List TP programs
        CgtpAsciiFileItem[] tpPrograms = robot.Cgtp.Http.ListTpPrograms();
        foreach (var prog in tpPrograms)
        {
            Console.WriteLine($"{prog.File} - {prog.Comment}");
        }

        // List variable files
        CgtpAsciiFileItem[] varFiles = robot.Cgtp.Http.ListVariableFiles();

        // Download as string
        string content = robot.Cgtp.Http.DownloadAsString("numreg.va");

        // Download as bytes
        byte[] data = robot.Cgtp.Http.DownloadAsBytes("posreg.va");
        /**/
    }
}
```

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

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

##
# List files in a directory
files = robot.cgtp.list_files("MD:")

# List TP programs
tp_programs = robot.cgtp.http.list_tp_programs()
for prog in tp_programs:
    print(f"{prog.file} - {prog.comment}")

# List variable files
var_files = robot.cgtp.http.list_variable_files()

# Download as string
content = robot.cgtp.http.download_as_string("numreg.va")

# Download as bytes
data = robot.cgtp.http.download_as_bytes("posreg.va")
##
```


## Complete example

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

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

    ConnectionParameters parameters = new ConnectionParameters("192.168.0.1");
    parameters.Cgtp.Enable = true;

    robot.Connect(parameters);

    /**/
    // --- Register comments ---
    string[] regComments = robot.Cgtp.GetComments(CgtpCommentType.NumericRegister);
    string[] posComments = robot.Cgtp.GetComments(CgtpCommentType.PositionRegister);

    // Write a comment
    robot.Cgtp.SetComment(CgtpCommentType.NumericRegister, 1, "Speed setpoint");

    // --- I/O comments ---
    IOComments digitalIo = robot.Cgtp.GetIoComments(CgtpCommentIoType.DigitalIO);
    IOComments robotIo = robot.Cgtp.GetIoComments(CgtpCommentIoType.RobotIO);

    // --- User alarms ---
    UserAlarmDefinition[] alarms = robot.Cgtp.ReadUserAlarms();
    robot.Cgtp.SetUserAlarmSeverity(1, 2);

    // --- File listing ---
    string[] files = robot.Cgtp.ListFiles("MD:");

    CgtpAsciiFileItem[] tpPrograms = robot.Cgtp.Http.ListTpPrograms();
    CgtpAsciiFileItem[] varFiles = robot.Cgtp.Http.ListVariableFiles();
    CgtpFileItem[] diagFiles = robot.Cgtp.Http.ListDiagnosticFiles();

    // --- File download ---
    string content = robot.Cgtp.Http.DownloadAsString("numreg.va");
    byte[] data = robot.Cgtp.Http.DownloadAsBytes("posreg.va");
    /**/
  }
}
```

**Python : CgtpAlarmsFiles**
```python
from underautomation.fanuc.fanuc_robot import FanucRobot
from underautomation.fanuc.connection_parameters import ConnectionParameters
from underautomation.fanuc.cgtp.cgtp_comment_type import CgtpCommentType
from underautomation.fanuc.cgtp.cgtp_comment_io_type import CgtpCommentIoType

# Create a robot instance
robot = FanucRobot()

# Configure connection parameters
parameters = ConnectionParameters("192.168.0.1")
parameters.cgtp.enable = True

# Connect to the robot
robot.connect(parameters)

##
# --- Register comments ---
reg_comments = robot.cgtp.get_comments(CgtpCommentType.NUMERIC_REGISTER)
pos_comments = robot.cgtp.get_comments(CgtpCommentType.POSITION_REGISTER)

# Write a comment
robot.cgtp.set_comment(CgtpCommentType.NUMERIC_REGISTER, 1, "Speed setpoint")

# --- I/O comments ---
digital_io = robot.cgtp.get_io_comments(CgtpCommentIoType.DIGITAL_IO)
robot_io = robot.cgtp.get_io_comments(CgtpCommentIoType.ROBOT_IO)

# --- User alarms ---
alarms = robot.cgtp.read_user_alarms()
robot.cgtp.set_user_alarm_severity(1, 2)

# --- File listing ---
files = robot.cgtp.list_files("MD:")

tp_programs = robot.cgtp.http.list_tp_programs()
var_files = robot.cgtp.http.list_variable_files()
diag_files = robot.cgtp.http.list_diagnostic_files()

# --- File download ---
content = robot.cgtp.http.download_as_string("numreg.va")
data = robot.cgtp.http.download_as_bytes("posreg.va")
##
```

## API reference

**Members of Cgtp.CgtpCommentType**
```csharp
public enum CgtpCommentType {
    // Analog input.
    AI = 12

    // Analog output.
    AO = 13

    // Digital input.
    DI = 8

    // Digital output.
    DO = 9

    // Flag (F[]).
    Flag = 19

    // Group input.
    GI = 10

    // Group output.
    GO = 11

    // Numeric register (R[]).
    NumericRegister = 1

    // Position register (PR[]).
    PositionRegister = 3

    // Robot input.
    RI = 6

    // Robot output.
    RO = 7

    // String register (SR[]).
    StringRegister = 14

    // User alarm.
    UserAlarm = 4
}
```

**Members of Cgtp.CgtpCommentIoType**
```csharp
public enum CgtpCommentIoType {
    // Analog I/O (AI/AO).
    AnalogIO = 35

    // Digital I/O (DI/DO).
    DigitalIO = 33

    // Group I/O (GI/GO).
    GroupIO = 34

    // Robot I/O (RI/RO).
    RobotIO = 32
}
```

**Members of Cgtp.CgtpFileItem**
```csharp
public class CgtpFileItem {
    public CgtpFileItem()

    // Comment associated with the file, if any.
    public string Comment { get; }

    // File name on the controller.
    public string File { get; }

    public override string ToString()
}
```

**Members of Cgtp.CgtpAsciiFileItem**
```csharp
public class CgtpAsciiFileItem : CgtpFileItem {
    public CgtpAsciiFileItem()

    // ASCII format file name, or null if not available.
    public string AsciiFile { get; }

    public override string ToString()
}
```

**Members of Cgtp.Internal.CgtpHttpClient**
```csharp
public class CgtpHttpClient : FileClientBase {
    // Base path used to build the download URL. Default is "MD".
    public string BasePath { get; set; }

    // Download a file from the controller and return its raw bytes.
    public byte[] DownloadAsBytes(string fileName)

    // Download a file from the controller and return a readable stream.
    // Otherwise the raw binary response is returned.
    public Stream DownloadAsStream(string fileName)

    // Download a file from the controller and return its content as a string.
    public string DownloadAsString(string fileName)

    // Get the list of all variable file names available on the controller
    public override string[] EnumerateVariableFileNames()

    // IP address of the controller
    public override string IP { get; }

    // List diagnostic and error files available on the controller.
    public CgtpFileItem[] ListDiagnosticFiles()

    // List other files available on the controller.
    public CgtpFileItem[] ListOtherFiles()

    // List TP program files available on the controller.
    public CgtpAsciiFileItem[] ListTpPrograms()

    // List variable files available on the controller.
    public CgtpAsciiFileItem[] ListVariableFiles()
}
```

**Members of Common.UserAlarmDefinition**
```csharp
public class UserAlarmDefinition {
    public UserAlarmDefinition()

    // Comment associated with this alarm.
    public string Comment { get; set; }

    // Severity level of the alarm.
    public int Severity { get; set; }

    public override string ToString()
}
```