11 Commits
Author SHA1 Message Date
lorenz.stechauner f2a3ad3423 Reconstruct selected paths
Test / Run tests (push) Successful in 13s
2026-08-14 10:53:42 +02:00
lorenz.stechauner f251994c25 Add scaling to PlantSchemeWindow
Test / Run tests (push) Successful in 13s
2026-08-14 09:59:16 +02:00
lorenz.stechauner 2dee3a9ae9 Rework updating process a bit
Test / Run tests (push) Successful in 13s
2026-08-12 15:01:59 +02:00
lorenz.stechauner 4e82f164c9 Update README and AboutWindow 2026-08-12 14:45:58 +02:00
thomas.hilscherandlorenz.stechauner 77f9ae167c Update Über page 2026-08-12 11:38:09 +02:00
thomas.hilscherandlorenz.stechauner eb0ec60ed2 Add auto updater 2026-08-12 11:37:07 +02:00
lorenz.stechauner 9d4ae11de8 Ignore empty sensors in tanks
Test / Run tests (push) Successful in 33s
2026-08-12 11:24:14 +02:00
lorenz.stechauner d507a7486e Bump version to 0.0.3
Deploy / Build and Deploy (push) Successful in 2m34s
Test / Run tests (push) Successful in 14s
2026-08-11 14:50:41 +02:00
lorenz.stechauner ece46846b4 Add buttons for controlling pumps
Test / Run tests (push) Successful in 34s
2026-08-11 12:59:08 +02:00
lorenz.stechauner 03c91fb55a Enhance path finding using path cost 2026-08-11 02:01:08 +02:00
lorenz.stechauner f0accc8df8 Add fast select buttons
Test / Run tests (push) Successful in 14s
2026-08-11 00:26:27 +02:00
38 changed files with 1649 additions and 678 deletions
+4
View File
@@ -1,3 +1,7 @@
[plc]
port = COM1
[update]
url = https://elwig.at/files/pamhagen-sysctrl/latest
auto = true
+48
View File
@@ -1,3 +1,4 @@
using PamhagenSysCtrl.Dialogs;
using PamhagenSysCtrl.Helpers;
using System.IO;
using System.Reflection;
@@ -10,6 +11,8 @@ namespace PamhagenSysCtrl {
public static PamhagenPlant? Plant;
public static Dispatcher? MainDispatcher;
private readonly DispatcherTimer AutoUpdateTimer = new() { Interval = TimeSpan.FromHours(1) };
public static readonly string DataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "Anlagensteuerung Pamhagen");
public static readonly string ConfigPath = Path.Combine(DataPath, "config.ini");
public static readonly string InstallPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "Anlagensteuerung Pamhagen");
@@ -45,6 +48,51 @@ namespace PamhagenSysCtrl {
}
base.OnStartup(evt);
if (Config.UpdateUrl != null && Config.UpdateAuto) {
AutoUpdateTimer.Tick += async (_, _) => {
try {
await CheckForUpdates();
} catch { }
};
AutoUpdateTimer.Start();
await Dispatcher.BeginInvoke(async () => {
await Task.Delay(1500);
try {
await CheckForUpdates();
} catch { }
});
}
}
public static async Task CheckForUpdates(bool showResult = false) {
if (Config.UpdateUrl == null) return;
try {
var latest = await UpdateService.GetLatestInstallerUrl(Config.UpdateUrl);
if (latest.HasValue && new Version(latest.Value.Version) > Version) {
var dialog = new UpdateDialog(latest.Value.Version, latest.Value.Url, latest.Value.Size) {
Owner = Current.MainWindow,
};
if (dialog.ShowDialog() == true) {
Current.Shutdown();
}
} else if (showResult) {
MessageBox.Show($"Die Anlagensteuerung ist auf dem aktuellen Stand.\n(Version {Version})", "Nach Updates suchen", MessageBoxButton.OK, MessageBoxImage.Information);
}
} catch (OperationCanceledException) {
if (showResult) {
MessageBox.Show("Zeitüberschreitung beim Abrufen der Update-Informationen.", "Nach Updates suchen", MessageBoxButton.OK, MessageBoxImage.Error);
} else {
throw;
}
} catch (Exception exc) {
if (showResult) {
MessageBox.Show($"Die Update-Informationen konnten nicht abgerufen werden:\n\n{exc.Message}", "Nach Updates suchen", MessageBoxButton.OK, MessageBoxImage.Error);
} else {
throw;
}
}
}
protected async void Application_Exit(object sender, ExitEventArgs evt) {
+37
View File
@@ -0,0 +1,37 @@
<Window x:Class="PamhagenSysCtrl.Dialogs.UpdateDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
ResizeMode="NoResize" ShowInTaskbar="False" Topmost="True"
WindowStartupLocation="CenterOwner"
Title="Update verfügbar - Anlagensteuerung Pamhagen"
Height="220" Width="480"
Closed="OnClosed">
<Grid Margin="20">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock x:Name="Description" FontSize="14" TextAlignment="Center"
HorizontalAlignment="Center" VerticalAlignment="Center">
Version <Run x:Name="VersionText" FontWeight="Bold">0.0.0</Run> ist verfügbar.<LineBreak/>
Soll das Update heruntergeladen und installiert werden?<LineBreak/>
(ca. <Run x:Name="SizeText">0</Run> MB)<LineBreak/><LineBreak/>
<Run FontWeight="Bold">Hinweis:</Run> Die Anlagensteuerung wird für die Installation geschlossen.
</TextBlock>
<StackPanel x:Name="DownloadPanel" Grid.Row="0" VerticalAlignment="Center" Visibility="Collapsed">
<TextBlock x:Name="StatusText" Text="Update wird heruntergeladen..."
FontSize="14" TextAlignment="Center" Margin="0,0,0,10"/>
<ProgressBar x:Name="DownloadProgress" Height="24" Minimum="0" Maximum="100"/>
</StackPanel>
<StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,18,0,0">
<Button x:Name="InstallButton" Content="Installieren" IsDefault="True"
Width="110" Height="30" Margin="0,0,12,0" Click="InstallButton_Click"/>
<Button x:Name="CancelButton" Content="Abbrechen" IsCancel="True"
Width="110" Height="30"/>
</StackPanel>
</Grid>
</Window>
@@ -0,0 +1,45 @@
using PamhagenSysCtrl.Helpers;
using System.IO;
using System.Windows;
namespace PamhagenSysCtrl.Dialogs {
public partial class UpdateDialog : Window {
private readonly string Url;
private readonly CancellationTokenSource Cancellation = new();
public UpdateDialog(string version, string url, long size) {
Url = url;
InitializeComponent();
VersionText.Text = version;
SizeText.Text = Math.Ceiling(size / 1024d / 1024d).ToString("N0");
}
private void OnClosed(object? sender, EventArgs evt) {
Cancellation.Cancel();
Cancellation.Dispose();
}
private async void InstallButton_Click(object sender, RoutedEventArgs evt) {
Description.Visibility = Visibility.Collapsed;
DownloadPanel.Visibility = Visibility.Visible;
InstallButton.IsEnabled = false;
try {
var progress = new Progress<double>(value => DownloadProgress.Value = value * 100);
var filename = Path.Combine(App.TempPath, $"PamhagenSysCtrl-{VersionText.Text}.msi");
await UpdateService.DownloadInstaller(Url, filename, progress, Cancellation.Token);
StatusText.Text = "Installer wird gestartet...";
UpdateService.StartInstaller(filename);
DialogResult = true;
} catch (OperationCanceledException) {
// Closing the dialog cancels an active download.
} catch (Exception exc) {
MessageBox.Show($"Das Update konnte nicht installiert werden:\n\n{exc.Message}", "Update installieren", MessageBoxButton.OK, MessageBoxImage.Error);
Description.Visibility = Visibility.Visible;
DownloadPanel.Visibility = Visibility.Collapsed;
InstallButton.IsEnabled = true;
}
}
}
}
+4
View File
@@ -9,6 +9,8 @@ namespace PamhagenSysCtrl.Helpers {
private readonly string FileName;
public string PlcPort = "COM1";
public string? UpdateUrl;
public bool UpdateAuto;
public Config(string filename) {
FileName = filename;
@@ -19,6 +21,8 @@ namespace PamhagenSysCtrl.Helpers {
try {
var config = new ConfigurationBuilder().AddIniFile(FileName).Build();
PlcPort = config["plc:port"] ?? "COM1";
UpdateUrl = config["update:url"];
UpdateAuto = TrueValues.Contains(config["update:auto"]?.ToLower());
} catch (Exception exc) {
MessageBox.Show($"Die Konfigurationsdatei konnte nicht gelesen werden:\n\n{exc.Message}", "Konfigurationsdatei lesen", MessageBoxButton.OK, MessageBoxImage.Error);
Application.Current.Shutdown();
+233 -194
View File
@@ -18,78 +18,96 @@ namespace PamhagenSysCtrl.Helpers {
public readonly Pump P6;
public readonly EncasedAuger Auger1;
public readonly EncasedAuger Auger3;
public readonly Press Press1;
public readonly Press Press2;
public readonly Tank Tank1;
public readonly Tank Tank2;
public readonly Tank Tank3;
public readonly Tank Tank4;
public readonly Tank Tank5;
public readonly Tank Tank6;
public readonly Tank Tank7;
public readonly Tank Tank8;
public readonly Tank Tank9;
public PamhagenGraph() {
double mw2X = 180;
double mw1X = 300;
double mpY = 380;
double ltg1Y = 510;
double ltg2Y = ltg1Y + 30;
double ltg1X = 600;
double ltg2X = ltg1X + 30;
double ltg6Y = 160;
double ltg7Y = ltg6Y - 30;
double tanksY = 280;
double tValveY = ((tanksY - 50) + ltg6Y) / 2 + 5;
double wtX = ltg1X - 180;
double wt2Y = 225;
double wt1Y = wt2Y + 135;
double x1X = wtX + 40;
double t1X = 735;
double t2X = t1X + 80;
double t3X = t2X + 80;
double t4X = t3X + 80 + 30;
double t5X = t4X + 80;
double t6X = t5X + 80 + 30;
double t7X = t6X + 80;
double t8X = t7X + 80;
double t9X = t8X + 80;
var prY = 720;
var pr1X = 730;
var pr2X = 920;
double mw2X = -118;
double mw1X = -94;
double rebX = (mw1X + mw2X) / 2;
double rebY = -46;
double mpY = -10;
double tanksY = -30;
double ltg1Y = 16;
double ltg2Y = ltg1Y + 6;
double ltg1X = -34;
double ltg2X = ltg1X + 6;
double ltg3Y = 30;
double ltg4Y = ltg3Y + 6;
double ltg5Y = tanksY + 36;
double ltg6Y = -54;
double ltg7Y = ltg6Y - 6;
double ltg8Y = ltg3Y - 6;
double ltg9Y = ltg4Y + 6;
double tValveY = ((tanksY - 10) + ltg6Y) / 2 + 1;
double wtX = ltg1X - 36;
double wt2Y = -41;
double wt1Y = wt2Y + 27;
double x1X = wtX + 8;
double t1X = -7;
double t2X = t1X + 16;
double t3X = t2X + 16;
double t4X = t3X + 16 + 6;
double t5X = t4X + 16;
double t6X = t5X + 16 + 6;
double t7X = t6X + 16;
double t8X = t7X + 16;
double t9X = t8X + 16;
var prY = 58;
var pr1X = -15;
var pr2X = 23;
var trough = new EntryTrough("Auffangwanne", mw1X + 70, 100, () => App.Plant?.IsTroughAugerActive ?? false);
var trough = new EntryTrough("Auffangwanne", mw1X + 14, rebY - 20, () => App.Plant?.IsTroughAugerActive ?? false);
Nodes.Add(trough);
Auger1 = new EncasedAuger("", (mw1X + mw2X) / 2 - 100, 200, () => App.Plant?.IsAuger1Active ?? false);
var auger0 = new EncasedAuger("Pressen-\nQuerschnecke", 40, 200, () => App.Plant?.IsPresseQuerSchneckeActive ?? false, 180, clickable: false);
Auger3 = new EncasedAuger("", 120, 80, () => App.Plant?.IsAuger3Active ?? false, 135);
var belt = new ConveyorBelt("", 90, 160, () => App.Plant?.IsAuger2Active ?? false);
Auger1 = new EncasedAuger("", rebX - 19, rebY, () => App.Plant?.IsAuger1Active ?? false);
var auger0 = new EncasedAuger("Pressen-\nQuerschnecke", rebX - 39, rebY, () => App.Plant?.IsPresseQuerSchneckeActive ?? false, 180, clickable: false);
Auger3 = new EncasedAuger("", rebX - 23, rebY - 24, () => App.Plant?.IsAuger3Active ?? false, 135);
var belt = new ConveyorBelt("", rebX - 29, rebY - 8, () => App.Plant?.IsAuger2Active ?? false);
Nodes.Add(belt);
Nodes.Add(Auger1);
Nodes.Add(auger0);
Nodes.Add(Auger3);
var rebler = new Rebler("Rebler", (mw1X + mw2X) / 2, 200, () => App.Plant?.IsReblerActive ?? false);
var rebler = new Rebler("Rebler", rebX, rebY, () => App.Plant?.IsReblerActive ?? false);
Nodes.Add(rebler);
var switcher = new Switcher("", (mw1X + mw2X) / 2, 260, () => App.Plant?.TroughSelector ?? 0, () => App.Plant == null ? 0 : App.Plant.WantMW1Selected ? 1 : 2);
var switcher = new Switcher("", rebX, rebY + 12, () => App.Plant?.TroughSelector ?? 0, () => App.Plant == null ? 0 : App.Plant.WantMW1Selected ? 1 : 2);
Nodes.Add(switcher);
MW1 = new Trough("MW1", mw1X, mpY - 70, () => App.Plant?.FillLevelMW1 ?? FillState.Unknown);
MW2 = new Trough("MW2", mw2X, mpY - 70, () => App.Plant?.FillLevelMW2 ?? FillState.Unknown);
MW1 = new Trough("MW1", mw1X, mpY - 14, () => App.Plant?.FillLevelMW1 ?? FillState.Unknown);
MW2 = new Trough("MW2", mw2X, mpY - 14, () => App.Plant?.FillLevelMW2 ?? FillState.Unknown);
MP1 = new Pump("MP1", mw1X, mpY, () => App.Plant?.MP1 ?? default, () => App.Plant?.MP1HasClearance ?? false, (x) => SelectedPaths.Any(p => p.Hops.Any(h => h.Node == x)));
MP2 = new Pump("MP2", mw2X, mpY, () => App.Plant?.MP2 ?? default, () => App.Plant?.MP2HasClearance ?? false, (x) => SelectedPaths.Any(p => p.Hops.Any(h => h.Node == x)));
var x1 = new PipeJoin(mw1X, mpY + 40);
var x2 = new PipeJoin(mw2X, mpY + 40);
var x1 = new PipeJoin(mw1X, mpY + 8);
var x2 = new PipeJoin(mw2X, mpY + 8);
CreateOutlet(MW1, MP1);
CreateOutlet(MW2, MP2);
CreatePipe(MP1, x1);
CreatePipe(MP2, x2);
var v1 = CreateValve(1, mw1X, mpY + 70);
var v2 = CreateValve(2, mw2X, mpY + 70);
var v3 = CreateValve(3, mw2X + 30, mpY + 70);
var v4 = CreateValve(4, mw1X - 30, mpY + 70);
var v1 = CreateValve(1, mw1X, mpY + 16);
var v2 = CreateValve(2, mw2X, mpY + 16);
var v3 = CreateValve(3, mw2X + 6, mpY + 16);
var v4 = CreateValve(4, mw1X - 6, mpY + 16);
CreatePipe(x1, v1);
CreatePipe(x1, v4);
CreatePipe(x2, v2);
CreatePipe(x2, v3);
var x3 = new PipeJoin(mw1X, mpY + 100);
var x3 = new PipeJoin(mw1X, ltg1Y);
var x4 = new PipeJoin(x1X, ltg1Y);
var x5 = new PipeJoin(mw2X, mpY + 130);
var x6 = new PipeJoin(x1X - 30, ltg2Y);
var x5 = new PipeJoin(mw1X - 6, ltg2Y);
var x6 = new PipeJoin(x1X - 6, ltg2Y);
CreatePipe(v1, x3, true);
CreatePipe(v3, x3, true);
@@ -98,50 +116,50 @@ namespace PamhagenSysCtrl.Helpers {
CreatePipe(v4, x5, true);
CreatePipe(x5, x6, true);
var v5 = CreateValve(5, x1X + 30, ltg1Y);
var v6 = CreateValve(6, x1X + 30, ltg2Y + 40);
var v7 = CreateValve(7, x1X + 30, ltg2Y);
var v8 = CreateValve(8, x1X - 30, ltg2Y + 40);
var v9 = CreateValve(9, ltg2X, 500);
var v5 = CreateValve(5, x1X + 6, ltg1Y);
var v6 = CreateValve(6, x1X + 6, ltg2Y + 8);
var v7 = CreateValve(7, x1X + 6, ltg2Y);
var v8 = CreateValve(8, x1X - 6, ltg2Y + 8);
var v9 = CreateValve(9, ltg2X, ltg5Y + 8);
CreatePipe(x4, v5);
CreatePipe(x4, v6, true);
CreatePipe(x6, v7);
CreatePipe(x6, v8);
CreatePipe(v7, v9, label: "Ltg. 2", labelOffsetX: 30);
CreatePipe(v7, v9, label: "Ltg. 2", labelOffsetX: 6);
var xv15 = new PipeJoin(ltg1X, wt1Y + 40);
var xv11 = new PipeJoin(ltg2X, wt1Y + 70);
var x7 = new PipeJoin(ltg2X, 460);
var xv15 = new PipeJoin(ltg1X, wt1Y + 8);
var xv11 = new PipeJoin(ltg2X, wt1Y + 14);
var x7 = new PipeJoin(ltg2X, ltg5Y);
CreatePipe(v5, xv15, label: "Ltg. 1", labelOffsetX: 30);
CreatePipe(v5, xv15, label: "Ltg. 1", labelOffsetX: 6);
CreatePipe(v9, x7);
CreatePipe(x7, xv11);
var v10 = CreateValve(10, ltg2X + 40, 460);
var v11 = CreateValve(11, ltg1X - 30, wt1Y + 70);
var v10 = CreateValve(10, ltg2X + 8, ltg5Y);
var v11 = CreateValve(11, ltg1X - 6, wt1Y + 14);
var v12 = CreateValve(12, ltg1X, wt1Y);
var v13 = CreateValve(13, ltg2X, wt1Y);
var v14 = CreateValve(14, ltg1X - 30, wt1Y - 40);
var v15 = CreateValve(15, ltg1X - 30, wt1Y + 40);
var v16 = CreateValve(16, ltg1X - 30, wt1Y - 70);
var v14 = CreateValve(14, ltg1X - 6, wt1Y - 8);
var v15 = CreateValve(15, ltg1X - 6, wt1Y + 8);
var v16 = CreateValve(16, ltg1X - 6, wt1Y - 14);
CreatePipe(v10, x7);
CreatePipe(xv11, v11);
CreatePipe(xv15, v15);
CreatePipe(xv15, v12);
CreatePipe(xv11, v13);
var xv16 = new PipeJoin(ltg1X, wt1Y - 70);
var xv14 = new PipeJoin(ltg2X, wt1Y - 40);
var xv16 = new PipeJoin(ltg1X, wt1Y - 14);
var xv14 = new PipeJoin(ltg2X, wt1Y - 8);
CreatePipe(v12, xv16);
CreatePipe(v13, xv14);
CreatePipe(v16, xv16);
CreatePipe(v14, xv14);
var v20 = CreateValve(20, ltg1X - 30, wt2Y - 70);
var v21 = CreateValve(21, ltg1X - 30, wt2Y - 40);
var xv20 = new PipeJoin(ltg1X, wt2Y - 70);
var xv21 = new PipeJoin(ltg2X, wt2Y - 40);
var v20 = CreateValve(20, ltg1X - 6, wt2Y - 14);
var v21 = CreateValve(21, ltg1X - 6, wt2Y - 8);
var xv20 = new PipeJoin(ltg1X, wt2Y - 14);
var xv21 = new PipeJoin(ltg2X, wt2Y - 8);
CreatePipe(xv16, xv20);
CreatePipe(xv14, xv21);
CreatePipe(v20, xv20);
@@ -149,15 +167,15 @@ namespace PamhagenSysCtrl.Helpers {
var wt1 = new HeatExchanger("WT Most", wtX, wt1Y);
var wt2 = new HeatExchanger("WT Warmwasser", wtX, wt2Y);
var v17 = CreateValve(17, wtX + 70, wt1Y);
var v18 = CreateValve(18, wtX + 40, wt1Y + 40);
var v19 = CreateValve(19, wtX + 40, (wt1Y + wt2Y) / 2);
var xwt1 = new PipeJoin(wtX + 120, wt1Y + 40);
var xwt2 = new PipeJoin(wtX + 70, wt1Y + 40);
var xwt3 = new PipeJoin(wtX + 40, wt1Y - 40);
var xwt4 = new PipeJoin(wtX + 120, wt1Y - 40);
var xwt5 = new PipeJoin(wtX + 40, wt2Y + 40);
var xwt6 = new PipeJoin(wtX + 120, wt2Y - 40);
var v17 = CreateValve(17, wtX + 14, wt1Y);
var v18 = CreateValve(18, wtX + 8, wt1Y + 8);
var v19 = CreateValve(19, wtX + 8, (wt1Y + wt2Y) / 2);
var xwt1 = new PipeJoin(wtX + 24, wt1Y + 8);
var xwt2 = new PipeJoin(wtX + 14, wt1Y + 8);
var xwt3 = new PipeJoin(wtX + 8, wt1Y - 8);
var xwt4 = new PipeJoin(wtX + 24, wt1Y - 8);
var xwt5 = new PipeJoin(wtX + 8, wt2Y + 8);
var xwt6 = new PipeJoin(wtX + 24, wt2Y - 8);
CreatePipe(v11, xwt1);
CreatePipe(v15, xwt1);
CreatePipe(xwt1, xwt2);
@@ -176,141 +194,141 @@ namespace PamhagenSysCtrl.Helpers {
CreatePipe(v19, xwt5);
CreatePipe(xwt5, wt2);
var xv22 = new PipeJoin(t1X - 15, ltg7Y);
var xv23 = new PipeJoin(t1X + 15, ltg6Y);
var v22 = CreateValve(22, t1X - 15, tValveY);
var v23 = CreateValve(23, t1X + 15, tValveY);
var t1 = CreateTank(1, t1X, tanksY, 35000);
CreatePipe(xv20, xv22, true, label: "Ltg. 7", labelOffsetX: 50);
CreatePipe(xv21, xv23, true, label: "Ltg. 6", labelOffsetX: 20);
var xv22 = new PipeJoin(t1X - 3, ltg7Y);
var xv23 = new PipeJoin(t1X + 3, ltg6Y);
var v22 = CreateValve(22, t1X - 3, tValveY);
var v23 = CreateValve(23, t1X + 3, tValveY);
Tank1 = CreateTank(1, t1X, tanksY, 35000);
CreatePipe(xv20, xv22, true, label: "Ltg. 7", labelOffsetX: 10);
CreatePipe(xv21, xv23, true, label: "Ltg. 6", labelOffsetX: 4);
CreatePipe(xv22, v22);
CreatePipe(xv23, v23);
CreateInlet(v22, t1);
CreateInlet(v23, t1);
CreateInlet(v22, Tank1);
CreateInlet(v23, Tank1);
var xv24 = new PipeJoin(t2X - 15, ltg7Y);
var xv25 = new PipeJoin(t2X + 15, ltg6Y);
var v24 = CreateValve(24, t2X - 15, tValveY);
var v25 = CreateValve(25, t2X + 15, tValveY);
var t2 = CreateTank(2, t2X, tanksY, 35000);
var xv24 = new PipeJoin(t2X - 3, ltg7Y);
var xv25 = new PipeJoin(t2X + 3, ltg6Y);
var v24 = CreateValve(24, t2X - 3, tValveY);
var v25 = CreateValve(25, t2X + 3, tValveY);
Tank2 = CreateTank(2, t2X, tanksY, 35000);
CreatePipe(xv22, xv24);
CreatePipe(xv23, xv25);
CreatePipe(xv24, v24);
CreatePipe(xv25, v25);
CreateInlet(v24, t2);
CreateInlet(v25, t2);
CreateInlet(v24, Tank2);
CreateInlet(v25, Tank2);
var xv26 = new PipeJoin(t3X - 15, ltg7Y);
var xv27 = new PipeJoin(t3X + 15, ltg6Y);
var v26 = CreateValve(26, t3X - 15, tValveY);
var v27 = CreateValve(27, t3X + 15, tValveY);
var t3 = CreateTank(3, t3X, tanksY, 35000);
var xv26 = new PipeJoin(t3X - 3, ltg7Y);
var xv27 = new PipeJoin(t3X + 3, ltg6Y);
var v26 = CreateValve(26, t3X - 3, tValveY);
var v27 = CreateValve(27, t3X + 3, tValveY);
Tank3 = CreateTank(3, t3X, tanksY, 35000);
CreatePipe(xv24, xv26);
CreatePipe(xv25, xv27);
CreatePipe(xv26, v26);
CreatePipe(xv27, v27);
CreateInlet(v26, t3);
CreateInlet(v27, t3);
CreateInlet(v26, Tank3);
CreateInlet(v27, Tank3);
var v28 = CreateValve(28, (t3X + t4X) / 2, ltg7Y);
var v29 = CreateValve(29, (t3X + t4X) / 2, ltg6Y);
CreatePipe(xv26, v28);
CreatePipe(xv27, v29);
var xv30 = new PipeJoin(t4X - 15, ltg7Y);
var xv31 = new PipeJoin(t4X + 15, ltg6Y);
var v30 = CreateValve(30, t4X - 15, tValveY);
var v31 = CreateValve(31, t4X + 15, tValveY);
var t4 = CreateTank(4, t4X, tanksY, 35000);
var xv30 = new PipeJoin(t4X - 3, ltg7Y);
var xv31 = new PipeJoin(t4X + 3, ltg6Y);
var v30 = CreateValve(30, t4X - 3, tValveY);
var v31 = CreateValve(31, t4X + 3, tValveY);
Tank4 = CreateTank(4, t4X, tanksY, 35000);
CreatePipe(v28, xv30);
CreatePipe(v29, xv31);
CreatePipe(xv30, v30);
CreatePipe(xv31, v31);
CreateInlet(v30, t4);
CreateInlet(v31, t4);
CreateInlet(v30, Tank4);
CreateInlet(v31, Tank4);
var xv32 = new PipeJoin(t5X - 15, ltg7Y);
var xv33 = new PipeJoin(t5X + 15, ltg6Y);
var v32 = CreateValve(32, t5X - 15, tValveY);
var v33 = CreateValve(33, t5X + 15, tValveY);
var t5 = CreateTank(5, t5X, tanksY, 35000);
CreatePipe(xv30, xv32, label: "Ltg. 7", labelOffsetX: 30);
var xv32 = new PipeJoin(t5X - 3, ltg7Y);
var xv33 = new PipeJoin(t5X + 3, ltg6Y);
var v32 = CreateValve(32, t5X - 3, tValveY);
var v33 = CreateValve(33, t5X + 3, tValveY);
Tank5 = CreateTank(5, t5X, tanksY, 35000);
CreatePipe(xv30, xv32, label: "Ltg. 7", labelOffsetX: 6);
CreatePipe(xv31, xv33, label: "Ltg. 6", labelOffsetX: 0);
CreatePipe(xv32, v32);
CreatePipe(xv33, v33);
CreateInlet(v32, t5);
CreateInlet(v33, t5);
CreateInlet(v32, Tank5);
CreateInlet(v33, Tank5);
var v34 = CreateValve(34, (t5X + t6X) / 2, ltg7Y);
var v35 = CreateValve(35, (t5X + t6X) / 2, ltg6Y);
CreatePipe(xv32, v34);
CreatePipe(xv33, v35);
var xv36 = new PipeJoin(t6X + 15, ltg6Y);
var xv37 = new PipeJoin(t6X - 15, ltg7Y);
var v36 = CreateValve(36, t6X + 15, tValveY);
var v37 = CreateValve(37, t6X - 15, tValveY);
var t6 = CreateTank(6, t6X, tanksY, 35000);
var xv36 = new PipeJoin(t6X + 3, ltg6Y);
var xv37 = new PipeJoin(t6X - 3, ltg7Y);
var v36 = CreateValve(36, t6X + 3, tValveY);
var v37 = CreateValve(37, t6X - 3, tValveY);
Tank6 = CreateTank(6, t6X, tanksY, 35000);
CreatePipe(v34, xv37);
CreatePipe(v35, xv36);
CreatePipe(xv37, v37);
CreatePipe(xv36, v36);
CreateInlet(v36, t6);
CreateInlet(v37, t6);
CreateInlet(v36, Tank6);
CreateInlet(v37, Tank6);
var xv38 = new PipeJoin(t7X + 15, ltg6Y);
var xv39 = new PipeJoin(t7X - 15, ltg7Y);
var v38 = CreateValve(38, t7X + 15, tValveY);
var v39 = CreateValve(39, t7X - 15, tValveY);
var t7 = CreateTank(7, t7X, tanksY, 35000);
var xv38 = new PipeJoin(t7X + 3, ltg6Y);
var xv39 = new PipeJoin(t7X - 3, ltg7Y);
var v38 = CreateValve(38, t7X + 3, tValveY);
var v39 = CreateValve(39, t7X - 3, tValveY);
Tank7 = CreateTank(7, t7X, tanksY, 35000);
CreatePipe(xv37, xv39);
CreatePipe(xv36, xv38);
CreatePipe(xv38, v38);
CreatePipe(xv39, v39);
CreateInlet(v38, t7);
CreateInlet(v39, t7);
CreateInlet(v38, Tank7);
CreateInlet(v39, Tank7);
var xv40 = new PipeJoin(t8X + 15, ltg6Y);
var xv41 = new PipeJoin(t8X - 15, ltg7Y);
var v40 = CreateValve(40, t8X + 15, tValveY);
var v41 = CreateValve(41, t8X - 15, tValveY);
var t8 = CreateTank(8, t8X, tanksY, 35000);
var xv40 = new PipeJoin(t8X + 3, ltg6Y);
var xv41 = new PipeJoin(t8X - 3, ltg7Y);
var v40 = CreateValve(40, t8X + 3, tValveY);
var v41 = CreateValve(41, t8X - 3, tValveY);
Tank8 = CreateTank(8, t8X, tanksY, 35000);
CreatePipe(xv38, xv40, label: "Ltg. 6", labelOffsetX: 0);
CreatePipe(xv39, xv41, label: "Ltg. 7", labelOffsetX: 30);
CreatePipe(xv39, xv41, label: "Ltg. 7", labelOffsetX: 6);
CreatePipe(xv40, v40);
CreatePipe(xv41, v41);
CreateInlet(v40, t8);
CreateInlet(v41, t8);
CreateInlet(v40, Tank8);
CreateInlet(v41, Tank8);
var v42 = CreateValve(42, t9X + 15, tValveY);
var v43 = CreateValve(43, t9X - 15, tValveY);
var t9 = CreateTank(9, t9X, tanksY, 35000);
var v42 = CreateValve(42, t9X + 3, tValveY);
var v43 = CreateValve(43, t9X - 3, tValveY);
Tank9 = CreateTank(9, t9X, tanksY, 35000);
CreatePipe(xv40, v42);
CreatePipe(xv41, v43);
CreateInlet(v42, t9);
CreateInlet(v43, t9);
CreateInlet(v42, Tank9);
CreateInlet(v43, Tank9);
var xp12 = new PipeJoin((t1X + t2X) / 2, tanksY + 80);
P12 = new Pump("P1/2", (t1X + t2X) / 2, tanksY + 110, () => App.Plant?.P12 ?? default, () => App.Plant?.P12HasClearance ?? false, (x) => SelectedPaths.Any(p => p.Hops.Any(h => h.Node == x)));
CreateOutlet(t1, xp12);
CreateOutlet(t2, xp12);
var xp12 = new PipeJoin((t1X + t2X) / 2, tanksY + 16);
P12 = new Pump("P1/2", (t1X + t2X) / 2, tanksY + 22, () => App.Plant?.P12 ?? default, () => App.Plant?.P12HasClearance ?? false, (x) => SelectedPaths.Any(p => p.Hops.Any(h => h.Node == x)));
CreateOutlet(Tank1, xp12);
CreateOutlet(Tank2, xp12);
CreatePipe(xp12, P12);
P3 = new Pump("P3", t3X, tanksY + 110, () => App.Plant?.P3 ?? default, () => App.Plant?.P3HasClearance ?? false, (x) => SelectedPaths.Any(p => p.Hops.Any(h => h.Node == x)));
P4 = new Pump("P4", t4X, tanksY + 110, () => App.Plant?.P4 ?? default, () => App.Plant?.P4HasClearance ?? false, (x) => SelectedPaths.Any(p => p.Hops.Any(h => h.Node == x)));
P5 = new Pump("P5", t5X, tanksY + 110, () => App.Plant?.P5 ?? default, () => App.Plant?.P5HasClearance ?? false, (x) => SelectedPaths.Any(p => p.Hops.Any(h => h.Node == x)));
CreateOutlet(t3, P3);
CreateOutlet(t4, P4);
CreateOutlet(t5, P5);
P3 = new Pump("P3", t3X, tanksY + 22, () => App.Plant?.P3 ?? default, () => App.Plant?.P3HasClearance ?? false, (x) => SelectedPaths.Any(p => p.Hops.Any(h => h.Node == x)));
P4 = new Pump("P4", t4X, tanksY + 22, () => App.Plant?.P4 ?? default, () => App.Plant?.P4HasClearance ?? false, (x) => SelectedPaths.Any(p => p.Hops.Any(h => h.Node == x)));
P5 = new Pump("P5", t5X, tanksY + 22, () => App.Plant?.P5 ?? default, () => App.Plant?.P5HasClearance ?? false, (x) => SelectedPaths.Any(p => p.Hops.Any(h => h.Node == x)));
CreateOutlet(Tank3, P3);
CreateOutlet(Tank4, P4);
CreateOutlet(Tank5, P5);
var v44 = CreateValve(44, (t1X + t2X) / 2, tanksY + 150);
var v45 = CreateValve(45, t3X, tanksY + 150);
var v46 = CreateValve(46, (t3X + t4X) / 2, tanksY + 180);
var v47 = CreateValve(47, t4X, tanksY + 150);
var v48 = CreateValve(48, t5X, tanksY + 150);
var xv44 = new PipeJoin((t1X + t2X) / 2, tanksY + 180);
var xv45 = new PipeJoin(t3X, tanksY + 180);
var xv47 = new PipeJoin(t4X, tanksY + 180);
var v44 = CreateValve(44, (t1X + t2X) / 2, tanksY + 30);
var v45 = CreateValve(45, t3X, tanksY + 30);
var v46 = CreateValve(46, (t3X + t4X) / 2, ltg5Y);
var v47 = CreateValve(47, t4X, tanksY + 30);
var v48 = CreateValve(48, t5X, tanksY + 30);
var xv44 = new PipeJoin((t1X + t2X) / 2, tanksY + 36);
var xv45 = new PipeJoin(t3X, tanksY + 36);
var xv47 = new PipeJoin(t4X, tanksY + 36);
CreatePipe(P12, v44);
CreatePipe(P3, v45);
CreatePipe(P4, v47);
@@ -325,45 +343,45 @@ namespace PamhagenSysCtrl.Helpers {
CreateTwoWayPipe(v46, xv45);
CreateTwoWayPipe(xv45, xv44);
var xt6 = new PipeJoin(t6X, tanksY + 110);
var xt7 = new PipeJoin(t7X, tanksY + 110);
var xt8 = new PipeJoin(t8X, tanksY + 110);
P6 = new Pump("P6", t6X, tanksY + 150, () => App.Plant?.P6 ?? default, () => App.Plant?.P6HasClearance ?? false, (x) => SelectedPaths.Any(p => p.Hops.Any(h => h.Node == x)));
CreateOutlet(t6, xt6);
CreateOutlet(t7, xt7);
CreateOutlet(t8, xt8);
CreateOutlet(t9, xt8);
var xt6 = new PipeJoin(t6X, tanksY + 22);
var xt7 = new PipeJoin(t7X, tanksY + 22);
var xt8 = new PipeJoin(t8X, tanksY + 22);
P6 = new Pump("P6", t6X, tanksY + 30, () => App.Plant?.P6 ?? default, () => App.Plant?.P6HasClearance ?? false, (x) => SelectedPaths.Any(p => p.Hops.Any(h => h.Node == x)));
CreateOutlet(Tank6, xt6);
CreateOutlet(Tank7, xt7);
CreateOutlet(Tank8, xt8);
CreateOutlet(Tank9, xt8);
CreatePipe(xt8, xt7);
CreatePipe(xt7, xt6);
CreatePipe(xt6, P6);
var v49 = CreateValve(49, t4X, tanksY + 220);
var v49 = CreateValve(49, t4X, tanksY + 44);
CreatePipe(xv47, v49);
var prX = (pr1X + pr2X) / 2;
var pr1cX = prX - 15;
var pr2cX = prX + 15;
var press1 = new Press("Presse 1", pr1X, prY, 20000, () => FillState.Unknown);
var press2 = new Press("Presse 2", pr2X, prY, 15000, () => FillState.Unknown);
var v50 = CreateValve(50, pr2cX + 30, 580);
var v51 = CreateValve(51, pr1cX - 30, 580);
var v52 = CreateValve(52, pr1cX - 30, 610);
var v53 = CreateValve(53, pr2cX + 30, 610);
var v54 = CreateValve(54, pr2cX + 30, 550);
var v55 = CreateValve(55, pr1cX - 30, 550);
var v56 = CreateValve(56, pr1cX - 30, 640);
var v57 = CreateValve(57, pr2cX + 30, 640);
var xp1 = new PipeJoin(pr1cX - 70, 580);
var xp2 = new PipeJoin(pr1cX - 70, 610);
var xp3 = new PipeJoin(pr2cX + 70, 550);
var xp4 = new PipeJoin(pr2cX + 70, 640);
var xp5 = new PipeJoin(pr1cX, 580);
var xp6 = new PipeJoin(pr1cX, 610);
var xp7 = new PipeJoin(pr2cX, 550);
var xp8 = new PipeJoin(pr2cX, 640);
var pr1cX = prX - 3;
var pr2cX = prX + 3;
Press1 = new Press("Presse 1", pr1X, prY, 20000, () => FillState.Unknown);
Press2 = new Press("Presse 2", pr2X, prY, 15000, () => FillState.Unknown);
var v50 = CreateValve(50, pr2cX + 6, ltg3Y);
var v51 = CreateValve(51, pr1cX - 6, ltg3Y);
var v52 = CreateValve(52, pr1cX - 6, ltg4Y);
var v53 = CreateValve(53, pr2cX + 6, ltg4Y);
var v54 = CreateValve(54, pr2cX + 6, ltg8Y);
var v55 = CreateValve(55, pr1cX - 6, ltg8Y);
var v56 = CreateValve(56, pr1cX - 6, ltg9Y);
var v57 = CreateValve(57, pr2cX + 6, ltg9Y);
var xp1 = new PipeJoin(pr1cX - 14, ltg3Y);
var xp2 = new PipeJoin(pr1cX - 14, ltg4Y);
var xp3 = new PipeJoin(pr2cX + 14, ltg8Y);
var xp4 = new PipeJoin(pr2cX + 14, ltg9Y);
var xp5 = new PipeJoin(pr1cX, ltg3Y);
var xp6 = new PipeJoin(pr1cX, ltg4Y);
var xp7 = new PipeJoin(pr2cX, ltg8Y);
var xp8 = new PipeJoin(pr2cX, ltg9Y);
CreatePipe(v6, xp1, true, label: "Ltg. 3", labelOffsetX: 30);
CreatePipe(v8, xp2, true, label: "Ltg. 4", labelOffsetX: 90);
CreatePipe(v6, xp1, true, label: "Ltg. 3", labelOffsetX: 6);
CreatePipe(v8, xp2, true, label: "Ltg. 4", labelOffsetX: 18);
CreatePipe(v49, xp3, true, label: "Ltg. 8");
CreatePipe(P6, xp4, true, label: "Ltg. 9");
CreatePipe(xp1, v51, true);
@@ -386,12 +404,12 @@ namespace PamhagenSysCtrl.Helpers {
CreatePipe(xp5, xp6);
CreatePipe(xp7, xp8);
var zv1 = new CenterValve("ZV1", pr1cX, prY - 40, () => App.Plant?.Press1HasClearance ?? false);
var zv2 = new CenterValve("ZV2", pr2cX, prY - 40, () => App.Plant?.Press2HasClearance ?? false);
var zv1 = new CenterValve("ZV1", pr1cX, prY - 8, () => App.Plant?.Press1HasClearance ?? false);
var zv2 = new CenterValve("ZV2", pr2cX, prY - 8, () => App.Plant?.Press2HasClearance ?? false);
CreatePipe(xp6, zv1, true);
CreatePipe(xp8, zv2, true);
CreateInlet(zv1, press1, true);
CreateInlet(zv2, press2, true);
CreateInlet(zv1, Press1, true);
CreateInlet(zv2, Press2, true);
}
protected Valve CreateValve(int n, double x, double y) {
@@ -402,6 +420,23 @@ namespace PamhagenSysCtrl.Helpers {
return new($"Tank {n}", x, y, capacity, () => App.Plant?.TankFillLevels[n - 1] ?? FillState.Unknown);
}
private int PathCost(Path p) {
return
1000 * p.Hops.Count(h => h.Node is Valve) +
(p.Hops.Any(h => h.Node is Valve v && v.Nr == 15) && !p.Hops.Any(h => h.Node is Valve v && (v.Nr == 16 || v.Nr == 20)) ? 10 : 0) +
(p.Hops.Any(h => h.Node is Valve v && v.Nr == 11) && !p.Hops.Any(h => h.Node is Valve v && (v.Nr == 14 || v.Nr == 21)) ? 10 : 0) +
(p.Hops.Any(h => h.Node is Valve v && v.Nr == 6) ? 10 : 0) +
p.Bends;
}
public Path? GetFreePath(IEnumerable<INode> points, bool overrideStart = false) {
if (overrideStart) {
return GetPath(points, (n) => n is not ISink && (n is not Valve v || !v.LockedForPaths.Any(p => p.Start != points.First())), PathCost);
} else {
return GetPath(points, (n) => n is not ISink && (n is not Valve v || !v.IsLocked), PathCost);
}
}
public void TraverseSubgraph(INode start, Func<INode, bool> invalid, HashSet<IEdge>? _visited = null, Action<INode, bool, IEdge>? edgeAction = null, Action<Valve>? valveAction = null, bool reverse = false) {
var visited = _visited ?? [];
if (start is Valve v) {
@@ -455,7 +490,11 @@ namespace PamhagenSysCtrl.Helpers {
private void UpdateValvesAdjacientToPath(Path path, bool locked, bool? wantOpen = null) {
foreach (var (edge, node) in path.Hops) {
TraverseSubgraph(node, (n) => n is Valve || n is ISink || n is Pump, valveAction: (v) => {
v.IsLocked = locked;
if (locked) {
v.LockedForPaths.Add(path);
} else {
v.LockedForPaths.Remove(path);
}
if (wantOpen.HasValue) {
if (wantOpen.Value) {
App.Plant?.OpenV(v.Nr);
+4 -3
View File
@@ -30,7 +30,7 @@ namespace PamhagenSysCtrl.Helpers {
public bool AreValvesClosed(params int[] ns) => ns.All(IsValveClosed) && ns.All(WantValveClosed);
public int TroughSelector => Sensors.TroughSelector;
public bool IsMWSelected => Sensors.TroughSelector == 1;
public bool IsMW1Selected => Sensors.TroughSelector == 1;
public bool IsMW2Selected => Sensors.TroughSelector == 2;
public FillState FillLevelMW1 => Sensors.FillingLevelMW1;
public FillState FillLevelMW2 => Sensors.FillingLevelMW2;
@@ -54,6 +54,7 @@ namespace PamhagenSysCtrl.Helpers {
public bool WantMW2Selected => !Actuators.GetV(58);
public bool IsTroughAugerActive => Actuators.TroughAuger;
public bool TroughAugerHasClearance => IsReblerActive && !(IsMW1Selected && FillLevelMW1 == FillState.Full) && !(IsMW2Selected && FillLevelMW2 == FillState.Full);
public bool IsReblerActive => Actuators.Rebler;
public bool IsStirrerMW1Active => Actuators.StirrerMW1;
public bool IsStirrerMW2Active => Actuators.StirrerMW2;
@@ -88,7 +89,7 @@ namespace PamhagenSysCtrl.Helpers {
if (p.IsReblerActive && !p.IsAuger1Active) p.StartAuger1();
if (p.IsAuger1Active && !p.IsAuger2Active) p.StartAuger2();
if (p.IsAuger2Active && !p.IsAuger3Active) p.StartAuger3();
if (p.IsTroughAugerActive && (!p.IsReblerActive || (p.IsMWSelected && p.FillLevelMW1 == FillState.Full) || (p.IsMW2Selected && p.FillLevelMW2 == FillState.Full)))
if (p.IsTroughAugerActive && !p.TroughAugerHasClearance)
p.StopTroughAuger();
}
@@ -410,7 +411,7 @@ namespace PamhagenSysCtrl.Helpers {
}
public void StartTroughAuger() {
if (!ManualControlMode && (!IsReblerActive || (IsMWSelected && FillLevelMW1 == FillState.Full) || (IsMW2Selected && FillLevelMW2 == FillState.Full)))
if (!ManualControlMode && !TroughAugerHasClearance)
throw new NoClearanceException("Schnecke Auffangwanne hat keine Freigabe");
Actuators.TroughAuger = true;
ActuatorsChanged = true;
+24 -27
View File
@@ -43,31 +43,28 @@ namespace PamhagenSysCtrl.Helpers {
GC.SuppressFinalize(this);
}
protected static FillState Int3ToFillState(int n) {
return n switch {
7 => FillState.Full,
6 => FillState.Half,
4 => FillState.Filled,
0 => FillState.Empty,
_ => FillState.Invalid,
};
protected static FillState Int3ToFillState(int n, bool bigEndian = true) {
return
(bigEndian && (n & 0x4) != 0) || (!bigEndian && (n & 0x1) != 0) ? FillState.Full :
(bigEndian && (n & 0x2) != 0) || (!bigEndian && (n & 0x2) != 0) ? FillState.Half :
(bigEndian && (n & 0x1) != 0) || (!bigEndian && (n & 0x4) != 0) ? FillState.Filled :
n == 0 ? FillState.Empty :
FillState.Invalid;
}
protected static FillState Int2ToFillState(int n) {
return n switch {
2 => FillState.Full,
0 => FillState.Filled,
1 => FillState.Empty,
_ => FillState.Invalid,
};
protected static FillState Int2ToFillState(int n, bool bigEndian = true) {
return
(bigEndian && (n & 0x2) != 0) || (!bigEndian && (n & 0x1) != 0) ? FillState.Full :
(bigEndian && (n & 0x1) != 0) || (!bigEndian && (n & 0x2) != 0) ? FillState.Filled :
n == 0 ? FillState.Empty :
FillState.Invalid;
}
protected static FillState Int1ToFillState(int n) {
return n switch {
1 => FillState.Full,
0 => FillState.Unknown,
_ => FillState.Invalid,
};
return
n == 1 ? FillState.Full :
n == 0 ? FillState.Unknown :
FillState.Invalid;
}
protected static MotorState Int2ToPumpState(int n, bool inverse) {
@@ -110,8 +107,8 @@ namespace PamhagenSysCtrl.Helpers {
long pressure = (long)r1 | ((long)r2 << 16) | ((long)r3 << 32) | ((long)r4 << 48);
pressure = (pressure & 0x01FFFFFFFFFFFFFF) | ((pressure & 0x0600000000000000) << 1);
var mw1 = Int3ToFillState((f1 ) & 0x7); // 111 011 001 000
var mw2 = Int3ToFillState((f1 >> 3) & 0x7); // 111 011 001 000
var mw1 = Int3ToFillState((f1 ) & 0x7, false); // 111 011 001 000
var mw2 = Int3ToFillState((f1 >> 3) & 0x7, false); // 111 011 001 000
var p1 = ((f1 >> 6) & 0x1) == 0; // 1 0
var p2 = ((f1 >> 7) & 0x1) == 0; // 1 0
var wp = ((f1 >> 8) & 0x3); // 10 01
@@ -129,11 +126,11 @@ namespace PamhagenSysCtrl.Helpers {
// -> factor: 0,03125 + (offset) 25 Oe
double oe = v * 0.03125 + 25;
var t1 = Int2ToFillState((f2 ) & 0x3); // 10 01 00
var t2 = Int2ToFillState((f2 >> 2) & 0x3); // 10 01 00
var t3 = Int2ToFillState((f2 >> 4) & 0x3); // 10 01 00
var t4 = Int2ToFillState((f2 >> 6) & 0x3); // 10 01 00
var t5 = Int2ToFillState((f2 >> 8) & 0x3); // 10 01 00
var t1 = Int1ToFillState(((f2 ) & 0x3) >> 1); // 1X 0X
var t2 = Int1ToFillState(((f2 >> 2) & 0x3) >> 1); // 1X 0X
var t3 = Int1ToFillState(((f2 >> 4) & 0x3) >> 1); // 1X 0X
var t4 = Int1ToFillState(((f2 >> 6) & 0x3) >> 1); // 1X 0X
var t5 = Int1ToFillState(((f2 >> 8) & 0x3) >> 1); // 1X 0X
var t6 = Int1ToFillState((f2 >> 10) & 0x1); // 1 0
var t7 = Int1ToFillState((f2 >> 11) & 0x1); // 1 0
var t8 = Int1ToFillState((f2 >> 12) & 0x1); // 1 0
+38 -24
View File
@@ -14,17 +14,21 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
public double Angle { get; set; }
public bool IsAnimationActive {
get => !(_storyboard?.GetIsPaused() ?? true);
set {
if (value) {
_storyboard?.Resume();
} else {
_storyboard?.Pause();
if (_storyboard == null) return;
if (value && _storyboard.GetIsPaused()) {
_storyboard.Resume();
} else if (!value && !_storyboard.GetIsPaused()) {
_storyboard.Pause();
}
}
}
private Polyline? _polyline;
private Storyboard? _storyboard;
private DoubleAnimation? _leftSlide;
private Canvas? _clipCanvas;
public Auger(double x, double y, double width, double height, double angle = 0) {
CenterX = x;
@@ -35,41 +39,51 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
}
public void Draw(Canvas canvas) {
var d = Height / 4;
int n = (int)(Width / d / 4) + 2;
_polyline = new Polyline() {
Points = [.. Enumerable.Range(0, n).SelectMany(i => new List<Point>() {
new(i * 4 * d, Height / 2), new((i * 4 + 1) * d, 0),
new((i * 4 + 2) * d, Height / 2), new((i * 4 + 3) * d, Height)
}), new(n * 4 * d, Height / 2), new(0, Height / 2)],
Fill = Brushes.Transparent,
Stroke = Brushes.Black,
StrokeThickness = 2,
};
_polyline.SetValue(Canvas.LeftProperty, 0.0);
var slideLeft = new DoubleAnimation {
_leftSlide = new DoubleAnimation {
From = 0,
To = -d * 4,
Duration = new Duration(TimeSpan.FromSeconds(1)),
RepeatBehavior = RepeatBehavior.Forever,
};
Storyboard.SetTarget(_leftSlide, _polyline);
_storyboard = new Storyboard();
_storyboard.Children.Add(slideLeft);
Storyboard.SetTarget(slideLeft, _polyline);
Storyboard.SetTargetProperty(slideLeft, new PropertyPath(Canvas.LeftProperty));
var clipCanvas = new Canvas() {
Width = Width,
Height = Height,
_storyboard.Children.Add(_leftSlide);
Storyboard.SetTargetProperty(_leftSlide, new PropertyPath(Canvas.LeftProperty));
_clipCanvas = new Canvas() {
ClipToBounds = true,
RenderTransform = new RotateTransform(Angle, Width / 2, Height / 2),
};
clipCanvas.SetValue(Canvas.TopProperty, CenterY - Height / 2);
clipCanvas.SetValue(Canvas.LeftProperty, CenterX - Width / 2);
clipCanvas.Children.Add(_polyline);
canvas.Children.Add(clipCanvas);
_clipCanvas.Children.Add(_polyline);
canvas.Children.Add(_clipCanvas);
_storyboard.Begin();
_storyboard.Pause();
}
public void Scale(double scale) {
var border = Graph.ToBorder(scale);
var d = Height / 4 * scale;
int n = (int)(Width * scale / d / 4) + 2;
_polyline?.Points = [.. Enumerable.Range(0, n).SelectMany(i => new List<Point>() {
new(i * 4 * d, Height / 2 * scale), new((i * 4 + 1) * d, 0),
new((i * 4 + 2) * d, Height / 2 * scale), new((i * 4 + 3) * d, Height * scale)
}), new(n * 4 * d, Height / 2 * scale), new(0, Height / 2 * scale)];
_polyline?.StrokeThickness = border;
var active = IsAnimationActive;
_leftSlide?.To = -d * 4;
_storyboard?.Stop();
_storyboard?.Begin();
if (!active) _storyboard?.Pause();
_clipCanvas?.Width = Width * scale;
_clipCanvas?.Height = Height * scale;
_clipCanvas?.RenderTransform = new RotateTransform(Angle, Width / 2 * scale, Height / 2 * scale);
_clipCanvas?.SetValue(Canvas.TopProperty, (CenterY - Height / 2) * scale);
_clipCanvas?.SetValue(Canvas.LeftProperty,( CenterX - Width / 2) * scale);
}
}
}
+12 -11
View File
@@ -6,7 +6,7 @@ using System.Windows.Shapes;
namespace PamhagenSysCtrl.Helpers.Pipeline {
public class CenterValve : INode {
public const double DIAMETER = 24;
public const double DIAMETER = 4.8;
public double CenterX { get; set; }
public double CenterY { get; set; }
@@ -33,29 +33,30 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
public void Draw(Canvas canvas) {
_circle = new Ellipse() {
Height = DIAMETER,
Width = DIAMETER,
Fill = Brushes.DarkGray,
Stroke = Brushes.Black,
StrokeThickness = 2,
};
_circle.SetValue(Canvas.LeftProperty, CenterX - DIAMETER / 2);
_circle.SetValue(Canvas.TopProperty, CenterY - DIAMETER / 2);
_text = new() {
Text = Label,
FontSize = 10,
Width = DIAMETER,
Height = DIAMETER,
TextAlignment = TextAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
SnapsToDevicePixels = true,
};
_text.SetValue(Canvas.LeftProperty, CenterX - DIAMETER / 2 + 0.5);
_text.SetValue(Canvas.TopProperty, CenterY - DIAMETER / 2 + 5.5);
canvas.Children.Add(_circle);
canvas.Children.Add(_text);
}
public void Scale(double scale) {
var border = Graph.ToBorder(scale);
Graph.SetCenter(_circle, CenterX, CenterY, DIAMETER, DIAMETER, scale);
_circle?.StrokeThickness = border;
_text?.Width = DIAMETER * scale;
_text?.Height = DIAMETER * scale;
_text?.FontSize = 2 * scale;
_text?.SetValue(Canvas.LeftProperty, (CenterX - DIAMETER / 2 + 0.1) * scale);
_text?.SetValue(Canvas.TopProperty, (CenterY - DIAMETER / 2 + 1.1) * scale);
}
public bool IsInside(double x, double y) {
return Math.Sqrt(Math.Pow(CenterX - x, 2) + Math.Pow(CenterY - y, 2)) <= DIAMETER / 2;
}
@@ -7,8 +7,8 @@ using System.Windows.Shapes;
namespace PamhagenSysCtrl.Helpers.Pipeline {
public class ConveyorBelt : INode {
public const double WIDTH = 30;
public const double HEIGHT = 120;
public const double WIDTH = 6;
public const double HEIGHT = 24;
public double CenterX { get; set; }
public double CenterY { get; set; }
@@ -18,22 +18,23 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
public bool IsActive => CallbackActive();
public bool IsAnimationActive {
get => _animationActive;
get => !(_storyboard?.GetIsPaused() ?? true);
set {
_animationActive = value;
if (value) {
_storyboard?.Resume();
} else {
_storyboard?.Pause();
if (_storyboard == null) return;
if (value && _storyboard.GetIsPaused()) {
_storyboard.Resume();
} else if (!value && !_storyboard.GetIsPaused()) {
_storyboard.Pause();
}
}
}
protected Func<bool> CallbackActive;
private bool _animationActive;
private Shape? _rect;
private Rectangle? _rect;
private Polyline? _polyline;
private DoubleAnimation? _slideUp;
private Canvas? _clipCanvas;
private Storyboard? _storyboard;
public ConveyorBelt(string label, double x, double y, Func<bool> cbActive) {
@@ -47,52 +48,63 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
public void Draw(Canvas canvas) {
_rect = new Rectangle() {
Width = WIDTH,
Height = HEIGHT,
Stroke = Brushes.Black,
StrokeThickness = 2,
Fill = Brushes.WhiteSmoke,
StrokeLineJoin = PenLineJoin.Round,
};
_rect.SetValue(Canvas.LeftProperty, CenterX - WIDTH / 2);
_rect.SetValue(Canvas.TopProperty, CenterY - HEIGHT / 2);
var d = 15;
int n = (int)(HEIGHT / d) + 2;
_polyline = new Polyline() {
Points = [.. Enumerable.Range(0, n).SelectMany(i => new List<Point>() {
new(-WIDTH, i * d), new(WIDTH, i * d), new(-WIDTH, i * d)
})],
Fill = Brushes.Transparent,
Stroke = Brushes.Black,
StrokeThickness = 2,
};
_polyline.SetValue(Canvas.TopProperty, 0.0);
var slideUp = new DoubleAnimation {
_slideUp = new DoubleAnimation {
From = 0,
To = -d,
Duration = new Duration(TimeSpan.FromSeconds(1)),
RepeatBehavior = RepeatBehavior.Forever,
};
Storyboard.SetTargetProperty(_slideUp, new PropertyPath(Canvas.TopProperty));
_storyboard = new Storyboard();
_storyboard.Children.Add(slideUp);
Storyboard.SetTarget(slideUp, _polyline);
Storyboard.SetTargetProperty(slideUp, new PropertyPath(Canvas.TopProperty));
var clipCanvas = new Canvas() {
Width = WIDTH - 15,
Height = HEIGHT - 8,
_storyboard.Children.Add(_slideUp);
Storyboard.SetTarget(_slideUp, _polyline);
_clipCanvas = new Canvas() {
ClipToBounds = true,
};
clipCanvas.SetValue(Canvas.TopProperty, CenterY - HEIGHT / 2 + 4);
clipCanvas.SetValue(Canvas.LeftProperty, CenterX - WIDTH / 2 + 7.5);
clipCanvas.Children.Add(_polyline);
_clipCanvas.Children.Add(_polyline);
canvas.Children.Add(_rect);
canvas.Children.Add(clipCanvas);
canvas.Children.Add(_clipCanvas);
_storyboard.Begin();
_storyboard.Pause();
}
public void Scale(double scale) {
var border = Graph.ToBorder(scale);
_rect?.Width = WIDTH * scale;
_rect?.Height = HEIGHT * scale;
_rect?.StrokeThickness = border;
_rect?.SetValue(Canvas.LeftProperty, (CenterX - WIDTH / 2) * scale);
_rect?.SetValue(Canvas.TopProperty, (CenterY - HEIGHT / 2) * scale);
var d = Math.Round(3 * scale);
int n = (int)(HEIGHT * scale / d) + 2;
_polyline?.Points = [.. Enumerable.Range(0, n).SelectMany(i => new List<Point>() {
new(-WIDTH * scale, i * d), new(WIDTH * scale, i * d), new(-WIDTH * scale, i * d)
})];
_polyline?.StrokeThickness = border;
var active = IsAnimationActive;
_slideUp?.To = -d;
_storyboard?.Stop();
_storyboard?.Begin();
if (!active) _storyboard?.Pause();
_clipCanvas?.Width = (WIDTH - 2.2) * scale - border * 2;
_clipCanvas?.Height = (HEIGHT - 0.8) * scale - border * 2;
_clipCanvas?.SetValue(Canvas.LeftProperty, (CenterX - WIDTH / 2 + 1.1) * scale + border);
_clipCanvas?.SetValue(Canvas.TopProperty, (CenterY - HEIGHT / 2 + 0.4) * scale + border);
}
public bool IsInside(double x, double y) {
@@ -102,11 +114,11 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
public void Update(bool isHovering, bool isPressed) {
IsAnimationActive = IsActive;
_rect?.Fill =
IsAnimationActive && isHovering && isPressed ? PamhagenBrushes.Red :
IsAnimationActive && isHovering ? PamhagenBrushes.Red :
!IsAnimationActive && isHovering && isPressed ? PamhagenBrushes.Green :
!IsAnimationActive && isHovering ? PamhagenBrushes.Green :
IsAnimationActive ? PamhagenBrushes.Green :
IsActive && isHovering && isPressed ? PamhagenBrushes.Red :
IsActive && isHovering ? PamhagenBrushes.Red :
!IsActive && isHovering && isPressed ? PamhagenBrushes.Green :
!IsActive && isHovering ? PamhagenBrushes.Green :
IsActive ? PamhagenBrushes.Green :
Brushes.WhiteSmoke;
}
}
@@ -6,8 +6,8 @@ using System.Windows.Shapes;
namespace PamhagenSysCtrl.Helpers.Pipeline {
public class EncasedAuger : INode {
public const double WIDTH = 80;
public const double HEIGHT = 20;
public const double WIDTH = 16;
public const double HEIGHT = 4;
public double CenterX { get; set; }
public double CenterY { get; set; }
@@ -29,8 +29,9 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
protected Func<bool> CallbackActive;
private bool _animationActive;
private Shape? _inner;
private Shape? _outer;
private Canvas? _canvas;
private Rectangle? _inner;
private Rectangle? _outer;
private Auger? _auger;
private TextBlock? _text;
@@ -46,41 +47,49 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
}
public void Draw(Canvas canvas) {
var c = new Canvas() {
RenderTransform = new RotateTransform(Angle, WIDTH / 2, HEIGHT / 2),
_canvas = new Canvas() {
RenderTransform = new RotateTransform(Angle),
};
_outer = new Rectangle() {
Width = WIDTH,
Height = HEIGHT,
Fill = Brushes.Black,
};
_inner = new Rectangle() {
Width = WIDTH,
Height = HEIGHT - 4,
Fill = Brushes.WhiteSmoke,
};
c.SetValue(Canvas.LeftProperty, CenterX - WIDTH / 2);
c.SetValue(Canvas.TopProperty, CenterY - HEIGHT / 2);
_inner.SetValue(Canvas.TopProperty, 2.0);
c.Children.Add(_outer);
c.Children.Add(_inner);
canvas.Children.Add(c);
_canvas.Children.Add(_outer);
_canvas.Children.Add(_inner);
canvas.Children.Add(_canvas);
_text = new() {
Text = Label,
Width = WIDTH,
FontSize = 12,
TextAlignment = TextAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
};
_text.SetValue(Canvas.LeftProperty, CenterX - WIDTH / 2);
_text.SetValue(Canvas.TopProperty, CenterY + HEIGHT / 2);
canvas.Children.Add(_text);
_auger = new Auger(CenterX, CenterY, WIDTH, 12, Angle);
_auger = new Auger(CenterX, CenterY, WIDTH, 2.4, Angle);
_auger.Draw(canvas);
}
public void Scale(double scale) {
var border = Graph.ToBorder(scale);
_canvas?.SetValue(Canvas.LeftProperty, (CenterX - WIDTH / 2) * scale);
_canvas?.SetValue(Canvas.TopProperty, (CenterY - HEIGHT / 2) * scale);
_canvas?.RenderTransform = new RotateTransform(Angle, WIDTH / 2 * scale, HEIGHT / 2 * scale);
_outer?.Width = WIDTH * scale;
_outer?.Height = HEIGHT * scale;
_inner?.Width = WIDTH * scale;
_inner?.Height = HEIGHT * scale - border * 2;
_inner?.SetValue(Canvas.TopProperty, border);
_text?.FontSize = 12;
_text?.Width = WIDTH * scale;
_text?.SetValue(Canvas.LeftProperty, (CenterX - WIDTH / 2) * scale);
_text?.SetValue(Canvas.TopProperty, (CenterY + HEIGHT / 2) * scale);
_auger?.Scale(scale);
}
public bool IsInside(double x, double y) {
return Math.Sqrt(Math.Pow(CenterX - x, 2) + Math.Pow(CenterY - y, 2)) <= WIDTH / 2;
}
+47 -22
View File
@@ -7,8 +7,8 @@ using System.Windows.Shapes;
namespace PamhagenSysCtrl.Helpers.Pipeline {
class EntryTrough : INode {
public const double WIDTH = 150;
public const double HEIGHT = 60;
public const double WIDTH = 30;
public const double HEIGHT = 12;
public double CenterX { get; set; }
public double CenterY { get; set; }
@@ -20,9 +20,8 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
public bool IsAnimationActive {
get => _animationActive;
set {
_animationActive = value;
_auger?.IsAnimationActive = value;
if (value) {
if (value && !_animationActive) {
_doorTransform?.BeginAnimation(
RotateTransform.AngleProperty,
new DoubleAnimation {
@@ -30,7 +29,7 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
To = 60,
Duration = TimeSpan.FromSeconds(Math.Abs(_doorTransform.Angle - 60) / 60.0)
});
} else {
} else if (!value && _animationActive) {
_doorTransform?.BeginAnimation(
RotateTransform.AngleProperty,
new DoubleAnimation {
@@ -39,17 +38,23 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
Duration = TimeSpan.FromSeconds(Math.Abs(_doorTransform.Angle - 0) / 60.0)
});
}
_animationActive = value;
}
}
public double Top => CenterY - HEIGHT / 2;
public double Right => CenterX + WIDTH / 2;
public double Bottom => CenterY + HEIGHT / 2;
public double Left => CenterX - WIDTH / 2;
protected Func<bool> CallbackActive;
private bool _animationActive;
private Shape? _inner;
private Shape? _outer;
private Polygon? _inner;
private Polygon? _outer;
private TextBlock? _text;
private Auger? _auger;
private Shape? _door;
private Line? _door;
private RotateTransform? _doorTransform;
public EntryTrough(string label, double x, double y, Func<bool> cbActive) {
@@ -62,42 +67,62 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
}
public void Draw(Canvas canvas) {
var top = CenterY - HEIGHT / 2;
var right = CenterX + WIDTH / 2;
var bottom = CenterY + HEIGHT / 2;
var left = CenterX - WIDTH / 2;
_outer = new Polygon() {
Points = [new(left, top), new(right, top), new(right - 20, bottom), new(left, bottom), new(left, bottom - 20), new(left + 12.5, bottom - 20)],
Fill = Brushes.Black,
};
_inner = new Polygon() {
Points = [new(left + 2, top), new(right - 2, top), new(right - 20 - 2, bottom - 2), new(left, bottom - 2), new(left, bottom - 18), new(left + 15.5, bottom - 18)],
Fill = Brushes.WhiteSmoke,
};
_doorTransform = new RotateTransform(0, left, bottom - 24);
_doorTransform = new RotateTransform(0);
_door = new Line() {
X1 = left, Y1 = bottom - 24, X2 = left, Y2 = bottom + 4,
Stroke = Brushes.Black,
StrokeThickness = 4,
RenderTransform = _doorTransform,
};
_text = new() {
Text = Label,
FontSize = 12,
Width = WIDTH,
TextAlignment = TextAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
};
_text.SetValue(Canvas.LeftProperty, CenterX - WIDTH / 2);
_text.SetValue(Canvas.TopProperty, CenterY - 7.5 - 8);
canvas.Children.Add(_outer);
canvas.Children.Add(_inner);
canvas.Children.Add(_text);
canvas.Children.Add(_door);
_auger = new(CenterX - 11, CenterY + HEIGHT / 2 - 9, WIDTH - 25, 12);
_auger = new(CenterX - 2.2, CenterY + HEIGHT / 2 - 1.8, WIDTH - 5, 2.4);
_auger.Draw(canvas);
}
public void Scale(double scale) {
var border = Graph.ToBorder(scale);
_outer?.Points = [
new(Left * scale, Top * scale),
new(Right * scale, Top * scale),
new((Right - 4) * scale, Bottom * scale),
new(Left * scale, Bottom * scale),
new(Left * scale, (Bottom - 4) * scale),
new((Left + 2.5) * scale, (Bottom - 4) * scale),
];
_inner?.Points = [
new(Left * scale + border, Top * scale),
new(Right * scale - border, Top * scale),
new((Right - 4) * scale - border, Bottom * scale - border),
new(Left * scale, Bottom * scale - border),
new(Left * scale, (Bottom - 3.6) * scale),
new((Left + 3.1) * scale, (Bottom - 3.6) * scale),
];
_door?.X1 = Left * scale;
_door?.Y1 = (Bottom - 4.8) * scale;
_door?.X2 = Left * scale;
_door?.Y2 = (Bottom + 0.8) * scale;
_door?.StrokeThickness = border * 2;
_doorTransform?.CenterX = Left * scale;
_doorTransform?.CenterY = (Bottom - 4.8) * scale;
_text?.FontSize = 12;
_text?.Width = WIDTH * scale;
_text?.SetValue(Canvas.LeftProperty, (CenterX - WIDTH / 2) * scale);
_text?.SetValue(Canvas.TopProperty, (CenterY - 1.5) * scale - 8);
_auger?.Scale(scale);
}
public bool IsInside(double x, double y) {
return Math.Abs(x - CenterX) <= WIDTH / 2 && Math.Abs(y - CenterY) <= HEIGHT / 2;
}
+18 -21
View File
@@ -7,42 +7,40 @@ using System.Windows.Shapes;
namespace PamhagenSysCtrl.Helpers.Pipeline {
internal sealed class FlowArrows {
public const double SPEED = 20;
public const double SPACING = 15;
public const double LENGTH = 7;
public const double WIDTH = 7;
public const double SPEED = 4;
public const double SPACING = 3;
public const double LENGTH = 1.4;
public const double WIDTH = 1.4;
private static readonly Stopwatch Clock = Stopwatch.StartNew();
private double _scale = 5;
private readonly Canvas _layer;
private readonly Point[] _path;
private Point[] _points = [];
private double _length;
private double _pathOffset;
private bool _isActive;
public double Length => GetLength(_path[0], _path[1]) + GetLength(_path[1], _path[2]);
public double Length { get; init; }
private FlowArrows(Canvas canvas, Point[] path) {
private FlowArrows(Point[] path) {
_path = path;
Length = _path.Length <= 1 ? 0 : Enumerable.Range(0, _path.Length - 1).Sum(i => GetLength(_path[i], _path[i + 1]));
_layer = new Canvas() {
IsHitTestVisible = false,
Visibility = Visibility.Collapsed,
};
_layer.Unloaded += (_, _) => Stop();
canvas.Children.Add(_layer);
}
public static FlowArrows Create(Canvas canvas, Line first, Line second) {
return new FlowArrows(canvas, [
new Point(first.X1, first.Y1),
new Point(first.X2, first.Y2),
new Point(second.X2, second.Y2),
]);
public static FlowArrows Create(Canvas canvas, IEnumerable<Point> points) {
var arrows = new FlowArrows([.. points]);
canvas.Children.Add(arrows._layer);
return arrows;
}
public static FlowArrows Create(Canvas canvas, Polyline path) {
return new FlowArrows(canvas, [.. path.Points]);
public void Scale(double scale) {
_scale = scale;
}
public void Update((bool TowardEnd, double PathOffset)? flow) {
@@ -52,7 +50,6 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
}
_points = flow.Value.TowardEnd ? _path : [.. _path.Reverse()];
_length = GetLength(_points[0], _points[1]) + GetLength(_points[1], _points[2]);
_pathOffset = flow.Value.PathOffset;
if (!_isActive) {
CompositionTarget.Rendering += OnRendering;
@@ -69,7 +66,7 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
private void Render() {
var distance = ((Clock.Elapsed.TotalSeconds * SPEED - _pathOffset) % SPACING + SPACING) % SPACING;
var arrowIndex = 0;
while (distance <= _length) {
while (distance <= Length) {
var arrow = GetArrow(arrowIndex++);
SetPosition(arrow, distance);
arrow.Visibility = Visibility.Visible;
@@ -145,9 +142,9 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
direction = v2;
}
double ux = direction.X;
double uy = direction.Y;
(arrow.RenderTransform as MatrixTransform)?.Matrix = new Matrix(ux, uy, -uy, ux, position.X, position.Y);
double ux = direction.X * _scale;
double uy = direction.Y * _scale;
(arrow.RenderTransform as MatrixTransform)?.Matrix = new Matrix(ux, uy, -uy, ux, position.X * _scale, position.Y * _scale);
}
private void Stop() {
+79 -26
View File
@@ -1,5 +1,7 @@
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Media3D;
using System.Windows.Shapes;
namespace PamhagenSysCtrl.Helpers.Pipeline {
@@ -54,64 +56,115 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
return p;
}
public Path? GetPath(IEnumerable<INode> points, Func<INode, bool>? valid = null) {
public Path? GetPath(IEnumerable<INode> points, Func<INode, bool>? valid = null, Func<Path, int>? cost = null) {
if (points.Count() < 2) return null;
var start = points.First();
var path = new Path(start, []);
List<Path> paths = [new(start, [])];
foreach (var end in points.Skip(1)) {
if (valid != null && start != points.First() && !valid(start)) {
if (valid != null && start != points.First() && !valid(start))
return null;
} else if (GetPath(start, end, valid, visited: [.. path.Hops.Select(h => h.Node)]) is not Path p) {
return null;
} else {
path.Hops = [.. path.Hops, .. p.Hops];
start = end;
var newPaths = new List<Path>();
foreach (var path in paths) {
foreach (var subPath in GetPaths(start, end, visited: [.. path.Hops.Select(h => h.Node)], valid)) {
newPaths.Add(new(path.Start, [.. path.Hops, .. subPath.Hops]));
}
}
if (newPaths.Count == 0)
return null;
paths = newPaths;
start = end;
}
if (paths.Count == 0) {
return null;
} else {
cost ??= p => 0;
return paths.OrderBy(cost).First();
}
return path;
}
public Path? GetPath(INode start, INode end, Func<INode, bool>? valid = null, HashSet<INode>? visited = null) {
public IEnumerable<Path> GetPaths(INode start, INode end, HashSet<INode>? visited = null, Func<INode, bool>? valid = null) {
if (!Nodes.Contains(start) || !Nodes.Contains(end)) throw new ArgumentException("Start/end node not contained in graph");
valid ??= a => true;
visited = [.. visited ?? [], start];
List<(IEdge, INode)> hops = [];
Path? path = null;
foreach (var o in start.Outputs) {
var e = o.IsTwoWay && o.End == start ? o.Start : o.End;
if (e == end) {
return new(start, [(o, e)]);
yield return new(start, [(o, e)]);
continue;
} else if (!valid(e) || visited.Contains(e)) {
continue;
}
var p = GetPath(e, end, valid, visited);
if (p != null) {
var p2 = new Path(start, [(o, e), .. p.Value.Hops]);
if (path == null || p2.Bends < path.Value.Bends || (p2.Bends == path.Value.Bends && p2.Length < path.Value.Length)) {
path = p2;
}
foreach (var p in GetPaths(e, end, visited, valid)) {
yield return new(start, [(o, e), .. p.Hops]);
}
}
return path != null ? new(start, path.Value.Hops) : null;
}
public void Draw(Canvas canvas) {
canvas.Children.Add(new Rectangle() {
public void Draw(Canvas canvas, double scale) {
var bg = new Rectangle() {
Fill = Brushes.White,
Width = 5000,
Height = 5000,
});
Width = 8000,
Height = 8000,
};
SetPos(bg, -4000, -4000, 1);
canvas.Children.Add(bg);
foreach (var e in Edges) {
e.Draw(canvas);
e.Scale(scale);
}
foreach (var n in Nodes) {
n.Draw(canvas);
n.Scale(scale);
}
}
public ISet<INode> GetHover(double x, double y) {
return Nodes.Where(n => n.IsInside(x, y)).ToHashSet();
public void Scale(double scale) {
foreach (var e in Edges) {
e.Scale(scale);
}
foreach (var n in Nodes) {
n.Scale(scale);
}
}
public static double ToPx(double v, double scale) {
return Math.Round(v * scale);
}
public static Point ToPx(double x, double y, double scale, double dxpx = 0, double dypx = 0, bool round = true) {
var p = new Point(x * scale + dxpx, y * scale + dypx);
return round ? new(Math.Round(p.X), Math.Round(p.Y)) : p;
}
public static Point ToPx(Point p, double scale) {
return ToPx(p.X, p.Y, scale);
}
public static double ToBorder(double scale) {
return scale > 10 ? 4 : scale > 7.5 ? 3 : scale > 4 ? 2 : 1;
}
public static void SetPos(FrameworkElement? s, double x, double y, double scale, double dxpx = 0, double dypx = 0) {
s?.SetValue(Canvas.LeftProperty, ToPx(x, scale) + dxpx);
s?.SetValue(Canvas.TopProperty, ToPx(y, scale) + dypx);
}
public static void SetWH(Shape? s, double w, double h, double scale) {
s?.Width = ToPx(w, scale);
s?.Height = ToPx(h, scale);
}
public static void SetCenter(Shape? s, double cx, double cy, double w, double h, double scale) {
Graph.SetWH(s, w, h, scale);
Graph.SetPos(s, cx - w / 2, cy - h / 2, scale);
}
public ISet<INode> GetHover(double x, double y, double scale) {
return Nodes.Where(n => n.IsInside(x / scale, y / scale)).ToHashSet();
}
public void Update(ISet<INode> hovering, bool isPressed) {
@@ -6,8 +6,8 @@ using System.Windows.Shapes;
namespace PamhagenSysCtrl.Helpers.Pipeline {
public class HeatExchanger : INode {
public const double WIDTH = 30;
public const double HEIGHT = 120;
public const double WIDTH = 6;
public const double HEIGHT = 24;
public double CenterX { get; set; }
public double CenterY { get; set; }
@@ -28,29 +28,30 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
public void Draw(Canvas canvas) {
_rect = new Rectangle() {
Width = WIDTH,
Height = HEIGHT,
Stroke = Brushes.Black,
StrokeThickness = 2,
Fill = Brushes.WhiteSmoke,
};
_text = new() {
Text = Label,
FontSize = 12,
Width = HEIGHT,
TextAlignment = TextAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
RenderTransform = new RotateTransform(270),
SnapsToDevicePixels = true,
};
_rect.SetValue(Canvas.LeftProperty, CenterX - WIDTH / 2);
_rect.SetValue(Canvas.TopProperty, CenterY - HEIGHT / 2);
_text.SetValue(Canvas.LeftProperty, CenterX - 9);
_text.SetValue(Canvas.TopProperty, CenterY + HEIGHT / 2);
canvas.Children.Add(_rect);
canvas.Children.Add(_text);
}
public void Scale(double scale) {
var border = Graph.ToBorder(scale);
Graph.SetWH(_rect, WIDTH, HEIGHT, scale);
Graph.SetPos(_rect, CenterX - WIDTH / 2, CenterY - HEIGHT / 2, scale);
_rect?.StrokeThickness = border;
_text?.FontSize = 12;
_text?.Width = Math.Round(HEIGHT * scale);
Graph.SetPos(_text, CenterX, CenterY + HEIGHT / 2, scale, dxpx: -9);
}
public bool IsInside(double x, double y) {
return Math.Abs(x - CenterX) <= WIDTH / 2 && Math.Abs(y - CenterY) <= HEIGHT / 2;
}
@@ -14,6 +14,7 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
public double FlowLength { get; }
public void Draw(Canvas canvas);
public void Scale(double scale);
public void Update();
}
}
+1 -1
View File
@@ -10,8 +10,8 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
public ISet<IEdge> Outputs { get; }
public void Draw(Canvas canvas);
public void Scale(double scale);
public void Update(bool isHovering, bool isPressed);
public bool IsInside(double x, double y);
}
}
+26 -49
View File
@@ -15,10 +15,15 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
public (bool TowardEnd, double PathOffset)? Flow { get; set; }
public double FlowLength => _flowArrows?.Length ?? 0;
private Line? _outer1;
private Line? _outer2;
private Line? _inner1;
private Line? _inner2;
public double X1 => Start.CenterX;
public double Y1 => Start.CenterY;
public double X2 => Start.CenterX;
public double Y2 => Orientation ? Sink.CenterY - 2 : Sink.TopY - 2;
public double X3 => Orientation ? Sink.CenterX : Start.CenterX + (Start.CenterX == End.CenterX ? 0 : Start.CenterX > End.CenterX ? -4 : 4);
public double Y3 => Orientation ? Sink.CenterY - 2 : Sink.TopY + 4;
private Polyline? _outer;
private Polyline? _inner;
private FlowArrows? _flowArrows;
public Inlet(INode start, ISink end, bool orientation = false) {
@@ -28,62 +33,34 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
}
public void Draw(Canvas canvas) {
var x1 = Start.CenterX;
var y1 = Start.CenterY;
var x2 = Start.CenterX;
var y2 = Orientation ? Sink.CenterY - 10 : Sink.TopY - 10;
var x3 = Orientation ? Sink.CenterX : Start.CenterX + (Start.CenterX == End.CenterX ? 0 : Start.CenterX > End.CenterX ? -20 : 20);
var y3 = Orientation ? Sink.CenterY - 10 : Sink.TopY + 20;
_outer1 = new Line() {
X1 = x1,
Y1 = y1,
X2 = x2,
Y2 = y2,
StrokeThickness = 10,
Stroke = Brushes.Black,
StrokeStartLineCap = PenLineCap.Round,
StrokeEndLineCap = PenLineCap.Round,
};
_inner1 = new Line() {
X1 = x1,
Y1 = y1,
X2 = x2,
Y2 = y2,
StrokeThickness = 6,
Stroke = Brushes.DarkGray,
StrokeStartLineCap = PenLineCap.Round,
StrokeEndLineCap = PenLineCap.Round,
};
_outer2 = new Line() {
X1 = x2,
Y1 = y2,
X2 = x3,
Y2 = y3,
StrokeThickness = 10,
_outer = new Polyline() {
Stroke = Brushes.Black,
StrokeStartLineCap = PenLineCap.Round,
StrokeLineJoin = PenLineJoin.Round,
StrokeEndLineCap = PenLineCap.Flat,
};
_inner2 = new Line() {
X1 = x2,
Y1 = y2,
X2 = x3,
Y2 = y3,
StrokeThickness = 6,
_inner = new Polyline() {
Stroke = Brushes.DarkGray,
StrokeStartLineCap = PenLineCap.Round,
StrokeLineJoin = PenLineJoin.Round,
StrokeEndLineCap = PenLineCap.Flat,
};
canvas.Children.Add(_outer1);
canvas.Children.Add(_outer2);
canvas.Children.Add(_inner1);
canvas.Children.Add(_inner2);
_flowArrows = FlowArrows.Create(canvas, _inner1!, _inner2!);
canvas.Children.Add(_outer);
canvas.Children.Add(_inner);
_flowArrows = FlowArrows.Create(canvas, [new(X1, Y1), new(X2, Y2), new(X3, Y3)]);
}
public void Scale(double scale) {
var border = Graph.ToBorder(scale);
_outer?.Points = [Graph.ToPx(X1, Y1, scale), Graph.ToPx(X2, Y2, scale), Graph.ToPx(X3, Y3, scale)];
_inner?.Points = [Graph.ToPx(X1, Y1, scale), Graph.ToPx(X2, Y2, scale), Graph.ToPx(X3, Y3, scale)];
_inner?.StrokeThickness = Math.Round(1.2 * scale / 2) * 2;
_outer?.StrokeThickness = Math.Round(1.2 * scale / 2) * 2 + border * 2;
_flowArrows?.Scale(scale);
}
public void Update() {
_inner1?.Stroke = Highlight ?? Brushes.DarkGray;
_inner2?.Stroke = Highlight ?? Brushes.DarkGray;
_inner?.Stroke = Highlight ?? Brushes.DarkGray;
_flowArrows?.Update(Flow);
}
}
+29 -52
View File
@@ -5,7 +5,7 @@ using System.Windows.Shapes;
namespace PamhagenSysCtrl.Helpers.Pipeline {
public class Outlet : IEdge {
public const double POINT = 16;
public const double POINT = 3.2;
public INode Start => Source;
public INode End { get; set; }
@@ -17,12 +17,17 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
public (bool TowardEnd, double PathOffset)? Flow { get; set; }
public double FlowLength => _flowArrows?.Length ?? 0;
public double X1 => Start.CenterX;
public double Y1 => Source.BottomY;
public double X2 => Orientation ? Start.CenterX : End.CenterX;
public double Y2 => Orientation ? End.CenterY : Start.CenterY;
public double X3 => End.CenterX;
public double Y3 => End.CenterY;
private Polygon? _hopper;
private FlowArrows? _flowArrows;
private Line? _outer1;
private Line? _outer2;
private Line? _inner1;
private Line? _inner2;
private Polyline? _outer;
private Polyline? _inner;
public Outlet(ISource start, INode end) {
Source = start;
@@ -31,69 +36,41 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
}
public void Draw(Canvas canvas) {
var x1 = Start.CenterX ;
var y1 = Source.BottomY;
var x2 = Orientation ? Start.CenterX : End.CenterX;
var y2 = Orientation ? End.CenterY : Start.CenterY;
var x3 = End.CenterX;
var y3 = End.CenterY;
_hopper = new Polygon() {
Points = [new(x1 - POINT, y1 - 2), new(x1 + POINT, y1 - 2), new(x1, y1 + POINT)],
Fill = Brushes.DarkGray,
Stroke = Brushes.Black,
StrokeThickness = 2,
};
_outer1 = new Line() {
X1 = x1,
Y1 = y1,
X2 = x2,
Y2 = y2,
StrokeThickness = 10,
_outer = new Polyline() {
Stroke = Brushes.Black,
StrokeStartLineCap = PenLineCap.Round,
StrokeLineJoin = PenLineJoin.Round,
StrokeEndLineCap = PenLineCap.Round,
};
_inner1 = new Line() {
X1 = x1,
Y1 = y1,
X2 = x2,
Y2 = y2,
StrokeThickness = 6,
_inner = new Polyline() {
Stroke = Brushes.DarkGray,
StrokeStartLineCap = PenLineCap.Round,
StrokeLineJoin = PenLineJoin.Round,
StrokeEndLineCap = PenLineCap.Round,
};
_outer2 = new Line() {
X1 = x2,
Y1 = y2,
X2 = x3,
Y2 = y3,
StrokeThickness = 10,
Stroke = Brushes.Black,
StrokeStartLineCap = PenLineCap.Round,
StrokeEndLineCap = PenLineCap.Round,
};
_inner2 = new Line() {
X1 = x2,
Y1 = y2,
X2 = x3,
Y2 = y3,
StrokeThickness = 6,
Stroke = Brushes.DarkGray,
StrokeStartLineCap = PenLineCap.Round,
StrokeEndLineCap = PenLineCap.Round,
};
canvas.Children.Add(_outer1);
canvas.Children.Add(_outer2);
canvas.Children.Add(_outer);
canvas.Children.Add(_hopper);
canvas.Children.Add(_inner1);
canvas.Children.Add(_inner2);
_flowArrows = FlowArrows.Create(canvas, _inner1!, _inner2!);
canvas.Children.Add(_inner);
_flowArrows = FlowArrows.Create(canvas, [new(X1, Y1), new(X2, Y2), new(X3, Y3)]);
}
public void Scale(double scale) {
var border = Graph.ToBorder(scale);
_hopper?.Points = [Graph.ToPx(X1 - POINT, Y1, scale, dypx: -border * 2), Graph.ToPx(X1 + POINT, Y1, scale, dypx: -border * 2), Graph.ToPx(X1, Y1 + POINT, scale)];
_hopper?.StrokeThickness = border;
_outer?.Points = [Graph.ToPx(X1, Y1, scale), Graph.ToPx(X2, Y2, scale), Graph.ToPx(X3, Y3, scale)];
_inner?.Points = [Graph.ToPx(X1, Y1, scale), Graph.ToPx(X2, Y2, scale), Graph.ToPx(X3, Y3, scale)];
_inner?.StrokeThickness = Math.Round(1.2 * scale / 2) * 2;
_outer?.StrokeThickness = Math.Round(1.2 * scale / 2) * 2 + border * 2;
_flowArrows?.Scale(scale);
}
public void Update() {
_inner1?.Stroke = Highlight ?? Brushes.DarkGray;
_inner2?.Stroke = Highlight ?? Brushes.DarkGray;
_inner?.Stroke = Highlight ?? Brushes.DarkGray;
_hopper?.Fill = Highlight ?? Brushes.DarkGray;
_flowArrows?.Update(Flow);
}
+1 -1
View File
@@ -3,7 +3,7 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
INode Start,
IEnumerable<(IEdge Edge, INode Node)> Hops)
{
public readonly double Bends => Hops.Sum(h => (h.Node is not Valve && h.Node is not PipeJoin ? 1 : 0) + (h.Edge.Start.CenterX != h.Edge.End.CenterX && h.Edge.Start.CenterY != h.Edge.End.CenterY ? 1 : 0));
public readonly int Bends => Hops.Sum(h => (h.Node is not Valve && h.Node is not PipeJoin ? 1 : 0) + (h.Edge.Start.CenterX != h.Edge.End.CenterX && h.Edge.Start.CenterY != h.Edge.End.CenterY ? 1 : 0));
public readonly double Length => Hops.Sum(h => Math.Abs(h.Edge.Start.CenterX - h.Edge.End.CenterX) + Math.Abs(h.Edge.Start.CenterY - h.Edge.End.CenterY));
}
}
+20 -15
View File
@@ -15,6 +15,13 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
public (bool TowardEnd, double PathOffset)? Flow { get; set; }
public double FlowLength => _flowArrows?.Length ?? 0;
public double X1 => Start.CenterX;
public double Y1 => Start.CenterY;
public double X2 => Orientation ? Start.CenterX : End.CenterX;
public double Y2 => Orientation ? End.CenterY : Start.CenterY;
public double X3 => End.CenterX;
public double Y3 => End.CenterY;
private Polyline? _outer;
private Polyline? _inner;
private TextBlock? _text;
@@ -31,23 +38,13 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
}
public void Draw(Canvas canvas) {
var x1 = Start.CenterX;
var y1 = Start.CenterY;
var x2 = Orientation ? Start.CenterX : End.CenterX;
var y2 = Orientation ? End.CenterY : Start.CenterY;
var x3 = End.CenterX;
var y3 = End.CenterY;
_outer = new Polyline() {
Points = [new(x1, y1), new(x2, y2), new(x3, y3)],
StrokeThickness = 10,
Stroke = Brushes.Black,
StrokeStartLineCap = PenLineCap.Round,
StrokeEndLineCap = PenLineCap.Round,
StrokeLineJoin = PenLineJoin.Round,
};
_inner = new Polyline() {
Points = [new(x1, y1), new(x2, y2), new(x3, y3)],
StrokeThickness = 6,
Stroke = Brushes.DarkGray,
StrokeStartLineCap = PenLineCap.Round,
StrokeEndLineCap = PenLineCap.Round,
@@ -58,18 +55,26 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
if (Label != null) {
_text = new() {
Text = Label,
FontSize = 12,
Width = 50,
TextAlignment = TextAlignment.Center,
VerticalAlignment = VerticalAlignment.Bottom,
HorizontalAlignment = HorizontalAlignment.Center,
SnapsToDevicePixels = true,
};
_text.SetValue(Canvas.LeftProperty, _textOffsetX != null ? (Orientation ? x2 : x1) + _textOffsetX : (Orientation ? (x2 + x3) / 2 : (x1 + x2) / 2) - 25);
_text.SetValue(Canvas.TopProperty, y2 - 22);
canvas.Children.Add(_text);
}
_flowArrows = FlowArrows.Create(canvas, _inner);
_flowArrows = FlowArrows.Create(canvas, [new(X1, Y1), new(X2, Y2), new(X3, Y3)]);
}
public void Scale(double scale) {
var border = Graph.ToBorder(scale);
_outer?.Points = [Graph.ToPx(X1, Y1, scale), Graph.ToPx(X2, Y2, scale), Graph.ToPx(X3, Y3, scale)];
_inner?.Points = [Graph.ToPx(X1, Y1, scale), Graph.ToPx(X2, Y2, scale), Graph.ToPx(X3, Y3, scale)];
_inner?.StrokeThickness = Math.Round(1.2 * scale / 2) * 2;
_outer?.StrokeThickness = Math.Round(1.2 * scale / 2) * 2 + border * 2;
_text?.FontSize = 12;
_text?.Width = 10 * scale;
Graph.SetPos(_text, _textOffsetX != null ? (Orientation ? X2 : X1) + _textOffsetX.Value : (Orientation ? (X2 + X3) / 2 : (X1 + X2) / 2) - 5, Y2 - 1.4, scale, dypx: -16);
_flowArrows?.Scale(scale);
}
public void Update() {
+23 -20
View File
@@ -6,8 +6,8 @@ using System.Windows.Shapes;
namespace PamhagenSysCtrl.Helpers.Pipeline {
public class PipeJoin : INode {
public const double SIZE = 18;
public const double POINT = 4;
public const double SIZE = 3.6;
public const double POINT = 0.8;
public double CenterX { get; set; }
public double CenterY { get; set; }
@@ -16,7 +16,7 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
public ISet<IEdge> Inputs { get; init; }
public ISet<IEdge> Outputs { get; init; }
private Shape? _rect;
private Polygon? _rect;
public PipeJoin(double x, double y) {
CenterX = x;
@@ -26,14 +26,22 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
}
public void Draw(Canvas canvas) {
var it = Inputs.Any(e => (e.Start.CenterY < CenterY && (!e.Orientation || e.Start.CenterX == CenterX)) || (e.IsTwoWay && e.End.CenterY < CenterY && (!e.Orientation || e.End.CenterX == CenterX)));
var ot = Outputs.Any(e => (e.End.CenterY < CenterY && ( e.Orientation || e.End.CenterX == CenterX)) || (e.IsTwoWay && e.Start.CenterY < CenterY && ( e.Orientation || e.Start.CenterX == CenterX)));
var ir = Inputs.Any(e => (e.Start.CenterX > CenterX && ( e.Orientation || e.Start.CenterY == CenterY)) || (e.IsTwoWay && e.End.CenterX > CenterX && ( e.Orientation || e.End.CenterY == CenterY)));
var or = Outputs.Any(e => (e.End.CenterX > CenterX && (!e.Orientation || e.End.CenterY == CenterY)) || (e.IsTwoWay && e.Start.CenterX > CenterX && (!e.Orientation || e.Start.CenterY == CenterY)));
var ib = Inputs.Any(e => (e.Start.CenterY > CenterY && (!e.Orientation || e.Start.CenterX == CenterX)) || (e.IsTwoWay && e.End.CenterY > CenterY && (!e.Orientation || e.End.CenterX == CenterX)));
var ob = Outputs.Any(e => (e.End.CenterY > CenterY && ( e.Orientation || e.End.CenterX == CenterX)) || (e.IsTwoWay && e.Start.CenterY > CenterY && ( e.Orientation || e.Start.CenterX == CenterX)));
var il = Inputs.Any(e => (e.Start.CenterX < CenterX && ( e.Orientation || e.Start.CenterY == CenterY)) || (e.IsTwoWay && e.End.CenterX < CenterX && ( e.Orientation || e.End.CenterY == CenterY)));
var ol = Outputs.Any(e => (e.End.CenterX < CenterX && (!e.Orientation || e.End.CenterY == CenterY)) || (e.IsTwoWay && e.Start.CenterX < CenterX && (!e.Orientation || e.Start.CenterY == CenterY)));
_rect = new Polygon() {
Fill = Brushes.Black,
Stroke = Brushes.Black,
};
canvas.Children.Add(_rect);
}
public void Scale(double scale) {
var it = Inputs.Any(e => (e.Start.CenterY < CenterY && (!e.Orientation || e.Start.CenterX == CenterX)) || (e.IsTwoWay && e.End.CenterY < CenterY && (!e.Orientation || e.End.CenterX == CenterX)));
var ot = Outputs.Any(e => (e.End.CenterY < CenterY && (e.Orientation || e.End.CenterX == CenterX)) || (e.IsTwoWay && e.Start.CenterY < CenterY && (e.Orientation || e.Start.CenterX == CenterX)));
var ir = Inputs.Any(e => (e.Start.CenterX > CenterX && (e.Orientation || e.Start.CenterY == CenterY)) || (e.IsTwoWay && e.End.CenterX > CenterX && (e.Orientation || e.End.CenterY == CenterY)));
var or = Outputs.Any(e => (e.End.CenterX > CenterX && (!e.Orientation || e.End.CenterY == CenterY)) || (e.IsTwoWay && e.Start.CenterX > CenterX && (!e.Orientation || e.Start.CenterY == CenterY)));
var ib = Inputs.Any(e => (e.Start.CenterY > CenterY && (!e.Orientation || e.Start.CenterX == CenterX)) || (e.IsTwoWay && e.End.CenterY > CenterY && (!e.Orientation || e.End.CenterX == CenterX)));
var ob = Outputs.Any(e => (e.End.CenterY > CenterY && (e.Orientation || e.End.CenterX == CenterX)) || (e.IsTwoWay && e.Start.CenterY > CenterY && (e.Orientation || e.Start.CenterX == CenterX)));
var il = Inputs.Any(e => (e.Start.CenterX < CenterX && (e.Orientation || e.Start.CenterY == CenterY)) || (e.IsTwoWay && e.End.CenterX < CenterX && (e.Orientation || e.End.CenterY == CenterY)));
var ol = Outputs.Any(e => (e.End.CenterX < CenterX && (!e.Orientation || e.End.CenterY == CenterY)) || (e.IsTwoWay && e.Start.CenterX < CenterX && (!e.Orientation || e.Start.CenterY == CenterY)));
var points = new List<Point> {
new(0, 0)
@@ -70,15 +78,10 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
points.AddRange([new(0, SIZE / 2 + POINT), new(POINT, SIZE / 2), new(0, SIZE / 2 - POINT)]);
}
_rect = new Polygon() {
Points = [..points],
Fill = Brushes.Black,
Stroke = Brushes.Black,
StrokeThickness = 2,
};
_rect.SetValue(Canvas.LeftProperty, CenterX - SIZE / 2);
_rect.SetValue(Canvas.TopProperty, CenterY - SIZE / 2);
canvas.Children.Add(_rect);
_rect?.Points = [.. points.Select(p => new Point(p.X * scale, p.Y * scale))];
_rect?.StrokeThickness = 2;
_rect?.SetValue(Canvas.LeftProperty, (CenterX - SIZE / 2) * scale);
_rect?.SetValue(Canvas.TopProperty, (CenterY - SIZE / 2) * scale);
}
public bool IsInside(double x, double y) {
+20 -20
View File
@@ -1,13 +1,12 @@
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Media3D;
using System.Windows.Shapes;
namespace PamhagenSysCtrl.Helpers.Pipeline {
public class Press : INode, ISink {
public const double DIAMETER = 120;
public const double DIAMETER = 24;
public double CenterX { get; set; }
public double CenterY { get; set; }
@@ -24,8 +23,8 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
protected Func<FillState> CallbackFillState;
private Shape? _frame;
private Shape? _circle;
private Polygon? _frame;
private Ellipse? _circle;
private TextBlock? _text;
public Press(string label, double x, double y, int capacityLiters, Func<FillState> cbFillState) {
@@ -40,39 +39,40 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
public void Draw(Canvas canvas) {
_circle = new Ellipse() {
Width = DIAMETER,
Height = DIAMETER,
Stroke = Brushes.Black,
StrokeThickness = 2,
Fill = Brushes.WhiteSmoke,
};
_frame = new Polygon() {
Points = [
new(CenterX - DIAMETER / 2 - 10, CenterY), new(CenterX + DIAMETER / 2 + 10, CenterY),
new(CenterX + DIAMETER / 2 + 10, CenterY + DIAMETER / 2 + 30), new(CenterX + DIAMETER / 2 - 20, CenterY + DIAMETER / 2 + 30),
new(CenterX + DIAMETER / 2 - 20, CenterY + DIAMETER / 2 + 10), new(CenterX - DIAMETER / 2 + 20, CenterY + DIAMETER / 2 + 10),
new(CenterX - DIAMETER / 2 + 20, CenterY + DIAMETER / 2 + 30), new(CenterX - DIAMETER / 2 - 10, CenterY + DIAMETER / 2 + 30)
],
Stroke = Brushes.Black,
StrokeThickness = 2,
Fill = Brushes.WhiteSmoke,
};
_text = new() {
Text = CapacityLiters.HasValue ? $"{Label}\n{CapacityLiters:N0}" : Label,
FontSize = 14,
Width = DIAMETER,
TextAlignment = TextAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
};
_circle.SetValue(Canvas.LeftProperty, CenterX - DIAMETER / 2);
_circle.SetValue(Canvas.TopProperty, CenterY - DIAMETER / 2);
_text.SetValue(Canvas.LeftProperty, CenterX - DIAMETER / 2);
_text.SetValue(Canvas.TopProperty, CenterY - (CapacityLiters.HasValue ? 20 : 10));
canvas.Children.Add(_frame);
canvas.Children.Add(_circle);
canvas.Children.Add(_text);
}
public void Scale(double scale) {
var border = Graph.ToBorder(scale);
_circle?.StrokeThickness = border;
Graph.SetCenter(_circle, CenterX, CenterY, DIAMETER, DIAMETER, scale);
_frame?.Points = [
Graph.ToPx(CenterX - DIAMETER / 2 - 2, CenterY, scale), Graph.ToPx(CenterX + DIAMETER / 2 + 2, CenterY, scale),
Graph.ToPx(CenterX + DIAMETER / 2 + 2, CenterY + DIAMETER / 2 + 6, scale), Graph.ToPx(CenterX + DIAMETER / 2 - 4, CenterY + DIAMETER / 2 + 6, scale),
Graph.ToPx(CenterX + DIAMETER / 2 - 4, CenterY + DIAMETER / 2 + 2, scale), Graph.ToPx(CenterX - DIAMETER / 2 + 4, CenterY + DIAMETER / 2 + 2, scale),
Graph.ToPx(CenterX - DIAMETER / 2 + 4, CenterY + DIAMETER / 2 + 6, scale), Graph.ToPx(CenterX - DIAMETER / 2 - 2, CenterY + DIAMETER / 2 + 6, scale),
];
_frame?.StrokeThickness = border;
_text?.FontSize = 14;
_text?.Width = DIAMETER * scale;
_text?.SetValue(Canvas.LeftProperty, (CenterX - DIAMETER / 2) * scale);
_text?.SetValue(Canvas.TopProperty, (CenterY * scale) - (CapacityLiters.HasValue ? 20 : 10));
}
public bool IsInside(double x, double y) {
return Math.Sqrt(Math.Pow(CenterX - x, 2) + Math.Pow(CenterY - y, 2)) <= DIAMETER / 2 || (Math.Abs(x - CenterX) <= DIAMETER / 2 + 10 && y >= CenterY && y <= CenterY + DIAMETER / 2 + 30);
}
+20 -15
View File
@@ -6,7 +6,7 @@ using System.Windows.Shapes;
namespace PamhagenSysCtrl.Helpers.Pipeline {
public class Pump : INode {
public const double DIAMETER = 24;
public const double DIAMETER = 4.8;
public double CenterX { get; set; }
public double CenterY { get; set; }
@@ -25,8 +25,8 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
protected Func<bool> CallbackClearance;
protected Func<Pump, bool> CallbackSelected;
private Shape? _circle;
private Shape? _triangle;
private Ellipse? _circle;
private Polygon? _triangle;
private TextBlock? _text;
public Pump(string label, double x, double y, Func<MotorState> cbState, Func<bool> cbClearance, Func<Pump, bool> cbSelected) {
@@ -42,35 +42,40 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
public void Draw(Canvas canvas) {
_circle = new Ellipse() {
Height = DIAMETER,
Width = DIAMETER,
Fill = Brushes.WhiteSmoke,
Stroke = Brushes.Black,
StrokeThickness = 2,
};
var dx = Math.Cos(Math.PI / 6) * (DIAMETER / 2 - 2);
var dy = Math.Sin(Math.PI / 6) * (DIAMETER / 2 - 2);
_triangle = new Polygon() {
Points = [new(CenterX - dx, CenterY - dy), new(CenterX + dx, CenterY - dy), new(CenterX, CenterY + DIAMETER / 2 - 2)],
Fill = Brushes.Transparent,
Stroke = Brushes.Black,
StrokeThickness = 2,
};
_text = new() {
Text = Label,
FontSize = 14,
TextAlignment = TextAlignment.Left,
VerticalAlignment = VerticalAlignment.Center,
};
_circle.SetValue(Canvas.LeftProperty, CenterX - DIAMETER / 2);
_circle.SetValue(Canvas.TopProperty, CenterY - DIAMETER / 2);
_text.SetValue(Canvas.LeftProperty, CenterX + DIAMETER / 2 + 2);
_text.SetValue(Canvas.TopProperty, CenterY - 10);
canvas.Children.Add(_circle);
canvas.Children.Add(_triangle);
canvas.Children.Add(_text);
}
public void Scale(double scale) {
var border = Graph.ToBorder(scale);
_circle?.StrokeThickness = border;
Graph.SetCenter(_circle, CenterX, CenterY, DIAMETER, DIAMETER, scale);
var dx = Math.Cos(Math.PI / 6) * (DIAMETER / 2);
var dy = Math.Sin(Math.PI / 6) * (DIAMETER / 2);
_triangle?.Points = [
Graph.ToPx(CenterX - dx, CenterY - dy, scale, dxpx: border, dypx: border / 2, round: false),
Graph.ToPx(CenterX + dx, CenterY - dy, scale, dxpx: -border, dypx: border / 2, round: false),
Graph.ToPx(CenterX, CenterY + DIAMETER / 2, scale, dypx: -border, round: false),
];
_triangle?.StrokeThickness = border;
_text?.FontSize = 14;
_text?.SetValue(Canvas.LeftProperty, (CenterX + DIAMETER / 2) * scale + 2);
_text?.SetValue(Canvas.TopProperty, CenterY * scale - 10);
}
public bool IsInside(double x, double y) {
return Math.Sqrt(Math.Pow(CenterX - x, 2) + Math.Pow(CenterY - y, 2)) <= DIAMETER / 2;
}
+31 -27
View File
@@ -6,8 +6,8 @@ using System.Windows.Shapes;
namespace PamhagenSysCtrl.Helpers.Pipeline {
public class Rebler : INode {
public const double WIDTH = 120;
public const double HEIGHT = 60;
public const double WIDTH = 24;
public const double HEIGHT = 12;
public double CenterX { get; set; }
public double CenterY { get; set; }
@@ -20,11 +20,11 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
protected Func<bool> CallbackActive;
private TextBlock? _text;
private Shape? _rect;
private Shape? _hopperOuter;
private Shape? _hopperInner;
private Shape? _bottomInner;
private Shape? _bottomOuter;
private Rectangle? _rect;
private Polygon? _hopperOuter;
private Polygon? _hopperInner;
private Polygon? _bottomInner;
private Polygon? _bottomOuter;
public Rebler(string label, double x, double y, Func<bool> cbActive) {
CenterX = x;
@@ -37,54 +37,58 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
public void Draw(Canvas canvas) {
_rect = new Rectangle() {
Width = WIDTH,
Height = HEIGHT,
Fill = Brushes.WhiteSmoke,
Stroke = Brushes.Black,
StrokeThickness = 2,
};
var left = CenterX - WIDTH / 2;
var right = CenterX + WIDTH / 2;
var top = CenterY - HEIGHT / 2;
var bottom = CenterY + HEIGHT / 2;
var hx = right - 20;
var h = 15;
var w = 25;
_hopperOuter = new Polygon() {
Points = [new(hx - w, top - h), new(hx - w + 5, top + 2), new(hx + w - 5, top + 2), new(hx + w, top - h)],
Fill = Brushes.Black,
};
_hopperInner = new Polygon() {
Points = [new(hx - w + 2, top - h), new(hx - w + 5 + 2, top + 2), new(hx + w - 5 - 2, top + 2), new(hx + w - 2, top - h)],
Fill = Brushes.WhiteSmoke,
};
_bottomOuter = new Polygon() {
Points = [new(left + 20, bottom), new(right - 20, bottom), new(right - 15, bottom + 10), new(left + 15, bottom + 10)],
Fill = Brushes.Black,
};
_bottomInner = new Polygon() {
Points = [new(left + 20 + 2, bottom), new(right - 20 - 2, bottom), new(right - 15 - 2, bottom + 10), new(left + 15 + 2, bottom + 10)],
Fill = Brushes.WhiteSmoke,
};
_text = new() {
Text = Label,
FontSize = 12,
Width = WIDTH,
TextAlignment = TextAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
};
_rect.SetValue(Canvas.LeftProperty, CenterX - WIDTH / 2);
_rect.SetValue(Canvas.TopProperty, CenterY - HEIGHT / 2);
_text.SetValue(Canvas.LeftProperty, CenterX - WIDTH / 2);
_text.SetValue(Canvas.TopProperty, CenterY - 8);
canvas.Children.Add(_hopperOuter);
canvas.Children.Add(_bottomOuter);
canvas.Children.Add(_bottomInner);
canvas.Children.Add(_rect);
canvas.Children.Add(_hopperInner);
canvas.Children.Add(_bottomInner);
canvas.Children.Add(_text);
}
public void Scale(double scale) {
var border = Graph.ToBorder(scale);
Graph.SetCenter(_rect, CenterX, CenterY, WIDTH, HEIGHT, scale);
_rect?.StrokeThickness = border;
var left = CenterX - WIDTH / 2;
var right = CenterX + WIDTH / 2;
var top = CenterY - HEIGHT / 2;
var bottom = CenterY + HEIGHT / 2;
var hx = right - 4;
var h = 3;
var w = 5;
_hopperOuter?.Points = [Graph.ToPx(hx - w, top - h, scale), Graph.ToPx(hx - w + 1, top, scale, dypx: border), Graph.ToPx(hx + w - 1, top, scale, dypx: border), Graph.ToPx(hx + w, top - h, scale)];
_hopperInner?.Points = [Graph.ToPx(hx - w, top - h, scale, dxpx: border), Graph.ToPx(hx - w + 1, top, scale, dxpx: border, dypx: border), Graph.ToPx(hx + w - 1, top, scale, dxpx: -border, dypx: border), Graph.ToPx(hx + w, top - h, scale, dxpx: -border)];
_bottomOuter?.Points = [Graph.ToPx(left + 5, bottom - 1, scale), Graph.ToPx(right - 5, bottom - 1, scale), Graph.ToPx(right - 3, bottom + 2, scale), Graph.ToPx(left + 3, bottom + 2, scale)];
_bottomInner?.Points = [Graph.ToPx(left + 5, bottom - 1, scale, dxpx: border), Graph.ToPx(right - 5, bottom - 1, scale, dxpx: -border), Graph.ToPx(right - 3, bottom + 2, scale, dxpx: -border), Graph.ToPx(left + 3, bottom + 2, scale, dxpx: border)];
_text?.FontSize = 12;
_text?.Width = WIDTH * scale;
_text?.SetValue(Canvas.LeftProperty, (CenterX - WIDTH / 2) * scale);
_text?.SetValue(Canvas.TopProperty, (CenterY * scale) - 8);
}
public bool IsInside(double x, double y) {
return Math.Abs(x - CenterX) <= WIDTH / 2 && Math.Abs(y - CenterY) <= HEIGHT / 2;
}
+23 -10
View File
@@ -6,8 +6,8 @@ using System.Windows.Shapes;
namespace PamhagenSysCtrl.Helpers.Pipeline {
public class Switcher : INode {
public const double WIDTH = 100;
public const double HEIGHT = 50;
public const double WIDTH = 20;
public const double HEIGHT = 10;
public double CenterX { get; set; }
public double CenterY { get; set; }
@@ -34,21 +34,15 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
}
public void Draw(Canvas canvas) {
_mainTransform = new RotateTransform(0, CenterX, CenterY);
_shadowTransform = new RotateTransform(0, CenterX, CenterY);
_mainTransform = new RotateTransform(0);
_shadowTransform = new RotateTransform(0);
_main = new Line() {
X1 = CenterX - WIDTH / 2, Y1 = CenterY,
X2 = CenterX + WIDTH / 2, Y2 = CenterY,
StrokeThickness = 5,
Stroke = Brushes.Black,
StrokeStartLineCap = PenLineCap.Square,
StrokeEndLineCap = PenLineCap.Square,
RenderTransform = _mainTransform,
};
_shadow = new Line() {
X1 = CenterX - WIDTH / 2, Y1 = CenterY,
X2 = CenterX + WIDTH / 2, Y2 = CenterY,
StrokeThickness = 5,
Stroke = Brushes.DarkGray,
StrokeStartLineCap = PenLineCap.Square,
StrokeEndLineCap = PenLineCap.Square,
@@ -58,6 +52,25 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
canvas.Children.Add(_main);
}
public void Scale(double scale) {
_mainTransform?.CenterX = CenterX * scale;
_mainTransform?.CenterY = CenterY * scale;
_shadowTransform?.CenterX = CenterX * scale;
_shadowTransform?.CenterY = CenterY * scale;
_main?.X1 = (CenterX - WIDTH / 2) * scale;
_main?.Y1 = CenterY * scale;
_main?.X2 = (CenterX + WIDTH / 2) * scale;
_main?.Y2 = CenterY * scale;
_main?.StrokeThickness = 1 * scale;
_shadow?.X1 = (CenterX - WIDTH / 2) * scale;
_shadow?.Y1 = CenterY * scale;
_shadow?.X2 = (CenterX + WIDTH / 2) * scale;
_shadow?.Y2 = CenterY * scale;
_shadow?.StrokeThickness = 1 * scale;
}
public bool IsInside(double x, double y) {
return Math.Abs(x - CenterX) <= WIDTH / 2 && Math.Abs(y - CenterY) <= HEIGHT / 2;
}
+15 -11
View File
@@ -6,8 +6,8 @@ using System.Windows.Shapes;
namespace PamhagenSysCtrl.Helpers.Pipeline {
public class Tank : INode, ISink, ISource {
public const double WIDTH = 60;
public const double HEIGHT = 100;
public const double WIDTH = 12;
public const double HEIGHT = 20;
public double CenterX { get; set; }
public double CenterY { get; set; }
@@ -40,27 +40,31 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
public void Draw(Canvas canvas) {
_rect = new Rectangle() {
Width = WIDTH,
Height = HEIGHT,
Stroke = Brushes.Black,
StrokeThickness = 2,
Fill = Brushes.WhiteSmoke,
};
_text = new() {
Text = CapacityLiters.HasValue ? $"{Label}\n{CapacityLiters:N0}" : Label,
FontSize = 12,
Width = WIDTH,
TextAlignment = TextAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
};
_rect.SetValue(Canvas.LeftProperty, CenterX - WIDTH / 2);
_rect.SetValue(Canvas.TopProperty, CenterY - HEIGHT / 2);
_text.SetValue(Canvas.LeftProperty, CenterX - WIDTH / 2);
_text.SetValue(Canvas.TopProperty, CenterY - (CapacityLiters.HasValue ? 16 : 8));
canvas.Children.Add(_rect);
canvas.Children.Add(_text);
}
public void Scale(double scale) {
var border = Graph.ToBorder(scale);
_rect?.Height = Graph.ToPx(HEIGHT, scale);
_rect?.Width = Graph.ToPx(WIDTH, scale);
_rect?.StrokeThickness = border;
_rect?.SetValue(Canvas.LeftProperty, (CenterX - WIDTH / 2) * scale);
_rect?.SetValue(Canvas.TopProperty, (CenterY - HEIGHT / 2) * scale);
_text?.Width = Graph.ToPx(WIDTH, scale);
_text?.FontSize = 12;
_text?.SetValue(Canvas.LeftProperty, (CenterX - WIDTH / 2) * scale);
_text?.SetValue(Canvas.TopProperty, (CenterY * scale) - (CapacityLiters.HasValue ? 16 : 8));
}
public bool IsInside(double x, double y) {
return Math.Abs(x - CenterX) <= WIDTH / 2 && Math.Abs(y - CenterY) <= HEIGHT / 2;
}
+18 -14
View File
@@ -6,8 +6,8 @@ using System.Windows.Shapes;
namespace PamhagenSysCtrl.Helpers.Pipeline {
public class Trough : INode, ISource {
public const double WIDTH = 100;
public const double HEIGHT = 60;
public const double WIDTH = 20;
public const double HEIGHT = 12;
public double CenterX { get; set; }
public double CenterY { get; set; }
@@ -35,33 +35,37 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
public void Draw(Canvas canvas) {
_outer = new Rectangle() {
Width = WIDTH,
Height = HEIGHT,
Fill = Brushes.Black,
};
_inner = new Rectangle() {
Width = WIDTH - 4,
Height = HEIGHT - 2,
Fill = Brushes.WhiteSmoke,
};
_text = new() {
Text = Label,
FontSize = 14,
Width = WIDTH,
TextAlignment = TextAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
};
_outer.SetValue(Canvas.LeftProperty, CenterX - WIDTH / 2);
_outer.SetValue(Canvas.TopProperty, CenterY - HEIGHT / 2);
_inner.SetValue(Canvas.LeftProperty, CenterX - WIDTH / 2 + 2);
_inner.SetValue(Canvas.TopProperty, CenterY - HEIGHT / 2);
_text.SetValue(Canvas.LeftProperty, CenterX - WIDTH / 2);
_text.SetValue(Canvas.TopProperty, CenterY - 10);
canvas.Children.Add(_outer);
canvas.Children.Add(_inner);
canvas.Children.Add(_text);
}
public void Scale(double scale) {
var border = Graph.ToBorder(scale);
_outer?.Width = WIDTH * scale;
_outer?.Height = HEIGHT * scale;
_inner?.Width = WIDTH * scale - border * 2;
_inner?.Height = HEIGHT * scale - border;
_text?.Width = WIDTH * scale;
_text?.FontSize = 14;
_outer?.SetValue(Canvas.LeftProperty, (CenterX - WIDTH / 2) * scale);
_outer?.SetValue(Canvas.TopProperty, (CenterY - HEIGHT / 2) * scale);
_inner?.SetValue(Canvas.LeftProperty, (CenterX - WIDTH / 2) * scale + border);
_inner?.SetValue(Canvas.TopProperty, (CenterY - HEIGHT / 2) * scale);
_text?.SetValue(Canvas.LeftProperty, (CenterX - WIDTH / 2) * scale);
_text?.SetValue(Canvas.TopProperty, (CenterY * scale) - 10);
}
public bool IsInside(double x, double y) {
return Math.Abs(x - CenterX) <= WIDTH / 2 && Math.Abs(y - CenterY) <= HEIGHT / 2;
}
+15 -12
View File
@@ -6,7 +6,7 @@ using System.Windows.Shapes;
namespace PamhagenSysCtrl.Helpers.Pipeline {
public class Valve : INode {
public const double DIAMETER = 24;
public const double DIAMETER = 4.8;
public double CenterX { get; set; }
public double CenterY { get; set; }
@@ -14,7 +14,9 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
public string Label => $"V{Nr}";
public Brush? Highlight { get; set; }
public bool IsLocked { get; set; }
public readonly ISet<Path> LockedForPaths = new HashSet<Path>();
public bool IsLocked => LockedForPaths.Any();
public bool IsOpen => CallbackIsOpen();
public bool WantOpen => CallbackWantOpen(this);
public ISet<IEdge> Inputs { get; init; }
@@ -38,29 +40,30 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
public void Draw(Canvas canvas) {
_circle = new Ellipse() {
Height = DIAMETER,
Width = DIAMETER,
Fill = Brushes.DarkGray,
Stroke = Brushes.Black,
StrokeThickness = 2,
};
_circle.SetValue(Canvas.LeftProperty, CenterX - DIAMETER / 2);
_circle.SetValue(Canvas.TopProperty, CenterY - DIAMETER / 2);
_text = new() {
Text = Label,
FontSize = 10,
Width = DIAMETER,
Height = DIAMETER,
TextAlignment = TextAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
SnapsToDevicePixels = true,
};
_text.SetValue(Canvas.LeftProperty, CenterX - DIAMETER / 2 + 0.5);
_text.SetValue(Canvas.TopProperty, CenterY - DIAMETER / 2 + 5.5);
canvas.Children.Add(_circle);
canvas.Children.Add(_text);
}
public void Scale(double scale) {
var border = Graph.ToBorder(scale);
Graph.SetCenter(_circle, CenterX, CenterY, DIAMETER, DIAMETER, scale);
_circle?.StrokeThickness = border;
_text?.Width = DIAMETER * scale;
_text?.Height = DIAMETER * scale;
_text?.FontSize = 2 * scale;
_text?.SetValue(Canvas.LeftProperty, (CenterX - DIAMETER / 2 + 0.1) * scale);
_text?.SetValue(Canvas.TopProperty, (CenterY - DIAMETER / 2 + 1.1) * scale);
}
public bool IsInside(double x, double y) {
return Math.Sqrt(Math.Pow(CenterX - x, 2) + Math.Pow(CenterY - y, 2)) <= DIAMETER / 2;
}
+77
View File
@@ -0,0 +1,77 @@
using System.Diagnostics;
using System.IO;
using System.Net.Http;
using System.Text.Json.Nodes;
namespace PamhagenSysCtrl.Helpers {
public static class UpdateService {
public static async Task<(string Version, string Url, long Size)?> GetLatestInstallerUrl(string feedUrl) {
try {
using var client = new HttpClient() {
Timeout = TimeSpan.FromSeconds(5),
};
client.DefaultRequestHeaders.UserAgent.Clear();
client.DefaultRequestHeaders.UserAgent.ParseAdd($"PamhagenSysCtrl/{App.Version} ({Environment.MachineName}, {Environment.OSVersion})");
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new("application/json"));
using var res = await client.GetAsync(feedUrl);
if (!res.IsSuccessStatusCode)
return null;
var json = JsonNode.Parse(await res.Content.ReadAsStringAsync());
var latest = json!["data"]!.AsArray()[^1]!;
return ((string)latest["version"]!, (string)latest["url"]!, (long)latest["size"]!);
} catch {
return null;
}
}
public static async Task DownloadInstaller(string url, string filename, IProgress<double>? progress = null, CancellationToken cancellationToken = default) {
try {
using var client = new HttpClient() {
Timeout = TimeSpan.FromSeconds(5),
};
client.DefaultRequestHeaders.UserAgent.Clear();
client.DefaultRequestHeaders.UserAgent.ParseAdd($"PamhagenSysCtrl/{App.Version} ({Environment.MachineName}, {Environment.OSVersion})");
client.DefaultRequestHeaders.Accept.Clear();
using var response = await client.GetAsync(url, HttpCompletionOption.ResponseHeadersRead, cancellationToken);
response.EnsureSuccessStatusCode();
var contentLength = response.Content.Headers.ContentLength;
await using (var destination = new FileStream(filename, FileMode.Create)) {
await using var source = await response.Content.ReadAsStreamAsync(cancellationToken);
var buffer = new byte[81920];
long downloaded = 0;
int read;
while ((read = await source.ReadAsync(buffer, cancellationToken)) != 0) {
await destination.WriteAsync(buffer.AsMemory(0, read), cancellationToken);
downloaded += read;
if (contentLength.HasValue) {
progress?.Report((double)downloaded / contentLength.Value);
}
}
}
progress?.Report(1);
} catch {
File.Delete(filename);
throw;
}
}
public static void StartInstaller(string fileName) {
var startInfo = new ProcessStartInfo {
FileName = "msiexec.exe",
UseShellExecute = true,
Verb = "runas",
};
startInfo.ArgumentList.Add("/i");
startInfo.ArgumentList.Add(Path.GetFullPath(fileName));
if (Process.Start(startInfo) == null) {
throw new InvalidOperationException("Der Installer konnte nicht gestartet werden.");
}
}
}
}
+1 -1
View File
@@ -3,7 +3,7 @@
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net10.0-windows</TargetFramework>
<Version>0.0.2</Version>
<Version>0.0.3</Version>
<Product>Anlagensteuerung Pamhagen</Product>
<AssemblyTitle>Anlagensteuerung Pamhagen</AssemblyTitle>
<AssemblyName>PamhagenSysCtrl</AssemblyName>
+28
View File
@@ -0,0 +1,28 @@
<Window x:Class="PamhagenSysCtrl.Windows.AboutWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Über - Anlagensteuerung Pamhagen"
Height="340" Width="560" ResizeMode="NoResize"
WindowStartupLocation="CenterOwner">
<Grid>
<TextBlock Margin="20,10" FontSize="12">
<Bold>Produkt:</Bold> Anlagensteuerung Pamhagen<LineBreak/>
<Bold>Beschreibung:</Bold> Schnittstelle zu einer SPS und grafische Benutzeroberfläche für die<LineBreak/>
<Bold Foreground="Transparent">Beschreibung:</Bold> Steuerung der Anlage<LineBreak/>
<Bold>Typ:</Bold> HMI- und SPS-Steuerungssoftware<LineBreak/>
<Bold>Version:</Bold> <Run x:Name="VersionText">0.0.0</Run><LineBreak/>
<Bold>Lizenz:</Bold> <Hyperlink NavigateUri="https://www.gnu.org/licenses/gpl-3.0.html" RequestNavigate="Hyperlink_RequestNavigate">GNU General Public License 3.0 (GPLv3)</Hyperlink><LineBreak/>
<Bold>Entwickler:</Bold> Lorenz Stechauner, Thomas Hilscher<LineBreak/>
<Bold>Kontakt:</Bold> <Hyperlink NavigateUri="mailto:lorenz.stechauner@necronda.net" RequestNavigate="Hyperlink_RequestNavigate">lorenz.stechauner@necronda.net</Hyperlink>, <Hyperlink NavigateUri="mailto:thomas.hilscher@gmail.com" RequestNavigate="Hyperlink_RequestNavigate">thomas.hilscher@gmail.com</Hyperlink><LineBreak/>
<Bold>Quellcode:</Bold> <Hyperlink NavigateUri="C:\Program Files\Anlagensteuerung Pamhagen\src" RequestNavigate="Hyperlink_RequestNavigate_Explorer">C:\Program Files\Anlagensteuerung Pamhagen\src</Hyperlink>,<LineBreak/>
<Bold Foreground="Transparent">Quellcode:</Bold> <Hyperlink NavigateUri="https://git.necronda.net/winzer/pamhagen-sysctrl" RequestNavigate="Hyperlink_RequestNavigate">https://git.necronda.net/winzer/pamhagen-sysctrl</Hyperlink><LineBreak/>
<Bold>Entwicklungszeitraum:</Bold> 2026<LineBreak/>
<LineBreak/>
<Bold>Verwendete Technologien:</Bold><LineBreak/>
Programmiersprache: C#<LineBreak/>
Framework: Windows Presentation Framework (WPF)<LineBreak/>
SPS-Schnittstelle: Serielle Verbindung<LineBreak/>
Paketierung: <Hyperlink NavigateUri="https://www.firegiant.com/wixtoolset/" RequestNavigate="Hyperlink_RequestNavigate">WiX Toolset</Hyperlink>
</TextBlock>
</Grid>
</Window>
@@ -0,0 +1,25 @@
using System.Diagnostics;
using System.Windows;
using System.Windows.Navigation;
namespace PamhagenSysCtrl.Windows {
public partial class AboutWindow : Window {
public AboutWindow() {
InitializeComponent();
VersionText.Text = App.Version.ToString();
}
private void Hyperlink_RequestNavigate(object sender, RequestNavigateEventArgs evt) {
try {
Process.Start(new ProcessStartInfo(evt.Uri.AbsoluteUri) { UseShellExecute = true });
} catch { }
}
private void Hyperlink_RequestNavigate_Explorer(object sender, RequestNavigateEventArgs evt) {
try {
Process.Start("explorer.exe", evt.Uri.AbsoluteUri);
} catch { }
}
}
}
@@ -141,7 +141,7 @@ namespace PamhagenSysCtrl {
Gradation °Oe: {plant.GradationOe:N2}
Presse Querschnecke: {plant.PresseQuerSchnecke}
Füllstände:
Maischewanne 1: {plant.FillLevelMW1} (ausgewählt: {plant.WantMW1Selected}, Status: {plant.IsMWSelected})
Maischewanne 1: {plant.FillLevelMW1} (ausgewählt: {plant.WantMW1Selected}, Status: {plant.IsMW1Selected})
Maischewanne 2: {plant.FillLevelMW2} (ausgewählt: {plant.WantMW2Selected}, Status: {plant.IsMW2Selected})
Presse 1: {plant.Press1HasClearance}
Presse 2: {plant.Press2HasClearance}
+172 -5
View File
@@ -5,7 +5,9 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:PamhagenSysCtrl.Windows"
Closed="OnClosed"
Title="Anlagensteuerung Pamhagen" Height="950" Width="1600" MinWidth="1500" MinHeight="950">
SizeChanged="OnSizeChanged"
Title="Anlagensteuerung Pamhagen"
Height="800" Width="1400" MinWidth="1000" MinHeight="500">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="19"/>
@@ -45,23 +47,188 @@
</MenuItem>
</MenuItem>
<MenuItem Header="Hilfe">
<MenuItem Header="Über">
<MenuItem Header="Über" Click="Menu_Help_About_Click">
<MenuItem.Icon>
<TextBlock FontFamily="Segoe MDL2 Assets" FontSize="16" Text="&#xE946;"/>
</MenuItem.Icon>
</MenuItem>
<MenuItem x:Name="Menu_Help_CheckForUpdates" Header="Nach Updates suchen..." Click="Menu_Help_CheckForUpdates_Click">
<MenuItem.Icon>
<TextBlock FontFamily="Segoe MDL2 Assets" FontSize="16" Text="&#xE895;"/>
</MenuItem.Icon>
</MenuItem>
</MenuItem>
</Menu>
<Grid Grid.Row="1" ClipToBounds="True">
<Canvas x:Name="SchemeCanvas" Width="1550" Height="900" VerticalAlignment="Center" HorizontalAlignment="Center" SnapsToDevicePixels="True"
MouseMove="SchemeCanvas_MouseMove" MouseLeftButtonDown="SchemeCanvas_MouseLeftButtonDown" MouseLeftButtonUp="SchemeCanvas_MouseLeftButtonUp" Grid.ColumnSpan="2" Margin="25,0,0,0">
<Canvas x:Name="SchemeCanvas" VerticalAlignment="Center" HorizontalAlignment="Center" SnapsToDevicePixels="True" Grid.ColumnSpan="2" Margin="25,0,0,0"
MouseMove="SchemeCanvas_MouseMove" MouseWheel="SchemeCanvas_MouseWheel"
MouseLeftButtonDown="SchemeCanvas_MouseLeftButtonDown" MouseLeftButtonUp="SchemeCanvas_MouseLeftButtonUp">
</Canvas>
<Border Grid.Row="1" HorizontalAlignment="Right" VerticalAlignment="Bottom" Padding="10,10,20,20" Margin="0,0,-11,-11"
Background="WhiteSmoke"
BorderBrush="Gray" BorderThickness="1" CornerRadius="10">
<Grid x:Name="FastSelectButtonsRight">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="160"/>
<ColumnDefinition Width="5"/>
<ColumnDefinition Width="160"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="50"/>
<RowDefinition Height="5"/>
<RowDefinition Height="50"/>
<RowDefinition Height="5"/>
<RowDefinition Height="50"/>
<RowDefinition Height="5"/>
<RowDefinition Height="50"/>
<RowDefinition Height="5"/>
<RowDefinition Height="50"/>
<RowDefinition Height="5"/>
<RowDefinition Height="50"/>
<RowDefinition Height="5"/>
<RowDefinition Height="50"/>
</Grid.RowDefinitions>
<Button x:Name="FastSelectButton_MW1_Press1" Grid.Column="0" Grid.Row="0"
Content="MW1 &#x2B9E; Presse 1" FontSize="16" FontWeight="Bold"
Click="FastSelectButton_Click" MouseEnter="FastSelectButton_Enter" MouseLeave="FastSelectButton_Leave"
BorderThickness="2"/>
<Button x:Name="FastSelectButton_MW2_Press1" Grid.Column="2" Grid.Row="0"
Content="MW2 &#x2B9E; Presse 1" FontSize="16" FontWeight="Bold"
Click="FastSelectButton_Click" MouseEnter="FastSelectButton_Enter" MouseLeave="FastSelectButton_Leave"
BorderThickness="2"/>
<Button x:Name="FastSelectButton_MW1_Press2" Grid.Column="0" Grid.Row="2"
Content="MW1 &#x2B9E; Presse 2" FontSize="16" FontWeight="Bold"
Click="FastSelectButton_Click" MouseEnter="FastSelectButton_Enter" MouseLeave="FastSelectButton_Leave"
BorderThickness="2"/>
<Button x:Name="FastSelectButton_MW2_Press2" Grid.Column="2" Grid.Row="2"
Content="MW2 &#x2B9E; Presse 2" FontSize="16" FontWeight="Bold"
Click="FastSelectButton_Click" MouseEnter="FastSelectButton_Enter" MouseLeave="FastSelectButton_Leave"
BorderThickness="2"/>
<Button x:Name="FastSelectButton_MW1_Tank1" Grid.Column="0" Grid.Row="4"
Content="MW1 &#x2B9E; Tank 1" FontSize="16" FontWeight="Bold"
Click="FastSelectButton_Click" MouseEnter="FastSelectButton_Enter" MouseLeave="FastSelectButton_Leave"
BorderThickness="2"/>
<Button x:Name="FastSelectButton_MW2_Tank1" Grid.Column="2" Grid.Row="4"
Content="MW2 &#x2B9E; Tank 1" FontSize="16" FontWeight="Bold"
Click="FastSelectButton_Click" MouseEnter="FastSelectButton_Enter" MouseLeave="FastSelectButton_Leave"
BorderThickness="2"/>
<Button x:Name="FastSelectButton_MW1_Tank2" Grid.Column="0" Grid.Row="6"
Content="MW1 &#x2B9E; Tank 2" FontSize="16" FontWeight="Bold"
Click="FastSelectButton_Click" MouseEnter="FastSelectButton_Enter" MouseLeave="FastSelectButton_Leave"
BorderThickness="2"/>
<Button x:Name="FastSelectButton_MW2_Tank2" Grid.Column="2" Grid.Row="6"
Content="MW2 &#x2B9E; Tank 2" FontSize="16" FontWeight="Bold"
Click="FastSelectButton_Click" MouseEnter="FastSelectButton_Enter" MouseLeave="FastSelectButton_Leave"
BorderThickness="2"/>
<Button x:Name="FastSelectButton_MW1_Tank3" Grid.Column="0" Grid.Row="8"
Content="MW1 &#x2B9E; Tank 3" FontSize="16" FontWeight="Bold"
Click="FastSelectButton_Click" MouseEnter="FastSelectButton_Enter" MouseLeave="FastSelectButton_Leave"
BorderThickness="2"/>
<Button x:Name="FastSelectButton_MW2_Tank3" Grid.Column="2" Grid.Row="8"
Content="MW2 &#x2B9E; Tank 3" FontSize="16" FontWeight="Bold"
Click="FastSelectButton_Click" MouseEnter="FastSelectButton_Enter" MouseLeave="FastSelectButton_Leave"
BorderThickness="2"/>
<Button x:Name="FastSelectButton_MW1_Tank4" Grid.Column="0" Grid.Row="10"
Content="MW1 &#x2B9E; Tank 4" FontSize="16" FontWeight="Bold"
Click="FastSelectButton_Click" MouseEnter="FastSelectButton_Enter" MouseLeave="FastSelectButton_Leave"
BorderThickness="2"/>
<Button x:Name="FastSelectButton_MW2_Tank4" Grid.Column="2" Grid.Row="10"
Content="MW2 &#x2B9E; Tank 4" FontSize="16" FontWeight="Bold"
Click="FastSelectButton_Click" MouseEnter="FastSelectButton_Enter" MouseLeave="FastSelectButton_Leave"
BorderThickness="2"/>
<Button x:Name="FastSelectButton_MW1_Tank5" Grid.Column="0" Grid.Row="12"
Content="MW1 &#x2B9E; Tank 5" FontSize="16" FontWeight="Bold"
Click="FastSelectButton_Click" MouseEnter="FastSelectButton_Enter" MouseLeave="FastSelectButton_Leave"
BorderThickness="2"/>
<Button x:Name="FastSelectButton_MW2_Tank5" Grid.Column="2" Grid.Row="12"
Content="MW2 &#x2B9E; Tank 5" FontSize="16" FontWeight="Bold"
Click="FastSelectButton_Click" MouseEnter="FastSelectButton_Enter" MouseLeave="FastSelectButton_Leave"
BorderThickness="2"/>
</Grid>
</Border>
<Border HorizontalAlignment="Left" VerticalAlignment="Bottom" Padding="60,15,15,30" Margin="-11,0,0,-11"
Background="WhiteSmoke"
BorderBrush="Gray" BorderThickness="1" CornerRadius="10">
<Grid x:Name="FastSelectButtonsLeft">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="160"/>
<ColumnDefinition Width="2.5"/>
<ColumnDefinition Width="2.5"/>
<ColumnDefinition Width="160"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="60"/>
<RowDefinition Height="5"/>
<RowDefinition Height="50"/>
<RowDefinition Height="5"/>
<RowDefinition Height="80"/>
<RowDefinition Height="80"/>
</Grid.RowDefinitions>
<Button x:Name="FastSelectButton_EntryTrough_Start" Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="2"
FontSize="14" FontWeight="Bold"
Click="FastSelectButton_EntryTroughStart_Click" MouseEnter="FastSelectButton_Enter" MouseLeave="FastSelectButton_Leave"
BorderThickness="2">
<TextBlock TextAlignment="Center">Auffangwanne<LineBreak/><Run x:Name="FastSelectButton_EntryTrough_Start_Run" FontSize="18">Schnecke Start</Run></TextBlock>
</Button>
<Button x:Name="FastSelectButton_EntryTrough_Stop" Grid.Column="2" Grid.Row="0" Grid.ColumnSpan="2"
FontSize="14" FontWeight="Bold"
Click="FastSelectButton_EntryTroughStop_Click" MouseEnter="FastSelectButton_Enter" MouseLeave="FastSelectButton_Leave"
BorderThickness="2">
<TextBlock TextAlignment="Center">Auffangwanne<LineBreak/><Run x:Name="FastSelectButton_EntryTrough_Stop_Run" FontSize="18">Schnecke Stop</Run></TextBlock>
</Button>
<Button x:Name="FastSelectButton_MW2" Grid.Column="0" Grid.Row="2"
Content="MW2 &#x2B9C;" FontSize="16" FontWeight="Bold"
Click="FastSelectButton_MW2_Click" MouseEnter="FastSelectButton_Enter" MouseLeave="FastSelectButton_Leave"
BorderThickness="2"/>
<Button x:Name="FastSelectButton_MW1" Grid.Column="3" Grid.Row="2"
Content="&#x2B9E; MW1" FontSize="16" FontWeight="Bold"
Click="FastSelectButton_MW1_Click" MouseEnter="FastSelectButton_Enter" MouseLeave="FastSelectButton_Leave"
BorderThickness="2"/>
<Button x:Name="FastSelectButton_MP2_Stop" Grid.Column="0" Grid.Row="4"
FontSize="16" FontWeight="Bold"
Click="FastSelectButton_MP2_Stop_Click" MouseEnter="FastSelectButton_Enter" MouseLeave="FastSelectButton_Leave"
BorderThickness="2">
<TextBlock TextAlignment="Center"><Run x:Name="FastSelectButton_MP2_Stop_Run" FontSize="24">MP2</Run><LineBreak/>Stop</TextBlock>
</Button>
<Button x:Name="FastSelectButton_MP2_Forward" Grid.Column="0" Grid.Row="5"
FontSize="16" FontWeight="Bold"
Click="FastSelectButton_MP2_Forward_Click" MouseEnter="FastSelectButton_Enter" MouseLeave="FastSelectButton_Leave"
BorderThickness="2">
<TextBlock TextAlignment="Center"><Run x:Name="FastSelectButton_MP2_Forward_Run" FontSize="24">MP2</Run><LineBreak/><Run x:Name="MP2_Target">Vor</Run></TextBlock>
</Button>
<Button x:Name="FastSelectButton_MP1_Stop" Grid.Column="3" Grid.Row="4"
FontSize="16" FontWeight="Bold"
Click="FastSelectButton_MP1_Stop_Click" MouseEnter="FastSelectButton_Enter" MouseLeave="FastSelectButton_Leave"
BorderThickness="2">
<TextBlock TextAlignment="Center"><Run x:Name="FastSelectButton_MP1_Stop_Run" FontSize="24">MP1</Run><LineBreak/>Stop</TextBlock>
</Button>
<Button x:Name="FastSelectButton_MP1_Forward" Grid.Column="3" Grid.Row="5"
FontSize="16" FontWeight="Bold"
Click="FastSelectButton_MP1_Forward_Click" MouseEnter="FastSelectButton_Enter" MouseLeave="FastSelectButton_Leave"
BorderThickness="2">
<TextBlock TextAlignment="Center"><Run x:Name="FastSelectButton_MP1_Forward_Run" FontSize="24">MP1</Run><LineBreak/><Run x:Name="MP1_Target">Vor</Run></TextBlock>
</Button>
</Grid>
</Border>
</Grid>
<StatusBar Grid.Row="2" BorderThickness="0,1,0,0" BorderBrush="Gray">
</StatusBar>
</Grid>
</Window>
+377 -26
View File
@@ -2,23 +2,74 @@ using PamhagenSysCtrl.Helpers;
using PamhagenSysCtrl.Helpers.Pipeline;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
namespace PamhagenSysCtrl.Windows {
public partial class PlantSchemeWindow : Window {
private const double _minMove = 50;
private readonly PamhagenGraph Graph;
private Point? _lastMousePos;
private bool _mouseDragging;
private ISource? _lastSource;
private List<INode> _path = [];
private ISet<INode>? _lastSelected;
private ISet<INode>? _hover;
public double Scale { get; set; } = 5;
public double RoundedScale => Math.Round(Scale * 2) / 2;
public Path? HoveringPath {
get {
foreach (var b in FastSelectPaths.Where(b => b.Key.IsMouseOver)) {
if (Graph.SelectedPaths.Any(p => p.Start == b.Value.Source && p.Hops.Last().Node == b.Value.Sink))
continue;
return Graph.GetFreePath([b.Value.Source, b.Value.Sink], true);
}
if (_lastSource == null || _hover == null || !(_hover.Count > 0 || _path.Count > 0))
return null;
List<INode> points = [_lastSource, .. _path];
if (_hover.Count > 0 && !points.Contains(_hover.First())) {
points.Add(_hover.First());
}
if (points.Count >= 2) {
return Graph.GetFreePath(points);
} else {
return null;
}
}
}
protected Dictionary<Button, (ISource Source, Pump Pump, ISink Sink)> FastSelectPaths;
public PlantSchemeWindow() {
InitializeComponent();
App.Plant?.Update += OnUpdate;
Menu_Help_CheckForUpdates.IsEnabled = App.Config.UpdateUrl != null;
Graph = new();
Graph.Draw(SchemeCanvas);
Graph.Draw(SchemeCanvas, RoundedScale);
FastSelectPaths = new Dictionary<Button, (ISource, Pump, ISink)> {
[FastSelectButton_MW1_Press1] = (Graph.MW1, Graph.MP1, Graph.Press1),
[FastSelectButton_MW2_Press1] = (Graph.MW2, Graph.MP2, Graph.Press1),
[FastSelectButton_MW1_Press2] = (Graph.MW1, Graph.MP1, Graph.Press2),
[FastSelectButton_MW2_Press2] = (Graph.MW2, Graph.MP2, Graph.Press2),
[FastSelectButton_MW1_Tank1] = (Graph.MW1, Graph.MP1, Graph.Tank1),
[FastSelectButton_MW2_Tank1] = (Graph.MW2, Graph.MP2, Graph.Tank1),
[FastSelectButton_MW1_Tank2] = (Graph.MW1, Graph.MP1, Graph.Tank2),
[FastSelectButton_MW2_Tank2] = (Graph.MW2, Graph.MP2, Graph.Tank2),
[FastSelectButton_MW1_Tank3] = (Graph.MW1, Graph.MP1, Graph.Tank3),
[FastSelectButton_MW2_Tank3] = (Graph.MW2, Graph.MP2, Graph.Tank3),
[FastSelectButton_MW1_Tank4] = (Graph.MW1, Graph.MP1, Graph.Tank4),
[FastSelectButton_MW2_Tank4] = (Graph.MW2, Graph.MP2, Graph.Tank4),
[FastSelectButton_MW1_Tank5] = (Graph.MW1, Graph.MP1, Graph.Tank5),
[FastSelectButton_MW2_Tank5] = (Graph.MW2, Graph.MP2, Graph.Tank5),
};
App.Plant?.Update += OnUpdate;
InitializePaths();
}
private void OnClosed(object sender, EventArgs evt) {
@@ -44,6 +95,8 @@ namespace PamhagenSysCtrl.Windows {
}
Menu_Settings_OverridePathClearances.IsChecked = false;
Menu_Settings_OverrideDryRunClearances.IsChecked = false;
InitializePaths();
}
OnUpdate(null, null);
}
@@ -75,18 +128,220 @@ namespace PamhagenSysCtrl.Windows {
} catch { }
}
private void SchemeCanvas_MouseMove(object sender, MouseEventArgs evt) {
var p = evt.GetPosition(SchemeCanvas);
private async void Menu_Help_CheckForUpdates_Click(object sender, RoutedEventArgs evt) {
await App.CheckForUpdates(true);
}
private void Menu_Help_About_Click(object sender, RoutedEventArgs evt) {
var window = new AboutWindow {
Owner = this,
};
window.Show();
}
private void FastSelectButton_EntryTroughStart_Click(object sender, RoutedEventArgs evt) {
try {
App.Plant?.StartTroughAuger();
} catch (NoClearanceException exc) {
MessageBox.Show($"{exc.Message}", "Keine Freigabe", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
private void FastSelectButton_EntryTroughStop_Click(object sender, RoutedEventArgs evt) {
try {
App.Plant?.StopTroughAuger();
} catch (NoClearanceException exc) {
MessageBox.Show($"{exc.Message}", "Keine Freigabe", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
private void FastSelectButton_MW1_Click(object sender, RoutedEventArgs evt) {
try {
App.Plant?.SelectMW1();
} catch (NoClearanceException exc) {
MessageBox.Show($"{exc.Message}", "Keine Freigabe", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
private void FastSelectButton_MW2_Click(object sender, RoutedEventArgs evt) {
try {
App.Plant?.SelectMW2();
} catch (NoClearanceException exc) {
MessageBox.Show($"{exc.Message}", "Keine Freigabe", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
private void FastSelectButton_MP1_Forward_Click(object sender, RoutedEventArgs evt) {
try {
App.Plant?.StartMP1Forward();
} catch (NoClearanceException exc) {
MessageBox.Show($"{exc.Message}", "Keine Freigabe", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
private void FastSelectButton_MP1_Stop_Click(object sender, RoutedEventArgs evt) {
try {
App.Plant?.StopMP1();
} catch (NoClearanceException exc) {
MessageBox.Show($"{exc.Message}", "Keine Freigabe", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
private void FastSelectButton_MP2_Forward_Click(object sender, RoutedEventArgs evt) {
try {
App.Plant?.StartMP2Forward();
} catch (NoClearanceException exc) {
MessageBox.Show($"{exc.Message}", "Keine Freigabe", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
private void FastSelectButton_MP2_Stop_Click(object sender, RoutedEventArgs evt) {
try {
App.Plant?.StopMP2();
} catch (NoClearanceException exc) {
MessageBox.Show($"{exc.Message}", "Keine Freigabe", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
private void FastSelectButton_Enter(object sender, MouseEventArgs evt) {
UpdateScheme(evt.GetPosition(SchemeCanvas), evt.LeftButton == MouseButtonState.Pressed);
}
private void FastSelectButton_Leave(object sender, MouseEventArgs evt) {
UpdateScheme(evt.GetPosition(SchemeCanvas), evt.LeftButton == MouseButtonState.Pressed);
}
private void FastSelectButton_Click(object sender, RoutedEventArgs evt) {
if (sender is not Button b || !FastSelectPaths.TryGetValue(b, out var val))
return;
if (Graph.SelectedPaths.Select(p => (Path?)p).FirstOrDefault(p => p?.Start == val.Source, null) is Path p1) {
Graph.RemovePath(p1);
if (p1.Hops.Last().Node == val.Sink)
return;
}
if (Graph.GetFreePath([val.Source, val.Sink]) is Path p2) {
Graph.AddPath(p2);
_lastSource = null;
}
}
private void OnSizeChanged(object sender, SizeChangedEventArgs evt) {
var rx = evt.NewSize.Width / 1550.0;
var ry = evt.NewSize.Height / 900.0;
var r = Math.Min(rx, ry);
Scale = r * 5;
SchemeCanvas.Margin = new();
Graph.Scale(RoundedScale);
if (RoundedScale < 4) {
(FastSelectButtonsLeft.Parent as Border)?.Visibility = Visibility.Hidden;
(FastSelectButtonsRight.Parent as Border)?.Visibility = Visibility.Hidden;
} else if (RoundedScale <= 5) {
(FastSelectButtonsLeft.Parent as Border)?.Visibility = Visibility.Visible;
FastSelectButtonsLeft.ColumnDefinitions[0].Width = new(120);
FastSelectButtonsLeft.ColumnDefinitions[3].Width = new(120);
FastSelectButtonsLeft.RowDefinitions[0].Height = new(45);
FastSelectButtonsLeft.RowDefinitions[2].Height = new(40);
FastSelectButtonsLeft.RowDefinitions[4].Height = new(55);
FastSelectButtonsLeft.RowDefinitions[5].Height = new(55);
(FastSelectButtonsRight.Parent as Border)?.Visibility = Visibility.Visible;
foreach (var col in FastSelectButtonsRight.ColumnDefinitions) {
if (col.Width.Value <= 5) continue;
col.Width = new(120);
}
foreach (var row in FastSelectButtonsRight.RowDefinitions) {
if (row.Height.Value <= 5) continue;
row.Height = new(40);
}
foreach (var b in FastSelectPaths.Keys) {
b.FontSize = 14;
}
FastSelectButton_EntryTrough_Start.FontSize = 12;
FastSelectButton_EntryTrough_Start_Run.FontSize = 14;
FastSelectButton_EntryTrough_Stop.FontSize = 12;
FastSelectButton_EntryTrough_Stop_Run.FontSize = 14;
FastSelectButton_MW1.FontSize = 14;
FastSelectButton_MW2.FontSize = 14;
FastSelectButton_MP1_Stop.FontSize = 14;
FastSelectButton_MP1_Stop_Run.FontSize = 18;
FastSelectButton_MP1_Forward.FontSize = 14;
FastSelectButton_MP1_Forward_Run.FontSize = 18;
FastSelectButton_MP2_Stop.FontSize = 14;
FastSelectButton_MP2_Stop_Run.FontSize = 18;
FastSelectButton_MP2_Forward.FontSize = 14;
FastSelectButton_MP2_Forward_Run.FontSize = 18;
} else {
(FastSelectButtonsLeft.Parent as Border)?.Visibility = Visibility.Visible;
FastSelectButtonsLeft.ColumnDefinitions[0].Width = new(160);
FastSelectButtonsLeft.ColumnDefinitions[3].Width = new(160);
FastSelectButtonsLeft.RowDefinitions[0].Height = new(60);
FastSelectButtonsLeft.RowDefinitions[2].Height = new(50);
FastSelectButtonsLeft.RowDefinitions[4].Height = new(80);
FastSelectButtonsLeft.RowDefinitions[5].Height = new(80);
(FastSelectButtonsRight.Parent as Border)?.Visibility = Visibility.Visible;
foreach (var col in FastSelectButtonsRight.ColumnDefinitions) {
if (col.Width.Value <= 5) continue;
col.Width = new(160);
}
foreach (var row in FastSelectButtonsRight.RowDefinitions) {
if (row.Height.Value <= 5) continue;
row.Height = new(50);
}
foreach (var b in FastSelectPaths.Keys) {
b.FontSize = 16;
}
FastSelectButton_EntryTrough_Start.FontSize = 14;
FastSelectButton_EntryTrough_Start_Run.FontSize = 18;
FastSelectButton_EntryTrough_Stop.FontSize = 14;
FastSelectButton_EntryTrough_Stop_Run.FontSize = 18;
FastSelectButton_MW1.FontSize = 16;
FastSelectButton_MW2.FontSize = 16;
FastSelectButton_MP1_Stop.FontSize = 16;
FastSelectButton_MP1_Stop_Run.FontSize = 24;
FastSelectButton_MP1_Forward.FontSize = 16;
FastSelectButton_MP1_Forward_Run.FontSize = 24;
FastSelectButton_MP2_Stop.FontSize = 16;
FastSelectButton_MP2_Stop_Run.FontSize = 24;
FastSelectButton_MP2_Forward.FontSize = 16;
FastSelectButton_MP2_Forward_Run.FontSize = 24;
}
UpdateScheme(Mouse.GetPosition(SchemeCanvas), Mouse.LeftButton == MouseButtonState.Pressed);
}
private void SchemeCanvas_MouseWheel(object sender, MouseWheelEventArgs evt) {
Scale = Math.Max(1, Math.Min(20, Scale + evt.Delta / 500.0));
Graph.Scale(RoundedScale);
UpdateScheme(evt.GetPosition(SchemeCanvas), evt.LeftButton == MouseButtonState.Pressed);
}
private void SchemeCanvas_MouseMove(object sender, MouseEventArgs evt) {
var pos = evt.GetPosition(SchemeCanvas);
if (_lastMousePos is Point p) {
if (!_mouseDragging) {
var dx = p.X - pos.X;
var dy = p.Y - pos.Y;
_mouseDragging = Math.Sqrt(dx * dx + dy * dy) >= _minMove;
}
if (_mouseDragging) {
var dx = SchemeCanvas.Margin.Right - SchemeCanvas.Margin.Left + p.X - pos.X;
var dy = SchemeCanvas.Margin.Bottom - SchemeCanvas.Margin.Top + p.Y - pos.Y;
SchemeCanvas.Margin = new(dx > 0 ? 0 : -dx, dy > 0 ? 0 : -dy, dx < 0 ? 0 : dx, dy < 0 ? 0 : dy);
}
}
UpdateScheme(pos, evt.LeftButton == MouseButtonState.Pressed);
}
private void SchemeCanvas_MouseLeftButtonDown(object sender, MouseButtonEventArgs evt) {
var p = evt.GetPosition(SchemeCanvas);
_lastSelected = UpdateScheme(evt.GetPosition(SchemeCanvas), evt.LeftButton == MouseButtonState.Pressed);
var pos = evt.GetPosition(SchemeCanvas);
_lastMousePos = pos;
_mouseDragging = false;
_lastSelected = UpdateScheme(pos, evt.LeftButton == MouseButtonState.Pressed);
}
private void SchemeCanvas_MouseLeftButtonUp(object sender, MouseButtonEventArgs evt) {
var pos = evt.GetPosition(SchemeCanvas);
_lastMousePos = null;
_mouseDragging = false;
var curSelected = UpdateScheme(pos, evt.LeftButton == MouseButtonState.Pressed);
var clicked = curSelected.Intersect(_lastSelected ?? new HashSet<INode>()).ToList();
if (clicked.Count == 0) {
@@ -108,13 +363,12 @@ namespace PamhagenSysCtrl.Windows {
Graph.RemovePath(path);
}
} else if (_lastSource != null && c is ISink sink) {
var res = Graph.GetPath([_lastSource, .. _path, sink], (n) => n is not ISink && (n is not Valve v || !v.IsLocked));
if (res is Path path) {
if (Graph.GetFreePath([_lastSource, .. _path, sink]) is Path path) {
Graph.AddPath(path);
_lastSource = null;
}
} else if (_lastSource != null) {
var path = Graph.GetPath([_lastSource, .. _path, c], (n) => n is not ISink && (n is not Valve v || !v.IsLocked));
var path = Graph.GetFreePath([_lastSource, .. _path, c]);
if (path != null) {
_path.Add(c);
}
@@ -216,6 +470,30 @@ namespace PamhagenSysCtrl.Windows {
UpdateScheme(pos, evt.LeftButton == MouseButtonState.Pressed);
}
private static void SetFastSelectButton(Button b, int m, bool disabled = false) {
b.IsEnabled = !disabled;
if (m == 1) {
b.Background = Brushes.MintCream;
b.BorderBrush = Brushes.DarkGreen;
b.Foreground = Brushes.DarkGreen;
} else if (m == 2) {
b.Background = Brushes.MistyRose;
b.BorderBrush = Brushes.DarkRed;
b.Foreground = Brushes.DarkRed;
} else {
b.Background = Brushes.LightGray;
b.BorderBrush = Brushes.DimGray;
b.Foreground = Brushes.Black;
}
}
private void UpdateFastSelectPathButton(IEnumerable<Path> paths, Path? hoverPathDeactivate, Button b) {
var e = FastSelectPaths[b];
SetFastSelectButton(b,
paths.Any(p => p.Start == e.Source && p.Hops.Last().Node == e.Sink) ? (hoverPathDeactivate?.Start == e.Source && hoverPathDeactivate?.Hops.Last().Node == e.Sink) ? 2 : 1 : 0,
e.Pump.IsActive || Graph.GetFreePath([e.Source, e.Sink], overrideStart: true) == null);
}
private ISet<INode> UpdateScheme(Point pos, bool down) {
foreach (var e in Graph.Edges) {
e.Highlight = null;
@@ -227,35 +505,52 @@ namespace PamhagenSysCtrl.Windows {
}
}
_hover = Graph.GetHover(pos.X, pos.Y);
SetFastSelectButton(FastSelectButton_EntryTrough_Start, App.Plant?.IsTroughAugerActive ?? false ? 1 : 0, !(App.Plant?.TroughAugerHasClearance ?? false));
SetFastSelectButton(FastSelectButton_EntryTrough_Stop, App.Plant?.IsTroughAugerActive ?? false ? 0 : 2);
SetFastSelectButton(FastSelectButton_MW1, App.Plant?.IsMW1Selected ?? false ? 1 : 0);
SetFastSelectButton(FastSelectButton_MW2, App.Plant?.IsMW2Selected ?? false ? 1 : 0);
SetFastSelectButton(FastSelectButton_MP1_Forward, App.Plant?.MP1 == MotorState.Forward ? 1 : 0, !(App.Plant?.MP1HasClearance ?? false));
SetFastSelectButton(FastSelectButton_MP1_Stop, App.Plant?.MP1 == MotorState.Halt ? 2 : 0);
SetFastSelectButton(FastSelectButton_MP2_Forward, App.Plant?.MP2 == MotorState.Forward ? 1 : 0, !(App.Plant?.MP2HasClearance ?? false));
SetFastSelectButton(FastSelectButton_MP2_Stop, App.Plant?.MP2 == MotorState.Halt ? 2 : 0);
foreach (var b in FastSelectPaths) {
SetFastSelectButton(b.Key, 0, false);
}
_hover = Graph.GetHover(pos.X, pos.Y, RoundedScale);
var hoverButtons = FastSelectPaths.Where(b => b.Key.IsMouseOver).ToDictionary();
Path? hoverPathDeactivate = null;
if (App.Plant?.ManualControlMode ?? false) {
foreach (var src in Graph.Nodes.Where(n => n is Pump)) {
Graph.ColorPipesByValves(src, PamhagenBrushes.Green, (src as Pump)?.State ?? default, PamhagenBrushes.DimOrange);
}
MP1_Target.Text = "Vor";
MP2_Target.Text = "Vor";
MP1_Target.FontSize = 16;
MP2_Target.FontSize = 16;
} else {
foreach (var p in Graph.SelectedPaths) {
Graph.ColorPipesAdjacientToPath(p, PamhagenBrushes.Green, p.Hops.Select(h => (h.Node as Pump)?.State ?? default).FirstOrDefault(n => n != MotorState.Halt), PamhagenBrushes.DimOrange);
}
if (_lastSource != null && (_hover.Count > 0 || _path.Count > 0)) {
List<INode> points = [_lastSource, .. _path];
if (_hover.Count > 0 && !points.Contains(_hover.First())) {
points.Add(_hover.First());
}
if (points.Count >= 2) {
var res = Graph.GetPath(points, (n) => n is not ISink && (n is not Valve v || !v.IsLocked));
if (res is Path path) {
Graph.ColorPipesAdjacientToPath(path, PamhagenBrushes.Green, default, PamhagenBrushes.DimOrange);
}
}
} else if (_lastSource == null && _hover.Count > 0 && Graph.SelectedPaths.Any(p => p.Start == _hover.First())) {
var path = Graph.SelectedPaths.First(p => p.Start == _hover.First());
var pumpActive = path.Hops.Any(h => (h.Node as Pump)?.IsActive ?? false);
if (_lastSource == null && _hover.Count > 0 && Graph.SelectedPaths.Select(p => (Path?)p).FirstOrDefault(p => p?.Start == _hover.First()) is Path path1) {
var pumpActive = path1.Hops.Any(h => (h.Node as Pump)?.IsActive ?? false);
if (pumpActive) {
foreach (var pump in path.Hops.Select(h => h.Node as Pump).Where(p => p != null)) {
foreach (var pump in path1.Hops.Select(h => h.Node as Pump).Where(p => p != null)) {
pump?.Highlight = PamhagenBrushes.Red;
}
} else {
Graph.ColorPipesAdjacientToPath(path, PamhagenBrushes.Red, default, null);
hoverPathDeactivate = path1;
Graph.ColorPipesAdjacientToPath(path1, PamhagenBrushes.Red, default, null);
}
} else if (hoverButtons.Count != 0 && Graph.SelectedPaths.Select(p => (Path?)p).FirstOrDefault(p => p?.Start == hoverButtons.First().Value.Source) is Path path2) {
var pumpActive = path2.Hops.Any(h => (h.Node as Pump)?.IsActive ?? false);
if (pumpActive) {
foreach (var pump in path2.Hops.Select(h => h.Node as Pump).Where(p => p != null)) {
pump?.Highlight = PamhagenBrushes.Red;
}
} else {
hoverPathDeactivate = path2;
Graph.ColorPipesAdjacientToPath(path2, PamhagenBrushes.Red, default, null);
}
}
if (_lastSource != null) {
@@ -263,7 +558,36 @@ namespace PamhagenSysCtrl.Windows {
edge.Highlight = PamhagenBrushes.Green;
}
}
if (HoveringPath is Path hoveringPath) {
Graph.ColorPipesAdjacientToPath(hoveringPath, PamhagenBrushes.Green, default, PamhagenBrushes.DimOrange);
}
if (Graph.SelectedPaths.Select(p => (Path?)p).FirstOrDefault(p => p?.Start == Graph.MW1) is Path pmw1) {
MP1_Target.Text = "\u2b9e " + string.Join(" \u2b9e ", pmw1.Hops
.Select(h => h.Node is Valve || h.Node is Pump || h.Node is CenterValve ? null : h.Node.Label)
.Where(l => !string.IsNullOrWhiteSpace(l)));
} else {
MP1_Target.Text = "Vor";
}
if (Graph.SelectedPaths.Select(p => (Path?)p).FirstOrDefault(p => p?.Start == Graph.MW2) is Path pmw2) {
MP2_Target.Text = "\u2b9e " + string.Join(" \u2b9e ", pmw2.Hops
.Select(h => h.Node is Valve || h.Node is Pump || h.Node is CenterValve ? null : h.Node.Label)
.Where(l => !string.IsNullOrWhiteSpace(l)));
} else {
MP2_Target.Text = "Vor";
}
var len1 = MP1_Target.Text.Length;
var len2 = MP2_Target.Text.Length;
MP1_Target.FontSize = len1 > 24 ? 8 : len1 > 20 ? 10 : len1 > 16 ? 12 : len1 > 12 ? 14 : 16;
MP2_Target.FontSize = len2 > 24 ? 8 : len2 > 20 ? 10 : len2 > 16 ? 12 : len2 > 12 ? 14 : 16;
}
var paths = Graph.SelectedPaths;
if (HoveringPath is Path hp) paths = paths.Append(hp);
foreach (var b in FastSelectPaths.Keys) {
UpdateFastSelectPathButton(paths, hoverPathDeactivate, b);
}
Graph.Update(_hover, down);
return _hover;
}
@@ -272,5 +596,32 @@ namespace PamhagenSysCtrl.Windows {
if (sender is not PamhagenPlant plant) return;
UpdateScheme(Mouse.GetPosition(SchemeCanvas), Mouse.LeftButton == MouseButtonState.Pressed);
}
public void InitializePaths() {
var add = ReconstructSelectedPaths().ToList();
var remove = Graph.SelectedPaths.ToList();
foreach (var p in remove) Graph.RemovePath(p);
for (int i = 1; i <= 57; i++) {
App.Plant?.CloseV(i);
}
foreach (var p in add) {
if (p.Hops.Any(h => h.Node is Valve v && v.IsLocked)) continue;
Graph.AddPath(p);
}
}
public IEnumerable<Path> ReconstructSelectedPaths() {
if (App.Plant is not PamhagenPlant p) yield break;
var sources = Graph.Nodes.Where(n => n is ISource).ToList();
var sinks = Graph.Nodes.Where(n => n is ISink).ToList();
foreach (var src in sources) {
var paths = new List<Path>();
foreach (var sink in sinks) {
paths.AddRange(Graph.GetPaths(src, sink, null, (n) => n is not ISink && (n is not Valve v || p.WantValveOpen(v.Nr))));
}
if (paths.Count == 1)
yield return paths.First();
}
}
}
}
+41 -1
View File
@@ -1,2 +1,42 @@
# Anlagensteuerung Pamhangen
Anlagensteuerung Pamhagen
=========================
Schnittstelle zur SPS und grafische Benutzeroberfläche.
Winzerkeller Seewinkel, Pamhagen.
About
=====
**Product:** Anlagensteuerung Pamhagen
**Description:** Interface to a LPC and graphical user interface for controlling the plant/system
**Type:** HMI and PLC Control Software
**Version:** 0.0.3 ([Changelog](./CHANGELOG.md))
**License:** [GNU General Public License 3.0 (GPLv3)](./LICENSE)
**Source code:** https://git.necronda.net/winzer/pamhagen-sysctrl
**Developement period:** 2026
**Technology Stack:**
Language: C#
Framework: Windows Presentation Framework (WPF)
LPC-Interface: Serial connection
Packaging: [WiX Toolset](https://www.firegiant.com/wixtoolset/)
Über
====
**Produkt:** Anlagensteuerung Pamhagen
**Beschreibung:** Schnittstelle zu einer SPS und grafische Benutzeroberfläche für die Steuerung der Anlage
**Typ:** HMI- und SPS-Steuerungssoftware
**Version:** 0.0.3 ([Änderungsprotokoll](./CHANGELOG.md))
**Lizenz:** [GNU General Public License 3.0 (GPLv3)](./LICENSE)
**Quellcode:** https://git.necronda.net/winzer/pamhagen-sysctrl
**Entwicklungszeitraum:** 2026
**Verwendete Technologien:**
Programmiersprache: C#
Framework: Windows Presentation Framework (WPF)
SPS-Schnittstelle: Serielle Verbindung
Paketierung: [WiX Toolset](https://www.firegiant.com/wixtoolset/)