Class NcResultReview
- Namespace
- Hi.MachiningProcs
- Assembly
- HiNc.dll
Internal Use Only. One recorded play result open for review on the host (the NC play result recording's P4): the result file (SqliteNcResultReader, read-only) and what the host counted while it rebuilt its strip, its steps and its physics channels from it. While a review is open the host's strip is the result's, its step reads (the two briefs) come from the file, and the panels that show a source program read the pieces through this object (FindPieceIds(int, int), FindPieceAddresses(int, int, int), TryGetSyntaxPiece(int, out SyntaxPieceRecord), TryGetStepRangeOfPiece(int, out int, out int)). Any thread may read it, during the fill too: the reader's members run under the reader's own lock, the piece-to-step table is a concurrent dictionary the fill adds to, and the counts are plain integers the fill writes (a read in the middle of the fill sees the count so far). Disposed by the host when the review closes (CloseNcResultReview(IProgress<IMessage>), every reset path): a reader-backed query after that throws ObjectDisposedException, while Directory, DatabasePath, Meta, NcFiles, the counts and TryGetStepRangeOfPiece(int, out int, out int) stay readable (the web service's status reads them after a close).
public sealed class NcResultReview : IDisposable
- Inheritance
-
NcResultReview
- Implements
- Inherited Members
- Extension Methods
Properties
BriefCount
How many of the rebuilt steps had a brief record in the file (a brief without a step – the step dropped, or its chunk never reached the file – is not counted, so this may be below BriefCount); counted by the fill.
public int BriefCount { get; }
Property Value
DatabasePath
The result file's full path.
public string DatabasePath { get; }
Property Value
Directory
The result folder (the parent of the result file), as the host resolved it.
public string Directory { get; }
Property Value
FirstStepIndex
The smallest step index the file holds a row for (StepIndexRange): the first step the strip was rebuilt with when the row's payload is in the file, else a position without a step; -1 for a result without a step row. For the tests (the status reads StripOffset and the counts).
public int FirstStepIndex { get; }
Property Value
LastStepIndex
The largest step index the file holds a row for (StepIndexRange): the last step the strip was rebuilt with when the row's payload is in the file (a crashed recording's last rows may have none), else a position without a step; -1 for a result without a step row. For the tests.
public int LastStepIndex { get; }
Property Value
Meta
The result file's metadata (Meta): whether the recording completed and the play ran to its end, the writer's counts (null for a crashed recording), the stock's name and hash.
public NcResultMeta Meta { get; }
Property Value
NcFiles
The result's NC source files by file index (NcFiles): a row a file index, with the first path recorded for it; a file read several times, or entered by a jump, has several.
public IReadOnlyList<NcResultSourceFile> NcFiles { get; }
Property Value
NodeRebind
What the rebind of the loaded stock's nodes to the review's strip positions did (the NC play result recording's P5; CubeTree's read with rebound attachments): the nodes read, those bound to a position, those bound to the plain stock, those left unattached. Null when the stock was not loaded or the result holds no node map (the stock shows plain).
public CubeTreeRebindStats? NodeRebind { get; }
Property Value
NodeRebindOrphanKeys
How many node keys of the result had no position on the review's strip (a key past the strip's end), left out of the rebind; 0 when none.
public int NodeRebindOrphanKeys { get; }
Property Value
NodeRebindPositions
How many strip positions the rebind paired a node key with; 0 when the stock was not rebound.
public int NodeRebindPositions { get; }
Property Value
OpenDuration
How long the fill took: the strip, the steps and the physics channels rebuilt, the stock loaded.
public TimeSpan OpenDuration { get; }
Property Value
OpenedUtc
When the review opened, in UTC.
public DateTime OpenedUtc { get; }
Property Value
PieceCount
How many pieces the recorder wrote (PieceCount), or, for a recording without counts, how many distinct pieces the rebuilt steps name.
public int PieceCount { get; }
Property Value
PieceIdsWithSteps
The piece ids a rebuilt step names, ascending: what TryGetStepRangeOfPiece(int, out int, out int) knows (a snapshot, sorted on each read). For the tests.
public IEnumerable<int> PieceIdsWithSteps { get; }
Property Value
PositionCount
How many strip positions the file held (the positions the recorder took); counted by the fill.
public int PositionCount { get; }
Property Value
StepCount
How many steps were rebuilt (a row whose payload the file holds); counted by the fill.
public int StepCount { get; }
Property Value
StripOffset
The positions the host put before the result's first one so that the strip's indices are the file's: a recording begun in the middle of a mission starts above 0, and the panels, the step reads and the physics channels are keyed by the position's index. 0 for a result that starts at 0. The padding positions hold no step and sit at the first recorded CL.
public int StripOffset { get; }
Property Value
WctColoured
Whether the loaded stock is coloured and picked by the review's steps: the result held a node map and it bound at least one node to a position.
public bool WctColoured { get; }
Property Value
WctPath
The stock file's full path when the result names one, whether or not it was loaded; null otherwise.
public string WctPath { get; }
Property Value
WctState
What became of the finished stock (finish.wct) when the review opened.
public NcResultWctState WctState { get; }
Property Value
Methods
Dispose()
Closes the result file. Idempotent; a reader-backed query after it throws ObjectDisposedException, while the metadata, the counts and the piece-to-step table stay readable.
public void Dispose()
FindFileIndices(string)
The file indices recorded for a source file's path (compared ordinally, as the sentences record it), ascending; empty for a path the result does not know. For the tests and a panel to come; the panels of the moment key by file index.
public IReadOnlyList<int> FindFileIndices(string filePath)
Parameters
filePathstringThe source file's path.
Returns
- IReadOnlyList<int>
The file indices.
FindPieceAddresses(int, int, int)
Internal Use Only (the NC play result review). Finds the pieces whose sentence begins in one
file index (as FindPieceIds(int, int) takes it) at a line of [lineBegin, lineEnd):
the page of line marks a source panel shows, read in one query on the address index instead
of one a line, each piece's sentence index off its index row, no chunk decoded. The addresses
come by line, then by piece id (a line with several pieces – a loop, a recording that went on
across a reset – answers several), and only of pieces whose chunk the file holds; empty for a
file index or a range the file does not know.
public List<NcResultPieceAddress> FindPieceAddresses(int fileIndex, int lineBegin, int lineEnd)
Parameters
fileIndexintThe file index.
lineBeginintThe first 0-based line index (inclusive); a negative one counts as 0.
lineEndintThe line index past the last (exclusive); at or below the first, the range is empty.
Returns
- List<NcResultPieceAddress>
The pieces' addresses, by line then by id.
Exceptions
- ObjectDisposedException
The reader was disposed, the range empty or not.
FindPieceIds(int, int)
Internal Use Only (the NC play result review). Finds the ids of the pieces whose sentence begins at a line of one file index (one entry or control-flow jump into a source file, as NcFiles lists them), the 0-based line index: the address the host's source panels key their pieces by. The ids come by id, and only of pieces whose chunk the file holds; empty for an address the file does not know. One query on the address index.
public List<int> FindPieceIds(int fileIndex, int lineIndex)
Parameters
Returns
Exceptions
- ObjectDisposedException
The reader was disposed.
FindPieceIds(string, int)
Finds the ids of the pieces whose sentence begins at a line of a source file: the file's path as the sentences record it (compared ordinally, not normalised), the 0-based line index. A path has a file index for every entry and every control-flow jump into it, so a line can answer several pieces (a loop, a subprogram); the ids come by id, and only of pieces whose chunk the file holds. Empty for a path or a line the file does not know. One query, whose cost grows with the path's file indices; a piece is found under the path first recorded for its file index (NcFiles).
public List<int> FindPieceIds(string filePath, int lineIndex)
Parameters
Returns
Remarks
For the tests; the panels key by file index (FindPieceIds(int, int), FindPieceAddresses(int, int, int)).
Exceptions
- ArgumentNullException
filePathis null.- ObjectDisposedException
The reader was disposed.
FindStepBriefs(int, int)
Reads the briefs of the steps whose index is in [beginIndex, endIndex), by
index, each as TryGetStepBrief(int, out StepBrief) reads it; a step without a brief record is
skipped, a brief chunk the file does not hold skipped whole. Each brief chunk the window
crosses is decoded once. The list holds the whole window: a scan reads a window at a time.
public List<StepBrief> FindStepBriefs(int beginIndex, int endIndex)
Parameters
beginIndexintThe first index (inclusive); a negative one counts as 0.
endIndexintThe index past the last (exclusive); at or below the first, the window is empty.
Returns
Exceptions
- InvalidDataException
A brief chunk or record in the window is not what this build reads.
- ObjectDisposedException
The reader was disposed, the window empty or not.
TryGetStepBlockText(int, out string)
Reads the block text of a step's sentence off its piece's index row, without decoding a chunk (a piece whose chunk never reached the file still answers): false when the file has no row for the step or the step names no piece the file holds a row for; true with a null text when the sentence had none.
public bool TryGetStepBlockText(int stepIndex, out string blockText)
Parameters
stepIndexintThe step's index.
blockTextstringThe block text; null when the sentence had none or the answer is false.
Returns
- bool
True when the file holds the step's row and its piece's row.
Remarks
For the tests; the panels read the step's SourceCommand on the strip.
Exceptions
- ObjectDisposedException
The reader was disposed.
TryGetStepBrief(int, out StepBrief)
Reads a step's two briefs from the brief chunk: the force brief (null for the null record, the physics not run on the step) and the sequential physics state. The briefs are recorded apart from the step, so a step the file holds may have none: briefs the recorder never added, or a brief chunk that never reached the file.
public bool TryGetStepBrief(int stepIndex, out StepBrief brief)
Parameters
stepIndexintThe step's index.
briefStepBriefThe briefs; null when the file holds no brief record for the step.
Returns
- bool
True when the file holds the step's brief record; false for a negative index too.
Exceptions
- InvalidDataException
The brief chunk or the record is not what this build reads.
- ObjectDisposedException
The reader was disposed.
TryGetStepRangeOfPiece(int, out int, out int)
The steps a piece built, as the fill rebuilt them: the smallest and the largest step index
whose record names pieceId (the piece's steps are consecutive, since a
piece's steps are built before the next piece's). False for a piece no rebuilt step names –
a piece that built no step, one the recording never stored a step for, or one whose steps'
chunk never reached the file. Readable while the fill runs (the range then grows at its end).
public bool TryGetStepRangeOfPiece(int pieceId, out int first, out int last)
Parameters
Returns
- bool
True when a rebuilt step names the piece.
TryGetStepRow(int, out NcResultStepRow)
Reads a step's narrow row: its queryable scalars, without decoding its chunk (the piece id and the sentence index -1 where the column is NULL; NcResultStepRow says what each holds). A row may be committed before its chunk, so true here does not promise a record from TryGetMachiningStep(int, out MachiningStepRecord).
public bool TryGetStepRow(int stepIndex, out NcResultStepRow row)
Parameters
stepIndexintThe step's index.
rowNcResultStepRowThe row; default when the file has no row for the step.
Returns
- bool
True when the file holds the step's row.
Remarks
For the tests; the panels read the step's SourceCommand on the strip.
Exceptions
- ObjectDisposedException
The reader was disposed.
TryGetSyntaxPiece(int, out SyntaxPieceRecord)
Reads a piece's record: the snapshot of its sentence (the object the piece's steps carry while the piece chunk is cached) and a copy of its compact JSON (empty, with HasJson false, for a piece stored without one).
public bool TryGetSyntaxPiece(int pieceId, out SyntaxPieceRecord piece)
Parameters
pieceIdintThe piece's id.
pieceSyntaxPieceRecordThe record; null when the file has no row for the id or no chunk for the row.
Returns
- bool
True when the file holds the piece.
Exceptions
- InvalidDataException
The piece chunk or the entry is not what this build reads.
- ObjectDisposedException
The reader was disposed.