Initial Push

This commit is contained in:
2026-02-11 08:38:36 +01:00
commit 627050501d
81 changed files with 5500 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
<UserControl x:Class="HMIToolkit.IntlkButtonControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:HMIToolkit"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance Type=local:IntlkControlVM, IsDesignTimeCreatable=True}"
d:DesignHeight="35" d:DesignWidth="175">
<UserControl.Resources>
<local:BoolToBrushConverter x:Key="myBoolConverter" />
</UserControl.Resources>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Button Grid.Column="0" Padding="0" Command="{Binding ShowProcessIntlksCommand}">
<StackPanel Orientation="Horizontal">
<Label>Process</Label>
<Rectangle Width="10" Height="10" Fill="{Binding Path=XProcessIntlkOk, Converter={StaticResource myBoolConverter}}" RadiusX="2" RadiusY="2" Margin="0,2,0,0"/>
</StackPanel>
</Button>
<Button Grid.Column="1" Padding="0" Margin="5,0,0,0" Command="{Binding ShowSafetyIntlksCommand}">
<StackPanel Orientation="Horizontal">
<Label>Safety</Label>
<Rectangle Width="10" Height="10" Fill="{Binding Path=XSafetyIntlkOk, Converter={StaticResource myBoolConverter}}" RadiusX="2" RadiusY="2" Margin="0,2,0,0"/>
</StackPanel>
</Button>
</Grid>
</UserControl>

View File

@@ -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
{
/// <summary>
/// Interaktionslogik für ProcessIntlkButtonControl.xaml
/// </summary>
public partial class IntlkButtonControl : UserControl
{
public IntlkButtonControl()
{
InitializeComponent();
// Unloaded += OnUnloaded;
}
private void OnUnloaded(object? sender, EventArgs e)
{
var disposable = DataContext as IDisposable;
disposable?.Dispose();
}
}
}

View File

@@ -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;
}
}