Initial Push
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
<UserControl xmlns:AnalogValue="clr-namespace:HMIToolkit" x:Class="HMIToolkit.AnalogValveControl"
|
||||
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:AnalogValveControlVM, IsDesignTimeCreatable=True}"
|
||||
Width="Auto"
|
||||
Height="Auto">
|
||||
<d:DesignerProperties.DesignStyle>
|
||||
<Style TargetType="UserControl">
|
||||
<!-- Property="Background" Value="White" /> -->
|
||||
<Setter Property="Height" Value="Auto" />
|
||||
<Setter Property="Width" Value="Auto" />
|
||||
</Style>
|
||||
</d:DesignerProperties.DesignStyle>
|
||||
<Grid>
|
||||
<Grid Margin="5" ShowGridLines="False">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<!-- Row 0 -->
|
||||
<Label Grid.Row="0" Content="{Binding SName}" HorizontalAlignment="Center" FontSize="24" FontWeight="Bold"/>
|
||||
|
||||
<!-- Row 1 -->
|
||||
<Label Grid.Row="1" Content="Interlocks:" Margin="0,0,0,-3"/>
|
||||
|
||||
<!-- Row 2 -->
|
||||
<Grid Grid.Row="2">
|
||||
<local:IntlkButtonControl DataContext="{Binding Interlocks}"/>
|
||||
</Grid>
|
||||
|
||||
<!-- Row 3 -->
|
||||
<Label Grid.Row="3" Content="Setpoint:" Margin="0,0,0,-3"/>
|
||||
|
||||
<!-- Row 4 -->
|
||||
<AnalogValue:AnalogValue DataContext="{Binding Setpoint}" Grid.Row="4"/>
|
||||
|
||||
<!-- Row 5 -->
|
||||
<Label Grid.Row="5" Content="Process value:" Margin="0,0,0,-3"/>
|
||||
|
||||
<!-- Row 6 -->
|
||||
<AnalogValue:AnalogValue DataContext="{Binding ProcessValue}" Grid.Row="6"/>
|
||||
|
||||
<!-- Row 7 -->
|
||||
<Grid Grid.Row="7">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Label Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" Content="Control:" Margin="0,0,0,-3" />
|
||||
<Button x:Name="btnOpen" DataContext="{Binding OpenButton}" Command="{Binding ButtonClickedCommand}" IsEnabled="{Binding XRelease}" Grid.Row="1" Grid.Column="0" Content="Open" Height="80" Width="80" Margin="0,0,5,5" />
|
||||
<Button x:Name="btnClose" DataContext="{Binding CloseButton}" Command="{Binding ButtonClickedCommand}" IsEnabled="{Binding XRelease}" Grid.Row="1" Grid.Column="1" Content="Close" Height="80" Width="80" Margin="0,-5,0,0"/>
|
||||
</Grid>
|
||||
|
||||
<!-- Row 8 -->
|
||||
<Grid Grid.Row="8">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Label Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" Content="Mode:" Margin="0,0,0,-3" />
|
||||
<Button x:Name="btnAuto" DataContext="{Binding AutomaticButton}" Command="{Binding ButtonClickedCommand}" IsEnabled="{Binding XRelease}" Grid.Row="1" Grid.Column="0" Content="Auto" Height="80" Width="80" Margin="0,0,5,0"/>
|
||||
<Button x:Name="btnManual" DataContext="{Binding ManualButton}" Command="{Binding ButtonClickedCommand}" IsEnabled="{Binding XRelease}" Grid.Row="1" Grid.Column="1" Content="Man" Height="80" Width="80" Margin="0,-5,0,-5"/>
|
||||
</Grid>
|
||||
|
||||
</Grid>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -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 AnalogValveControl.xaml
|
||||
/// </summary>
|
||||
public partial class AnalogValveControl : UserControl
|
||||
{
|
||||
public AnalogValveControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
// Unloaded += OnUnloaded;
|
||||
}
|
||||
|
||||
private void OnUnloaded(object? sender, EventArgs e)
|
||||
{
|
||||
var disposable = DataContext as IDisposable;
|
||||
disposable?.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using TwinCAT.TypeSystem;
|
||||
using Heisig.HMI.AdsManager;
|
||||
|
||||
namespace HMIToolkit
|
||||
{
|
||||
public sealed partial class AnalogValveControlVM : ObservableObject
|
||||
{
|
||||
[ObservableProperty]
|
||||
private string sName = "No Name";
|
||||
|
||||
public HMIControlButtonVM? AutomaticButton { get; private set; }
|
||||
public HMIControlButtonVM? ManualButton { get; private set; }
|
||||
public HMIControlButtonVM? OpenButton { get; private set; }
|
||||
public HMIControlButtonVM? CloseButton { get; private set; }
|
||||
public IntlkControlVM? Interlocks { get; private set; }
|
||||
public AnalogValueVM? Setpoint { get; private set; }
|
||||
public AnalogValueVM? ProcessValue { get; private set; }
|
||||
|
||||
private readonly string? _variableName;
|
||||
|
||||
private IAdsManager? _adsManager;
|
||||
|
||||
public AnalogValveControlVM()
|
||||
{
|
||||
AutomaticButton = new HMIControlButtonVM();
|
||||
ManualButton = new HMIControlButtonVM();
|
||||
OpenButton = new HMIControlButtonVM();
|
||||
CloseButton = new HMIControlButtonVM();
|
||||
Interlocks = new IntlkControlVM();
|
||||
Setpoint = new AnalogValueVM();
|
||||
ProcessValue = new AnalogValueVM();
|
||||
}
|
||||
|
||||
public AnalogValveControlVM(IAdsManager adsManager, string variableName)
|
||||
{
|
||||
_adsManager = adsManager;
|
||||
_variableName = variableName;
|
||||
AutomaticButton = new HMIControlButtonVM(_adsManager, _variableName + ".stAutomaticButton");
|
||||
ManualButton = new HMIControlButtonVM(_adsManager, _variableName + ".stManualButton");
|
||||
OpenButton = new HMIControlButtonVM(_adsManager, _variableName + ".stOpenButton");
|
||||
CloseButton = new HMIControlButtonVM(_adsManager, _variableName + ".stCloseButton");
|
||||
Interlocks = new IntlkControlVM(_adsManager, _variableName + ".stInterlock");
|
||||
Setpoint = new AnalogValueVM(_adsManager, _variableName + ".stSetpoint", false);
|
||||
ProcessValue = new AnalogValueVM(_adsManager, _variableName + ".stProcessValue", true);
|
||||
|
||||
|
||||
_adsManager.Register(_variableName + ".sName", NameChanged);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_adsManager?.Deregister(_variableName + ".sName", NameChanged);
|
||||
_adsManager = null;
|
||||
|
||||
AutomaticButton?.Dispose();
|
||||
AutomaticButton = null;
|
||||
|
||||
ManualButton?.Dispose();
|
||||
ManualButton = null;
|
||||
|
||||
OpenButton?.Dispose();
|
||||
OpenButton = null;
|
||||
|
||||
CloseButton?.Dispose();
|
||||
CloseButton = null;
|
||||
|
||||
Interlocks?.Dispose();
|
||||
Interlocks = null;
|
||||
|
||||
Setpoint?.Dispose();
|
||||
Setpoint = null;
|
||||
|
||||
ProcessValue?.Dispose();
|
||||
ProcessValue = null;
|
||||
}
|
||||
|
||||
private void NameChanged(object? sender, ValueChangedEventArgs e)
|
||||
{
|
||||
SName = (string)e.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user