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
stringBase 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
stringBase directory for file operations
mongoClient
MongoClientMongoDB 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
XElementXML element containing configuration data
baseDirectory
stringBase 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
XElementXML element containing configuration data
baseDirectory
stringBase directory for resolving relative paths
mongoClient
MongoClientMongoDB client instance
Properties
ApiVersion
Gets the API version from the entry assembly.
public static Version ApiVersion { get; }
Property Value
BaseDirectory
Gets the base directory where project files are located.
public string BaseDirectory { get; }
Property Value
BoundSelectorHost
Gets the bound selector host for managing selection boundaries.
public BoundSelectorHost BoundSelectorHost { get; }
Property Value
ClStrip
Gets the cutter location strip.
public ClStrip ClStrip { get; }
Property Value
CoordinateEntryDisplayee
Gets the displayee for coordinate entry visualization.
public CoordinateEntryDisplayee CoordinateEntryDisplayee { get; }
Property Value
DictionaryColorGuide
Gets the color guide for dictionary-based coloring.
public DictionaryColorGuide DictionaryColorGuide { get; }
Property Value
DispCacheMb
Gets or sets the display cache size in megabytes.
public static long DispCacheMb { get; set; }
Property Value
EnableCollisionDetection
Gets or sets whether collision detection is enabled. When set to true, initializes collision detection mechanism.
public bool EnableCollisionDetection { get; set; }
Property Value
EnablePauseOnFailure
Enable Pause On Failure Detected. Only take effect if the EnableCollisionDetection or EnableStrokeLimitCheck is enabled.
public bool EnablePauseOnFailure { get; set; }
Property Value
EnableStrokeLimitCheck
public bool EnableStrokeLimitCheck { get; set; }
Property Value
Global
global variable for ShellApi. Not save on XML.
public Dictionary<object, object> Global { get; set; }
Property Value
InspectingKey
Gets or sets the current inspecting key for visualization. When set, updates the inspecting quantity function.
public string InspectingKey { get; set; }
Property Value
InspectingQuantityFunc
Gets the function that retrieves the quantity value for the current inspecting key.
public Func<MachiningStep, double?> InspectingQuantityFunc { get; }
Property Value
MachiningActRunner
Gets the machining act runner responsible for executing machining operations.
public MachiningActRunner MachiningActRunner { get; }
Property Value
MachiningEquipment
Gets or sets the machining equipment used for milling. Updates related components when changed.
public MachiningEquipment MachiningEquipment { get; set; }
Property Value
MachiningSession
Gets or sets the current machining session.
public MachiningSession MachiningSession { get; set; }
Property Value
MachiningToolHouse
Gets or sets the milling tool house containing available tools.
public MachiningToolHouse MachiningToolHouse { get; set; }
Property Value
MachiningToolHouseFile
Gets or sets the file path to the milling tool house configuration.
public string MachiningToolHouseFile { get; set; }
Property Value
MillingActRunnerConfig
Gets or sets the configuration for the milling act runner.
public MillingActRunnerConfig MillingActRunnerConfig { get; set; }
Property Value
MillingGuide
Gets or sets the milling guide containing visualization and analysis configurations.
public MillingGuide MillingGuide { get; set; }
Property Value
MillingStepLuggageReader
Gets the reader for accessing milling step luggage data.
public ParallelBulkReader<MillingStepLuggage> MillingStepLuggageReader { get; }
Property Value
NcEnv
public NcEnv NcEnv { get; }
Property Value
NcOptProc
Gets the NC optimization processor for optimizing NC programs.
public NcOptProc NcOptProc { get; }
Property Value
NcRunner
Gets the NC runner responsible for executing NC programs.
public NcRunner NcRunner { get; }
Property Value
PacePlayer
Gets the pace player for controlling execution pace of milling operations.
public PacePlayer PacePlayer { get; }
Property Value
PlayerCommand
Gets the command to execute when playing the machining project.
public IShellCommand PlayerCommand { get; }
Property Value
Progress
Gets the progress reporting mechanism for long-running operations.
public Progress<IProgressReport> Progress { get; }
Property Value
SessionMessageHost
Gets the message host for displaying messages, warnings, and errors.
public SessionMessageHost SessionMessageHost { get; }
Property Value
ShellApi
Gets the shell API for interacting with this machining process.
public ShellApi ShellApi { get; }
Property Value
StepPropertyAccessDictionary
Gets the dictionary mapping property keys to their access methods.
public ConcurrentDictionary<string, PropertyAccess<MachiningStep>> StepPropertyAccessDictionary { get; }
Property Value
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
Workpiece
Gets or sets the workpiece to be machined. Ensures proper initialization of workpiece properties.
public Workpiece Workpiece { get; set; }
Property Value
XName
Name for XML IO.
public static string XName { get; }
Property Value
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
StringLocalizerThe string localizer to use for localization
Returns
- string
The localized presentation name
GetMillingEquipment()
Get MachiningEquipment.
public MachiningEquipment GetMillingEquipment()
Returns
LoadFile(string)
Loads a machining project from the specified file path.
public static MachiningProject LoadFile(string projectFilePath)
Parameters
projectFilePath
stringPath 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
stringThe base directory for resolving relative paths
relFile
stringThe 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
stringThe NC command text to execute
fileNameAlternative
stringAlternative 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
stringRoot directory for resolving relative paths
relNcFilePath
stringRelative 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
SampleFlagoutlierRatio
doubledstRelFile
stringcancellationToken
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
stringThe NC command text to execute
fileNameAlternative
stringAlternative 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
stringRoot directory for resolving relative paths
relNcFilePath
stringRelative 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
stringRoot directory for resolving relative paths. If the value is null, BaseDirectory substitudes the value.
relNcFilePath
stringRelative path to the NC file
cancellationToken
CancellationTokenToken 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
stringName to associate with the NC program
lines
IEnumerable<string>The NC command lines to execute
cancellationToken
CancellationTokenToken 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
stringThe title of the message board
message
stringThe message to display
bootstrapThemeColor
BootstrapThemeThe 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
SampleFlagenableFzOnlyDuringDrilling
booloutlierRatio
doubledstRelFile
stringcancellationToken
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
TimeSpanThe time period between samples
relFileTemplate
stringTemplate 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
stringTemplate 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
OnShownMessageBoard
Event that is triggered when a message board is shown.
public event ShowMessageBoardDelegate OnShownMessageBoard
Event Type
OnUpdatedInspectingQuantityFunc
Event triggered when the inspecting quantity function is updated.
public event Action OnUpdatedInspectingQuantityFunc