fix bug of wpf mission initialization.

This commit is contained in:
unknown 2025-08-30 15:31:54 +08:00
parent a5e8b11156
commit a570fced8a
2 changed files with 125 additions and 119 deletions

View File

@ -36,27 +36,31 @@ namespace Sample.Machining
LocalApp.AppBegin(); LocalApp.AppBegin();
LocalProjectService localProjectService = new LocalProjectService();
#region ProjectLoading #region ProjectLoading
//var projectPath = "C:/HiNC-Projects/DemoStandardPath/Main.hincproj"; //var projectPath = "C:/HiNC-Projects/DemoStandardPath/Main.hincproj";
var projectPath = "C:/HiNC-Projects/demo-test-1/Main.hincproj"; var projectPath = "C:/HiNC-Projects/demo-test-1/Main.hincproj";
var projectDir = Path.GetDirectoryName(projectPath);
Console.WriteLine($"Load Project: {projectPath}"); Console.WriteLine($"Load Project: {projectPath}");
MachiningProject project = MachiningProject.LoadFile(projectPath); localProjectService.LoadProject(projectPath).ShowIfCatched(null);
var project = localProjectService.MachiningProject;
#endregion #endregion
var projectDisplayee = new MachiningProjectDisplayee(project); var projectDisplayee = new MachiningProjectDisplayee(()=> localProjectService.MachiningProject);
var device = new ClMillingDevice(); var device = new ClMillingDevice();
project.MachiningEquipment.MachiningChain = device; project.MachiningEquipment.MachiningChain = device;
project.ClStrip.IsShowDot = true; project.ClStrip.IsShowDot = true;
double resolution_mm = 0.5; double resolution_mm = 0.5;
var projectDir = Path.GetDirectoryName(projectPath);
project.Workpiece.InitGeom = new StlFile(stlFile_CylinderR20, projectDir); project.Workpiece.InitGeom = new StlFile(stlFile_CylinderR20, projectDir);
project.Workpiece.IdealGeom = new StlFile(stlFile_CylinderR19, projectDir); project.Workpiece.IdealGeom = new StlFile(stlFile_CylinderR19, projectDir);
project.Workpiece.InitResolution = resolution_mm; project.Workpiece.InitResolution = resolution_mm;
project.RuntimeController.SetNcResolutionFixed(9999, 15); RuntimeApi runtimeApi = new RuntimeApi(localProjectService);
project.RuntimeController.EnableCollisionDetection = false; runtimeApi.SetNcResolutionFixed(9999, 15);
project.RuntimeController.EnablePhysics = false; runtimeApi.EnableCollisionDetection = false;
project.RuntimeController.MachiningResolution_mm = resolution_mm; runtimeApi.EnablePhysics = false;
runtimeApi.MachiningResolution_mm = resolution_mm;
//RunConsole(project, projectDisplayee, resolution_mm); //RunConsole(project, projectDisplayee, resolution_mm);
RunWindow(project, projectDisplayee, resolution_mm); RunWindow(project, projectDisplayee, resolution_mm);
@ -104,6 +108,8 @@ namespace Sample.Machining
} }
static void RunSession(MachiningProject project, double resolution_mm) static void RunSession(MachiningProject project, double resolution_mm)
{ {
RuntimeApi runtimeApi = new RuntimeApi(project);
project.BeginSession(); project.BeginSession();
double radius = 20; double radius = 20;
double z = -1; double z = -1;
@ -121,7 +127,7 @@ namespace Sample.Machining
project.Act(new ActClStep(cl)); project.Act(new ActClStep(cl));
} }
double diffLimit_mm = resolution_mm * 2; double diffLimit_mm = resolution_mm * 2;
project.RuntimeController.Diff(resolution_mm * 2); runtimeApi.Diff(resolution_mm * 2);
Console.WriteLine($"IsDifferenceAceptable: {IsDifferenceAceptable(project, diffLimit_mm)}"); Console.WriteLine($"IsDifferenceAceptable: {IsDifferenceAceptable(project, diffLimit_mm)}");
project.EndSession(); project.EndSession();
} }

View File

@ -33,7 +33,7 @@ namespace Sample.Machining
Console.WriteLine($"Load Project: {projectPath}"); Console.WriteLine($"Load Project: {projectPath}");
MachiningProject machiningProject = MachiningProject.LoadFile(projectPath); MachiningProject machiningProject = MachiningProject.LoadFile(projectPath);
machiningProject.RuntimeController.MachiningStepSelected += (MachiningStep step) => machiningProject.RuntimeApi.MachiningStepSelected += (MachiningStep step) =>
{ {
var sourceCommand = step.SourceCommand; var sourceCommand = step.SourceCommand;
Console.WriteLine($"Step Selected: MRR = {step.Mrr_mm3ds} At \"{sourceCommand?.FilePath}\" (Line {sourceCommand?.GetLineNo()}) \"{sourceCommand?.Line}\""); Console.WriteLine($"Step Selected: MRR = {step.Mrr_mm3ds} At \"{sourceCommand?.FilePath}\" (Line {sourceCommand?.GetLineNo()}) \"{sourceCommand?.Line}\"");
@ -42,7 +42,7 @@ namespace Sample.Machining
#endregion #endregion
#region Configure Rendering Options #region Configure Rendering Options
var projectDisplayee = new MachiningProjectDisplayee(machiningProject); var projectDisplayee = new MachiningProjectDisplayee(()=>machiningProject);
projectDisplayee.RenderingFlagBitArray[(int)RenderingFlag.Mech] = true; projectDisplayee.RenderingFlagBitArray[(int)RenderingFlag.Mech] = true;
projectDisplayee.RenderingFlagBitArray[(int)RenderingFlag.Fixture] = true; projectDisplayee.RenderingFlagBitArray[(int)RenderingFlag.Fixture] = true;
projectDisplayee.RenderingFlagBitArray[(int)RenderingFlag.WorkpieceGeom] = false; projectDisplayee.RenderingFlagBitArray[(int)RenderingFlag.WorkpieceGeom] = false;