publish aicam server.
This commit is contained in:
parent
21211fa726
commit
e2cb50d1e7
@ -14,7 +14,7 @@
|
||||
<Product>$(AssemblyName)</Product>
|
||||
<OutputPath>bin\$(Platform).$(Configuration)\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<StartupObject>Sample.Machining.DemoRenderingMachiningProcessAndStripPosSelection</StartupObject>
|
||||
<StartupObject>Sample.Machining.DemoMillingByCutterLocation</StartupObject>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup Condition="'$(Configuration)'=='Debug'">
|
||||
|
141
Machining/DemoMillingByCutterLocation.cs
Normal file
141
Machining/DemoMillingByCutterLocation.cs
Normal file
@ -0,0 +1,141 @@
|
||||
using Hi.Common;
|
||||
using Hi.Disp;
|
||||
using Hi.Geom;
|
||||
using Hi.Geom.Resolution;
|
||||
using Hi.HiNcKits;
|
||||
using Hi.MachiningProcs;
|
||||
using Hi.Numerical.Acts;
|
||||
using Hi.Wpf.Disp;
|
||||
using HiMachining.Milling;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
||||
namespace Sample.Machining
|
||||
{
|
||||
/// <remarks>
|
||||
/// ### Source Code
|
||||
/// [!code-csharp[SampleCode](~/../Hi.Sample/Machining/DemoMillingByCutterLocation.cs)]
|
||||
/// </remarks>
|
||||
public static class DemoMillingByCutterLocation
|
||||
{
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
int h = 2;
|
||||
string stlFile_CylinderR20 = $"Cache/CylinderH{h}R20.stl";
|
||||
string stlFile_CylinderR19 = $"Cache/CylinderH{h}R19.stl";
|
||||
string stlFile_CylinderR18 = $"Cache/CylinderH{h}R18.stl";
|
||||
new Cylindroid(new PairZr(-h, 20), new PairZr(0, 20))
|
||||
.GenStl(new PolarResolution2d(1, MathUtil.ToRad(15))).WriteBin(stlFile_CylinderR20);
|
||||
new Cylindroid(new PairZr(-h, 19), new PairZr(0, 19))
|
||||
.GenStl(new PolarResolution2d(1, MathUtil.ToRad(15))).WriteBin(stlFile_CylinderR19);
|
||||
new Cylindroid(new PairZr(-h, 18), new PairZr(0, 18))
|
||||
.GenStl(new PolarResolution2d(1, MathUtil.ToRad(15))).WriteBin(stlFile_CylinderR18);
|
||||
|
||||
SingleUserApp.AppBegin();
|
||||
|
||||
#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);
|
||||
#endregion
|
||||
|
||||
var projectDisplayee = new MachiningProjectDisplayee(project);
|
||||
var device = new ClMillingDevice();
|
||||
project.MachiningEquipment.MachiningChain = device;
|
||||
project.ClStrip.IsShowDot = true;
|
||||
double resolution_mm = 0.5;
|
||||
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;
|
||||
|
||||
//RunConsole(project, projectDisplayee, resolution_mm);
|
||||
RunWindow(project, projectDisplayee, resolution_mm);
|
||||
}
|
||||
static void RunConsole(MachiningProject project,
|
||||
MachiningProjectDisplayee projectDisplayee, double resolution_mm)
|
||||
{
|
||||
RunSession(project, resolution_mm);
|
||||
DispEngine dispEngine = new DispEngine(projectDisplayee);
|
||||
dispEngine.SetViewToIsometricView();
|
||||
dispEngine.SketchView = project.ClStrip.GetFittingView(dispEngine.SketchView);
|
||||
dispEngine.SketchView = dispEngine.SketchView.Scale(0.5);
|
||||
dispEngine.Snapshot($"Cache/result.bmp", 1000, 1000);
|
||||
|
||||
project.Dispose();
|
||||
SingleUserApp.AppEnd();
|
||||
Console.WriteLine($"App exit.");
|
||||
}
|
||||
static void RunWindow(MachiningProject project,
|
||||
MachiningProjectDisplayee projectDisplayee, double resolution_mm)
|
||||
{
|
||||
var task = Task.Run(() =>
|
||||
{
|
||||
RunSession(project, resolution_mm);
|
||||
Console.WriteLine($"task done.");
|
||||
}).ShowIfCatched(null);
|
||||
|
||||
#region Create and Run WPF Application
|
||||
Application app = new Application
|
||||
{
|
||||
ShutdownMode = ShutdownMode.OnMainWindowClose
|
||||
};
|
||||
app.Exit += (o, e) =>
|
||||
{
|
||||
project.Dispose();
|
||||
SingleUserApp.AppEnd();
|
||||
Console.WriteLine($"App exit.");
|
||||
};
|
||||
app.Run(new RenderingWindow()
|
||||
{
|
||||
Title = "Demo",
|
||||
Displayee = projectDisplayee
|
||||
});
|
||||
#endregion
|
||||
}
|
||||
static void RunSession(MachiningProject project, double resolution_mm)
|
||||
{
|
||||
project.BeginSession();
|
||||
double radius = 20;
|
||||
double z = -1;
|
||||
project.Act(new ActToolingTeleport(1));//equip tool
|
||||
project.Act(new ActClTeleport(new DVec3d(radius, 0, z, 0, 0, 1)));//goto initial position
|
||||
//run an arbitrary contour.
|
||||
int divNum = 36;
|
||||
for (int i = 0; i <= divNum; i++)
|
||||
{
|
||||
var cl = new DVec3d(
|
||||
radius * Math.Cos(i * Math.PI * 2 / divNum),
|
||||
radius * Math.Sin(i * Math.PI * 2 / divNum), z,
|
||||
0, 0, 1);
|
||||
Console.WriteLine($"{cl.Point.CsvText},{cl.Normal.CsvText},");
|
||||
project.Act(new ActClStep(cl));
|
||||
}
|
||||
double diffLimit_mm = resolution_mm * 2;
|
||||
project.RuntimeController.Diff(resolution_mm * 2);
|
||||
Console.WriteLine($"IsDifferenceAceptable: {IsDifferenceAceptable(project, diffLimit_mm)}");
|
||||
project.EndSession();
|
||||
}
|
||||
static bool IsDifferenceAceptable(MachiningProject project, double diffLimit)
|
||||
{
|
||||
foreach (var attachment in project.Workpiece.DiffAttachmentBag)
|
||||
{
|
||||
if (double.IsNaN(attachment.Diff) || Math.Abs(attachment.Diff) > diffLimit)
|
||||
{
|
||||
Console.WriteLine($"Diff: {attachment.Diff}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
@ -7,6 +7,7 @@ using Hi.Common.FileLines;
|
||||
using System.Windows;
|
||||
using Hi.Disp;
|
||||
using Hi.MachiningSteps;
|
||||
using Hi.HiNcKits;
|
||||
|
||||
namespace Sample.Machining
|
||||
{
|
||||
@ -25,21 +26,14 @@ namespace Sample.Machining
|
||||
[STAThread]
|
||||
static void Main(string[] args)
|
||||
{
|
||||
#region Initialize Environment
|
||||
License.LogInAll();
|
||||
DispEngine.Init();
|
||||
MongoServer.Default = MongoServer.Run(new MongoRunnerOptions()
|
||||
{
|
||||
MongoPort = 28100
|
||||
});
|
||||
#endregion
|
||||
SingleUserApp.AppBegin();
|
||||
|
||||
#region Load Machining Project
|
||||
var projectPath = "C:/HiNC-Projects/DemoStandardPath/Main.hincproj";
|
||||
Console.WriteLine($"Load Project: {projectPath}");
|
||||
MachiningProject machiningProject = MachiningProject.LoadFile(projectPath);
|
||||
|
||||
machiningProject.ShellApi.MachiningStepSelected += (MachiningStep step) =>
|
||||
machiningProject.RuntimeController.MachiningStepSelected += (MachiningStep step) =>
|
||||
{
|
||||
var sourceCommand = step.SourceCommand;
|
||||
Console.WriteLine($"Step Selected: MRR = {step.Mrr_mm3ds} At \"{sourceCommand?.FilePath}\" (Line {sourceCommand?.GetLineNo()}) \"{sourceCommand?.Line}\"");
|
||||
@ -64,9 +58,7 @@ namespace Sample.Machining
|
||||
app.Exit += (o, e) =>
|
||||
{
|
||||
machiningProject.Dispose();
|
||||
MongoServer.Default.Dispose();
|
||||
DispEngine.FinishDisp();
|
||||
License.LogOutAll();
|
||||
SingleUserApp.AppEnd();
|
||||
Console.WriteLine($"App exit.");
|
||||
};
|
||||
app.Run(new RenderingWindow()
|
||||
|
Loading…
x
Reference in New Issue
Block a user