Table of Contents

Class RetainedCommonVariableTable

Namespace
Hi.NcParsers.Dependencys.Fanuc
Assembly
HiMech.dll

Fanuc-style ISO controller common variable table for the retained range #500-#999. These variables survive a power cycle (in real hardware they live in NV-RAM) and are serialised into the project file.

Excluded by design:

  • Local #1-#33Call-frame scoped (Fanuc local variables); lives in the SyntaxPiece JSON dataflow, not here.
  • Non-retained common #100-#499Cleared by program-end / power reset; lives in the SyntaxPiece JSON dataflow as well, not in this table.
  • System #1000+Read-only or computed from runtime state; resolved by dedicated reading syntaxes against other dependencies (e.g. FanucParameterTable, tool offset / WCS tables).

Vacant (Fanuc <vacant>) is represented by null: either the dictionary has no entry for the key, or the entry maps to null. Both are treated identically by GetVariable(int).

Naming rationale: Fanuc official documentation calls #500-#999 "retained common variables" (and #100-#499 "non-retained common variables"). The umbrella term "macro variable" was avoided because it conflicts with Custom Macro B's call-frame concept (G65/G66 push a frame containing the local #1-#33); using RetainedCommonVariableTable reserves "macro" for the call-frame topic.

public class RetainedCommonVariableTable : INcDependency, IMakeXmlSource, IVariableLookup
Inheritance
RetainedCommonVariableTable
Implements
Inherited Members
Extension Methods

Constructors

RetainedCommonVariableTable()

Empty table.

public RetainedCommonVariableTable()

RetainedCommonVariableTable(XElement)

Loads from XML produced by MakeXmlSource(string, string, bool).

public RetainedCommonVariableTable(XElement src)

Parameters

src XElement

Fields

RetainedCommonMax

Inclusive upper bound of the retained common range (#999).

public const int RetainedCommonMax = 999

Field Value

int

RetainedCommonMin

Inclusive lower bound of the retained common range (#500).

public const int RetainedCommonMin = 500

Field Value

int

Properties

Variables

Backing store. Key = variable number (e.g. 500). Value null = vacant. A missing key is also treated as vacant. Keys are constrained to RetainedCommonMin..RetainedCommonMax; out-of-range writes are silently ignored.

public Dictionary<int, double?> Variables { get; set; }

Property Value

Dictionary<int, double?>

XName

XML element name.

public static string XName { get; }

Property Value

string

Methods

Get(string)

Returns the value of the variable identified by key (e.g. "#124"), or null if vacant or unknown to this lookup.

public double? Get(string key)

Parameters

key string

Returns

double?

Remarks

Routes #500-#999 reads to GetVariable(int); other keys return null so the evaluator's lookup chain falls through.

GetVariable(int)

Reads a retained common variable. Returns null for vacant (either the entry is absent or stored as null).

public double? GetVariable(int id)

Parameters

id int

Variable number in RetainedCommonMin..RetainedCommonMax.

Returns

double?

MakeXmlSource(string, string, bool)

Creates an XML representation of the object. This method may also generate additional resources such as related files.

public XElement MakeXmlSource(string baseDirectory, string relFile, bool exhibitionOnly)

Parameters

baseDirectory string

The base directory for resolving relative paths

relFile string

The relative file path for the XML source

exhibitionOnly bool

if true, the extended file creation is suppressed.

Returns

XElement

An XML element representing the object's state

Remarks

For the demand of easy moving source folder (especially project folder) without configuration file path corruption, the relative file path is applied. The baseDirectory is typically the folder at the nearest configuration file folder. Since the folder can be moving with the configuration file.

Reg(XFactory)

Registers this type's deserializer with the given XFactory (or Default when factory is null). Idempotent.

public static void Reg(XFactory factory = null)

Parameters

factory XFactory

SetVariable(int, double?)

Writes a retained common variable. Pass null to set vacant. Ignores ids outside RetainedCommonMin..RetainedCommonMax.

public void SetVariable(int id, double? value)

Parameters

id int

Variable number.

value double?

New value, or null for vacant.