Fanuc SDK documentation
Members of Common.Kcl.SetVariableResult :
Members of Common.Kcl.SetPortResult :
Members of Common.Kcl.SimulateResult :
Members of Common.Kcl.KCLPorts :
Variables & I/O via Telnet
Read and write system variables, set output ports, simulate and unsimulate input ports using Telnet KCL.
Read and write system variables, set output ports, simulate and unsimulate input ports using Telnet KCL.
Read and write variables
// Read a variableGetVariableResult result = robot.Telnet.GetVariable("$RMT_MASTER");string value = result.RawValue;// Write a variablerobot.Telnet.SetVariable("$RMT_MASTER", 1);robot.Telnet.SetVariable("$MCR.$GENOVERRIDE", 50);robot.Telnet.SetVariable("$[MY_PROG]my_var", "hello");// Get current poseGetCurrentPoseResult pose = robot.Telnet.GetCurrentPose();
You can read any system variable, program variable, or user-defined variable by name. The value must match the declared data type. Use brackets ([]) after the variable name to specify an array element.
Set and simulate I/O ports
// Set an output port (DOUT port 2 = OFF)robot.Telnet.SetPort(KCLPorts.DOUT, 2, 0);// Set an output port (DOUT port 5 = ON)robot.Telnet.SetPort(KCLPorts.DOUT, 5, 1);// Simulate an input port (DIN port 3 = ON)robot.Telnet.Simulate(KCLPorts.DIN, 3, 1);// Stop simulating DIN port 3robot.Telnet.Unsimulate(KCLPorts.DIN, 3);// Stop simulating all portsrobot.Telnet.UnsimulateAll();
Available port types
The KCLPorts enum defines the available port types:
| Port | Description |
|---|---|
DIN / DOUT | Digital Input / Output |
GIN / GOUT | Group Input / Output |
AIN / AOUT | Analog Input / Output |
OPIN / OPOUT | Operator Panel Input / Output |
RDI / RDO | Robot Digital Input / Output |
WDI / WDO | Weld Digital Input / Output |
PLCIN / PLCOUT | PLC Input / Output |
FLAG | Flag register |
Complete example
using UnderAutomation.Fanuc;using UnderAutomation.Fanuc.Telnet;public class TelnetVariablesIo{static void Main(){FanucRobot robot = new FanucRobot();ConnectionParameters parameters = new ConnectionParameters("192.168.0.1");parameters.Telnet.Enable = true;parameters.Telnet.TelnetKclPassword = "TELNET_PASS";robot.Connect(parameters);/**/// Read a system variableGetVariableResult result = robot.Telnet.GetVariable("$RMT_MASTER");string value = result.RawValue;// Write system variablesrobot.Telnet.SetVariable("$RMT_MASTER", 1);robot.Telnet.SetVariable("$MCR.$GENOVERRIDE", 50);// Get current TCP poseGetCurrentPoseResult pose = robot.Telnet.GetCurrentPose();// Set an output portrobot.Telnet.SetPort(KCLPorts.DOUT, 2, 0);robot.Telnet.SetPort(KCLPorts.DOUT, 5, 1);// Simulate an input portrobot.Telnet.Simulate(KCLPorts.DIN, 3, 1);// Stop simulating a portrobot.Telnet.Unsimulate(KCLPorts.DIN, 3);// Stop simulating all portsrobot.Telnet.UnsimulateAll();/**/}}
API reference
Members of Common.Kcl.GetVariableResult :public class GetVariableResult : Result {public GetVariableResult()// Indicates that responses have been completed and receivedprotected override void EndReceive()// During implementation, return true if it is assumed that the frame has finished being received.protected override bool FromResult(string data)// Returns a structured object which represents the variable (not supported with Telnet)public GenericVariable ParseResult()// Gets the raw value of the variable as a string.public string RawValue { get; }// Controls whether the result should be finalized when an empty answer is received (i.e. a frame consisting only of VT100 escape sequences and whitespace).// Override and return false until meaningful data has been accumulated, to prevent premature finalization caused by intermediate display-update frames.// Default is true (backward compatible: finalize immediately on empty answer).protected override bool ShouldCompleteOnEmptyAnswer()public override string ToString()}
public class SetVariableResult : SetValueResult {public SetVariableResult()// During implementation, return true if it is assumed that the frame has finished being received.protected override bool FromResult(string data)// Controls whether the result should be finalized when an empty answer is received (i.e. a frame consisting only of VT100 escape sequences and whitespace).// Override and return false until meaningful data has been accumulated, to prevent premature finalization caused by intermediate display-update frames.// Default is true (backward compatible: finalize immediately on empty answer).protected override bool ShouldCompleteOnEmptyAnswer()}
public class SetPortResult : SetValueResult {public SetPortResult()// During implementation, return true if it is assumed that the frame has finished being received.protected override bool FromResult(string data)}
public class SimulateResult : BaseResult {public SimulateResult()}
public enum KCLPorts {// Analog Input port.AIN = 7// Analog Output port.AOUT = 8// Digital Input port.DIN = 0// Digital Output port.DOUT = 1// General Input port.GIN = 9// General Output port.GOUT = 10// Operator Panel Output port.OPOUT = 3// Robot Digital Output port.RDO = 2// Teach Pendant Output port.TPOUT = 4// Weld Digital Input port.WDI = 5// Weld Digital Output port.WDO = 6}