Table of Contents

Class MachiningProject

Namespace
Hi.MachiningProcs
Assembly
HiNc.dll

Represents a milling project that manages the execution, simulation, and analysis of NC programs.

public class MachiningProject : IDisposable, IMachiningStepHost, IGetMachiningEquipment, IMakeXmlSource
Inheritance
MachiningProject
Implements
Inherited Members
Extension Methods

Constructors

MachiningProject(string)

Initializes a new instance of the MachiningProject class with the specified directory. Uses the default MongoDB connection.

public MachiningProject(string baseDirectory)

Parameters

baseDirectory string

Base directory for file operations

MachiningProject(string, MongoClient)

Initializes a new instance of the MachiningProject class with the specified directory and MongoDB client.

public MachiningProject(string baseDirectory, MongoClient mongoClient)

Parameters

baseDirectory string

Base directory for file operations

mongoClient MongoClient

MongoDB client instance

MachiningProject(XElement, string)

Initializes a new instance of the MachiningProject class from XML data using MongoDB.

public MachiningProject(XElement src, string baseDirectory)

Parameters

src XElement

XML element containing configuration data

baseDirectory string

Base directory for resolving relative paths

MachiningProject(XElement, string, MongoClient)

Initializes a new instance of the MachiningProject class from XML data.

public MachiningProject(XElement src, string baseDirectory, MongoClient mongoClient)

Parameters

src XElement

XML element containing configuration data

baseDirectory string

Base directory for resolving relative paths

mongoClient MongoClient

MongoDB client instance

Properties

ApiVersion

Gets the API version from the entry assembly.

public static Version ApiVersion { get; }

Property Value

Version

BaseDirectory

Gets the base directory where project files are located.

public string BaseDirectory { get; }

Property Value

string

BoundSelectorHost

Gets the bound selector host for managing selection boundaries.

public BoundSelectorHost BoundSelectorHost { get; }

Property Value

BoundSelectorHost

ClStrip

Gets the cutter location strip.

public ClStrip ClStrip { get; }

Property Value

ClStrip

CoordinateEntryDisplayee

Gets the displayee for coordinate entry visualization.

public CoordinateEntryDisplayee CoordinateEntryDisplayee { get; }

Property Value

CoordinateEntryDisplayee

DictionaryColorGuide

Gets the color guide for dictionary-based coloring.

public DictionaryColorGuide DictionaryColorGuide { get; }

Property Value

DictionaryColorGuide

DispCacheMb

Gets or sets the display cache size in megabytes.

public static long DispCacheMb { get; set; }

Property Value

long

EnableCollisionDetection

Gets or sets whether collision detection is enabled. When set to true, initializes collision detection mechanism.

public bool EnableCollisionDetection { get; set; }

Property Value

bool

EnablePauseOnFailure

Enable Pause On Failure Detected. Only take effect if the EnableCollisionDetection or EnableStrokeLimitCheck is enabled.

public bool EnablePauseOnFailure { get; set; }

Property Value

bool

EnableStrokeLimitCheck

public bool EnableStrokeLimitCheck { get; set; }

Property Value

bool

Global

global variable for ShellApi. Not save on XML.

public Dictionary<object, object> Global { get; set; }

Property Value

Dictionary<object, object>

InspectingKey

Gets or sets the current inspecting key for visualization. When set, updates the inspecting quantity function.

public string InspectingKey { get; set; }

Property Value

string

InspectingQuantityFunc

Gets the function that retrieves the quantity value for the current inspecting key.

public Func<MachiningStep, double?> InspectingQuantityFunc { get; }

Property Value

Func<MachiningStep, double?>

MachiningActRunner

Gets the machining act runner responsible for executing machining operations.

public MachiningActRunner MachiningActRunner { get; }

Property Value

MachiningActRunner

MachiningEquipment

Gets or sets the machining equipment used for milling. Updates related components when changed.

public MachiningEquipment MachiningEquipment { get; set; }

Property Value

MachiningEquipment

MachiningSession

Gets or sets the current machining session.

public MachiningSession MachiningSession { get; set; }

Property Value

MachiningSession

MachiningToolHouse

Gets or sets the milling tool house containing available tools.

public MachiningToolHouse MachiningToolHouse { get; set; }

Property Value

MachiningToolHouse

MachiningToolHouseFile

Gets or sets the file path to the milling tool house configuration.

public string MachiningToolHouseFile { get; set; }

Property Value

