From 1e1869cc271de46759e5ae920342aa69e9eb91f0 Mon Sep 17 00:00:00 2001 From: Garr777 Date: Wed, 28 Sep 2022 16:07:08 +0300 Subject: [PATCH 01/35] Creat empty MACH3 postproccesor --- .../Mill/MACH3_DN/.vscode/launch.json | 48 ++++++++ Distributive/Mill/MACH3_DN/.vscode/tasks.json | 44 +++++++ Distributive/Mill/MACH3_DN/MACH3_DN.csproj | 31 +++++ Distributive/Mill/MACH3_DN/PostSchema.xsd | 115 ++++++++++++++++++ Distributive/Mill/MACH3_DN/Postprocessor.cs | 52 ++++++++ Distributive/Mill/MACH3_DN/Registers.cs | 27 ++++ Distributive/Mill/MACH3_DN/Settings.xml | 26 ++++ 7 files changed, 343 insertions(+) create mode 100644 Distributive/Mill/MACH3_DN/.vscode/launch.json create mode 100644 Distributive/Mill/MACH3_DN/.vscode/tasks.json create mode 100644 Distributive/Mill/MACH3_DN/MACH3_DN.csproj create mode 100644 Distributive/Mill/MACH3_DN/PostSchema.xsd create mode 100644 Distributive/Mill/MACH3_DN/Postprocessor.cs create mode 100644 Distributive/Mill/MACH3_DN/Registers.cs create mode 100644 Distributive/Mill/MACH3_DN/Settings.xml diff --git a/Distributive/Mill/MACH3_DN/.vscode/launch.json b/Distributive/Mill/MACH3_DN/.vscode/launch.json new file mode 100644 index 0000000..a647ba0 --- /dev/null +++ b/Distributive/Mill/MACH3_DN/.vscode/launch.json @@ -0,0 +1,48 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Launch post", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "buildPostprocessor", + "program": "${env:SprutCAMDir}/DotNet/InpCore.exe", + "args": [ + "-cldviewermode", + "-sharedfile:STInpCoreOfDebugger", + "-postfile:\"${workspaceFolder}\\bin\\Debug\\${workspaceFolderBasename}.dll\"" + ], + "cwd": "${workspaceFolder}", + "console": "integratedTerminal", + "stopAtEntry": false, + "justMyCode": true + }, + { + "name": "Launch post (console mode)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "buildPostprocessor", + "program": "${env:SprutCAMDir}/DotNet/InpCore.exe", + "args": [ + "-batchmode", + "-cldfile:\"c:\\Users\\Public\\Documents\\SprutCAM\\Version 16\\Projects\\Examples\\Milling\\3+2D\\3+2.stc\"", + "-postfile:\"${workspaceFolder}\\bin\\Debug\\${workspaceFolderBasename}.dll\"", + "-settingsfile:\"${workspaceFolder}\\Settings.xml" + ], + "cwd": "${workspaceFolder}", + "console": "integratedTerminal", + "stopAtEntry": false, + "enableStepFiltering": false, + "justMyCode": true + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach", + "processId": "${command:pickProcess}" + } + ] +} \ No newline at end of file diff --git a/Distributive/Mill/MACH3_DN/.vscode/tasks.json b/Distributive/Mill/MACH3_DN/.vscode/tasks.json new file mode 100644 index 0000000..303bb59 --- /dev/null +++ b/Distributive/Mill/MACH3_DN/.vscode/tasks.json @@ -0,0 +1,44 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", + "tasks": [ + { + "label": "buildPostprocessor", + "command": "dotnet", + "type": "shell", + "args": [ + "build", + // Ask dotnet build to generate full paths for file names. + "/property:GenerateFullPaths=true", + // Do not generate summary otherwise it leads to duplicate errors in Problems panel + "/consoleloggerparameters:NoSummary" + ], + "group": { + "kind": "build", + "isDefault": true + }, + "presentation": { + "reveal": "silent" + }, + "problemMatcher": "$msCompile" + }, + { + "label": "publish", + "command": "dotnet", + "type": "shell", + "args": [ + "publish", + // Ask dotnet build to generate full paths for file names. + "/property:GenerateFullPaths=true", + // Do not generate summary otherwise it leads to duplicate errors in Problems panel + "/consoleloggerparameters:NoSummary" + ], + "group": "build", + "presentation": { + "reveal": "silent" + }, + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/Distributive/Mill/MACH3_DN/MACH3_DN.csproj b/Distributive/Mill/MACH3_DN/MACH3_DN.csproj new file mode 100644 index 0000000..699401d --- /dev/null +++ b/Distributive/Mill/MACH3_DN/MACH3_DN.csproj @@ -0,0 +1,31 @@ + + + + net6.0-windows + bin\Debug\ + bin\Debug\ + enable + annotations + + + + + $(SprutCAMDir)\DotNet\STDefLib.dll + + + $(SprutCAMDir)\DotNet\VecMatrLib.dll + + + $(SprutCAMDir)\DotNet\SCPostprocessor.dll + + + + + + + + + + + + diff --git a/Distributive/Mill/MACH3_DN/PostSchema.xsd b/Distributive/Mill/MACH3_DN/PostSchema.xsd new file mode 100644 index 0000000..0b6fa9b --- /dev/null +++ b/Distributive/Mill/MACH3_DN/PostSchema.xsd @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Distributive/Mill/MACH3_DN/Postprocessor.cs b/Distributive/Mill/MACH3_DN/Postprocessor.cs new file mode 100644 index 0000000..a84db0b --- /dev/null +++ b/Distributive/Mill/MACH3_DN/Postprocessor.cs @@ -0,0 +1,52 @@ +namespace SprutTechnology.SCPostprocessor +{ + + public partial class NCFile: TTextNCFile + { + // Declare variables specific to a particular file here, as shown below + // int FileNumber; + } + + public partial class Postprocessor: TPostprocessor + { + #region Common variables definition + // Declare here global variables that apply to the entire postprocessor. + + ///Current nc-file + NCFile nc; + + #endregion + + public override void OnStartProject(ICLDProject prj) + { + nc = new NCFile(); + nc.OutputFileName = Settings.Params.Str["OutFiles.NCFileName"]; + + nc.WriteLine("Start of file: " + Path.GetFileName(nc.OutputFileName)); + } + + public override void OnFinishProject(ICLDProject prj) + { + nc.WriteLine("End of file: " + Path.GetFileName(nc.OutputFileName)); + } + + public override void OnStartTechOperation(ICLDTechOperation op, ICLDPPFunCommand cmd, CLDArray cld) + { + nc.WriteLine(" Start of operation: " + op.Comment); + } + + public override void OnFinishTechOperation(ICLDTechOperation op, ICLDPPFunCommand cmd, CLDArray cld) + { + nc.WriteLine(); + } + + public override void StopOnCLData() + { + // Do nothing, just to be possible to use CLData breakpoints + } + + // Uncomment line below (Ctrl + "/"), go to the end of "On" word and press Ctrl+Space to add a new CLData command handler + // override On + + } +} diff --git a/Distributive/Mill/MACH3_DN/Registers.cs b/Distributive/Mill/MACH3_DN/Registers.cs new file mode 100644 index 0000000..9fe19b1 --- /dev/null +++ b/Distributive/Mill/MACH3_DN/Registers.cs @@ -0,0 +1,27 @@ +// This file may be autogenerated, do not place meaningful code here. +// Use it only to define a list of nc-words (registers) that may appear +// in blocks of the nc-file. +namespace SprutTechnology.SCPostprocessor +{ + ///A class that defines the nc-file - main output file that should be generated by the postprocessor. + public partial class NCFile : TTextNCFile + { + ///The block of the nc-file is an ordered list of nc-words + public NCBlock Block; + ///X coordinate of the movement + public NumericNCWord X = new NumericNCWord("X{-#####!####}", 0); + ///Y coordinate of the movement + public NumericNCWord Y = new NumericNCWord("Y{-#####!####}", 0); + /// + public NumericNCWord Z = new NumericNCWord("Z{-#####!####}", 0); + public NCFile(): base() + { + Block = new NCBlock( + this, + X, + Y, + Z); + OnInit(); + } + } +} \ No newline at end of file diff --git a/Distributive/Mill/MACH3_DN/Settings.xml b/Distributive/Mill/MACH3_DN/Settings.xml new file mode 100644 index 0000000..1a37484 --- /dev/null +++ b/Distributive/Mill/MACH3_DN/Settings.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + No + + false + 0.01 + 0 + . + + + + + + + From d7f48000f12d8ba79593df3eab9fd5ae09f9f90e Mon Sep 17 00:00:00 2001 From: Garr777 Date: Sun, 16 Oct 2022 02:57:22 +0300 Subject: [PATCH 02/35] Registers.cs : Add Text, TextBlock and BlockN; Postproccesors.cs: Add ProgName in TTextNCFile --- Distributive/Mill/MACH3_DN/Postprocessor.cs | 7 ++++++- Distributive/Mill/MACH3_DN/Registers.cs | 10 ++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Distributive/Mill/MACH3_DN/Postprocessor.cs b/Distributive/Mill/MACH3_DN/Postprocessor.cs index a84db0b..ab02c6b 100644 --- a/Distributive/Mill/MACH3_DN/Postprocessor.cs +++ b/Distributive/Mill/MACH3_DN/Postprocessor.cs @@ -3,6 +3,7 @@ namespace SprutTechnology.SCPostprocessor public partial class NCFile: TTextNCFile { + public string ProgName; // Declare variables specific to a particular file here, as shown below // int FileNumber; } @@ -21,7 +22,11 @@ public override void OnStartProject(ICLDProject prj) { nc = new NCFile(); nc.OutputFileName = Settings.Params.Str["OutFiles.NCFileName"]; - + nc.ProgName = Settings.Params.Str["OutFiles.NCProgName"]; + if (String.IsNullOrEmpty(nc.ProgName)) + nc.ProgName = prj.ProjectName; + nc.Text.Show($"{nc.ProgName}"); + nc.TextBlock.Out(); nc.WriteLine("Start of file: " + Path.GetFileName(nc.OutputFileName)); } diff --git a/Distributive/Mill/MACH3_DN/Registers.cs b/Distributive/Mill/MACH3_DN/Registers.cs index 9fe19b1..faec9d2 100644 --- a/Distributive/Mill/MACH3_DN/Registers.cs +++ b/Distributive/Mill/MACH3_DN/Registers.cs @@ -9,11 +9,17 @@ public partial class NCFile : TTextNCFile ///The block of the nc-file is an ordered list of nc-words public NCBlock Block; ///X coordinate of the movement + public CountingNCWord BlockN = new CountingNCWord("######", 0, 1, 1); public NumericNCWord X = new NumericNCWord("X{-#####!####}", 0); ///Y coordinate of the movement public NumericNCWord Y = new NumericNCWord("Y{-#####!####}", 0); /// public NumericNCWord Z = new NumericNCWord("Z{-#####!####}", 0); + + public NCBlock TextBlock; + ///Text string to output simply with number + + public TextNCWord Text = new TextNCWord("","",""); public NCFile(): base() { Block = new NCBlock( @@ -21,6 +27,10 @@ public NCFile(): base() X, Y, Z); + TextBlock = new NCBlock( + this, + BlockN, + Text); OnInit(); } } From dcdf9b5b9d0f5493b49881eb26533158566b1ee6 Mon Sep 17 00:00:00 2001 From: Garr777 Date: Mon, 31 Oct 2022 05:31:38 +0300 Subject: [PATCH 03/35] Create outToolsList functiob prototype --- Distributive/Mill/MACH3_DN/Postprocessor.cs | 46 +++++++++++++++++++-- 1 file changed, 42 insertions(+), 4 deletions(-) diff --git a/Distributive/Mill/MACH3_DN/Postprocessor.cs b/Distributive/Mill/MACH3_DN/Postprocessor.cs index ab02c6b..e215a9b 100644 --- a/Distributive/Mill/MACH3_DN/Postprocessor.cs +++ b/Distributive/Mill/MACH3_DN/Postprocessor.cs @@ -8,6 +8,8 @@ public partial class NCFile: TTextNCFile // int FileNumber; } + + public partial class Postprocessor: TPostprocessor { #region Common variables definition @@ -15,9 +17,26 @@ public partial class Postprocessor: TPostprocessor ///Current nc-file NCFile nc; - + #endregion + const string SPPName = "MACH3_DN"; + + public void OutToolList() + { + // int i; + // int j; + // int k; + // int ToolNumber; + // string ToolComment; + // double ToolDiam; + // string OpComment; + // string ss, ss2, curS, prevS; + // nc.WriteLine(); + // prevS = ""; + + // for(int i = 0; i < ) + } public override void OnStartProject(ICLDProject prj) { nc = new NCFile(); @@ -26,8 +45,27 @@ public override void OnStartProject(ICLDProject prj) if (String.IsNullOrEmpty(nc.ProgName)) nc.ProgName = prj.ProjectName; nc.Text.Show($"{nc.ProgName}"); - nc.TextBlock.Out(); - nc.WriteLine("Start of file: " + Path.GetFileName(nc.OutputFileName)); + nc.WriteLine("%"); + nc.WriteLine("O" + nc.ProgName); + + nc.WriteLine(); + + nc.WriteLine("( Postprocessor: " + SPPName + " )"); + nc.WriteLine("( Generated by SprutCAM )"); + nc.WriteLine("( DATE: " + CurDate() + " )"); + nc.WriteLine("( TIME: " + CurTime() + " )"); + // nc.WriteLine("Start of file: " + Path.GetFileName(nc.OutputFileName)); + + //foreach(auto n in ) + } + + public override void OnGoto(ICLDGotoCommand cmd, CLDArray cld) + { + nc.GInterp.v = 1; + nc.X.v = cmd.EP.X; + nc.Y.v = cmd.EP.Y; + nc.Z.v = cmd.EP.Z; + nc.Block.Out(); } public override void OnFinishProject(ICLDProject prj) @@ -37,7 +75,7 @@ public override void OnFinishProject(ICLDProject prj) public override void OnStartTechOperation(ICLDTechOperation op, ICLDPPFunCommand cmd, CLDArray cld) { - nc.WriteLine(" Start of operation: " + op.Comment); + nc.WriteLine("(" + op.Comment + ")"); } public override void OnFinishTechOperation(ICLDTechOperation op, ICLDPPFunCommand cmd, CLDArray cld) From cbafb8dfc2c00ce62f75fa8be3cd92bffbf0cc26 Mon Sep 17 00:00:00 2001 From: Garr777 Date: Mon, 31 Oct 2022 05:32:33 +0300 Subject: [PATCH 04/35] Set up BlockN parameters; create GInterapt register --- Distributive/Mill/MACH3_DN/Registers.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Distributive/Mill/MACH3_DN/Registers.cs b/Distributive/Mill/MACH3_DN/Registers.cs index faec9d2..b0a2b3c 100644 --- a/Distributive/Mill/MACH3_DN/Registers.cs +++ b/Distributive/Mill/MACH3_DN/Registers.cs @@ -9,13 +9,15 @@ public partial class NCFile : TTextNCFile ///The block of the nc-file is an ordered list of nc-words public NCBlock Block; ///X coordinate of the movement - public CountingNCWord BlockN = new CountingNCWord("######", 0, 1, 1); + public CountingNCWord BlockN = new CountingNCWord("N{######}", 10, 10, 1); public NumericNCWord X = new NumericNCWord("X{-#####!####}", 0); ///Y coordinate of the movement public NumericNCWord Y = new NumericNCWord("Y{-#####!####}", 0); /// public NumericNCWord Z = new NumericNCWord("Z{-#####!####}", 0); + public NumericNCWord GInterp = new NumericNCWord("G{00}",0); + public NCBlock TextBlock; ///Text string to output simply with number @@ -23,7 +25,8 @@ public partial class NCFile : TTextNCFile public NCFile(): base() { Block = new NCBlock( - this, + this, + BlockN, X, Y, Z); From fc0b11325363c5e0c6c093fa40e551ee68f300f4 Mon Sep 17 00:00:00 2001 From: Garr777 Date: Wed, 2 Nov 2022 07:38:50 +0300 Subject: [PATCH 05/35] Change registers summary --- Distributive/Mill/MACH3_DN/Registers.cs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Distributive/Mill/MACH3_DN/Registers.cs b/Distributive/Mill/MACH3_DN/Registers.cs index b0a2b3c..0776055 100644 --- a/Distributive/Mill/MACH3_DN/Registers.cs +++ b/Distributive/Mill/MACH3_DN/Registers.cs @@ -8,32 +8,32 @@ public partial class NCFile : TTextNCFile { ///The block of the nc-file is an ordered list of nc-words public NCBlock Block; - ///X coordinate of the movement + /// public CountingNCWord BlockN = new CountingNCWord("N{######}", 10, 10, 1); + ///X coordinate of the movement public NumericNCWord X = new NumericNCWord("X{-#####!####}", 0); ///Y coordinate of the movement public NumericNCWord Y = new NumericNCWord("Y{-#####!####}", 0); /// public NumericNCWord Z = new NumericNCWord("Z{-#####!####}", 0); - - public NumericNCWord GInterp = new NumericNCWord("G{00}",0); - + /// public NCBlock TextBlock; - ///Text string to output simply with number - - public TextNCWord Text = new TextNCWord("","",""); + ///Text string to output simply with number + public TextNCWord Text = new TextNCWord("", "", ""); + /// + public NumericNCWord GInterp = new NumericNCWord("G{00}", 0); public NCFile(): base() { Block = new NCBlock( - this, - BlockN, + this, + BlockN, X, Y, Z); TextBlock = new NCBlock( - this, - BlockN, - Text); + this, + BlockN, + Text); OnInit(); } } From 1e4896895fc609f79b9986b29d074d196371f619 Mon Sep 17 00:00:00 2001 From: Garr777 Date: Wed, 2 Nov 2022 07:39:09 +0300 Subject: [PATCH 06/35] And inputbox func --- Distributive/Mill/MACH3_DN/Postprocessor.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Distributive/Mill/MACH3_DN/Postprocessor.cs b/Distributive/Mill/MACH3_DN/Postprocessor.cs index e215a9b..8c66795 100644 --- a/Distributive/Mill/MACH3_DN/Postprocessor.cs +++ b/Distributive/Mill/MACH3_DN/Postprocessor.cs @@ -37,13 +37,19 @@ public void OutToolList() // for(int i = 0; i < ) } + + + public override void OnStartProject(ICLDProject prj) { + + nc = new NCFile(); nc.OutputFileName = Settings.Params.Str["OutFiles.NCFileName"]; - nc.ProgName = Settings.Params.Str["OutFiles.NCProgName"]; + //nc.ProgName = Settings.Params.Str["OutFiles.NCProgName"]; + InputBox("Input the name of programs", ref nc.ProgName); if (String.IsNullOrEmpty(nc.ProgName)) - nc.ProgName = prj.ProjectName; + nc.ProgName = ""; nc.Text.Show($"{nc.ProgName}"); nc.WriteLine("%"); nc.WriteLine("O" + nc.ProgName); From e380042ace77202c07aed87d39957be7048526f7 Mon Sep 17 00:00:00 2001 From: Garr777 Date: Wed, 2 Nov 2022 09:34:23 +0300 Subject: [PATCH 07/35] Create outools func body --- Distributive/Mill/MACH3_DN/Postprocessor.cs | 30 ++++++++++++--------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/Distributive/Mill/MACH3_DN/Postprocessor.cs b/Distributive/Mill/MACH3_DN/Postprocessor.cs index 8c66795..eec0661 100644 --- a/Distributive/Mill/MACH3_DN/Postprocessor.cs +++ b/Distributive/Mill/MACH3_DN/Postprocessor.cs @@ -24,18 +24,19 @@ public partial class Postprocessor: TPostprocessor public void OutToolList() { - // int i; - // int j; - // int k; - // int ToolNumber; - // string ToolComment; - // double ToolDiam; - // string OpComment; - // string ss, ss2, curS, prevS; - // nc.WriteLine(); - // prevS = ""; - - // for(int i = 0; i < ) + SortedList list = new SortedList(); + for(int i = 0; i < CLDProject.Operations.Count; i++) + { + var op = CLDProject.Operations[i]; + if((op.Tool != null) && (op.Tool.Command != null)) + { + list.TryAdd(op.Tool.Number, op.Tool.Caption); + } + } + foreach(var tl in list) + { + nc.Output(tl.Key + " " + tl.Value); + } } @@ -60,6 +61,8 @@ public override void OnStartProject(ICLDProject prj) nc.WriteLine("( Generated by SprutCAM )"); nc.WriteLine("( DATE: " + CurDate() + " )"); nc.WriteLine("( TIME: " + CurTime() + " )"); + + OutToolList(); // nc.WriteLine("Start of file: " + Path.GetFileName(nc.OutputFileName)); //foreach(auto n in ) @@ -76,7 +79,8 @@ public override void OnGoto(ICLDGotoCommand cmd, CLDArray cld) public override void OnFinishProject(ICLDProject prj) { - nc.WriteLine("End of file: " + Path.GetFileName(nc.OutputFileName)); + + nc.Write("%"); } public override void OnStartTechOperation(ICLDTechOperation op, ICLDPPFunCommand cmd, CLDArray cld) From a3fc403a0a8c3ad848171c317d2439de27e9c328 Mon Sep 17 00:00:00 2001 From: Garr777 Date: Sun, 6 Nov 2022 12:04:16 +0300 Subject: [PATCH 08/35] Edit OutToolList func; --- Distributive/Mill/MACH3_DN/Postprocessor.cs | 23 +++++++++------------ 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/Distributive/Mill/MACH3_DN/Postprocessor.cs b/Distributive/Mill/MACH3_DN/Postprocessor.cs index eec0661..c3ab220 100644 --- a/Distributive/Mill/MACH3_DN/Postprocessor.cs +++ b/Distributive/Mill/MACH3_DN/Postprocessor.cs @@ -21,25 +21,21 @@ public partial class Postprocessor: TPostprocessor #endregion const string SPPName = "MACH3_DN"; - - public void OutToolList() + + public void OutToolList() { - SortedList list = new SortedList(); - for(int i = 0; i < CLDProject.Operations.Count; i++) + var diametr = CLDProject.Operations[0].Tool.Command.CLD[5]; + for(int i = 0; i < CLDProject.Operations.Count;i++) { - var op = CLDProject.Operations[i]; - if((op.Tool != null) && (op.Tool.Command != null)) + var curtool = CLDProject.Operations[i]; + if(curtool.Enabled) { - list.TryAdd(op.Tool.Number, op.Tool.Caption); + diametr = curtool.Tool.Command.CLD[5]; } - } - foreach(var tl in list) - { - nc.Output(tl.Key + " " + tl.Value); + nc.Output($"(Tool) ({curtool.Tool.Number}) (Diametr) ({diametr}.) ({curtool.Tool.Caption}) (Operation) ({curtool.Comment}))"); + } } - - public override void OnStartProject(ICLDProject prj) { @@ -68,6 +64,7 @@ public override void OnStartProject(ICLDProject prj) //foreach(auto n in ) } + public override void OnGoto(ICLDGotoCommand cmd, CLDArray cld) { nc.GInterp.v = 1; From 80e4081410f8da45bd8fe7410b03d306d8539416 Mon Sep 17 00:00:00 2001 From: Garr777 Date: Sun, 6 Nov 2022 13:08:04 +0300 Subject: [PATCH 09/35] Add list necessary registers; --- Distributive/Mill/MACH3_DN/Postprocessor.cs | 12 ++++++-- Distributive/Mill/MACH3_DN/Registers.cs | 31 +++++++++++++++++++-- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/Distributive/Mill/MACH3_DN/Postprocessor.cs b/Distributive/Mill/MACH3_DN/Postprocessor.cs index c3ab220..0864282 100644 --- a/Distributive/Mill/MACH3_DN/Postprocessor.cs +++ b/Distributive/Mill/MACH3_DN/Postprocessor.cs @@ -59,9 +59,17 @@ public override void OnStartProject(ICLDProject prj) nc.WriteLine("( TIME: " + CurTime() + " )"); OutToolList(); - // nc.WriteLine("Start of file: " + Path.GetFileName(nc.OutputFileName)); - //foreach(auto n in ) + nc.GInterp.v = 100; + nc.Plane.v = 17; + nc.KorEcv.v = 40; + nc.KorDL.v = 49; + nc.Cycle.v = 80; + nc.ABS_INC.v = 90; + nc.COORDSYS.v = 54; + nc.SmoothMv.v = 64; + nc.CancelScale.v = 50; + nc.Block.Out(); } diff --git a/Distributive/Mill/MACH3_DN/Registers.cs b/Distributive/Mill/MACH3_DN/Registers.cs index 0776055..97b6c37 100644 --- a/Distributive/Mill/MACH3_DN/Registers.cs +++ b/Distributive/Mill/MACH3_DN/Registers.cs @@ -17,11 +17,29 @@ public partial class NCFile : TTextNCFile /// public NumericNCWord Z = new NumericNCWord("Z{-#####!####}", 0); /// + public NumericNCWord GInterp = new NumericNCWord("G{00}", 0); + /// + public NumericNCWord Plane = new NumericNCWord("G{00}", 0); + /// + public NumericNCWord KorEcv = new NumericNCWord("G{00}", 0); + /// + public NumericNCWord KorDL = new NumericNCWord("G{00}", 0); + /// + public NumericNCWord Cycle = new NumericNCWord("G{00}", 0); + /// + public NumericNCWord ABS_INC = new NumericNCWord("G{00}", 0); + /// + public NumericNCWord COORDSYS = new NumericNCWord("G{00}", 0); + /// + public NumericNCWord SmoothMv = new NumericNCWord("G{00}", 0); + /// + public NumericNCWord CancelScale = new NumericNCWord("G{00}", 0); + /// public NCBlock TextBlock; ///Text string to output simply with number public TextNCWord Text = new TextNCWord("", "", ""); /// - public NumericNCWord GInterp = new NumericNCWord("G{00}", 0); + public NCFile(): base() { Block = new NCBlock( @@ -29,7 +47,16 @@ public NCFile(): base() BlockN, X, Y, - Z); + Z, + ABS_INC, + SmoothMv, + CancelScale, + COORDSYS, + Cycle, + Plane, + KorEcv, + KorDL + ); TextBlock = new NCBlock( this, BlockN, From 2244d662e78f088b354111db1de643225e66342c Mon Sep 17 00:00:00 2001 From: Garr777 Date: Sun, 6 Nov 2022 15:31:48 +0300 Subject: [PATCH 10/35] Add PPFun command + new Registers (Flip, Units) --- Distributive/Mill/MACH3_DN/Postprocessor.cs | 42 +++++++++++++++++++++ Distributive/Mill/MACH3_DN/Registers.cs | 11 +++++- 2 files changed, 51 insertions(+), 2 deletions(-) diff --git a/Distributive/Mill/MACH3_DN/Postprocessor.cs b/Distributive/Mill/MACH3_DN/Postprocessor.cs index 0864282..0fd70be 100644 --- a/Distributive/Mill/MACH3_DN/Postprocessor.cs +++ b/Distributive/Mill/MACH3_DN/Postprocessor.cs @@ -70,6 +70,14 @@ public override void OnStartProject(ICLDProject prj) nc.SmoothMv.v = 64; nc.CancelScale.v = 50; nc.Block.Out(); + + string Flip = "N"; + InputBox("Flip 4th Axis Project Say Y\\N (Case Sensative): ", ref Flip); + if(Flip.ToUpper() == "Y") + { + nc.Flip.v = 1; + } + nc.Block.Out(); } @@ -82,6 +90,40 @@ public override void OnGoto(ICLDGotoCommand cmd, CLDArray cld) nc.Block.Out(); } + public override void OnPPFun(ICLDPPFunCommand cmd, CLDArray cld) + { + switch(cld[1]) + { + case 58 : + { + int unit = 0; + if(cld[20] == 0) + { + unit = 21; + } + else + { + unit = 20; + } + if(unit == 21) + { + nc.Units.v = unit; + nc.Text.v = "(Metric)"; + nc.TextBlock.Out(); + } + else + { + nc.Units.v = unit; + nc.Text.v = "(Inch)"; + nc.TextBlock.Out(); + } + break; + } + default: + break; + } + } + public override void OnFinishProject(ICLDProject prj) { diff --git a/Distributive/Mill/MACH3_DN/Registers.cs b/Distributive/Mill/MACH3_DN/Registers.cs index 97b6c37..7df7175 100644 --- a/Distributive/Mill/MACH3_DN/Registers.cs +++ b/Distributive/Mill/MACH3_DN/Registers.cs @@ -35,6 +35,10 @@ public partial class NCFile : TTextNCFile /// public NumericNCWord CancelScale = new NumericNCWord("G{00}", 0); /// + public NumericNCWord Units = new NumericNCWord("G{00}", 0); + /// + public NumericNCWord Flip = new NumericNCWord("G51 A-{##}", 0); + /// public NCBlock TextBlock; ///Text string to output simply with number public TextNCWord Text = new TextNCWord("", "", ""); @@ -55,11 +59,14 @@ public NCFile(): base() Cycle, Plane, KorEcv, - KorDL + KorDL, + Flip, + Units ); TextBlock = new NCBlock( this, - BlockN, + BlockN, + Units, Text); OnInit(); } From 5e9dc6fc9357b0d76a9cd4b80a95b2316dea191a Mon Sep 17 00:00:00 2001 From: Garr777 Date: Sun, 6 Nov 2022 17:36:19 +0300 Subject: [PATCH 11/35] Add Initialise fucn, LoadTl func; Add necessary registrs; --- Distributive/Mill/MACH3_DN/Postprocessor.cs | 69 +++++++++++++++++++++ Distributive/Mill/MACH3_DN/Registers.cs | 32 +++++++++- 2 files changed, 100 insertions(+), 1 deletion(-) diff --git a/Distributive/Mill/MACH3_DN/Postprocessor.cs b/Distributive/Mill/MACH3_DN/Postprocessor.cs index 0fd70be..c895a4c 100644 --- a/Distributive/Mill/MACH3_DN/Postprocessor.cs +++ b/Distributive/Mill/MACH3_DN/Postprocessor.cs @@ -20,6 +20,31 @@ public partial class Postprocessor: TPostprocessor #endregion + double MaxReal = 99999.999; + int XT_ = 0; + int YT_ = 0; + int ZT_ = 0; + //! Constsnt cycles variables + int CycleOn = 0; //! 0 - cycle Off, 1 - cycle On + int KodCycle = 0; //! constant cycle code + int Za = 0; //! work depth + int Zf = 0; //! safe level + int ZP_ = 0; // ! reverse move level + int Zl = 0; //! depth of one drilling step + int Zi = 0; //! transitional value + int Dwell = 0; //! pause in constsnt cycles + int Fr = 0; //! work FEED_ + int Pause = 0; + //! Set machene functions by default + + + int Firstap = 1; + int Fedmod = 10; + int Isfirstpass = 1; + int SubIDShift = 0;//! Numbers of subroutines starts from it + + + const string SPPName = "MACH3_DN"; public void OutToolList() @@ -36,6 +61,19 @@ public void OutToolList() } } + public void Initialise() + { + nc.GInterp.v = MaxReal; //! initilalise G0 rapid + nc.ZCycle.v = MaxReal; //! initalise cycle depth + nc.ZClear.v = MaxReal; //! initialise cycle rapid + nc.Cyc_retract.v = MaxReal; //! initialise G98 retract + nc.Q.v = MaxReal; //! initialise peck amount + nc.Feed_.v = MaxReal; //! initialise feed + nc.X.v = MaxReal; //! initialise X + nc.Y.v = MaxReal; //! initialise Y + nc.Z.v = MaxReal; //! initialise Z + + } public override void OnStartProject(ICLDProject prj) { @@ -124,6 +162,37 @@ public override void OnPPFun(ICLDPPFunCommand cmd, CLDArray cld) } } + public override void OnLoadTool(ICLDLoadToolCommand cmd, CLDArray cld) + { + nc.Block.Out(); + if(CycleOn == 1) + { + CycleOn = 0; + nc.Cycle.v = 80; + } + nc.GoTCP.v = 998; + nc.Block.Out(); + var Tool_ = cld[1]; + var H_ = cld[1]; + int Mspdir = 0; + if(nc.MSP.v != 5) + { + Mspdir = (int)nc.MSP.v; + nc.MSP.v = 5; + nc.Block.Out(); + } + nc.Tool.v = Tool_; + nc.H.v = H_; + nc.KorDL.v = 43; + nc.Msm.v = 6; + nc.Block.Out(); + if(Mspdir != 0) + { + nc.MSP.v = Mspdir; + } + nc.Block.Out(); + Initialise(); + } public override void OnFinishProject(ICLDProject prj) { diff --git a/Distributive/Mill/MACH3_DN/Registers.cs b/Distributive/Mill/MACH3_DN/Registers.cs index 7df7175..61bec03 100644 --- a/Distributive/Mill/MACH3_DN/Registers.cs +++ b/Distributive/Mill/MACH3_DN/Registers.cs @@ -37,6 +37,30 @@ public partial class NCFile : TTextNCFile /// public NumericNCWord Units = new NumericNCWord("G{00}", 0); /// + public NumericNCWord Cyc_retract = new NumericNCWord("G{##}", 0); + /// + public NumericNCWord GoTCP = new NumericNCWord("M{###}", 0); + /// + public NumericNCWord D = new NumericNCWord("D{00}", 0); + /// + public NumericNCWord H = new NumericNCWord("H{00}", 0); + /// + public NumericNCWord BT = new NumericNCWord("BT-{####.####}", 0); + /// + public NumericNCWord ZCycle = new NumericNCWord("Z-{####.####}", 0); + /// + public NumericNCWord ZClear = new NumericNCWord("Z-{####.####}", 0); + /// + public NumericNCWord Q = new NumericNCWord("Q-{####.####}", 0); + /// + public NumericNCWord Tool = new NumericNCWord("T{####}",0); + /// + public NumericNCWord Feed_ = new NumericNCWord("F{####.#}",0); + /// + public NumericNCWord MSP = new NumericNCWord("M{00}", 5); + /// + public NumericNCWord Msm = new NumericNCWord("M{0}", 0); + /// public NumericNCWord Flip = new NumericNCWord("G51 A-{##}", 0); /// public NCBlock TextBlock; @@ -59,9 +83,15 @@ public NCFile(): base() Cycle, Plane, KorEcv, + Tool, KorDL, + H, + Msm, Flip, - Units + Units, + MSP, + GoTCP, + D ); TextBlock = new NCBlock( this, From c9520598ce300a8efaa16c25b5c677bfc09d55d3 Mon Sep 17 00:00:00 2001 From: Garr777 Date: Sun, 6 Nov 2022 17:47:59 +0300 Subject: [PATCH 12/35] Add OnComment func; --- Distributive/Mill/MACH3_DN/Postprocessor.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Distributive/Mill/MACH3_DN/Postprocessor.cs b/Distributive/Mill/MACH3_DN/Postprocessor.cs index c895a4c..ed6ec4c 100644 --- a/Distributive/Mill/MACH3_DN/Postprocessor.cs +++ b/Distributive/Mill/MACH3_DN/Postprocessor.cs @@ -193,6 +193,10 @@ public override void OnLoadTool(ICLDLoadToolCommand cmd, CLDArray cld) nc.Block.Out(); Initialise(); } + public override void OnComment(ICLDCommentCommand cmd, CLDArray cld) + { + nc.WriteLine("(" + cmd.CLDataS + ")"); + } public override void OnFinishProject(ICLDProject prj) { @@ -201,7 +205,7 @@ public override void OnFinishProject(ICLDProject prj) public override void OnStartTechOperation(ICLDTechOperation op, ICLDPPFunCommand cmd, CLDArray cld) { - nc.WriteLine("(" + op.Comment + ")"); + nc.WriteLine(); } public override void OnFinishTechOperation(ICLDTechOperation op, ICLDPPFunCommand cmd, CLDArray cld) From 157ca57d9c3409b1f543255a32f1bd2fe3104bb4 Mon Sep 17 00:00:00 2001 From: Garr777 Date: Sun, 6 Nov 2022 20:47:40 +0300 Subject: [PATCH 13/35] Add OnPlane Func --- Distributive/Mill/MACH3_DN/Postprocessor.cs | 31 +++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/Distributive/Mill/MACH3_DN/Postprocessor.cs b/Distributive/Mill/MACH3_DN/Postprocessor.cs index ed6ec4c..107d5ce 100644 --- a/Distributive/Mill/MACH3_DN/Postprocessor.cs +++ b/Distributive/Mill/MACH3_DN/Postprocessor.cs @@ -60,6 +60,7 @@ public void OutToolList() nc.Output($"(Tool) ({curtool.Tool.Number}) (Diametr) ({diametr}.) ({curtool.Tool.Caption}) (Operation) ({curtool.Comment}))"); } + nc.WriteLine(); } public void Initialise() { @@ -197,6 +198,32 @@ public override void OnComment(ICLDCommentCommand cmd, CLDArray cld) { nc.WriteLine("(" + cmd.CLDataS + ")"); } + + public override void OnPlane(ICLDPlaneCommand cmd, CLDArray cld) + { + switch(cmd.CLD[1]) + { + case 33 or 133: + { + nc.Plane.v = 17; + break; + } + case 37 or 137: + { + nc.Plane.v = 19; + break; + } + case 41 or 141: + { + nc.Plane.v = 18; + break; + } + } + if(cmd.CLD[1] > 100) + { + nc.Plane.v = -nc.Plane.v; + } + } public override void OnFinishProject(ICLDProject prj) { @@ -205,12 +232,12 @@ public override void OnFinishProject(ICLDProject prj) public override void OnStartTechOperation(ICLDTechOperation op, ICLDPPFunCommand cmd, CLDArray cld) { - nc.WriteLine(); + } public override void OnFinishTechOperation(ICLDTechOperation op, ICLDPPFunCommand cmd, CLDArray cld) { - nc.WriteLine(); + } public override void StopOnCLData() From 707f50b7eb488cc4bb53368bdc492d90770df0d1 Mon Sep 17 00:00:00 2001 From: Garr777 Date: Mon, 7 Nov 2022 11:08:58 +0300 Subject: [PATCH 14/35] Add anothers cases of PPFun Func; Add Soindle func; Add necessary registrs; --- Distributive/Mill/MACH3_DN/Postprocessor.cs | 157 +++++++++++++++++--- Distributive/Mill/MACH3_DN/Registers.cs | 12 ++ 2 files changed, 147 insertions(+), 22 deletions(-) diff --git a/Distributive/Mill/MACH3_DN/Postprocessor.cs b/Distributive/Mill/MACH3_DN/Postprocessor.cs index 107d5ce..be7bd7e 100644 --- a/Distributive/Mill/MACH3_DN/Postprocessor.cs +++ b/Distributive/Mill/MACH3_DN/Postprocessor.cs @@ -34,7 +34,6 @@ public partial class Postprocessor: TPostprocessor int Zi = 0; //! transitional value int Dwell = 0; //! pause in constsnt cycles int Fr = 0; //! work FEED_ - int Pause = 0; //! Set machene functions by default @@ -43,7 +42,8 @@ public partial class Postprocessor: TPostprocessor int Isfirstpass = 1; int SubIDShift = 0;//! Numbers of subroutines starts from it - + int cfi; + int ppfj; const string SPPName = "MACH3_DN"; @@ -133,33 +133,85 @@ public override void OnPPFun(ICLDPPFunCommand cmd, CLDArray cld) { switch(cld[1]) { - case 58 : + case 50: // ! StartSub { - int unit = 0; - if(cld[20] == 0) + nc.Block.Out(); + nc.WriteLine(); + nc.WriteLine("%"); + nc.WriteLine("O00" + Str(SubIDShift + cld[2])); + if (cmd.CLDataS != "") { - unit = 21; - } - else - { - unit = 20; - } - if(unit == 21) + nc.WriteLine("(" + cmd.CLDataS.ToUpper() + ")"); + } + nc.GInterp.v = MaxReal; + nc.GInterp.v0 = nc.GInterp.v; + nc.Feed_.v = MaxReal; + nc.Feed_.v0 = nc.Feed_.v; + nc.BlockN.v = 0; + break; + } + case 51: //! EndSub + { + nc.Block.Out(); + nc.M.v = 99; + nc.M.v0 = MaxReal; + nc.Block.Out(); + nc.Output("%"); + break; + } + case 52: //! CallSub + { + nc.Block.Out(); + nc.M.v = 98; + nc.M.v0 = MaxReal; + nc.PSubNum.v = SubIDShift + cmd.CLD[2]; + nc.PSubNum.v0 = MaxReal; + nc.Block.Out(); + break; + } + + case 58 : + { + int unit = 0; + if(cld[20] == 0) + { + unit = 21; + } + else + { + unit = 20; + } + if(unit == 21) + { + nc.Units.v = unit; + nc.Text.v = "(Metric)"; + nc.TextBlock.Out(); + } + else + { + nc.Units.v = unit; + nc.Text.v = "(Inch)"; + nc.TextBlock.Out(); + } + break; + } + + case 59: //! EndTechInfo - Finish of operation + { + cfi = -1; + ppfj = -1; //! CLDFile[cfi].Cmd[ppfj] = PPFun(TechInfo) of the current operation + if (CycleOn == 1) { - nc.Units.v = unit; - nc.Text.v = "(Metric)"; - nc.TextBlock.Out(); + CycleOn = 0; + nc.Cycle.v = 80; } - else + nc.Block.Out(); + if (cmd.CLDFile.Index < cmd.CLDFile.CmdCount - 1) // ! if not last operation { - nc.Units.v = unit; - nc.Text.v = "(Inch)"; - nc.TextBlock.Out(); + nc.Output(""); //! Spaces between operations //! case } break; - } - default: - break; + } } } @@ -224,6 +276,67 @@ public override void OnPlane(ICLDPlaneCommand cmd, CLDArray cld) nc.Plane.v = -nc.Plane.v; } } + + public override void OnSpindle(ICLDSpindleCommand cmd, CLDArray cld) + { + int IsReverse; + switch(cld[1]) + { + case 71: //! On + { + nc.S.v = Math.Abs(cld[2]); + if (cld[2] > 0) + { + nc.MSP.v = 3; + } + else nc.MSP.v = 4; //! M3/M4 CW/CCW + if (nc.MSP.v == (7-nc.MSP.v0)) + IsReverse = 1; + else + IsReverse = 0; + if (cfi >= 0) + { + if (cmd.CLDFile.Cmd[cfi].CLD[58] != 0) //! PPFun.Cld[58] = Coolant tube number + nc.Mc.v = 8; + } + + + nc.Block.Out(); + if ((IsReverse > 0) && (cmd.Next.CmdTypeCode != 1010)) + { + nc.GDwell.v = 4; + nc.GDwell.v0 = MaxReal; + nc.Pause.v = nc.Pause.v0 * 2; + nc.Pause.v0 = MaxReal; + nc.Block.Out(); + } + break; + } + + case 72: // ! Off + { + nc.MSP.v = 5; + nc.S.v = 0; + break; + } + + + + case 246: //! Oriented stop + //!cld[2] - angle + //!S = 0 + { + if (nc.S.v != nc.S.v0) + nc.Block.Out(); + nc.GDwell.v = 4; + nc.GDwell.v0 = MaxReal; + nc.Pause.v = 1; + nc.Pause.v0 = MaxReal; + break; + } + nc.Block.Out(); + } + } public override void OnFinishProject(ICLDProject prj) { diff --git a/Distributive/Mill/MACH3_DN/Registers.cs b/Distributive/Mill/MACH3_DN/Registers.cs index 61bec03..8f57e7b 100644 --- a/Distributive/Mill/MACH3_DN/Registers.cs +++ b/Distributive/Mill/MACH3_DN/Registers.cs @@ -39,8 +39,12 @@ public partial class NCFile : TTextNCFile /// public NumericNCWord Cyc_retract = new NumericNCWord("G{##}", 0); /// + public NumericNCWord GDwell = new NumericNCWord("G{##}", 0); + /// public NumericNCWord GoTCP = new NumericNCWord("M{###}", 0); /// + public NumericNCWord M = new NumericNCWord("M{##}", 0); + /// public NumericNCWord D = new NumericNCWord("D{00}", 0); /// public NumericNCWord H = new NumericNCWord("H{00}", 0); @@ -53,14 +57,22 @@ public partial class NCFile : TTextNCFile /// public NumericNCWord Q = new NumericNCWord("Q-{####.####}", 0); /// + public NumericNCWord PSubNum = new NumericNCWord("P{##########}", 0); + /// + public NumericNCWord Pause = new NumericNCWord("P{##.#}", 0); + /// public NumericNCWord Tool = new NumericNCWord("T{####}",0); /// public NumericNCWord Feed_ = new NumericNCWord("F{####.#}",0); /// public NumericNCWord MSP = new NumericNCWord("M{00}", 5); /// + public NumericNCWord Mc = new NumericNCWord("M{00}", 0); + /// public NumericNCWord Msm = new NumericNCWord("M{0}", 0); /// + public NumericNCWord S = new NumericNCWord("S{####}", 0); + /// public NumericNCWord Flip = new NumericNCWord("G51 A-{##}", 0); /// public NCBlock TextBlock; From 9808168f5f67124daca5a1e2b8f35f8d8f79b84d Mon Sep 17 00:00:00 2001 From: Garr777 Date: Mon, 7 Nov 2022 13:59:04 +0300 Subject: [PATCH 15/35] Finished OnSpindle Func; --- Distributive/Mill/MACH3_DN/Registers.cs | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/Distributive/Mill/MACH3_DN/Registers.cs b/Distributive/Mill/MACH3_DN/Registers.cs index 8f57e7b..33715be 100644 --- a/Distributive/Mill/MACH3_DN/Registers.cs +++ b/Distributive/Mill/MACH3_DN/Registers.cs @@ -47,11 +47,11 @@ public partial class NCFile : TTextNCFile /// public NumericNCWord D = new NumericNCWord("D{00}", 0); /// - public NumericNCWord H = new NumericNCWord("H{00}", 0); + public NumericNCWord H = new NumericNCWord("H{##}", 0); /// public NumericNCWord BT = new NumericNCWord("BT-{####.####}", 0); /// - public NumericNCWord ZCycle = new NumericNCWord("Z-{####.####}", 0); + public NumericNCWord ZCycle = new NumericNCWord("Z-{####.####}", 99999.999); /// public NumericNCWord ZClear = new NumericNCWord("Z-{####.####}", 0); /// @@ -59,15 +59,17 @@ public partial class NCFile : TTextNCFile /// public NumericNCWord PSubNum = new NumericNCWord("P{##########}", 0); /// + public NumericNCWord AT = new NumericNCWord("A{######.#####}", 0); + /// public NumericNCWord Pause = new NumericNCWord("P{##.#}", 0); /// public NumericNCWord Tool = new NumericNCWord("T{####}",0); /// public NumericNCWord Feed_ = new NumericNCWord("F{####.#}",0); /// - public NumericNCWord MSP = new NumericNCWord("M{00}", 5); + public NumericNCWord MSP = new NumericNCWord("M{##}", 5); /// - public NumericNCWord Mc = new NumericNCWord("M{00}", 0); + public NumericNCWord Mc = new NumericNCWord("M{##}", 0); /// public NumericNCWord Msm = new NumericNCWord("M{0}", 0); /// @@ -93,17 +95,29 @@ public NCFile(): base() CancelScale, COORDSYS, Cycle, + ZCycle, + ZClear, Plane, KorEcv, Tool, KorDL, H, + M, + S, + Feed_, + Q, + BT, Msm, Flip, Units, MSP, GoTCP, - D + D, + Mc, + Cyc_retract, + GDwell, + PSubNum, + Pause ); TextBlock = new NCBlock( this, From c824436e272d4014d8479e31f0315563bda2539c Mon Sep 17 00:00:00 2001 From: Garr777 Date: Mon, 7 Nov 2022 13:59:32 +0300 Subject: [PATCH 16/35] To comment Initializw func; --- Distributive/Mill/MACH3_DN/Postprocessor.cs | 135 +++++++++++--------- 1 file changed, 76 insertions(+), 59 deletions(-) diff --git a/Distributive/Mill/MACH3_DN/Postprocessor.cs b/Distributive/Mill/MACH3_DN/Postprocessor.cs index be7bd7e..93ec46b 100644 --- a/Distributive/Mill/MACH3_DN/Postprocessor.cs +++ b/Distributive/Mill/MACH3_DN/Postprocessor.cs @@ -36,7 +36,7 @@ public partial class Postprocessor: TPostprocessor int Fr = 0; //! work FEED_ //! Set machene functions by default - + int D_, H_; int Firstap = 1; int Fedmod = 10; int Isfirstpass = 1; @@ -64,22 +64,20 @@ public void OutToolList() } public void Initialise() { - nc.GInterp.v = MaxReal; //! initilalise G0 rapid - nc.ZCycle.v = MaxReal; //! initalise cycle depth - nc.ZClear.v = MaxReal; //! initialise cycle rapid - nc.Cyc_retract.v = MaxReal; //! initialise G98 retract - nc.Q.v = MaxReal; //! initialise peck amount - nc.Feed_.v = MaxReal; //! initialise feed - nc.X.v = MaxReal; //! initialise X - nc.Y.v = MaxReal; //! initialise Y - nc.Z.v = MaxReal; //! initialise Z + // nc.GInterp.v = MaxReal; //! initilalise G0 rapid + // nc.ZCycle.v = MaxReal; //! initalise cycle depth + // nc.ZClear.v = MaxReal; //! initialise cycle rapid + // nc.Cyc_retract.v = MaxReal; //! initialise G98 retract + // nc.Q.v = MaxReal; //! initialise peck amount + // nc.Feed_.v = MaxReal; //! initialise feed + // nc.X.v = MaxReal; //! initialise X + // nc.Y.v = MaxReal; //! initialise Y + // nc.Z.v = MaxReal; //! initialise Z } public override void OnStartProject(ICLDProject prj) { - - nc = new NCFile(); nc.OutputFileName = Settings.Params.Str["OutFiles.NCFileName"]; //nc.ProgName = Settings.Params.Str["OutFiles.NCProgName"]; @@ -97,6 +95,26 @@ public override void OnStartProject(ICLDProject prj) nc.WriteLine("( DATE: " + CurDate() + " )"); nc.WriteLine("( TIME: " + CurTime() + " )"); + nc.ZCycle.v0 = nc.ZCycle.v; + nc.X.v = MaxReal; + nc.X.v0=nc.X.v; + nc.Y.v = MaxReal; + nc.Y.v0=nc.Y.v; + nc.Z.v = MaxReal; + nc.Z.v0=nc.Z.v; + nc.AT.v = MaxReal; + nc.AT.v0 = nc.AT.v; + nc.BT.v = MaxReal; + nc.BT.v0 = nc.BT.v; + Firstap = 1; + Fedmod = 10; + D_ = 0; // ! values D, H + H_ = 0; + nc.MSP.v = 5; + nc.MSP.v0 = nc.MSP.v; // ! spindle off + Isfirstpass = 1; + SubIDShift = 0; //! Numbers of subroutines starts from it + OutToolList(); nc.GInterp.v = 100; @@ -280,66 +298,65 @@ public override void OnPlane(ICLDPlaneCommand cmd, CLDArray cld) public override void OnSpindle(ICLDSpindleCommand cmd, CLDArray cld) { int IsReverse; - switch(cld[1]) + if(cmd.IsOn) //! On { - case 71: //! On + nc.S.v = Math.Abs(cmd.RPMValue); + if (cmd.RPMValue > 0) { - nc.S.v = Math.Abs(cld[2]); - if (cld[2] > 0) - { - nc.MSP.v = 3; - } - else nc.MSP.v = 4; //! M3/M4 CW/CCW - if (nc.MSP.v == (7-nc.MSP.v0)) - IsReverse = 1; - else - IsReverse = 0; - if (cfi >= 0) - { - if (cmd.CLDFile.Cmd[cfi].CLD[58] != 0) //! PPFun.Cld[58] = Coolant tube number - nc.Mc.v = 8; - } - - - nc.Block.Out(); - if ((IsReverse > 0) && (cmd.Next.CmdTypeCode != 1010)) + nc.MSP.v = 3; + } + else nc.MSP.v = 4; //! M3/M4 CW/CCW + if (nc.MSP.v == (7-nc.MSP.v0)) + IsReverse = 1; + else + IsReverse = 0; + if (cfi >= 0) + { + SprutTechnology.SCPostprocessor.ICLDCommand i = cmd; + while((i.CmdTypeCode) != 1079) { - nc.GDwell.v = 4; - nc.GDwell.v0 = MaxReal; - nc.Pause.v = nc.Pause.v0 * 2; - nc.Pause.v0 = MaxReal; - nc.Block.Out(); + i = i.Prev; } - break; - } - - case 72: // ! Off - { - nc.MSP.v = 5; - nc.S.v = 0; - break; + if(i.CLD[58] != 0) //! PPFun.Cld[58] = Coolant tube number + nc.Mc.v = 8; } + - - - case 246: //! Oriented stop - //!cld[2] - angle - //!S = 0 + nc.Block.Out(); + if ((IsReverse > 0) && (cmd.Next.CmdTypeCode != 1010)) { - if (nc.S.v != nc.S.v0) - nc.Block.Out(); - nc.GDwell.v = 4; - nc.GDwell.v0 = MaxReal; - nc.Pause.v = 1; - nc.Pause.v0 = MaxReal; - break; + nc.GDwell.v = 4; + nc.GDwell.v0 = MaxReal; + nc.Pause.v = nc.Pause.v0 * 2; + nc.Pause.v0 = MaxReal; + nc.Block.Out(); } + } + + if(cmd.IsOff) // ! Off + { + nc.MSP.v = 5; + nc.S.v = 0; + } + + + + if(cmd.IsOrient) //! Oriented stop + //!cld[2] - angle + //!S = 0 + { + if (nc.S.v != nc.S.v0) nc.Block.Out(); + nc.GDwell.v = 4; + nc.GDwell.v0 = MaxReal; + nc.Pause.v = 1; + nc.Pause.v0 = MaxReal; } + nc.Block.Out(); } + public override void OnFinishProject(ICLDProject prj) { - nc.Write("%"); } From 363a0878ce7e737fb0d0610346d7caca58b9468a Mon Sep 17 00:00:00 2001 From: Garr777 Date: Mon, 7 Nov 2022 17:43:59 +0300 Subject: [PATCH 17/35] Add necessary global variables; Add CardList prototype; Add OnMultyGoto fucn; --- Distributive/Mill/MACH3_DN/Postprocessor.cs | 94 ++++++++++++++++++++- 1 file changed, 91 insertions(+), 3 deletions(-) diff --git a/Distributive/Mill/MACH3_DN/Postprocessor.cs b/Distributive/Mill/MACH3_DN/Postprocessor.cs index 93ec46b..562121b 100644 --- a/Distributive/Mill/MACH3_DN/Postprocessor.cs +++ b/Distributive/Mill/MACH3_DN/Postprocessor.cs @@ -21,9 +21,9 @@ public partial class Postprocessor: TPostprocessor #endregion double MaxReal = 99999.999; - int XT_ = 0; - int YT_ = 0; - int ZT_ = 0; + double XT_ = 0; + double YT_ = 0; + double ZT_ = 0; //! Constsnt cycles variables int CycleOn = 0; //! 0 - cycle Off, 1 - cycle On int KodCycle = 0; //! constant cycle code @@ -35,6 +35,9 @@ public partial class Postprocessor: TPostprocessor int Dwell = 0; //! pause in constsnt cycles int Fr = 0; //! work FEED_ //! Set machene functions by default + double cycleon = 0; + double Feedout = 0; + double INTERP_ = 99999.999; int D_, H_; int Firstap = 1; @@ -62,6 +65,11 @@ public void OutToolList() } nc.WriteLine(); } + + public void Calcdist() + { + + } public void Initialise() { // nc.GInterp.v = MaxReal; //! initilalise G0 rapid @@ -354,7 +362,87 @@ public override void OnSpindle(ICLDSpindleCommand cmd, CLDArray cld) } nc.Block.Out(); } + + public override void OnMultiGoto(ICLDMultiGotoCommand cmd, CLDArray cld) + { + var X1 = XT_; + var Y1 = YT_; + var Z1 = ZT_; + var A1 = nc.AT.v0; + + if (INTERP_ > 1) + { + INTERP_ = 1; + } + if (cmd.Ptr["Axes(AxisXPos)"].ValueAsDouble != 0) + { + nc.X.v = cmd.Flt["Axes(AxisXPos).Value"]; + XT_ = nc.X.v; + } + if (cmd.Ptr["Axes(AxisYPos)"].ValueAsDouble != 0) + { + nc.Y.v = cmd.Flt["Axes(AxisYPos).Value"]; + YT_ = nc.Y.v; + } + if (cmd.Ptr["Axes(AxisZPos)"].ValueAsDouble != 0) + { + nc.Z.v = cmd.Flt["Axes(AxisZPos).Value"]; + ZT_ = nc.Z.v; + } + if (cmd.Ptr["Axes(AxisAPos)"].ValueAsDouble != 0) + { + nc.AT.v = cmd.Flt["Axes(AxisAPos).Value"]; + } + if ((nc.X.v != nc.X.v0) || (nc.Y.v != nc.Y.v0) || (nc.Z.v != nc.Z.v0) || (nc.AT.v != nc.AT.v0)) + { + var X2 = nc.X.v; + var Y2 = nc.Y.v; + var Z2 = nc.Z.v; + var A2 = nc.AT.v; + + if ((INTERP_ == 1 ) && (nc.AT.v != nc.AT.v0)) //! Inverse time feed output + { + Calcdist(); + } + else + { + nc.GFeed.v = 94; + if (INTERP_ != 0) + { + nc.Feed_.v = Feedout; + nc.Feed_.v0 = MaxReal; + } + } + if ((cycleon == 0) || (nc.AT.v != nc.AT.v0) || (nc.Z.v != nc.Z.v0)) //! when drilling, don't output X/Y pos + { + nc.GInterp.v = INTERP_; + if ((CycleOn>0) && ((nc.AT.v != nc.AT.v0) || (nc.Z.v != nc.Z.v0))) // ! Cannot G81 with A at the same time + { + nc.GInterp.v0 = MaxReal; + nc.Cycle.v = 80; + nc.Cycle.v0 = MaxReal; + CycleOn = 0; + } + nc.Block.Out(); // ! output to NC block + } + } + + nc.GoTCP.v = 0; + nc.GoTCP.v0 = nc.GoTCP.v; //! After any move machine is not in tool change position + if (cmd.Ptr["Axes(AxisBPos)"].ValueAsDouble != 0) + { + nc.BT.v = cmd.Flt["Axes(AxisBPos).Value"]; + if (nc.BT.v != nc.BT.v0 ) + { + nc.BT.v0 = nc.BT.v; + nc.MStop.v = 1; + nc.MStop.v0 = 0; + nc.Block.Out(); + nc.WriteLine("(Set B-axis tilt position" + nc.BT.v + " degrees)"); + } + } + } public override void OnFinishProject(ICLDProject prj) { nc.Write("%"); From 959db2e9a16b955ffc69f762a8cca45a42c3d68d Mon Sep 17 00:00:00 2001 From: Garr777 Date: Mon, 7 Nov 2022 17:44:17 +0300 Subject: [PATCH 18/35] Add Registers; --- Distributive/Mill/MACH3_DN/Registers.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Distributive/Mill/MACH3_DN/Registers.cs b/Distributive/Mill/MACH3_DN/Registers.cs index 33715be..66eefb6 100644 --- a/Distributive/Mill/MACH3_DN/Registers.cs +++ b/Distributive/Mill/MACH3_DN/Registers.cs @@ -41,10 +41,14 @@ public partial class NCFile : TTextNCFile /// public NumericNCWord GDwell = new NumericNCWord("G{##}", 0); /// + public NumericNCWord GFeed = new NumericNCWord("G{###}", 0); + /// public NumericNCWord GoTCP = new NumericNCWord("M{###}", 0); /// public NumericNCWord M = new NumericNCWord("M{##}", 0); /// + public NumericNCWord MStop = new NumericNCWord("M{##}", 0); + /// public NumericNCWord D = new NumericNCWord("D{00}", 0); /// public NumericNCWord H = new NumericNCWord("H{##}", 0); From 79b9d6c556883cb7d86a7010c4434938a6f8738c Mon Sep 17 00:00:00 2001 From: Garr777 Date: Mon, 7 Nov 2022 18:00:33 +0300 Subject: [PATCH 19/35] Add registers --- Distributive/Mill/MACH3_DN/Registers.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Distributive/Mill/MACH3_DN/Registers.cs b/Distributive/Mill/MACH3_DN/Registers.cs index 66eefb6..a2170bb 100644 --- a/Distributive/Mill/MACH3_DN/Registers.cs +++ b/Distributive/Mill/MACH3_DN/Registers.cs @@ -105,6 +105,10 @@ public NCFile(): base() KorEcv, Tool, KorDL, + GInterp, + GFeed, + MStop, + AT, H, M, S, From 63e2189eda3b6f83ab1d57c10bdab17fe7503d7b Mon Sep 17 00:00:00 2001 From: Garr777 Date: Mon, 7 Nov 2022 18:00:57 +0300 Subject: [PATCH 20/35] Resolve null exception problem in MultiGoto func --- Distributive/Mill/MACH3_DN/Postprocessor.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Distributive/Mill/MACH3_DN/Postprocessor.cs b/Distributive/Mill/MACH3_DN/Postprocessor.cs index 562121b..6b0477b 100644 --- a/Distributive/Mill/MACH3_DN/Postprocessor.cs +++ b/Distributive/Mill/MACH3_DN/Postprocessor.cs @@ -374,22 +374,22 @@ public override void OnMultiGoto(ICLDMultiGotoCommand cmd, CLDArray cld) { INTERP_ = 1; } - if (cmd.Ptr["Axes(AxisXPos)"].ValueAsDouble != 0) + if (cmd.Axis.X != null) { nc.X.v = cmd.Flt["Axes(AxisXPos).Value"]; XT_ = nc.X.v; } - if (cmd.Ptr["Axes(AxisYPos)"].ValueAsDouble != 0) + if (cmd.Axis.Y != null) { nc.Y.v = cmd.Flt["Axes(AxisYPos).Value"]; YT_ = nc.Y.v; } - if (cmd.Ptr["Axes(AxisZPos)"].ValueAsDouble != 0) + if (cmd.Axis.Z != null) { nc.Z.v = cmd.Flt["Axes(AxisZPos).Value"]; ZT_ = nc.Z.v; } - if (cmd.Ptr["Axes(AxisAPos)"].ValueAsDouble != 0) + if (cmd.Axis.A != null) { nc.AT.v = cmd.Flt["Axes(AxisAPos).Value"]; } @@ -430,7 +430,7 @@ public override void OnMultiGoto(ICLDMultiGotoCommand cmd, CLDArray cld) nc.GoTCP.v = 0; nc.GoTCP.v0 = nc.GoTCP.v; //! After any move machine is not in tool change position - if (cmd.Ptr["Axes(AxisBPos)"].ValueAsDouble != 0) + if (cmd.Axis.B != null) { nc.BT.v = cmd.Flt["Axes(AxisBPos).Value"]; if (nc.BT.v != nc.BT.v0 ) @@ -439,7 +439,7 @@ public override void OnMultiGoto(ICLDMultiGotoCommand cmd, CLDArray cld) nc.MStop.v = 1; nc.MStop.v0 = 0; nc.Block.Out(); - nc.WriteLine("(Set B-axis tilt position" + nc.BT.v + " degrees)"); + nc.WriteLine("(Set B-axis tilt position" + (int)nc.BT.v + " degrees)"); } } } From 620156af9f50ccf3f257aa9126f9a78345ee9145 Mon Sep 17 00:00:00 2001 From: Garr777 Date: Mon, 7 Nov 2022 18:36:57 +0300 Subject: [PATCH 21/35] Add registers --- Distributive/Mill/MACH3_DN/Postprocessor.cs | 95 +++++++++++++++++++-- Distributive/Mill/MACH3_DN/Registers.cs | 5 +- 2 files changed, 94 insertions(+), 6 deletions(-) diff --git a/Distributive/Mill/MACH3_DN/Postprocessor.cs b/Distributive/Mill/MACH3_DN/Postprocessor.cs index 6b0477b..b135753 100644 --- a/Distributive/Mill/MACH3_DN/Postprocessor.cs +++ b/Distributive/Mill/MACH3_DN/Postprocessor.cs @@ -66,10 +66,7 @@ public void OutToolList() nc.WriteLine(); } - public void Calcdist() - { - - } + public void Initialise() { // nc.GInterp.v = MaxReal; //! initilalise G0 rapid @@ -402,7 +399,94 @@ public override void OnMultiGoto(ICLDMultiGotoCommand cmd, CLDArray cld) if ((INTERP_ == 1 ) && (nc.AT.v != nc.AT.v0)) //! Inverse time feed output { - Calcdist(); + // ! (X1 Y1 Y1 A1) - start position + // ! (X2 Y2 Z2 A2) - final position + + double dx; + double dy; + double dz; + double da; + double R; + double stp; + double ti; + double xn; + double yn; + double zn; + double an; + double px; + double py; + double pz; + double pa; + double Dist; + + var time = cmd.Time; + Dist = 0; + dx = X2-X1; + dy = Y2-Y1; + dz = Z2-Z1; + da = A2-A1; + if (da == 0) //!3d case + { + Dist = Math.Pow(dx*dx+dy*dy+dz*dz,2); + } + else + if ((dy == 0) && (dz == 0)) // !simple helic + { + R = Math.Pow(Y1*Y1+Z1*Z1,2); //!radius of helic + R = R* da*3.141592653/180 ; //!Length of arc + Dist = Math.Pow(dx*dx+R*R,2); //! Length of helic + } + else //!public case. Divide curve with 1 deg step + { + Dist = 0; + an = A1; + ti = 0; + xn = X2*ti + X1*(1-ti); + yn = Y2*ti + Y1*(1-ti); + zn = Z2*ti + Z1*(1-ti); + R = Math.Pow(yn*yn+zn*zn,2); //!radius of current point + yn = R*Math.Cos(an); + zn = R*Math.Sin(an); + do //! save previous position + { + px = xn; + py = yn; + pz = zn; //! calculating new point in 1 deg. You can change the step if you need the better tolerance + if (A2>A1) + { + an = an + 1; + } + else + an = an -1; + ti = (an-A1)/(A2-A1); + if (ti>1) + { + ti = 1; + an = A2; + } + xn = X2*ti + X1*(1-ti); + yn = Y2*ti + Y1*(1-ti); + zn = Z2*ti + Z1*(1-ti); + R = Math.Pow(yn*yn+zn*zn,2); //!radius of current point + yn = R*Math.Cos(an); + zn = R*Math.Sin(an); + dx = xn-px; + dy = yn-py; + dz = zn-pz; + Dist = Dist + Math.Pow(dx*dx+dy*dy+dz*dz,2); + }while(ti>=1); + } + nc.GFeed.v = 93; //!print dist + time = Dist / Feedout; + if (Abs(time)<0.00001) + { + nc.InvFeed.v = 60000; + } + else + { + nc.InvFeed.v = 1 / (time); + } + nc.InvFeed.v0 = MaxReal; //!Print InvFeed } else { @@ -442,6 +526,7 @@ public override void OnMultiGoto(ICLDMultiGotoCommand cmd, CLDArray cld) nc.WriteLine("(Set B-axis tilt position" + (int)nc.BT.v + " degrees)"); } } + } public override void OnFinishProject(ICLDProject prj) { diff --git a/Distributive/Mill/MACH3_DN/Registers.cs b/Distributive/Mill/MACH3_DN/Registers.cs index a2170bb..56af3a7 100644 --- a/Distributive/Mill/MACH3_DN/Registers.cs +++ b/Distributive/Mill/MACH3_DN/Registers.cs @@ -69,7 +69,9 @@ public partial class NCFile : TTextNCFile /// public NumericNCWord Tool = new NumericNCWord("T{####}",0); /// - public NumericNCWord Feed_ = new NumericNCWord("F{####.#}",0); + public NumericNCWord Feed_ = new NumericNCWord("F{####.#}",0); + /// + public NumericNCWord InvFeed = new NumericNCWord("F{####.##}",0); /// public NumericNCWord MSP = new NumericNCWord("M{##}", 5); /// @@ -113,6 +115,7 @@ public NCFile(): base() M, S, Feed_, + InvFeed, Q, BT, Msm, From a8b016789745447425e053d7ea5092d760ef90bf Mon Sep 17 00:00:00 2001 From: Garr777 Date: Mon, 7 Nov 2022 22:00:00 +0300 Subject: [PATCH 22/35] Add functions --- Distributive/Mill/MACH3_DN/Postprocessor.cs | 195 ++++++++++++++++++-- Distributive/Mill/MACH3_DN/Registers.cs | 101 ++++++---- 2 files changed, 244 insertions(+), 52 deletions(-) diff --git a/Distributive/Mill/MACH3_DN/Postprocessor.cs b/Distributive/Mill/MACH3_DN/Postprocessor.cs index b135753..a3f2081 100644 --- a/Distributive/Mill/MACH3_DN/Postprocessor.cs +++ b/Distributive/Mill/MACH3_DN/Postprocessor.cs @@ -35,9 +35,11 @@ public partial class Postprocessor: TPostprocessor int Dwell = 0; //! pause in constsnt cycles int Fr = 0; //! work FEED_ //! Set machene functions by default - double cycleon = 0; + double cycleon = 1; double Feedout = 0; double INTERP_ = 99999.999; + double interp_ = 99999.999; + string StructNodeName = ""; int D_, H_; int Firstap = 1; @@ -122,7 +124,6 @@ public override void OnStartProject(ICLDProject prj) OutToolList(); - nc.GInterp.v = 100; nc.Plane.v = 17; nc.KorEcv.v = 40; nc.KorDL.v = 49; @@ -145,11 +146,42 @@ public override void OnStartProject(ICLDProject prj) public override void OnGoto(ICLDGotoCommand cmd, CLDArray cld) { - nc.GInterp.v = 1; - nc.X.v = cmd.EP.X; - nc.Y.v = cmd.EP.Y; - nc.Z.v = cmd.EP.Z; - nc.Block.Out(); + if (INTERP_>0) + { + nc.GFeed.v = 94; + nc.Feed_.v = Feedout; + if (nc.GFeed.v != nc.GFeed.v0) + nc.Feed_.v0 = MaxReal; + } + if (INTERP_ > 1) + INTERP_ = 1; //! G1 + nc.X.v = cld[1]; // ! X,Y,Z in absolutes + nc.Y.v = cld[2]; + nc.Z.v = cld[3]; + if ((nc.X.v != nc.X.v0) || (nc.Y.v0 != nc.Y.v0) || (nc.Z.v != nc.Z.v0)) + { + if ((cycleon == 0) || (nc.AT.v != nc.AT.v0) || (nc.Z.v != nc.Z.v0)) //! when drilling, don't output X/Y pos + { + nc.GInterp.v = INTERP_; + if ((CycleOn > 0) && ((nc.AT.v != nc.AT.v0) || (nc.Z.v0 != nc.Z.v0))) // ! Cannot G81 with A at the same time + { + nc.GInterp.v0 = MaxReal; + nc.Cycle.v = 80; + nc.Cycle.v0 = MaxReal; + CycleOn = 0; + } + nc.Block.Out(); // ! output to NC block + + } + + } + XT_ = nc.X.v; YT_ = nc.Y.v; ZT_ = nc.Z.v; //! save current coordinates + nc.GoTCP.v = 0; nc.GoTCP.v0 = nc.GoTCP.v; //! After any move machine is not in tool change position + // nc.GInterp.v = 1; + // nc.X.v = cmd.EP.X; + // nc.Y.v = cmd.EP.Y; + // nc.Z.v = cmd.EP.Z; + // nc.Block.Out(); } public override void OnPPFun(ICLDPPFunCommand cmd, CLDArray cld) @@ -341,7 +373,6 @@ public override void OnSpindle(ICLDSpindleCommand cmd, CLDArray cld) if(cmd.IsOff) // ! Off { nc.MSP.v = 5; - nc.S.v = 0; } @@ -509,10 +540,10 @@ public override void OnMultiGoto(ICLDMultiGotoCommand cmd, CLDArray cld) } nc.Block.Out(); // ! output to NC block } + nc.GoTCP.v = 0; + nc.GoTCP.v0 = nc.GoTCP.v; //! After any move machine is not in tool change position } - - nc.GoTCP.v = 0; - nc.GoTCP.v0 = nc.GoTCP.v; //! After any move machine is not in tool change position + if (cmd.Axis.B != null) { @@ -528,6 +559,146 @@ public override void OnMultiGoto(ICLDMultiGotoCommand cmd, CLDArray cld) } } + + public override void OnStructure(ICLDStructureCommand cmd, CLDArray cld) + { + var NodeType = ""; + if (!cmd.IsClose) // ! Open group + { + NodeType = cmd.Str["NodeType"]; + StructNodeName = cmd.Str["Comment"]; + if ((StructNodeName != "") && + (NodeType == "Block") && + ((cmd.Caption).ToUpper() == ("HoleMachiningOp").ToUpper()) && + (cfi>=0)) + { + SprutTechnology.SCPostprocessor.ICLDCommand i = cmd; + while((i.CmdTypeCode) != 1079) + { + i = i.Prev; + } + if(i.Int["PPFun(TechInfo).Operation(1).NCCodeFormat"] == 0) // ! Expanded cycle format + { + nc.BlockN.v = nc.BlockN.v + nc.BlockN.AutoIncrementStep; + nc.Output("N" + Str(nc.BlockN.v) + " (" + StructNodeName + ")"); + } + } + } + else //! Close group + { + StructNodeName = ""; + } + } + + public override void OnRapid(ICLDRapidCommand cmd, CLDArray cld) + { + if (INTERP_ > 0) + { + INTERP_ = 0; //! G0 + } + } + + public override void OnCoolant(ICLDCoolantCommand cmd, CLDArray cld) + { + if ((nc.MSP.v != nc.MSP.v) || (nc.M.v != nc.M.v0)) + nc.Block.Out(); + if (cld[1] == 71) + nc.Mc.v = 8; + else nc.Mc.v = 9; //! On/Off coolant + } + + public override void OnFeedrate(ICLDFeedrateCommand cmd, CLDArray cld) + { + Feedout = cld[1]; // ! filling FEED_ rgister + if (cld[3]==316) + Feedout = nc.S.v/Feedout; + if (INTERP_ == 0) + INTERP_ = 1; //! G1 + } + + public override void OnCircle(ICLDCircleCommand cmd, CLDArray cld) + { + if (cld[4] > 0) + INTERP_ = 3; + else INTERP_ = 2; //! G3/G2 + nc.XC_.v = cld[1] - XT_ + 10/1000000; // ! I,J,K in increments always + nc.YC_.v = cld[2] - YT_ + 10/1000000; + nc.ZC_.v = cld[3] - ZT_ + 10/1000000; + nc.X.v = cld[5]; // ! X,Y,Z in absolutes + nc.Y.v = cld[6]; + nc.Z.v = cld[7]; + nc.XC_.v0 = MaxReal; + nc.YC_.v0 = MaxReal; + nc.ZC_.v0 = MaxReal; + nc.X.v0 = MaxReal; + nc.Y.v0 = MaxReal; + nc.Z.v0 = MaxReal; + switch(nc.Plane.v) + { + case 17: + { + nc.ZC_.v0 = nc.ZC_.v; + nc.Z.v0 = nc.Z.v; //!This line changed 17Jan07 by TM for helical path fix via Dave Pearson + break; + } + case 18: + { + nc.YC_.v0 = nc.YC_.v; + nc.Y.v0 = nc.Y.v; //!This line changed 17Jan07 by TM for helical path fix via Dave Pearson + break; + } + case 19: + { + nc.XC_.v0 = nc.XC_.v; + nc.X.v0 = nc.X.v; //!This line changed 17Jan07 by TM for helical path fix via Dave Pearson + break; + } + } + if (interp_ > 1) + nc.Feed_.v = Feedout; + nc.GInterp.v = INTERP_; + nc.Block.Out(); //! output to NC block + XT_ = cld[5]; //! save current coordinates + YT_ = cld[6]; + ZT_ = cld[7]; + nc.GoTCP.v = 0; nc.GoTCP.v0 = nc.GoTCP.v; //! After any move machine is not in tool change position + } + + public override void OnPhysicGoto(ICLDPhysicGotoCommand cmd, CLDArray cld) + { + program PhysicGoto + if Cmd.Ptr["Axes(AxisXPos)"]<>0 then begin + X = Cmd.Flt["Axes(AxisXPos).Value"] + XT_ = X + end + if Cmd.Ptr["Axes(AxisYPos)"]<>0 then begin + Y = Cmd.Flt["Axes(AxisYPos).Value"] + YT_ = Y + end + if Cmd.Ptr["Axes(AxisZPos)"]<>0 then begin + Z = Cmd.Flt["Axes(AxisZPos).Value"] + ZT_ = Z + end + if Cmd.Ptr["Axes(AxisAPos)"]<>0 then begin + AT = Cmd.Flt["Axes(AxisAPos).Value"] + end + if (X<>X@) or (Y<>Y@) or (Z<>Z@) or (AT<>AT@) then begin + GInterp = 53; GInterp@ = MaxReal ! G53 + OutBlock ! output to NC block + end + + if Cmd.Ptr["Axes(AxisBPos)"]<>0 then begin + BT = Cmd.Flt["Axes(AxisBPos).Value"] + if BT <> BT@ then begin + BT@ = BT; + MStop = 1; + MStop@ = 0; + OutBlock + output "(Set B-axis tilt position"+ STR(BT)+" degrees)" + end; + end + end + } public override void OnFinishProject(ICLDProject prj) { nc.Write("%"); @@ -552,4 +723,4 @@ public override void StopOnCLData() // override On } -} +} \ No newline at end of file diff --git a/Distributive/Mill/MACH3_DN/Registers.cs b/Distributive/Mill/MACH3_DN/Registers.cs index 56af3a7..0051f63 100644 --- a/Distributive/Mill/MACH3_DN/Registers.cs +++ b/Distributive/Mill/MACH3_DN/Registers.cs @@ -17,7 +17,7 @@ public partial class NCFile : TTextNCFile /// public NumericNCWord Z = new NumericNCWord("Z{-#####!####}", 0); /// - public NumericNCWord GInterp = new NumericNCWord("G{00}", 0); + public NumericNCWord GInterp = new NumericNCWord("G{##}", 100); /// public NumericNCWord Plane = new NumericNCWord("G{00}", 0); /// @@ -41,6 +41,10 @@ public partial class NCFile : TTextNCFile /// public NumericNCWord GDwell = new NumericNCWord("G{##}", 0); /// + public NumericNCWord GLCS = new NumericNCWord("G{##}", 0); + /// + public NumericNCWord GFUNCC = new NumericNCWord("G{##}", 0); + /// public NumericNCWord GFeed = new NumericNCWord("G{###}", 0); /// public NumericNCWord GoTCP = new NumericNCWord("M{###}", 0); @@ -53,7 +57,9 @@ public partial class NCFile : TTextNCFile /// public NumericNCWord H = new NumericNCWord("H{##}", 0); /// - public NumericNCWord BT = new NumericNCWord("BT-{####.####}", 0); + public NumericNCWord BT = new NumericNCWord("B-{####.####}", 0); + /// + public NumericNCWord CT = new NumericNCWord("C-{####.####}", 0); /// public NumericNCWord ZCycle = new NumericNCWord("Z-{####.####}", 99999.999); /// @@ -61,6 +67,14 @@ public partial class NCFile : TTextNCFile /// public NumericNCWord Q = new NumericNCWord("Q-{####.####}", 0); /// + public NumericNCWord QStep = new NumericNCWord("Q{#####.####}", 0); + /// + public NumericNCWord XC_ = new NumericNCWord("I{#####.####}", 0); + /// + public NumericNCWord YC_ = new NumericNCWord("J{#####.####}", 0); + /// + public NumericNCWord ZC_ = new NumericNCWord("K{######.#####}", 0); + /// public NumericNCWord PSubNum = new NumericNCWord("P{##########}", 0); /// public NumericNCWord AT = new NumericNCWord("A{######.#####}", 0); @@ -91,44 +105,51 @@ public partial class NCFile : TTextNCFile public NCFile(): base() { Block = new NCBlock( - this, - BlockN, - X, - Y, - Z, - ABS_INC, - SmoothMv, - CancelScale, - COORDSYS, - Cycle, - ZCycle, - ZClear, - Plane, - KorEcv, - Tool, - KorDL, - GInterp, - GFeed, - MStop, - AT, - H, - M, - S, - Feed_, - InvFeed, - Q, - BT, - Msm, - Flip, - Units, - MSP, - GoTCP, - D, - Mc, - Cyc_retract, - GDwell, - PSubNum, - Pause + this, + BlockN, + ABS_INC, + SmoothMv, + CancelScale, + COORDSYS, + GLCS, + Cycle, + GInterp, + GFUNCC, + GDwell, + Plane, + GFeed, + GoTCP, + KorEcv, + Cyc_retract, + X, + Y, + Z, + XC_, + YC_, + ZC_, + ZCycle, + ZClear, + Q, + QStep, + Feed_, + Pause, + D, + S, + Tool, + KorDL, + H, + Msm, + Flip, + M, + MStop, + MSP, + Mc, + AT, + BT, + CT, + InvFeed, + PSubNum, + Units ); TextBlock = new NCBlock( this, From 47fba13245095327d67062113927bd8b7328ce96 Mon Sep 17 00:00:00 2001 From: Garr777 Date: Tue, 8 Nov 2022 09:36:18 +0300 Subject: [PATCH 23/35] Add OnPhysicGoto comm; --- Distributive/Mill/MACH3_DN/Postprocessor.cs | 118 ++++++++++++-------- 1 file changed, 73 insertions(+), 45 deletions(-) diff --git a/Distributive/Mill/MACH3_DN/Postprocessor.cs b/Distributive/Mill/MACH3_DN/Postprocessor.cs index a3f2081..7867aad 100644 --- a/Distributive/Mill/MACH3_DN/Postprocessor.cs +++ b/Distributive/Mill/MACH3_DN/Postprocessor.cs @@ -25,15 +25,15 @@ public partial class Postprocessor: TPostprocessor double YT_ = 0; double ZT_ = 0; //! Constsnt cycles variables - int CycleOn = 0; //! 0 - cycle Off, 1 - cycle On - int KodCycle = 0; //! constant cycle code - int Za = 0; //! work depth - int Zf = 0; //! safe level - int ZP_ = 0; // ! reverse move level - int Zl = 0; //! depth of one drilling step - int Zi = 0; //! transitional value - int Dwell = 0; //! pause in constsnt cycles - int Fr = 0; //! work FEED_ + double CycleOn = 0; //! 0 - cycle Off, 1 - cycle On + double KodCycle = 0; //! constant cycle code + double Za = 0; //! work depth + double Zf = 0; //! safe level + double ZP_ = 0; // ! reverse move level + double Zl = 0; //! depth of one drilling step + double Zi = 0; //! transitional value + double Dwell = 0; //! pause in constsnt cycles + double Fr = 0; //! work FEED_ //! Set machene functions by default double cycleon = 1; double Feedout = 0; @@ -41,15 +41,36 @@ public partial class Postprocessor: TPostprocessor double interp_ = 99999.999; string StructNodeName = ""; - int D_, H_; int Firstap = 1; int Fedmod = 10; int Isfirstpass = 1; int SubIDShift = 0;//! Numbers of subroutines starts from it - int cfi; - int ppfj; - + + double Interp_; + double CYCLEON; + double KODCYCLE; + double ZA; + double ZF; + double ZL; + double ZI; + double DWELL; + double FR; + double D_; + double H_; + int IsFirstpass; + double X1; + double Y1; + double Z1; + double A1; + double X2; + double Y2; + double Z2; + double A2; + double FedMod; + string OperationType; + int cfi; //! CLDFile.CurrentFile + int ppfj; // ! CLDFile[cfi].Cmd[ppfj] = PPFun(TechInfo) of the current operation const string SPPName = "MACH3_DN"; public void OutToolList() @@ -666,38 +687,45 @@ public override void OnCircle(ICLDCircleCommand cmd, CLDArray cld) public override void OnPhysicGoto(ICLDPhysicGotoCommand cmd, CLDArray cld) { - program PhysicGoto - if Cmd.Ptr["Axes(AxisXPos)"]<>0 then begin - X = Cmd.Flt["Axes(AxisXPos).Value"] - XT_ = X - end - if Cmd.Ptr["Axes(AxisYPos)"]<>0 then begin - Y = Cmd.Flt["Axes(AxisYPos).Value"] - YT_ = Y - end - if Cmd.Ptr["Axes(AxisZPos)"]<>0 then begin - Z = Cmd.Flt["Axes(AxisZPos).Value"] - ZT_ = Z - end - if Cmd.Ptr["Axes(AxisAPos)"]<>0 then begin - AT = Cmd.Flt["Axes(AxisAPos).Value"] - end - if (X<>X@) or (Y<>Y@) or (Z<>Z@) or (AT<>AT@) then begin - GInterp = 53; GInterp@ = MaxReal ! G53 - OutBlock ! output to NC block - end - - if Cmd.Ptr["Axes(AxisBPos)"]<>0 then begin - BT = Cmd.Flt["Axes(AxisBPos).Value"] - if BT <> BT@ then begin - BT@ = BT; - MStop = 1; - MStop@ = 0; - OutBlock - output "(Set B-axis tilt position"+ STR(BT)+" degrees)" - end; - end - end + if (cmd.Axis.X != null) + { + nc.X.v = cmd.Flt["Axes(AxisXPos).Value"]; + XT_ = nc.X.v; + } + if (cmd.Axis.Y != null) + { + nc.Y.v = cmd.Flt["Axes(AxisYPos).Value"]; + YT_ = nc.Y.v; + } + + if (cmd.Axis.Z != null) + { + nc.Z.v = cmd.Flt["Axes(AxisZPos).Value"]; + ZT_ = nc.Z.v; + } + if (cmd.Axis.A != null) + { + nc.AT.v = cmd.Flt["Axes(AxisAPos).Value"]; + } + if ((nc.X.v!=nc.X.v0) || (nc.Y.v!=nc.Y.v0) || (nc.Z.v!=nc.Z.v0) || (nc.AT.v!=nc.AT.v0)) + { + nc.GInterp.v = 53; + nc.GInterp.v0 = MaxReal; // ! G53 + nc.Block.Out(); // ! output to NC block + } + + if (cmd.Axis.B != null) + { + nc.BT.v = cmd.Flt["Axes(AxisBPos).Value"]; + if (nc.BT.v != nc.BT.v0) + { + nc.BT.v0 = nc.BT.v; + nc.MStop.v = 1; + nc.MStop.v0 = 0; + nc.Block.Out(); + nc.Output("(Set B-axis tilt position" + nc.BT.v + " degrees)"); + } + } } public override void OnFinishProject(ICLDProject prj) { From ee11aeed0e26e115876ee99b860abdf0ce54829d Mon Sep 17 00:00:00 2001 From: Garr777 Date: Tue, 8 Nov 2022 10:00:16 +0300 Subject: [PATCH 24/35] Add OnAbsMov comm (commented); --- Distributive/Mill/MACH3_DN/Postprocessor.cs | 37 +++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/Distributive/Mill/MACH3_DN/Postprocessor.cs b/Distributive/Mill/MACH3_DN/Postprocessor.cs index 7867aad..cd0acaf 100644 --- a/Distributive/Mill/MACH3_DN/Postprocessor.cs +++ b/Distributive/Mill/MACH3_DN/Postprocessor.cs @@ -727,6 +727,43 @@ public override void OnPhysicGoto(ICLDPhysicGotoCommand cmd, CLDArray cld) } } } + + // public override void OnAbsMov(ICLDPhysicGotoCommand cmd, CLDArray cld) + // { + // if (INTERP_>0) + // { + // nc.GFeed.v = 94; + // nc.Feed_.v = Feedout; + // if (nc.GFeed.v!=nc.GFeed.v0) + // { + // nc.Feed_.v0=MaxReal; + // } + // } + // if (INTERP_ > 1) //! G1 + // { + // INTERP_ = 1; + // } + // nc.X.v = cld[1]; // ! X,Y,Z in absolutes + // nc.Y.v = cld[2]; + // nc.Z.v = cld[3]; + // if ((nc.X.v != nc.X.v0) || (nc.Y.v!=nc.Y.v0) || (nc.Z.v!=nc.Z.v0)) + // { + // if ((cycleon==0) && (nc.AT.v!=nc.AT.v0) && (nc.Z.v!=nc.Z.v0)) // ! when drilling, don't output X/Y pos + // { + // nc.GInterp.v = INTERP_; + // if ((CycleOn>0) && ((nc.AT.v!=nc.AT.v0) || (nc.Z.v!=nc.Z.v0))) // ! Cannot G81 with A at the same time + // { + // nc.GInterp.v0 = MaxReal; + // nc.Cycle.v = 80; + // nc.Cycle.v0 = MaxReal; + // CycleOn = 0; + // } + // nc.Block.Out(); // ! output to NC block + // } + // } + // XT_ = nc.X.v; YT_ = nc.Y.v; ZT_ = nc.Z.v; //! save current coordinates + // nc.GoTCP.v = 0; nc.GoTCP.v0 = nc.GoTCP.v; //! After any move machine is not in tool change position + // } public override void OnFinishProject(ICLDProject prj) { nc.Write("%"); From 35ed1119e4c2e16ce332b8efe85df340d14e63eb Mon Sep 17 00:00:00 2001 From: Garr777 Date: Tue, 8 Nov 2022 10:05:36 +0300 Subject: [PATCH 25/35] Add CutCom command; --- Distributive/Mill/MACH3_DN/Postprocessor.cs | 23 +++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/Distributive/Mill/MACH3_DN/Postprocessor.cs b/Distributive/Mill/MACH3_DN/Postprocessor.cs index cd0acaf..56f146a 100644 --- a/Distributive/Mill/MACH3_DN/Postprocessor.cs +++ b/Distributive/Mill/MACH3_DN/Postprocessor.cs @@ -764,6 +764,29 @@ public override void OnPhysicGoto(ICLDPhysicGotoCommand cmd, CLDArray cld) // XT_ = nc.X.v; YT_ = nc.Y.v; ZT_ = nc.Z.v; //! save current coordinates // nc.GoTCP.v = 0; nc.GoTCP.v0 = nc.GoTCP.v; //! After any move machine is not in tool change position // } + + public override void OnCutCom(ICLDCutComCommand cmd, CLDArray cld) + { + if (cld[2]==9) //! LENGTH + { + if (cld[1] ==71) + H_=cld[3] ; + else H_= 0; + } + + else if (cld[2]==23) // ! RADIUS + { + if (cld[1]==72) + nc.KorEcv.v=40; + else + { + if (cld[10]==24) + nc.KorEcv.v=42; + else nc.KorEcv.v=41; + nc.D.v=cld[3]; + } + } + } public override void OnFinishProject(ICLDProject prj) { nc.Write("%"); From bd55e48b24240408e28fbd9fee67124f07f6739d Mon Sep 17 00:00:00 2001 From: Garr777 Date: Tue, 8 Nov 2022 10:50:57 +0300 Subject: [PATCH 26/35] Add Tapper program; Add OnCycle command; --- Distributive/Mill/MACH3_DN/Postprocessor.cs | 146 ++++++++++++++++++++ 1 file changed, 146 insertions(+) diff --git a/Distributive/Mill/MACH3_DN/Postprocessor.cs b/Distributive/Mill/MACH3_DN/Postprocessor.cs index 56f146a..849b6b4 100644 --- a/Distributive/Mill/MACH3_DN/Postprocessor.cs +++ b/Distributive/Mill/MACH3_DN/Postprocessor.cs @@ -103,6 +103,37 @@ public void Initialise() // nc.Z.v = MaxReal; //! initialise Z } + + public void Tapper(double BottomLev,double ReturnLev,double WorkFeed,double ReturnFeed,double BottomDwell, double TopDwell) + { + nc.Block.Out(); + if (StructNodeName!="") + { + nc.BlockN.v = nc.BlockN.v + nc.BlockN.AutoIncrementStep; + nc.Output("N" + nc.BlockN.v + " (" + StructNodeName + ")"); + } + nc.MSP.v0 = 99999.999; // ! Spindle forward + nc.S.v0 = 99999.999; + nc.Block.Out(); + nc.GInterp.v = 1; nc.GInterp.v0 = 99999.999; + nc.Z.v = BottomLev; nc.Z.v0 = 99999.999; // ! Feed to depth + nc.Feed_.v = WorkFeed; nc.Feed_.v0 = 99999.999; // ! Reduce feedrate + nc.Block.Out(); + nc.MSP.v = 7-nc.MSP.v; // ! Spindle reverse + nc.Block.Out(); + nc.GDwell.v = 4; nc.GDwell.v0 = 99999.999; //! Dwell for spindle + nc.Pause.v = BottomDwell; nc.Pause.v0 = 99999.999; + nc.Block.Out(); + nc.GInterp.v = 1; nc.GInterp.v0 = 99999.999; + nc.Z.v = ReturnLev; nc.Z.v0= 99999.999; // ! Feed back to safe level + nc.Feed_.v = ReturnFeed; nc.Feed_.v0 = 99999.999; // ! Increase feedrate + nc.Block.Out(); + nc.MSP.v = 7-nc.MSP.v; // ! Spindle forward + nc.Block.Out(); + nc.GDwell.v = 4; nc.GDwell.v0 = 99999.999; // ! Dwell for spindle + nc.Pause.v = TopDwell; nc.Pause.v0 = 99999.999; + nc.Block.Out(); + } public override void OnStartProject(ICLDProject prj) { @@ -787,6 +818,121 @@ public override void OnCutCom(ICLDCutComCommand cmd, CLDArray cld) } } } + + public override void OnCycle(ICLDCycleCommand cmd, CLDArray cld) + { + if (cld[1]==72) //! cycle Off + { + CycleOn = 0; + nc.Cycle.v = 80; + nc.Block.Out(); // ! modified 1Oct07 per Dave Pearson to fix G80/G0 issue - ; OutBlock added + INTERP_ = 0; + nc.GInterp.v = 1; + nc.GInterp.v0 = nc.GInterp.v; + } + else // ! cycle call + { + KodCycle = cld[1]; + if (KodCycle == 168) + { + if ((OperationType).ToUpper() == ("HoleMachiningOp").ToUpper()) + { + Fr = nc.S.v/cld[12]; //! For new HoleMachining operation take feed from thread step + } + else //! For old HoleMachining operation take feed from WorkFeed as it was before + { + if (cld[3]==316) + Fr=nc.S.v*cld[4]; + else Fr=cld[4]; + } + Tapper(cld[5]-cld[2], cld[8], Fr, cld[15], cld[10], 2*cld[10]); + } + else + { + nc.Cyc_retract.v = 98; + CycleOn = 1; //! cycle On + Za = cld[2]; // ! work depth + if (cld[4] > 0) //! creating FEED_ value + { + if (cld[3] == 316) + Fr=cld[4]*nc.S.v; + else Fr=cld[4]; + + } + Zf = cld[5]; // ! safe level + ZP_ = cld[8]; // ! reverse move level + Dwell = cld[10]; //! dwell time + if (cld[1] == 153 || cld[1]==288) // ! DEEP,BRKCHP + { + Zl = cld[6]; // ! depth of one drilling step + Zi = cld[7]; // ! transitional value + ZP_ = cld[8]; // ! reverse move level + } + nc.ZCycle.v = Zf-Za; + nc.ZClear.v = Zf; + nc.Pause.v = Dwell; + Dwell=0; + if (Zl != 0) + nc.Q.v = Zl; + Zl=0; + nc.Feed_.v = Fr; + switch(KodCycle) + { + case 163: + { + nc.Cycle.v = 81; // ! DRILL + break; + } + case 81: + { + nc.Cycle.v = 82; // ! FACE + break; + } + case 168: + { + nc.Cycle.v = 84; // ! TAP + break; + } + case 209: + { + nc.Cycle.v = 85; // ! BORE5 + break; + } + case 210: + { + nc.Cycle.v = 86; // ! BORE6 + break; + } + case 211: + { + nc.Cycle.v = 87; //! BORE7 + break; + } + case 212: + { + nc.Cycle.v = 88; //! BORE8 + break; + } + case 213: + { + nc.Cycle.v = 89; //! BORE9 + break; + } + case 153: + { + nc.Cycle.v = 83; //! DEEP + break; + } + case 288: + { + nc.Cycle.v = 73; //! BRKCHP + break; + } + } + nc.Block.Out(); + } + } + } public override void OnFinishProject(ICLDProject prj) { nc.Write("%"); From 946d929d1c9d852a3c657d6eeb7df1a30b71d7d8 Mon Sep 17 00:00:00 2001 From: Garr777 Date: Tue, 8 Nov 2022 13:08:45 +0300 Subject: [PATCH 27/35] Add Tapper --- Distributive/Mill/MACH3_DN/Postprocessor.cs | 31 +++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/Distributive/Mill/MACH3_DN/Postprocessor.cs b/Distributive/Mill/MACH3_DN/Postprocessor.cs index 849b6b4..900a92a 100644 --- a/Distributive/Mill/MACH3_DN/Postprocessor.cs +++ b/Distributive/Mill/MACH3_DN/Postprocessor.cs @@ -89,6 +89,37 @@ public void OutToolList() nc.WriteLine(); } + public void Tapper(double BottomLev,double ReturnLev,double WorkFeed,double ReturnFeed,double BottomDwell, double TopDwell) + { + nc.Block.Out(); + if (StructNodeName!="") + { + nc.BlockN.v = nc.BlockN.v + nc.BlockN.AutoIncrementStep; + nc.Output("N" + nc.BlockN.v + " (" + StructNodeName + ")"); + } + nc.MSP.v0 = 99999.999; // ! Spindle forward + nc.S.v0 = 99999.999; + nc.Block.Out(); + nc.GInterp.v = 1; nc.GInterp.v0 = 99999.999; + nc.Z.v = BottomLev; nc.Z.v0 = 99999.999; // ! Feed to depth + nc.Feed_.v = WorkFeed; nc.Feed_.v0 = 99999.999; // ! Reduce feedrate + nc.Block.Out(); + nc.MSP.v = 7-nc.MSP.v; // ! Spindle reverse + nc.Block.Out(); + nc.GDwell.v = 4; nc.GDwell.v0 = 99999.999; //! Dwell for spindle + nc.Pause.v = BottomDwell; nc.Pause.v0 = 99999.999; + nc.Block.Out(); + nc.GInterp.v = 1; nc.GInterp.v0 = 99999.999; + nc.Z.v = ReturnLev; nc.Z.v0= 99999.999; // ! Feed back to safe level + nc.Feed_.v = ReturnFeed; nc.Feed_.v0 = 99999.999; // ! Increase feedrate + nc.Block.Out(); + nc.MSP.v = 7-nc.MSP.v; // ! Spindle forward + nc.Block.Out(); + nc.GDwell.v = 4; nc.GDwell.v0 = 99999.999; // ! Dwell for spindle + nc.Pause.v = TopDwell; nc.Pause.v0 = 99999.999; + nc.Block.Out(); + } + public void Initialise() { From 4716e0b41e131dd3bc323d7f6931c5c4265a38c3 Mon Sep 17 00:00:00 2001 From: Garr777 Date: Tue, 8 Nov 2022 13:16:57 +0300 Subject: [PATCH 28/35] Add OnDelay command; --- Distributive/Mill/MACH3_DN/Postprocessor.cs | 40 +++++---------------- 1 file changed, 9 insertions(+), 31 deletions(-) diff --git a/Distributive/Mill/MACH3_DN/Postprocessor.cs b/Distributive/Mill/MACH3_DN/Postprocessor.cs index 900a92a..c36daeb 100644 --- a/Distributive/Mill/MACH3_DN/Postprocessor.cs +++ b/Distributive/Mill/MACH3_DN/Postprocessor.cs @@ -134,37 +134,6 @@ public void Initialise() // nc.Z.v = MaxReal; //! initialise Z } - - public void Tapper(double BottomLev,double ReturnLev,double WorkFeed,double ReturnFeed,double BottomDwell, double TopDwell) - { - nc.Block.Out(); - if (StructNodeName!="") - { - nc.BlockN.v = nc.BlockN.v + nc.BlockN.AutoIncrementStep; - nc.Output("N" + nc.BlockN.v + " (" + StructNodeName + ")"); - } - nc.MSP.v0 = 99999.999; // ! Spindle forward - nc.S.v0 = 99999.999; - nc.Block.Out(); - nc.GInterp.v = 1; nc.GInterp.v0 = 99999.999; - nc.Z.v = BottomLev; nc.Z.v0 = 99999.999; // ! Feed to depth - nc.Feed_.v = WorkFeed; nc.Feed_.v0 = 99999.999; // ! Reduce feedrate - nc.Block.Out(); - nc.MSP.v = 7-nc.MSP.v; // ! Spindle reverse - nc.Block.Out(); - nc.GDwell.v = 4; nc.GDwell.v0 = 99999.999; //! Dwell for spindle - nc.Pause.v = BottomDwell; nc.Pause.v0 = 99999.999; - nc.Block.Out(); - nc.GInterp.v = 1; nc.GInterp.v0 = 99999.999; - nc.Z.v = ReturnLev; nc.Z.v0= 99999.999; // ! Feed back to safe level - nc.Feed_.v = ReturnFeed; nc.Feed_.v0 = 99999.999; // ! Increase feedrate - nc.Block.Out(); - nc.MSP.v = 7-nc.MSP.v; // ! Spindle forward - nc.Block.Out(); - nc.GDwell.v = 4; nc.GDwell.v0 = 99999.999; // ! Dwell for spindle - nc.Pause.v = TopDwell; nc.Pause.v0 = 99999.999; - nc.Block.Out(); - } public override void OnStartProject(ICLDProject prj) { @@ -964,6 +933,15 @@ public override void OnCycle(ICLDCycleCommand cmd, CLDArray cld) } } } + + public override void OnDelay() + { + nc.Block.Out(); // ! load old values to block + nc.GDwell.v = 4; nc.GDwell.v0 = MaxReal; //! value G4 + nc.Pause.v = CLD[1]; // ! dwell value + nc.Pause.V0 = MaxReal; // ! dwell output be always + nc.Block.Out(); //! output NC block + } public override void OnFinishProject(ICLDProject prj) { nc.Write("%"); From 0883439a4dcb9cd93efe5426f4783045a19a91b5 Mon Sep 17 00:00:00 2001 From: Garr777 Date: Tue, 8 Nov 2022 13:36:58 +0300 Subject: [PATCH 29/35] Add OnExtCycle command --- Distributive/Mill/MACH3_DN/Postprocessor.cs | 164 ++++++++++++++++++++ 1 file changed, 164 insertions(+) diff --git a/Distributive/Mill/MACH3_DN/Postprocessor.cs b/Distributive/Mill/MACH3_DN/Postprocessor.cs index c36daeb..9eed9f6 100644 --- a/Distributive/Mill/MACH3_DN/Postprocessor.cs +++ b/Distributive/Mill/MACH3_DN/Postprocessor.cs @@ -942,6 +942,170 @@ public override void OnDelay() nc.Pause.V0 = MaxReal; // ! dwell output be always nc.Block.Out(); //! output NC block } + + public override void OnExtCycle() + { + if (cld[1]==72) //! cycle Off; + { + CycleOn = 0; + nc.Cycle = 80; + nc.Block.Out(); + INTERP_ = 0; + nc.GInterp.v = 1; + nc.GInterp.v0 = GInterp; + } + else + if (cld[1]=52) // ! do cycle + { + if ((CLD.SubType>=473) && (CLD.SubType<=489) && (CLD.SubType!=484)) //! Mill cycles + { + //! All drill cycles have same ZCycle ZClear Feed_ + if (cld[10] > 0) //! creating FEED_ value + { + if (cld[9] == 0) + Fr = cld[10]*S; + else Fr = cld[10]; + nc.Feed_.v= Fr; + nc.ZCycle.v = Z - cld[8]; + nc.ZClear.v = Z - cld[6]; + nc.Cyc_retract = 98; + CycleOn = 1; + } + } + switch(CLD.SubType) + { + case 481: + { + if (Cycle!=81) + { + nc.Feed_.v0=MaxReal; + nc.ZCycle.v0 = MaxReal; + nc.ZClear.v0 = MaxReal; + } + nc.Cycle.v = 81; + nc.Block.Out(); + break; + } + case 482: + { + if (Cycle!=82) + { + nc.Feed_.v0=MaxReal; + nc.ZCycle.v0 = MaxReal; + nc.ZClear.v0 = MaxReal; + nc.Pause.v0 = MaxReal; + } + nc.Pause.v = cld[15]; + Cycle = 82; + nc.Block.Out(); + } + case 483: + { + if (Cycle!=83) + { + nc.Feed_.v0=MaxReal; + nc.ZCycle.v0 = MaxReal; + nc.ZClear.v0 = MaxReal; + //!Pause@ = MaxReal; + nc.QStep.v0 = MaxReal; + } + nc.QStep.v = cld[17]; + //!Pause = cld[15]; + nc.Cycle = 83; + nc.Block.Out(); + break; + } + case 484: + { + if (cld[13]==0) + Fr = nc.S.v*cld[14]; + else Fr = cld[14]; + call Tapper(nc.Z.v-cld[8], nc.Z.v-cld[6], nc.S.v*cld[17], Fr, cld[15], cld[16]) + } + 485: begin + if Cycle<>85 then begin + Feed_@=Maxreal; + ZCycle@ = MaxReal; + ZClear@ = MaxReal; + end; + Cycle = 85; + OutBlock + break; + 486: begin + if Cycle<>86 then begin + Feed_@=Maxreal; + ZCycle@ = MaxReal; + ZClear@ = MaxReal; + end; + Pause = cld[15]; + if Pause=0 then + Pause@ = 0 + Cycle = 86; + OutBlock + end + 487: begin + if Cycle<>87 then begin + Feed_@=Maxreal; + ZCycle@ = MaxReal; + ZClear@ = MaxReal; + end; + Pause = cld[15]; + if Pause=0 then + Pause@ = 0 + Cycle = 87; + if cld[17]>0 then begin + !call Swap(ZCycle, ZClear) + XC_=cld[19]; XC_@=0 + YC_=cld[20]; YC_@=0 + ZC_=cld[21]; ZC_@=0 + end + OutBlock + end + 488: begin + if Cycle<>88 then begin + Feed_@=Maxreal; + ZCycle@ = MaxReal; + ZClear@ = MaxReal; + Pause@ = MaxReal; + end; + Pause = cld[15]; + Cycle = 88; + OutBlock + end + 489: begin + if Cycle<>89 then begin + Feed_@=Maxreal; + ZCycle@ = MaxReal; + ZClear@ = MaxReal; + Pause@ = MaxReal; + end; + Pause = cld[15]; + Cycle = 89; + OutBlock + end + 473: begin + if Cycle<>73 then begin + Feed_@=Maxreal; + ZCycle@ = MaxReal; + ZClear@ = MaxReal; + QStep@ = MaxReal; + end; + QStep =cld[17]; + Cycle = 73; + OutBlock + end; + else begin + Output "(MSG, Cycle doesn't supported)" + end + end ! case + } + + + + + } + + } public override void OnFinishProject(ICLDProject prj) { nc.Write("%"); From 1a3cc14fddb1a17db93cfc1d47dd081262003aee Mon Sep 17 00:00:00 2001 From: Garr777 Date: Tue, 8 Nov 2022 14:00:50 +0300 Subject: [PATCH 30/35] Add ExtCycle command --- Distributive/Mill/MACH3_DN/Postprocessor.cs | 217 +++++++++++--------- 1 file changed, 120 insertions(+), 97 deletions(-) diff --git a/Distributive/Mill/MACH3_DN/Postprocessor.cs b/Distributive/Mill/MACH3_DN/Postprocessor.cs index 9eed9f6..9e5f64b 100644 --- a/Distributive/Mill/MACH3_DN/Postprocessor.cs +++ b/Distributive/Mill/MACH3_DN/Postprocessor.cs @@ -934,49 +934,49 @@ public override void OnCycle(ICLDCycleCommand cmd, CLDArray cld) } } - public override void OnDelay() + public override void OnDelay(ICLDDelayCommand cmd, CLDArray cld) { nc.Block.Out(); // ! load old values to block nc.GDwell.v = 4; nc.GDwell.v0 = MaxReal; //! value G4 - nc.Pause.v = CLD[1]; // ! dwell value - nc.Pause.V0 = MaxReal; // ! dwell output be always + nc.Pause.v = cld[1]; // ! dwell value + nc.Pause.v0 = MaxReal; // ! dwell output be always nc.Block.Out(); //! output NC block } - public override void OnExtCycle() + public override void OnExtCycle(ICLDExtCycleCommand cmd, CLDArray cld) { if (cld[1]==72) //! cycle Off; { CycleOn = 0; - nc.Cycle = 80; + nc.Cycle.v = 80; nc.Block.Out(); INTERP_ = 0; nc.GInterp.v = 1; - nc.GInterp.v0 = GInterp; + nc.GInterp.v0 = nc.GInterp.v; } else - if (cld[1]=52) // ! do cycle + if (cld[1]==52) // ! do cycle { - if ((CLD.SubType>=473) && (CLD.SubType<=489) && (CLD.SubType!=484)) //! Mill cycles + if ((cld[2]>=473) && (cld[2]<=489) && (cld[2]!=484)) //! Mill cycles { //! All drill cycles have same ZCycle ZClear Feed_ if (cld[10] > 0) //! creating FEED_ value { if (cld[9] == 0) - Fr = cld[10]*S; + Fr = cld[10]*nc.S.v; else Fr = cld[10]; nc.Feed_.v= Fr; - nc.ZCycle.v = Z - cld[8]; - nc.ZClear.v = Z - cld[6]; - nc.Cyc_retract = 98; + nc.ZCycle.v = nc.Z.v - cld[8]; + nc.ZClear.v = nc.Z.v - cld[6]; + nc.Cyc_retract.v = 98; CycleOn = 1; } } - switch(CLD.SubType) + switch(cld[2]) { case 481: { - if (Cycle!=81) + if (nc.Cycle.v!=81) { nc.Feed_.v0=MaxReal; nc.ZCycle.v0 = MaxReal; @@ -988,7 +988,7 @@ public override void OnExtCycle() } case 482: { - if (Cycle!=82) + if (nc.Cycle.v!=82) { nc.Feed_.v0=MaxReal; nc.ZCycle.v0 = MaxReal; @@ -996,12 +996,13 @@ public override void OnExtCycle() nc.Pause.v0 = MaxReal; } nc.Pause.v = cld[15]; - Cycle = 82; + nc.Cycle.v = 82; nc.Block.Out(); + break; } case 483: { - if (Cycle!=83) + if (nc.Cycle.v!=83) { nc.Feed_.v0=MaxReal; nc.ZCycle.v0 = MaxReal; @@ -1011,7 +1012,7 @@ public override void OnExtCycle() } nc.QStep.v = cld[17]; //!Pause = cld[15]; - nc.Cycle = 83; + nc.Cycle.v = 83; nc.Block.Out(); break; } @@ -1020,92 +1021,114 @@ public override void OnExtCycle() if (cld[13]==0) Fr = nc.S.v*cld[14]; else Fr = cld[14]; - call Tapper(nc.Z.v-cld[8], nc.Z.v-cld[6], nc.S.v*cld[17], Fr, cld[15], cld[16]) + Tapper(nc.Z.v-cld[8], nc.Z.v-cld[6], nc.S.v*cld[17], Fr, cld[15], cld[16]); + break; + } + case 485: + { + if(nc.Cycle.v!=85) + { + nc.Feed_.v0=MaxReal; + nc.ZCycle.v0 = MaxReal; + nc.ZClear.v0 = MaxReal; + } + nc.Cycle.v = 85; + nc.Block.Out(); + break; } - 485: begin - if Cycle<>85 then begin - Feed_@=Maxreal; - ZCycle@ = MaxReal; - ZClear@ = MaxReal; - end; - Cycle = 85; - OutBlock + case 486: + { + if (nc.Cycle.v!=86) + { + nc.Feed_.v0=MaxReal; + nc.ZCycle.v0 = MaxReal; + nc.ZClear.v0 = MaxReal; + } + nc.Pause.v = cld[15]; + if (nc.Pause.v==0) + nc.Pause.v0 = 0; + nc.Cycle.v = 86; + nc.Block.Out(); break; - 486: begin - if Cycle<>86 then begin - Feed_@=Maxreal; - ZCycle@ = MaxReal; - ZClear@ = MaxReal; - end; - Pause = cld[15]; - if Pause=0 then - Pause@ = 0 - Cycle = 86; - OutBlock - end - 487: begin - if Cycle<>87 then begin - Feed_@=Maxreal; - ZCycle@ = MaxReal; - ZClear@ = MaxReal; - end; - Pause = cld[15]; - if Pause=0 then - Pause@ = 0 - Cycle = 87; - if cld[17]>0 then begin - !call Swap(ZCycle, ZClear) - XC_=cld[19]; XC_@=0 - YC_=cld[20]; YC_@=0 - ZC_=cld[21]; ZC_@=0 - end - OutBlock - end - 488: begin - if Cycle<>88 then begin - Feed_@=Maxreal; - ZCycle@ = MaxReal; - ZClear@ = MaxReal; - Pause@ = MaxReal; - end; - Pause = cld[15]; - Cycle = 88; - OutBlock - end - 489: begin - if Cycle<>89 then begin - Feed_@=Maxreal; - ZCycle@ = MaxReal; - ZClear@ = MaxReal; - Pause@ = MaxReal; - end; - Pause = cld[15]; - Cycle = 89; - OutBlock - end - 473: begin - if Cycle<>73 then begin - Feed_@=Maxreal; - ZCycle@ = MaxReal; - ZClear@ = MaxReal; - QStep@ = MaxReal; - end; - QStep =cld[17]; - Cycle = 73; - OutBlock - end; - else begin - Output "(MSG, Cycle doesn't supported)" - end - end ! case + } + case 487: + { + if (nc.Cycle.v!=87) + { + nc.Feed_.v0=MaxReal; + nc.ZCycle.v0 = MaxReal; + nc.ZClear.v0 = MaxReal; + } + nc.Pause.v = cld[15]; + if (nc.Pause.v==0) + { + nc.Pause.v0 = 0; + nc.Cycle.v = 87; + if (cld[17]>0) //!call Swap(ZCycle, ZClear) + { + nc.XC_.v=cld[19]; nc.XC_.v0=0; + nc.YC_.v=cld[20]; nc.YC_.v0=0; + nc.ZC_.v=cld[21]; nc.ZC_.v0=0; + } + } + nc.Block.Out(); + break; + } + case 488: + { + if (nc.Cycle.v!=88) + { + nc.Feed_.v0=MaxReal; + nc.ZCycle.v0 = MaxReal; + nc.ZClear.v0 = MaxReal; + nc.Pause.v0 = MaxReal; + } + nc.Pause.v = cld[15]; + nc.Cycle.v = 88; + nc.Block.Out(); + break; + } + case 489: + { + if (nc.Cycle!=89) + { + nc.Feed_.v0=MaxReal; + nc.ZCycle.v0 = MaxReal; + nc.ZClear.v0 = MaxReal; + nc.Pause.v0 = MaxReal; + } + nc.Pause.v = cld[15]; + nc.Cycle.v = 89; + nc.Block.Out(); + break; + } + case 473: + { + if (nc.Cycle.v!=73) + { + nc.Feed_.v0=MaxReal; + nc.ZCycle.v0 = MaxReal; + nc.ZClear.v0 = MaxReal; + nc.QStep.v0 = MaxReal; + } + nc.QStep.v =cld[17]; + nc.Cycle.v = 73; + nc.Block.Out(); + break; + } + default: + { + nc.Output("(MSG, Cycle doesn't supported)"); + break; + } + } - + } - } - } + public override void OnFinishProject(ICLDProject prj) { nc.Write("%"); From 8173158cef66bb92022869992037663ab25eb3fe Mon Sep 17 00:00:00 2001 From: Garr777 Date: Tue, 8 Nov 2022 14:03:42 +0300 Subject: [PATCH 31/35] Add OnFinish command; --- Distributive/Mill/MACH3_DN/Postprocessor.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Distributive/Mill/MACH3_DN/Postprocessor.cs b/Distributive/Mill/MACH3_DN/Postprocessor.cs index 9e5f64b..a057066 100644 --- a/Distributive/Mill/MACH3_DN/Postprocessor.cs +++ b/Distributive/Mill/MACH3_DN/Postprocessor.cs @@ -1131,7 +1131,12 @@ public override void OnExtCycle(ICLDExtCycleCommand cmd, CLDArray cld) public override void OnFinishProject(ICLDProject prj) { - nc.Write("%"); + nc.GoTCP.v = 998; //!GoTCP@ = 0 + nc.Block.Out(); // ! output go to Tool Ch Pos + nc.M.v = 30; // ! M30 Rewind programm + nc.Block.Out(); //! output + nc.Output("%"); + nc.WriteLine(); } public override void OnStartTechOperation(ICLDTechOperation op, ICLDPPFunCommand cmd, CLDArray cld) From 59dc058272faf4c71b0ba0ab301e95e6cdc4d795 Mon Sep 17 00:00:00 2001 From: Garr777 Date: Tue, 8 Nov 2022 14:07:20 +0300 Subject: [PATCH 32/35] Add OnGoHome command; --- Distributive/Mill/MACH3_DN/Postprocessor.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Distributive/Mill/MACH3_DN/Postprocessor.cs b/Distributive/Mill/MACH3_DN/Postprocessor.cs index a057066..16b03ba 100644 --- a/Distributive/Mill/MACH3_DN/Postprocessor.cs +++ b/Distributive/Mill/MACH3_DN/Postprocessor.cs @@ -1139,6 +1139,22 @@ public override void OnFinishProject(ICLDProject prj) nc.WriteLine(); } + public override void OnGoHome(ICLDGoHomeCommand cmd, CLDArray cld) + { + if (CycleOn==1) + { + CycleOn=0; + nc.Cycle.v=80; + nc.Block.Out(); //! Output in block + } + if (nc.GoTCP.v0!=998) + { + nc.Block.Out(); + nc.GoTCP.v = 998; //! M998 go to tool change point + nc.Block.Out(); + } + } + public override void OnStartTechOperation(ICLDTechOperation op, ICLDPPFunCommand cmd, CLDArray cld) { From 6d609da77fd56e9904a4a49b03ce0f76d26dfe2e Mon Sep 17 00:00:00 2001 From: Garr777 Date: Tue, 8 Nov 2022 14:10:22 +0300 Subject: [PATCH 33/35] Add Insert and Interpolation commands --- Distributive/Mill/MACH3_DN/Postprocessor.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Distributive/Mill/MACH3_DN/Postprocessor.cs b/Distributive/Mill/MACH3_DN/Postprocessor.cs index 16b03ba..fc7c233 100644 --- a/Distributive/Mill/MACH3_DN/Postprocessor.cs +++ b/Distributive/Mill/MACH3_DN/Postprocessor.cs @@ -1154,6 +1154,14 @@ public override void OnGoHome(ICLDGoHomeCommand cmd, CLDArray cld) nc.Block.Out(); } } + public override void OnInsert(ICLDInsertCommand cmd, CLDArray cld) + { + nc.Output(cmd.CLDataS); + } + public override void OnInterpolation(ICLDInterpolationCommand cmd, CLDArray cld) + { + nc.Output("(MSG, Interpolation doesn't supported)"); + } public override void OnStartTechOperation(ICLDTechOperation op, ICLDPPFunCommand cmd, CLDArray cld) { From c3f3f6e3adfa399ed7e25b25c25ce03fe8765e93 Mon Sep 17 00:00:00 2001 From: Garr777 Date: Tue, 8 Nov 2022 14:12:53 +0300 Subject: [PATCH 34/35] Add OpStop command; --- Distributive/Mill/MACH3_DN/Postprocessor.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Distributive/Mill/MACH3_DN/Postprocessor.cs b/Distributive/Mill/MACH3_DN/Postprocessor.cs index fc7c233..9ca4765 100644 --- a/Distributive/Mill/MACH3_DN/Postprocessor.cs +++ b/Distributive/Mill/MACH3_DN/Postprocessor.cs @@ -1162,6 +1162,13 @@ public override void OnInterpolation(ICLDInterpolationCommand cmd, CLDArray cld) { nc.Output("(MSG, Interpolation doesn't supported)"); } + public override void OnOpStop(ICLDOpStopCommand cmd, CLDArray cld) + { + if (nc.M.v != nc.M.v0) + nc.Block.Out(); + nc.M.v = 1; //! M01 + nc.M.v = 0; + } public override void OnStartTechOperation(ICLDTechOperation op, ICLDPPFunCommand cmd, CLDArray cld) { From 32e1bbda63d3c4bbfed76ad8eab7ea112b71fa80 Mon Sep 17 00:00:00 2001 From: Garr777 Date: Tue, 8 Nov 2022 14:24:30 +0300 Subject: [PATCH 35/35] Add Origin command; --- Distributive/Mill/MACH3_DN/Postprocessor.cs | 42 +++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/Distributive/Mill/MACH3_DN/Postprocessor.cs b/Distributive/Mill/MACH3_DN/Postprocessor.cs index 9ca4765..33c858a 100644 --- a/Distributive/Mill/MACH3_DN/Postprocessor.cs +++ b/Distributive/Mill/MACH3_DN/Postprocessor.cs @@ -1170,6 +1170,48 @@ public override void OnOpStop(ICLDOpStopCommand cmd, CLDArray cld) nc.M.v = 0; } + public override void OnOrigin(ICLDOriginCommand cmd, CLDArray cld) + { + void SwitchOffLocalCS() + { + if (nc.GLCS.v ==52) //! Switch off G52 + { + nc.GLCS.v0 = MaxReal; + nc.X.v = 0; nc.X.v0 = MaxReal; + nc.Y.v = 0; nc.Y.v0 = MaxReal; + nc.Z.v = 0; nc.Z.v0 = MaxReal; + nc.Block.Out(); + nc.X.v = MaxReal; nc.X.v0 = nc.X.v; + nc.Y.v = MaxReal; nc.Y.v0 = nc.Y.v; + nc.Z.v = MaxReal; nc.Z.v0 = nc.Z.v; + nc.GLCS.v = 0; nc.GLCS.v0 = nc.GLCS.v; + } + } + + + if (cmd.OriginType==0) + { + SwitchOffLocalCS(); + if (cmd.Flt["CSNumber"] != 0) + { + nc.COORDSYS.v = cmd.Flt["CSNumber"]; //! Work offset number G54-G59 + if (nc.COORDSYS.v0!= nc.COORDSYS.v) + nc.Block.Out(); + } + } + else //! Switch on G52 + { + nc.GLCS.v = 52; nc.GLCS.v0 = MaxReal; + nc.X.v = cmd.Flt["MCS.OriginPoint.X"]; nc.X.v0 = MaxReal; + nc.Y.v = cmd.Flt["MCS.OriginPoint.Y"]; nc.Y.v0 = MaxReal; + nc.Z.v = cmd.Flt["MCS.OriginPoint.Z"]; nc.Z.v0 = MaxReal; + nc.Block.Out(); + nc.X.v = MaxReal; nc.X.v0 = nc.X.v; + nc.Y.v = MaxReal; nc.Y.v0 = nc.Y.v; + nc.Z.v = MaxReal; nc.Z.v0 = nc.Z.v; + } + } + public override void OnStartTechOperation(ICLDTechOperation op, ICLDPPFunCommand cmd, CLDArray cld) {