Fanuc SDK documentation
Members of Cgtp.CgtpCommentIoType :
Members of Cgtp.CgtpFileItem :
Members of Cgtp.CgtpAsciiFileItem :
Members of Cgtp.Internal.CgtpHttpClient :
Members of Common.UserAlarmDefinition :
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:
// 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);
User alarms
Read and configure user alarm definitions:
// 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);
File listing
List files on the controller using CGTP HTTP:
// 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");
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
Members of Cgtp.CgtpCommentType :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}
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}
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()}
public class CgtpAsciiFileItem : CgtpFileItem {public CgtpAsciiFileItem()// ASCII format file name, or null if not available.public string AsciiFile { get; }public override string ToString()}
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 controllerpublic override string[] EnumerateVariableFileNames()// IP address of the controllerpublic 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()}
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()}