Fanuc SDK documentation
Members of Common.Files.FanucFileReaders :
Offline file parsing
Parse and decode Fanuc variable files (.va), error lists (.ls), I/O state, safety status, and current position files without a robot connection.
The SDK includes offline file parsers for reading and editing Fanuc controller files without a network connection. Download files from the robot via FTP, then parse them locally.
Variable files (.va)
Parse any variable file (.va) into a hierarchical list of typed variables:
// Parse a variable fileGenericVariableFile vaFile = FanucFileReaders.VariableReader.ReadFile("C:/backup/numreg.va", Languages.English);// Browse variablesforeach (var variable in vaFile.Variables){Console.WriteLine($"{variable.Name} = {variable.Value} [{variable.Type}]");}// Re-generate the .va filevaFile.GenerateVa("C:/backup/numreg_modified.va");
This works with all .va files: numreg.va, posreg.va, strreg.va, sysvars.va, sysmotn.va, etc.
Error log (errall.ls)
// Error logvar errors = FanucFileReaders.ErrorListReader.ReadFile("C:/backup/errall.ls", Languages.English);foreach (var error in errors.Items){Console.WriteLine($"{error.OccurringTime} [{error.ErrorCode}] {error.Message}");}// I/O statevar ioState = FanucFileReaders.IOStateReader.ReadFile("C:/backup/iostate.dg", Languages.English);// Safety statusvar safety = FanucFileReaders.SafetyStatusReader.ReadFile("C:/backup/safety.dg", Languages.English);// Current positionvar currentPos = FanucFileReaders.CurrentPositionReader.ReadFile("C:/backup/curpos.dg", Languages.English);
Workflow: FTP download + offline parse
A common pattern is to download files via FTP and parse them locally:
// Download a file from the robotrobot.Ftp.DirectFileHandling.DownloadFileFromController("numreg.va", "md:/numreg.va");// Parse offlinevar vaFile = FanucFileReaders.VariableReader.ReadFile("numreg.va", Languages.English);// Or use the built-in helpersvar numRegs = robot.Ftp.KnownVariableFiles.GetNumregFile();var posRegs = robot.Ftp.KnownVariableFiles.GetPosregFile();
Complete example
using UnderAutomation.Fanuc.Common;using UnderAutomation.Fanuc.Common.Files;using UnderAutomation.Fanuc.Common.Files.Variables;public class OfflineFileParsing{static void Main(){/**/// Parse a variable file and extract a hierarchical list of variablesGenericVariableFile vaFile = FanucFileReaders.VariableReader.ReadFile("C:/path/to/variable.va", Languages.English);foreach (var variable in vaFile.Variables)Console.WriteLine($"{variable.Name} = {variable.Value} [{variable.Type}]");// Edit and regenerate the variable filevaFile.GenerateVa("C:/path/to/variable_modified.va\"");// Parse several types of filesFanucFileReaders.ErrorListReader.ReadFile("C:/path/to/errall.ls", Languages.English);FanucFileReaders.IOStateReader.ReadFile("C:/path/to/iostate.dg", Languages.English);FanucFileReaders.SafetyStatusReader.ReadFile("C:/path/to/safety.dg", Languages.English);FanucFileReaders.CurrentPositionReader.ReadFile("C:/path/to/curpos.dg", Languages.English);/**/}}
API reference
Members of Common.Files.Variables.GenericVariableFile :public class GenericVariableFile : IGenericVariableType, IFanucContent {public GenericVariableFile()public override bool Equals(object obj)// Generates a .va file and writes it to the specified streampublic void GenerateVa(Stream stream)// Generates a .va file and writes it to the specified pathpublic void GenerateVa(string pathToVa)// Generates the content of a .va variable file as a string.public string GeneratedVa()// Gets a variable by name (case-insensitive)public GenericVariable GetField(string name)public override int GetHashCode()// File namepublic string Name { get; }// Parent containerpublic IGenericVariableType Parent { get; set; }public override string ToString()// Variables declared in this filepublic GenericVariable[] Variables { get; }}
public static class FanucFileReaders {// Decode current position file curpos.dgpublic static readonly DiagnosisReader<CurrentPosition, CurrentPositionReader> CurrentPositionReader// Helper to read error files like errall.lspublic static readonly ErrorListReader ErrorListReader// Decode IO Status file iostate.dgpublic static readonly DiagnosisReader<IOState, IOStateParser> IOStateReader// Decode task and program states prgstate.dgpublic static readonly DiagnosisReader<ProgramStates, ProgramStatesParser> ProgramStates// Read any file by path on disc, recognize it by name and decode itpublic static IFanucContent ReadFile(Stream fileStream, string fileName, Languages language)// Read any file by path on disc, recognize it by name and decode itpublic static IFanucContent ReadFile(string fileName, Languages language)// Get the collection of all parserspublic static IFileReader<IFanucContent>[] Readers { get; }// Decode IO Status file iostate.dgpublic static readonly DiagnosisReader<SafetyStatus, SafetyStatusParser> SafetyStatusReader// Helper to read summary diagnosis file summary.dgpublic static readonly SummaryDiagnosisReader SummaryDiagnosticReader// Helper to read variable files *.vapublic static readonly VariableReader VariableReader}