From fece18d725295cbd9d7c6b07fe8f8fff75f26053 Mon Sep 17 00:00:00 2001 From: iamboss Date: Mon, 22 Dec 2025 23:35:42 +0800 Subject: [PATCH] add ChartRange to ClStrip. --- Common/DemoSessionMessage.cs | 10 +++--- .../DemoBuildGeomOnlyMachiningProject.cs | 18 +++++----- Machining/DemoBuildMachiningProject.cs | 20 ++++++----- Machining/DemoUseMachiningProject.cs | 34 ++++++++++--------- 4 files changed, 44 insertions(+), 38 deletions(-) diff --git a/Common/DemoSessionMessage.cs b/Common/DemoSessionMessage.cs index 4adc69c..93fe7e9 100644 --- a/Common/DemoSessionMessage.cs +++ b/Common/DemoSessionMessage.cs @@ -22,9 +22,9 @@ namespace Sample.Common public static class DemoSessionMessage { #region Demo_UseSessionMessageHost - internal static void DemoUseSessionMessageHost(MachiningProject project) + internal static void DemoUseSessionMessageHost(LocalProjectService localProjectService) { - SessionMessageHost sessionMessageHost = project.SessionMessageHost; + SessionMessageHost sessionMessageHost = localProjectService.SessionMessageHost; SessionMessageHost.FilterFlag filterFlags = SessionMessageHost.FilterFlag.NC | @@ -58,10 +58,10 @@ namespace Sample.Common } #endregion - internal static void DemoUseSessionMessageHost2(MachiningProject project) + internal static void DemoUseSessionMessageHost2(LocalProjectService localProjectService) { - SessionMessageHost sessionMessageHost = project.SessionMessageHost; - IMachiningChain machiningChain = project.MachiningEquipment?.MachiningChain; + SessionMessageHost sessionMessageHost = localProjectService.SessionMessageHost; + IMachiningChain machiningChain = localProjectService.MachiningChain; PresentAttribute mrrPresent = typeof(MachiningStep).GetProperty(nameof(MachiningStep.Mrr_mm3ds)).GetCustomAttribute(); string mrrUnit = mrrPresent?.TailUnitString; diff --git a/Machining/DemoBuildGeomOnlyMachiningProject.cs b/Machining/DemoBuildGeomOnlyMachiningProject.cs index e14c739..70beaab 100644 --- a/Machining/DemoBuildGeomOnlyMachiningProject.cs +++ b/Machining/DemoBuildGeomOnlyMachiningProject.cs @@ -43,11 +43,13 @@ namespace Sample.Machining static void Main() { LocalApp.AppBegin(); + LocalProjectService localProjectService = new LocalProjectService(); - var projectPath = "C:/HiNC-Projects/NewProject/Main.hincproj"; + var projectPath = "C:/HiNC-Projects/NewProject/Main.hincproj"; var projectDirectory = Path.GetDirectoryName(projectPath); Console.WriteLine($"Directory of the New Project: {projectDirectory}"); - MachiningProject machiningProject = new MachiningProject(projectDirectory); + localProjectService.LoadProject(projectPath); + MachiningProject machiningProject = localProjectService.MachiningProject; CylindroidHolder cylindroidHolder = new CylindroidHolder() { @@ -55,7 +57,7 @@ namespace Sample.Machining Cylindroid = new Cylindroid([ new PairZr(0,12),new PairZr(20,12), new PairZr(20,16),new PairZr(30,16)]) }; - machiningProject.MachiningToolHouse = new MachiningToolHouse() + localProjectService.MachiningToolHouse = new MachiningToolHouse() { [1] = new MillingTool() { @@ -66,13 +68,13 @@ namespace Sample.Machining }, }; - machiningProject.MachiningEquipment.Fixture = new Fixture() + localProjectService.Fixture = new Fixture() { Geom = new Box3d(new Vec3d(-40, -40, 0), new Vec3d(40, 40, 10)), GeomToWorkpieceTransformer = new StaticTranslation(new Vec3d(0, 0, 10)), }; - machiningProject.MachiningEquipment.Workpiece = new Workpiece() + localProjectService.Workpiece = new Workpiece() { InitResolution = 0.25, InitGeom = new Box3d(0, 0, -50, 70, 50, 0), @@ -80,12 +82,12 @@ namespace Sample.Machining WorkpieceGeomToFixtureBuckleTransformer = new StaticTranslation(new Vec3d(0, 0, 0)), }; - machiningProject.MachiningEquipment.MachiningChain + localProjectService.MachiningChain = XFactory.GenByFile( "Resource", "MachineTool/PMC-B1/PMC-B1.mt", GenMode.Default); - machiningProject.MachiningEquipment.MachiningChainFile = "PMC-B1/PMC-B1.mt"; + localProjectService.MachiningChainFile = "PMC-B1/PMC-B1.mt"; - machiningProject.MakeXmlSourceFile(projectPath); + localProjectService.SaveProject(); machiningProject.Dispose(); LocalApp.AppEnd(); diff --git a/Machining/DemoBuildMachiningProject.cs b/Machining/DemoBuildMachiningProject.cs index 2a24cc1..8dd74f1 100644 --- a/Machining/DemoBuildMachiningProject.cs +++ b/Machining/DemoBuildMachiningProject.cs @@ -143,14 +143,16 @@ namespace Sample.Machining static void Main() { LocalApp.AppBegin(); + LocalProjectService localProjectService = new LocalProjectService(); - var projectPath = "C:/HiNC-Projects/NewProject/Main.hincproj"; + var projectPath = "C:/HiNC-Projects/NewProject/Main.hincproj"; var projectDirectory = Path.GetDirectoryName(projectPath); Console.WriteLine($"Directory of the New Project: {projectDirectory}"); - MachiningProject machiningProject = new MachiningProject(projectDirectory); + localProjectService.LoadProject(projectPath); + MachiningProject machiningProject = localProjectService.MachiningProject; - #region ConfigureMachiningToolHouse - machiningProject.MachiningToolHouse = new MachiningToolHouse() + #region ConfigureMachiningToolHouse + localProjectService.MachiningToolHouse = new MachiningToolHouse() { [1] = new MillingTool() { @@ -174,10 +176,10 @@ namespace Sample.Machining Cutter = CreateMillingCutter1() }, }; - #endregion + #endregion - #region ConfigureFixture - machiningProject.MachiningEquipment.Fixture = new Fixture() + #region ConfigureFixture + localProjectService.Fixture = new Fixture() { Geom = new Box3d(new Vec3d(-40, -40, 0), new Vec3d(40, 40, 10)), GeomToWorkpieceTransformer = new StaticTranslation(new Vec3d(0, 0, 10)), @@ -185,7 +187,7 @@ namespace Sample.Machining #endregion #region ConfigureWorkpiece - machiningProject.MachiningEquipment.Workpiece = new Workpiece() + localProjectService.Workpiece = new Workpiece() { InitResolution = 0.25, InitGeom = new Box3d(0, 0, -50, 70, 50, 0), @@ -199,7 +201,7 @@ namespace Sample.Machining #endregion #region ConfigureMachineChain - machiningProject.MachiningEquipment.MachiningChain + localProjectService.MachiningChain = XFactory.GenByFile( "Resource", "MachineTool/PMC-B1/PMC-B1.mt", GenMode.Default); #endregion diff --git a/Machining/DemoUseMachiningProject.cs b/Machining/DemoUseMachiningProject.cs index 5fbbfd7..0746fac 100644 --- a/Machining/DemoUseMachiningProject.cs +++ b/Machining/DemoUseMachiningProject.cs @@ -22,11 +22,13 @@ namespace Sample.Machining static void Main() { LocalApp.AppBegin(); + LocalProjectService localProjectService = new LocalProjectService(); - #region ProjectLoading - var projectPath = "C:/HiNC-Projects/DemoStandardPath/Main.hincproj"; + #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 @@ -34,7 +36,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()) || @@ -45,8 +47,8 @@ namespace Sample.Machining } }; Console.WriteLine($"Set machining step event."); - //show MRR. - machiningProject.RuntimeApi.MachiningStepBuilt += (preStep, curStep) => + //show MRR. + localProjectService.RuntimeApi.MachiningStepBuilt += (preStep, curStep) => { var sourceCommand = curStep.SourceCommand; if (curStep.Mrr_mm3ds > 500) //show only the step that contains large MRR. @@ -56,18 +58,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; - //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.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. + localProjectService.RuntimeApi.PlayNcFile("NC/side.ptp"); + localProjectService.RuntimeApi.PlayNcFile("NC/circle.ptp"); + localProjectService.EndSession(); Console.WriteLine($"Session end."); #endregion