Alarms, comments & files
Manage user alarms, read/write register and I/O comments, list and download files from the controller via CGTP.
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:
FanucRobot robot = new FanucRobot();robot.Connect("192.168.0.1");// Read register commentsstring[] regComments = robot.Cgtp.GetComments(CgtpCommentType.NumericRegister);string[] posComments = robot.Cgtp.GetComments(CgtpCommentType.PositionRegister);string[] strComments = robot.Cgtp.GetComments(CgtpCommentType.StringRegister);// Write a register commentrobot.Cgtp.SetComment(CgtpCommentType.NumericRegister, 1, "Speed setpoint");robot.Cgtp.SetComment(CgtpCommentType.PositionRegister, 1, "Home position");// Read I/O commentsIOComments robotIo = robot.Cgtp.GetIoComments(CgtpCommentIoType.RobotIO);IOComments digitalIo = robot.Cgtp.GetIoComments(CgtpCommentIoType.DigitalIO);IOComments analogIo = robot.Cgtp.GetIoComments(CgtpCommentIoType.AnalogIO);}}
Click to see the full code
User alarms
Read and configure user alarm definitions:
FanucRobot robot = new FanucRobot();robot.Connect("192.168.0.1");// Read all user alarmsUserAlarmDefinition[] alarms = robot.Cgtp.ReadUserAlarms();foreach (var alarm in alarms){Console.WriteLine($"Alarm: {alarm.Comment} (Severity: {alarm.Severity})");}// Set user alarm severityrobot.Cgtp.SetUserAlarmSeverity(1, 2);}}
Click to see the full code
File listing
List files on the controller using CGTP HTTP:
FanucRobot robot = new FanucRobot();robot.Connect("192.168.0.1");// List files in a directorystring[] files = robot.Cgtp.ListFiles("MD:");// List TP programsCgtpAsciiFileItem[] tpPrograms = robot.Cgtp.Http.ListTpPrograms();foreach (var prog in tpPrograms){Console.WriteLine($"{prog.File} - {prog.Comment}");}// List variable filesCgtpAsciiFileItem[] varFiles = robot.Cgtp.Http.ListVariableFiles();// Download as stringstring content = robot.Cgtp.Http.DownloadAsString("numreg.va");// Download as bytesbyte[] data = robot.Cgtp.Http.DownloadAsBytes("posreg.va");}}
Click to see the full code
Complete example
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 commentrobot.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");}}
API reference
Type of element whose comment can be read or written via CGTP.
| Name | Value | Description |
|---|---|---|
AI | 12 | Analog input. |
AO | 13 | Analog output. |
DI | 8 | Digital input. |
DO | 9 | Digital output. |
Flag | 19 | Flag (F[]). |
GI | 10 | Group input. |
GO | 11 | Group output. |
NumericRegister | 1 | Numeric register (R[]). |
PositionRegister | 3 | Position register (PR[]). |
RI | 6 | Robot input. |
RO | 7 | Robot output. |
StringRegister | 14 | String register (SR[]). |
UserAlarm | 4 | User alarm. |
Type of I/O pair whose comments can be read via CGTP.
| Name | Value | Description |
|---|---|---|
AnalogIO | 35 | Analog I/O (AI/AO). |
DigitalIO | 33 | Digital I/O (DI/DO). |
GroupIO | 34 | Group I/O (GI/GO). |
RobotIO | 32 | Robot I/O (RI/RO). |
Represents a file entry returned by the controller's index pages.
| Member | Type | Description |
|---|---|---|
CgtpFileItem() Constructor | ||
Comment Property read only | string | Comment associated with the file, if any. |
File Property read only | string | File name on the controller. |
ToString() Method | string |
Represents a file entry that has both a binary and an ASCII format.
| Member | Type | Description |
|---|---|---|
CgtpAsciiFileItem() Constructor | ||
AsciiFile Property read only | string | ASCII format file name, or null if not available. |
ToString() Method | string |
Provides methods to download and list files from the controller via HTTP.
| Member | Type | Description |
|---|---|---|
BasePath Property | string | Base path used to build the download URL. Default is "MD". |
IP Property read only | string | IP address of the controller |
DownloadAsBytes(string) Method | byte[] | Download a file from the controller and return its raw bytes. |
DownloadAsStream(string) Method | Stream | Download a file from the controller and return a readable stream. Otherwise the raw binary response is returned. |
DownloadAsString(string) Method | string | Download a file from the controller and return its content as a string. |
EnumerateVariableFileNames() Method | string[] | Get the list of all variable file names available on the controller |
ListDiagnosticFiles() Method | CgtpFileItem[] | List diagnostic and error files available on the controller. |
ListOtherFiles() Method | CgtpFileItem[] | List other files available on the controller. |
ListTpPrograms() Method | CgtpAsciiFileItem[] | List TP program files available on the controller. |
ListVariableFiles() Method | CgtpAsciiFileItem[] | List variable files available on the controller. |