This commit is contained in:
2025-07-25 16:27:29 +08:00
parent 38b27cd481
commit b5cad3c171
1114 changed files with 68009 additions and 23981 deletions
@@ -153,11 +153,10 @@ execute NC files, and properly manage project resources using
<h2 id="Sample_Machining_DemoUseMachiningProject_remarks">Remarks</h2>
<div class="markdown level0 remarks"><h3 id="source-code">Source Code</h3>
<pre><code class="lang-csharp" name="SampleCode">using System;
using Hi.Licenses;
using Hi.Common.Messages;
using Hi.MachiningProcs;
using Hi.Common.FileLines;
using Hi.MongoUtils;
using Hi.HiNcKits;
namespace Sample.Machining
{
@@ -175,16 +174,7 @@ namespace Sample.Machining
{
static void Main()
{
#region LicenseAndDatabaseSetup
Console.WriteLine($&quot;License Login.&quot;);
License.LogInAll();
Console.WriteLine($&quot;Start Database.&quot;);
MongoServer.Default = MongoServer.Run(new MongoRunnerOptions()
{
MongoPort = 28100
});
#endregion
LocalApp.AppBegin();
#region ProjectLoading
var projectPath = &quot;C:/HiNC-Projects/DemoStandardPath/Main.hincproj&quot;;
@@ -199,7 +189,7 @@ namespace Sample.Machining
{
if (pack.Tags.Contains(MessageFlag.Warning.ToString()) ||
pack.Tags.Contains(MessageFlag.Error.ToString()) ||
pack.Tags.Contains(MessageFlag.SysErr.ToString()))
pack.Tags.Contains(MessageFlag.Exception.ToString()))
{
var sourceCommand = pack.SourceCommand;
Console.WriteLine($&quot;{pack.Message} At \&quot;{sourceCommand?.FilePath}\&quot; (Line {sourceCommand?.GetLineNo()}) \&quot;{sourceCommand?.Line}\&quot;&quot;);
@@ -207,7 +197,7 @@ namespace Sample.Machining
};
Console.WriteLine($&quot;Set machining step event.&quot;);
//show MRR.
machiningProject.ShellApi.MachiningStepBuilt += (preStep, curStep) =&gt;
machiningProject.RuntimeController.MachiningStepBuilt += (preStep, curStep) =&gt;
{
var sourceCommand = curStep.SourceCommand;
if (curStep.Mrr_mm3ds &gt; 500) //show only the step that contains large MRR.
@@ -221,13 +211,13 @@ namespace Sample.Machining
Console.WriteLine($&quot;Session begin.&quot;);
machiningProject.BeginSession();
machiningProject.ShellApi.MachiningResolution_mm = 1;
machiningProject.ShellApi.EnableCollisionDetection = true;
machiningProject.ShellApi.EnablePauseOnCollision = false;
machiningProject.ShellApi.EnableMillingForceEvaluation = false;
machiningProject.RuntimeController.MachiningResolution_mm = 1;
machiningProject.RuntimeController.EnableCollisionDetection = true;
machiningProject.RuntimeController.EnablePauseOnFailure = false;
machiningProject.RuntimeController.EnablePhysics = false;
//the path from Shell-API is relative by project directory.
machiningProject.ShellApi.PlayNcFile(&quot;NC/side.ptp&quot;);
machiningProject.ShellApi.PlayNcFile(&quot;NC/circle.ptp&quot;);
machiningProject.RuntimeController.PlayNcFile(&quot;NC/side.ptp&quot;);
machiningProject.RuntimeController.PlayNcFile(&quot;NC/circle.ptp&quot;);
machiningProject.EndSession();
Console.WriteLine($&quot;Session end.&quot;);
#endregion
@@ -236,11 +226,7 @@ namespace Sample.Machining
Console.WriteLine($&quot;Close Project: {projectPath}&quot;);
machiningProject.Dispose();
Console.WriteLine($&quot;Close Database.&quot;);
MongoServer.Default.Dispose();
Console.WriteLine($&quot;License Logout.&quot;);
License.LogOutAll();
LocalApp.AppEnd();
Console.WriteLine($&quot;Program end.&quot;);
#endregion