Class SoftNcOptProc
SoftNc NC-optimization orchestrator: classifies the final-layer SyntaxPiece stream (NcOptPieceClassifier), solves the per-step feed adjustments (StepFeedSolver), regenerates the NC text through the mixed patch/splition writeback (NcOptMixedPatchConverter over NcPatchWriter) and writes the optimized files.
public class SoftNcOptProc
- Inheritance
-
SoftNcOptProc
- Inherited Members
- Extension Methods
Remarks
Ported from HiNc NcOptProc.Optimize / OptimizeToFiles /
GetOptNcLines (frozen HardNc baseline,
HiNc/NcOpt/NcOptProc.cs lines 2042-2401 and 2423-2567). Message ids
and stage ordering mirror the HardNc pipeline. Text regeneration replaces
the HardNc line re-synthesis with anchored token edits over the verbatim
block text (patch mode) — untouched lines round-trip byte-identically —
and, for SplitionPiecePack pieces, with the per-fragment
text rewrite planned by BuildSplitionPlan(SplitionPiecePack, List<INcOptPiecePack>, int, SortedList<int, NcOptOption>, int, List<MachiningStep>, string, NcTagValueKind, FileWritebackGroup, double, ref double, ref double, IProgress<IMessage>, NcDiagnosticProgress, ref bool, ref bool) (P2).
Compensation stage: when any seed option carries a non-zero CompensationMask, BuildCompensation(ICuttingPara, List<INcOptPiecePack>, List<MachiningStep>, SortedList<int, NcOptOption>, IProgress<IMessage>) fills the PACK adjustments (the fixed handoff — the HardNc baseline wrote the context side the output never read, see the method remarks) and the splition plan builder consumes them: the essential filter keeps compensated fragments and their neighbors, and each fragment endpoint is offset by the tool-running compensation vector rotated into the program frame (CdnTransformToolRunningToProgram). With no mask set anywhere the build call is skipped (only the stage-parity message is emitted) and every adjustment keeps its null compensation — the whole flow is a strict no-op.
Methods
GetMachineRapidFeedrate_mmds(MachiningSession)
Resolves the machine rapid traverse feedrate in mm/s from the session's
effective dependency list — the SoftNc equivalent of
HardNcEnv.RapidFeedrate_mmds.
public static double GetMachineRapidFeedrate_mmds(MachiningSession machiningSession)
Parameters
machiningSessionMachiningSessionThe machining session; may be null.
Returns
Remarks
The source is the maximum linear-axis (X/Y/Z) rate of the pipeline's
IRapidFeedrateConfig (the brand parameter table, e.g.
Fanuc #1420). For legacy projects this equals the HardNc value exactly:
SoftNcRunner.PopulateLegacyMachineConfig
(SoftNcRunner.cs:935-943) writes the legacy
HardNcEnv XML RapidFeedrate_mmdmin onto all three linear
axes, and the unconfigured-table default (20000 mm/min,
ControllerParameterTableBase.cs:39) matches the
HardNcEnv default (HardNcEnv.cs:252). Returns NaN when no
config is reachable (no played session state); callers then fall back
per piece via
ResolveRapidFeedrate_mmds(double, List<MachiningStep>, IndexSegment), or — for
the modal-F register seeds and the pre-first-F modal fallback — to the
20000 mm/min sentinel via
GetEffectiveMachineRapidFeedrate_mmds(double).
OptimizeToFiles(ICuttingPara, MachiningSession, IReadOnlyList<SyntaxPiece>, List<MachiningStep>, MachiningToolHouse, string, string, IProgress<IMessage>, NcDiagnosticProgress, CancellationToken, Func<int, MillingStepLuggage>, Action)
Optimizes the played NC program and writes the optimized files.
public List<NcConversion> OptimizeToFiles(ICuttingPara millingPara, MachiningSession machiningSession, IReadOnlyList<SyntaxPiece> finalLayerPieces, List<MachiningStep> machiningSteps, MachiningToolHouse machiningToolHouse, string baseDirectory, string relFileTemplate, IProgress<IMessage> mixedProgress, NcDiagnosticProgress conversionProgress, CancellationToken cancellationToken, Func<int, MillingStepLuggage> luggageGetter, Action clearLuggageCache)
Parameters
millingParaICuttingParaThe cutting parameters; null disables physics-computable optimization.
machiningSessionMachiningSessionThe machining session; supplies StepIndexToNcOptOptionSortedList, the writeback identity counters and the NcOptimizations retention list (cleared at the start of each run).
finalLayerPiecesIReadOnlyList<SyntaxPiece>Final-layer syntax pieces in execution order, init seed filtered.
machiningStepsList<MachiningStep>The raw strip-pose step projection, UNFILTERED, in strip order (a strip pos without a machining step contributes a null entry) — mirrors the oracle's unfiltered read (
NcOptProc.cs:2521), so a step's list position always equals StepIndex; every step-keyed dictionary of the pipeline lives in that single index space.machiningToolHouseMachiningToolHouseThe machining tool house.
baseDirectorystringBase directory the output paths are combined against.
relFileTemplatestringRelative output path template; RelNcFileTemplateReplacingKeyword and NcNameTemplateReplacingKeyword are expanded per source file.
mixedProgressIProgress<IMessage>The message host for lifecycle / progress logging.
conversionProgressNcDiagnosticProgressDiagnostic home for piece-anchored optimization diagnostics.
cancellationTokenCancellationTokenCancellation token to cancel the operation.
luggageGetterFunc<int, MillingStepLuggage>Maps a step index to its MillingStepLuggage; must be thread safe (called from the solver's parallel workers).
clearLuggageCacheActionOptional cache-clear hook invoked at the end of the run (mirrors the HardNc
MillingStepLuggageReader.ClearCache()tail).
Returns
- List<NcConversion>
The writeback conversions of the written files (also retained in NcOptimizations).