add ChartRange to ClStrip.

This commit is contained in:
iamboss 2025-12-22 23:35:42 +08:00
parent 901a1181e2
commit fece18d725
4 changed files with 44 additions and 38 deletions

View File

@ -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<PresentAttribute>();
string mrrUnit = mrrPresent?.TailUnitString;

View File

@ -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 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<CodeXyzabcMachineTool>(
"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();

View File

@ -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 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()
localProjectService.MachiningToolHouse = new MachiningToolHouse()
{
[1] = new MillingTool()
{
@ -177,7 +179,7 @@ namespace Sample.Machining
#endregion
#region ConfigureFixture
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)),
@ -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<CodeXyzabcMachineTool>(
"Resource", "MachineTool/PMC-B1/PMC-B1.mt", GenMode.Default);
#endregion

View File

@ -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";
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()) ||
@ -46,7 +48,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.
@ -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;
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