Compare commits
9
Commits
e45c398c68
..
v0.0.3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d507a7486e | ||
|
|
ece46846b4 | ||
|
|
03c91fb55a | ||
|
|
f0accc8df8 | ||
|
|
3983393e10 | ||
|
|
c82adcc054 | ||
|
|
28aaa6b1f3 | ||
|
|
0ceab368ce | ||
|
|
7c3233361f |
No files matched your search
@@ -5,10 +5,12 @@ namespace PamhagenSysCtrl.Helpers {
|
|||||||
|
|
||||||
public const double TRANSITION = 1.0 / 4096;
|
public const double TRANSITION = 1.0 / 4096;
|
||||||
|
|
||||||
public static readonly SolidColorBrush Green = new SolidColorBrush(Color.FromRgb(0x20, 0xE0, 0x20));
|
public static readonly SolidColorBrush Green = new(Color.FromRgb(0x20, 0xE0, 0x20));
|
||||||
public static readonly SolidColorBrush DimOrange = new SolidColorBrush(Color.FromRgb(0xFF, 0xC0, 0x80));
|
public static readonly SolidColorBrush DimGreen = new(Color.FromRgb(0xC0, 0xE0, 0xC0));
|
||||||
public static readonly SolidColorBrush Yellow = new SolidColorBrush(Color.FromRgb(0xFF, 0xE0, 0x10));
|
public static readonly SolidColorBrush DimOrange = new(Color.FromRgb(0xFF, 0xC0, 0x80));
|
||||||
public static readonly SolidColorBrush Red = new SolidColorBrush(Color.FromRgb(0xFF, 0x20, 0x20));
|
public static readonly SolidColorBrush Yellow = new(Color.FromRgb(0xFF, 0xE0, 0x10));
|
||||||
|
public static readonly SolidColorBrush Red = new(Color.FromRgb(0xFF, 0x20, 0x20));
|
||||||
|
public static readonly SolidColorBrush DimRed = new(Color.FromRgb(0xFF, 0xC0, 0xC0));
|
||||||
|
|
||||||
public static Brush ForFillState(FillState state, Color background) {
|
public static Brush ForFillState(FillState state, Color background) {
|
||||||
return state switch {
|
return state switch {
|
||||||
|
|||||||
@@ -18,6 +18,17 @@ namespace PamhagenSysCtrl.Helpers {
|
|||||||
public readonly Pump P6;
|
public readonly Pump P6;
|
||||||
public readonly EncasedAuger Auger1;
|
public readonly EncasedAuger Auger1;
|
||||||
public readonly EncasedAuger Auger3;
|
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() {
|
public PamhagenGraph() {
|
||||||
double mw2X = 180;
|
double mw2X = 180;
|
||||||
@@ -66,8 +77,8 @@ namespace PamhagenSysCtrl.Helpers {
|
|||||||
|
|
||||||
MW1 = new Trough("MW1", mw1X, mpY - 70, () => App.Plant?.FillLevelMW1 ?? FillState.Unknown);
|
MW1 = new Trough("MW1", mw1X, mpY - 70, () => App.Plant?.FillLevelMW1 ?? FillState.Unknown);
|
||||||
MW2 = new Trough("MW2", mw2X, mpY - 70, () => App.Plant?.FillLevelMW2 ?? FillState.Unknown);
|
MW2 = new Trough("MW2", mw2X, mpY - 70, () => App.Plant?.FillLevelMW2 ?? FillState.Unknown);
|
||||||
MP1 = new Pump("MP1", mw1X, mpY, () => App.Plant?.IsMP1Active ?? false, () => App.Plant?.MP1HasClearance ?? false, (x) => SelectedPaths.Any(p => p.Hops.Any(h => h.Node == x)));
|
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?.IsMP2Active ?? false, () => App.Plant?.MP2HasClearance ?? 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 x1 = new PipeJoin(mw1X, mpY + 40);
|
||||||
var x2 = new PipeJoin(mw2X, mpY + 40);
|
var x2 = new PipeJoin(mw2X, mpY + 40);
|
||||||
|
|
||||||
@@ -76,19 +87,19 @@ namespace PamhagenSysCtrl.Helpers {
|
|||||||
CreatePipe(MP1, x1);
|
CreatePipe(MP1, x1);
|
||||||
CreatePipe(MP2, x2);
|
CreatePipe(MP2, x2);
|
||||||
|
|
||||||
var v1 = CreateValve(1, mw1X, mpY + 70);
|
var v1 = CreateValve(1, mw1X, mpY + 80);
|
||||||
var v2 = CreateValve(2, mw2X, mpY + 70);
|
var v2 = CreateValve(2, mw2X, mpY + 80);
|
||||||
var v3 = CreateValve(3, mw2X + 30, mpY + 70);
|
var v3 = CreateValve(3, mw2X + 30, mpY + 80);
|
||||||
var v4 = CreateValve(4, mw1X - 30, mpY + 70);
|
var v4 = CreateValve(4, mw1X - 30, mpY + 80);
|
||||||
|
|
||||||
CreatePipe(x1, v1);
|
CreatePipe(x1, v1);
|
||||||
CreatePipe(x1, v4);
|
CreatePipe(x1, v4);
|
||||||
CreatePipe(x2, v2);
|
CreatePipe(x2, v2);
|
||||||
CreatePipe(x2, v3);
|
CreatePipe(x2, v3);
|
||||||
|
|
||||||
var x3 = new PipeJoin(mw1X, mpY + 100);
|
var x3 = new PipeJoin(mw1X, ltg1Y);
|
||||||
var x4 = new PipeJoin(x1X, ltg1Y);
|
var x4 = new PipeJoin(x1X, ltg1Y);
|
||||||
var x5 = new PipeJoin(mw2X, mpY + 130);
|
var x5 = new PipeJoin(mw1X - 30, ltg2Y);
|
||||||
var x6 = new PipeJoin(x1X - 30, ltg2Y);
|
var x6 = new PipeJoin(x1X - 30, ltg2Y);
|
||||||
|
|
||||||
CreatePipe(v1, x3, true);
|
CreatePipe(v1, x3, true);
|
||||||
@@ -180,37 +191,37 @@ namespace PamhagenSysCtrl.Helpers {
|
|||||||
var xv23 = new PipeJoin(t1X + 15, ltg6Y);
|
var xv23 = new PipeJoin(t1X + 15, ltg6Y);
|
||||||
var v22 = CreateValve(22, t1X - 15, tValveY);
|
var v22 = CreateValve(22, t1X - 15, tValveY);
|
||||||
var v23 = CreateValve(23, t1X + 15, tValveY);
|
var v23 = CreateValve(23, t1X + 15, tValveY);
|
||||||
var t1 = CreateTank(1, t1X, tanksY, 35000);
|
Tank1 = CreateTank(1, t1X, tanksY, 35000);
|
||||||
CreatePipe(xv20, xv22, true, label: "Ltg. 7", labelOffsetX: 50);
|
CreatePipe(xv20, xv22, true, label: "Ltg. 7", labelOffsetX: 50);
|
||||||
CreatePipe(xv21, xv23, true, label: "Ltg. 6", labelOffsetX: 20);
|
CreatePipe(xv21, xv23, true, label: "Ltg. 6", labelOffsetX: 20);
|
||||||
CreatePipe(xv22, v22);
|
CreatePipe(xv22, v22);
|
||||||
CreatePipe(xv23, v23);
|
CreatePipe(xv23, v23);
|
||||||
CreateInlet(v22, t1);
|
CreateInlet(v22, Tank1);
|
||||||
CreateInlet(v23, t1);
|
CreateInlet(v23, Tank1);
|
||||||
|
|
||||||
var xv24 = new PipeJoin(t2X - 15, ltg7Y);
|
var xv24 = new PipeJoin(t2X - 15, ltg7Y);
|
||||||
var xv25 = new PipeJoin(t2X + 15, ltg6Y);
|
var xv25 = new PipeJoin(t2X + 15, ltg6Y);
|
||||||
var v24 = CreateValve(24, t2X - 15, tValveY);
|
var v24 = CreateValve(24, t2X - 15, tValveY);
|
||||||
var v25 = CreateValve(25, t2X + 15, tValveY);
|
var v25 = CreateValve(25, t2X + 15, tValveY);
|
||||||
var t2 = CreateTank(2, t2X, tanksY, 35000);
|
Tank2 = CreateTank(2, t2X, tanksY, 35000);
|
||||||
CreatePipe(xv22, xv24);
|
CreatePipe(xv22, xv24);
|
||||||
CreatePipe(xv23, xv25);
|
CreatePipe(xv23, xv25);
|
||||||
CreatePipe(xv24, v24);
|
CreatePipe(xv24, v24);
|
||||||
CreatePipe(xv25, v25);
|
CreatePipe(xv25, v25);
|
||||||
CreateInlet(v24, t2);
|
CreateInlet(v24, Tank2);
|
||||||
CreateInlet(v25, t2);
|
CreateInlet(v25, Tank2);
|
||||||
|
|
||||||
var xv26 = new PipeJoin(t3X - 15, ltg7Y);
|
var xv26 = new PipeJoin(t3X - 15, ltg7Y);
|
||||||
var xv27 = new PipeJoin(t3X + 15, ltg6Y);
|
var xv27 = new PipeJoin(t3X + 15, ltg6Y);
|
||||||
var v26 = CreateValve(26, t3X - 15, tValveY);
|
var v26 = CreateValve(26, t3X - 15, tValveY);
|
||||||
var v27 = CreateValve(27, t3X + 15, tValveY);
|
var v27 = CreateValve(27, t3X + 15, tValveY);
|
||||||
var t3 = CreateTank(3, t3X, tanksY, 35000);
|
Tank3 = CreateTank(3, t3X, tanksY, 35000);
|
||||||
CreatePipe(xv24, xv26);
|
CreatePipe(xv24, xv26);
|
||||||
CreatePipe(xv25, xv27);
|
CreatePipe(xv25, xv27);
|
||||||
CreatePipe(xv26, v26);
|
CreatePipe(xv26, v26);
|
||||||
CreatePipe(xv27, v27);
|
CreatePipe(xv27, v27);
|
||||||
CreateInlet(v26, t3);
|
CreateInlet(v26, Tank3);
|
||||||
CreateInlet(v27, t3);
|
CreateInlet(v27, Tank3);
|
||||||
|
|
||||||
var v28 = CreateValve(28, (t3X + t4X) / 2, ltg7Y);
|
var v28 = CreateValve(28, (t3X + t4X) / 2, ltg7Y);
|
||||||
var v29 = CreateValve(29, (t3X + t4X) / 2, ltg6Y);
|
var v29 = CreateValve(29, (t3X + t4X) / 2, ltg6Y);
|
||||||
@@ -221,25 +232,25 @@ namespace PamhagenSysCtrl.Helpers {
|
|||||||
var xv31 = new PipeJoin(t4X + 15, ltg6Y);
|
var xv31 = new PipeJoin(t4X + 15, ltg6Y);
|
||||||
var v30 = CreateValve(30, t4X - 15, tValveY);
|
var v30 = CreateValve(30, t4X - 15, tValveY);
|
||||||
var v31 = CreateValve(31, t4X + 15, tValveY);
|
var v31 = CreateValve(31, t4X + 15, tValveY);
|
||||||
var t4 = CreateTank(4, t4X, tanksY, 35000);
|
Tank4 = CreateTank(4, t4X, tanksY, 35000);
|
||||||
CreatePipe(v28, xv30);
|
CreatePipe(v28, xv30);
|
||||||
CreatePipe(v29, xv31);
|
CreatePipe(v29, xv31);
|
||||||
CreatePipe(xv30, v30);
|
CreatePipe(xv30, v30);
|
||||||
CreatePipe(xv31, v31);
|
CreatePipe(xv31, v31);
|
||||||
CreateInlet(v30, t4);
|
CreateInlet(v30, Tank4);
|
||||||
CreateInlet(v31, t4);
|
CreateInlet(v31, Tank4);
|
||||||
|
|
||||||
var xv32 = new PipeJoin(t5X - 15, ltg7Y);
|
var xv32 = new PipeJoin(t5X - 15, ltg7Y);
|
||||||
var xv33 = new PipeJoin(t5X + 15, ltg6Y);
|
var xv33 = new PipeJoin(t5X + 15, ltg6Y);
|
||||||
var v32 = CreateValve(32, t5X - 15, tValveY);
|
var v32 = CreateValve(32, t5X - 15, tValveY);
|
||||||
var v33 = CreateValve(33, t5X + 15, tValveY);
|
var v33 = CreateValve(33, t5X + 15, tValveY);
|
||||||
var t5 = CreateTank(5, t5X, tanksY, 35000);
|
Tank5 = CreateTank(5, t5X, tanksY, 35000);
|
||||||
CreatePipe(xv30, xv32, label: "Ltg. 7", labelOffsetX: 30);
|
CreatePipe(xv30, xv32, label: "Ltg. 7", labelOffsetX: 30);
|
||||||
CreatePipe(xv31, xv33, label: "Ltg. 6", labelOffsetX: 0);
|
CreatePipe(xv31, xv33, label: "Ltg. 6", labelOffsetX: 0);
|
||||||
CreatePipe(xv32, v32);
|
CreatePipe(xv32, v32);
|
||||||
CreatePipe(xv33, v33);
|
CreatePipe(xv33, v33);
|
||||||
CreateInlet(v32, t5);
|
CreateInlet(v32, Tank5);
|
||||||
CreateInlet(v33, t5);
|
CreateInlet(v33, Tank5);
|
||||||
|
|
||||||
var v34 = CreateValve(34, (t5X + t6X) / 2, ltg7Y);
|
var v34 = CreateValve(34, (t5X + t6X) / 2, ltg7Y);
|
||||||
var v35 = CreateValve(35, (t5X + t6X) / 2, ltg6Y);
|
var v35 = CreateValve(35, (t5X + t6X) / 2, ltg6Y);
|
||||||
@@ -250,58 +261,58 @@ namespace PamhagenSysCtrl.Helpers {
|
|||||||
var xv37 = new PipeJoin(t6X - 15, ltg7Y);
|
var xv37 = new PipeJoin(t6X - 15, ltg7Y);
|
||||||
var v36 = CreateValve(36, t6X + 15, tValveY);
|
var v36 = CreateValve(36, t6X + 15, tValveY);
|
||||||
var v37 = CreateValve(37, t6X - 15, tValveY);
|
var v37 = CreateValve(37, t6X - 15, tValveY);
|
||||||
var t6 = CreateTank(6, t6X, tanksY, 35000);
|
Tank6 = CreateTank(6, t6X, tanksY, 35000);
|
||||||
CreatePipe(v34, xv37);
|
CreatePipe(v34, xv37);
|
||||||
CreatePipe(v35, xv36);
|
CreatePipe(v35, xv36);
|
||||||
CreatePipe(xv37, v37);
|
CreatePipe(xv37, v37);
|
||||||
CreatePipe(xv36, v36);
|
CreatePipe(xv36, v36);
|
||||||
CreateInlet(v36, t6);
|
CreateInlet(v36, Tank6);
|
||||||
CreateInlet(v37, t6);
|
CreateInlet(v37, Tank6);
|
||||||
|
|
||||||
var xv38 = new PipeJoin(t7X + 15, ltg6Y);
|
var xv38 = new PipeJoin(t7X + 15, ltg6Y);
|
||||||
var xv39 = new PipeJoin(t7X - 15, ltg7Y);
|
var xv39 = new PipeJoin(t7X - 15, ltg7Y);
|
||||||
var v38 = CreateValve(38, t7X + 15, tValveY);
|
var v38 = CreateValve(38, t7X + 15, tValveY);
|
||||||
var v39 = CreateValve(39, t7X - 15, tValveY);
|
var v39 = CreateValve(39, t7X - 15, tValveY);
|
||||||
var t7 = CreateTank(7, t7X, tanksY, 35000);
|
Tank7 = CreateTank(7, t7X, tanksY, 35000);
|
||||||
CreatePipe(xv37, xv39);
|
CreatePipe(xv37, xv39);
|
||||||
CreatePipe(xv36, xv38);
|
CreatePipe(xv36, xv38);
|
||||||
CreatePipe(xv38, v38);
|
CreatePipe(xv38, v38);
|
||||||
CreatePipe(xv39, v39);
|
CreatePipe(xv39, v39);
|
||||||
CreateInlet(v38, t7);
|
CreateInlet(v38, Tank7);
|
||||||
CreateInlet(v39, t7);
|
CreateInlet(v39, Tank7);
|
||||||
|
|
||||||
var xv40 = new PipeJoin(t8X + 15, ltg6Y);
|
var xv40 = new PipeJoin(t8X + 15, ltg6Y);
|
||||||
var xv41 = new PipeJoin(t8X - 15, ltg7Y);
|
var xv41 = new PipeJoin(t8X - 15, ltg7Y);
|
||||||
var v40 = CreateValve(40, t8X + 15, tValveY);
|
var v40 = CreateValve(40, t8X + 15, tValveY);
|
||||||
var v41 = CreateValve(41, t8X - 15, tValveY);
|
var v41 = CreateValve(41, t8X - 15, tValveY);
|
||||||
var t8 = CreateTank(8, t8X, tanksY, 35000);
|
Tank8 = CreateTank(8, t8X, tanksY, 35000);
|
||||||
CreatePipe(xv38, xv40, label: "Ltg. 6", labelOffsetX: 0);
|
CreatePipe(xv38, xv40, label: "Ltg. 6", labelOffsetX: 0);
|
||||||
CreatePipe(xv39, xv41, label: "Ltg. 7", labelOffsetX: 30);
|
CreatePipe(xv39, xv41, label: "Ltg. 7", labelOffsetX: 30);
|
||||||
CreatePipe(xv40, v40);
|
CreatePipe(xv40, v40);
|
||||||
CreatePipe(xv41, v41);
|
CreatePipe(xv41, v41);
|
||||||
CreateInlet(v40, t8);
|
CreateInlet(v40, Tank8);
|
||||||
CreateInlet(v41, t8);
|
CreateInlet(v41, Tank8);
|
||||||
|
|
||||||
var v42 = CreateValve(42, t9X + 15, tValveY);
|
var v42 = CreateValve(42, t9X + 15, tValveY);
|
||||||
var v43 = CreateValve(43, t9X - 15, tValveY);
|
var v43 = CreateValve(43, t9X - 15, tValveY);
|
||||||
var t9 = CreateTank(9, t9X, tanksY, 35000);
|
Tank9 = CreateTank(9, t9X, tanksY, 35000);
|
||||||
CreatePipe(xv40, v42);
|
CreatePipe(xv40, v42);
|
||||||
CreatePipe(xv41, v43);
|
CreatePipe(xv41, v43);
|
||||||
CreateInlet(v42, t9);
|
CreateInlet(v42, Tank9);
|
||||||
CreateInlet(v43, t9);
|
CreateInlet(v43, Tank9);
|
||||||
|
|
||||||
var xp12 = new PipeJoin((t1X + t2X) / 2, tanksY + 80);
|
var xp12 = new PipeJoin((t1X + t2X) / 2, tanksY + 80);
|
||||||
P12 = new Pump("P1/2", (t1X + t2X) / 2, tanksY + 110, () => App.Plant?.IsP12Active ?? false, () => App.Plant?.P12HasClearance ?? false, (x) => SelectedPaths.Any(p => p.Hops.Any(h => h.Node == x)));
|
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(Tank1, xp12);
|
||||||
CreateOutlet(t2, xp12);
|
CreateOutlet(Tank2, xp12);
|
||||||
CreatePipe(xp12, P12);
|
CreatePipe(xp12, P12);
|
||||||
|
|
||||||
P3 = new Pump("P3", t3X, tanksY + 110, () => App.Plant?.IsP3Active ?? false, () => App.Plant?.P3HasClearance ?? false, (x) => SelectedPaths.Any(p => p.Hops.Any(h => h.Node == x)));
|
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?.IsP4Active ?? false, () => App.Plant?.P4HasClearance ?? 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?.IsP5Active ?? false, () => App.Plant?.P5HasClearance ?? 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(Tank3, P3);
|
||||||
CreateOutlet(t4, P4);
|
CreateOutlet(Tank4, P4);
|
||||||
CreateOutlet(t5, P5);
|
CreateOutlet(Tank5, P5);
|
||||||
|
|
||||||
var v44 = CreateValve(44, (t1X + t2X) / 2, tanksY + 150);
|
var v44 = CreateValve(44, (t1X + t2X) / 2, tanksY + 150);
|
||||||
var v45 = CreateValve(45, t3X, tanksY + 150);
|
var v45 = CreateValve(45, t3X, tanksY + 150);
|
||||||
@@ -328,11 +339,11 @@ namespace PamhagenSysCtrl.Helpers {
|
|||||||
var xt6 = new PipeJoin(t6X, tanksY + 110);
|
var xt6 = new PipeJoin(t6X, tanksY + 110);
|
||||||
var xt7 = new PipeJoin(t7X, tanksY + 110);
|
var xt7 = new PipeJoin(t7X, tanksY + 110);
|
||||||
var xt8 = new PipeJoin(t8X, tanksY + 110);
|
var xt8 = new PipeJoin(t8X, tanksY + 110);
|
||||||
P6 = new Pump("P6", t6X, tanksY + 150, () => App.Plant?.IsP6Active ?? false, () => App.Plant?.P6HasClearance ?? false, (x) => SelectedPaths.Any(p => p.Hops.Any(h => h.Node == x)));
|
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(Tank6, xt6);
|
||||||
CreateOutlet(t7, xt7);
|
CreateOutlet(Tank7, xt7);
|
||||||
CreateOutlet(t8, xt8);
|
CreateOutlet(Tank8, xt8);
|
||||||
CreateOutlet(t9, xt8);
|
CreateOutlet(Tank9, xt8);
|
||||||
CreatePipe(xt8, xt7);
|
CreatePipe(xt8, xt7);
|
||||||
CreatePipe(xt7, xt6);
|
CreatePipe(xt7, xt6);
|
||||||
CreatePipe(xt6, P6);
|
CreatePipe(xt6, P6);
|
||||||
@@ -343,8 +354,8 @@ namespace PamhagenSysCtrl.Helpers {
|
|||||||
var prX = (pr1X + pr2X) / 2;
|
var prX = (pr1X + pr2X) / 2;
|
||||||
var pr1cX = prX - 15;
|
var pr1cX = prX - 15;
|
||||||
var pr2cX = prX + 15;
|
var pr2cX = prX + 15;
|
||||||
var press1 = new Press("Presse 1", pr1X, prY, 20000, () => FillState.Unknown);
|
Press1 = new Press("Presse 1", pr1X, prY, 20000, () => FillState.Unknown);
|
||||||
var press2 = new Press("Presse 2", pr2X, prY, 15000, () => FillState.Unknown);
|
Press2 = new Press("Presse 2", pr2X, prY, 15000, () => FillState.Unknown);
|
||||||
var v50 = CreateValve(50, pr2cX + 30, 580);
|
var v50 = CreateValve(50, pr2cX + 30, 580);
|
||||||
var v51 = CreateValve(51, pr1cX - 30, 580);
|
var v51 = CreateValve(51, pr1cX - 30, 580);
|
||||||
var v52 = CreateValve(52, pr1cX - 30, 610);
|
var v52 = CreateValve(52, pr1cX - 30, 610);
|
||||||
@@ -390,39 +401,57 @@ namespace PamhagenSysCtrl.Helpers {
|
|||||||
var zv2 = new CenterValve("ZV2", pr2cX, prY - 40, () => App.Plant?.Press2HasClearance ?? false);
|
var zv2 = new CenterValve("ZV2", pr2cX, prY - 40, () => App.Plant?.Press2HasClearance ?? false);
|
||||||
CreatePipe(xp6, zv1, true);
|
CreatePipe(xp6, zv1, true);
|
||||||
CreatePipe(xp8, zv2, true);
|
CreatePipe(xp8, zv2, true);
|
||||||
CreateInlet(zv1, press1, true);
|
CreateInlet(zv1, Press1, true);
|
||||||
CreateInlet(zv2, press2, true);
|
CreateInlet(zv2, Press2, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Valve CreateValve(int n, double x, double y) {
|
protected Valve CreateValve(int n, double x, double y) {
|
||||||
return new(n, x, y, () => App.Plant?.IsValveOpen(n) ?? false, (v) => SelectedPaths.Any(p => p.Hops.Any(h => h.Node == v)));
|
return new(n, x, y, () => App.Plant?.IsValveOpen(n) ?? false, (v) => App.Plant?.ManualControlMode ?? false ? App.Plant.WantValveOpen(n) : SelectedPaths.Any(p => p.Hops.Any(h => h.Node == v)));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static Tank CreateTank(int n, double x, double y, int capacity) {
|
protected static Tank CreateTank(int n, double x, double y, int capacity) {
|
||||||
return new($"Tank {n}", x, y, capacity, () => App.Plant?.TankFillLevels[n - 1] ?? FillState.Unknown);
|
return new($"Tank {n}", x, y, capacity, () => App.Plant?.TankFillLevels[n - 1] ?? FillState.Unknown);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void TraverseSubgraph(INode start, HashSet<IEdge>? visited = null, Action<IEdge>? edgeAction = null, Action<Valve>? valveAction = null) {
|
private int PathCost(Path p) {
|
||||||
visited ??= [];
|
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) {
|
if (start is Valve v) {
|
||||||
valveAction?.Invoke(v);
|
valveAction?.Invoke(v);
|
||||||
return;
|
}
|
||||||
} else if (start is ISink || start is Pump) {
|
if (invalid(start)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var edge in start.Inputs) {
|
foreach (var edge in start.Inputs) {
|
||||||
if (visited.Contains(edge)) continue;
|
if (visited.Contains(edge)) continue;
|
||||||
var o = edge.IsTwoWay && edge.Start == start ? edge.End : edge.Start;
|
var o = edge.IsTwoWay && edge.Start == start ? edge.End : edge.Start;
|
||||||
edgeAction?.Invoke(edge);
|
edgeAction?.Invoke(start, reverse || _visited == null, edge);
|
||||||
visited.Add(edge);
|
visited.Add(edge);
|
||||||
TraverseSubgraph(o, visited, edgeAction, valveAction);
|
TraverseSubgraph(o, invalid, visited, edgeAction, valveAction, reverse || _visited == null);
|
||||||
}
|
}
|
||||||
foreach (var edge in start.Outputs) {
|
foreach (var edge in start.Outputs) {
|
||||||
if (visited.Contains(edge)) continue;
|
if (visited.Contains(edge)) continue;
|
||||||
var o = edge.IsTwoWay && edge.End == start ? edge.Start : edge.End;
|
var o = edge.IsTwoWay && edge.End == start ? edge.Start : edge.End;
|
||||||
edgeAction?.Invoke(edge);
|
edgeAction?.Invoke(start, reverse, edge);
|
||||||
visited.Add(edge);
|
visited.Add(edge);
|
||||||
TraverseSubgraph(o, visited, edgeAction, valveAction);
|
TraverseSubgraph(o, invalid, visited, edgeAction, valveAction, reverse);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -453,8 +482,12 @@ namespace PamhagenSysCtrl.Helpers {
|
|||||||
|
|
||||||
private void UpdateValvesAdjacientToPath(Path path, bool locked, bool? wantOpen = null) {
|
private void UpdateValvesAdjacientToPath(Path path, bool locked, bool? wantOpen = null) {
|
||||||
foreach (var (edge, node) in path.Hops) {
|
foreach (var (edge, node) in path.Hops) {
|
||||||
TraverseSubgraph(node, valveAction: (v) => {
|
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.HasValue) {
|
||||||
if (wantOpen.Value) {
|
if (wantOpen.Value) {
|
||||||
App.Plant?.OpenV(v.Nr);
|
App.Plant?.OpenV(v.Nr);
|
||||||
@@ -466,18 +499,41 @@ namespace PamhagenSysCtrl.Helpers {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ColorPipesAdjacientToPath(Path path, Brush? color1, bool flowArrows, Brush? color2) {
|
public void ColorPipesAdjacientToPath(Path path, Brush? color1, MotorState flowArrows, Brush? color2) {
|
||||||
var color = color1;
|
var color = color1;
|
||||||
var flowPathOffset = 0.0;
|
var flowPathOffset = 0.0;
|
||||||
HashSet<IEdge> visited = [];
|
HashSet<IEdge> visited = [];
|
||||||
foreach (var (edge, node) in path.Hops) {
|
foreach (var (edge, node) in path.Hops) {
|
||||||
edge.Highlight = color1;
|
edge.Highlight = color1;
|
||||||
edge.Flow = flowArrows ? (edge.End == node, flowPathOffset) : null;
|
if (flowArrows > MotorState.Halt) {
|
||||||
if (edge.Flow != null) flowPathOffset += edge.FlowLength;
|
var dir = edge.End == node;
|
||||||
|
if (flowArrows == MotorState.Backward) dir = !dir;
|
||||||
|
edge.Flow = (dir, flowPathOffset);
|
||||||
|
flowPathOffset += edge.FlowLength;
|
||||||
|
}
|
||||||
visited.Add(edge);
|
visited.Add(edge);
|
||||||
if (node is Pump) color = color2;
|
if (node is Pump) color = color2;
|
||||||
TraverseSubgraph(node, visited, edgeAction: (e) => e.Highlight = color);
|
TraverseSubgraph(node, (n) => n is Valve || n is ISink || n is Pump, visited, edgeAction: (s, r, e) => e.Highlight = color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ColorPipesByValves(INode start, Brush? color1, MotorState flowArrows, Brush? color2) {
|
||||||
|
var flowPathOffset = 0.0;
|
||||||
|
TraverseSubgraph(start, (n) => n is ISink || n is Outlet || !((n as Valve)?.IsOpen ?? (n as CenterValve)?.IsOpen ?? true), null,
|
||||||
|
edgeAction: (s, r, e) => {
|
||||||
|
if (((e.Start as Valve)?.IsOpen ?? true) && ((e.End as Valve)?.IsOpen ?? true)) {
|
||||||
|
e.Highlight = color1;
|
||||||
|
if (flowArrows == MotorState.Forward || flowArrows == MotorState.Backward) {
|
||||||
|
var dir = e.Start == s;
|
||||||
|
if (r) dir = !dir;
|
||||||
|
if (flowArrows == MotorState.Backward) dir = !dir;
|
||||||
|
e.Flow = (dir, flowPathOffset);
|
||||||
|
flowPathOffset += e.FlowLength;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
e.Highlight = color2;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -9,6 +9,7 @@ namespace PamhagenSysCtrl.Helpers {
|
|||||||
protected bool IsRunning = true;
|
protected bool IsRunning = true;
|
||||||
protected Thread? BackgroundThread;
|
protected Thread? BackgroundThread;
|
||||||
|
|
||||||
|
public bool ManualControlMode { get; set; }
|
||||||
public bool OverridePathClearances { get; set; }
|
public bool OverridePathClearances { get; set; }
|
||||||
public bool OverrideDryRunClearances { get; set; }
|
public bool OverrideDryRunClearances { get; set; }
|
||||||
|
|
||||||
@@ -29,7 +30,7 @@ namespace PamhagenSysCtrl.Helpers {
|
|||||||
public bool AreValvesClosed(params int[] ns) => ns.All(IsValveClosed) && ns.All(WantValveClosed);
|
public bool AreValvesClosed(params int[] ns) => ns.All(IsValveClosed) && ns.All(WantValveClosed);
|
||||||
|
|
||||||
public int TroughSelector => Sensors.TroughSelector;
|
public int TroughSelector => Sensors.TroughSelector;
|
||||||
public bool IsMWSelected => Sensors.TroughSelector == 1;
|
public bool IsMW1Selected => Sensors.TroughSelector == 1;
|
||||||
public bool IsMW2Selected => Sensors.TroughSelector == 2;
|
public bool IsMW2Selected => Sensors.TroughSelector == 2;
|
||||||
public FillState FillLevelMW1 => Sensors.FillingLevelMW1;
|
public FillState FillLevelMW1 => Sensors.FillingLevelMW1;
|
||||||
public FillState FillLevelMW2 => Sensors.FillingLevelMW2;
|
public FillState FillLevelMW2 => Sensors.FillingLevelMW2;
|
||||||
@@ -53,6 +54,7 @@ namespace PamhagenSysCtrl.Helpers {
|
|||||||
public bool WantMW2Selected => !Actuators.GetV(58);
|
public bool WantMW2Selected => !Actuators.GetV(58);
|
||||||
|
|
||||||
public bool IsTroughAugerActive => Actuators.TroughAuger;
|
public bool IsTroughAugerActive => Actuators.TroughAuger;
|
||||||
|
public bool TroughAugerHasClearance => IsReblerActive && !(IsMW1Selected && FillLevelMW1 == FillState.Full) && !(IsMW2Selected && FillLevelMW2 == FillState.Full);
|
||||||
public bool IsReblerActive => Actuators.Rebler;
|
public bool IsReblerActive => Actuators.Rebler;
|
||||||
public bool IsStirrerMW1Active => Actuators.StirrerMW1;
|
public bool IsStirrerMW1Active => Actuators.StirrerMW1;
|
||||||
public bool IsStirrerMW2Active => Actuators.StirrerMW2;
|
public bool IsStirrerMW2Active => Actuators.StirrerMW2;
|
||||||
@@ -81,14 +83,32 @@ namespace PamhagenSysCtrl.Helpers {
|
|||||||
|
|
||||||
protected static void OnUpdate(object? sender, PlantEventArgs evt) {
|
protected static void OnUpdate(object? sender, PlantEventArgs evt) {
|
||||||
if (sender is not PamhagenPlant p) return;
|
if (sender is not PamhagenPlant p) return;
|
||||||
if (p.IsPresseQuerSchneckeActive && !p.IsAuger2Active) p.StartAuger2();
|
|
||||||
if (p.IsReblerActive && !p.IsAuger1Active) p.StartAuger1();
|
if (!p.ManualControlMode) {
|
||||||
if (p.IsAuger1Active && !p.IsAuger2Active) p.StartAuger2();
|
if (p.IsPresseQuerSchneckeActive && !p.IsAuger2Active) p.StartAuger2();
|
||||||
if (p.IsAuger2Active && !p.IsAuger3Active) p.StartAuger3();
|
if (p.IsReblerActive && !p.IsAuger1Active) p.StartAuger1();
|
||||||
if (p.IsTroughAugerActive && (!p.IsReblerActive || (p.IsMWSelected && p.FillLevelMW1 == FillState.Full) || (p.IsMW2Selected && p.FillLevelMW2 == FillState.Full)))
|
if (p.IsAuger1Active && !p.IsAuger2Active) p.StartAuger2();
|
||||||
p.StopTroughAuger();
|
if (p.IsAuger2Active && !p.IsAuger3Active) p.StartAuger3();
|
||||||
|
if (p.IsTroughAugerActive && !p.TroughAugerHasClearance)
|
||||||
|
p.StopTroughAuger();
|
||||||
|
}
|
||||||
|
|
||||||
if (p.IsMP1Active && !p.MP1HasClearance) p.StopMP1();
|
if (p.IsMP1Active && !p.MP1HasClearance) p.StopMP1();
|
||||||
if (p.IsMP2Active && !p.MP2HasClearance) p.StopMP2();
|
if (p.IsMP2Active && !p.MP2HasClearance) p.StopMP2();
|
||||||
|
|
||||||
|
if (!p.ManualControlMode) {
|
||||||
|
if (p.MP1 == MotorState.Forward && p.FillLevelMW1 >= FillState.Half && !p.IsStirrerMW1Active) {
|
||||||
|
p.StartStirrerMW1();
|
||||||
|
} else if (p.IsStirrerMW1Active && (!p.IsMP1Active || p.FillLevelMW1 < FillState.Half)) {
|
||||||
|
p.StopStirrerMW1();
|
||||||
|
}
|
||||||
|
if (p.MP2 == MotorState.Forward && p.FillLevelMW2 >= FillState.Half && !p.IsStirrerMW2Active) {
|
||||||
|
p.StartStirrerMW2();
|
||||||
|
} else if (p.IsStirrerMW2Active && (!p.IsMP2Active || p.FillLevelMW2 < FillState.Half)) {
|
||||||
|
p.StopStirrerMW2();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (p.IsP12Active && !p.P12HasClearance) p.StopP12();
|
if (p.IsP12Active && !p.P12HasClearance) p.StopP12();
|
||||||
if (p.IsP3Active && !p.P3HasClearance) p.StopP3();
|
if (p.IsP3Active && !p.P3HasClearance) p.StopP3();
|
||||||
if (p.IsP4Active && !p.P4HasClearance) p.StopP4();
|
if (p.IsP4Active && !p.P4HasClearance) p.StopP4();
|
||||||
@@ -382,18 +402,16 @@ namespace PamhagenSysCtrl.Helpers {
|
|||||||
|
|
||||||
public void SelectMW1() {
|
public void SelectMW1() {
|
||||||
Actuators.SetV(58, true);
|
Actuators.SetV(58, true);
|
||||||
//if (IsReblerActive) Actuators.StirrerMW1 = true;
|
|
||||||
ActuatorsChanged = true;
|
ActuatorsChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SelectMW2() {
|
public void SelectMW2() {
|
||||||
Actuators.SetV(58, false);
|
Actuators.SetV(58, false);
|
||||||
//if (IsReblerActive) Actuators.StirrerMW2 = true;
|
|
||||||
ActuatorsChanged = true;
|
ActuatorsChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void StartTroughAuger() {
|
public void StartTroughAuger() {
|
||||||
if (!IsReblerActive || (IsMWSelected && FillLevelMW1 == FillState.Full) || (IsMW2Selected && FillLevelMW2 == FillState.Full))
|
if (!ManualControlMode && !TroughAugerHasClearance)
|
||||||
throw new NoClearanceException("Schnecke Auffangwanne hat keine Freigabe");
|
throw new NoClearanceException("Schnecke Auffangwanne hat keine Freigabe");
|
||||||
Actuators.TroughAuger = true;
|
Actuators.TroughAuger = true;
|
||||||
ActuatorsChanged = true;
|
ActuatorsChanged = true;
|
||||||
@@ -406,12 +424,12 @@ namespace PamhagenSysCtrl.Helpers {
|
|||||||
|
|
||||||
public void StartRebler() {
|
public void StartRebler() {
|
||||||
Actuators.Rebler = true;
|
Actuators.Rebler = true;
|
||||||
StartAuger1();
|
if (!ManualControlMode) StartAuger1();
|
||||||
ActuatorsChanged = true;
|
ActuatorsChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void StopRebler() {
|
public void StopRebler() {
|
||||||
StopTroughAuger();
|
if (!ManualControlMode) StopTroughAuger();
|
||||||
Actuators.Rebler = false;
|
Actuators.Rebler = false;
|
||||||
ActuatorsChanged = true;
|
ActuatorsChanged = true;
|
||||||
}
|
}
|
||||||
@@ -438,25 +456,25 @@ namespace PamhagenSysCtrl.Helpers {
|
|||||||
|
|
||||||
public void StartAuger1() {
|
public void StartAuger1() {
|
||||||
Actuators.Auger1 = true;
|
Actuators.Auger1 = true;
|
||||||
StartAuger2();
|
if (!ManualControlMode) StartAuger2();
|
||||||
ActuatorsChanged = true;
|
ActuatorsChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void StopAuger1() {
|
public void StopAuger1() {
|
||||||
if (IsReblerActive) throw new NoClearanceException("Rebler aktiv");
|
if (!ManualControlMode && IsReblerActive) throw new NoClearanceException("Rebler aktiv");
|
||||||
Actuators.Auger1 = false;
|
Actuators.Auger1 = false;
|
||||||
ActuatorsChanged = true;
|
ActuatorsChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void StartAuger2() {
|
public void StartAuger2() {
|
||||||
Actuators.Auger2 = true;
|
Actuators.Auger2 = true;
|
||||||
StartAuger3();
|
if (!ManualControlMode) StartAuger3();
|
||||||
ActuatorsChanged = true;
|
ActuatorsChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void StopAuger2() {
|
public void StopAuger2() {
|
||||||
if (IsPresseQuerSchneckeActive) throw new NoClearanceException("Presse-Querschnecke aktiv");
|
if (!ManualControlMode && IsPresseQuerSchneckeActive) throw new NoClearanceException("Presse-Querschnecke aktiv");
|
||||||
if (IsAuger1Active) throw new NoClearanceException("Förderschnecke 1 aktiv");
|
if (!ManualControlMode && IsAuger1Active) throw new NoClearanceException("Förderschnecke 1 aktiv");
|
||||||
Actuators.Auger2 = false;
|
Actuators.Auger2 = false;
|
||||||
ActuatorsChanged = true;
|
ActuatorsChanged = true;
|
||||||
}
|
}
|
||||||
@@ -467,7 +485,7 @@ namespace PamhagenSysCtrl.Helpers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void StopAuger3() {
|
public void StopAuger3() {
|
||||||
if (IsAuger2Active) throw new NoClearanceException("Förderschnecke 2 aktiv");
|
if (!ManualControlMode && IsAuger2Active) throw new NoClearanceException("Förderschnecke 2 aktiv");
|
||||||
Actuators.Auger3 = false;
|
Actuators.Auger3 = false;
|
||||||
ActuatorsChanged = true;
|
ActuatorsChanged = true;
|
||||||
}
|
}
|
||||||
@@ -484,35 +502,43 @@ namespace PamhagenSysCtrl.Helpers {
|
|||||||
|
|
||||||
public void StartMP1Forward() {
|
public void StartMP1Forward() {
|
||||||
if (!MP1HasClearance) throw new NoClearanceException("MP1 hat keine Freigabe");
|
if (!MP1HasClearance) throw new NoClearanceException("MP1 hat keine Freigabe");
|
||||||
|
if (Actuators.MP1 == MotorState.Backward) throw new NoClearanceException("MP1 läuft bereits (zurück)");
|
||||||
Actuators.MP1 = MotorState.Forward;
|
Actuators.MP1 = MotorState.Forward;
|
||||||
|
if (FillLevelMW1 >= FillState.Half) StartStirrerMW1();
|
||||||
ActuatorsChanged = true;
|
ActuatorsChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void StartMP1Backward() {
|
public void StartMP1Backward() {
|
||||||
if (!MP1HasClearance) throw new NoClearanceException("MP1 hat keine Freigabe");
|
if (!MP1HasClearance) throw new NoClearanceException("MP1 hat keine Freigabe");
|
||||||
|
if (Actuators.MP1 == MotorState.Forward) throw new NoClearanceException("MP1 läuft bereits (vor)");
|
||||||
Actuators.MP1 = MotorState.Backward;
|
Actuators.MP1 = MotorState.Backward;
|
||||||
ActuatorsChanged = true;
|
ActuatorsChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void StopMP1() {
|
public void StopMP1() {
|
||||||
Actuators.MP1 = MotorState.Halt;
|
Actuators.MP1 = MotorState.Halt;
|
||||||
|
if (!ManualControlMode) StopStirrerMW1();
|
||||||
ActuatorsChanged = true;
|
ActuatorsChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void StartMP2Forward() {
|
public void StartMP2Forward() {
|
||||||
if (!MP2HasClearance) throw new NoClearanceException("MP2 hat keine Freigabe");
|
if (!MP2HasClearance) throw new NoClearanceException("MP2 hat keine Freigabe");
|
||||||
|
if (Actuators.MP2 == MotorState.Backward) throw new NoClearanceException("MP2 läuft bereits (zurück)");
|
||||||
Actuators.MP2 = MotorState.Forward;
|
Actuators.MP2 = MotorState.Forward;
|
||||||
|
if (FillLevelMW2 >= FillState.Half) StartStirrerMW2();
|
||||||
ActuatorsChanged = true;
|
ActuatorsChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void StartMP2Backward() {
|
public void StartMP2Backward() {
|
||||||
if (!MP2HasClearance) throw new NoClearanceException("MP2 hat keine Freigabe");
|
if (!MP2HasClearance) throw new NoClearanceException("MP2 hat keine Freigabe");
|
||||||
|
if (Actuators.MP2 == MotorState.Forward) throw new NoClearanceException("MP2 läuft bereits (vor)");
|
||||||
Actuators.MP2 = MotorState.Backward;
|
Actuators.MP2 = MotorState.Backward;
|
||||||
ActuatorsChanged = true;
|
ActuatorsChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void StopMP2() {
|
public void StopMP2() {
|
||||||
Actuators.MP2 = MotorState.Halt;
|
Actuators.MP2 = MotorState.Halt;
|
||||||
|
if (!ManualControlMode) StopStirrerMW1();
|
||||||
ActuatorsChanged = true;
|
ActuatorsChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -54,46 +54,52 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
|||||||
return p;
|
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;
|
if (points.Count() < 2) return null;
|
||||||
var start = points.First();
|
var start = points.First();
|
||||||
var path = new Path(start, []);
|
List<Path> paths = [new(start, [])];
|
||||||
foreach (var end in points.Skip(1)) {
|
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;
|
return null;
|
||||||
} else if (GetPath(start, end, valid, visited: [.. path.Hops.Select(h => h.Node)]) is not Path p) {
|
|
||||||
return null;
|
var newPaths = new List<Path>();
|
||||||
} else {
|
foreach (var path in paths) {
|
||||||
path.Hops = [.. path.Hops, .. p.Hops];
|
foreach (var subPath in GetPaths(start, end, visited: [.. path.Hops.Select(h => h.Node)], valid)) {
|
||||||
start = end;
|
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");
|
if (!Nodes.Contains(start) || !Nodes.Contains(end)) throw new ArgumentException("Start/end node not contained in graph");
|
||||||
valid ??= a => true;
|
valid ??= a => true;
|
||||||
visited = [.. visited ?? [], start];
|
visited = [.. visited ?? [], start];
|
||||||
List<(IEdge, INode)> hops = [];
|
List<(IEdge, INode)> hops = [];
|
||||||
Path? path = null;
|
|
||||||
foreach (var o in start.Outputs) {
|
foreach (var o in start.Outputs) {
|
||||||
var e = o.IsTwoWay && o.End == start ? o.Start : o.End;
|
var e = o.IsTwoWay && o.End == start ? o.Start : o.End;
|
||||||
if (e == end) {
|
if (e == end) {
|
||||||
return new(start, [(o, e)]);
|
yield return new(start, [(o, e)]);
|
||||||
|
continue;
|
||||||
} else if (!valid(e) || visited.Contains(e)) {
|
} else if (!valid(e) || visited.Contains(e)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var p = GetPath(e, end, valid, visited);
|
foreach (var p in GetPaths(e, end, visited, valid)) {
|
||||||
if (p != null) {
|
yield return new(start, [(o, e), .. p.Hops]);
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return path != null ? new(start, path.Value.Hops) : null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Draw(Canvas canvas) {
|
public void Draw(Canvas canvas) {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
|||||||
INode Start,
|
INode Start,
|
||||||
IEnumerable<(IEdge Edge, INode Node)> Hops)
|
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));
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -16,11 +16,12 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
|||||||
public ISet<IEdge> Outputs { get; init; }
|
public ISet<IEdge> Outputs { get; init; }
|
||||||
|
|
||||||
public Brush? Highlight { get; set; }
|
public Brush? Highlight { get; set; }
|
||||||
public bool IsActive => CallbackActive();
|
public bool IsActive => State == MotorState.Forward || State == MotorState.Backward;
|
||||||
|
public MotorState State => CallbackState();
|
||||||
public bool HasClearance => CallbackClearance();
|
public bool HasClearance => CallbackClearance();
|
||||||
public bool IsSelected => CallbackSelected(this);
|
public bool IsSelected => CallbackSelected(this);
|
||||||
|
|
||||||
protected Func<bool> CallbackActive;
|
protected Func<MotorState> CallbackState;
|
||||||
protected Func<bool> CallbackClearance;
|
protected Func<bool> CallbackClearance;
|
||||||
protected Func<Pump, bool> CallbackSelected;
|
protected Func<Pump, bool> CallbackSelected;
|
||||||
|
|
||||||
@@ -28,11 +29,11 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
|||||||
private Shape? _triangle;
|
private Shape? _triangle;
|
||||||
private TextBlock? _text;
|
private TextBlock? _text;
|
||||||
|
|
||||||
public Pump(string label, double x, double y, Func<bool> cbActive, Func<bool> cbClearance, Func<Pump, bool> cbSelected) {
|
public Pump(string label, double x, double y, Func<MotorState> cbState, Func<bool> cbClearance, Func<Pump, bool> cbSelected) {
|
||||||
CenterX = x;
|
CenterX = x;
|
||||||
CenterY = y;
|
CenterY = y;
|
||||||
Label = label;
|
Label = label;
|
||||||
CallbackActive = cbActive;
|
CallbackState = cbState;
|
||||||
CallbackClearance = cbClearance;
|
CallbackClearance = cbClearance;
|
||||||
CallbackSelected = cbSelected;
|
CallbackSelected = cbSelected;
|
||||||
Inputs = new HashSet<IEdge>();
|
Inputs = new HashSet<IEdge>();
|
||||||
@@ -75,13 +76,22 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void Update(bool isHovering, bool isPresed) {
|
public void Update(bool isHovering, bool isPresed) {
|
||||||
_circle?.Fill = Highlight ?? (
|
if (App.Plant?.ManualControlMode ?? false) {
|
||||||
IsActive && isHovering ? PamhagenBrushes.Red :
|
_circle?.Fill = Highlight ?? (
|
||||||
IsActive ? PamhagenBrushes.Green :
|
IsActive && isHovering ? PamhagenBrushes.Red :
|
||||||
HasClearance && IsSelected && isHovering ? PamhagenBrushes.Green :
|
IsActive ? PamhagenBrushes.Green :
|
||||||
HasClearance && IsSelected ? PamhagenBrushes.Yellow :
|
HasClearance && isHovering ? PamhagenBrushes.Green :
|
||||||
IsSelected ? PamhagenBrushes.Red :
|
HasClearance ? PamhagenBrushes.Yellow :
|
||||||
isHovering ? Brushes.LightGray : Brushes.WhiteSmoke);
|
PamhagenBrushes.Red);
|
||||||
|
} else {
|
||||||
|
_circle?.Fill = Highlight ?? (
|
||||||
|
IsActive && isHovering ? PamhagenBrushes.Red :
|
||||||
|
IsActive ? PamhagenBrushes.Green :
|
||||||
|
HasClearance && IsSelected && isHovering ? PamhagenBrushes.Green :
|
||||||
|
HasClearance && IsSelected ? PamhagenBrushes.Yellow :
|
||||||
|
IsSelected ? PamhagenBrushes.Red :
|
||||||
|
isHovering ? Brushes.LightGray : Brushes.WhiteSmoke);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -14,7 +14,9 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
|||||||
public string Label => $"V{Nr}";
|
public string Label => $"V{Nr}";
|
||||||
public Brush? Highlight { get; set; }
|
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 IsOpen => CallbackIsOpen();
|
||||||
public bool WantOpen => CallbackWantOpen(this);
|
public bool WantOpen => CallbackWantOpen(this);
|
||||||
public ISet<IEdge> Inputs { get; init; }
|
public ISet<IEdge> Inputs { get; init; }
|
||||||
@@ -66,12 +68,23 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void Update(bool isHovering, bool isPressed) {
|
public void Update(bool isHovering, bool isPressed) {
|
||||||
_circle?.Fill =
|
if (App.Plant?.ManualControlMode ?? false) {
|
||||||
IsLocked && !WantOpen && !IsOpen ? PamhagenBrushes.DimOrange :
|
_circle?.Fill =
|
||||||
IsLocked && !WantOpen && IsOpen ? PamhagenBrushes.Red :
|
!WantOpen && !IsOpen && !isHovering ? PamhagenBrushes.Red :
|
||||||
IsLocked && WantOpen && !IsOpen ? PamhagenBrushes.Yellow :
|
!WantOpen && !IsOpen ? PamhagenBrushes.Green :
|
||||||
IsLocked && WantOpen && IsOpen ? PamhagenBrushes.Green :
|
!WantOpen && IsOpen ? PamhagenBrushes.DimRed :
|
||||||
Highlight ?? (isHovering ? Brushes.LightGray : Brushes.DarkGray);
|
WantOpen && !IsOpen ? PamhagenBrushes.DimGreen :
|
||||||
|
WantOpen && IsOpen && !isHovering ? PamhagenBrushes.Green :
|
||||||
|
WantOpen && IsOpen ? PamhagenBrushes.Red :
|
||||||
|
Highlight ?? (isHovering ? Brushes.LightGray : Brushes.DarkGray);
|
||||||
|
} else {
|
||||||
|
_circle?.Fill =
|
||||||
|
IsLocked && !WantOpen && !IsOpen ? PamhagenBrushes.DimOrange :
|
||||||
|
IsLocked && !WantOpen && IsOpen ? PamhagenBrushes.Red :
|
||||||
|
IsLocked && WantOpen && !IsOpen ? PamhagenBrushes.Yellow :
|
||||||
|
IsLocked && WantOpen && IsOpen ? PamhagenBrushes.Green :
|
||||||
|
Highlight ?? (isHovering ? Brushes.LightGray : Brushes.DarkGray);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<TargetFramework>net10.0-windows</TargetFramework>
|
<TargetFramework>net10.0-windows</TargetFramework>
|
||||||
<Version>0.0.1</Version>
|
<Version>0.0.3</Version>
|
||||||
<Product>Anlagensteuerung Pamhagen</Product>
|
<Product>Anlagensteuerung Pamhagen</Product>
|
||||||
<AssemblyTitle>Anlagensteuerung Pamhagen</AssemblyTitle>
|
<AssemblyTitle>Anlagensteuerung Pamhagen</AssemblyTitle>
|
||||||
<AssemblyName>PamhagenSysCtrl</AssemblyName>
|
<AssemblyName>PamhagenSysCtrl</AssemblyName>
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:local="clr-namespace:PamhagenSysCtrl"
|
xmlns:local="clr-namespace:PamhagenSysCtrl"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
|
Closed="OnClosed"
|
||||||
Title="Handbetrieb - Anlagensteuerung Pamhagen" Height="550" Width="860">
|
Title="Handbetrieb - Anlagensteuerung Pamhagen" Height="550" Width="860">
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid x:Name="ValvePanel" Margin="5,5,5,5">
|
<Grid x:Name="ValvePanel" Margin="5,5,5,5">
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using PamhagenSysCtrl.Helpers;
|
using PamhagenSysCtrl.Helpers;
|
||||||
|
using PamhagenSysCtrl.Windows;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
@@ -47,6 +48,14 @@ namespace PamhagenSysCtrl {
|
|||||||
App.Plant?.Update += OnUpdate;
|
App.Plant?.Update += OnUpdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnClosed(object sender, EventArgs evt) {
|
||||||
|
foreach (var win in Application.Current.Windows) {
|
||||||
|
if (win is PlantSchemeWindow w) {
|
||||||
|
w.Menu_Settings_ManualControl.IsChecked = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void OnUpdate(object? sender, PlantEventArgs evt) {
|
public void OnUpdate(object? sender, PlantEventArgs evt) {
|
||||||
if (sender is not PamhagenPlant plant) return;
|
if (sender is not PamhagenPlant plant) return;
|
||||||
|
|
||||||
@@ -132,7 +141,7 @@ namespace PamhagenSysCtrl {
|
|||||||
Gradation °Oe: {plant.GradationOe:N2}
|
Gradation °Oe: {plant.GradationOe:N2}
|
||||||
Presse Querschnecke: {plant.PresseQuerSchnecke}
|
Presse Querschnecke: {plant.PresseQuerSchnecke}
|
||||||
Füllstände:
|
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})
|
Maischewanne 2: {plant.FillLevelMW2} (ausgewählt: {plant.WantMW2Selected}, Status: {plant.IsMW2Selected})
|
||||||
Presse 1: {plant.Press1HasClearance}
|
Presse 1: {plant.Press1HasClearance}
|
||||||
Presse 2: {plant.Press2HasClearance}
|
Presse 2: {plant.Press2HasClearance}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:local="clr-namespace:PamhagenSysCtrl.Windows"
|
xmlns:local="clr-namespace:PamhagenSysCtrl.Windows"
|
||||||
|
Closed="OnClosed"
|
||||||
Title="Anlagensteuerung Pamhagen" Height="950" Width="1600" MinWidth="1500" MinHeight="950">
|
Title="Anlagensteuerung Pamhagen" Height="950" Width="1600" MinWidth="1500" MinHeight="950">
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
@@ -14,20 +15,23 @@
|
|||||||
|
|
||||||
<Menu Grid.Row="0" BorderThickness="0,0,0,1" BorderBrush="LightGray" Background="White">
|
<Menu Grid.Row="0" BorderThickness="0,0,0,1" BorderBrush="LightGray" Background="White">
|
||||||
<MenuItem Header="Einstellungen">
|
<MenuItem Header="Einstellungen">
|
||||||
<MenuItem x:Name="Menu_Settings_ManualControl" Header="Handbetrieb"
|
<MenuItem x:Name="Menu_Settings_ManualControl" Header="Handbetrieb" IsCheckable="True"
|
||||||
Click="Menu_Settings_ManualControl_Click" IsCheckable="True">
|
Checked="Menu_Settings_ManualControl_Changed"
|
||||||
|
Unchecked="Menu_Settings_ManualControl_Changed">
|
||||||
<MenuItem.Icon>
|
<MenuItem.Icon>
|
||||||
<TextBlock FontFamily="Segoe MDL2 Assets" FontSize="16" Text=""/>
|
<TextBlock FontFamily="Segoe MDL2 Assets" FontSize="16" Text=""/>
|
||||||
</MenuItem.Icon>
|
</MenuItem.Icon>
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
<MenuItem x:Name="Menu_Settings_OverridePathClearances" Header="Pfad-Freigaben überbrücken"
|
<MenuItem x:Name="Menu_Settings_OverridePathClearances" Header="Pfad-Freigaben überbrücken" IsCheckable="True"
|
||||||
Click="Menu_Settings_OverridePathClearances_Click" IsCheckable="True">
|
Checked="Menu_Settings_OverridePathClearances_Changed"
|
||||||
|
Unchecked="Menu_Settings_OverridePathClearances_Changed">
|
||||||
<MenuItem.Icon>
|
<MenuItem.Icon>
|
||||||
<TextBlock FontFamily="Segoe MDL2 Assets" FontSize="16" Text=""/>
|
<TextBlock FontFamily="Segoe MDL2 Assets" FontSize="16" Text=""/>
|
||||||
</MenuItem.Icon>
|
</MenuItem.Icon>
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
<MenuItem x:Name="Menu_Settings_OverrideDryRunClearances" Header="Trockenlauf-Freigaben überbrücken"
|
<MenuItem x:Name="Menu_Settings_OverrideDryRunClearances" Header="Trockenlauf-Freigaben überbrücken" IsCheckable="True"
|
||||||
Click="Menu_Settings_OverrideDryRunClearances_Click" IsCheckable="True"/>
|
Checked="Menu_Settings_OverrideDryRunClearances_Changed"
|
||||||
|
Unchecked="Menu_Settings_OverrideDryRunClearances_Changed"/>
|
||||||
<Separator/>
|
<Separator/>
|
||||||
<MenuItem x:Name="Menu_Settings_Config" Header="Konfigurationsdatei öffnen..." Click="Menu_Settings_Config_Click">
|
<MenuItem x:Name="Menu_Settings_Config" Header="Konfigurationsdatei öffnen..." Click="Menu_Settings_Config_Click">
|
||||||
<MenuItem.Icon>
|
<MenuItem.Icon>
|
||||||
@@ -53,11 +57,170 @@
|
|||||||
<Canvas x:Name="SchemeCanvas" Width="1550" Height="900" VerticalAlignment="Center" HorizontalAlignment="Center" SnapsToDevicePixels="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">
|
MouseMove="SchemeCanvas_MouseMove" MouseLeftButtonDown="SchemeCanvas_MouseLeftButtonDown" MouseLeftButtonUp="SchemeCanvas_MouseLeftButtonUp" Grid.ColumnSpan="2" Margin="25,0,0,0">
|
||||||
</Canvas>
|
</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>
|
||||||
|
<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 ⮞ 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 ⮞ 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 ⮞ 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 ⮞ 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 ⮞ 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 ⮞ 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 ⮞ 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 ⮞ 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 ⮞ 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 ⮞ 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 ⮞ 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 ⮞ 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 ⮞ 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 ⮞ 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>
|
||||||
|
<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 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 FontSize="18">Schnecke Stop</Run></TextBlock>
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
|
||||||
|
<Button x:Name="FastSelectButton_MW2" Grid.Column="0" Grid.Row="2"
|
||||||
|
Content="MW2 ⮜" 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="⮞ 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 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 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 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 FontSize="24">MP1</Run><LineBreak/><Run x:Name="MP1_Target">Vor</Run></TextBlock>
|
||||||
|
</Button>
|
||||||
|
</Grid>
|
||||||
|
</Border>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<StatusBar Grid.Row="2" BorderThickness="0,1,0,0" BorderBrush="Gray">
|
<StatusBar Grid.Row="2" BorderThickness="0,1,0,0" BorderBrush="Gray">
|
||||||
|
|
||||||
</StatusBar>
|
</StatusBar>
|
||||||
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</Window>
|
</Window>
|
||||||
@@ -2,7 +2,9 @@ using PamhagenSysCtrl.Helpers;
|
|||||||
using PamhagenSysCtrl.Helpers.Pipeline;
|
using PamhagenSysCtrl.Helpers.Pipeline;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Media;
|
||||||
|
|
||||||
namespace PamhagenSysCtrl.Windows {
|
namespace PamhagenSysCtrl.Windows {
|
||||||
public partial class PlantSchemeWindow : Window {
|
public partial class PlantSchemeWindow : Window {
|
||||||
@@ -14,14 +16,59 @@ namespace PamhagenSysCtrl.Windows {
|
|||||||
private ISet<INode>? _lastSelected;
|
private ISet<INode>? _lastSelected;
|
||||||
private ISet<INode>? _hover;
|
private ISet<INode>? _hover;
|
||||||
|
|
||||||
public PlantSchemeWindow() {
|
public Path? HoveringPath {
|
||||||
InitializeComponent();
|
get {
|
||||||
App.Plant?.Update += OnUpdate;
|
foreach (var b in FastSelectPaths.Where(b => b.Key.IsMouseOver)) {
|
||||||
Graph = new();
|
if (Graph.SelectedPaths.Any(p => p.Start == b.Value.Source && p.Hops.Last().Node == b.Value.Sink))
|
||||||
Graph.Draw(SchemeCanvas);
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Menu_Settings_ManualControl_Click(object sender, RoutedEventArgs evt) {
|
protected Dictionary<Button, (ISource Source, Pump Pump, ISink Sink)> FastSelectPaths;
|
||||||
|
|
||||||
|
public PlantSchemeWindow() {
|
||||||
|
InitializeComponent();
|
||||||
|
Graph = new();
|
||||||
|
Graph.Draw(SchemeCanvas);
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnClosed(object sender, EventArgs evt) {
|
||||||
|
Application.Current.Shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Menu_Settings_ManualControl_Changed(object sender, RoutedEventArgs evt) {
|
||||||
|
App.Plant?.ManualControlMode = Menu_Settings_ManualControl.IsChecked;
|
||||||
if (Menu_Settings_ManualControl.IsChecked) {
|
if (Menu_Settings_ManualControl.IsChecked) {
|
||||||
foreach (var win in Application.Current.Windows) {
|
foreach (var win in Application.Current.Windows) {
|
||||||
if (win is ManualControlWindow w) {
|
if (win is ManualControlWindow w) {
|
||||||
@@ -37,15 +84,18 @@ namespace PamhagenSysCtrl.Windows {
|
|||||||
w.Close();
|
w.Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Menu_Settings_OverridePathClearances.IsChecked = false;
|
||||||
|
Menu_Settings_OverrideDryRunClearances.IsChecked = false;
|
||||||
}
|
}
|
||||||
|
OnUpdate(null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Menu_Settings_OverridePathClearances_Click(object sender, RoutedEventArgs evt) {
|
private void Menu_Settings_OverridePathClearances_Changed(object sender, RoutedEventArgs evt) {
|
||||||
App.Plant?.OverridePathClearances = Menu_Settings_OverridePathClearances.IsChecked;
|
App.Plant?.OverridePathClearances = Menu_Settings_OverridePathClearances.IsChecked;
|
||||||
OnUpdate(null, null);
|
OnUpdate(null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Menu_Settings_OverrideDryRunClearances_Click(object sender, RoutedEventArgs evt) {
|
private void Menu_Settings_OverrideDryRunClearances_Changed(object sender, RoutedEventArgs evt) {
|
||||||
App.Plant?.OverrideDryRunClearances = Menu_Settings_OverrideDryRunClearances.IsChecked;
|
App.Plant?.OverrideDryRunClearances = Menu_Settings_OverrideDryRunClearances.IsChecked;
|
||||||
OnUpdate(null, null);
|
OnUpdate(null, null);
|
||||||
}
|
}
|
||||||
@@ -67,13 +117,98 @@ namespace PamhagenSysCtrl.Windows {
|
|||||||
} catch { }
|
} catch { }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 SchemeCanvas_MouseMove(object sender, MouseEventArgs evt) {
|
private void SchemeCanvas_MouseMove(object sender, MouseEventArgs evt) {
|
||||||
var p = evt.GetPosition(SchemeCanvas);
|
|
||||||
UpdateScheme(evt.GetPosition(SchemeCanvas), evt.LeftButton == MouseButtonState.Pressed);
|
UpdateScheme(evt.GetPosition(SchemeCanvas), evt.LeftButton == MouseButtonState.Pressed);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SchemeCanvas_MouseLeftButtonDown(object sender, MouseButtonEventArgs evt) {
|
private void SchemeCanvas_MouseLeftButtonDown(object sender, MouseButtonEventArgs evt) {
|
||||||
var p = evt.GetPosition(SchemeCanvas);
|
|
||||||
_lastSelected = UpdateScheme(evt.GetPosition(SchemeCanvas), evt.LeftButton == MouseButtonState.Pressed);
|
_lastSelected = UpdateScheme(evt.GetPosition(SchemeCanvas), evt.LeftButton == MouseButtonState.Pressed);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,27 +220,36 @@ namespace PamhagenSysCtrl.Windows {
|
|||||||
_lastSource = null;
|
_lastSource = null;
|
||||||
}
|
}
|
||||||
foreach (var c in clicked) {
|
foreach (var c in clicked) {
|
||||||
if (_lastSource == null && Graph.SelectedPaths.Any(p => p.Start == c)) {
|
if (App.Plant?.ManualControlMode ?? false) {
|
||||||
var path = Graph.SelectedPaths.First(p => p.Start == c);
|
if (c is Valve v) {
|
||||||
if (!path.Hops.Any(h => (h.Node as Pump)?.IsActive ?? false)) {
|
if (v.WantOpen) {
|
||||||
Graph.RemovePath(path);
|
App.Plant.CloseV(v.Nr);
|
||||||
|
} else {
|
||||||
|
App.Plant.OpenV(v.Nr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (_lastSource != null && c is ISink sink) {
|
} else {
|
||||||
var res = Graph.GetPath([_lastSource, .._path, sink], (n) => n is not ISink && (n is not Valve v || !v.IsLocked));
|
if (_lastSource == null && Graph.SelectedPaths.Any(p => p.Start == c)) {
|
||||||
if (res is Path path) {
|
var path = Graph.SelectedPaths.First(p => p.Start == c);
|
||||||
Graph.AddPath(path);
|
if (!path.Hops.Any(h => (h.Node as Pump)?.IsActive ?? false)) {
|
||||||
|
Graph.RemovePath(path);
|
||||||
|
}
|
||||||
|
} else if (_lastSource != null && c is ISink sink) {
|
||||||
|
if (Graph.GetFreePath([_lastSource, .. _path, sink]) is Path path) {
|
||||||
|
Graph.AddPath(path);
|
||||||
|
_lastSource = null;
|
||||||
|
}
|
||||||
|
} else if (_lastSource != null) {
|
||||||
|
var path = Graph.GetFreePath([_lastSource, .. _path, c]);
|
||||||
|
if (path != null) {
|
||||||
|
_path.Add(c);
|
||||||
|
}
|
||||||
|
} else if (c is ISource source) {
|
||||||
|
_lastSource = source;
|
||||||
|
_path = [];
|
||||||
|
} else {
|
||||||
_lastSource = null;
|
_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));
|
|
||||||
if (path != null) {
|
|
||||||
_path.Add(c);
|
|
||||||
}
|
|
||||||
} else if (c is ISource source) {
|
|
||||||
_lastSource = source;
|
|
||||||
_path = [];
|
|
||||||
} else {
|
|
||||||
_lastSource = null;
|
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (c is EntryTrough trough) {
|
if (c is EntryTrough trough) {
|
||||||
@@ -198,6 +342,30 @@ namespace PamhagenSysCtrl.Windows {
|
|||||||
UpdateScheme(pos, evt.LeftButton == MouseButtonState.Pressed);
|
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) {
|
private ISet<INode> UpdateScheme(Point pos, bool down) {
|
||||||
foreach (var e in Graph.Edges) {
|
foreach (var e in Graph.Edges) {
|
||||||
e.Highlight = null;
|
e.Highlight = null;
|
||||||
@@ -208,37 +376,90 @@ namespace PamhagenSysCtrl.Windows {
|
|||||||
p.Highlight = null;
|
p.Highlight = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach (var p in Graph.SelectedPaths) {
|
|
||||||
Graph.ColorPipesAdjacientToPath(p, PamhagenBrushes.Green, p.Hops.Any(h => (h.Node as Pump)?.IsActive ?? false), PamhagenBrushes.DimOrange);
|
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);
|
_hover = Graph.GetHover(pos.X, pos.Y);
|
||||||
if (_lastSource != null && (_hover.Count > 0 || _path.Count > 0)) {
|
var hoverButtons = FastSelectPaths.Where(b => b.Key.IsMouseOver).ToDictionary();
|
||||||
List<INode> points = [_lastSource, .. _path];
|
Path? hoverPathDeactivate = null;
|
||||||
if (_hover.Count > 0 && !points.Contains(_hover.First())) {
|
if (App.Plant?.ManualControlMode ?? false) {
|
||||||
points.Add(_hover.First());
|
foreach (var src in Graph.Nodes.Where(n => n is Pump)) {
|
||||||
|
Graph.ColorPipesByValves(src, PamhagenBrushes.Green, (src as Pump)?.State ?? default, PamhagenBrushes.DimOrange);
|
||||||
}
|
}
|
||||||
if (points.Count >= 2) {
|
MP1_Target.Text = "Vor";
|
||||||
var res = Graph.GetPath(points, (n) => n is not ISink && (n is not Valve v || !v.IsLocked));
|
MP2_Target.Text = "Vor";
|
||||||
if (res is Path path) {
|
MP1_Target.FontSize = 16;
|
||||||
Graph.ColorPipesAdjacientToPath(path, PamhagenBrushes.Green, false, PamhagenBrushes.DimOrange);
|
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 && 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 path1.Hops.Select(h => h.Node as Pump).Where(p => p != null)) {
|
||||||
|
pump?.Highlight = PamhagenBrushes.Red;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (_lastSource == null && _hover.Count > 0 && Graph.SelectedPaths.Any(p => p.Start == _hover.First())) {
|
if (_lastSource != null) {
|
||||||
var path = Graph.SelectedPaths.First(p => p.Start == _hover.First());
|
foreach (var edge in _lastSource.Outputs) {
|
||||||
var pumpActive = path.Hops.Any(h => (h.Node as Pump)?.IsActive ?? false);
|
edge.Highlight = PamhagenBrushes.Green;
|
||||||
if (pumpActive) {
|
|
||||||
foreach (var pump in path.Hops.Select(h => h.Node as Pump).Where(p => p != null)) {
|
|
||||||
pump?.Highlight = PamhagenBrushes.Red;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
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 {
|
} else {
|
||||||
Graph.ColorPipesAdjacientToPath(path, PamhagenBrushes.Red, false, null);
|
MP1_Target.Text = "Vor";
|
||||||
}
|
}
|
||||||
}
|
if (Graph.SelectedPaths.Select(p => (Path?)p).FirstOrDefault(p => p?.Start == Graph.MW2) is Path pmw2) {
|
||||||
if (_lastSource != null) {
|
MP2_Target.Text = "\u2b9e " + string.Join(" \u2b9e ", pmw2.Hops
|
||||||
foreach (var edge in _lastSource.Outputs) {
|
.Select(h => h.Node is Valve || h.Node is Pump || h.Node is CenterValve ? null : h.Node.Label)
|
||||||
edge.Highlight = PamhagenBrushes.Green;
|
.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);
|
Graph.Update(_hover, down);
|
||||||
return _hover;
|
return _hover;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user