Class RuntimeController
- Namespace
- Hi.MachiningProcs
- Assembly
- HiNc.dll
Provides a C# scripting API for controlling and manipulating the milling course. Allows for runtime control of milling operations, geometry manipulation, and data analysis.
[ApiController]
[Route("api/[controller]/[action]")]
public class RuntimeController : ControllerBase, ICsScriptApi
- Inheritance
-
RuntimeController
- Implements
- Inherited Members
- Extension Methods
Constructors
RuntimeController(IMachiningProjectGetter)
Initializes a new instance.
public RuntimeController(IMachiningProjectGetter machiningProjectGetter)
Parameters
machiningProjectGetter
IMachiningProjectGetter
Properties
DiffVisualRadius_mm
Gets or sets the visual radius in millimeters for difference visualization. Controls the radius used for highlighting differences between workpiece states.
[JsAce]
public double DiffVisualRadius_mm { get; set; }
Property Value
DispCacheMb
Gets or sets the display cache size in megabytes.
public long DispCacheMb { get; set; }
Property Value
DispCache_Mb
Gets or sets the display cache size in megabytes.
[JsAce]
public long DispCache_Mb { get; set; }
Property Value
EnableAutoMapOnSelectionEnd
Gets or sets whether to automatically map selections when they end.
[JsAce]
public bool EnableAutoMapOnSelectionEnd { get; set; }
Property Value
EnableCollisionDetection
Gets or sets whether collision detection is enabled.
[JsAce(DocContentHtml = "Enable Collision Detection.")]
public bool EnableCollisionDetection { get; set; }
Property Value
EnablePauseOnCollision
Obsoleted.
Gets or sets whether to pause execution when a collision is detected. This property only has an effect if collision detection is enabled.
public bool EnablePauseOnCollision { get; set; }
Property Value
EnablePauseOnFailure
[JsAce(DocContentHtml = "Enable Pause On Failure.")]
public bool EnablePauseOnFailure { get; set; }
Property Value
EnablePhysics
Gets or sets whether milling force evaluation is enabled.
[JsAce(DocContentHtml = "Enable milling force evaluation.")]
public bool EnablePhysics { get; set; }
Property Value
EnableWearEffect
Gets or sets whether tool wear effects are enabled in simulation.
[JsAce]
public bool EnableWearEffect { get; set; }
Property Value
FeedPerCycle
Gets a new feed per cycle machining motion resolution instance.
[JsAce]
public FeedPerCycleMachiningMotionResolution FeedPerCycle { get; }
Property Value
FeedPerTooth
Gets a new feed per tooth machining motion resolution instance.
[JsAce]
public FeedPerToothMachiningMotionResolution FeedPerTooth { get; }
Property Value
Global
Global variables.
[JsAce("Global[$1key]")]
public Dictionary<object, object> Global { get; }
Property Value
InitSpindleTemperature_C
Gets or sets the initial spindle temperature in degrees Celsius.
[JsAce(DocContentHtml = "Spindle Temperature on initialization.")]
public double InitSpindleTemperature_C { get; set; }
Property Value
JsAceCompletionProfileJsonArray
Internal used.
public static JsonArray JsAceCompletionProfileJsonArray { get; }
Property Value
MachiningMotionResolution
Gets or sets the machining motion resolution.
[JsAce]
public IMachiningMotionResolution MachiningMotionResolution { get; set; }
Property Value
MachiningResolution
Gets or sets the machining resolution in millimeters. For legacy compatable.
[JsAce]
[Obsolete]
public double MachiningResolution { get; set; }
Property Value
MachiningResolution_mm
Gets or sets the machining resolution in millimeters.
[JsAce]
public double MachiningResolution_mm { get; set; }
Property Value
MachiningSession
public MachiningSession MachiningSession { get; }
Property Value
MapTask
Task tracking the status of mapping operations.
public Task MapTask { get; set; }
Property Value
MillingForceCycleDivisionNum
Gets or sets the number of divisions per cycle for milling force calculation. This property should be set before milling force evaluation if TrainMillingPara(SampleFlag, string, double) is intended to be used.
[JsAce]
public static int MillingForceCycleDivisionNum { get; set; }
Property Value
NcOptOption
[JsAce]
public NcOptOption NcOptOption { get; set; }
Property Value
OptEnableDepthCompensation
Enables or disables depth compensation during optimization.
[JsAce]
public bool OptEnableDepthCompensation { get; set; }
Property Value
OptEnableFeedrate
Gets or sets whether to enable feed rate optimization in NC optimization.
[JsAce]
public bool OptEnableFeedrate { get; set; }
Property Value
OptEnableForwardCompensation
Enables or disables forward compensation during optimization.
[JsAce]
public bool OptEnableForwardCompensation { get; set; }
Property Value
OptEnableInterpolation
Enables or disables reinterpolation for optimization.
[JsAce]
public bool OptEnableInterpolation { get; set; }
Property Value
OptEnableSideCompensation
Enables or disables side compensation during optimization.
[JsAce]
public bool OptEnableSideCompensation { get; set; }
Property Value
OptExtendedPostDistance_mm
Gets or sets the extended post-distance in millimeters for NC optimization. This is the distance after the current segment that will be considered for optimization.
[JsAce]
public double OptExtendedPostDistance_mm { get; set; }
Property Value
OptExtendedPreDistance_mm
Gets or sets the extended pre-distance in millimeters for NC optimization. This is the distance before the current segment that will be considered for optimization.
[JsAce]
public double OptExtendedPreDistance_mm { get; set; }
Property Value
OptMaxAcceleration_mmds2
Maximum acceleration in mm/s² during optimization. Only takes effect on reinterpolated section.
[JsAce(DocContentHtml = "Only take effect on reinterpolated section.")]
public double OptMaxAcceleration_mmds2 { get; set; }
Property Value
OptMaxFeedrate_mmdmin
Maximum feed rate in mm/min for cutting movements during optimization.
[JsAce]
public double OptMaxFeedrate_mmdmin { get; set; }
Property Value
OptMaxJerk_mmds3
Maximum jerk in mm/s³ during optimization. Only takes effect on reinterpolated section.
[JsAce(DocContentHtml = "Only take effect on reinterpolated section.")]
public double OptMaxJerk_mmds3 { get; set; }
Property Value
OptMinFeedrate_mmdmin
Minimum feed rate in mm/min for cutting movements during optimization.
[JsAce]
public double OptMinFeedrate_mmdmin { get; set; }
Property Value
OptPreferedForce_N
Preferred force in N for optimization.
[JsAce]
public double OptPreferedForce_N { get; set; }
Property Value
OptRapidFeed_mmdmin
Rapid feed rate in mm/min for non-cutting movements during optimization.
[JsAce]
public double OptRapidFeed_mmdmin { get; set; }
Property Value
OptSpindlePowerSafetyFactor
Safety factor for spindle power during optimization.
[JsAce]
public double OptSpindlePowerSafetyFactor { get; set; }
Property Value
OptSpindleTorqueSafetyFactor
Safety factor for spindle torque during optimization.
[JsAce]
public double OptSpindleTorqueSafetyFactor { get; set; }
Property Value
ParaTemplateDimension
[JsAce]
public int ParaTemplateDimension { get; set; }
Property Value
ScriptOptions
ScriptOptions.
public ScriptOptions ScriptOptions { get; set; }
Property Value
SessionMessageHost
[JsAce]
public SessionMessageHost SessionMessageHost { get; }
Property Value
StepCount
Gets the total number of milling steps.
[JsAce]
public int StepCount { get; }
Property Value
Methods
AddTimeDataByFile(string, string, double, double)
Adds time-based data from a file to the time mapping dictionary with specified time bounds in seconds.
[JsAce("AddTimeDataByFile($1key, $2relFile, $3beginTime, $4endTime)")]
[NonAction]
public bool AddTimeDataByFile(string key, string relFile, double beginTime, double endTime)
Parameters
key
stringKey to identify the data
relFile
stringRelative path to the data file
beginTime
doubleBeginning time in seconds
endTime
doubleEnding time in seconds
Returns
- bool
True if the data was successfully added, false otherwise
AddTimeDataByFile(string, string, string, string)
Adds time-based data from a file to the time mapping dictionary with specified time bounds.
[JsAce("AddTimeDataByFile($1key, $2relFile, $3beginTime, $4endTime)")]
[HttpPost]
public bool AddTimeDataByFile(string key, string relFile, string beginTimeText, string endTimeText)
Parameters
key
stringKey to identify the data
relFile
stringRelative path to the data file
beginTimeText
stringBeginning time as text (seconds or TimeSpan format)
endTimeText
stringEnding time as text (seconds or TimeSpan format)
Returns
- bool
True if the data was successfully added, false otherwise
AppendMessagesToFile(string, params string[])
Appends messages to a file, optionally filtered by tags.
[JsAce("AppendMessagesToFile(\"dstRelFile\",flags)")]
[HttpPost]
public void AppendMessagesToFile(string dstRelFile, params string[] flags)
Parameters
dstRelFile
stringDestination relative file path
flags
string[]Optional flags to filter messages by tags
BeginPreserve()
Begin Preserve section in optimzation process.
[JsAce("BeginPreserve()")]
[HttpPost]
public void BeginPreserve()
BeginSelection(string, AnchorMode, IStepShift)
Begin mark on current line. milling step() has not triggered yet.
[NonAction]
public void BeginSelection(string key, AnchorMode anchorMode = AnchorMode.LineBegin, IStepShift shift = null)
Parameters
key
stringIdentifier key for the selection
anchorMode
AnchorModeMode for anchoring the beginning of selection
shift
IStepShiftStep shift to apply
BeginSession()
[HttpPost]
public void BeginSession()
ClearTimeMappingData()
Clears all time mapping data.
[JsAce]
[HttpPost]
public void ClearTimeMappingData()
Diff(double)
Performs a difference analysis on the workpiece geometry to detect variations.
[JsAce("Diff($1detectionRadius_mm)")]
[HttpPost]
public void Diff(double detectionRadius_mm)
Parameters
detectionRadius_mm
doubleRadius for detecting differences
EndPreserve()
End Preserve section in optimzation process.
[JsAce("EndPreserve()")]
[HttpPost]
public void EndPreserve()
EndSelection(string, AnchorMode, IStepShift)
End mark on current line for selection.
[NonAction]
public void EndSelection(string key, AnchorMode anchorMode = AnchorMode.LineEnd, IStepShift shift = null)
Parameters
key
stringIdentifier key for the selection
anchorMode
AnchorModeMode for anchoring the end of selection
shift
IStepShiftStep shift to apply
EndSession()
[HttpPost]
public void EndSession()
ErrorMessage(string)
Displays an error message in the message host.
[JsAce("ErrorMessage($1message)")]
[HttpPost]
public void ErrorMessage(string message)
Parameters
message
stringThe error message to display
FixedPace(double, double)
Creates a fixed machining motion resolution with specified parameters.
[JsAce("FixedPace($1linearResolution_mm, $2rotaryResolution_deg)")]
[NonAction]
public FixedMachiningMotionResolution FixedPace(double linearResolution_mm, double rotaryResolution_deg)
Parameters
linearResolution_mm
doubleLinear resolution in millimeters
rotaryResolution_deg
doubleRotary resolution in degrees
Returns
- FixedMachiningMotionResolution
A new fixed machining motion resolution instance
GetMillingStep(int)
Retrieves a milling step at the specified index.
[JsAce(Snippet = "GetMillingStep($1\"stepIndex\")")]
[NonAction]
public MachiningStep GetMillingStep(int stepIndex)
Parameters
stepIndex
intIndex of the milling step to retrieve
Returns
- MachiningStep
The milling step at the specified index
GetStickMachiningToolObservationHeight_mm(int)
Gets the observation height in millimeters for the specified stick machining tool.
[JsAce("GetStickMachiningToolObservationHeight_mm($1toolId)")]
[HttpGet]
public double GetStickMachiningToolObservationHeight_mm(int toolId)
Parameters
toolId
intThe ID of the tool
Returns
- double
The observation height in millimeters
GetUniformContourTrayShiftAngle_deg(int)
Gets the shift angle in degrees for the uniform contour tray of the specified tool.
[JsAce("GetUniformContourTrayShiftAngle_deg($1toolId)")]
[HttpGet]
public double GetUniformContourTrayShiftAngle_deg(int toolId)
Parameters
toolId
intThe ID of the tool
Returns
- double
The shift angle in degrees
LineSelection(string, AnchorMode, IStepShift, AnchorMode, IStepShift)
Create a line selection from begin to end mark.
[NonAction]
public void LineSelection(string key, AnchorMode beginAnchorMode = AnchorMode.LineBegin, IStepShift beginShift = null, AnchorMode endAnchorMode = AnchorMode.LineEnd, IStepShift endShift = null)
Parameters
key
stringIdentifier key for the selection
beginAnchorMode
AnchorModeMode for anchoring the beginning of selection
beginShift
IStepShiftStep shift to apply at beginning
endAnchorMode
AnchorModeMode for anchoring the end of selection
endShift
IStepShiftStep shift to apply at end
Map(string, FileTimeSection, CycleSamplingMode?)
Maps selection data to time section.
[HttpPost]
public Task Map(string key, FileTimeSection fileTimeSection = null, StepTimeShotUtil.CycleSamplingMode? cycleSamplingMode = CycleSamplingMode.SpindleCycle)
Parameters
key
stringIdentifier key for the selection
fileTimeSection
FileTimeSectionFile time section, or null to use the one associated with the key
cycleSamplingMode
StepTimeShotUtil.CycleSamplingMode?Cycle sampling mode
Returns
- Task
Task representing the asynchronous mapping operation
Message(string)
Displays a message in the message host.
[JsAce("Message($1message)")]
[HttpPost]
public void Message(string message)
Parameters
message
stringThe message to display
OptimizeToFiles(string)
Optimizes NC files and saves results using the specified file template.
[JsAce(Snippet = "OptimizeToFiles(\"Output/Opt-[NcName]\")", DocContentHtml = "Optimize To Files by substitude template keywoard \"[NcName]\"")]
[HttpPost]
public void OptimizeToFiles(string relFileTemplate = "Output/Opt-[NcName]")
Parameters
relFileTemplate
stringTemplate for output file path, can include [NcName] placeholder
Pace()
Controls the pace of machining operations during execution.
[JsAce("Pace();")]
[HttpPost]
public void Pace()
Pause()
Pause Player
[JsAce(DocContentHtml = "Pause Player")]
[HttpPost]
public void Pause()
PlayAct(IAct, ISourceCommand, CancellationToken?)
[JsAce]
[NonAction]
public void PlayAct(IAct act, ISourceCommand sourceCommand = null, CancellationToken? cancellationToken = null)
Parameters
act
IActsourceCommand
ISourceCommandcancellationToken
CancellationToken?
PlayClTeleport(double, double, double, double, double, double)
[JsAce]
[HttpPost]
public void PlayClTeleport(double x, double y, double z, double i, double j, double k)
Parameters
PlayNc(string, string)
Plays NC code directly from a string, executing each action and pacing between them.
[JsAce(Snippet = "PlayNc($1\"ncCommand\",$2\"\"(Direct Command)\"\");", DocContentHtml = "Play NC. second parameter is the file name alternative shows in the log.")]
[HttpPost]
public void PlayNc(string ncText, string fileNameAlternative = "--")
Parameters
PlayNcFile(string)
Plays an NC file with the specified relative path.
[JsAce("PlayNcFile($1\"ncFile\");")]
[HttpPost]
public void PlayNcFile(string relNcFilePath)
Parameters
relNcFilePath
stringRelative path to the NC file
PlayToolingTeleport(int)
[JsAce]
[HttpPost]
public void PlayToolingTeleport(int toolId)
Parameters
toolId
int
Preserve()
Preserve one line NC code in optimzation process.
[JsAce("Preserve()")]
[HttpPost]
public void Preserve()
ProgressMessage(string)
Displays a progress message in the message host.
[JsAce("ProgressMessage($1message)")]
[HttpPost]
public void ProgressMessage(string message)
Parameters
message
stringThe progress message to display
ReTrainMillingPara(SampleFlag, string, double)
Re-trains milling parameters using the specified sample flag.
[JsAce("ReTrainMillingPara(Fx|Fy|Fz, $1dstFile)")]
[HttpPost]
public void ReTrainMillingPara(SampleFlag sampleFlag, string dstRelFile, double outlierRatio = 2)
Parameters
sampleFlag
SampleFlagSample flag indicating which components to train
dstRelFile
stringDestination relative file path
outlierRatio
doubleOutlier ratio for data filtering
ReadCsvByTimeInterpolation(string)
Reads a CSV file and performs time-based interpolation to map data to milling steps.
[JsAce(Snippet = "ReadCsvByTimeInterpolation($1\"csvFile\")")]
[HttpPost]
public void ReadCsvByTimeInterpolation(string csvFile)
Parameters
csvFile
stringPath to the CSV file relative to the base directory
ReadRuntimeGeom(string)
Reads runtime geometry from a file.
[JsAce("ReadRuntimeGeom($1\"srcFile\")")]
[HttpPost]
public void ReadRuntimeGeom(string relFile)
Parameters
relFile
stringRelative path to the input file
RegisterStepVariable(string, string, string, string, Func<MachiningStep, object>)
Registers a step variable for tracking during execution.
[JsAce(Snippet = "RegisterStepVariable(\"$1key\",\"$2name\",\"$3unit\",\"$4formatString\",\"$5variableFunc\")", DocContentHtml = "<p>Register Step Variable.</p> <p>\"unit\" is nullable</p> <p>\"formatString\" is nullable</p>")]
[NonAction]
public void RegisterStepVariable(string key, string name, string unit, string formatString, Func<MachiningStep, object> variableFunc = null)
Parameters
key
stringUnique key to identify the variable
name
stringHuman-readable name of the variable
unit
stringPhysical unit of the variable (can be null)
formatString
stringFormat string for displaying the variable (can be null)
variableFunc
Func<MachiningStep, object>Function to compute the variable value from a milling step (can be null)
RemoveFlyPiece()
Removes any disconnected or “flying” pieces from the workpiece geometry.
[JsAce]
[HttpPost]
public void RemoveFlyPiece()
Reset()
Reset Player
[JsAce(DocContentHtml = "Reset Player")]
[HttpPost]
public void Reset()
ResetRuntime()
Clears internal buffers.
[JsAce]
[HttpPost]
public void ResetRuntime()
RunNc(string, string)
Runs NC code directly from a string.
[JsAce(Snippet = "RunNc($1\"ncCommand\",$2\"\"(Direct Command)\"\");", DocContentHtml = "Run NC. second parameter is the file name alternative shows in the log.")]
[NonAction]
public IEnumerable<Action> RunNc(string ncText, string fileNameAlternative = "--")
Parameters
Returns
- IEnumerable<Action>
Enumerable sequence of actions to be executed
RunNcFile(string)
Runs an NC file with the specified relative path.
[JsAce("RunNcFile($1\"ncFile\");")]
[NonAction]
public IEnumerable<Action> RunNcFile(string relNcFilePath)
Parameters
relNcFilePath
stringRelative path to the NC file
Returns
- IEnumerable<Action>
Enumerable sequence of actions to be executed
SetNcResolutionFeedPerCycle()
Sets NC resolution to feed per cycle mode.
[HttpPost]
public void SetNcResolutionFeedPerCycle()
SetNcResolutionFeedPerTooth()
Sets NC resolution to feed per tooth mode.
[HttpPost]
public void SetNcResolutionFeedPerTooth()
SetNcResolutionFixed(double, double)
Sets NC resolution to fixed mode with specified resolution values.
[HttpPost]
public void SetNcResolutionFixed(double linearResolution_mm, double rotaryResolution_deg)
Parameters
linearResolution_mm
doubleLinear resolution in millimeters.
rotaryResolution_deg
doubleRotary resolution in degrees.
SetStickMachiningToolObservationHeight_mm(int, double)
Sets the observation height in millimeters for the specified stick machining tool.
[JsAce("SetStickMachiningToolObservationHeight_mm($1toolId,$2height_mm)")]
[HttpPost]
public void SetStickMachiningToolObservationHeight_mm(int toolId, double height)
Parameters
SetUniformContourTrayShiftAngle_deg(int, double)
Sets the shift angle in degrees for the uniform contour tray of the specified tool.
[JsAce("SetUniformContourTrayShiftAngle_deg($1toolId,$2angle_deg)")]
[HttpPost]
public void SetUniformContourTrayShiftAngle_deg(int toolId, double angle_deg)
Parameters
ShiftDistance_mm(double)
Creates a distance shift object representing the specified distance in millimeters.
[NonAction]
public DistanceShift ShiftDistance_mm(double distanceShift_mm)
Parameters
distanceShift_mm
doubleDistance shift in millimeters
Returns
- DistanceShift
Distance shift object
ShiftTime_s(double)
Creates a time shift object representing the specified time in seconds.
[NonAction]
public TimeShift ShiftTime_s(double seconds)
Parameters
seconds
doubleTime in seconds
Returns
- TimeShift
Time shift object
TrainMillingPara(SampleFlag, string, double)
Trains milling parameters using the specified sample flag.
[JsAce("TrainMillingPara(Fx|Fy|Fz, $1dstFile)")]
[HttpPost]
public void TrainMillingPara(SampleFlag sampleFlag, string dstRelFile, double outlierRatio = 2)
Parameters
sampleFlag
SampleFlagSample flag indicating which components to train
dstRelFile
stringDestination relative file path
outlierRatio
doubleOutlier ratio for data filtering
WarningMessage(string)
Displays a warning message in the message host.
[JsAce("WarningMessage($1message)")]
[HttpPost]
public void WarningMessage(string message)
Parameters
message
stringThe warning message to display
WriteRuntimeGeom(string)
Writes the current runtime geometry to a file.
[JsAce("WriteRuntimeGeom($1\"dstFile\")")]
[HttpPost]
public void WriteRuntimeGeom(string relFile)
Parameters
relFile
stringRelative path to the output file
WriteRuntimeGeomToStl(string, double)
Writes the current runtime geometry to an STL file.
[JsAce("WriteRuntimeGeomToStl($1\"dstFile\",$2resolution_mm)")]
[HttpPost]
public void WriteRuntimeGeomToStl(string relFile, double resolution_mm = 0)
Parameters
relFile
stringRelative path to the output STL file
resolution_mm
doubleResolution in millimeters (0 for default)
WriteShotFiles(double, string)
Writes time-series data to shot files with the specified resolution period (alternative parameter order).
[HttpPost]
public void WriteShotFiles(double resolutionPeroid_ms, string relFileTemplate)
Parameters
resolutionPeroid_ms
doubleResolution period in milliseconds
relFileTemplate
stringTemplate for output file path, can include [NcName] placeholder
WriteShotFiles(string, double)
Writes time-series data to shot files with the specified resolution period.
[JsAce(Snippet = "WriteShotFiles(\"Output/[NcName].shot.csv\",resolutionPeroid_ms)", DocContentHtml = "Write time series data by resolutionPeroid_ms")]
[HttpPost]
public void WriteShotFiles(string relFileTemplate = "Output/[NcName].shot.csv", double resolutionPeroid_ms = 1)
Parameters
relFileTemplate
stringTemplate for output file path, can include [NcName] placeholder
resolutionPeroid_ms
doubleResolution period in milliseconds
WriteStepFiles(string)
Writes step-series data to files with the specified file template.
[JsAce(Snippet = "WriteStepFiles(\"Output/[NcName].step.csv\")", DocContentHtml = "Write step series data.")]
[HttpPost]
public void WriteStepFiles(string relFileTemplate = "Output/[NcName].step.csv")
Parameters
relFileTemplate
stringTemplate for output file path, can include [NcName] placeholder
Events
MachiningStepBuilt
Gets or sets the action to configure steps during execution.
[JsAce(Snippet = "MachiningStepBuilt+=($1preStep,$2curStep)=>{$3Command};", DocContentHtml = "Runtime Step Configuration action. preStep is the Previous Milling Step; curStep is the Current Milling Step. preStep is null if no previous step existed.")]
public event MachiningActRunner.MachiningStepBuiltDelegate MachiningStepBuilt
Event Type
MachiningStepSelected
Event that is triggered when a milling step is selected.
[JsAce(Snippet = "MachiningStepSelected+=($1millingStep)=>{$2Command};")]
public event Action<MachiningStep> MachiningStepSelected