Class NCBlock
The object that contains the list of registers (NCWord) and helps make output lines for a resulting file (G-code, TTextNCFile). First, it organizes the formatted output of the register values from its list. Secondly, it filters (excludes from the output string) those registers whose values have not changed since the previous output.
Inheritance
Implements
Inherited Members
Namespace: SprutTechnology.SCPostprocessor
Assembly: SCPostprocessor.dll
Syntax
public class NCBlock : IEnumerable
Constructors
NCBlock(INCBlockOwner)
Initializes the new instance of the NCBlock and assigns the specified object as an owner of this block.
Declaration
public NCBlock(INCBlockOwner owner)
Parameters
Type | Name | Description |
---|---|---|
INCBlockOwner | owner | The owner object of the NCBlock. Usually this is a TTextNCFile to which the output string should be written. |
NCBlock(INCBlockOwner, NCWord[])
Initializes the new instance of the NCBlock and assigns the specified object as an owner of this block.
Declaration
public NCBlock(INCBlockOwner owner, params NCWord[] words)
Parameters
Type | Name | Description |
---|---|---|
INCBlockOwner | owner | The owner object of the NCBlock. Usually this is a TTextNCFile to which the output string should be written. |
NCWord[] | words | A comma-separated list of registers that should be added to this block. |
NCBlock(INCBlockOwner, String, NCWord[])
Initializes the new instance of the NCBlock and assigns the specified object as an owner of this block.
Declaration
public NCBlock(INCBlockOwner owner, string wordsSeparator, params NCWord[] words)
Parameters
Type | Name | Description |
---|---|---|
INCBlockOwner | owner | The owner object of the NCBlock. Usually this is a TTextNCFile to which the output string should be written. |
System.String | wordsSeparator | An additional string that will be added between each separate register value to the resulting output string of Out() or Form() methods. |
NCWord[] | words | A comma-separated list of registers that should be added to this block. |
Properties
FirstWord
Returns the first register (NCWord) from the list of this NCBlock.
Declaration
public NCWord FirstWord { get; }
Property Value
Type | Description |
---|---|
NCWord |
Item[Int32]
Provides access to an individual register from the block by its index in the list.
Declaration
public NCWord this[int index] { get; }
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | The zero based index of the register you want to get in the list of this block ([0..WordCount-1]). |
Property Value
Type | Description |
---|---|
NCWord | Returns the register (NCWord) with the specified index. It will throw an exception if the index is incorrect (exceeds the total count of registers) |
LastWord
Returns the last register (NCWord) from the list of this NCBlock.
Declaration
public NCWord LastWord { get; }
Property Value
Type | Description |
---|---|
NCWord |
MarkedWords
Returns the "list" of the register which has the Marked property equals to "true". Using it you can easily loop through the all marked registers with foreach cycle.
Declaration
public IEnumerable MarkedWords { get; }
Property Value
Type | Description |
---|---|
System.Collections.IEnumerable |
Remarks
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);
Owner
The owner object of the NCBlock. Usually this is a TTextNCFile to which the output string should be written.
Declaration
public INCBlockOwner Owner { get; set; }
Property Value
Type | Description |
---|---|
INCBlockOwner |
UnmarkedWords
Returns the "list" of the register which has the Marked property equals to "false". Using it you can easily loop through the all unmarked registers with foreach cycle.
Declaration
public IEnumerable UnmarkedWords { get; }
Property Value
Type | Description |
---|---|
System.Collections.IEnumerable |
Remarks
For example:
nc.Block.SetMarks(true);
nc.X.Marked = false;
nc.Y.Marked = false;
nc.Z.Marked = false;
string s = "";
foreach (NCWord w in nc.Block.UnmarkedWords) {
s = s + w.ToString();
}
nc.WriteLine(s);
WordCount
The total number of NCWords contained in this block.
Declaration
public int WordCount { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
WordsSeparator
An additional string that will be added between each separate register value to the resulting output string of Out() or Form() methods.
Declaration
public string WordsSeparator { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Methods
AddWord(NCWord)
Adds the specified register (NCWord) to the end of list of this NCBlock.
Declaration
public void AddWord(NCWord word)
Parameters
Type | Name | Description |
---|---|---|
NCWord | word | The register (NCWord) to add. |
AddWord(NCWord, NCWord)
Inserts the specified register (NCWord) to the exact position in the list of this NCBlock before the specified one.
Declaration
public void AddWord(NCWord word, NCWord beforeWord)
Parameters
Type | Name | Description |
---|---|---|
NCWord | word | The register (NCWord) to add. |
NCWord | beforeWord | Some another word from the list before which you want to add the word. |
AddWord(NCWord, Int32)
Inserts the specified register (NCWord) to the exact position in the list of this NCBlock.
Declaration
public void AddWord(NCWord word, int index)
Parameters
Type | Name | Description |
---|---|---|
NCWord | word | The register (NCWord) to add. |
System.Int32 | index | The index in the list to which you want to add the register. The all following registers starting from this position will be moved further. |
Form()
Forms the output line of this NCBlock in accordance with the current state of its registers.
It iterates through the all registers and if the register has a Changed state (often this means that the values of v and v0 are different), it calls the ToString() method of this register and adds it's result to the common resulting output line.
It doesn't write the resulting line to an output file.
If there are no changed registers in the list then the result is the empty string.
Declaration
public string Form()
Returns
Type | Description |
---|---|
System.String | The resulting output line with the content of all changed NCWords from the list. |
GetEnumerator()
Returns an enumerator of the all registers from this NCBlock to be possible to use for example the "foreach" cycle.
Declaration
public IEnumerator GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.IEnumerator | The enumerator of all registers from this NCBlock. |
Hide(NCWord[])
It calls the Hide() method for the all specified registers. This means that it switches the registers to the Unchanged state. It means that they will NOT output on the next call of Out() or Form().
It doesn't change the current v or previous v0 value of the registers.
Later you can use the UpdateState(NCWord[]) method to restore the changed-unchanged state depend on equality ot the v and v0.
Declaration
public void Hide(params NCWord[] words)
Parameters
Type | Name | Description |
---|---|---|
NCWord[] | words | The registers to be switched to unchanged state. |
IndexOfWord(NCWord)
Allows to find the index of specified register (NCWord) in the list of this NCBlock.
Declaration
public int IndexOfWord(NCWord word)
Parameters
Type | Name | Description |
---|---|---|
NCWord | word | The register index of which to find. |
Returns
Type | Description |
---|---|
System.Int32 | Returns the index of the register. If there is no such register in the list the resilt is "-1". |
Out()
Forms the output line of this NCBlock in accordance with the current state of its registers (using the Form() method) and writes it to the output file which is the Owner.
The writing performs to the position in file that the DefaultLabel points (in the most cases it is the end of file).
It writes the resulting string with the line break.
If there are no changed registers in the list then the method does nothing.
This method is fully the same with WriteLine() (it calls this inside).
So the purpose of this method is to be short and ideological compatibility with
the Postprocessors generator's OutBlock
routine.
Declaration
public void Out()
Out(INCLabel)
Forms the output line of this NCBlock in accordance with the current state of its registers (using the Form() method) and writes it to the output file which is the Owner.
The writing performs to the position in file that the specifed INCLabel points.
It writes the resulting string with the line break.
If there are no changed registers in the list then the method does nothing.
This method is fully the same with WriteLine(INCLabel) (it calls this inside).
So the purpose of this method is to be short and ideological compatibility with
the Postprocessors generator's OutBlock
routine.
Declaration
public void Out(INCLabel label)
Parameters
Type | Name | Description |
---|---|---|
INCLabel | label | The label that defines the position in file to which the resulting string should be written. |
RemoveWord(NCWord)
Removes the specified register (NCWord) from the list of this NCBlock.
Declaration
public void RemoveWord(NCWord word)
Parameters
Type | Name | Description |
---|---|---|
NCWord | word | The register to remove from the list. |
Reset(NCWord[])
It calls the Reset() method for the all specified registers. This means that it switches the registers 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 they will NOT output on the next call of Out() or Form(). But they will output just after the first change of the current v value.
It is the so-called "Unstable" state of registers.
It doesn't change the current v value of the registers.
Declaration
public void Reset(params NCWord[] words)
Parameters
Type | Name | Description |
---|---|---|
NCWord[] | words | The registers to be switched to unstable state. |
SetMarks(Boolean)
Sets the Marked property to the specified value for the all registers of this NCBlock.
Declaration
public void SetMarks(bool value)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | value | The value with which it should mark the registers. |
Show(NCWord[])
It calls the Show() method for the all specified registers. This means that it switches the registers to the Changed state. It means that they will output on the next call of Out() or Form().
It doesn't change the current v or previous v0 value of the registers.
Declaration
public void Show(params NCWord[] words)
Parameters
Type | Name | Description |
---|---|---|
NCWord[] | words | The registers to be switched to changed state. |
UpdateState(NCWord[])
It calls the UpdateState() method for the all specified registers. This means that it switches the registers to Changed or Unchanged state depend on the current v and previous v0 values. If the values are same then the state will be "Unchanged", otherwise it will be "Changed".
Declaration
public void UpdateState(params NCWord[] words)
Parameters
Type | Name | Description |
---|---|---|
NCWord[] | words | The registers to update state. |
Write()
Forms the output line of this NCBlock in accordance with the current state of its registers (using the Form() method) and writes it to the output file which is the Owner.
The writing performs to the position in file that the DefaultLabel points (in the most cases it is the end of file).
No line break is added.
If there are no changed registers in the list then the method does nothing.
Declaration
public void Write()
Write(INCLabel)
Forms the output line of this NCBlock in accordance with the current state of its registers (using the Form() method) and writes it to the output file which is the Owner.
The writing performs to the position in file that the specifed INCLabel points.
No line break is added.
If there are no changed registers in the list then the method does nothing.
Declaration
public void Write(INCLabel label)
Parameters
Type | Name | Description |
---|---|---|
INCLabel | label | The label that defines the position in file to which the resulting string should be written. |
WriteLine()
Forms the output line of this NCBlock in accordance with the current state of its registers (using the Form() method) and writes it to the output file which is the Owner.
The writing performs to the position in file that the DefaultLabel points (in the most cases it is the end of file).
It writes the resulting string with the line break.
If there are no changed registers in the list then the method does nothing.
Declaration
public void WriteLine()
WriteLine(INCLabel)
Forms the output line of this NCBlock in accordance with the current state of its registers (using the Form() method) and writes it to the output file which is the Owner.
The writing performs to the position in file that the specifed INCLabel points.
It writes the resulting string with the line break.
If there are no changed registers in the list then the method does nothing.
Declaration
public void WriteLine(INCLabel label)
Parameters
Type | Name | Description |
---|---|---|
INCLabel | label | The label that defines the position in file to which the resulting string should be written. |