Class NCWord
"NCWord", or in other words "Register", is an object that helps you quickly and conveniently convert numeric or string values to a text format that the CNC machine understands. For example, you can easily convert the coordinate value x = 5.18 to the string "X0005.180". This corresponds approximately to one word in the output G-code.
Optionally, NCWord can also help you to filter the output. It contains two values - current v and previous v0 (which has already been output earlier). If both of these values are the same, then re-output the value can be skipped automatically.
Namespace: DotnetPostprocessing.SDK
Assembly: DotnetPostprocessing.SDK.dll
Syntax
public abstract class NCWord : Object
Constructors
NCWord()
Creates a new instance of an NCWord and initializes it's state.
Declaration
public NCWord()
Properties
Address
First part of the NCWord's output string that will output directly without any changes. For example, if the NCWord has a format like "< X >{-000.000}< /X >", then the Address is "< X >". An expression in curly braces is a part automatically formed from the value.
Declaration
public string Address { get; set; }
Property Value
Type | Description |
---|---|
string |
AutoUpdateState
The "AutoUpdateState" property determines whether the NCWord State should be automatically updated when the current v or previous v0 value changes. Default is "True".
Declaration
public bool AutoUpdateState { get; set; }
Property Value
Type | Description |
---|---|
bool |
Changed
Returns "True" if the NCWord is in the "Changed" state, otherwise returns "False". It means that the NCWord will output on the next call of Out() or Form().
It doesn't check the actual equality of the current v and previous v0 values. You can use ValuesSame or ValuesDiffer properties for this.
Declaration
public bool Changed { get; }
Property Value
Type | Description |
---|---|
bool |
Disabled
Returns "True" if the NCWord is in the "Disabled" state, otherwise returns "False". It means that the NCWord will not be output by the block at all and will not change its state until it is explicitly switched to another state (using Show() or Hide()).
Declaration
public bool Disabled { get; }
Property Value
Type | Description |
---|---|
bool |
Marked
The "Marked" property means nothing for the postprocessing system. It doesn't check it at all. So the developer of a postprocessor can use it for their own purposes. For example, you can loop through all the NCWord from an NCBlock and mark with this flag only those that you need in a particular case. After that you can use foreach cycle with the NCBlock.MarkedWords collection to quick loop through the marked words only.
You can use also the SetMarks(bool) method to simply set the Marked flag to a desired value for all words of the NCBlock.
For example:
nc.Block.SetMarks(false);
nc.X.Marked = true;
nc.Y.Marked = true;
nc.Z.Marked = true;
string s = "";
foreach (NCWord w in nc.Block.MarkedWords) {
s = s + w.ToString();
}
nc.WriteLine(s);
Declaration
public bool Marked { get; set; }
Property Value
Type | Description |
---|---|
bool |
State
The state of the NCWord. It affects whether or not this NCWord will be output to the file on the next call of Out() or Form(). It can be Unchanged, Changed or Disabled.
Declaration
public NCWordState State { get; protected set; }
Property Value
Type | Description |
---|---|
NCWordState |
TailString
Final part of the NCWord's output string that will output directly without any changes. For example, if the NCWord has a format like "< X >{-000.000}< /X >", then the TailString is "< /X >". An expression in curly braces is a part automatically formed from the value.
Declaration
public string TailString { get; set; }
Property Value
Type | Description |
---|---|
string |
Unchanged
Returns "True" if the NCWord is in the "Unchanged" state, otherwise returns "False". It means that the NCWord will NOT output on the next call of Out() or Form().
It doesn't check the actual equality of the current v and previous v0 values. You can use ValuesSame or ValuesDiffer properties for this.
Declaration
public bool Unchanged { get; }
Property Value
Type | Description |
---|---|
bool |
Unstable
Returns "True" if the NCWord is in the so-called "Unstable" state after the call of Reset() method. Actually it checks that the previous v0 value is equal to the "undefined" value ("double.MaxValue" for the NumericNCWord and "null" for the TextNCWord). This state means that the NCWord will NOT output on the next call of Out() or Form(). But it will output just after the first change of the current v value.
Declaration
public virtual bool Unstable { get; }
Property Value
Type | Description |
---|---|
bool |
ValuesDiffer
The property is "True" only if the current value v and the previous value v0 form a different output string.
Declaration
public abstract bool ValuesDiffer { get; }
Property Value
Type | Description |
---|---|
bool |
ValuesSame
The property is "True" only if the current value v and the previous value v0 form a completely identical output string.
Declaration
public abstract bool ValuesSame { get; }
Property Value
Type | Description |
---|---|
bool |
Methods
Disable()
Switches the NCWord to the Disabled state. It means that the NCWord will not be output by the block at all and will not change its state until it is explicitly switched to another state (using Show() or Hide()).
It doesn't change the current v or previous v0 value of the NCWord.
Declaration
public void Disable()
Hide()
Switches the NCWord to the Unchanged state. It means that the NCWord will NOT output on the next call of Out() or Form().
It doesn't change the current v or previous v0 value of the NCWord.
Later you can use the UpdateState() method to restore the changed-unchanged state depend on equality ot the v and v0.
Declaration
public void Hide()
Init()
This method initializes an internal state of the NCWord just after creation.
Declaration
protected virtual void Init()
Reset()
Switches the NCWord to the Unchanged state and changes the previous v0 value to an undefined value ("double.MaxValue" for the NumericNCWord and "null" for the TextNCWord). It means that the NCWord will NOT output on the next call of Out() or Form(). But it will output just after the first change of the current v value.
It is the so-called "Unstable" state.
It doesn't change the current v value of the NCWord.
Declaration
public abstract void Reset()
RestoreDefaultValue(bool)
Assigns the default value of the NCWord to it's current value v and previous value v0. Depend on the "show" parameter it switches the state to Unchanged (show=false) or Changed (show=true).
Declaration
public abstract void RestoreDefaultValue(bool show)
Parameters
Type | Name | Description |
---|---|---|
bool | show | If "show" is "false" then it switches the state to Unchanged. If "show" is "true" then it switches the state to Changed. |
Show()
Switches the NCWord to the Changed state. It means that the NCWord will output on the next call of Out() or Form().
It doesn't change the current v or previous v0 value of the NCWord.
Declaration
public void Show()
UpdateState()
Switches the State of the NCWord to Changed or Unchanged depend on the current v and previous v0 values. If the values are same then the state will "Unchanged", otherwise it will "Changed".
If the NCWord is Disabled or has the AutoUpdateState=false then the method does nothing.
Declaration
public abstract void UpdateState()