Skip to content

Commit

Permalink
Release 2.0.41
Browse files Browse the repository at this point in the history
  • Loading branch information
terjeio committed Nov 17, 2022
1 parent 29f206a commit 6a7f84b
Show file tree
Hide file tree
Showing 93 changed files with 2,005 additions and 581 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@
</Compile>
<Compile Include="HeightMapViewModel.cs" />
<Compile Include="IProbeTab.cs" />
<Compile Include="ProbeVerify.xaml.cs">
<DependentUpon>ProbeVerify.xaml</DependentUpon>
</Compile>
<Compile Include="ProbingConfig.cs" />
<Compile Include="ProbingView.xaml.cs">
<DependentUpon>ProbingView.xaml</DependentUpon>
Expand Down Expand Up @@ -134,6 +137,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="ProbeVerify.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="ProbingView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down Expand Up @@ -188,6 +195,9 @@
<Resource Include="Resources\RotaterCB.png" />
<Resource Include="Resources\RotaterCD.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\App.ico" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* CenterFinderControl.xaml.cs - part of CNC Probing library
*
* v0.37 / 2022-02-21 / Io Engineering (Terje Io)
* v0.41 / 2022-11-13 / Io Engineering (Terje Io)
*
*/

Expand Down Expand Up @@ -80,6 +80,7 @@ public void Activate(bool activate)

if (activate)
{
probing.AllowMeasure = true;
probing.Instructions = ((string)FindResource("Instructions")).Replace("\\n", "\n");
probing.PropertyChanged += Probing_PropertyChanged;
} else
Expand Down Expand Up @@ -135,7 +136,7 @@ private bool CreateProgram(bool preview)

if (!probing.Program.Init())
{
probing.Message = (string)FindResource("InitFailed");
probing.Message = (string)FindResource("InitFailed") + " " + probing.Message;
return false;
}

Expand Down Expand Up @@ -295,6 +296,9 @@ public void Start(bool preview = false)
return;
}

if (!probing.VerifyProbe())
return;

pass = preview ? 1 : probing.Passes;

if (CreateProgram(preview))
Expand All @@ -310,8 +314,11 @@ public void Start(bool preview = false)
else
{
probing.Program.Execute(true);
OnCompleted();
if(OnCompleted())
probing.WaitForIdle(string.Empty);
}


} while (--pass != 0 && CreateProgram(preview));
}
}
Expand Down Expand Up @@ -375,19 +382,27 @@ private bool OnCompleted()

if (ok && pass == 1)
{
if (probing.CoordinateMode == ProbingViewModel.CoordMode.G92)
{
center.X = probing.ProbeOffsetX;
center.Y = probing.ProbeOffsetY;
probing.WaitForResponse("G92" + center.ToString(axisflags));
if (!probing.Grbl.IsParserStateLive)
probing.Grbl.ExecuteCommand("$G");
}
else
switch(probing.CoordinateMode)
{
center.X += probing.ProbeOffsetX;
center.Y += probing.ProbeOffsetY;
probing.WaitForResponse(string.Format("G10L2P{0}{1}", probing.CoordinateSystem, center.ToString(axisflags)));
case ProbingViewModel.CoordMode.Measure:
center.X += probing.ProbeOffsetX;
center.Y += probing.ProbeOffsetY;
probing.Measurement.Add(center, axisflags, ProbingType);
break;

case ProbingViewModel.CoordMode.G92:
center.X = probing.ProbeOffsetX;
center.Y = probing.ProbeOffsetY;
probing.WaitForResponse("G92" + center.ToString(axisflags));
if (!probing.Grbl.IsParserStateLive)
probing.Grbl.ExecuteCommand("$G");
break;

case ProbingViewModel.CoordMode.G10:
center.X += probing.ProbeOffsetX;
center.Y += probing.ProbeOffsetY;
probing.WaitForResponse(string.Format("G10L2P{0}{1}", probing.CoordinateSystem, center.ToString(axisflags)));
break;
}
}

