Table of Contents

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

userService UserService

The application service.

logger ILogger<LocalProjectService>

The logger instance.

Properties

BoundSelectorHost

Gets the bound selector host for managing selection boundaries.

public BoundSelectorHost BoundSelectorHost { get; }

Property Value

BoundSelectorHost

ClStrip

Gets the cutter location strip containing the machining steps.

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

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

public bool EnablePauseOnFailure { get; set; }

Property Value

bool

EnableStrokeLimitCheck

public bool EnableStrokeLimitCheck { get; set; }

Property Value

bool

Fixture

Gets or sets the fixture.

public Fixture Fixture { get; set; }

Property Value

Fixture

Global

global variable for RuntimeApi. 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?>

Logger

Gets the logger instance for this service.

public ILogger<LocalProjectService> Logger { get; }

Property Value

ILogger<LocalProjectService>

MachiningActRunner

Gets the machining act runner responsible for executing machining operations.

public MachiningActRunner MachiningActRunner { get; }

Property Value

MachiningActRunner

MachiningChain

Gets or sets the machining chain.

public IMachiningChain MachiningChain { get; set; }

Property Value

IMachiningChain

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

string

MachiningEquipment

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

public MachiningEquipment MachiningEquipment { get; set; }

Property Value

MachiningEquipment

MachiningProject

Gets or sets the machining project instance.

public MachiningProject MachiningProject { get; set; }

Property Value

MachiningProject

MachiningProjectPath

public string MachiningProjectPath { get; set; }

Property Value

string

MachiningSession

Gets the current machining session.

public MachiningSession MachiningSession { get; set; }

Property Value

MachiningSession

MachiningTool

Gets or sets the machining tool.

public IMachiningTool MachiningTool { get; set; }

Property Value

IMachiningTool

MachiningToolHouse

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

MillingStepLuggageReader

Gets the reader for accessing milling step luggage data.

public ParallelBulkReader<MillingStepLuggage> MillingStepLuggageReader { get; }

Property Value

ParallelBulkReader<MillingStepLuggage>

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

Progress

Gets the progress reporting mechanism for long-running operations.

public Progress<IProgressReport> Progress { get; }

Property Value

Progress<IProgressReport>

ProjectDirectory

Gets the directory containing the machining project.

public string ProjectDirectory { get; }

Property Value

string

RuntimeApi

Gets the shell API for interacting with this machining process.

public RuntimeApi RuntimeApi { get; }

Property Value

RuntimeApi

SessionMessageHost

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

public SessionMessageHost SessionMessageHost { get; }

Property Value

SessionMessageHost

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.

public TimeMapping TimeMapping { get; set; }

Property Value

TimeMapping

UserService

Gets the application service instance.

public UserService UserService { get; }

Property Value

UserService

Workpiece

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

public Workpiece Workpiece { get; set; }

Property Value

Workpiece

Methods

Act(IAct, IIndexedFileLine, CancellationToken?)

Executes an act and collects all results.

public void Act(IAct act, IIndexedFileLine sourceCommand = null, CancellationToken? cancellationToken = null)

Parameters

act IAct

The act to execute.

sourceCommand IIndexedFileLine

The source command that triggered the act.

cancellationToken CancellationToken?

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

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

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()

public MachiningEquipment GetMillingEquipment()

Returns

MachiningEquipment

MachiningEquipment

LoadProject(string)

Loads a project by file path relative to the admin directory.

public void LoadProject(string projectPath)

Parameters

projectPath string

The absolute file path

NewProject(string)

Creates a new project by file path.

public void NewProject(string projectPath)

Parameters

projectPath string

The absolute file path

PlayCsvFile(string, string)

Plays a CSV file from the specified path.

public void PlayCsvFile(string baseDirectory, string relFilePath)

Parameters

baseDirectory string

Base directory for resolving relative paths.

relFilePath string

Relative 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

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 baseDirectory, string relFilePath)

Parameters

baseDirectory string

Base directory for resolving relative paths

relFilePath string

Relative 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

act IAct

The act to process.

sourceCommand IIndexedFileLine

The source command that triggered the act.

cancellationToken CancellationToken?

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

sampleFlags SampleFlag
outlierRatio double
dstRelFile string
cancellationToken CancellationToken

RefreshDrawing()

Refreshes the visual display of the milling course.

public void RefreshDrawing()

ReloadProject()

Reloads the current project.

public Task ReloadProject()

Returns

Task

A task representing the asynchronous operation

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

baseDirectory string

Base directory for resolving relative paths.

relFilePath string

Relative 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

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 baseDirectory, string relFilePath)

Parameters

baseDirectory string

Base directory for resolving relative paths. If the value is null, BaseDirectory substitutes the value.

relFilePath string

Relative 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

projectPath string

The 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

sampleFlags SampleFlag
enableFzOnlyDuringDrilling bool
outlierRatio double
dstRelFile string
cancellationToken CancellationToken
paraTemplate ICuttingPara

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

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

MachiningProjectChanged

Event raised when the machining project changes.

public event LocalProjectService.MachiningProjectChangedDelegate MachiningProjectChanged

Event Type

LocalProjectService.MachiningProjectChangedDelegate

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

MachiningActRunner.MachiningStepBuiltDelegate

OnRanNcBlock

Event triggered after an NC block is executed.

public event Action OnRanNcBlock

Event Type

Action

OnUpdatedInspectingQuantityFunc

Event triggered when the inspecting quantity function is updated.

public event Action OnUpdatedInspectingQuantityFunc

Event Type

Action

WorkpieceChanged

Event that is raised when the workpiece is changed.

public event Action<SeqPair<Workpiece>> WorkpieceChanged

Event Type

Action<SeqPair<Workpiece>>

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.