From fe01ffaba3a13e39be7c3d40cfb87f9fb521c27a Mon Sep 17 00:00:00 2001 From: Terje Io Date: Thu, 27 Jan 2022 19:38:27 +0100 Subject: [PATCH] Release 2.0.36 --- .../CNC Controls Probing/GCodeTransform.cs | 27 ++- .../CNC Controls Probing/HeightMap.cs | 1 + .../CNC Controls Probing/Program.cs | 7 +- .../Properties/AssemblyInfo.cs | 2 +- CNC Controls/CNC Controls/AppConfig.cs | 217 ++++++++++++++++- CNC Controls/CNC Controls/JobControl.xaml.cs | 4 +- .../CNC Controls/JogBaseControl.xaml.cs | 109 +++++++-- CNC Controls/CNC Controls/LibStrings.xaml | 12 + CNC Controls/CNC Controls/MacroEditor.xaml | 16 +- CNC Controls/CNC Controls/MacroEditor.xaml.cs | 24 +- .../CNC Controls/MacroExecuteControl.xaml | 1 + .../CNC Controls/MacroExecuteControl.xaml.cs | 5 +- .../CNC Controls/MacroToolbarControl.xaml.cs | 4 +- .../CNC Controls/Properties/AssemblyInfo.cs | 2 +- CNC Controls/CNC Controls/SidebarItem.cs | 6 +- CNC Converters/HpglToGCode.cs | 136 ++++++++++- CNC Converters/Properties/AssemblyInfo.cs | 6 +- CNC Core/CNC Core/GCode.cs | 3 +- CNC Core/CNC Core/GCodeJob.cs | 6 +- CNC Core/CNC Core/Grbl.cs | 58 +++-- CNC Core/CNC Core/KeypressHandler.cs | 59 ++++- CNC Core/CNC Core/LibStrings.xaml | 2 +- CNC Core/CNC Core/Properties/AssemblyInfo.cs | 2 +- CNC Core/CNC Core/TelnetStream.cs | 8 +- .../Properties/AssemblyInfo.cs | 6 +- CNC GCodeViewer/CNC GCodeViewer/Renderer.xaml | 2 +- .../CNC GCodeViewer/Renderer.xaml.cs | 88 ++++--- .../CNC GCodeViewer/Viewer.xaml.cs | 2 +- .../CNC.Controls.Probing.resources.de-DE.csv | 2 +- .../CNC.Controls.Viewer.resources.de-DE.csv | 9 +- .../csv/CNC.Controls.WPF.resources.de-DE.csv | 14 ++ Locale/de-DE/csv/ioSender.resources.de-DE.csv | 12 - Locale/de-DE/translation.txt | Bin 100800 -> 101038 bytes .../CNC.Controls.Camera.resources.en-US.csv | 3 - ...CNC.Controls.DragKnife.resources.en-US.csv | 3 - .../CNC.Controls.Probing.resources.en-US.csv | 61 +---- .../CNC.Controls.Viewer.resources.en-US.csv | 16 +- .../csv/CNC.Controls.WPF.resources.en-US.csv | 95 ++------ .../csv/CNC.Converters.resources.en-US.csv | 3 - Locale/en-US/csv/CNC.Core.resources.en-US.csv | 2 +- Locale/en-US/csv/ioSender.resources.en-US.csv | 22 -- Locale/en-US/translation.txt | Bin 96124 -> 96374 bytes .../CNC.Controls.Probing.resources.ru-RU.csv | 2 +- .../CNC.Controls.Viewer.resources.ru-RU.csv | 9 +- .../csv/CNC.Controls.WPF.resources.ru-RU.csv | 14 ++ Locale/ru-RU/csv/ioSender.resources.ru-RU.csv | 12 - Locale/ru-RU/translation.txt | Bin 98618 -> 98856 bytes Locale/ru-RU/translations.txt | Bin 93942 -> 0 bytes .../CNC.Controls.Camera.resources.zh-CN.csv | 3 - ...CNC.Controls.DragKnife.resources.zh-CN.csv | 3 - .../CNC.Controls.Probing.resources.zh-CN.csv | 61 +---- .../CNC.Controls.Viewer.resources.zh-CN.csv | 16 +- .../csv/CNC.Controls.WPF.resources.zh-CN.csv | 95 ++------ .../csv/CNC.Converters.resources.zh-CN.csv | 3 - Locale/zh-CN/csv/CNC.Core.resources.zh-CN.csv | 2 +- Locale/zh-CN/csv/ioSender.resources.zh-CN.csv | 22 -- Locale/zh-CN/translation.txt | Bin 95870 -> 96120 bytes Media/Sender2.png | Bin 120119 -> 114264 bytes Media/Sender2_XL.png | Bin 0 -> 151412 bytes Media/Sender8.png | Bin 4449 -> 6396 bytes changelog.md | 11 +- ioSender XL/ioSender XL/JobView.xaml.cs | 220 ++--------------- ioSender XL/ioSender XL/MainWindow.xaml | 10 +- ioSender XL/ioSender XL/MainWindow.xaml.cs | 6 +- .../ioSender XL/Properties/AssemblyInfo.cs | 6 +- ioSender/ioSender/JobView.xaml.cs | 228 +++--------------- ioSender/ioSender/MainWindow.xaml | 12 +- ioSender/ioSender/MainWindow.xaml.cs | 2 +- ioSender/ioSender/Properties/AssemblyInfo.cs | 6 +- readme.md | 9 +- 70 files changed, 838 insertions(+), 971 deletions(-) delete mode 100644 Locale/ru-RU/translations.txt create mode 100644 Media/Sender2_XL.png diff --git a/CNC Controls Probing/CNC Controls Probing/GCodeTransform.cs b/CNC Controls Probing/CNC Controls Probing/GCodeTransform.cs index 416a8a4..5d8bf95 100644 --- a/CNC Controls Probing/CNC Controls Probing/GCodeTransform.cs +++ b/CNC Controls Probing/CNC Controls Probing/GCodeTransform.cs @@ -7,6 +7,7 @@ using RP.Math; using System; using System.Collections.Generic; +using System.Linq; namespace CNC.Controls.Probing { @@ -56,9 +57,10 @@ public void ApplyHeightMap(ProbingViewModel model) { var motion = token as GCLinearMotion; - var m = new Line(); + var m = new Line(motion.AxisFlags); m.Start = pos; m.End = pos = ToAbsolute(pos, motion.Values, distanceMode == DistanceMode.Incremental); + m.Rapid = token.Command == Commands.G0; foreach (Motion subMotion in m.Split(segmentLength)) { @@ -188,11 +190,22 @@ public Vector3 Delta } class Line : Motion { - public bool Rapid; + public bool Rapid = false; // PositionValid[i] is true if the corresponding coordinate of the end position was defined in the file. // eg. for a file with "G0 Z15" as the first line, X and Y would still be false public bool[] PositionValid = new bool[] { false, false, false }; + public Line() + { + } + + public Line(AxisFlags axisFlags) + { + PositionValid[0] = axisFlags.HasFlag(AxisFlags.X); + PositionValid[1] = axisFlags.HasFlag(AxisFlags.Y); + PositionValid[2] = axisFlags.HasFlag(AxisFlags.Z); + } + public override double Length { get @@ -208,11 +221,11 @@ public override Vector3 Interpolate(double ratio) public override IEnumerable Split(double length) { - //if (Rapid || PositionValid.Any(isValid => !isValid)) //don't split up rapid or not fully defined motions - //{ - // yield return this; - // yield break; - //} + if (Rapid /* || PositionValid.Any(isValid => !isValid)*/) //don't split up rapid or not fully defined motions + { + yield return this; + yield break; + } int divisions = (int)Math.Ceiling(Length / length); diff --git a/CNC Controls Probing/CNC Controls Probing/HeightMap.cs b/CNC Controls Probing/CNC Controls Probing/HeightMap.cs index ead5abe..24e113a 100644 --- a/CNC Controls Probing/CNC Controls Probing/HeightMap.cs +++ b/CNC Controls Probing/CNC Controls Probing/HeightMap.cs @@ -30,6 +30,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE Changes by Terje Io for GCode Sender 2020-09-20 : Added constructor for separate X and Y grid sizes + 2022-01-23 : Added check for rapid motions and motion validity */ diff --git a/CNC Controls Probing/CNC Controls Probing/Program.cs b/CNC Controls Probing/CNC Controls Probing/Program.cs index d52b743..4d325a1 100644 --- a/CNC Controls Probing/CNC Controls Probing/Program.cs +++ b/CNC Controls Probing/CNC Controls Probing/Program.cs @@ -1,13 +1,13 @@ /* * Program.cs - part of CNC Probing library * - * v0.36 / 2021-11-29 / Io Engineering (Terje Io) + * v0.36 / 2022-01-09 / Io Engineering (Terje Io) * */ /* -Copyright (c) 2020, Io Engineering (Terje Io) +Copyright (c) 2020-2022, Io Engineering (Terje Io) All rights reserved. Redistribution and use in source and binary forms, with or without modification, @@ -466,7 +466,8 @@ public bool Execute(bool go) private void ResponseReceived(string response) { - cmd_response = response; + if(cmd_response != "cancel") + cmd_response = response; } public override string ToString() diff --git a/CNC Controls Probing/CNC Controls Probing/Properties/AssemblyInfo.cs b/CNC Controls Probing/CNC Controls Probing/Properties/AssemblyInfo.cs index a66bada..02d5125 100644 --- a/CNC Controls Probing/CNC Controls Probing/Properties/AssemblyInfo.cs +++ b/CNC Controls Probing/CNC Controls Probing/Properties/AssemblyInfo.cs @@ -11,7 +11,7 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Io Engineering")] [assembly: AssemblyProduct("ioSender")] -[assembly: AssemblyCopyright("Copyright © 2021 Io Engineering")] +[assembly: AssemblyCopyright("Copyright © 2022 Io Engineering")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] [assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] diff --git a/CNC Controls/CNC Controls/AppConfig.cs b/CNC Controls/CNC Controls/AppConfig.cs index 28cb314..5c1bb6a 100644 --- a/CNC Controls/CNC Controls/AppConfig.cs +++ b/CNC Controls/CNC Controls/AppConfig.cs @@ -1,13 +1,13 @@ /* * AppConfig.cs - part of CNC Controls library * - * v0.36 / 2021-12-25 / Io Engineering (Terje Io) + * v0.36 / 2022-01-23 / Io Engineering (Terje Io) * */ /* -Copyright (c) 2019-2021, Io Engineering (Terje Io) +Copyright (c) 2019-2022, Io Engineering (Terje Io) All rights reserved. Redistribution and use in source and binary forms, with or without modification, @@ -544,4 +544,217 @@ private string GetArg(string[] args, int i) return i < args.GetLength(0) ? args[i] : null; } } + + public class Controller + { + GrblViewModel model; + + public enum RestartResult + { + Ok = 0, + NoResponse, + Close, + Exit + } + + public Controller (GrblViewModel model) + { + this.model = model; + } + + public bool ResetPending { get; private set; } = false; + public string Message { get; private set; } + + public RestartResult Restart () + { + Message = model.Message; + model.Message = string.Format(LibStrings.FindResource("MsgWaiting"), AppConfig.Settings.Base.PortParams); + + string response = GrblInfo.Startup(model); + + if (response.StartsWith("<")) + { + if (model.GrblState.State != GrblStates.Unknown) + { + + switch (model.GrblState.State) + { + case GrblStates.Alarm: + + model.Poller.SetState(AppConfig.Settings.Base.PollInterval); + + switch (model.GrblState.Substate) + { + case 1: // Hard limits + if (!GrblInfo.IsLoaded) + { + if (model.LimitTriggered) + { + MessageBox.Show(string.Format(LibStrings.FindResource("MsgNoCommAlarm"), model.GrblState.Substate.ToString()), "ioSender"); + if (AttemptReset()) + model.ExecuteCommand(GrblConstants.CMD_UNLOCK); + else + { + MessageBox.Show(LibStrings.FindResource("MsgResetFailed"), "ioSender"); + return RestartResult.Close; + } + } + else if (AttemptReset()) + model.ExecuteCommand(GrblConstants.CMD_UNLOCK); + } + else + response = string.Empty; + break; + + case 2: // Soft limits + if (!GrblInfo.IsLoaded) + { + MessageBox.Show(string.Format(LibStrings.FindResource("MsgNoCommAlarm"), model.GrblState.Substate.ToString()), "ioSender"); + if (AttemptReset()) + model.ExecuteCommand(GrblConstants.CMD_UNLOCK); + else + { + MessageBox.Show(LibStrings.FindResource("MsgResetFailed"), "ioSender"); + return RestartResult.Close; + } + } + else + response = string.Empty; + break; + + case 10: // EStop + if (GrblInfo.IsGrblHAL && model.Signals.Value.HasFlag(Signals.EStop)) + { + MessageBox.Show(LibStrings.FindResource("MsgEStop"), "ioSender", MessageBoxButton.OK, MessageBoxImage.Warning); + while (!AttemptReset() && model.GrblState.State == GrblStates.Alarm) + { + if (MessageBox.Show(LibStrings.FindResource("MsgEStopExit"), "ioSender", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) + return RestartResult.Close; + }; + } + else + AttemptReset(); + if (!GrblInfo.IsLoaded) + model.ExecuteCommand(GrblConstants.CMD_UNLOCK); + break; + + case 11: // Homing required + if (GrblInfo.IsLoaded) + response = string.Empty; + else + Message = LibStrings.FindResource("MsgHome"); + break; + } + break; + + case GrblStates.Tool: + Comms.com.WriteByte(GrblConstants.CMD_STOP); + break; + + case GrblStates.Door: + if (!GrblInfo.IsLoaded) + { + if (MessageBox.Show(LibStrings.FindResource("MsgDoorOpen"), "ioSender", MessageBoxButton.YesNo, MessageBoxImage.Question) != MessageBoxResult.Yes) + return RestartResult.Close; + else + { + bool exit = false; + do + { + Comms.com.PurgeQueue(); + + bool? res = null; + CancellationToken cancellationToken = new CancellationToken(); + + new Thread(() => + { + res = WaitFor.SingleEvent( + cancellationToken, + s => TrapReset(s), + a => model.OnGrblReset += a, + a => model.OnGrblReset -= a, + 200, () => Comms.com.WriteByte(GrblConstants.CMD_STATUS_REPORT)); + }).Start(); + + while (res == null) + EventUtils.DoEvents(); + + if (!(exit = !model.Signals.Value.HasFlag(Signals.SafetyDoor))) + { + if (MessageBox.Show(LibStrings.FindResource("MsgDoorExit"), "ioSender", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) + { + exit = true; + return RestartResult.Close; + } + } + } while (!exit); + } + } + else + { + MessageBox.Show(LibStrings.FindResource("MsgDoorPersist"), "ioSender", MessageBoxButton.YesNo, MessageBoxImage.Exclamation); + response = string.Empty; + } + break; + + case GrblStates.Hold: + case GrblStates.Sleep: + if (MessageBox.Show(string.Format(LibStrings.FindResource("MsgNoComm"), model.GrblState.State.ToString()), + "ioSender", MessageBoxButton.YesNo, MessageBoxImage.Question) != MessageBoxResult.Yes) + return RestartResult.Close; + else if (!AttemptReset()) + { + MessageBox.Show(LibStrings.FindResource("MsgResetExit"), "ioSender"); + return RestartResult.Close; + } + break; + + case GrblStates.Idle: + if (response.Contains("|SD:Pending")) + AttemptReset(); + break; + } + } + } + else + { + MessageBox.Show(response == string.Empty + ? "No respone received from controller, exiting." + : string.Format("Unexpected response received from controller: \"{0}\", exiting.", response), + "ioSender", MessageBoxButton.OK, MessageBoxImage.Stop); + return RestartResult.Exit; + } + + return response == string.Empty ? RestartResult.NoResponse : RestartResult.Ok; + } + + private void TrapReset(string rws) + { + ResetPending = false; + } + + private bool AttemptReset() + { + ResetPending = true; + Comms.com.PurgeQueue(); + + bool? res = null; + CancellationToken cancellationToken = new CancellationToken(); + + new Thread(() => + { + res = WaitFor.SingleEvent( + cancellationToken, + s => TrapReset(s), + a => model.OnGrblReset += a, + a => model.OnGrblReset -= a, + AppConfig.Settings.Base.ResetDelay, () => Comms.com.WriteByte(GrblConstants.CMD_RESET)); + }).Start(); + + while (res == null) + EventUtils.DoEvents(); + + return !ResetPending; + } + } } diff --git a/CNC Controls/CNC Controls/JobControl.xaml.cs b/CNC Controls/CNC Controls/JobControl.xaml.cs index f131ed7..1f2602a 100644 --- a/CNC Controls/CNC Controls/JobControl.xaml.cs +++ b/CNC Controls/CNC Controls/JobControl.xaml.cs @@ -1,7 +1,7 @@ /* * JobControl.xaml.cs - part of CNC Controls library for Grbl * - * v0.36 / 2021-12-25 / Io Engineering (Terje Io) + * v0.36 / 2021-12-27 / Io Engineering (Terje Io) * */ @@ -383,7 +383,7 @@ private bool FnKeyHandler(Key key) { int id = int.Parse(key.ToString().Substring(1)); var macro = AppConfig.Settings.Macros.FirstOrDefault(o => o.Id == id); - if (macro != null && MessageBox.Show(string.Format("Run {0} macro?", macro.Name), "Run macro", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) + if (macro != null && (!macro.ConfirmOnExecute || MessageBox.Show(string.Format("Run {0} macro?", macro.Name), "Run macro", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)) { model.ExecuteCommand(macro.Code); return true; diff --git a/CNC Controls/CNC Controls/JogBaseControl.xaml.cs b/CNC Controls/CNC Controls/JogBaseControl.xaml.cs index 202401e..200799b 100644 --- a/CNC Controls/CNC Controls/JogBaseControl.xaml.cs +++ b/CNC Controls/CNC Controls/JogBaseControl.xaml.cs @@ -1,13 +1,13 @@ /* * JogBaseControl.xaml.cs - part of CNC Controls library * - * v0.36 / 2021-12-26 / Io Engineering (Terje Io) + * v0.36 / 2022-01-10 / Io Engineering (Terje Io) * */ /* -Copyright (c) 2020-2021, Io Engineering (Terje Io) +Copyright (c) 2020-2022, Io Engineering (Terje Io) All rights reserved. Redistribution and use in source and binary forms, with or without modification, @@ -43,6 +43,7 @@ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR using System.Windows.Controls; using System.Windows.Input; using CNC.Core; +using CNC.GCode; namespace CNC.Controls { @@ -52,12 +53,14 @@ namespace CNC.Controls public partial class JogBaseControl : UserControl { private string mode = "G21"; // Metric - private bool silent = false; - private int distance = 2, feedrate = 2; + private bool softLimits = false; + private int distance = 2, feedrate = 2, jogAxis = -1; + private double limitSwitchesClearance = .5d, position = 0d; private KeypressHandler keyboard; private static bool keyboardMappingsOk = false; - private const Key xplus = Key.H, xminus = Key.J, yplus = Key.K, yminus = Key.L, zplus = Key.I, zminus = Key.M; + + private const Key xplus = Key.J, xminus = Key.H, yplus = Key.K, yminus = Key.L, zplus = Key.I, zminus = Key.M, aplus = Key.U, aminus = Key.N; public JogBaseControl() { @@ -77,27 +80,38 @@ private void JogData_PropertyChanged(object sender, PropertyChangedEventArgs e) { case nameof(JogViewModel.Distance): if (AppConfig.Settings.Jog.Mode == JogConfig.JogMode.UI || (AppConfig.Settings.Jog.LinkStepJogToUI && JogData.StepSize != JogViewModel.JogStep.Step3)) - { - silent = true; (DataContext as GrblViewModel).JogStep = JogData.Distance; - silent = false; - } break; } } + private void Model_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) + { + if (e.PropertyName == nameof(GrblViewModel.MachinePosition) || e.PropertyName == nameof(GrblViewModel.GrblState)) + { + if ((sender as GrblViewModel).GrblState.State != GrblStates.Jog) + jogAxis = -1; + } + } + private void JogControl_Loaded(object sender, RoutedEventArgs e) { if (DataContext is GrblViewModel) { mode = GrblSettings.GetInteger(GrblSetting.ReportInches) == 0 ? "G21" : "G20"; - JogData.SetMetric(mode == "G21"); + softLimits = !(GrblInfo.IsGrblHAL && GrblSettings.GetInteger(grblHALSetting.SoftLimitJogging) == 1) && GrblSettings.GetInteger(GrblSetting.SoftLimitsEnable) == 1; + limitSwitchesClearance = GrblSettings.GetDouble(GrblSetting.HomingPulloff); - if (!GrblInfo.HasFirmwareJog || AppConfig.Settings.Jog.LinkStepJogToUI) - JogData.PropertyChanged += JogData_PropertyChanged; + JogData.SetMetric(mode == "G21"); if (!keyboardMappingsOk) { + if (!GrblInfo.HasFirmwareJog || AppConfig.Settings.Jog.LinkStepJogToUI) + JogData.PropertyChanged += JogData_PropertyChanged; + + if (softLimits) + (DataContext as GrblViewModel).PropertyChanged += Model_PropertyChanged; + keyboard = (DataContext as GrblViewModel).Keyboard; keyboardMappingsOk = true; @@ -118,6 +132,10 @@ private void JogControl_Loaded(object sender, RoutedEventArgs e) keyboard.AddHandler(yminus, ModifierKeys.Control | ModifierKeys.Shift, normalKeyJog, false); keyboard.AddHandler(zplus, ModifierKeys.Control | ModifierKeys.Shift, normalKeyJog, false); keyboard.AddHandler(zminus, ModifierKeys.Control | ModifierKeys.Shift, normalKeyJog, false); + if(GrblInfo.AxisFlags.HasFlag(AxisFlags.A)) { + keyboard.AddHandler(aplus, ModifierKeys.Control | ModifierKeys.Shift, normalKeyJog, false); + keyboard.AddHandler(aminus, ModifierKeys.Control | ModifierKeys.Shift, normalKeyJog, false); + } if (AppConfig.Settings.Jog.Mode != JogConfig.JogMode.Keypad) { @@ -252,6 +270,14 @@ private bool normalKeyJog(Key key) case yminus: JogCommand(GrblInfo.LatheModeEnabled ? "X+" : "Y-"); break; + + case aplus: + JogCommand("A+"); + break; + + case aminus: + JogCommand("A-"); + break; } return true; @@ -293,8 +319,63 @@ private bool cursorKeyJog(Key key) private void JogCommand(string cmd) { - cmd = cmd == "stop" ? ((char)GrblConstants.CMD_JOG_CANCEL).ToString() : string.Format("$J=G91{0}{1}{2}F{3}", mode, cmd.Replace("+", ""), JogData.Distance.ToInvariantString(), Math.Ceiling(JogData.FeedRate).ToInvariantString()); - (DataContext as GrblViewModel).ExecuteCommand(cmd); + GrblViewModel model = DataContext as GrblViewModel; + + if (cmd == "stop") + cmd = ((char)GrblConstants.CMD_JOG_CANCEL).ToString(); + + else { + + var distance = cmd[1] == '-' ? -JogData.Distance : JogData.Distance; + + if (softLimits) + { + int axis = GrblInfo.AxisLetterToIndex(cmd[0]); + + if (jogAxis != -1 && axis != jogAxis) + return; + + if (axis != jogAxis) + position = distance + model.MachinePosition.Values[axis]; + else + position += distance; + + if (GrblInfo.ForceSetOrigin) + { + if (!GrblInfo.HomingDirection.HasFlag(GrblInfo.AxisIndexToFlag(axis))) + { + if (position > 0d) + position = 0d; + else if (position < (-GrblInfo.MaxTravel.Values[axis] + limitSwitchesClearance)) + position = (-GrblInfo.MaxTravel.Values[axis] + limitSwitchesClearance); + } + else + { + if (position < 0d) + position = 0d; + else if (position > (GrblInfo.MaxTravel.Values[axis] - limitSwitchesClearance)) + position = GrblInfo.MaxTravel.Values[axis] - limitSwitchesClearance; + } + } + else + { + if (position > -limitSwitchesClearance) + position = -limitSwitchesClearance; + else if (position < -(GrblInfo.MaxTravel.Values[axis] - limitSwitchesClearance)) + position = -(GrblInfo.MaxTravel.Values[axis] - limitSwitchesClearance); + } + + if (position == 0d) + return; + + jogAxis = axis; + + cmd = string.Format("$J=G53{0}{1}{2}F{3}", mode, cmd.Substring(0, 1), position.ToInvariantString(), Math.Ceiling(JogData.FeedRate).ToInvariantString()); + } else + cmd = string.Format("$J=G91{0}{1}{2}F{3}", mode, cmd.Substring(0, 1), distance.ToInvariantString(), Math.Ceiling(JogData.FeedRate).ToInvariantString()); + } + + model.ExecuteCommand(cmd); } private void Button_Click(object sender, RoutedEventArgs e) diff --git a/CNC Controls/CNC Controls/LibStrings.xaml b/CNC Controls/CNC Controls/LibStrings.xaml index f11fb08..23c66ee 100644 --- a/CNC Controls/CNC Controls/LibStrings.xaml +++ b/CNC Controls/CNC Controls/LibStrings.xaml @@ -13,6 +13,18 @@ Invalid input: minimum allowed value is {0}. Invalid input: maximum allowed value is {0}. Invalid input: not an IP4 address.. + Waiting for controller ({0})... + Controller is not able to communicate due to alarm {0}, attempting a soft reset. + Controller soft reset failed, exiting. + E-Stop active! - clear before continuing... + E-Stop still active, exit? + Homing cycle required, <Home> to continue + Door is open, close door and continue? + Door is still open, exit? + Door state cannot be cleared with <Reset> + Controller is in {0} state and cannot respond, try a soft reset? + Controller soft reset failed, exiting. + Controller is not responding! UNKNOWN IDLE RUN diff --git a/CNC Controls/CNC Controls/MacroEditor.xaml b/CNC Controls/CNC Controls/MacroEditor.xaml index 02476f9..aa6fecb 100644 --- a/CNC Controls/CNC Controls/MacroEditor.xaml +++ b/CNC Controls/CNC Controls/MacroEditor.xaml @@ -3,17 +3,25 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:system="clr-namespace:System;assembly=mscorlib" xmlns:local="clr-namespace:CNC.Controls" mc:Ignorable="d" x:Uid="dlg_macroEditor" - Title="Macro Editor" Height="260" Width="310" Icon="App.ico" ResizeMode="NoResize" ShowInTaskbar="False" + Title="Macro Editor" Height="275" Width="310" Icon="App.ico" ResizeMode="NoResize" ShowInTaskbar="False" WindowStartupLocation="CenterOwner" Loaded="Window_Loaded" Closing="Window_Closing"> + + + + + +