UnderAutomation
有问题吗?

[email protected]

联系我们
UnderAutomation
⌘Q
Fanuc SDK documentation
Inputs & Outputs
Documentation home

System variables

Read and write integer, real, position, and string system variables on the Fanuc controller via SNPX.

  • Complete example
  • API reference

SNPX lets you read and write system variables by name, including integer, real (float), position, and string types. You can also access Karel program variables using the $[ProgramName]VariableName syntax.

// Integer variables
int rmtMaster = robot.Snpx.IntegerSystemVariables.Read("$RMT_MASTER");
robot.Snpx.IntegerSystemVariables.Write("$RMT_MASTER", 1);
// Real (float) variables
float overr = robot.Snpx.RealSystemVariables.Read("$MCR.$GENOVERRIDE");
robot.Snpx.RealSystemVariables.Write("$MCR.$GENOVERRIDE", 50.0f);
// Position variables
Position cellFloor = robot.Snpx.PositionSystemVariables.Read("$CELL_FLOOR");
robot.Snpx.PositionSystemVariables.Write("$CELL_FLOOR", cellFloor);
// String variables
string lastAlm = robot.Snpx.StringSystemVariables.Read("$ALM_IF.$LAST_ALM");
// Karel program variables
int karelVar = robot.Snpx.IntegerSystemVariables.Read("$[MyKarelProg]my_variable");
robot.Snpx.IntegerSystemVariables.Write("$[MyKarelProg]my_variable", 42);
// Set variable by name (auto-typed)
robot.Snpx.SetVariable("$RMT_MASTER", 1);

Complete example

using UnderAutomation.Fanuc;
using UnderAutomation.Fanuc.Common;
public class SnpxVariables
{
public static void Main()
{
FanucRobot robot = new FanucRobot();
ConnectionParameters parameters = new ConnectionParameters("192.168.0.1");
parameters.Snpx.Enable = true;
robot.Connect(parameters);
/**/
// --- Integer system variables ---
int rmtMaster = robot.Snpx.IntegerSystemVariables.Read("$RMT_MASTER");
robot.Snpx.IntegerSystemVariables.Write("$RMT_MASTER", 1);
// --- Real (float) system variables ---
float genOverride = robot.Snpx.RealSystemVariables.Read("$MCR.$GENOVERRIDE");
robot.Snpx.RealSystemVariables.Write("$MCR.$GENOVERRIDE", 50.0f);
// --- Position system variables ---
Position cellFloor = robot.Snpx.PositionSystemVariables.Read("$CELL_FLOOR");
robot.Snpx.PositionSystemVariables.Write("$CELL_FLOOR", cellFloor);
// --- String system variables ---
string lastAlm = robot.Snpx.StringSystemVariables.Read("$ALM_IF.$LAST_ALM");
robot.Snpx.StringSystemVariables.Write("$ALM_IF.$LAST_ALM", "No alarms");
// --- Karel program variables ---
int karelVar = robot.Snpx.IntegerSystemVariables.Read("$[MyKarelProg]my_variable");
robot.Snpx.IntegerSystemVariables.Write("$[MyKarelProg]my_variable", 42);
// --- Set variable (auto-detects type) ---
robot.Snpx.SetVariable("$RMT_MASTER", 1);
/**/
}
}

API reference

Members of Snpx.Internal.PositionSystemVariables :
public class PositionSystemVariables : SnpxWritableAssignableElements<Position, string, PositionSystemVariablesBatchAssignment> {
protected override string GetAssignmentName(string index)
protected override int GetAssignmentSize(string index)
protected override string GetAssignmentTarget(string index)
// Reads the position at the specified system variable.
public Position Read(string index)
// Reads a value from the client at the specified memory offset.
protected override Position ReadFromClient(int offset, string index)
// Writes a Cartesian position to the specified system variable.
public void Write(string variable, CartesianPosition cartesianPosition)
// Writes an extended Cartesian position to the specified system variable.
public void Write(string variable, ExtendedCartesianPosition extendedCartesianPosition)
// Writes a joints position to the specified system variable.
public void Write(string variable, JointsPosition jointsPosition)
// Writes a value to the robot at the specified offset.
protected override void WriteInClient(int offset, string index, Position value)
}
Members of Snpx.Internal.StringSystemVariables :
public class StringSystemVariables : SnpxWritableAssignableElements<string, string, StringSystemVariablesBatchAssignment> {
protected override string GetAssignmentName(string index)
protected override int GetAssignmentSize(string index)
protected override string GetAssignmentTarget(string index)
// Reads a value from the client at the specified memory offset.
protected override string ReadFromClient(int offset, string index)
// Writes a value to the robot at the specified offset.
protected override void WriteInClient(int offset, string index, string value)
}

轻松将 Universal Robots、Fanuc、Yaskawa、ABB 或 Staubli 机器人集成到您的 .NET、Python、LabVIEW 或 Matlab 应用程序中

UnderAutomation
联系我们Legal

© All rights reserved.