Expand Down
3 changes: 2 additions & 1 deletion CNC Controls Probing/CNC Controls Probing/ConfigControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
xmlns:local="clr-namespace:CNC.Controls.Probing"
xmlns:Controls="clr-namespace:CNC.Controls;assembly=CNC.Controls.WPF"
mc:Ignorable="d"
d:DesignHeight="42" d:DesignWidth="310">
d:DesignHeight="80" d:DesignWidth="310">
<GroupBox x:Uid="grp_probeConfig" Header="Probing" HorizontalAlignment="Left" VerticalAlignment="Top" Height="Auto" Width="310">
<StackPanel HorizontalAlignment="Left" Height="Auto" Margin="0,3,0,0" VerticalAlignment="Top" Width="290">
<CheckBox x:Uid="lbl_chkProbeConnected" Content="Manually validate probe is connected" HorizontalContentAlignment="Left" HorizontalAlignment="Left" Margin="5,0,0,0" IsChecked="{Binding Path=Probing.ValidateProbeConnected, Mode=TwoWay}" ToolTip="A dialog will be shown until the probe is asserted or the dialog is cancelled."/>
<CheckBox x:Uid="lbl_chkProbeStatus" Content="Check probe status before start (G59.3)" HorizontalContentAlignment="Left" HorizontalAlignment="Left" Margin="5,0,0,0" IsChecked="{Binding Path=Probing.CheckProbeStatus, Mode=TwoWay}" ToolTip="An alarm will be generated by the controller if not enabled and the probe is asserted."/>
</StackPanel>
</GroupBox>
Expand Down
11 changes: 7 additions & 4 deletions CNC Controls Probing/CNC Controls Probing/CsSelectControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,26 @@
xmlns:Controls="clr-namespace:CNC.Controls;assembly=CNC.Controls.WPF"
xmlns:local="clr-namespace:CNC.Controls.Probing"
mc:Ignorable="d"
d:DesignHeight="80" d:DesignWidth="230">
d:DesignHeight="105" d:DesignWidth="230">
<UserControl.Resources>
<Controls:EnumValueToBooleanConverter x:Key="EnumToCheckedConverter" />
<Controls:BoolToVisibleConverter x:Key="IsVisibleConverter" />
</UserControl.Resources>
<GroupBox x:Uid="grp_action" Header="Action" Height="85">
<StackPanel Orientation="Vertical" Margin="2,5,0,0">
<GroupBox x:Uid="grp_action" Header="Action">
<StackPanel Orientation="Vertical" Margin="2,3,0,0">
<DockPanel>
<RadioButton x:Uid="set_coord" Content="Set coordinate system:" IsChecked="{Binding Path=CoordinateMode, Mode=TwoWay, Converter={StaticResource EnumToCheckedConverter}, ConverterParameter=G10}" VerticalAlignment="Center"/>
<ComboBox x:Name="cbxOffset" Margin="3,0" DisplayMemberPath="Code" SelectedValuePath="Id" ItemsSource="{Binding Path=CoordinateSystems}" SelectedValue="{Binding Path=CoordinateSystem, Mode=TwoWay}" HorizontalAlignment="Right" VerticalAlignment="Center" Width="55" Height="22"/>
</DockPanel>
<DockPanel Margin="0,5,0,0" Width="Auto" Height="30">
<DockPanel Margin="0,2,0,0" Width="Auto" Height="30">
<RadioButton x:Uid="btn_setG92" Content="Set offset (G92)" IsChecked="{Binding Path=CoordinateMode, Mode=TwoWay, Converter={StaticResource EnumToCheckedConverter}, ConverterParameter=G92}" VerticalAlignment="Center"/>
<Border Visibility="{Binding Path=Grbl.IsG92Active, Converter={StaticResource IsVisibleConverter}}" Background="Salmon" HorizontalAlignment="Right" VerticalAlignment="Center" CornerRadius="2" Width="61" Height="28">
<Button x:Uid="btn_clear" Content="Clear" HorizontalAlignment="Center" VerticalAlignment="Center" Width="55" Height="22" Click="ClearG92_Click"/>
</Border>
</DockPanel>
<DockPanel Visibility="{Binding Path=AllowMeasure, Converter={StaticResource IsVisibleConverter}}" Margin="0,5,0,0" Width="Auto" Height="19">
<RadioButton x:Uid="btn_setMeasure" Content="Measure" IsChecked="{Binding Path=CoordinateMode, Mode=TwoWay, Converter={StaticResource EnumToCheckedConverter}, ConverterParameter=Measure}" VerticalAlignment="Center"/>
</DockPanel>
</StackPanel>
</GroupBox>
</UserControl>
53 changes: 34 additions & 19 deletions CNC Controls Probing/CNC Controls Probing/EdgeFinderControl.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* EdgeFinderControl.xaml.cs - part of CNC Probing library
*
* v0.37 / 2022-02-21 / Io Engineering (Terje Io)
* v0.41 / 2022-11-13 / Io Engineering (Terje Io)
*
*/

