Skip to content

Commit

Permalink
Release 2.0.44
Browse files Browse the repository at this point in the history
  • Loading branch information
terjeio committed Dec 31, 2023
1 parent b6b66e4 commit 552f20d
Show file tree
Hide file tree
Showing 59 changed files with 661 additions and 188 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<system:String x:Uid="str_heightMapInstructions" x:Key="Instructions">A rapid motion to X0Y0 will be performed before probing the height map starts.\nEnsure the initial Z-position is clear of any obstacles that might be encountered during probing.</system:String>
<system:String x:Uid="str_heightMapFailed" x:Key="ProbingFailed">Probing failed</system:String>
<system:String x:Uid="str_heightMapCompleted" x:Key="ProbingCompleted">Probing completed: Z min: {0}, Z max: {1}.</system:String>
<system:String x:Uid="str_heightMapPointOf" x:Key="ProbingPointOf">Probing point {0} of {1}...</system:String>
<Controls:LogicalNotConverter x:Key="IsNotRunningConverter" />
</UserControl.Resources>
<Grid>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* HeightMapControl.xaml.cs - part of CNC Probing library
*
* v0.42 / 2023-03-22 / Io Engineering (Terje Io)
* v0.44 / 2023-10-01 / Io Engineering (Terje Io)
*
*/

Expand Down Expand Up @@ -110,10 +110,15 @@ public void Start(bool preview = false)
probing.HeightMap.GridSizeX = probing.HeightMap.Map.GridX;
probing.HeightMap.GridSizeY = probing.HeightMap.Map.GridY;

int point = 0, points = probing.HeightMap.Map.SizeX * probing.HeightMap.Map.SizeX;
string pointOf = ((string)FindResource("ProbingPointOf"));

