Table of Contents

Class SiemensLoopIterationDependency

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

Watchdog shared by all four Siemens loop constructs (WHILE/ENDWHILE, FOR/ENDFOR, REPEAT/UNTIL, LOOP/ENDLOOP) — construct-neutral by design, unlike the Fanuc sibling (FanucWhileDoIterationDependency) which only has WHILE to guard. Same “soft-cap + runtime counter + session-init ISessionResettable” shape.

Siemens loop constructs carry no LoopId, so the counter key is (FileName, BeginLineNo) — the loop-entry line recorded in the active frame identifies the construct uniquely within its file, and the file path isolates identically-numbered lines across files (and across inlined subprograms).

The consuming syntax (SiemensLoopSyntax) counts at the back-jump step (the loop terminator / falsy UNTIL), so a loop whose condition is false from the outset consumes zero iterations. Above MaxIterationsPerLoop the terminator warns SiemensLoop--IterationLimitExceeded, pops the frame and falls through. A missing dependency disables the cap for the condition-bearing constructs (Fanuc parity) but hard-blocks the ENDLOOP back-jump — LOOP has no exit condition, so an uncapped back-jump would hang the pipeline deterministically.

public class SiemensLoopIterationDependency : INcDependency, IMakeXmlSource, ISessionResettable
Inheritance
SiemensLoopIterationDependency
Implements
Inherited Members
Extension Methods

Constructors

SiemensLoopIterationDependency()

Initializes a new instance with the default limit and an empty counter.

public SiemensLoopIterationDependency()

SiemensLoopIterationDependency(XElement)

Loads MaxIterationsPerLoop from XML produced by MakeXmlSource(string, string, bool); absent element falls back to DefaultMaxIterationsPerLoop.

public SiemensLoopIterationDependency(XElement src)

Parameters

src XElement

Root element named XName.

Fields

DefaultMaxIterationsPerLoop

Default for MaxIterationsPerLoop — matches the Fanuc WHILE default: loops are the legitimate iteration primitive (drill grids, calibration sweeps), so the cap is generous while still catching runaways in a tractable time.

public const int DefaultMaxIterationsPerLoop = 10000

Field Value

int

Properties

CountByLoop

Per-loop hit counter keyed by (FileName, BeginLineNo). Runtime-only; not serialised. Cleared by OnSessionReset() on the session-init edge.

public Dictionary<(string FileName, int BeginLineNo), int> CountByLoop { get; }

Property Value

Dictionary<(string FileName, int TargetN), int>

MaxIterationsPerLoop

Soft cap on back-jumps for any single (FileName, BeginLineNo) pair. Above this the terminator block emits SiemensLoop–IterationLimitExceeded, pops the frame and falls through.

public int MaxIterationsPerLoop { get; set; }

Property Value

int

XName

XML element name used to register this dependency with XFactory.

public static string XName { get; }

Property Value

string

Methods

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.

OnSessionReset()

Clears CountByLoop; leaves MaxIterationsPerLoop untouched.

public void OnSessionReset()

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