Expand Down Expand Up @@ -80,8 +80,11 @@ public EdgeFinderControl()

public void Activate(bool activate)
{
if(activate)
if (activate)
{
(DataContext as ProbingViewModel).AllowMeasure = true;
(DataContext as ProbingViewModel).Instructions = ((string)FindResource("Instructions")).Replace("\\n", "\n");
}
}

public void Start(bool preview = false)
Expand All @@ -97,6 +100,9 @@ public void Start(bool preview = false)
return;
}

if (!probing.VerifyProbe())
return;

if (!probing.Program.Init())
return;

Expand Down Expand Up @@ -275,24 +281,33 @@ private void OnCompleted ()

if (ok)
{
if (probing.CoordinateMode == ProbingViewModel.CoordMode.G92)
{
if((ok = !isCancelled && probing.GotoMachinePosition(pos, AxisFlags.Z)))
{
pos.X = -probing.ProbeOffsetX;
pos.Y = -probing.ProbeOffsetY;
pos.Z = probing.WorkpieceHeight + probing.TouchPlateHeight;
probing.WaitForResponse("G92" + pos.ToString(axisflags));
if (!isCancelled && axisflags.HasFlag(AxisFlags.Z))
probing.GotoMachinePosition(probing.StartPosition, AxisFlags.Z);
}
}
else
switch (probing.CoordinateMode)
{
pos.X += probing.ProbeOffsetX;
pos.Y += probing.ProbeOffsetY;
pos.Z -= probing.WorkpieceHeight + probing.TouchPlateHeight + probing.Grbl.ToolOffset.Z;
probing.WaitForResponse(string.Format("G10L2P{0}{1}", probing.CoordinateSystem, pos.ToString(axisflags)));
case ProbingViewModel.CoordMode.Measure:
pos.X += probing.ProbeOffsetX;
pos.Y += probing.ProbeOffsetY;
pos.Z -= probing.WorkpieceHeight + probing.TouchPlateHeight + probing.Grbl.ToolOffset.Z;
probing.Measurement.Add(pos, axisflags, ProbingType);
break;

case ProbingViewModel.CoordMode.G92:
if ((ok = !isCancelled && probing.GotoMachinePosition(pos, AxisFlags.Z)))
{
pos.X = -probing.ProbeOffsetX;
pos.Y = -probing.ProbeOffsetY;
pos.Z = probing.WorkpieceHeight + probing.TouchPlateHeight;
probing.WaitForResponse("G92" + pos.ToString(axisflags));
if (!isCancelled && axisflags.HasFlag(AxisFlags.Z))
probing.GotoMachinePosition(probing.StartPosition, AxisFlags.Z);
}
break;

case ProbingViewModel.CoordMode.G10:
pos.X += probing.ProbeOffsetX;
pos.Y += probing.ProbeOffsetY;
pos.Z -= probing.WorkpieceHeight + probing.TouchPlateHeight + probing.Grbl.ToolOffset.Z;
probing.WaitForResponse(string.Format("G10L2P{0}{1}", probing.CoordinateSystem, pos.ToString(axisflags)));
break;
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* EdgeFinderIntControl.xaml.cs - part of CNC Probing library
*
* v0.37 / 2022-02-21 / Io Engineering (Terje Io)
* v0.41 / 2022-11-13 / Io Engineering (Terje Io)
*
*/

Expand Down Expand Up @@ -67,8 +67,10 @@ public EdgeFinderIntControl()

public void Activate(bool activate)
{
if (activate)
if (activate) {
(DataContext as ProbingViewModel).AllowMeasure = true;
(DataContext as ProbingViewModel).Instructions = ((string)FindResource("Instructions")).Replace("\\n", "\n");
}
}

public void Start(bool preview = false)
Expand All @@ -84,6 +86,9 @@ public void Start(bool preview = false)
return;
}

if(!probing.VerifyProbe())
return;

if (!probing.Program.Init())
return;

Expand Down Expand Up @@ -264,24 +269,33 @@ private void OnCompleted()

if (ok)
{
if (probing.CoordinateMode == ProbingViewModel.CoordMode.G92)
{
if ((ok = !isCancelled && probing.GotoMachinePosition(pos, AxisFlags.Z)))
{
pos.X = -probing.ProbeOffsetX;
pos.Y = -probing.ProbeOffsetY;
pos.Z = probing.WorkpieceHeight + probing.TouchPlateHeight;
probing.WaitForResponse("G92" + pos.ToString(axisflags));
if (!isCancelled && axisflags.HasFlag(AxisFlags.Z))
probing.GotoMachinePosition(probing.StartPosition, AxisFlags.Z);
}
}
else
switch (probing.CoordinateMode)
{
pos.X += probing.ProbeOffsetX;
pos.Y += probing.ProbeOffsetY;
pos.Z -= probing.WorkpieceHeight + probing.TouchPlateHeight + probing.Grbl.ToolOffset.Z;
probing.WaitForResponse(string.Format("G10L2P{0}{1}", probing.CoordinateSystem, pos.ToString(axisflags)));
case ProbingViewModel.CoordMode.Measure:
pos.X += probing.ProbeOffsetX;
pos.Y += probing.ProbeOffsetY;
pos.Z -= probing.WorkpieceHeight + probing.TouchPlateHeight + probing.Grbl.ToolOffset.Z;
probing.Measurement.Add(pos, axisflags, ProbingType);
break;

case ProbingViewModel.CoordMode.G92:
if ((ok = !isCancelled && probing.GotoMachinePosition(pos, AxisFlags.Z)))
{
pos.X = -probing.ProbeOffsetX;
pos.Y = -probing.ProbeOffsetY;
pos.Z = probing.WorkpieceHeight + probing.TouchPlateHeight;
probing.WaitForResponse("G92" + pos.ToString(axisflags));
if (!isCancelled && axisflags.HasFlag(AxisFlags.Z))
probing.GotoMachinePosition(probing.StartPosition, AxisFlags.Z);
}
break;

case ProbingViewModel.CoordMode.G10:
pos.X += probing.ProbeOffsetX;
pos.Y += probing.ProbeOffsetY;
pos.Z -= probing.WorkpieceHeight + probing.TouchPlateHeight + probing.Grbl.ToolOffset.Z;
probing.WaitForResponse(string.Format("G10L2P{0}{1}", probing.CoordinateSystem, pos.ToString(axisflags)));
break;
}
}

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.37 / 2022-03-09 / Io Engineering (Terje Io)
* v0.41 / 2022-11-13 / Io Engineering (Terje Io)
*
*/

Expand Down Expand Up @@ -75,7 +75,11 @@ public void Start(bool preview = false)
if (!probing.ValidateInput(true))
return;

probing.WaitForIdle(string.Format("G90G0X{0}Y{1}", probing.HeightMap.MinX.ToInvariantString(), probing.HeightMap.MinY.ToInvariantString()));
if (!probing.WaitForIdle(string.Format("G90G0X{0}Y{1}", probing.HeightMap.MinX.ToInvariantString(), probing.HeightMap.MinY.ToInvariantString())))
return;

if (!probing.VerifyProbe())
return;

if (!probing.Program.Init())
return;
Expand Down
2 changes: 2 additions & 0 deletions CNC Controls Probing/CNC Controls Probing/LibStrings.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@
<system:String x:Uid="str_probingDistanceError" x:Key="ErrorProbingDistance">Probing distance must be larger than XY Clearance + ½ Probe/tool diameter.</system:String>
<system:String x:Uid="str_probingLatchDistanceError" x:Key="ErrorLatchDistance">Latch distance must be less than Probing distance.</system:String>
<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>
</ResourceDictionary>
13 changes: 13 additions & 0 deletions CNC Controls Probing/CNC Controls Probing/ProbeVerify.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Window x:Class="CNC.Controls.Probing.ProbeVerify"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
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:local="clr-namespace:CNC.Controls.Probing"
mc:Ignorable="d"
Title="Sender" Height="100" Width="300" ResizeMode="NoResize"
Loaded="Window_Loaded" Closing="Window_Closing" Icon="Resources/App.ico">
<Grid Background="Snow">
<Label x:Uid="str_probeVerify" x:Name="label" Content="Assert probe to verify connection." HorizontalAlignment="Center" Margin="0" VerticalAlignment="Center" FontSize="16"/>
</Grid>
</Window>
Loading

0 comments on commit 6a7f84b

Please sign in to comment.