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

View File

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