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:
static void Main(){// 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");}}
Click to see the full code
This works with all .va files: numreg.va, posreg.va, strreg.va, sysvars.va, sysmotn.va, etc.
Error log (errall.ls)
static void Main(){// 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);}}
Click to see the full code
Workflow: FTP download + offline parse
A common pattern is to download files via FTP and parse them locally:
FanucRobot robot = new FanucRobot();robot.Connect("192.168.0.1");// 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();}}
Click to see the full code
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
Represents a parsed Fanuc variable file containing one or more variables
| Member | Type | Description |
|---|---|---|
GenericVariableFile() Constructor | ||
Name Property read only | string | File name |
Parent Property | IGenericVariableType | Parent container |
Variables Property read only | GenericVariable[] | Variables declared in this file |
Equals(object) Method | bool | |
GenerateVa(Stream) Method | void | Generates a .va file and writes it to the specified stream |
GenerateVa(string) Method | void | Generates a .va file and writes it to the specified path |
GeneratedVa() Method | string | Generates the content of a .va variable file as a string. |
GetField(string) Method | GenericVariable | Gets a variable by name (case-insensitive) |
GetHashCode() Method | int | |
ToString() Method | string |
Contains static functions to decode Fanuc files (variables, diagnosis, listing, ...)
| Member | Type | Description |
|---|---|---|
Readers Property static read only | IFileReader<IFanucContent>[] | Get the collection of all parsers |
CurrentPositionReader Field static | DiagnosisReader<CurrentPosition,CurrentPositionReader> | Decode current position file curpos.dg |
ErrorListReader Field static | ErrorListReader | Helper to read error files like errall.ls |
IOStateReader Field static | DiagnosisReader<IOState,IOStateParser> | Decode IO Status file iostate.dg |
ProgramStates Field static | DiagnosisReader<ProgramStates,ProgramStatesParser> | Decode task and program states prgstate.dg |
SafetyStatusReader Field static | DiagnosisReader<SafetyStatus,SafetyStatusParser> | Decode IO Status file iostate.dg |
SummaryDiagnosticReader Field static | SummaryDiagnosisReader | Helper to read summary diagnosis file summary.dg |
VariableReader Field static | VariableReader | Helper to read variable files *.va |
ReadFile(Stream, string, Languages) Method static | IFanucContent | Read any file by path on disc, recognize it by name and decode it |
ReadFile(string, Languages) Method static | IFanucContent | Read any file by path on disc, recognize it by name and decode it |