for (x = 0; x < probing.HeightMap.Map.SizeX; x++)
{
for (y = 0; y < probing.HeightMap.Map.SizeY; y++)
{
probing.Program.AddMessage(string.Format(pointOf, ++point, points));

if (probing.HeightMap.AddPause && (x > 0 || y > 0))
probing.Program.AddPause();
probing.Program.AddProbingAction(AxisFlags.Z, true);
Expand Down Expand Up @@ -184,7 +189,7 @@ private void OnCompleted()
// double z = probing.HeightMap.Map.InterpolateZ(0d, 0d);

if (probing.HeightMap.SetToolOffset &&
(ok = (probing.Positions[0].X == origin.X && probing.Positions[0].Y == origin.Y) || probing.Program.ProbeZ(0d, 0d)))
(ok = /* (probing.Positions[0].X == origin.X && probing.Positions[0].Y == origin.Y) || */ probing.Program.ProbeZ(0d, 0d)))
{
probing.HeightMap.Map.ZOffset = Z0 - probing.Positions[0].Z; // vs Z above, add check for allowed delta?

Expand Down
1 change: 1 addition & 0 deletions CNC Controls Probing/CNC Controls Probing/LibStrings.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@
<system:String x:Uid="str_probingIllegalPosition" x:Key="IllegalPosition">Illegal probe position, try again.</system:String>
<system:String x:Uid="str_probingNoVerifyContinue" x:Key="NoVerifyContinue">Probe connection was not verified, continue anyway?</system:String>
<system:String x:Uid="str_probingVerifyStart" x:Key="VerifyStart">Press [Start] again to start probing.</system:String>
<system:String x:Uid="str_probingProbingAtX0Y0" x:Key="ProbingAtX0Y0">Probing @X0Y0...</system:String>
</ResourceDictionary>
10 changes: 5 additions & 5 deletions CNC Controls Probing/CNC Controls Probing/ProbingView.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* ProbingView.xaml.cs - part of CNC Probing library
*
* v0.43 / 2023-07-25 / Io Engineering (Terje Io)
* v0.44 / 2023-08-26 / Io Engineering (Terje Io)
*
*/

Expand Down Expand Up @@ -324,18 +324,18 @@ public void Setup(UIViewModel model, AppConfig profile)

private void mnu_Click(object sender, RoutedEventArgs e)
{
switch ((string)((MenuItem)sender).Header)
switch ((string)((MenuItem)sender).Name)
{
case "Add":
case "mnuAdd":
cbxProfile.SelectedValue = profiles.Add(cbxProfile.Text, model);
break;

case "Update":
case "mnuUpdate":
if(model.Profile != null)
profiles.Update(model.Profile.Id, cbxProfile.Text, model);
break;

case "Delete":
case "mnuDelete":
if (model.Profile != null && profiles.Delete(model.Profile.Id))
cbxProfile.SelectedValue = profiles.Profiles[0].Id;
break;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* ProbingViewModel.cs - part of CNC Probing library
*
* v0.43 / 2023-06-30 / Io Engineering (Terje Io)
* v0.44 / 2023-10-01 / Io Engineering (Terje Io)
*
*/

Expand Down Expand Up @@ -171,9 +171,6 @@ public bool WaitForResponse(string command)
{
bool? res = null;

if (Grbl.ResponseLogVerbose)
Grbl.ResponseLog.Add(command);

var t = new Thread(() =>
{
res = WaitFor.AckResponse<string>(
Expand Down
18 changes: 15 additions & 3 deletions CNC Controls Probing/CNC Controls Probing/Program.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Program.cs - part of CNC Probing library
*
* v0.42 / 2023-03-22 / Io Engineering (Terje Io)
* v0.44 / 2023-10-01 / Io Engineering (Terje Io)
*
*/

Expand Down Expand Up @@ -308,6 +308,11 @@ public void AddProbingAction(AxisFlags axis, bool negative)
}
}

public void AddMessage(string msg)
{
_program.Add("#" + msg);
}

public void AddSimulatedProbe(int p)
{
probing.IsSuccess = true;
Expand Down Expand Up @@ -415,8 +420,7 @@ public bool Execute(bool go)

if (response == "ok")
{
step++;
if (step < _program.Count)
if (++step < _program.Count)
{
int i;
//if ((i = _program[step].IndexOf('$')) > 0)
Expand All @@ -426,6 +430,13 @@ public bool Execute(bool go)
// double val = _positions[_positions.Count - 1].Values[i] + dbl.Parse(_program[step].Substring(i, 3));
// _program[step] = _program[step] + val.ToInvariantString();
//}
if (_program[step].StartsWith("#"))
{
Grbl.Message = _program[step].Substring(1);
if (++step == _program.Count)
break;
}

if (_program[step].StartsWith("!"))
{
isProbing = false;
Expand Down Expand Up @@ -475,6 +486,7 @@ public bool ProbeZ(double x, double y)
return false;

probing.Program.AddRapid(string.Format("G90X{0}Y{0}", x.ToInvariantString(probing.Grbl.Format), y.ToInvariantString(probing.Grbl.Format)));
probing.Program.AddMessage(LibStrings.FindResource("ProbingAtX0Y0"));
probing.Program.Add(string.Format("G91F{0}", probing.ProbeFeedRate.ToInvariantString()));
probing.Program.AddProbingAction(AxisFlags.Z, true);

Expand Down
13 changes: 12 additions & 1 deletion CNC Controls/CNC Controls/AppConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@ public RestartResult Restart ()
{
if (MessageBox.Show(LibStrings.FindResource("MsgEStopExit"), "ioSender", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
return RestartResult.Close;
};
}
}
else
AttemptReset();
Expand All @@ -725,6 +725,17 @@ public RestartResult Restart ()
else
Message = LibStrings.FindResource("MsgHome");
break;

case 17: // Motor fault
if (!(GrblInfo.IsGrblHAL && model.Signals.Value.HasFlag(Signals.MotorFault)))
{
AttemptReset();
if (!GrblInfo.IsLoaded)
model.ExecuteCommand(GrblConstants.CMD_UNLOCK);
}
break;


}
break;

Expand Down
10 changes: 9 additions & 1 deletion CNC Controls/CNC Controls/GCodeListControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,19 @@
d:DesignHeight="335" d:DesignWidth="400"
Loaded="UserControl_Loaded">
<DataGrid x:Name="grdGCode" Grid.Row="0" ItemsSource="{Binding}" AllowDrop="True" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" AutoGenerateColumns="False"
CanUserSortColumns="false" CanUserResizeRows="False" IsReadOnly="true" DragEnter="grdGCode_Drag" DragOver="grdGCode_Drag" DragLeave="grdGCode_Drag" Drop="grdGCode_Drop">
CanUserSortColumns="false" CanUserResizeRows="False" IsReadOnly="true" SelectionChanged="grdGCode_SelectionChanged"
DragEnter="grdGCode_Drag" DragOver="grdGCode_Drag" DragLeave="grdGCode_Drag" Drop="grdGCode_Drop">
<DataGrid.Columns>
<DataGridTextColumn x:Uid="hdr_block" Header="Block" Binding="{Binding LineNum}" Width="50" MinWidth="50" MaxWidth="60"/>
<DataGridTextColumn Header="" Binding="{Binding Sent}" Width="*" MinWidth="30" MaxWidth="60"/>
<DataGridTextColumn x:Uid="hdr_data" Header="Data" Binding="{Binding Data}" Width="*" MinWidth="280"/>
</DataGrid.Columns>
<DataGrid.ContextMenu>
<ContextMenu x:Name="ctxMenu">
<MenuItem x:Uid="mnu_sendToController" Header="Send to controller" IsEnabled="{Binding Path=MultipleSelected}" Click="SendController_Click" />
<MenuItem x:Uid="mnu_startFromHere" Header="Start from here" IsEnabled="{Binding Path=SingleSelected}" Click="StartHere_Click" />
<MenuItem x:Uid="mnu_copyToMDI" Header="Copy to MDI" IsEnabled="{Binding Path=SingleSelected}" Click="CopyMDI_Click" />
</ContextMenu>
</DataGrid.ContextMenu>
</DataGrid>
</UserControl>
129 changes: 115 additions & 14 deletions CNC Controls/CNC Controls/GCodeListControl.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,47 @@
using CNC.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
/*
* GcodeListControl.xaml.cs - part of CNC Controls library for Grbl
*
* v0.44 / 2023-10-07 / Io Engineering (Terje Io)
*
*/

/*
Copyright (c) 2020-2023, Io Engineering (Terje Io)
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
· Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
· Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.
· Neither the name of the copyright holder nor the names of its contributors may
be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

using System.Data;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Collections.Generic;
using CNC.Core;

namespace CNC.Controls
{
Expand All @@ -22,12 +51,31 @@ namespace CNC.Controls
public partial class GCodeListControl : UserControl
{
public ScrollViewer scroll = null;

public GCodeListControl()
{
InitializeComponent();

ctxMenu.DataContext = this;
}

#region Dependency properties

public static readonly DependencyProperty SingleSelectedProperty = DependencyProperty.Register(nameof(SingleSelected), typeof(bool), typeof(GCodeListControl), new PropertyMetadata(false));
public bool SingleSelected
{
get { return (bool)GetValue(SingleSelectedProperty); }
private set { SetValue(SingleSelectedProperty, value); }
}

public static readonly DependencyProperty MultipleSelectedProperty = DependencyProperty.Register(nameof(MultipleSelected), typeof(bool), typeof(GCodeListControl), new PropertyMetadata(false));
public bool MultipleSelected
{
get { return (bool)GetValue(MultipleSelectedProperty); }
private set { SetValue(MultipleSelectedProperty, value); }
}
#endregion

private void grdGCode_Drag(object sender, DragEventArgs e)
{
GCode.File.Drag(sender, e);
Expand Down Expand Up @@ -59,5 +107,58 @@ private void GCodeListControl_PropertyChanged(object sender, System.ComponentMod
break;
}
}

void grdGCode_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
SingleSelected = grdGCode.SelectedItems.Count == 1 && (DataContext as GrblViewModel).StartFromBlock.CanExecute(grdGCode.SelectedIndex);
MultipleSelected = grdGCode.SelectedItems.Count >= 0 && (DataContext as GrblViewModel).StartFromBlock.CanExecute(grdGCode.SelectedIndex);
}

private void StartHere_Click(object sender, RoutedEventArgs e)
{
if (grdGCode.SelectedItems.Count == 1 &&
MessageBox.Show(string.Format(LibStrings.FindResource("VerifyStartFrom"), ((DataRowView)(grdGCode.SelectedItems[0])).Row["LineNum"]),
"ioSender", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.Yes)
{
(DataContext as GrblViewModel).StartFromBlock.Execute(grdGCode.SelectedIndex);
}
}

private void CopyMDI_Click(object sender, RoutedEventArgs e)
{
if (grdGCode.SelectedItems.Count == 1)
(DataContext as GrblViewModel).MDIText = (string)((DataRowView)(grdGCode.SelectedItems[0])).Row["Data"];
}

private void SendController_Click(object sender, RoutedEventArgs e)
{
if (grdGCode.SelectedItems.Count >= 1 &&
MessageBox.Show(LibStrings.FindResource("VerifySendController"), "ioSender",
MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.Yes)
{
var model = DataContext as GrblViewModel;

if (model.GrblError != 0)
model.ExecuteCommand("");

List<DataRow> rows = new List<DataRow>();

for (int i = 0; i < grdGCode.SelectedItems.Count; i++)
rows.Add(((DataRowView)(grdGCode.SelectedItems[i])).Row);

rows.Sort(new RowComparer());

foreach (DataRow row in rows)
model.ExecuteCommand((string)row["Data"]);
}
}
}

internal class RowComparer : IComparer<DataRow>
{
public int Compare(DataRow a, DataRow b)
{
return (int)a["LineNum"] - (int)b["LineNum"];
}
}
}
17 changes: 16 additions & 1 deletion CNC Controls/CNC Controls/GrblConfigView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
<system:String x:Uid="str_settingsFail" x:Key="SettingsFail">Bummer...\nContinue loading?</system:String>
<system:String x:Uid="str_settingsInvalid" x:Key="SettingsInvalid">The file does not contain any settings.</system:String>
<system:String x:Uid="str_settingsRestore" x:Key="SettingsRestore">Restore settings from file</system:String>
<local:LogicalNotConverter x:Key="IsNotConverter" />
<local:GrblStateToBooleanConverter x:Key="StateToBooleanConverter" />
<Style x:Key="NumericErrorStyle" TargetType="local:NumericTextBox">
<Style.Triggers>
<Trigger Property="Validation.HasError" Value="true">
Expand Down Expand Up @@ -89,7 +91,20 @@
<DockPanel DockPanel.Dock="Bottom" HorizontalAlignment="Stretch" Height="Auto" Margin="10,0,10,10" VerticalAlignment="Top" Width="Auto">
<StackPanel Orientation="Horizontal" DockPanel.Dock="Left" Height="Auto" VerticalAlignment="Top">
<Button x:Uid="btn_reload" x:Name="btnReload" Content="Reload" ToolTip="Reload settings from controller." HorizontalAlignment="Left" Style="{StaticResource ConfigButtonStyle}" Click="btnReload_Click"/>
<Button x:Uid="btn_save" x:Name="btnSave" Content="Save" ToolTip="Save changed settings to controller." HorizontalAlignment="Left" Margin="5,0,0,0" VerticalAlignment="Top" Style="{StaticResource ConfigButtonStyle}" Click="btnSave_Click"/>
<Button x:Uid="btn_save" x:Name="btnSave" Content="Save" ToolTip="Save changed settings to controller." HorizontalAlignment="Left" Margin="5,0,0,0" VerticalAlignment="Top" Style="{StaticResource ConfigButtonStyle}" Click="btnSave_Click">
<!--- TODO <Button.IsEnabled>
<Binding Converter="IsNotConverter">
<MultiBinding Converter="{StaticResource StateToBooleanConverter}">
<Binding Path="Grbl.GrblState"/>
<Binding>
<Binding.Source>
<cnccore:GrblStates>Hold</cnccore:GrblStates>
</Binding.Source>
</Binding>
</MultiBinding>
</Binding>
</Button.IsEnabled> -->
</Button>
</StackPanel>
<StackPanel Orientation="Horizontal" DockPanel.Dock="Right" Height="Auto" VerticalAlignment="Top" HorizontalAlignment="Right">
<Button x:Uid="btn_backup" x:Name="btnBackup" Content="Backup" HorizontalAlignment="Left" VerticalAlignment="Top" Style="{StaticResource ConfigButtonStyle}" Click="btnBackup_Click"/>
Expand Down
Loading

0 comments on commit 552f20d

Please sign in to comment.