Class LocalProjectService
- Namespace
- Hi.MachiningProcs
- Assembly
- HiNc.dll
Root(Local) project service. Apply absolute file path.
public class LocalProjectService : IProjectService, IMachiningProjectGetter, IMachiningStepHost, IGetMachiningEquipment, IDisposable
- Inheritance
-
LocalProjectService
- Implements
- Inherited Members
- Extension Methods
Remarks
LocalProjectService handles the runtime data and cache generally not requires configuration IO. Compare to MachiningProject, LocalProjectService also handles events that does not reset on the MachiningProject been reloaded.
Constructors
LocalProjectService()
Ctor.
public LocalProjectService()
LocalProjectService(UserService, ILogger<LocalProjectService>)
Initializes a new instance.
public LocalProjectService(UserService userService, ILogger<LocalProjectService> logger)
Parameters
userServiceUserServiceThe application service.
loggerILogger<LocalProjectService>The logger instance.
Properties
BoundSelectorHost
Gets the bound selector host for managing selection boundaries.
public BoundSelectorHost BoundSelectorHost { get; }
Property Value
ClStrip
Gets the cutter location strip containing the machining steps.
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
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
public bool EnablePauseOnFailure { get; set; }
Property Value
EnableStrokeLimitCheck
public bool EnableStrokeLimitCheck { get; set; }
Property Value
Fixture
Gets or sets the fixture.
public Fixture Fixture { get; set; }
Property Value
Global
global variable for RuntimeApi. 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
Logger
Gets the logger instance for this service.
public ILogger<LocalProjectService> Logger { get; }
Property Value
MachiningActRunner
Gets the machining act runner responsible for executing machining operations.
public MachiningActRunner MachiningActRunner { get; }
Property Value
MachiningChain
Gets or sets the machining chain.
public IMachiningChain MachiningChain { get; set; }
Property Value
MachiningChainFile
Gets or sets the file path of the solid machining chain. This is used for XML serialization and file management.
public string MachiningChainFile { get; set; }
Property Value
MachiningEquipment
Gets or sets the machining equipment used for milling. Updates related components when changed.
public MachiningEquipment MachiningEquipment { get; set; }
Property Value
MachiningProject
Gets or sets the machining project instance.
public MachiningProject MachiningProject { get; set; }
Property Value
MachiningProjectPath
public string MachiningProjectPath { get; set; }
Property Value
MachiningSession
Gets the current machining session.
public MachiningSession MachiningSession { get; set; }
Property Value
MachiningTool
Gets or sets the machining tool.
public IMachiningTool MachiningTool { get; set; }
Property Value
MachiningToolHouse
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
MillingStepLuggageReader
Gets the reader for accessing milling step luggage data.
public ParallelBulkReader<MillingStepLuggage> MillingStepLuggageReader { 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
Progress
Gets the progress reporting mechanism for long-running operations.
public Progress<IProgressReport> Progress { get; }
Property Value
ProjectDirectory
Gets the directory containing the machining project.
public string ProjectDirectory { get; }
Property Value
RuntimeApi
Gets the shell API for interacting with this machining process.
public RuntimeApi RuntimeApi { get; }
Property Value
SessionMessageHost
Gets the message host for displaying messages, warnings, and errors.
public SessionMessageHost SessionMessageHost { 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.
public TimeMapping TimeMapping { get; set; }
Property Value
UserService
Gets the application service instance.
public UserService UserService { get; }
Property Value
Workpiece
Gets or sets the workpiece to be machined. Ensures proper initialization of workpiece properties.
public Workpiece Workpiece { get; set; }
Property Value
Methods
Act(IAct, IIndexedFileLine, CancellationToken?)
Executes an act and collects all results.
public void Act(IAct act, IIndexedFileLine sourceCommand = null, CancellationToken? cancellationToken = null)
Parameters
actIActThe act to execute.
sourceCommandIIndexedFileLineThe source command that triggered the act.
cancellationTokenCancellationToken?Cancellation token to cancel the operation.
BeginSession()
Initiate a simulation session. Clear the state from previous session (if existed).
public void BeginSession()
CloseProject()
Closes the current project.
public void CloseProject()
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
disposingbool
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
stringLocalizerStringLocalizerThe string localizer to use for localization
Returns
- string
The localized presentation name
GetLocalProjectService()
Get Local Project Service as base-service.
public LocalProjectService GetLocalProjectService()
Returns
- LocalProjectService
Local Project Service
GetMachiningProject()
Gets the MachiningProject instance.
public MachiningProject GetMachiningProject()
Returns
- MachiningProject
The MachiningProject instance.
GetMillingEquipment()
Get MachiningEquipment.
public MachiningEquipment GetMillingEquipment()
Returns
LoadProject(string)
Loads a project by file path relative to the admin directory.
public void LoadProject(string projectPath)
Parameters
projectPathstringThe absolute file path
NewProject(string)
Creates a new project by file path.
public void NewProject(string projectPath)
Parameters
projectPathstringThe absolute file path
PlayCsvFile(string, string)
Plays a CSV file from the specified path.
public void PlayCsvFile(string baseDirectory, string relFilePath)
Parameters
baseDirectorystringBase directory for resolving relative paths.
relFilePathstringRelative path to the CSV file.
PlayNc(string, string)
Plays NC commands from raw text with pace control.
public void PlayNc(string ncText, string fileNameAlternative = "--")
Parameters
ncTextstringThe NC command text to execute
fileNameAlternativestringAlternative 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 baseDirectory, string relFilePath)
Parameters
baseDirectorystringBase directory for resolving relative paths
relFilePathstringRelative path to the NC file
ProcAct(IAct, IIndexedFileLine, CancellationToken?)
Processes an act and returns the results.
public IEnumerable<object> ProcAct(IAct act, IIndexedFileLine sourceCommand = null, CancellationToken? cancellationToken = null)
Parameters
actIActThe act to process.
sourceCommandIIndexedFileLineThe source command that triggered the act.
cancellationTokenCancellationToken?Cancellation token to cancel the operation.
Returns
- IEnumerable<object>
Enumerable of results from processing the act.
ReTrainMillingPara(SampleFlag, double, string, CancellationToken)
Train Milling Parameter.
public void ReTrainMillingPara(SampleFlag sampleFlags, double outlierRatio, string dstRelFile, CancellationToken cancellationToken)
Parameters
sampleFlagsSampleFlagoutlierRatiodoubledstRelFilestringcancellationTokenCancellationToken
RefreshDrawing()
Refreshes the visual display of the milling course.
public void RefreshDrawing()
ReloadProject()
Reloads the current project.
public void ReloadProject()
ResetRuntime()
Reset the runtime states including: runtime geometry, collision flags, machine tool position, CL strips, message buffer and etc..
public void ResetRuntime()
RunCsvFile(string, string)
Runs a CSV file from the specified path.
public IEnumerable<Action> RunCsvFile(string baseDirectory, string relFilePath)
Parameters
baseDirectorystringBase directory for resolving relative paths.
relFilePathstringRelative path to the CSV file.
Returns
- IEnumerable<Action>
An enumerable of actions to be executed.
RunNc(string, string)
Runs NC commands from raw text.
public IEnumerable<Action> RunNc(string ncText, string fileNameAlternative = "--")
Parameters
ncTextstringThe NC command text to execute
fileNameAlternativestringAlternative 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 baseDirectory, string relFilePath)
Parameters
baseDirectorystringBase directory for resolving relative paths. If the value is null, BaseDirectory substitutes the value.
relFilePathstringRelative path to the NC file.
Returns
- IEnumerable<Action>
An enumerable of actions to be executed.
SaveAsProject(string)
Saves the current project to a specified relative file path.
public void SaveAsProject(string projectPath)
Parameters
projectPathstringThe absolute file path
SaveProject()
Save project by project path.
public void SaveProject()
TrainMillingPara(SampleFlag, bool, double, string, CancellationToken, ICuttingPara)
Train Milling Parameter.
public void TrainMillingPara(SampleFlag sampleFlags, bool enableFzOnlyDuringDrilling, double outlierRatio, string dstRelFile, CancellationToken cancellationToken, ICuttingPara paraTemplate)
Parameters
sampleFlagsSampleFlagenableFzOnlyDuringDrillingbooloutlierRatiodoubledstRelFilestringcancellationTokenCancellationTokenparaTemplateICuttingPara
UpdateByMachiningChain()
Updates components when the machining chain changes.
public void UpdateByMachiningChain()
UpdateByMachiningEquipment()
Call on MachiningEquipment Or MachiningChainChanged. i.e. Update By MachiningEquipment Or MachiningChain. The function is called on MachiningEquipment and its delegate property changed. If the changing is raised outer from THIS service, this updating function should be manual called.
public void UpdateByMachiningEquipment()
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
samplingPeriodTimeSpanThe time period between samples
relFileTemplatestringTemplate 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
relFileTemplatestringTemplate for the output file path, can include [NcName] placeholder
Events
MachiningProjectChanged
Event raised when the machining project changes.
public event LocalProjectService.MachiningProjectChangedDelegate MachiningProjectChanged
Event Type
MachiningStepBuilt
event to configure steps. The first parameter is the previous step; the second parameter is the current step. The previous step is null if no previous step exists.
public event MachiningActRunner.MachiningStepBuiltDelegate MachiningStepBuilt
Event Type
OnRanNcBlock
Event triggered after an NC block is executed.
public event Action OnRanNcBlock
Event Type
OnUpdatedInspectingQuantityFunc
Event triggered when the inspecting quantity function is updated.
public event Action OnUpdatedInspectingQuantityFunc
Event Type
WorkpieceChanged
Event that is raised when the workpiece is changed.
public event Action<SeqPair<Workpiece>> WorkpieceChanged
Event Type
Remarks
This event is triggered whenever the workpiece property is modified. Subscribers can use this event to respond to changes in the workpiece configuration, such as updating visualizations or recalculating machining parameters. The event provides both the previous and new workpiece values through a SeqPair.