Table of Contents

Class Branch

Namespace
Hi.Mech.Topo
Assembly
HiMech.dll

The linkage between two Anchor objects.

A branch is a view (world, id) over a branch node of the native topology registry (core.dll, Hi.Mech.Topo.NativeTopo). Attaching creates the node, detaching frees it — the id then goes stale and the view latches IsBreak; the ends, name, GUID and error-term mark are cached on the view (name, GUID and mark are pushed on set), and the transformer is a managed object bound to this branch: its state is the write-side truth, every mutation of it is pushed to the native node as a whole, and the native walks read the native copy (a few writes of the library go native first and bring the object along after: a batch of steps, the machine zero of an assembly, and the nominal rule that takes a marked branch as NoTransform). The same native id always resolves to the same view, and so to the same transformer object.

public class Branch
Inheritance
Branch
Inherited Members
Extension Methods

Properties

Arrow

Anchor from arrow side; null once the branch is broken.

public Anchor Arrow { get; }

Property Value

Anchor

Fletch

Anchor from fletch side; null once the branch is broken.

public Anchor Fletch { get; }

Property Value

Anchor

Guid

GUID.

public Guid Guid { get; }

Property Value

Guid

IndexXName

The XML element name used for indexing branches.

public static string IndexXName { get; }

Property Value

string

IndexXml

Get XML for indexing — the way a mechanism records which of its branches plays a role. Only the Guid takes effect when reading.

public XElement IndexXml { get; }

Property Value

XElement

The XML contains Guid and, when set, Name.

IsBreak

Is break: the native branch is gone — detached from this side, from an anchor's Detach(), or with a released component. Asks the native node while not yet known broken and latches the answer.

public bool IsBreak { get; }

Property Value

bool

IsErrorTerm

Whether the branch is an error term: it carries an error of the machine — the squareness of two linear axes, a pivot offset, an axis tilt, an offset of the machine zero — written as an ordinary static transformer, not a commanded motion.

The mark belongs to the branch, whatever its Transformer. The topology walks take a marked branch like any other, so the mechanism moves with its errors; the kinematics solver (XyzabcSolver) is the controller's model of the machine and takes every marked branch of its private clone as NoTransform, so the machine coordinates are solved on the nominal chain. The runtime face of a machining equipment follows the project switch (EnableErrorTerms): while the switch is off, that face takes the marked branches as NoTransform as well (MaterialiseMachiningEquipment(string, IProgress<IMessage>, bool)), so the machine itself is the nominal machine; the mark stays, and the authored face keeps the authored transformers. A branch that plays a role — an axis or the spindle of a machine tool, the key branch of a CL device — cannot be an error term (RequireRoleBranchesNotErrorTerm(IMachiningChain)).

A new branch is unmarked. The mark is written to XML only when set, is copied to the twin by TopoReflection, and goes with the branch when it is detached: a broken branch (IsBreak) reads unmarked, whatever was set on its view. An XML attribute value that is not a boolean reads unmarked and is reported at load, as a Branch-IsErrorTerm--Unreadable configuration warning that names the branch.

public bool IsErrorTerm { get; set; }

Property Value

bool

Name

Gets or sets the name of the branch.

public string Name { get; set; }

Property Value

string

Step

If the Transformer is IDynamicRegular, the property is delegated from IDynamicRegular.Step; otherwise, the getter returns NAN and setter does nothing.

public double Step { get; set; }

Property Value

double

Transformer

Transformer: the managed object bound to this branch, or null for a branch without one.

The getter materializes the object from the native node on first access and binds it, so every mutation made through it (including on a nested member of a GeneralTransform or StackTransformer) is pushed to the node; afterwards it returns that same object — the first access is serialized on a private gate, so concurrent first readers get the one object too. The setter writes the value to the native node, unbinds the object it replaces and binds the new one to this branch. An object already bound to another branch is re-bound here — last writer wins: the other branch keeps the value it has, but later mutations of the object reach this branch only.

public ITransformer Transformer { get; set; }

Property Value

ITransformer

