Skip to content

Commit

Permalink
add work envelope variables
Browse files Browse the repository at this point in the history
  • Loading branch information
martin2250 committed May 1, 2020
1 parent 2e6363e commit bc4ae53
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
2 changes: 2 additions & 0 deletions OpenCNCPilot/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ public MainWindow()

settingsWindow.SendLine += machine.SendLine;

machine.Calculator.GetGCode += () => ToolPath;

CheckBoxUseExpressions_Changed(null, null);
ButtonRestoreViewport_Click(null, null);

Expand Down
21 changes: 21 additions & 0 deletions OpenCNCPilot/Util/Calculator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace OpenCNCPilot.Util
class Calculator
{
private Machine machine;
public Func<GCode.GCodeFile> GetGCode;
private bool Success = true;

public Calculator(Machine machine)
Expand All @@ -30,6 +31,26 @@ private string ExpressionEvaluator(string input)
variables.Add("PM" + Axes[i], machine.LastProbePosMachine[i]);
variables.Add("PW" + Axes[i], machine.LastProbePosWork[i]);
}
if (GetGCode != null)
{
try
{
var file = GetGCode();
var min = file.MinFeed;
var max = file.MaxFeed;
if (!file.ContainsMotion)
{
min = new Vector3(0, 0, 0);
max = new Vector3(0, 0, 0);
}
for (int i = 0; i < 3; i++)
{
variables.Add("MAX" + Axes[i], max[i]);
variables.Add("MIN" + Axes[i], min[i]);
}
}
catch { }
}

variables.Add("TLO", machine.CurrentTLO);

Expand Down

0 comments on commit bc4ae53

Please sign in to comment.