Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions Renishaw_XL80_App/Renishaw_XL80_App.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
<ItemGroup>
<Reference Include="DeviceStream, Version=1.3.5514.20171, Culture=neutral, PublicKeyToken=a36aeb8c02b07f33, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\Documents\LaserAPI 1.16\Examples\bin\LaserServiceWinFormsDemo\x64\Release\DeviceStream.dll</HintPath>
<HintPath>bin\debug\DeviceStream.dll</HintPath>
</Reference>
<Reference Include="Interop.DX10SERVERLib">
<HintPath>bin\Debug\Interop.DX10SERVERLib.dll</HintPath>
Expand All @@ -78,6 +78,9 @@
<Reference Include="LaserApi">
<HintPath>..\..\..\..\..\Documents\LaserAPI 1.16\Examples\bin\LaserServiceWinFormsDemo\x64\Release\LaserApi.dll</HintPath>
</Reference>
<Reference Include="LocalHost">
<HintPath>bin\debug\LocalHost.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Expression.Drawing">
<HintPath>..\..\..\..\..\..\..\Program Files\Renishaw CARTO\Capture\Microsoft.Expression.Drawing.dll</HintPath>
</Reference>
Expand Down Expand Up @@ -116,31 +119,34 @@
<Reference Include="PresentationFramework" />
<Reference Include="Renishaw.Calibration, Version=1.33.7690.18690, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\Documents\LaserAPI 1.16\Examples\bin\LaserServiceWinFormsDemo\x64\Release\NEW DLL VERSIONS\Renishaw.Calibration.dll</HintPath>
<HintPath>bin\debug\Renishaw.Calibration.dll</HintPath>
</Reference>
<Reference Include="Renishaw.Calibration.Devices, Version=1.12.8105.16839, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\Documents\LaserAPI 1.16\Examples\bin\LaserServiceWinFormsDemo\x64\Release\NEW DLL VERSIONS\Renishaw.Calibration.Devices.dll</HintPath>
</Reference>
<Reference Include="Renishaw.Calibration.ServiceModel, Version=1.1.5514.20171, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\Documents\LaserAPI 1.16\Examples\bin\LaserServiceWinFormsDemo\x64\Release\Renishaw.Calibration.ServiceModel.dll</HintPath>
<HintPath>bin\debug\Renishaw.Calibration.ServiceModel.dll</HintPath>
</Reference>
<Reference Include="Renishaw.IO, Version=1.24.7690.18693, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\Documents\LaserAPI 1.16\Examples\bin\LaserServiceWinFormsDemo\x64\Release\NEW DLL VERSIONS\Renishaw.IO.dll</HintPath>
<HintPath>bin\debug\Renishaw.IO.dll</HintPath>
</Reference>
<Reference Include="Renishaw.IO.Bluetooth, Version=1.0.8105.16835, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\Documents\LaserAPI 1.16\Examples\bin\LaserServiceWinFormsDemo\x64\Release\Renishaw.IO.Bluetooth.dll</HintPath>
</Reference>
<Reference Include="RenishawDX10Service">
<HintPath>bin\debug\RenishawDX10Service.dll</HintPath>
</Reference>
<Reference Include="RenishawLaserService, Version=1.10.5514.20180, Culture=neutral, processorArchitecture=x86">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\Documents\LaserAPI 1.16\Examples\bin\LaserServiceWinFormsDemo\x64\Release\RenishawLaserService.dll</HintPath>
<HintPath>bin\debug\RenishawLaserService.dll</HintPath>
</Reference>
<Reference Include="RenishawWeatherStationService, Version=1.4.5514.20180, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\Documents\LaserAPI 1.16\Examples\bin\LaserServiceWinFormsDemo\x64\Release\RenishawWeatherStationService.dll</HintPath>
<HintPath>bin\debug\RenishawWeatherStationService.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
Expand Down Expand Up @@ -175,19 +181,19 @@
</Reference>
<Reference Include="UsbIo, Version=1.1.5514.20175, Culture=neutral, processorArchitecture=x86">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\Documents\LaserAPI 1.16\Examples\bin\LaserServiceWinFormsDemo\x64\Release\UsbIo.dll</HintPath>
<HintPath>bin\debug\UsbIo.dll</HintPath>
</Reference>
<Reference Include="UsbTmc, Version=1.1.5514.20179, Culture=neutral, processorArchitecture=x86">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\Documents\LaserAPI 1.16\Examples\bin\LaserServiceWinFormsDemo\x64\Release\UsbTmc.dll</HintPath>
<HintPath>bin\debug\UsbTmc.dll</HintPath>
</Reference>
<Reference Include="WindowsBase" />
<Reference Include="WpfAnimatedGif, Version=2.0.0.0, Culture=neutral, PublicKeyToken=9e7cd3b544a090dc, processorArchitecture=MSIL">
<HintPath>..\packages\WpfAnimatedGif.2.0.2\lib\net40\WpfAnimatedGif.dll</HintPath>
</Reference>
<Reference Include="XLLaserSystem, Version=1.13.5514.20180, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\Documents\LaserAPI 1.16\Examples\bin\LaserServiceWinFormsDemo\x64\Release\XLLaserSystem.dll</HintPath>
<HintPath>bin\debug\XLLaserSystem.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
Expand Down
103 changes: 103 additions & 0 deletions TwinCat Motion ADS/APPLICATION WINDOWS/measurementDeviceWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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;
Expand Down
Binary file added TwinCat Motion ADS/ImageAssets/COSINE.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
127 changes: 127 additions & 0 deletions TwinCat Motion ADS/Measurement Devices/MD_DigimaticIndicator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -26,10 +31,30 @@ public async Task<string> 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<string> 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<string> GetMeasurement_Uncorrected()
{
if (!Connected)
{
Expand Down Expand Up @@ -73,7 +98,109 @@ public async Task<string> 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();
Expand Down
2 changes: 2 additions & 0 deletions TwinCat Motion ADS/TwinCat Motion ADS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<None Remove="APPLICATION WINDOWS\Unidirectional.png" />
<None Remove="babyIbex.jpg" />
<None Remove="ibexHead.jpg" />
<None Remove="ImageAssets\COSINE.png" />
</ItemGroup>

<ItemGroup>
Expand All @@ -55,6 +56,7 @@
<Resource Include="APPLICATION WINDOWS\Help screen windows\ImageAssets\Scaling.png" />
<Resource Include="APPLICATION WINDOWS\Help screen windows\ImageAssets\Unidirectional.png" />
<Resource Include="ImageAssets\babyIbex.jpg" />
<Resource Include="ImageAssets\COSINE.png" />
<Resource Include="ImageAssets\ibexHead.jpg" />
</ItemGroup>

Expand Down