diff --git a/uniper_hmi/Uniper.sln b/uniper_hmi/Infineon.sln similarity index 83% rename from uniper_hmi/Uniper.sln rename to uniper_hmi/Infineon.sln index a2ac41a..3de47d2 100644 --- a/uniper_hmi/Uniper.sln +++ b/uniper_hmi/Infineon.sln @@ -1,9 +1,9 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 18 -VisualStudioVersion = 18.2.11415.280 d18.0 +VisualStudioVersion = 18.2.11415.280 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UniperHMI", "UniperHMI\UniperHMI.csproj", "{8D725B27-1242-4C66-ACD8-45F02098C7D3}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "InfineonHMI", "UniperHMI\InfineonHMI.csproj", "{8D725B27-1242-4C66-ACD8-45F02098C7D3}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/uniper_hmi/UniperHMI/Anlagenuebersicht.png b/uniper_hmi/UniperHMI/Anlagenuebersicht.png new file mode 100644 index 0000000..cc2fd0c Binary files /dev/null and b/uniper_hmi/UniperHMI/Anlagenuebersicht.png differ diff --git a/uniper_hmi/UniperHMI/App.xaml b/uniper_hmi/UniperHMI/App.xaml index 4b8b9c0..9890229 100644 --- a/uniper_hmi/UniperHMI/App.xaml +++ b/uniper_hmi/UniperHMI/App.xaml @@ -1,7 +1,7 @@ - + xmlns:local="clr-namespace:InfineonHMI"> diff --git a/uniper_hmi/UniperHMI/App.xaml.cs b/uniper_hmi/UniperHMI/App.xaml.cs index 5ea07d7..4de6837 100644 --- a/uniper_hmi/UniperHMI/App.xaml.cs +++ b/uniper_hmi/UniperHMI/App.xaml.cs @@ -4,7 +4,7 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using TcEventLoggerAdsProxyLib; -namespace UniperHMI; +namespace InfineonHMI; public partial class App : Application { @@ -18,10 +18,6 @@ public partial class App : Application services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); services.AddSingleton(); }) .Build(); diff --git a/uniper_hmi/UniperHMI/Common/L4ItXmlSerializer.cs b/uniper_hmi/UniperHMI/Common/L4ItXmlSerializer.cs new file mode 100644 index 0000000..3ee37b3 --- /dev/null +++ b/uniper_hmi/UniperHMI/Common/L4ItXmlSerializer.cs @@ -0,0 +1,127 @@ +using System.IO; +using System.Reflection; +using System.Runtime.InteropServices; +using System.Text; +using System.Xml; +using System.Xml.Serialization; + +namespace InfineonHMI.Common +{ + public static class L4ItXmlSerializer + { + /// + /// Serializes an object. + /// + /// + /// + /// + /// + /// + + public static void SerializeObject(T serializableObject, string fileName, bool encrypt = false, string rootElementName = null) + { + if (string.IsNullOrEmpty(fileName)) + return; + + if (serializableObject == null) + return; + + XmlSerializer serializer; + if (rootElementName != null) + { + var xmlRoot = new XmlRootAttribute(rootElementName); + serializer = new XmlSerializer(serializableObject.GetType(), xmlRoot); + } + else + { + serializer = new XmlSerializer(serializableObject.GetType()); + } + + try + { + var dir = new FileInfo(fileName).DirectoryName; + if (dir != null && !Directory.Exists(dir)) // Überprüfen Sie, ob dir nicht null ist, bevor Sie es verwenden + Directory.CreateDirectory(dir); + + var xmlDocument = new XmlDocument(); + using var stream = new MemoryStream(); + serializer.Serialize(stream, serializableObject); + stream.Position = 0; + xmlDocument.Load(stream); + if (encrypt && false) + { + //FileEncryption.SaveEncryptedToFile(fileName, xmlDocument.OuterXml); + return; + } + xmlDocument.Save(fileName); + } + catch (Exception ex) + { + Console.Write(ex); + } + } + + + /// + /// Deserializes an xml file into an object list + /// + /// + /// + /// + /// + /// + /// + /// + public static T DeSerializeObject(string fileName, bool decrypt = false, string rootElementName = null) + { + if (string.IsNullOrEmpty(fileName) || !File.Exists(fileName)) return default!; + + T objectOut; + + try + { + string xmlString; + if (decrypt && false) + { + //xmlString = FileEncryption.ReadDecryptedFromFile(fileName)!; + } + else + { + var xmlDocument = new XmlDocument(); + xmlDocument.Load(fileName); + xmlString = xmlDocument.OuterXml; + } + + if (string.IsNullOrEmpty(xmlString)) + { + // Handle empty xmlString if necessary + return default!; + } + + using var read = new StringReader(xmlString); + var outType = typeof(T); + + XmlSerializer serializer; + if (rootElementName != null) + { + var root = new XmlRootAttribute(rootElementName); + serializer = new XmlSerializer(outType, root); + } + else + { + serializer = new XmlSerializer(outType); + } + + using XmlReader reader = new XmlTextReader(read); + objectOut = (T)serializer.Deserialize(reader)!; + } + catch (Exception ex) + { + Console.Write(ex); + return default!; + } + + return objectOut; + } + } +} diff --git a/uniper_hmi/UniperHMI/Common/MediaContainer.xaml b/uniper_hmi/UniperHMI/Common/MediaContainer.xaml new file mode 100644 index 0000000..6594243 --- /dev/null +++ b/uniper_hmi/UniperHMI/Common/MediaContainer.xaml @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/uniper_hmi_old/UniperHMI/HMIToolkit/HMIObjects/InterlockControl/IntlkControl.xaml.cs b/uniper_hmi_old/UniperHMI/HMIToolkit/HMIObjects/InterlockControl/IntlkControl.xaml.cs new file mode 100644 index 0000000..6f4ae19 --- /dev/null +++ b/uniper_hmi_old/UniperHMI/HMIToolkit/HMIObjects/InterlockControl/IntlkControl.xaml.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +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; + +namespace HMIToolkit +{ + /// + /// Interaktionslogik für ProcessIntlkButtonControl.xaml + /// + public partial class IntlkButtonControl : UserControl + { + public IntlkButtonControl() + { + InitializeComponent(); + // Unloaded += OnUnloaded; + } + + private void OnUnloaded(object? sender, EventArgs e) + { + var disposable = DataContext as IDisposable; + disposable?.Dispose(); + } + } +} diff --git a/uniper_hmi_old/UniperHMI/HMIToolkit/HMIObjects/InterlockControl/IntlkControlVM.cs b/uniper_hmi_old/UniperHMI/HMIToolkit/HMIObjects/InterlockControl/IntlkControlVM.cs new file mode 100644 index 0000000..8b66b64 --- /dev/null +++ b/uniper_hmi_old/UniperHMI/HMIToolkit/HMIObjects/InterlockControl/IntlkControlVM.cs @@ -0,0 +1,109 @@ +using CommunityToolkit.Mvvm.ComponentModel; +using CommunityToolkit.Mvvm.Input; +using TwinCAT.TypeSystem; +using Heisig.HMI.AdsManager; + +namespace HMIToolkit; + +public sealed partial class IntlkControlVM : ObservableObject, IDisposable +{ + [ObservableProperty] + private bool xProcessIntlkOk; + + [ObservableProperty] + private bool xSafetyIntlkOk; + + [ObservableProperty] + private IntlkDetailsVM safetyInterlocksVM; + + [ObservableProperty] + private IntlkDetailsVM processInterlocksVM; + + private IntlkDetailsWindow? processIntlksDetailsWindow; + private IntlkDetailsWindow? safetyIntlksDetailsWindow; + + private readonly string _variableName; + + private IAdsManager? _adsManager; + + public IntlkControlVM() + { + XProcessIntlkOk = false; + XSafetyIntlkOk = false; + _variableName = string.Empty; + safetyInterlocksVM = new(); + processInterlocksVM = new(); + } + + public IntlkControlVM(IAdsManager adsManager, string variableName) + { + _adsManager = adsManager; + _variableName = variableName; + + SafetyInterlocksVM = new IntlkDetailsVM(_adsManager, _variableName + ".wSafetyINTLKStatus", _variableName + ".asSafetyINTLKName", "Safety Interlock"); + ProcessInterlocksVM = new IntlkDetailsVM(_adsManager, _variableName + ".wProcessINTLKStatus", _variableName + ".asProcessINTLKName", "Process Interlock"); + + _adsManager.Register(_variableName + ".xProcessINTLKOk", ProcessIntlkOkChanged); + _adsManager.Register(_variableName + ".xSafetyINTLKOk", SafetyIntlkOkChanged); + } + + public void Dispose() + { + SafetyInterlocksVM.Dispose(); + ProcessInterlocksVM.Dispose(); + + _adsManager?.Deregister(_variableName + ".xProcessINTLKOk", ProcessIntlkOkChanged); + _adsManager?.Deregister(_variableName + ".xSafetyINTLKOk", SafetyIntlkOkChanged); + + processIntlksDetailsWindow?.Close(); + safetyIntlksDetailsWindow?.Close(); + + _adsManager = null; + } + + private void ProcessIntlkOkChanged(object? sender, ValueChangedEventArgs e) + { + XProcessIntlkOk = (bool)e.Value; + } + + private void SafetyIntlkOkChanged(object? sender, ValueChangedEventArgs e) + { + XSafetyIntlkOk = (bool)e.Value; + } + + [RelayCommand] + private void ShowProcessIntlks() + { + if (_adsManager != null && processIntlksDetailsWindow == null) + { + processIntlksDetailsWindow = new() { DataContext = ProcessInterlocksVM }; + processIntlksDetailsWindow.Closed += ProcessIntlksDetailsWindow_Closed; + processIntlksDetailsWindow.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen; + processIntlksDetailsWindow.Show(); + } + } + + private void ProcessIntlksDetailsWindow_Closed(object? sender, EventArgs e) + { + processIntlksDetailsWindow!.Close(); + processIntlksDetailsWindow = null; + } + + [RelayCommand] + private void ShowSafetyIntlks() + { + if (_adsManager != null && safetyIntlksDetailsWindow == null) + { + safetyIntlksDetailsWindow = new() { DataContext = SafetyInterlocksVM }; + safetyIntlksDetailsWindow.Closed += SafetyIntlksDetailsWindow_Closed; + safetyIntlksDetailsWindow.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen; + safetyIntlksDetailsWindow.Show(); + } + } + + private void SafetyIntlksDetailsWindow_Closed(object? sender, EventArgs e) + { + safetyIntlksDetailsWindow!.Close(); + safetyIntlksDetailsWindow = null; + } +} diff --git a/uniper_hmi_old/UniperHMI/HMIToolkit/HMIObjects/InterlockDetailsControl/IntlkDetails.xaml b/uniper_hmi_old/UniperHMI/HMIToolkit/HMIObjects/InterlockDetailsControl/IntlkDetails.xaml new file mode 100644 index 0000000..c45ae3d --- /dev/null +++ b/uniper_hmi_old/UniperHMI/HMIToolkit/HMIObjects/InterlockDetailsControl/IntlkDetails.xaml @@ -0,0 +1,132 @@ + + + + + + + + + + + + + + + + + diff --git a/uniper_hmi_old/UniperHMI/HMIToolkit/HMIObjects/InterlockDetailsControl/IntlkDetails.xaml.cs b/uniper_hmi_old/UniperHMI/HMIToolkit/HMIObjects/InterlockDetailsControl/IntlkDetails.xaml.cs new file mode 100644 index 0000000..b331460 --- /dev/null +++ b/uniper_hmi_old/UniperHMI/HMIToolkit/HMIObjects/InterlockDetailsControl/IntlkDetails.xaml.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +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; + +namespace HMIToolkit +{ + /// + /// Interaktionslogik für IntlkDetails.xaml + /// + public partial class IntlkDetails : UserControl + { + public IntlkDetails() + { + InitializeComponent(); + // Unloaded += OnUnloaded; + } + + private void OnUnloaded(object? sender, EventArgs e) + { + var disposable = DataContext as IDisposable; + disposable?.Dispose(); + } + } +} diff --git a/uniper_hmi_old/UniperHMI/HMIToolkit/HMIObjects/InterlockDetailsControl/IntlkDetailsVM.cs b/uniper_hmi_old/UniperHMI/HMIToolkit/HMIObjects/InterlockDetailsControl/IntlkDetailsVM.cs new file mode 100644 index 0000000..7f6b3aa --- /dev/null +++ b/uniper_hmi_old/UniperHMI/HMIToolkit/HMIObjects/InterlockDetailsControl/IntlkDetailsVM.cs @@ -0,0 +1,151 @@ +using CommunityToolkit.Mvvm.ComponentModel; +using System.Collections; +using System.Windows; +using System.Windows.Controls; +using TwinCAT.TypeSystem; +using Heisig.HMI.AdsManager; + +namespace HMIToolkit +{ + public sealed partial class IntlkDetailsVM : ObservableObject, IDisposable + { + [ObservableProperty] + private string interlockName; + + [ObservableProperty] + private BitArray interlockStatus; + + [ObservableProperty] + private string[] interlockNames; + + [ObservableProperty] + private ListBoxItem[] listBoxItemsLeft; + + [ObservableProperty] + private ListBoxItem[] listBoxItemsRight; + + [ObservableProperty] + private Visibility isVisible; + + private readonly BoolToBrushConverter boolToBrushConverter = new(); + + private readonly int numIntlksLeftSide; + private readonly int numIntlksRightSide; + + private readonly string _variableNameStatus; + private readonly string _variableNameNames; + + private IAdsManager? _adsManager; + + public IntlkDetailsVM() + { + interlockName = "Interlocks"; + interlockStatus = new BitArray(HMIConstants.NumInterlocks); + interlockNames = new string[HMIConstants.NumInterlocks]; + Array.Fill(interlockNames, "Not used"); + + // Split all interlocks into two parts + numIntlksLeftSide = (int)Math.Ceiling(HMIConstants.NumInterlocks * 0.5); + numIntlksRightSide = HMIConstants.NumInterlocks - numIntlksLeftSide; + + listBoxItemsLeft = new ListBoxItem[numIntlksLeftSide]; + listBoxItemsRight = new ListBoxItem[numIntlksRightSide]; + + _variableNameStatus = System.String.Empty; + _variableNameNames = System.String.Empty; + + // CreateContent(); + } + + public IntlkDetailsVM(IAdsManager adsManager, string variableNameStatus, string variableNameNames, string intlkName) : this() + { + interlockName = intlkName; + _variableNameStatus = variableNameStatus; + _variableNameNames = variableNameNames; + _adsManager = adsManager; + + interlockStatus = new BitArray(HMIConstants.NumInterlocks); + interlockNames = new string[HMIConstants.NumInterlocks]; + + _adsManager.Register(_variableNameStatus, InterlockStatusChanged); + _adsManager.Register(_variableNameNames, InterlockNamesChanged); + } + + public void Dispose() + { + _adsManager?.Deregister(_variableNameStatus, InterlockStatusChanged); + _adsManager?.Deregister(_variableNameNames, InterlockNamesChanged); + + _adsManager = null; + } + + /*private void CreateContent() + { + // Create left side + for (int i = 0; i < HMIConstants.NumInterlocks; i++) + { + // Create the stack panel + StackPanel stackPanel = new StackPanel + { + Orientation = Orientation.Horizontal + }; + + // Create the box + // + Rectangle rectangle = new Rectangle + { + Width = 10, + Height = 10, + RadiusX = 2, + RadiusY = 2 + }; + + // Create binding + Binding binding = new() + { + Source = this, + Path = new PropertyPath("InterlockStatus[" + i + "]"), + Converter = boolToBrushConverter, + }; + + // Set binding + rectangle.SetBinding(Rectangle.FillProperty, binding); + + // Create label + Label label = new(); + binding = new() + { + Source = this, + Path = new PropertyPath("InterlockNames[" + i + "]") + }; + label.SetBinding(Label.ContentProperty, binding); + + // Add items to stack panel + stackPanel.Children.Add(rectangle); + stackPanel.Children.Add(label); + + // Add stack panel to listbox items + ListBoxItem tempListBoxItem = new() + { + Content = stackPanel + }; + if (i < numIntlksLeftSide) + ListBoxItemsLeft[i] = tempListBoxItem; + else + ListBoxItemsRight[i - numIntlksLeftSide] = tempListBoxItem; + } + + }*/ + + private void InterlockStatusChanged(object? sender, ValueChangedEventArgs e) + { + ushort temp = (ushort)e.Value; + InterlockStatus = new BitArray(BitConverter.GetBytes(temp)); + } + + private void InterlockNamesChanged(object? sender, ValueChangedEventArgs e) + { + InterlockNames = (string[])e.Value; + } + } +} diff --git a/uniper_hmi_old/UniperHMI/HMIToolkit/HMIObjects/InterlockDetailsControl/IntlkDetailsWindow.xaml b/uniper_hmi_old/UniperHMI/HMIToolkit/HMIObjects/InterlockDetailsControl/IntlkDetailsWindow.xaml new file mode 100644 index 0000000..695641c --- /dev/null +++ b/uniper_hmi_old/UniperHMI/HMIToolkit/HMIObjects/InterlockDetailsControl/IntlkDetailsWindow.xaml @@ -0,0 +1,13 @@ + + + + + diff --git a/uniper_hmi_old/UniperHMI/HMIToolkit/HMIObjects/InterlockDetailsControl/IntlkDetailsWindow.xaml.cs b/uniper_hmi_old/UniperHMI/HMIToolkit/HMIObjects/InterlockDetailsControl/IntlkDetailsWindow.xaml.cs new file mode 100644 index 0000000..f1bb72d --- /dev/null +++ b/uniper_hmi_old/UniperHMI/HMIToolkit/HMIObjects/InterlockDetailsControl/IntlkDetailsWindow.xaml.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +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.Shapes; + +namespace HMIToolkit +{ + /// + /// Interaktionslogik für IntlkDetailsWindow.xaml + /// + public partial class IntlkDetailsWindow : Window + { + public IntlkDetailsWindow() + { + InitializeComponent(); + } + } +} diff --git a/uniper_hmi_old/UniperHMI/HMIToolkit/HMIObjects/structures/HMIDataTypes.cs b/uniper_hmi_old/UniperHMI/HMIToolkit/HMIObjects/structures/HMIDataTypes.cs new file mode 100644 index 0000000..332eb81 --- /dev/null +++ b/uniper_hmi_old/UniperHMI/HMIToolkit/HMIObjects/structures/HMIDataTypes.cs @@ -0,0 +1,218 @@ +using System.Runtime.InteropServices; +using System.Text; + +namespace HMIToolkit +{ + // PLC - C# + // -------- + // int - short + // word - ushort + + // Constants for interaction with data + public static class HMIConstants + { + public const int StringLength = 81; + public const int NumInterlocks = 16; + } + + + [StructLayout(LayoutKind.Sequential, Pack = 0)] + public struct HMIAnalogValue + { + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = HMIConstants.StringLength)] + public string sName; + + // 1 = Ok, 2 = Error + public short iStatus; + + public float rValue; + + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = HMIConstants.StringLength)] + public string sUnit; + + [MarshalAs(UnmanagedType.I1)] + public bool xUsed; + } + + // TwinCAT2 Pack = 1, TwinCAT 3 Pack = 0 + [StructLayout(LayoutKind.Sequential, Pack = 0)] + public struct HMIControlButton + { + [MarshalAs(UnmanagedType.I1)] + public bool xRequest; + + [MarshalAs(UnmanagedType.I1)] + public bool xRelease; + + public short iFeedback; + } + + // TwinCAT2 Pack = 1, TwinCAT 3 Pack = 0 + [StructLayout(LayoutKind.Sequential, Pack = 0)] + public struct HMIInterlock + { + public ushort wProcessINTLKStatus; + + public ushort wSafeyINTLKStatus; + + public ushort wProcessINTLKUsed; + + public ushort wSafeyINTLKUsed; + + // 16 * String(80) = 81 bytes a 16 indexes + // combined in one string because reading a two dimensional array is not possible + [MarshalAs(UnmanagedType.ByValArray, SizeConst = HMIConstants.StringLength * HMIConstants.NumInterlocks)] + public byte[] asProcessINTLKName; + + // 16 * String(80) = 81 bytes a 16 indexes + // combined in one string because reading a two dimensional array is not possible + [MarshalAs(UnmanagedType.ByValArray, SizeConst = HMIConstants.StringLength * HMIConstants.NumInterlocks)] + public byte[] asSafetyINTLKName; + + [MarshalAs(UnmanagedType.I1)] + public bool xProcessINTLKOk; + + [MarshalAs(UnmanagedType.I1)] + public bool xSafetyINTLKOk; + } + + // TwinCAT2 Pack = 1, TwinCAT 3 Pack = 0 + [StructLayout(LayoutKind.Sequential, Pack = 0)] + public struct HMIValveData + { + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = HMIConstants.StringLength)] + public string sName; + + public HMIControlButton stAutomaticButton; + + public HMIControlButton stManualButton; + + public HMIControlButton stOpenButton; + + public HMIControlButton stCloseButton; + + // 1 = Opened, 2 = Opening/Closing, 3 = Closed, 4 = Error + public short iStatus; + + // 1 = Automatic mode, 2 = Manual mode + public short iCurrentMode; + + public HMIInterlock stInterlock; + + [MarshalAs(UnmanagedType.I1)] + public bool xUsed; + } + + [StructLayout(LayoutKind.Sequential, Pack = 0)] + public struct HMIAnalogValveData + { + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = HMIConstants.StringLength)] + public string sName; + + public HMIControlButton stAutomaticButton; + + public HMIControlButton stManualButton; + + public HMIControlButton stOpenButton; + + public HMIControlButton stCloseButton; + + // 1 = Opened, 2 = Opening/Closing, 3 = Closed, 4 = Error + public short iStatus; + + // 1 = Automatic mode, 2 = Manual mode + public short iCurrentMode; + + public HMIInterlock stInterlock; + + HMIAnalogValue stSetpoint; + + HMIAnalogValue stProcessValue; + + [MarshalAs(UnmanagedType.I1)] + public bool xUsed; + } + + // TwinCAT2 Pack = 1, TwinCAT 3 Pack = 0 + [StructLayout(LayoutKind.Sequential, Pack = 0)] + public struct HMIAnalogMotorData + { + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = HMIConstants.StringLength)] + public string sName; + + public HMIControlButton stAutomaticButton; + + public HMIControlButton stManualButton; + + public HMIControlButton stStartButton; + + public HMIControlButton stStopButton; + + // 1 = Opened, 2 = Opening/Closing, 3 = Closed, 4 = Error + public short iStatus; + + // 1 = Automatic mode, 2 = Manual mode + public short iCurrentMode; + + public HMIAnalogValue stSetpoint; + + public HMIAnalogValue stProcessValue; + + public HMIInterlock stInterlock; + + [MarshalAs(UnmanagedType.I1)] + public bool xUsed; + } + + // TwinCAT2 Pack = 1, TwinCAT 3 Pack = 0 + [StructLayout(LayoutKind.Sequential, Pack = 0)] + public struct HMIOrpSensorData + { + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = HMIConstants.StringLength)] + public string sName; + + // 1 = Ok, 2 = Error + public short iStatus; + + public float rValuePH; + + public float rValueTemp; + + public float rValueORP; + + public float rValueDLI; + + [MarshalAs(UnmanagedType.I1)] + public bool xUsed; + } + + static class HMIUtilities + { + // Converts the interlock byte array into a string array + public static string[] GetInterlockStringArray(byte[] byteArray) + { + string[] temp = new string[HMIConstants.NumInterlocks]; + int size; + + // Check if byteArray is of correct size + if (byteArray.Length != (HMIConstants.StringLength * HMIConstants.NumInterlocks)) + return temp; + + for (int i = 0; i < HMIConstants.NumInterlocks; i++) + { + // Calculate length of string by finding the 0 terminator so the unused bytes get truncated + size = Array.IndexOf(byteArray, (byte)0, i * HMIConstants.StringLength) - (i * HMIConstants.StringLength); + + // Check if we found a valid 0 terminator + if (size >= 0) + // Build string from byteArray with calculated size + temp[i] = Encoding.ASCII.GetString(byteArray, i * HMIConstants.StringLength, size); + else + // No valid 0 string terminator was found so return an empty string + temp[i] = ""; + } + + return temp; + } + } +} \ No newline at end of file diff --git a/uniper_hmi_old/UniperHMI/InfineonHMI.csproj b/uniper_hmi_old/UniperHMI/InfineonHMI.csproj new file mode 100644 index 0000000..b1d2dda --- /dev/null +++ b/uniper_hmi_old/UniperHMI/InfineonHMI.csproj @@ -0,0 +1,79 @@ + + + + WinExe + net8.0-windows8.0 + enable + enable + true + 0.1.0 + 0.1 + AnyCPU;x64 + False + + + + + + + + + + + + + + + + + + bin\x64\Debug\net8.0-windows8.0\AdsManager.dll + + + + + + Always + + + + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + + + + PreserveNewest + + + + diff --git a/uniper_hmi_old/UniperHMI/MainWindow.xaml b/uniper_hmi_old/UniperHMI/MainWindow.xaml new file mode 100644 index 0000000..79b1fa6 --- /dev/null +++ b/uniper_hmi_old/UniperHMI/MainWindow.xaml @@ -0,0 +1,190 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/uniper_hmi_old/UniperHMI/OwnControls/Views/SMUControlButton.xaml.cs b/uniper_hmi_old/UniperHMI/OwnControls/Views/SMUControlButton.xaml.cs new file mode 100644 index 0000000..96d038a --- /dev/null +++ b/uniper_hmi_old/UniperHMI/OwnControls/Views/SMUControlButton.xaml.cs @@ -0,0 +1,23 @@ +using System.Windows; +using System.Windows.Controls; + +namespace InfineonHMI +{ + /// + /// Interaktionslogik für StringControlButton.xaml + /// + public partial class SMUControlButton : Button + { + public static readonly DependencyProperty SMUNameProperty = DependencyProperty.Register("SMUName", typeof(string), typeof(SMUControlButton)); + public String SMUName + { + get { return (string)GetValue(SMUNameProperty); } + set { SetValue(SMUNameProperty, value); } + } + + public SMUControlButton() + { + InitializeComponent(); + } + } +} diff --git a/uniper_hmi_old/UniperHMI/OwnControls/Views/UnitDetailsControl.xaml b/uniper_hmi_old/UniperHMI/OwnControls/Views/UnitDetailsControl.xaml new file mode 100644 index 0000000..976067f --- /dev/null +++ b/uniper_hmi_old/UniperHMI/OwnControls/Views/UnitDetailsControl.xaml @@ -0,0 +1,138 @@ + + + + + + + + + + + + + + + + + + + diff --git a/uniper_hmi_old/UniperHMI/Pages/Views/MachineOverviewPage.xaml.cs b/uniper_hmi_old/UniperHMI/Pages/Views/MachineOverviewPage.xaml.cs new file mode 100644 index 0000000..fa8f63c --- /dev/null +++ b/uniper_hmi_old/UniperHMI/Pages/Views/MachineOverviewPage.xaml.cs @@ -0,0 +1,22 @@ +using System.Windows.Controls; + +namespace InfineonHMI +{ + /// + /// Interaktionslogik für AutomaticModePage.xaml + /// + public partial class MachineOverviewPage : Page + { + public MachineOverviewPage() + { + InitializeComponent(); + // Unloaded += OnUnloaded; + } + + private void OnUnloaded(object? sender, EventArgs e) + { + var disposable = DataContext as IDisposable; + disposable?.Dispose(); + } + } +} diff --git a/uniper_hmi_old/UniperHMI/Pages/Views/MediaCabinetPage.xaml b/uniper_hmi_old/UniperHMI/Pages/Views/MediaCabinetPage.xaml new file mode 100644 index 0000000..574006c --- /dev/null +++ b/uniper_hmi_old/UniperHMI/Pages/Views/MediaCabinetPage.xaml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + diff --git a/uniper_hmi_old/UniperHMI/Pages/Views/MediaCabinetPage.xaml.cs b/uniper_hmi_old/UniperHMI/Pages/Views/MediaCabinetPage.xaml.cs new file mode 100644 index 0000000..d5853dd --- /dev/null +++ b/uniper_hmi_old/UniperHMI/Pages/Views/MediaCabinetPage.xaml.cs @@ -0,0 +1,22 @@ +using System.Windows.Controls; + +namespace InfineonHMI +{ + /// + /// Interaktionslogik für AutomaticModePage.xaml + /// + public partial class MediaCabinetPage : Page + { + public MediaCabinetPage() + { + InitializeComponent(); + // Unloaded += OnUnloaded; + } + + private void OnUnloaded(object? sender, EventArgs e) + { + var disposable = DataContext as IDisposable; + disposable?.Dispose(); + } + } +} diff --git a/uniper_hmi/UniperHMI/Pages/Views/ModuleOverviewPage.xaml b/uniper_hmi_old/UniperHMI/Pages/Views/ModuleOverviewPage.xaml similarity index 100% rename from uniper_hmi/UniperHMI/Pages/Views/ModuleOverviewPage.xaml rename to uniper_hmi_old/UniperHMI/Pages/Views/ModuleOverviewPage.xaml diff --git a/uniper_hmi/UniperHMI/Pages/Views/ModuleOverviewPage.xaml.cs b/uniper_hmi_old/UniperHMI/Pages/Views/ModuleOverviewPage.xaml.cs similarity index 100% rename from uniper_hmi/UniperHMI/Pages/Views/ModuleOverviewPage.xaml.cs rename to uniper_hmi_old/UniperHMI/Pages/Views/ModuleOverviewPage.xaml.cs diff --git a/uniper_hmi_old/UniperHMI/Pages/Views/NIOStationPage.xaml b/uniper_hmi_old/UniperHMI/Pages/Views/NIOStationPage.xaml new file mode 100644 index 0000000..662da4b --- /dev/null +++ b/uniper_hmi_old/UniperHMI/Pages/Views/NIOStationPage.xaml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/uniper_hmi_old/UniperHMI/Pages/Views/ReceipePage.xaml.cs b/uniper_hmi_old/UniperHMI/Pages/Views/ReceipePage.xaml.cs new file mode 100644 index 0000000..875c4e2 --- /dev/null +++ b/uniper_hmi_old/UniperHMI/Pages/Views/ReceipePage.xaml.cs @@ -0,0 +1,15 @@ +using System.Windows.Controls; + +namespace InfineonHMI.Pages.Views +{ + /// + /// Receipes Overview Page + /// + public partial class ReceipePage : Page + { + public ReceipePage() + { + InitializeComponent(); + } + } +} diff --git a/uniper_hmi/UniperHMI/Pages/Views/StringOverviewPage.xaml b/uniper_hmi_old/UniperHMI/Pages/Views/StringOverviewPage.xaml similarity index 100% rename from uniper_hmi/UniperHMI/Pages/Views/StringOverviewPage.xaml rename to uniper_hmi_old/UniperHMI/Pages/Views/StringOverviewPage.xaml diff --git a/uniper_hmi/UniperHMI/Pages/Views/StringOverviewPage.xaml.cs b/uniper_hmi_old/UniperHMI/Pages/Views/StringOverviewPage.xaml.cs similarity index 100% rename from uniper_hmi/UniperHMI/Pages/Views/StringOverviewPage.xaml.cs rename to uniper_hmi_old/UniperHMI/Pages/Views/StringOverviewPage.xaml.cs diff --git a/uniper_hmi_old/UniperHMI/Pages/Views/TrayFeederPage.xaml b/uniper_hmi_old/UniperHMI/Pages/Views/TrayFeederPage.xaml new file mode 100644 index 0000000..948a325 --- /dev/null +++ b/uniper_hmi_old/UniperHMI/Pages/Views/TrayFeederPage.xaml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/uniper_hmi_old/UniperHMI/Pages/Views/TrayFeederPage.xaml.cs b/uniper_hmi_old/UniperHMI/Pages/Views/TrayFeederPage.xaml.cs new file mode 100644 index 0000000..b3140f2 --- /dev/null +++ b/uniper_hmi_old/UniperHMI/Pages/Views/TrayFeederPage.xaml.cs @@ -0,0 +1,16 @@ +using System.Windows.Controls; + +namespace InfineonHMI +{ + /// + /// Interaktionslogik für AutomaticModePage.xaml + /// + public partial class TrayFeederPage : Page + { + public TrayFeederPage() + { + InitializeComponent(); + } + + } +} diff --git a/uniper_hmi/UniperHMI/Pages/Views/UnitOverviewPage.xaml b/uniper_hmi_old/UniperHMI/Pages/Views/UnitOverviewPage.xaml similarity index 100% rename from uniper_hmi/UniperHMI/Pages/Views/UnitOverviewPage.xaml rename to uniper_hmi_old/UniperHMI/Pages/Views/UnitOverviewPage.xaml diff --git a/uniper_hmi/UniperHMI/Pages/Views/UnitOverviewPage.xaml.cs b/uniper_hmi_old/UniperHMI/Pages/Views/UnitOverviewPage.xaml.cs similarity index 100% rename from uniper_hmi/UniperHMI/Pages/Views/UnitOverviewPage.xaml.cs rename to uniper_hmi_old/UniperHMI/Pages/Views/UnitOverviewPage.xaml.cs diff --git a/uniper_hmi_old/UniperHMI/SettingsPage/SettingsPage.xaml b/uniper_hmi_old/UniperHMI/SettingsPage/SettingsPage.xaml new file mode 100644 index 0000000..c9019d0 --- /dev/null +++ b/uniper_hmi_old/UniperHMI/SettingsPage/SettingsPage.xaml @@ -0,0 +1,52 @@ + + + + + + + + + + +