commit 11ff5e343d5a9a0b33d41359eeb0cda33fad1b6d Author: iambossTC Date: Tue Apr 8 19:35:28 2025 +0800 re-init diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..1ff0c42 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,63 @@ +############################################################################### +# Set default behavior to automatically normalize line endings. +############################################################################### +* text=auto + +############################################################################### +# Set default behavior for command prompt diff. +# +# This is need for earlier builds of msysgit that does not have it on by +# default for csharp files. +# Note: This is only used by command line +############################################################################### +#*.cs diff=csharp + +############################################################################### +# Set the merge driver for project and solution files +# +# Merging from the command prompt will add diff markers to the files if there +# are conflicts (Merging from VS is not affected by the settings below, in VS +# the diff markers are never inserted). Diff markers may cause the following +# file extensions to fail to load in VS. An alternative would be to treat +# these files as binary and thus will always conflict and require user +# intervention with every merge. To do so, just uncomment the entries below +############################################################################### +#*.sln merge=binary +#*.csproj merge=binary +#*.vbproj merge=binary +#*.vcxproj merge=binary +#*.vcproj merge=binary +#*.dbproj merge=binary +#*.fsproj merge=binary +#*.lsproj merge=binary +#*.wixproj merge=binary +#*.modelproj merge=binary +#*.sqlproj merge=binary +#*.wwaproj merge=binary + +############################################################################### +# behavior for image files +# +# image files are treated as binary by default. +############################################################################### +#*.jpg binary +#*.png binary +#*.gif binary + +############################################################################### +# diff behavior for common document formats +# +# Convert binary document formats to text before diffing them. This feature +# is only available from the command line. Turn it on by uncommenting the +# entries below. +############################################################################### +#*.doc diff=astextplain +#*.DOC diff=astextplain +#*.docx diff=astextplain +#*.DOCX diff=astextplain +#*.dot diff=astextplain +#*.DOT diff=astextplain +#*.pdf diff=astextplain +#*.PDF diff=astextplain +#*.rtf diff=astextplain +#*.RTF diff=astextplain diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6d95f9c --- /dev/null +++ b/.gitignore @@ -0,0 +1,268 @@ +!*.lib + +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# DNX +project.lock.json +project.fragment.lock.json +artifacts/ + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Comment the next line if you want to checkin your web deploy settings +# but database connection strings (with potential passwords) will be unencrypted +#*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/packages/repositories.config +# NuGet v3's project.json files produces more ignoreable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +node_modules/ +orleans.codegen.cs + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +*.mdf +*.ldf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush +.cr/ + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +!hasp*.exe +!hasp*.dll +!HiLock.dll +!Aladdin*.dll diff --git a/Geom/DemoBuildGeom.cs b/Geom/DemoBuildGeom.cs new file mode 100644 index 0000000..ed287d0 --- /dev/null +++ b/Geom/DemoBuildGeom.cs @@ -0,0 +1,29 @@ +using System.Collections.Generic; +using Hi.Geom; +using Hi.Mech.Topo; + +namespace Sample.Geom +{ + public static class DemoBuildGeom + { + public static List GenGeoms() + { + Box3d box = new Box3d(0, 0, -50, 70, 50, 0); + Cylindroid cylindroid = new Cylindroid() + { + PairZrs = new List([ new PairZr(0,12),new PairZr(20,12), + new PairZr(20,16),new PairZr(30,16)]), + LongitudeNum = 30 + }; + Stl stl = new Stl("geom.stl"); + TransformationGeom transformationGeom = new TransformationGeom() + { + Transformer = new GeneralTransform(1, + new StaticRotation(new Vec3d(0, 0, 1), MathUtil.ToRad(15), new Vec3d(0, 0, 0)), + new StaticTranslation(new Vec3d(0, 0, 0))), + Geom = stl + }; + return new List([box, cylindroid, stl, transformationGeom]); + } + } +} diff --git a/Hi.Sample.csproj b/Hi.Sample.csproj new file mode 100644 index 0000000..40e5e15 --- /dev/null +++ b/Hi.Sample.csproj @@ -0,0 +1,36 @@ + + + Exe + net9.0 + x64 + true + Hi.Sample + Sample + + HiAPI samples. + + Demo;Maintenance + 0 + 1.4.$(VersionBuild) + $(AssemblyName) + techcoordinate.ico + Copyright 2025 Tech Coordinate Co., Ltd. + Tech Coordinate Co., Ltd. + Tech Coordinate Co., Ltd. + bin\$(Platform).$(Configuration)\ + + + + + + + + + + + DEBUG;TRACE + Sample.Machining.DemoUseMachiningProject + + + + \ No newline at end of file diff --git a/HiAPI_license.md b/HiAPI_license.md new file mode 100644 index 0000000..c8cd65e --- /dev/null +++ b/HiAPI_license.md @@ -0,0 +1,60 @@ +# HiAPI使用者條款 + +甲方:超級高科技股份有限公司 + +乙方:使用者 + +茲 甲方授權乙方使用 HiAPI軟體模組 一式,特立此書,乙方已閱讀並同意下列使用者條款: + +## 第一條、標的物 + +HiAPI軟體模組(以下簡稱本模組),內容、授權期間請見甲方提供之規格表。 + +## 第二條、智慧財產權保護及保密義務 + +一、本模組之結構、組織及代碼均屬於甲方所有的有價商業秘密和機密資訊,甲方提供之本模組及其所有相關資料,其智慧財產權均歸甲方所有。本模組僅供乙方內部使用,乙方同意依照使用者條款規範使用本模組,乙方不得出租、租賃、授權、移轉或販賣本組軟體、將本模組提供給第三方,亦不能修改、翻譯、逆向工程、反組譯、解譯本組軟體程序。 + +二、乙方開發之衍生軟體,其衍生智財及收入歸乙方。 + +三、乙方基於本模組開發之衍生軟體須甲方授權,第三方才可使用。 + +## 第三條、軟體確保之限制 + +本模組僅以「現貨」狀態為準,任何其它直接或隱含的表示,描述或擔保均不在確保之內。甲方及其經銷商對於特殊的、因其它事件而引起直接、間接或其它原因造成的損害,不負賠償責任。凡使用本模組所產生之結果及效能均由乙方自行承擔全部風險。 + +## 第四條、資訊蒐集 + +一、乙方同意提供本模組紀錄使用次數、使用時間及部份硬體資訊給甲方。 + +二、在乙方被授權電腦有連接網際網路之情況下,乙方同意將本條第一項所列資訊由本模組以網路傳輸方式傳遞給甲方。 + +三、所有紀錄及傳輸資訊,僅限於供甲方授權驗證及軟體保護之目的使用,將不會公開揭露於第三者或作為第三方使用。 + +## 第五條、同意條款 + +乙方安裝甲方軟體時,系統將會顯示「使用者條款」的條款和條件,乙方必須接受「使用者條 +款」的條款和條件,才能使用軟體產品,如果不同意「使用者條款」的條款和條件,則請勿安 +裝、複製、使用、存取或執行軟體產品,並立即向您的購買點提交書面退貨通知,行使「使用 +者條款」中所賦予的權利,即表示乙方同意遵守其條款和條件。 + +## 第六條、違約責任 + +若使用者違反本使用者條款之全部或部分,甲方有權自行判斷並採取其認為適當的措施,包括 +終止甲方與使用者間之合約、立刻暫停使用者使用本模組或甲方之其他服務,亦不排除對此等 +使用者採取法律行動。 + +## 第七條、一部無效 + +本使用者條款部分條款依法被認為無效時,其他條款仍應繼續有效。 + +(以下空白) + +甲 方:超級高科技股份有限公司 + +代表人:梅可人 董事長 + +統一編號:24921337 + +地址:台南市永康區忠義街60 巷3 號9 樓之11 + +日期:2020年1月27日 diff --git a/MachineTool/DemoBuildEmptyMachineTool.cs b/MachineTool/DemoBuildEmptyMachineTool.cs new file mode 100644 index 0000000..ac10e4f --- /dev/null +++ b/MachineTool/DemoBuildEmptyMachineTool.cs @@ -0,0 +1,38 @@ +using Hi.Geom; +using Hi.Mech.Topo; +using Hi.NcMech.Xyzabc; +using Hi.Numerical.Xyzabc; + +namespace Sample.MachineTool +{ + /// + /// Demo generating empty machine tool instances for testing or development. + /// + public static class DemoBuildEmptyMachineTool + { + /// + /// Generates an empty machine tool with basic configuration. + /// + /// A configured but empty machine tool without solids. + public static CodeXyzabcMachineTool GenEmptyMachineTool() + { + CodeXyzabcChain chain = new CodeXyzabcChain("[O][C][w];[O][X][Y][Z][B][S][t]"); + if (chain.ToolBuckleTransformer is StaticTranslation st) + st.Trans = new Vec3d(-200, 200, 400); + CodeXyzabcMachineTool xyzabcMachineTool = new CodeXyzabcMachineTool(chain); + return xyzabcMachineTool; + } + /// + /// Generates and saves an empty machine tool URI to a file. + /// + /// The base directory to save the machine tool file. + /// The machine tool URI object that was created and saved. + public static CodeXyzabcMachineToolUri GenEmptyMachineToolUri(string baseDirectory) + { + CodeXyzabcMachineToolUri machineToolUri = new CodeXyzabcMachineToolUri(@"Samples/EmpytMachineTool.mt", + GenEmptyMachineTool()); + machineToolUri.SaveToUri(baseDirectory); + return machineToolUri; + } + } +} diff --git a/MachineTool/DemoBuildMachineTool.cs b/MachineTool/DemoBuildMachineTool.cs new file mode 100644 index 0000000..7cf50a3 --- /dev/null +++ b/MachineTool/DemoBuildMachineTool.cs @@ -0,0 +1,82 @@ +using Hi.Common.XmlUtils; +using Hi.Geom; +using Hi.Mech; +using Hi.Mech.Topo; +using Hi.NcMech; +using Hi.NcMech.Solids; +using Hi.NcMech.Xyzabc; +using Hi.Numerical.Xyzabc; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Xml.Linq; + +namespace Sample.MachineTool +{ + /// + /// Provides access to the PMC-B1 machine tool model. + /// + public class DemoBuildMachineTool : IGetCodeXyzabcMachineTool + { + static DemoBuildMachineTool() + { + XFactory.Default.Regs.Add(XName, (xml, baseDirectory, relFile, res) => new DemoBuildMachineTool()); + } + /// + /// Generates an XYZ-ABC machine tool instance from embedded resources. + /// + /// A configured machine tool model. + public static CodeXyzabcMachineTool GenXyzabcMachineTool() + { + CodeXyzabcChain chain = new CodeXyzabcChain("[O][Y][X][C][w];[O][Z][B][S][t]"); + if (chain.ToolBuckleTransformer is StaticTranslation st) + st.Trans = new Vec3d(-72.40, 72.40, 176.44); + chain.TransformerB.Pivot = new Vec3d(-72.4, -177.4, 225.94); + Dictionary solidMap = new Dictionary() + { + ["O"] = new Solid(new Stl("MachineTool/base.stl")), + ["X"] = new Solid(new Stl("MachineTool/X.stl")), + ["Y"] = new Solid(new Stl("MachineTool/Y.stl")), + ["Z"] = new Solid(new Stl("MachineTool/Z.stl")), + ["B"] = new Solid(new Stl("MachineTool/B.stl")), + ["C"] = new Solid(new Stl("MachineTool/C.stl")), + ["S"] = new Solid(new Stl("MachineTool/spindle.stl")), + }; + chain.AnchorToSolid.BuildAnchorToSolid( + chain.Asmb.GetDescendantAnchors(), solidMap); + + CodeXyzabcMachineTool dst = new CodeXyzabcMachineTool(chain); + dst.GenerateCollisionIndexPairs(); + return dst; + } + + /// + /// The cached machine tool instance. + /// + CodeXyzabcMachineTool MachineTool { get; } + + /// + /// Default constructor that initializes the machine tool model. + /// + public DemoBuildMachineTool() + { + MachineTool = GenXyzabcMachineTool(); + } + #region XML IO + //public PmcB1MachineToolSource(XElement src, object res) : this() { } + /// + /// XML element name for serialization. + /// + public static string XName = nameof(DemoBuildMachineTool); + /// + public XElement ToXElement() => new XElement(XName); + #endregion + /// + public CodeXyzabcMachineTool GetXyzabcMachineTool() => MachineTool; + /// + public IMachiningChain GetMachiningChain() => MachineTool; + /// + public ISolidMachiningChain GetSolidMachiningChain() => MachineTool; + } +} diff --git a/Machining/DemoBuildMachiningProject.cs b/Machining/DemoBuildMachiningProject.cs new file mode 100644 index 0000000..293cde1 --- /dev/null +++ b/Machining/DemoBuildMachiningProject.cs @@ -0,0 +1,216 @@ +using System; +using System.Collections.Generic; +using Hi.Milling.Apts; +using Hi.Common.XmlUtils; +using Hi.Geom; +using Hi.Machining; +using Hi.Mech.Topo; +using Hi.Milling.Cutters; +using Hi.Milling.FluteContours; +using Hi.MillingForces.Fittings; +using Hi.MillingMech.MillingTools; +using Hi.NcMech.Fixtures; +using Hi.NcMech.Holders; +using Hi.NcMech.Workpieces; +using Hi.NcMech.Xyzabc; +using Hi.NcOpt; +using Hi.Physics; +using Hi.MongoUtils; +using Hi.Licenses; +using Hi.MachiningProcs; +using System.IO; + +namespace Sample.Machining +{ + public static class DemoBuildMachiningProject + { + #region CreateMillingCutter1 + private static MillingCutter CreateMillingCutter1() + { + MillingCutter millingCutter = new MillingCutter() + { + UpperBeamGeom = new TransformationGeom(), + MillingCutterOptLimit = new MillingCutterOptLimit() + }; + // since the following properties of MillingCutter has self-invoke, + // they have to be seperated from the initializer syntex. + + //build ShaperProfile property + double diameter_mm = 12; + double roundRadius_mm = 0.5; + millingCutter.ShaperProfile = new AptProfile(millingCutter, + new ColumnApt() + { + Diameter_mm = diameter_mm, + Rc_mm = roundRadius_mm, + FluteHeight_mm = 40 + }); + + //build FluteContourTray property + double helixAngle_deg = 50; + double radialRakeAngle_deg = 15; + double bottomOuterRadius_mm = diameter_mm / 2 - roundRadius_mm; + millingCutter.FluteContourTray = new UniformContourTray() + { + TrackNum = 3, + BaselineOneContour = new FluteContour() + { + BaseSideContour = new ConstHelixSideContour(millingCutter) + { + Helix_deg = helixAngle_deg, + RadialRakeAngle_deg = radialRakeAngle_deg + }, + BaseBottomContour = new SlideBottomContour() + { + //In most case, helix angle from side equal to rake angle from bottom. + AxialRakeAngle_deg = MathUtil.ToDeg(helixAngle_deg), + DiskAngle_deg = 1.5, + //In most case, rake angle from side equal to eccentric angle from bottom. + EccentricAngle_deg = radialRakeAngle_deg, + CutterLengthOnBottomProjection_mm = bottomOuterRadius_mm * 0.9, + OuterRadius_mm = bottomOuterRadius_mm + } + } + }; + + millingCutter.InnerBeamProfile + = new FluteDependentRatioProfile(millingCutter); + + return millingCutter; + } + #endregion + + #region CreateMillingCutter2 + private static MillingCutter CreateMillingCutter2() + { + MillingCutter millingCutter = new MillingCutter() + { + UpperBeamGeom = new TransformationGeom(), + MillingCutterOptLimit = new MillingCutterOptLimit() + }; + + //build ShaperProfile property + double diameter_mm = 12; + millingCutter.ShaperProfile = new AptProfile(millingCutter, + new ColumnApt() + { + Diameter_mm = diameter_mm, + FluteHeight_mm = 40 + }); + + //build FluteContourTray property + double helixAngle_deg = 50; + double radialRakeAngle_deg = 15; + millingCutter.FluteContourTray = new UniformContourTray() + { + TrackNum = 3, + BaselineOneContour = new FluteContour() + { + BaseSideContour = new ConstHelixSideContour(millingCutter) + { + Helix_deg = helixAngle_deg, + RadialRakeAngle_deg = radialRakeAngle_deg + }, + //since no bottom cut, set bottom contour to null. + BaseBottomContour = null + } + }; + + millingCutter.InnerBeamProfile + = new FluteDependentRatioProfile(millingCutter); + + return millingCutter; + } + #endregion + + #region TestMethod + [STAThread] + public static void Test() + { + Console.WriteLine($"License Login."); + License.LogInAll(); + + Console.WriteLine($"Start Database."); + MongoServer.Default = MongoServer.Run(new MongoRunnerOptions() + { + MongoPort = 28100 + }); + + 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); + + #region ConfigureHolder + CylindroidHolder cylindroidHolder = new CylindroidHolder() + { + Note = "BT40", + Cylindroid = new Cylindroid() + { + PairZrs = new List([ new PairZr(0,12),new PairZr(20,12), + new PairZr(20,16),new PairZr(30,16)]), + LongitudeNum = 30 + } + }; + #endregion + + #region ConfigureMachiningToolHouse + machiningProject.MachiningToolHouse = new MachiningToolHouse() + { + [1] = new StickMachiningTool() + { + Note = "T1", + PreservedDistanceBetweenFluteAndSpindleNose_mm = 8, + Holder = cylindroidHolder, + Cutter = CreateMillingCutter1() + }, + [2] = new StickMachiningTool() + { + Note = "T2", + PreservedDistanceBetweenFluteAndSpindleNose_mm = 8, + Holder = cylindroidHolder, + Cutter = CreateMillingCutter2() + }, + [3] = new StickMachiningTool() + { + Note = "T3", + PreservedDistanceBetweenFluteAndSpindleNose_mm = 8, + Holder = cylindroidHolder, + Cutter = CreateMillingCutter1() + }, + }; + #endregion + + #region ConfigureFixture + machiningProject.MachiningEquipment.Fixture = new Fixture() + { + Geom = new Box3d(new Vec3d(-40, -40, 0), new Vec3d(40, 40, 10)), + TableToWorkpieceTransformer = new StaticTranslation(new Vec3d(0, 0, 10)), + }; + #endregion + + #region ConfigureWorkpiece + machiningProject.MachiningEquipment.Workpiece = new Workpiece() + { + InitResolution = 0.25, + InitGeom = new Box3d(0, 0, -50, 70, 50, 0), + IdealGeom = null, + WorkpieceGeomToFixtureBuckleTransformer = new StaticTranslation(new Vec3d(0, 0, 0)), + MillingPara = XFactory.Default.GenByFile( + "Resource/CuttingParameter", "Al6061T6.mp", GenMode.Default), + WorkpieceMaterial = XFactory.Default.GenByFile( + "Resource/WorkpieceMaterial", "Al6061T6.WorkpieceMaterial", GenMode.Default), + }; + #endregion + + #region ConfigureMachineChain + machiningProject.MachiningEquipment.SolidMachiningChain + = XFactory.Default.GenByFile( + "Resource/MachineTool", "PMC-B1/PMC-B1.mt", GenMode.Default); + #endregion + + machiningProject.MakeXmlSourceFile(projectPath); + } + #endregion + } +} diff --git a/Machining/DemoUseMachiningProject.cs b/Machining/DemoUseMachiningProject.cs new file mode 100644 index 0000000..57f57b0 --- /dev/null +++ b/Machining/DemoUseMachiningProject.cs @@ -0,0 +1,94 @@ +using System; +using Hi.Licenses; +using Hi.Common.Messages; +using Hi.MachiningProcs; +using Hi.Common.FileLines; +using Hi.MongoUtils; + +namespace Sample.Machining +{ + public static class DemoUseMachiningProject + { + #region LoadProjectFileAndRunNcFiles + static void LoadProjectFileAndRunNcFiles() + { + #region LicenseAndDatabaseSetup + Console.WriteLine($"License Login."); + License.LogInAll(); + + Console.WriteLine($"Start Database."); + MongoServer.Default = MongoServer.Run(new MongoRunnerOptions() + { + MongoPort = 28100 + }); + #endregion + + #region ProjectLoading + var projectPath = "C:/HiNC-Projects/DemoStandardPath/Main.hincproj"; + Console.WriteLine($"Load Project: {projectPath}"); + MachiningProject machiningProject = MachiningProject.LoadFile(projectPath); + #endregion + + #region EventHandling + Console.WriteLine($"Set message event."); + //show message if something abnormal. + machiningProject.SessionMessageHost.CollectionItemAdded += pack => + { + if (pack.Tags.Contains(MessageFlag.Warning.ToString()) || + pack.Tags.Contains(MessageFlag.Error.ToString()) || + pack.Tags.Contains(MessageFlag.SysErr.ToString())) + { + var sourceCommand = pack.SourceCommand; + Console.WriteLine($"{pack.Message} At \"{sourceCommand?.FilePath}\" (Line {sourceCommand?.GetLineNo()}) \"{sourceCommand?.Line}\""); + } + }; + Console.WriteLine($"Set machining step event."); + //show MRR. + machiningProject.ShellApi.MachiningStepBuilt += (preStep, curStep) => + { + var sourceCommand = curStep.SourceCommand; + 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}\""); + }; + #endregion + + #region MachiningExecution + Console.WriteLine($"Reset runtime status."); + machiningProject.ResetRuntime(); + + Console.WriteLine($"Session begin."); + machiningProject.BeginSession(); + machiningProject.ShellApi.MachiningResolution_mm = 1; + machiningProject.ShellApi.EnableCollisionDetection = true; + machiningProject.ShellApi.EnablePauseOnCollision = false; + machiningProject.ShellApi.EnableMillingForceEvaluation = false; + //the path from Shell-API is relative by project directory. + machiningProject.ShellApi.PlayNcFile("NC/side.ptp"); + machiningProject.ShellApi.PlayNcFile("NC/circle.ptp"); + machiningProject.EndSession(); + Console.WriteLine($"Session end."); + #endregion + + #region CleanupResources + Console.WriteLine($"Close Project: {projectPath}"); + machiningProject.Dispose(); + + Console.WriteLine($"Close Database."); + MongoServer.Default.Dispose(); + + Console.WriteLine($"License Logout."); + License.LogOutAll(); + + Console.WriteLine($"Program end."); + #endregion + } + #endregion + + #region Main + public static void Main(string[] args) + { + LoadProjectFileAndRunNcFiles(); + } + #endregion + } +} diff --git a/Properties/launchSettings.json b/Properties/launchSettings.json new file mode 100644 index 0000000..adae572 --- /dev/null +++ b/Properties/launchSettings.json @@ -0,0 +1,12 @@ +{ + "profiles": { + "HiAPI.Sample": { + "commandName": "Project", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "applicationUrl": "https://localhost:52376;http://localhost:52377" + } + } +} \ No newline at end of file diff --git a/techcoordinate.ico b/techcoordinate.ico new file mode 100644 index 0000000..1aa69ce Binary files /dev/null and b/techcoordinate.ico differ