This commit is contained in:
2025-12-22 23:35:40 +08:00
parent 32ff8b45e3
commit 4556281c0a
77 changed files with 9248 additions and 3996 deletions
@@ -176,11 +176,13 @@ namespace Sample.Machining
static void Main()
{
LocalApp.AppBegin();
LocalProjectService localProjectService = new LocalProjectService();
#region ProjectLoading
var projectPath = "C:/HiNC-Projects/DemoStandardPath/Main.hincproj";
Console.WriteLine($"Load Project: {projectPath}");
MachiningProject machiningProject = MachiningProject.LoadFile(projectPath);
localProjectService.LoadProject(projectPath);
MachiningProject machiningProject = localProjectService.MachiningProject;
#endregion
#region EventHandling
@@ -188,7 +190,7 @@ namespace Sample.Machining
using StreamWriter writer = new StreamWriter("msg.txt");
//show message if something abnormal.
machiningProject.SessionMessageHost.CollectionItemAdded += pack =>
localProjectService.SessionMessageHost.CollectionItemAdded += pack =>
{
if (pack.Tags.Contains(MessageFlag.Warning.ToString()) ||
pack.Tags.Contains(MessageFlag.Error.ToString()) ||
@@ -200,7 +202,7 @@ namespace Sample.Machining
};
Console.WriteLine($"Set machining step event.");
//show MRR.
machiningProject.RuntimeApi.MachiningStepBuilt += (preStep, curStep) =>
localProjectService.RuntimeApi.MachiningStepBuilt += (preStep, curStep) =>
{
var sourceCommand = curStep.SourceCommand;
if (curStep.Mrr_mm3ds > 500) //show only the step that contains large MRR.
@@ -210,18 +212,18 @@ namespace Sample.Machining
#region MachiningExecution
Console.WriteLine($"Reset runtime status.");
machiningProject.ResetRuntime();
localProjectService.ResetRuntime();
Console.WriteLine($"Session begin.");
machiningProject.BeginSession();
machiningProject.RuntimeApi.MachiningResolution_mm = 1;
machiningProject.RuntimeApi.EnableCollisionDetection = true;
machiningProject.RuntimeApi.EnablePauseOnFailure = false;
machiningProject.RuntimeApi.EnablePhysics = false;
localProjectService.BeginSession();
localProjectService.RuntimeApi.MachiningResolution_mm = 1;
localProjectService.RuntimeApi.EnableCollisionDetection = true;
localProjectService.RuntimeApi.EnablePauseOnFailure = false;
localProjectService.RuntimeApi.EnablePhysics = false;
//the path from Shell-API is relative by project directory.
machiningProject.RuntimeApi.PlayNcFile("NC/side.ptp");
machiningProject.RuntimeApi.PlayNcFile("NC/circle.ptp");
machiningProject.EndSession();
localProjectService.RuntimeApi.PlayNcFile("NC/side.ptp");
localProjectService.RuntimeApi.PlayNcFile("NC/circle.ptp");
localProjectService.EndSession();
Console.WriteLine($"Session end.");
#endregion