string

MillingActRunnerConfig

Gets or sets the configuration for the milling act runner.

public MillingActRunnerConfig MillingActRunnerConfig { get; set; }

Property Value

MillingActRunnerConfig

MillingGuide

Gets or sets the milling guide containing visualization and analysis configurations.

public MillingGuide MillingGuide { get; set; }

Property Value

MillingGuide

MillingStepLuggageReader

Gets the reader for accessing milling step luggage data.

public ParallelBulkReader<MillingStepLuggage> MillingStepLuggageReader { get; }

Property Value

ParallelBulkReader<MillingStepLuggage>

NcEnv

public NcEnv NcEnv { get; }

Property Value

NcEnv

NcOptProc

Gets the NC optimization processor for optimizing NC programs.

public NcOptProc NcOptProc { get; }

Property Value

NcOptProc

NcRunner

Gets the NC runner responsible for executing NC programs.

public NcRunner NcRunner { get; }

Property Value

NcRunner

PacePlayer

Gets the pace player for controlling execution pace of milling operations.

public PacePlayer PacePlayer { get; }

Property Value

PacePlayer

PlayerCommand

Gets the command to execute when playing the machining project.

public IShellCommand PlayerCommand { get; }

Property Value

IShellCommand

Progress

Gets the progress reporting mechanism for long-running operations.

public Progress<IProgressReport> Progress { get; }

Property Value

Progress<IProgressReport>

SessionMessageHost

Gets the message host for displaying messages, warnings, and errors.

public SessionMessageHost SessionMessageHost { get; }

Property Value

SessionMessageHost

ShellApi

Gets the shell API for interacting with this machining process.

public ShellApi ShellApi { get; }

Property Value

ShellApi

StepPropertyAccessDictionary

Gets the dictionary mapping property keys to their access methods.

public ConcurrentDictionary<string, PropertyAccess<MachiningStep>> StepPropertyAccessDictionary { get; }

Property Value

ConcurrentDictionary<string, PropertyAccess<MachiningStep>>

TimeMapping

Gets or sets the time mapping for synchronizing different time-based data streams. Creates a new time mapping if one doesn't exist.

public TimeMapping TimeMapping { get; set; }

Property Value

TimeMapping

Workpiece

Gets or sets the workpiece to be machined. Ensures proper initialization of workpiece properties.

public Workpiece Workpiece { get; set; }

Property Value

Workpiece

XName

Name for XML IO.

public static string XName { get; }

Property Value

string

Methods

BeginSession()

Initiate a simulation session. Clear the state from previous session (if existed).

public void BeginSession()

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

Dispose(bool)

protected virtual void Dispose(bool disposing)

Parameters

disposing bool

EndSession()

Ends the current machining session and releases associated resources.

public void EndSession()

GetInspectingKeyPresentName(StringLocalizer)

Gets the localized presentation name for the current inspecting key.

public string GetInspectingKeyPresentName(StringLocalizer stringLocalizer)

Parameters

stringLocalizer StringLocalizer

The string localizer to use for localization

Returns

string

The localized presentation name

GetMillingEquipment()

public MachiningEquipment GetMillingEquipment()

Returns

MachiningEquipment

MachiningEquipment

LoadFile(string)

Loads a machining project from the specified file path.

public static MachiningProject LoadFile(string projectFilePath)

Parameters

projectFilePath string

Path to the project file to load

Returns

MachiningProject

A new machining project instance loaded from the file

MakeXmlSource(string, string)

Creates an XML representation of the object. This method may also generate additional resources such as related files.

public XElement MakeXmlSource(string baseDirectory, string relFile)

Parameters

baseDirectory string

The base directory for resolving relative paths

relFile string

The relative file path for the XML source

Returns

XElement

An XML element representing the object's state

Remarks

For the demand of easy moving source folder (especially project folder) without configuration file path corruption, the relative file path is applied. The baseDirectory is typically the folder at the nearest configuration file folder. Since the folder can be moving with the configuration file.

PlayNc(string, string)

Plays NC commands from raw text with pace control.

public void PlayNc(string ncText, string fileNameAlternative = "--")

Parameters

ncText string

The NC command text to execute

fileNameAlternative string

Alternative name to associate with the NC program

PlayNcFile(string, string)

Plays an NC file from the specified path with pace control.

public void PlayNcFile(string rootDirectory, string relNcFilePath)

Parameters

rootDirectory string

Root directory for resolving relative paths