Methods

Attach(IGetAnchor, IGetAnchor)

Attempts to attach two anchors.

public static Branch Attach(IGetAnchor fletch, IGetAnchor arrow)

Parameters

fletch IGetAnchor

See Fletch

arrow IGetAnchor

See Arrow

Returns

Branch

branch

Attach(IGetAnchor, IGetAnchor, ITransformer)

Attempts to attach two anchors with a specified transformer.

public static Branch Attach(IGetAnchor fletch, IGetAnchor arrow, ITransformer transformer)

Parameters

fletch IGetAnchor

See Fletch

arrow IGetAnchor

See Arrow

transformer ITransformer

See Transformer

Returns

Branch

branch

AttachIfAbsence(IGetAnchor, IGetAnchor)

Attempts to attach two anchors if they are not already connected. If the anchors are already connected, returns null instead of throwing an exception.

public static Branch AttachIfAbsence(IGetAnchor fletch, IGetAnchor arrow)

Parameters

fletch IGetAnchor

The fletch-side anchor to attach

arrow IGetAnchor

The arrow-side anchor to attach

Returns

Branch

The newly created branch if successful, null if the anchors are already connected

Detach()

Break the branch.

public void Detach()

Detach(IGetAnchor, IGetAnchor)

Break the branch from Get(IGetAnchor, IGetAnchor).

public static void Detach(IGetAnchor fletch, IGetAnchor arrow)

Parameters

fletch IGetAnchor

See Fletch

arrow IGetAnchor

See Arrow

Exceptions

InvalidOperationException

The exception is throwed if the Branch is not existed.

DetachIfExisted(IGetAnchor, IGetAnchor)

Break the branch from Get(IGetAnchor, IGetAnchor).

public static bool DetachIfExisted(IGetAnchor fletch, IGetAnchor arrow)

Parameters

fletch IGetAnchor

See Fletch

arrow IGetAnchor

See Arrow

Returns

bool

true if the Branch existed and then been deteched.

Get(IGetAnchor, IGetAnchor)

Get existed Branch by fletchSource and arrowSource.

public static Branch Get(IGetAnchor fletchSource, IGetAnchor arrowSource)

Parameters

fletchSource IGetAnchor

fletch

arrowSource IGetAnchor

arrow

Returns

Branch

The branch. If branch not exist, return null.

GetByIndexXml(XElement, Dictionary<Guid, Branch>)

Gets a branch from its XML index representation using a GUID-to-Branch dictionary.

public static Branch GetByIndexXml(XElement src, Dictionary<Guid, Branch> guidToBrnDictionary)

Parameters

src XElement

The source XML element containing the branch index information.

guidToBrnDictionary Dictionary<Guid, Branch>

Dictionary mapping GUIDs to Branch objects, as CallAsmb(XElement, string, Dictionary<Guid, Asmb>, Dictionary<Guid, Anchor>, Dictionary<Guid, Branch>, IProgress<IMessage>) fills it.

Returns

Branch

The branch the index names, or null when the dictionary has no branch of that Guid.

IsExisted(IGetAnchor, IGetAnchor)

Checks if a branch exists between two anchors.

public static bool IsExisted(IGetAnchor fletch, IGetAnchor arrow)

Parameters

fletch IGetAnchor

The fletch-side anchor.

arrow IGetAnchor

The arrow-side anchor.

Returns

bool

True if a branch exists between the anchors, false otherwise.

ToLinkString()

Get brief link description.

public string ToLinkString()

Returns

string

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.

TryAttach(IGetAnchor, IGetAnchor, ITransformer)

Attempts to attach two anchors with a specified transformer. If the attachment fails, returns null instead of throwing an exception.

public static Branch TryAttach(IGetAnchor fletch, IGetAnchor arrow, ITransformer transformer)

Parameters

fletch IGetAnchor

The fletch-side anchor to attach

arrow IGetAnchor

The arrow-side anchor to attach

transformer ITransformer

The transformer to use for the branch

Returns

Branch

The newly created branch if successful, null if the attachment fails