Add actuator buttons

This commit is contained in:
2026-07-09 10:18:29 +02:00
parent 68cbcef053
commit a6c876bd13
3 changed files with 382 additions and 4 deletions
+76 -2
View File
@@ -5,7 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:PamhagenSysCtrl"
mc:Ignorable="d"
Title="MainWindow" Height="520" Width="800">
Title="MainWindow" Height="550" Width="860">
<Grid>
<TextBox x:Name="PortInput" Text="COM1"
Margin="10,10,10,10" VerticalAlignment="Top" HorizontalAlignment="Left" Height="25" Width="80" FontSize="14" Padding="2,2,2,2"/>
@@ -13,10 +13,84 @@
Margin="100,10,10,10" VerticalAlignment="Top" HorizontalAlignment="Left" Height="25" Width="80" FontSize="14"
Click="ConnectButton_Click"/>
<Grid x:Name="ButtonPanel" Margin="5,50,5,5">
<Grid x:Name="ValvePanel" Margin="5,50,5,5">
</Grid>
<TextBlock x:Name="Status" FontSize="14"
Margin="350,50,10,10" VerticalAlignment="Top" HorizontalAlignment="Left"/>
<Grid x:Name="ActuatorPanel" Margin="350,350,5,5">
<Button x:Name="TroughAugerButton" Content="Trogschnecke" Padding="2" Height="30" Width="120"
FontSize="14" BorderThickness="2" FontWeight="Bold"
Margin="10,10,10,10" VerticalAlignment="Top" HorizontalAlignment="Left"
Click="TroughAugerButton_Click"/>
<Button x:Name="ReblerButton" Content="Rebler" Padding="2" Height="30" Width="120"
FontSize="14" BorderThickness="2" FontWeight="Bold"
Margin="10,45,10,10" VerticalAlignment="Top" HorizontalAlignment="Left"
Click="ReblerButton_Click"/>
<Button x:Name="StirrerA1Button" Content="Rührer A1" Padding="2" Height="30" Width="120"
FontSize="14" BorderThickness="2" FontWeight="Bold"
Margin="10,80,10,10" VerticalAlignment="Top" HorizontalAlignment="Left"
Click="StirrerA1Button_Click"/>
<Button x:Name="StirrerA2Button" Content="Rührer A2" Padding="2" Height="30" Width="120"
FontSize="14" BorderThickness="2" FontWeight="Bold"
Margin="10,115,10,10" VerticalAlignment="Top" HorizontalAlignment="Left"
Click="StirrerA2Button_Click"/>
<Button x:Name="BeltButton" Content="Förderband" Padding="2" Height="30" Width="150"
FontSize="14" BorderThickness="2" FontWeight="Bold"
Margin="135,10,10,10" VerticalAlignment="Top" HorizontalAlignment="Left"
Click="BeltButton_Click"/>
<Button x:Name="Auger1Button" Content="Förderschnecke 1" Padding="2" Height="30" Width="150"
FontSize="14" BorderThickness="2" FontWeight="Bold"
Margin="135,45,10,10" VerticalAlignment="Top" HorizontalAlignment="Left"
Click="Auger1Button_Click"/>
<Button x:Name="Auger2Button" Content="Förderschnecke 2" Padding="2" Height="30" Width="150"
FontSize="14" BorderThickness="2" FontWeight="Bold"
Margin="135,80,10,10" VerticalAlignment="Top" HorizontalAlignment="Left"
Click="Auger2Button_Click"/>
<Button x:Name="GradationPumpButton" Content="Gradationspumpe" Padding="2" Height="30" Width="150"
FontSize="14" BorderThickness="2" FontWeight="Bold"
Margin="135,115,10,10" VerticalAlignment="Top" HorizontalAlignment="Left"
Click="GradationPumpButton_Click"/>
<Button x:Name="MP1ForwardButton" Content="Zurück" Padding="2" Height="30" Width="60"
FontSize="14" BorderThickness="2" FontWeight="Bold"
Margin="290,10,10,10" VerticalAlignment="Top" HorizontalAlignment="Left"
Click="MP1ForwardButton_Click"/>
<Button x:Name="MP1HaltButton" Content="MP1" Padding="2" Height="30" Width="60"
FontSize="14" BorderThickness="2" FontWeight="Bold"
Margin="350,10,10,10" VerticalAlignment="Top" HorizontalAlignment="Left"
Click="MP1HaltButton_Click"/>
<Button x:Name="MP1BackwardButton" Content="Vor" Padding="2" Height="30" Width="60"
FontSize="14" BorderThickness="2" FontWeight="Bold"
Margin="410,10,10,10" VerticalAlignment="Top" HorizontalAlignment="Left"
Click="MP1BackwardButton_Click"/>
<Button x:Name="MP2ForwardButton" Content="Zurück" Padding="2" Height="30" Width="60"
FontSize="14" BorderThickness="2" FontWeight="Bold"
Margin="290,45,10,10" VerticalAlignment="Top" HorizontalAlignment="Left"
Click="MP2ForwardButton_Click"/>
<Button x:Name="MP2HaltButton" Content="MP2" Padding="2" Height="30" Width="60"
FontSize="14" BorderThickness="2" FontWeight="Bold"
Margin="350,45,10,10" VerticalAlignment="Top" HorizontalAlignment="Left"
Click="MP2HaltButton_Click"/>
<Button x:Name="MP2BackwardButton" Content="Vor" Padding="2" Height="30" Width="60"
FontSize="14" BorderThickness="2" FontWeight="Bold"
Margin="410,45,10,10" VerticalAlignment="Top" HorizontalAlignment="Left"
Click="MP2BackwardButton_Click"/>
<Button x:Name="P12Button" Content="Pumpe 1/2" Padding="2" Height="30" Width="180"
FontSize="14" BorderThickness="2" FontWeight="Bold"
Margin="290,80,10,10" VerticalAlignment="Top" HorizontalAlignment="Left"
Click="P12Button_Click"/>
</Grid>
</Grid>
</Window>
+186 -2
View File
@@ -14,6 +14,7 @@ namespace PamhagenSysCtrl {
Content = $"V{i}",
Margin = new(10 + ((i - 1) / 10) * 50, 10 + ((i - 1) % 10) * 40, 10, 10),
BorderThickness = new(2),
FontWeight = FontWeights.Bold,
VerticalAlignment = VerticalAlignment.Top,
HorizontalAlignment = HorizontalAlignment.Left,
Height = 30,
@@ -33,7 +34,7 @@ namespace PamhagenSysCtrl {
}
App.Plant.CommitChanges();
};
ButtonPanel.Children.Add(b);
ValvePanel.Children.Add(b);
}
}
@@ -57,13 +58,69 @@ namespace PamhagenSysCtrl {
for (int i = 1; i <= 60; i++) {
var target = plant.WantValveClosed(i);
var actual = plant.IsValveClosed(i);
if (ButtonPanel.Children[i - 1] is not Button b)
if (ValvePanel.Children[i - 1] is not Button b)
continue;
b.BorderBrush = target ? Brushes.DarkRed : Brushes.SlateGray;
b.Foreground = target ? Brushes.DarkRed : Brushes.Black;
b.Background = actual ? Brushes.MistyRose : Brushes.WhiteSmoke;
}
ReblerButton.BorderBrush = plant.IsReblerActive ? Brushes.DarkGreen : Brushes.DarkRed;
ReblerButton.Foreground = plant.IsReblerActive ? Brushes.DarkGreen : Brushes.DarkRed;
ReblerButton.Background = plant.IsReblerActive ? Brushes.MintCream: Brushes.MistyRose;
TroughAugerButton.BorderBrush = plant.IsTroughAugerActive ? Brushes.DarkGreen : Brushes.DarkRed;
TroughAugerButton.Foreground = plant.IsTroughAugerActive ? Brushes.DarkGreen : Brushes.DarkRed;
TroughAugerButton.Background = plant.IsTroughAugerActive ? Brushes.MintCream : Brushes.MistyRose;
StirrerA1Button.BorderBrush = plant.IsStirrerA1Active ? Brushes.DarkGreen : Brushes.DarkRed;
StirrerA1Button.Foreground = plant.IsStirrerA1Active ? Brushes.DarkGreen : Brushes.DarkRed;
StirrerA1Button.Background = plant.IsStirrerA1Active ? Brushes.MintCream : Brushes.MistyRose;
StirrerA2Button.BorderBrush = plant.IsStirrerA2Active ? Brushes.DarkGreen : Brushes.DarkRed;
StirrerA2Button.Foreground = plant.IsStirrerA2Active ? Brushes.DarkGreen : Brushes.DarkRed;
StirrerA2Button.Background = plant.IsStirrerA2Active ? Brushes.MintCream : Brushes.MistyRose;
BeltButton.BorderBrush = plant.IsBeltActive ? Brushes.DarkGreen : Brushes.DarkRed;
BeltButton.Foreground = plant.IsBeltActive ? Brushes.DarkGreen : Brushes.DarkRed;
BeltButton.Background = plant.IsBeltActive ? Brushes.MintCream : Brushes.MistyRose;
Auger1Button.BorderBrush = plant.IsAuger1Active ? Brushes.DarkGreen : Brushes.DarkRed;
Auger1Button.Foreground = plant.IsAuger1Active ? Brushes.DarkGreen : Brushes.DarkRed;
Auger1Button.Background = plant.IsAuger1Active ? Brushes.MintCream : Brushes.MistyRose;
Auger2Button.BorderBrush = plant.IsAuger2Active ? Brushes.DarkGreen : Brushes.DarkRed;
Auger2Button.Foreground = plant.IsAuger2Active ? Brushes.DarkGreen : Brushes.DarkRed;
Auger2Button.Background = plant.IsAuger2Active ? Brushes.MintCream : Brushes.MistyRose;
GradationPumpButton.BorderBrush = plant.IsGradationPumpActive ? Brushes.DarkGreen : Brushes.DarkRed;
GradationPumpButton.Foreground = plant.IsGradationPumpActive ? Brushes.DarkGreen : Brushes.DarkRed;
GradationPumpButton.Background = plant.IsGradationPumpActive ? Brushes.MintCream : Brushes.MistyRose;
MP1BackwardButton.BorderBrush = plant.MP1 == MotorState.Backward ? Brushes.DarkGreen : Brushes.SlateGray;
MP1BackwardButton.Foreground = plant.MP1 == MotorState.Backward ? Brushes.DarkGreen : Brushes.SlateGray;
MP1BackwardButton.Background = plant.MP1 == MotorState.Backward ? Brushes.MintCream : Brushes.WhiteSmoke;
MP1HaltButton.BorderBrush = plant.MP1 == MotorState.Halt ? Brushes.DarkRed : Brushes.SlateGray;
MP1HaltButton.Foreground = plant.MP1 == MotorState.Halt ? Brushes.DarkRed : Brushes.SlateGray;
MP1HaltButton.Background = plant.MP1 == MotorState.Halt ? Brushes.MistyRose : Brushes.WhiteSmoke;
MP1ForwardButton.BorderBrush = plant.MP1 == MotorState.Forward ? Brushes.DarkGreen : Brushes.SlateGray;
MP1ForwardButton.Foreground = plant.MP1 == MotorState.Forward ? Brushes.DarkGreen : Brushes.SlateGray;
MP1ForwardButton.Background = plant.MP1 == MotorState.Forward ? Brushes.MintCream: Brushes.WhiteSmoke;
MP2BackwardButton.BorderBrush = plant.MP2 == MotorState.Backward ? Brushes.DarkGreen : Brushes.SlateGray;
MP2BackwardButton.Foreground = plant.MP2 == MotorState.Backward ? Brushes.DarkGreen : Brushes.SlateGray;
MP2BackwardButton.Background = plant.MP2 == MotorState.Backward ? Brushes.MintCream : Brushes.WhiteSmoke;
MP2HaltButton.BorderBrush = plant.MP2 == MotorState.Halt ? Brushes.DarkRed : Brushes.SlateGray;
MP2HaltButton.Foreground = plant.MP2 == MotorState.Halt ? Brushes.DarkRed : Brushes.SlateGray;
MP2HaltButton.Background = plant.MP2 == MotorState.Halt ? Brushes.MistyRose : Brushes.WhiteSmoke;
MP2ForwardButton.BorderBrush = plant.MP2 == MotorState.Forward ? Brushes.DarkGreen : Brushes.SlateGray;
MP2ForwardButton.Foreground = plant.MP2 == MotorState.Forward ? Brushes.DarkGreen : Brushes.SlateGray;
MP2ForwardButton.Background = plant.MP2 == MotorState.Forward ? Brushes.MintCream : Brushes.WhiteSmoke;
P12Button.BorderBrush = plant.P12 == MotorState.Forward ? Brushes.DarkGreen : Brushes.DarkRed;
P12Button.Foreground = plant.P12 == MotorState.Forward ? Brushes.DarkGreen : Brushes.DarkRed;
P12Button.Background = plant.P12 == MotorState.Forward ? Brushes.MintCream : Brushes.MistyRose;
Status.Text = $"""
Gradation °Oe: {plant.GradationOe:N2}
Presse Querschnecke: {plant.PresseQuerSchnecke}
@@ -83,5 +140,132 @@ namespace PamhagenSysCtrl {
Tank 9: {plant.FillLevelT9}
""";
}
private void TroughAugerButton_Click(object? sender, RoutedEventArgs? evt) {
if (App.Plant == null) return;
if (App.Plant.IsTroughAugerActive) {
App.Plant.StopTroughAuger();
} else {
App.Plant.StartTroughAuger();
}
App.Plant.CommitChanges();
}
private void ReblerButton_Click(object? sender, RoutedEventArgs? evt) {
if (App.Plant == null) return;
if (App.Plant.IsReblerActive) {
App.Plant.StopRebler();
} else {
App.Plant.StartRebler();
}
App.Plant.CommitChanges();
}
private void StirrerA1Button_Click(object? sender, RoutedEventArgs? evt) {
if (App.Plant == null) return;
if (App.Plant.IsStirrerA1Active) {
App.Plant.StopStirrerA1();
} else {
App.Plant.StartStirrerA1();
}
App.Plant.CommitChanges();
}
private void StirrerA2Button_Click(object? sender, RoutedEventArgs? evt) {
if (App.Plant == null) return;
if (App.Plant.IsStirrerA2Active) {
App.Plant.StopStirrerA2();
} else {
App.Plant.StartStirrerA2();
}
App.Plant.CommitChanges();
}
private void BeltButton_Click(object? sender, RoutedEventArgs? evt) {
if (App.Plant == null) return;
if (App.Plant.IsBeltActive) {
App.Plant.StopBelt();
} else {
App.Plant.StartBelt();
}
App.Plant.CommitChanges();
}
private void Auger1Button_Click(object? sender, RoutedEventArgs? evt) {
if (App.Plant == null) return;
if (App.Plant.IsAuger1Active) {
App.Plant.StopAuger1();
} else {
App.Plant.StartAuger1();
}
App.Plant.CommitChanges();
}
private void Auger2Button_Click(object? sender, RoutedEventArgs? evt) {
if (App.Plant == null) return;
if (App.Plant.IsAuger2Active) {
App.Plant.StopAuger2();
} else {
App.Plant.StartAuger2();
}
App.Plant.CommitChanges();
}
private void GradationPumpButton_Click(object? sender, RoutedEventArgs? evt) {
if (App.Plant == null) return;
if (App.Plant.IsGradationPumpActive) {
App.Plant.StopGradationPump();
} else {
App.Plant.StartGradationPump();
}
App.Plant.CommitChanges();
}
private void MP1BackwardButton_Click(object? sender, RoutedEventArgs? evt) {
if (App.Plant == null) return;
App.Plant.StartMP1Backward();
App.Plant.CommitChanges();
}
private void MP1HaltButton_Click(object? sender, RoutedEventArgs? evt) {
if (App.Plant == null) return;
App.Plant.StopMP1();
App.Plant.CommitChanges();
}
private void MP1ForwardButton_Click(object? sender, RoutedEventArgs? evt) {
if (App.Plant == null) return;
App.Plant.StartMP1Forward();
App.Plant.CommitChanges();
}
private void MP2BackwardButton_Click(object? sender, RoutedEventArgs? evt) {
if (App.Plant == null) return;
App.Plant.StartMP2Backward();
App.Plant.CommitChanges();
}
private void MP2HaltButton_Click(object? sender, RoutedEventArgs? evt) {
if (App.Plant == null) return;
App.Plant.StopMP2();
App.Plant.CommitChanges();
}
private void MP2ForwardButton_Click(object? sender, RoutedEventArgs? evt) {
if (App.Plant == null) return;
App.Plant.StartMP2Forward();
App.Plant.CommitChanges();
}
private void P12Button_Click(object? sender, RoutedEventArgs? evt) {
if (App.Plant == null) return;
if (App.Plant.P12 == MotorState.Forward) {
App.Plant.StopP12();
} else {
App.Plant.StartP12();
}
App.Plant.CommitChanges();
}
}
}