relNcFilePath string

Relative path to the NC file

ReTrainMillingPara(SampleFlag, double, string, CancellationToken)

Train Milling Parameter.

public void ReTrainMillingPara(SampleFlag sampleFlags, double outlierRatio, string dstRelFile, CancellationToken cancellationToken)

Parameters

sampleFlags SampleFlag
outlierRatio double
dstRelFile string
cancellationToken CancellationToken

RefreshDrawing()

Refreshes the visual display of the milling course.

public void RefreshDrawing()

ResetRuntime()

Reset the runtime states including: runtime geometry, collision flags, machine tool position, CL strips, message buffer and etc..

public void ResetRuntime()

RunNc(string, string)

Runs NC commands from raw text.

public IEnumerable<Action> RunNc(string ncText, string fileNameAlternative = "--")

Parameters

ncText string

The NC command text to execute

fileNameAlternative string

Alternative name to associate with the NC program

Returns

IEnumerable<Action>

An enumerable of actions to be executed

RunNcFile(string, string)

Runs an NC file from the specified path.

public IEnumerable<Action> RunNcFile(string rootDirectory, string relNcFilePath)

Parameters

rootDirectory string

Root directory for resolving relative paths

relNcFilePath string

Relative path to the NC file

Returns

IEnumerable<Action>

An enumerable of actions to be executed

RunNcFile(string, string, CancellationToken)

Runs an NC file from the specified path with cancellation support.

public IEnumerable<Action> RunNcFile(string rootDirectory, string relNcFilePath, CancellationToken cancellationToken)

Parameters

rootDirectory string

Root directory for resolving relative paths. If the value is null, BaseDirectory substitudes the value.

relNcFilePath string

Relative path to the NC file

cancellationToken CancellationToken

Token to monitor for cancellation requests

Returns

IEnumerable<Action>

An enumerable of actions to be executed

RunRawNcLines(string, IEnumerable<string>, CancellationToken)

Runs NC commands from raw text lines.

public IEnumerable<Action> RunRawNcLines(string relNcFilePath, IEnumerable<string> lines, CancellationToken cancellationToken)

Parameters

relNcFilePath string

Name to associate with the NC program

lines IEnumerable<string>

The NC command lines to execute

cancellationToken CancellationToken

Token to monitor for cancellation requests

Returns

IEnumerable<Action>

An enumerable of actions to be executed

ShowMessageBoard(string, string, BootstrapTheme)

Shows a message board with the specified title, message, and theme.

public void ShowMessageBoard(string title, string message, BootstrapTheme bootstrapThemeColor)

Parameters

title string

The title of the message board

message string

The message to display

bootstrapThemeColor BootstrapTheme

The theme color for the message board

TrainMillingPara(SampleFlag, bool, double, string, CancellationToken)

Train Milling Parameter.

public void TrainMillingPara(SampleFlag sampleFlags, bool enableFzOnlyDuringDrilling, double outlierRatio, string dstRelFile, CancellationToken cancellationToken)

Parameters

sampleFlags SampleFlag
enableFzOnlyDuringDrilling bool
outlierRatio double
dstRelFile string
cancellationToken CancellationToken

UpdateIdealMillingToolOffsetTableByToolHouse()

Updates the ideal milling tool offset table based on the current tool house configuration.

public void UpdateIdealMillingToolOffsetTableByToolHouse()

WriteShotFile(TimeSpan, string)

Writes time-based shot data to a file with the specified sampling period.

public void WriteShotFile(TimeSpan samplingPeriod, string relFileTemplate = "Output/[NcName].shot.csv")

Parameters

samplingPeriod TimeSpan

The time period between samples

relFileTemplate string

Template for the output file path, can include [NcName] placeholder

WriteStepFile(string)

Writes step-based data to a file.

public void WriteStepFile(string relFileTemplate = "Output/[NcName].step.csv")

Parameters

relFileTemplate string

Template for the output file path, can include [NcName] placeholder

Events

OnRanNcBlock

Event triggered after an NC block is executed.

public event Action OnRanNcBlock

Event Type

Action

OnShownMessageBoard

Event that is triggered when a message board is shown.

public event ShowMessageBoardDelegate OnShownMessageBoard

Event Type

ShowMessageBoardDelegate

OnUpdatedInspectingQuantityFunc

Event triggered when the inspecting quantity function is updated.

public event Action OnUpdatedInspectingQuantityFunc

Event Type

Action