diff --git a/Renishaw_XL80_App/Renishaw_XL80_App.csproj b/Renishaw_XL80_App/Renishaw_XL80_App.csproj
index 0240cd2..330c3e5 100644
--- a/Renishaw_XL80_App/Renishaw_XL80_App.csproj
+++ b/Renishaw_XL80_App/Renishaw_XL80_App.csproj
@@ -69,7 +69,7 @@
False
- ..\..\..\..\..\Documents\LaserAPI 1.16\Examples\bin\LaserServiceWinFormsDemo\x64\Release\DeviceStream.dll
+ bin\debug\DeviceStream.dll
bin\Debug\Interop.DX10SERVERLib.dll
@@ -78,6 +78,9 @@
..\..\..\..\..\Documents\LaserAPI 1.16\Examples\bin\LaserServiceWinFormsDemo\x64\Release\LaserApi.dll
+
+ bin\debug\LocalHost.dll
+
..\..\..\..\..\..\..\Program Files\Renishaw CARTO\Capture\Microsoft.Expression.Drawing.dll
@@ -116,7 +119,7 @@
False
- ..\..\..\..\..\Documents\LaserAPI 1.16\Examples\bin\LaserServiceWinFormsDemo\x64\Release\NEW DLL VERSIONS\Renishaw.Calibration.dll
+ bin\debug\Renishaw.Calibration.dll
False
@@ -124,23 +127,26 @@
False
- ..\..\..\..\..\Documents\LaserAPI 1.16\Examples\bin\LaserServiceWinFormsDemo\x64\Release\Renishaw.Calibration.ServiceModel.dll
+ bin\debug\Renishaw.Calibration.ServiceModel.dll
False
- ..\..\..\..\..\Documents\LaserAPI 1.16\Examples\bin\LaserServiceWinFormsDemo\x64\Release\NEW DLL VERSIONS\Renishaw.IO.dll
+ bin\debug\Renishaw.IO.dll
False
..\..\..\..\..\Documents\LaserAPI 1.16\Examples\bin\LaserServiceWinFormsDemo\x64\Release\Renishaw.IO.Bluetooth.dll
+
+ bin\debug\RenishawDX10Service.dll
+
False
- ..\..\..\..\..\Documents\LaserAPI 1.16\Examples\bin\LaserServiceWinFormsDemo\x64\Release\RenishawLaserService.dll
+ bin\debug\RenishawLaserService.dll
False
- ..\..\..\..\..\Documents\LaserAPI 1.16\Examples\bin\LaserServiceWinFormsDemo\x64\Release\RenishawWeatherStationService.dll
+ bin\debug\RenishawWeatherStationService.dll
@@ -175,11 +181,11 @@
False
- ..\..\..\..\..\Documents\LaserAPI 1.16\Examples\bin\LaserServiceWinFormsDemo\x64\Release\UsbIo.dll
+ bin\debug\UsbIo.dll
False
- ..\..\..\..\..\Documents\LaserAPI 1.16\Examples\bin\LaserServiceWinFormsDemo\x64\Release\UsbTmc.dll
+ bin\debug\UsbTmc.dll
@@ -187,7 +193,7 @@
False
- ..\..\..\..\..\Documents\LaserAPI 1.16\Examples\bin\LaserServiceWinFormsDemo\x64\Release\XLLaserSystem.dll
+ bin\debug\XLLaserSystem.dll
diff --git a/TwinCat Motion ADS/APPLICATION WINDOWS/measurementDeviceWindow.xaml.cs b/TwinCat Motion ADS/APPLICATION WINDOWS/measurementDeviceWindow.xaml.cs
index ab57019..e5a6a07 100644
--- a/TwinCat Motion ADS/APPLICATION WINDOWS/measurementDeviceWindow.xaml.cs
+++ b/TwinCat Motion ADS/APPLICATION WINDOWS/measurementDeviceWindow.xaml.cs
@@ -2,9 +2,12 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
+using System.Security.Cryptography.X509Certificates;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
using TwinCat_Motion_ADS.MeasurementDevice;
namespace TwinCat_Motion_ADS
@@ -95,6 +98,11 @@ private void ConstructDeviceSettingsScreen()
{
case DeviceTypes.DigimaticIndicator:
CommonRs232Window();
+ //Create UI elements
+ cosineCorrectionUI cosineCorrectionUI = new(MDevice);
+
+ //add elements and stack pannels to UI
+ deviceSettings.Children.Add(cosineCorrectionUI.cosineCorrectionUISP);
break;
case DeviceTypes.KeyenceTM3000:
@@ -388,6 +396,101 @@ private void refreshPorts_Click(object sender, EventArgs e)
}
+ class cosineCorrectionUI
+ {
+ //Create UI elements
+ public StackPanel cosineCorrectionUISP = new() { Orientation = Orientation.Vertical };
+ public CheckBox enableCosineCalculationCheckBox = new() { Name = "enableCosineCalculationCheckBox" };
+ public Button calculateCosineCorrectionButton = new();
+ public Button resetCosineCalculationButton = new();
+ public Image cosineImage = new() { MaxWidth = 300, Height = 100 };
+ public TextBlock initialValueTextBlock = new();
+ public TextBox initialValueTextBox = new() { Name = "initialValueTextBox" };
+ public Button initialValue_ReadIn = new();
+ public TextBlock distanceTraveledTextBlock = new();
+ public TextBox distanceTraveledTextBox = new() { Name = "distanceTraveledTextBox" };
+ public TextBlock finalValueTextBlock = new();
+ public TextBox finalValueTextBox = new() { Name = "finalValueTextBox" };
+ public Button finalValue_ReadIn = new();
+ private StackPanel cosineCorrectionSP = new()
+ {
+ Orientation = Orientation.Vertical,
+ Width = 300,
+ IsEnabled = false,
+ Visibility = Visibility.Collapsed,
+ Name = "cosineCorrectionSP",
+ HorizontalAlignment = HorizontalAlignment.Center
+ };
+ public cosineCorrectionUI (I_MeasurementDevice MDevice)
+ {
+ //setup UI element
+ cosineImage.Source = new BitmapImage(new Uri("\\ImageAssets\\COSINE.png", UriKind.Relative));
+ XamlUI.SetupButton(ref calculateCosineCorrectionButton, "CALCULATE");
+ XamlUI.SetupButton(ref resetCosineCalculationButton, "RESET");
+ XamlUI.SetupTextBlock(ref initialValueTextBlock, "H1", 15);
+ XamlUI.SetupTextBox(ref initialValueTextBox, "0");
+ XamlUI.SetupButton(ref initialValue_ReadIn, "Read in");
+ XamlUI.SetupTextBlock(ref distanceTraveledTextBlock, "A", 15);
+ XamlUI.SetupTextBox(ref distanceTraveledTextBox, "1");
+ XamlUI.SetupTextBlock(ref finalValueTextBlock, "H2", 15);
+ XamlUI.SetupTextBox(ref finalValueTextBox, "1");
+ XamlUI.SetupButton(ref finalValue_ReadIn, "Read in");
+
+ //Setup bindings
+ XamlUI.CheckBoxBinding("Enable COSINE Correction", enableCosineCalculationCheckBox, (MD_DigimaticIndicator)MDevice, "EnableCosineCorrection");
+ XamlUI.TextboxBinding(initialValueTextBox, (MD_DigimaticIndicator)MDevice, "InitialValue");
+ XamlUI.TextboxBinding(distanceTraveledTextBox, (MD_DigimaticIndicator)MDevice, "DistanceTraveled");
+ XamlUI.TextboxBinding(finalValueTextBox, (MD_DigimaticIndicator)MDevice, "FinalValue");
+
+ //Setup event handlers
+ enableCosineCalculationCheckBox.Click += new RoutedEventHandler(EnableUI);
+ calculateCosineCorrectionButton.Click += new RoutedEventHandler(((MD_DigimaticIndicator)MDevice).CalculateCosineCorrection);
+ resetCosineCalculationButton.Click += new RoutedEventHandler(((MD_DigimaticIndicator)MDevice).ResetCosineCalculation);
+ initialValue_ReadIn.Click += new RoutedEventHandler(((MD_DigimaticIndicator)MDevice).InitialValue_ReadIn);
+ finalValue_ReadIn.Click += new RoutedEventHandler(((MD_DigimaticIndicator)MDevice).FinalValue_ReadIn);
+
+ //Setup stack pannels
+ StackPanel imageSP = new() { Orientation = Orientation.Horizontal };
+ StackPanel controlSP = new() { Orientation = Orientation.Vertical, VerticalAlignment = VerticalAlignment.Center };
+ StackPanel initalValueSP = new() { Orientation = Orientation.Horizontal };
+ StackPanel distanceTraveledSP = new() { Orientation = Orientation.Horizontal };
+ StackPanel finalValueSP = new() { Orientation = Orientation.Horizontal };
+
+ //add elements and stack pannels to UI
+ cosineCorrectionUISP.Children.Add(enableCosineCalculationCheckBox);
+ cosineCorrectionUISP.Children.Add(cosineCorrectionSP);
+ cosineCorrectionSP.Children.Add(imageSP);
+ cosineCorrectionSP.Children.Add(initalValueSP);
+ cosineCorrectionSP.Children.Add(finalValueSP);
+ cosineCorrectionSP.Children.Add(distanceTraveledSP);
+ imageSP.Children.Add(cosineImage);
+ imageSP.Children.Add(controlSP);
+ controlSP.Children.Add(calculateCosineCorrectionButton);
+ controlSP.Children.Add(resetCosineCalculationButton);
+ initalValueSP.Children.Add(initialValueTextBlock);
+ initalValueSP.Children.Add(initialValueTextBox);
+ initalValueSP.Children.Add(initialValue_ReadIn);
+ distanceTraveledSP.Children.Add(distanceTraveledTextBlock);
+ distanceTraveledSP.Children.Add(distanceTraveledTextBox);
+ finalValueSP.Children.Add(finalValueTextBlock);
+ finalValueSP.Children.Add(finalValueTextBox);
+ finalValueSP.Children.Add(finalValue_ReadIn);
+ }
+ public void EnableUI(object sender, EventArgs e)
+ {
+ if ((bool)enableCosineCalculationCheckBox.IsChecked)
+ {
+ cosineCorrectionSP.Visibility = Visibility.Visible;
+ cosineCorrectionSP.IsEnabled = true;
+ }
+ else
+ {
+ cosineCorrectionSP.Visibility = Visibility.Collapsed;
+ cosineCorrectionSP.IsEnabled = false;
+ }
+ }
+ }
+
class KeyenceChannel
{
public int channelID;
diff --git a/TwinCat Motion ADS/ImageAssets/COSINE.png b/TwinCat Motion ADS/ImageAssets/COSINE.png
new file mode 100644
index 0000000..dc1b211
Binary files /dev/null and b/TwinCat Motion ADS/ImageAssets/COSINE.png differ
diff --git a/TwinCat Motion ADS/Measurement Devices/MD_DigimaticIndicator.cs b/TwinCat Motion ADS/Measurement Devices/MD_DigimaticIndicator.cs
index 3a07cf5..9c5ea6d 100644
--- a/TwinCat Motion ADS/Measurement Devices/MD_DigimaticIndicator.cs
+++ b/TwinCat Motion ADS/Measurement Devices/MD_DigimaticIndicator.cs
@@ -3,6 +3,11 @@
using System.Collections.ObjectModel;
using System.Threading.Tasks;
using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Windows.Controls;
+using System.Windows.Media;
+using System.Windows;
namespace TwinCat_Motion_ADS.MeasurementDevice
{
@@ -26,10 +31,30 @@ public async Task GetChannelMeasurement(int channelNumber = 0)
string measurement;
CancellationTokenSource ct = new();
measurement = await ReadAsync("1", ct, readDelay, defaultTimeout);
+ if (EnableCosineCorrection)
+ {
+ measurement = Convert.ToString(CosineCorrectionValue * Convert.ToDouble(measurement));
+ }
return measurement;
}
public async Task GetMeasurement()
+ {
+ if (!Connected)
+ {
+ return "No device connected"; //Nothing to disconnect from
+ }
+ ReadInProgress = true;
+ string measurement;
+ CancellationTokenSource ct = new();
+ measurement = await ReadAsync("1", ct, readDelay, defaultTimeout);
+ if (EnableCosineCorrection)
+ {
+ measurement = Convert.ToString(CosineCorrectionValue * Convert.ToDouble(measurement));
+ }
+ return measurement;
+ }
+ public async Task GetMeasurement_Uncorrected()
{
if (!Connected)
{
@@ -73,7 +98,109 @@ public async Task ReadAsync(string cmd, CancellationTokenSource ct, int
}
}
+ #region get sets
+
+ public bool EnableCosineCorrection { get; set; }
+
+ private double cosineCorrectionValue = 1;
+ public double CosineCorrectionValue
+ {
+ get { return cosineCorrectionValue; }
+ set { cosineCorrectionValue = value; OnPropertyChanged(); }
+ }
+
+ private string initialValue;
+ public string InitialValue
+ {
+ get { return initialValue; }
+ set
+ {
+ if (double.TryParse(value, out _))
+ {
+ initialValue = value;
+ OnPropertyChanged();
+ }
+ }
+ }
+
+ private string distanceTraveled;
+ public string DistanceTraveled
+ {
+ get { return distanceTraveled; }
+ set
+ {
+ if (double.TryParse(value, out _))
+ {
+ distanceTraveled = value;
+ OnPropertyChanged();
+ }
+ }
+ }
+ private string finalValue;
+ public string FinalValue
+ {
+ get { return finalValue; }
+ set
+ {
+ if (double.TryParse(value, out _))
+ {
+ finalValue = value;
+ OnPropertyChanged();
+ }
+ }
+ }
+ #endregion
+
+ #region COSINE Correction
+ public void CalculateCosineCorrection(object sender, EventArgs e)
+ {
+ if (EnableCosineCorrection)
+ {
+ COSINECalculation(InitialValue, DistanceTraveled, FinalValue);
+ }
+ else
+ {
+ Console.WriteLine("COSIGNE Correction Not Enabled");
+ }
+
+ }
+ public void ResetCosineCalculation(object sender, EventArgs e)
+ {
+ InitialValue = "0";
+ DistanceTraveled = "1";
+ FinalValue = "1";
+ COSINECalculation(InitialValue, DistanceTraveled, FinalValue);
+ Console.WriteLine("COSINE Calculaion Reset");
+ }
+ public async void InitialValue_ReadIn(object sender, EventArgs e)
+ {
+ string measurement = await GetMeasurement_Uncorrected();
+ Console.WriteLine(Name + ": " + measurement);
+ InitialValue = measurement;
+ }
+ public async void FinalValue_ReadIn(object sender, EventArgs e)
+ {
+ string measurement = await GetMeasurement_Uncorrected();
+ Console.WriteLine(Name + ": " + measurement);
+ FinalValue = measurement;
+ }
+ public void COSINECalculation(string hypotenuse_point1, string hypotenuse_point2, string adjacent)
+ {
+ double hypotenuse = Math.Abs(Convert.ToDouble(hypotenuse_point2) - Convert.ToDouble(hypotenuse_point1));
+ double value = hypotenuse / Math.Abs(Convert.ToDouble(adjacent));
+ if (value > 1)
+ {
+ Console.WriteLine("Correction Ratio can NOT be greater than 1, value calculated = " + Convert.ToString(value));
+ }
+ else
+ {
+ CosineCorrectionValue = value;
+ Console.WriteLine("Correction Value : " + Convert.ToString(CosineCorrectionValue));
+ }
+
+ }
+ #endregion
public new bool Disconnect()
{
ChannelList.Clear();
diff --git a/TwinCat Motion ADS/TwinCat Motion ADS.csproj b/TwinCat Motion ADS/TwinCat Motion ADS.csproj
index 1109dec..f331121 100644
--- a/TwinCat Motion ADS/TwinCat Motion ADS.csproj
+++ b/TwinCat Motion ADS/TwinCat Motion ADS.csproj
@@ -32,6 +32,7 @@
+
@@ -55,6 +56,7 @@
+