update ISO coordinate rendering for 3+2axis machine.
This commit is contained in:
@@ -159,38 +159,38 @@ using Hi.MachiningProcs;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Sample.Machining
|
||||
namespace Sample.Machining;
|
||||
|
||||
/// <summary>
|
||||
/// Demonstrates how to load and use an existing <see cref="MachiningProject"/> instance.
|
||||
/// This sample shows how to set up event handlers for messages and machining step objects,
|
||||
/// execute NC files, and properly manage project resources using
|
||||
/// <see cref="IDisposable.Dispose"/>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// ### Source Code
|
||||
/// [!code-csharp[SampleCode](~/../Hi.Sample/Machining/DemoUseMachiningProject.cs)]
|
||||
/// </remarks>
|
||||
public static class DemoUseMachiningProject
|
||||
{
|
||||
/// <summary>
|
||||
/// Demonstrates how to load and use an existing <see cref="MachiningProject"/> instance.
|
||||
/// This sample shows how to set up event handlers for messages and machining step objects,
|
||||
/// execute NC files, and properly manage project resources using
|
||||
/// <see cref="IDisposable.Dispose"/>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// ### Source Code
|
||||
/// [!code-csharp[SampleCode](~/../Hi.Sample/Machining/DemoUseMachiningProject.cs)]
|
||||
/// </remarks>
|
||||
public static class DemoUseMachiningProject
|
||||
static void Main()
|
||||
{
|
||||
static void Main()
|
||||
{
|
||||
LocalApp.AppBegin();
|
||||
LocalProjectService localProjectService = new LocalProjectService();
|
||||
LocalApp.AppBegin();
|
||||
LocalProjectService localProjectService = new LocalProjectService();
|
||||
|
||||
#region ProjectLoading
|
||||
var projectPath = "C:/HiNC-Projects/DemoStandardPath/Main.hincproj";
|
||||
Console.WriteLine($"Load Project: {projectPath}");
|
||||
localProjectService.LoadProject(projectPath);
|
||||
MachiningProject machiningProject = localProjectService.MachiningProject;
|
||||
#endregion
|
||||
#region ProjectLoading
|
||||
var projectPath = "C:/HiNC-Projects/DemoStandardPath/Main.hincproj";
|
||||
Console.WriteLine($"Load Project: {projectPath}");
|
||||
localProjectService.LoadProject(projectPath);
|
||||
MachiningProject machiningProject = localProjectService.MachiningProject;
|
||||
#endregion
|
||||
|
||||
#region EventHandling
|
||||
Console.WriteLine($"Set message event.");
|
||||
#region EventHandling
|
||||
Console.WriteLine($"Set message event.");
|
||||
|
||||
using StreamWriter writer = new StreamWriter("msg.txt");
|
||||
//show message if something abnormal.
|
||||
localProjectService.SessionMessageHost.CollectionItemAdded += pack =>
|
||||
using StreamWriter writer = new StreamWriter("msg.txt");
|
||||
//show message if something abnormal.
|
||||
localProjectService.SessionProgress.CollectionItemAdded += pack =>
|
||||
{
|
||||
if (pack.Tags.Contains(MessageFlag.Warning.ToString()) ||
|
||||
pack.Tags.Contains(MessageFlag.Error.ToString()) ||
|
||||
@@ -200,42 +200,42 @@ namespace Sample.Machining
|
||||
writer.WriteLine($"{pack.Message} At \"{sourceCommand?.FilePath}\" (Line {sourceCommand?.GetLineNo()}) \"{sourceCommand?.Line}\"");
|
||||
}
|
||||
};
|
||||
Console.WriteLine($"Set machining step event.");
|
||||
//show MRR.
|
||||
localProjectService.RuntimeApi.MachiningStepBuilt += (preStep, curStep) =>
|
||||
Console.WriteLine($"Set machining step event.");
|
||||
//show MRR.
|
||||
localProjectService.RuntimeApi.MachiningStepBuilt += (preStep, curStep) =>
|
||||
{
|
||||
var sourceCommand = curStep.SourceCommand;
|
||||
var indexedFileLine=sourceCommand?.GetSentence()?.IndexedFileLine;
|
||||
if (curStep.Mrr_mm3ds > 500) //show only the step that contains large MRR.
|
||||
Console.WriteLine($"MRR = {curStep.Mrr_mm3ds} At \"{sourceCommand?.FilePath}\" (Line {sourceCommand?.GetLineNo()}) \"{sourceCommand?.Line}\"");
|
||||
Console.WriteLine($"MRR = {curStep.Mrr_mm3ds} At \"{indexedFileLine?.FilePath}\" (Line {indexedFileLine?.GetLineNo()}) \"{indexedFileLine?.Line}\"");
|
||||
};
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region MachiningExecution
|
||||
Console.WriteLine($"Reset runtime status.");
|
||||
localProjectService.ResetRuntime();
|
||||
#region MachiningExecution
|
||||
Console.WriteLine($"Reset runtime status.");
|
||||
localProjectService.ResetRuntime();
|
||||
|
||||
Console.WriteLine($"Session begin.");
|
||||
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
|
||||
Console.WriteLine($"Session begin.");
|
||||
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
|
||||
|
||||
#region CleanupResources
|
||||
Console.WriteLine($"Close Project: {projectPath}");
|
||||
machiningProject.Dispose();
|
||||
#region CleanupResources
|
||||
Console.WriteLine($"Close Project: {projectPath}");
|
||||
machiningProject.Dispose();
|
||||
|
||||
LocalApp.AppEnd();
|
||||
LocalApp.AppEnd();
|
||||
|
||||
Console.WriteLine($"Program end.");
|
||||
#endregion
|
||||
}
|
||||
Console.WriteLine($"Program end.");
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
</code></pre></div>
|
||||
|
||||
Reference in New Issue
Block a user