Compare commits
2
Commits
90f9ad8c79
..
dev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
334f201a32 | ||
|
|
24beafd9e5 |
No files matched your search
@@ -512,7 +512,6 @@ namespace PamhagenSysCtrl.Helpers {
|
|||||||
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.Start as PipeJoin)?.Highlight = color1;
|
|
||||||
if (flowArrows > MotorState.Halt) {
|
if (flowArrows > MotorState.Halt) {
|
||||||
var dir = edge.End == node;
|
var dir = edge.End == node;
|
||||||
if (flowArrows == MotorState.Backward) dir = !dir;
|
if (flowArrows == MotorState.Backward) dir = !dir;
|
||||||
@@ -521,10 +520,7 @@ namespace PamhagenSysCtrl.Helpers {
|
|||||||
}
|
}
|
||||||
visited.Add(edge);
|
visited.Add(edge);
|
||||||
if (node is Pump) color = color2;
|
if (node is Pump) color = color2;
|
||||||
TraverseSubgraph(node, (n) => n is Valve || n is ISink || n is Pump, visited, edgeAction: (s, r, e) => {
|
TraverseSubgraph(node, (n) => n is Valve || n is ISink || n is Pump, visited, edgeAction: (s, r, e) => e.Highlight = color);
|
||||||
(s as PipeJoin)?.Highlight = color;
|
|
||||||
e.Highlight = color;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -534,8 +530,6 @@ namespace PamhagenSysCtrl.Helpers {
|
|||||||
edgeAction: (s, r, e) => {
|
edgeAction: (s, r, e) => {
|
||||||
if (((e.Start as Valve)?.IsOpen ?? true) && ((e.End as Valve)?.IsOpen ?? true)) {
|
if (((e.Start as Valve)?.IsOpen ?? true) && ((e.End as Valve)?.IsOpen ?? true)) {
|
||||||
e.Highlight = color1;
|
e.Highlight = color1;
|
||||||
(e.Start as PipeJoin)?.Highlight = color1;
|
|
||||||
(e.End as PipeJoin)?.Highlight = color1;
|
|
||||||
if (flowArrows == MotorState.Forward || flowArrows == MotorState.Backward) {
|
if (flowArrows == MotorState.Forward || flowArrows == MotorState.Backward) {
|
||||||
var dir = e.Start == s;
|
var dir = e.Start == s;
|
||||||
if (r) dir = !dir;
|
if (r) dir = !dir;
|
||||||
|
|||||||
@@ -1,12 +1,32 @@
|
|||||||
using PamhagenSysCtrl.Helpers.Pipeline;
|
using PamhagenSysCtrl.Helpers.Pipeline;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
|
|
||||||
namespace PamhagenSysCtrl.Helpers {
|
namespace PamhagenSysCtrl.Helpers {
|
||||||
public class PamhagenPlant : IDisposable {
|
public class PamhagenPlant : IDisposable {
|
||||||
|
|
||||||
|
public enum Xbe24Key {
|
||||||
|
START_REBLER = 6, STOP_REBLER = 7,
|
||||||
|
START_TROUGH_AUGER = 12, STOP_TROUGH_AUGER = 13,
|
||||||
|
SELECT_MW1 = 14, SELECT_MW2 = 8,
|
||||||
|
STIRRER_MW1 = 15, STIRRER_MW2 = 9,
|
||||||
|
START_MP1 = 16, STOP_MP1 = 17,
|
||||||
|
START_MP2 = 10, STOP_MP2 = 11,
|
||||||
|
FAST_SELECT_MW1_1 = 18,
|
||||||
|
FAST_SELECT_MW1_2 = 19,
|
||||||
|
FAST_SELECT_MW1_3 = 20,
|
||||||
|
FAST_SELECT_MW1_4 = 21,
|
||||||
|
FAST_SELECT_MW1_5 = 22,
|
||||||
|
FAST_SELECT_MW1_6 = 23,
|
||||||
|
FAST_SELECT_MW2_1 = 0,
|
||||||
|
FAST_SELECT_MW2_2 = 1,
|
||||||
|
FAST_SELECT_MW2_3 = 2,
|
||||||
|
FAST_SELECT_MW2_4 = 3,
|
||||||
|
FAST_SELECT_MW2_5 = 4,
|
||||||
|
FAST_SELECT_MW2_6 = 5,
|
||||||
|
}
|
||||||
|
|
||||||
protected PamhagenPlc? Plc;
|
protected PamhagenPlc? Plc;
|
||||||
protected Xbe24Keyboard? Keyboard;
|
protected Xbe24Keyboard? Keyboard;
|
||||||
public PamhagenGraph Graph;
|
public PamhagenGraph Graph;
|
||||||
@@ -150,28 +170,28 @@ namespace PamhagenSysCtrl.Helpers {
|
|||||||
protected void UpdateKeyboardBacklights(object? sender, PlantEventArgs evt) {
|
protected void UpdateKeyboardBacklights(object? sender, PlantEventArgs evt) {
|
||||||
if (sender is not PamhagenPlant plant || plant.Keyboard is not Xbe24Keyboard k) return;
|
if (sender is not PamhagenPlant plant || plant.Keyboard is not Xbe24Keyboard k) return;
|
||||||
|
|
||||||
k.SetBacklight(0, plant.IsReblerActive ? Color.FromRgb(0, 255, 0) : plant.IsAuger1Active ? Color.FromRgb(255, 255, 0) : plant.IsAuger2Active || plant.IsAuger3Active ? Color.FromRgb(32, 32, 4) : Color.FromRgb(4, 32, 4));
|
k.SetBacklight((int)Xbe24Key.START_REBLER, plant.IsReblerActive ? Color.FromRgb(0, 255, 0) : plant.IsAuger1Active ? Color.FromRgb(255, 255, 0) : plant.IsAuger2Active || plant.IsAuger3Active ? Color.FromRgb(32, 32, 4) : Color.FromRgb(4, 32, 4));
|
||||||
k.SetBacklight(1, !plant.IsReblerActive ? Color.FromRgb(255, 0, 0) : Color.FromRgb(32, 4, 4));
|
k.SetBacklight((int)Xbe24Key.STOP_REBLER, !plant.IsReblerActive ? Color.FromRgb(255, 0, 0) : Color.FromRgb(32, 4, 4));
|
||||||
|
|
||||||
k.SetBacklight(6, !plant.TroughAugerHasClearance ? k.IsKeyPressed(6) ? Color.FromRgb(255, 0, 0) : Color.FromRgb(32, 4, 4) : plant.IsTroughAugerActive ? Color.FromRgb(0, 255, 0) : Color.FromRgb(4, 32, 4));
|
k.SetBacklight((int)Xbe24Key.START_TROUGH_AUGER, !plant.TroughAugerHasClearance ? k.IsKeyPressed((int)Xbe24Key.START_TROUGH_AUGER) ? Color.FromRgb(255, 32, 0) : Color.FromRgb(32, 4, 4) : plant.IsTroughAugerActive ? Color.FromRgb(0, 255, 0) : Color.FromRgb(4, 32, 4));
|
||||||
k.SetBacklight(7, !plant.IsTroughAugerActive ? Color.FromRgb(255, 0, 0) : Color.FromRgb(32, 4, 4));
|
k.SetBacklight((int)Xbe24Key.STOP_TROUGH_AUGER, !plant.IsTroughAugerActive ? Color.FromRgb(255, 0, 0) : Color.FromRgb(32, 4, 4));
|
||||||
|
|
||||||
k.SetBacklight(2, plant.WantMW2Selected || plant.IsMW2Selected ? Color.FromRgb(0, 0, 255) : Color.FromRgb(4, 4, 16), plant.WantMW2Selected && !plant.IsMW2Selected);
|
k.SetBacklight((int)Xbe24Key.SELECT_MW2, plant.WantMW2Selected || plant.IsMW2Selected ? Color.FromRgb(0, 0, 255) : Color.FromRgb(4, 4, 16), plant.WantMW2Selected && !plant.IsMW2Selected);
|
||||||
k.SetBacklight(8, plant.WantMW1Selected || plant.IsMW1Selected ? Color.FromRgb(0, 0, 255) : Color.FromRgb(4, 4, 16), plant.WantMW1Selected && !plant.IsMW1Selected);
|
k.SetBacklight((int)Xbe24Key.SELECT_MW1, plant.WantMW1Selected || plant.IsMW1Selected ? Color.FromRgb(0, 0, 255) : Color.FromRgb(4, 4, 16), plant.WantMW1Selected && !plant.IsMW1Selected);
|
||||||
|
|
||||||
var buttons = new Dictionary<int, (ISource Source, Pump Pump, ISink Sink)> {
|
var buttons = new Dictionary<Xbe24Key, (ISource Source, Pump Pump, ISink Sink)> {
|
||||||
[12] = (Graph.MW1, Graph.MP1, Graph.Press1),
|
[Xbe24Key.FAST_SELECT_MW1_1] = (Graph.MW1, Graph.MP1, Graph.Press1),
|
||||||
[18] = (Graph.MW2, Graph.MP2, Graph.Press1),
|
[Xbe24Key.FAST_SELECT_MW2_1] = (Graph.MW2, Graph.MP2, Graph.Press1),
|
||||||
[13] = (Graph.MW1, Graph.MP1, Graph.Press2),
|
[Xbe24Key.FAST_SELECT_MW1_2] = (Graph.MW1, Graph.MP1, Graph.Press2),
|
||||||
[19] = (Graph.MW2, Graph.MP2, Graph.Press2),
|
[Xbe24Key.FAST_SELECT_MW2_2] = (Graph.MW2, Graph.MP2, Graph.Press2),
|
||||||
[14] = (Graph.MW1, Graph.MP1, Graph.Tank1),
|
[Xbe24Key.FAST_SELECT_MW1_3] = (Graph.MW1, Graph.MP1, Graph.Tank1),
|
||||||
[20] = (Graph.MW2, Graph.MP2, Graph.Tank1),
|
[Xbe24Key.FAST_SELECT_MW2_3] = (Graph.MW2, Graph.MP2, Graph.Tank1),
|
||||||
[15] = (Graph.MW1, Graph.MP1, Graph.Tank2),
|
[Xbe24Key.FAST_SELECT_MW1_4] = (Graph.MW1, Graph.MP1, Graph.Tank2),
|
||||||
[21] = (Graph.MW2, Graph.MP2, Graph.Tank2),
|
[Xbe24Key.FAST_SELECT_MW2_4] = (Graph.MW2, Graph.MP2, Graph.Tank2),
|
||||||
[16] = (Graph.MW1, Graph.MP1, Graph.Tank3),
|
[Xbe24Key.FAST_SELECT_MW1_5] = (Graph.MW1, Graph.MP1, Graph.Tank3),
|
||||||
[22] = (Graph.MW2, Graph.MP2, Graph.Tank3),
|
[Xbe24Key.FAST_SELECT_MW2_5] = (Graph.MW2, Graph.MP2, Graph.Tank3),
|
||||||
[17] = (Graph.MW1, Graph.MP1, Graph.Tank4),
|
[Xbe24Key.FAST_SELECT_MW1_6] = (Graph.MW1, Graph.MP1, Graph.Tank4),
|
||||||
[23] = (Graph.MW2, Graph.MP2, Graph.Tank4),
|
[Xbe24Key.FAST_SELECT_MW2_6] = (Graph.MW2, Graph.MP2, Graph.Tank4),
|
||||||
};
|
};
|
||||||
|
|
||||||
bool preparingMP1 = false, preparingMP2 = false;
|
bool preparingMP1 = false, preparingMP2 = false;
|
||||||
@@ -184,27 +204,27 @@ namespace PamhagenSysCtrl.Helpers {
|
|||||||
if (!isReady && d.Pump == Graph.MP1) preparingMP1 = true;
|
if (!isReady && d.Pump == Graph.MP1) preparingMP1 = true;
|
||||||
if (!isReady && d.Pump == Graph.MP2) preparingMP2 = true;
|
if (!isReady && d.Pump == Graph.MP2) preparingMP2 = true;
|
||||||
var isDefault = !path.Hops.SkipLast(1).Any(h => h.Node is not Valve && h.Node is not PipeJoin && h.Node is not Pump);
|
var isDefault = !path.Hops.SkipLast(1).Any(h => h.Node is not Valve && h.Node is not PipeJoin && h.Node is not Pump);
|
||||||
k.SetBacklight(idx, isRunning ? isDefault ? Color.FromRgb(0, 255, 255) : Color.FromRgb(255, 64, 255) : isDefault ? Color.FromRgb(0, 0, 255) : Color.FromRgb(128, 0, 128), !isReady);
|
k.SetBacklight((int)idx, isRunning ? isDefault ? Color.FromRgb(0, 255, 255) : Color.FromRgb(255, 64, 255) : isDefault ? Color.FromRgb(0, 0, 255) : Color.FromRgb(128, 0, 128), !isReady);
|
||||||
} else {
|
} else {
|
||||||
var isFree = Graph.GetFreePath([d.Source, d.Sink], overrideStart: true) != null;
|
var isFree = Graph.GetFreePath([d.Source, d.Sink], overrideStart: true) != null;
|
||||||
if (isRunning && k.IsKeyPressed(idx) && d.Pump == Graph.MP1) highlightOffMP1 = true;
|
if (isRunning && k.IsKeyPressed((int)idx) && d.Pump == Graph.MP1) highlightOffMP1 = true;
|
||||||
if (isRunning && k.IsKeyPressed(idx) && d.Pump == Graph.MP2) highlightOffMP2 = true;
|
if (isRunning && k.IsKeyPressed((int)idx) && d.Pump == Graph.MP2) highlightOffMP2 = true;
|
||||||
k.SetBacklight(idx, isRunning ? k.IsKeyPressed(idx) ? Color.FromRgb(255, 0, 0) : Color.FromRgb(4, 4, 4) : isFree ? Color.FromRgb(8, 8, 32) : k.IsKeyPressed(idx) ? Color.FromRgb(255, 0, 0) : Color.FromRgb(4, 4, 4));
|
k.SetBacklight((int)idx, isRunning ? k.IsKeyPressed((int)idx) ? Color.FromRgb(255, 16, 0) : Color.FromRgb(4, 4, 4) : isFree ? Color.FromRgb(8, 8, 32) : k.IsKeyPressed((int)idx) ? Color.FromRgb(255, 32, 0) : Color.FromRgb(4, 4, 4));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!plant.MP2HasPathClearance && plant.MP2HasDryRunClearance && preparingMP2) {
|
if (!plant.MP2HasPathClearance && plant.MP2HasDryRunClearance && preparingMP2) {
|
||||||
k.SetBacklight(4, Color.FromRgb(4, 32, 4), true);
|
k.SetBacklight((int)Xbe24Key.START_MP2, Color.FromRgb(4, 32, 4), true);
|
||||||
} else {
|
} else {
|
||||||
k.SetBacklight(4, !plant.MP2HasClearance ? k.IsKeyPressed(4) ? Color.FromRgb(255, 0, 0) : Color.FromRgb(32, 4, 4) : plant.IsMP2Active ? Color.FromRgb(0, 255, 0) : Color.FromRgb(4, 32, 4));
|
k.SetBacklight((int)Xbe24Key.START_MP2, !plant.MP2HasClearance ? k.IsKeyPressed((int)Xbe24Key.START_MP2) ? Color.FromRgb(255, 32, 0) : Color.FromRgb(32, 4, 4) : plant.IsMP2Active ? Color.FromRgb(0, 255, 0) : Color.FromRgb(4, 32, 4));
|
||||||
}
|
}
|
||||||
if (!plant.MP1HasPathClearance && plant.MP1HasDryRunClearance && preparingMP1) {
|
if (!plant.MP1HasPathClearance && plant.MP1HasDryRunClearance && preparingMP1) {
|
||||||
k.SetBacklight(10, Color.FromRgb(4, 32, 4), true);
|
k.SetBacklight((int)Xbe24Key.START_MP1, Color.FromRgb(4, 32, 4), true);
|
||||||
} else {
|
} else {
|
||||||
k.SetBacklight(10, !plant.MP1HasClearance ? k.IsKeyPressed(10) ? Color.FromRgb(255, 0, 0) : Color.FromRgb(32, 4, 4) : plant.IsMP1Active ? Color.FromRgb(0, 255, 0) : Color.FromRgb(4, 32, 4));
|
k.SetBacklight((int)Xbe24Key.START_MP1, !plant.MP1HasClearance ? k.IsKeyPressed((int)Xbe24Key.START_MP1) ? Color.FromRgb(255, 32, 0) : Color.FromRgb(32, 4, 4) : plant.IsMP1Active ? Color.FromRgb(0, 255, 0) : Color.FromRgb(4, 32, 4));
|
||||||
}
|
}
|
||||||
k.SetBacklight(5, highlightOffMP2 ? Color.FromRgb(255, 64, 0) : !plant.IsMP2Active ? Color.FromRgb(255, 0, 0) : Color.FromRgb(32, 4, 4));
|
k.SetBacklight((int)Xbe24Key.STOP_MP2, highlightOffMP2 ? Color.FromRgb(255, 32, 0) : !plant.IsMP2Active ? Color.FromRgb(255, 0, 0) : Color.FromRgb(32, 4, 4));
|
||||||
k.SetBacklight(11, highlightOffMP1 ? Color.FromRgb(255, 64, 0) : !plant.IsMP1Active ? Color.FromRgb(255, 0, 0) : Color.FromRgb(32, 4, 4));
|
k.SetBacklight((int)Xbe24Key.STOP_MP1, highlightOffMP1 ? Color.FromRgb(255, 32, 0) : !plant.IsMP1Active ? Color.FromRgb(255, 0, 0) : Color.FromRgb(32, 4, 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task StartThread() {
|
public async Task StartThread() {
|
||||||
@@ -299,11 +319,12 @@ namespace PamhagenSysCtrl.Helpers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void Keyboard_KeyDown(object? sender, int keyIndex) {
|
private void Keyboard_KeyDown(object? sender, int keyIndex) {
|
||||||
|
var key = (Xbe24Key)keyIndex;
|
||||||
App.MainDispatcher?.BeginInvoke(() => {
|
App.MainDispatcher?.BeginInvoke(() => {
|
||||||
try {
|
try {
|
||||||
if (keyIndex == 0) {
|
if (key == Xbe24Key.START_REBLER) {
|
||||||
StartRebler();
|
StartRebler();
|
||||||
} else if (keyIndex == 1) {
|
} else if (key == Xbe24Key.STOP_REBLER) {
|
||||||
if (IsReblerActive) {
|
if (IsReblerActive) {
|
||||||
StopRebler();
|
StopRebler();
|
||||||
} else {
|
} else {
|
||||||
@@ -313,45 +334,45 @@ namespace PamhagenSysCtrl.Helpers {
|
|||||||
StopAuger3();
|
StopAuger3();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (keyIndex == 6) {
|
} else if (key == Xbe24Key.START_TROUGH_AUGER) {
|
||||||
StartTroughAuger();
|
StartTroughAuger();
|
||||||
} else if (keyIndex == 7) {
|
} else if (key == Xbe24Key.STOP_TROUGH_AUGER) {
|
||||||
StopTroughAuger();
|
StopTroughAuger();
|
||||||
} else if (keyIndex == 2) {
|
} else if (key == Xbe24Key.SELECT_MW2) {
|
||||||
SelectMW2();
|
SelectMW2();
|
||||||
} else if (keyIndex == 8) {
|
} else if (key == Xbe24Key.SELECT_MW1) {
|
||||||
SelectMW1();
|
SelectMW1();
|
||||||
} else if (keyIndex == 4) {
|
} else if (key == Xbe24Key.START_MP2) {
|
||||||
StartMP2Forward();
|
StartMP2Forward();
|
||||||
} else if (keyIndex == 5) {
|
} else if (key == Xbe24Key.STOP_MP2) {
|
||||||
StopMP2();
|
StopMP2();
|
||||||
} else if (keyIndex == 10) {
|
} else if (key == Xbe24Key.START_MP1) {
|
||||||
StartMP1Forward();
|
StartMP1Forward();
|
||||||
} else if (keyIndex == 11) {
|
} else if (key == Xbe24Key.STOP_MP1) {
|
||||||
StopMP1();
|
StopMP1();
|
||||||
} else if (keyIndex == 12) {
|
} else if (key == Xbe24Key.FAST_SELECT_MW1_1) {
|
||||||
FastSelect(Graph.MW1, Graph.Press1);
|
FastSelect(Graph.MW1, Graph.Press1);
|
||||||
} else if (keyIndex == 13) {
|
} else if (key == Xbe24Key.FAST_SELECT_MW1_2) {
|
||||||
FastSelect(Graph.MW1, Graph.Press2);
|
FastSelect(Graph.MW1, Graph.Press2);
|
||||||
} else if (keyIndex == 14) {
|
} else if (key == Xbe24Key.FAST_SELECT_MW1_3) {
|
||||||
FastSelect(Graph.MW1, Graph.Tank1);
|
FastSelect(Graph.MW1, Graph.Tank1);
|
||||||
} else if (keyIndex == 15) {
|
} else if (key == Xbe24Key.FAST_SELECT_MW1_4) {
|
||||||
FastSelect(Graph.MW1, Graph.Tank2);
|
FastSelect(Graph.MW1, Graph.Tank2);
|
||||||
} else if (keyIndex == 16) {
|
} else if (key == Xbe24Key.FAST_SELECT_MW1_5) {
|
||||||
FastSelect(Graph.MW1, Graph.Tank3);
|
FastSelect(Graph.MW1, Graph.Tank3);
|
||||||
} else if (keyIndex == 17) {
|
} else if (key == Xbe24Key.FAST_SELECT_MW1_6) {
|
||||||
FastSelect(Graph.MW1, Graph.Tank4);
|
FastSelect(Graph.MW1, Graph.Tank4);
|
||||||
} else if (keyIndex == 18) {
|
} else if (key == Xbe24Key.FAST_SELECT_MW2_1) {
|
||||||
FastSelect(Graph.MW2, Graph.Press1);
|
FastSelect(Graph.MW2, Graph.Press1);
|
||||||
} else if (keyIndex == 19) {
|
} else if (key == Xbe24Key.FAST_SELECT_MW2_2) {
|
||||||
FastSelect(Graph.MW2, Graph.Press2);
|
FastSelect(Graph.MW2, Graph.Press2);
|
||||||
} else if (keyIndex == 20) {
|
} else if (key == Xbe24Key.FAST_SELECT_MW2_3) {
|
||||||
FastSelect(Graph.MW2, Graph.Tank1);
|
FastSelect(Graph.MW2, Graph.Tank1);
|
||||||
} else if (keyIndex == 21) {
|
} else if (key == Xbe24Key.FAST_SELECT_MW2_4) {
|
||||||
FastSelect(Graph.MW2, Graph.Tank2);
|
FastSelect(Graph.MW2, Graph.Tank2);
|
||||||
} else if (keyIndex == 22) {
|
} else if (key == Xbe24Key.FAST_SELECT_MW2_5) {
|
||||||
FastSelect(Graph.MW2, Graph.Tank3);
|
FastSelect(Graph.MW2, Graph.Tank3);
|
||||||
} else if (keyIndex == 23) {
|
} else if (key == Xbe24Key.FAST_SELECT_MW2_6) {
|
||||||
FastSelect(Graph.MW2, Graph.Tank4);
|
FastSelect(Graph.MW2, Graph.Tank4);
|
||||||
}
|
}
|
||||||
} catch (NoClearanceException) {
|
} catch (NoClearanceException) {
|
||||||
@@ -467,7 +488,7 @@ namespace PamhagenSysCtrl.Helpers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public bool MP2HasClearance => MP2HasDryRunClearance && MP2HasPathClearance;
|
public bool MP2HasClearance => MP2HasDryRunClearance && MP2HasPathClearance;
|
||||||
public bool MP2HasDryRunClearance => (OverrideDryRunClearances || FillLevelMW2 != FillState.Empty);
|
public bool MP2HasDryRunClearance => (OverrideDryRunClearances || FillLevelMW2 != FillState.Empty);
|
||||||
public bool MP2HasPathClearance => (
|
public bool MP2HasPathClearance => (
|
||||||
OverridePathClearances ||
|
OverridePathClearances ||
|
||||||
(MP2HasClearancePress1 && Press1HasClearance) ||
|
(MP2HasClearancePress1 && Press1HasClearance) ||
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Shapes;
|
||||||
|
|
||||||
namespace PamhagenSysCtrl.Helpers.Pipeline {
|
namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||||
public class PipeJoin : INode {
|
public class PipeJoin : INode {
|
||||||
@@ -11,12 +12,11 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
|||||||
public double CenterX { get; set; }
|
public double CenterX { get; set; }
|
||||||
public double CenterY { get; set; }
|
public double CenterY { get; set; }
|
||||||
public string Label => "";
|
public string Label => "";
|
||||||
public Brush? Highlight { get; set; }
|
|
||||||
|
|
||||||
public ISet<IEdge> Inputs { get; init; }
|
public ISet<IEdge> Inputs { get; init; }
|
||||||
public ISet<IEdge> Outputs { get; init; }
|
public ISet<IEdge> Outputs { get; init; }
|
||||||
|
|
||||||
private System.Windows.Shapes.Path? _rect;
|
private Polygon? _rect;
|
||||||
|
|
||||||
public PipeJoin(double x, double y) {
|
public PipeJoin(double x, double y) {
|
||||||
CenterX = x;
|
CenterX = x;
|
||||||
@@ -26,8 +26,8 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void Draw(Canvas canvas) {
|
public void Draw(Canvas canvas) {
|
||||||
_rect = new System.Windows.Shapes.Path() {
|
_rect = new Polygon() {
|
||||||
Fill = Brushes.DarkGray,
|
Fill = Brushes.Black,
|
||||||
Stroke = Brushes.Black,
|
Stroke = Brushes.Black,
|
||||||
};
|
};
|
||||||
canvas.Children.Add(_rect);
|
canvas.Children.Add(_rect);
|
||||||
@@ -43,66 +43,43 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
|||||||
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 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 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 size = new Size(SIZE / 2 * scale, SIZE / 2 * scale);
|
var points = new List<Point> {
|
||||||
var geo = new StreamGeometry();
|
new(0, 0)
|
||||||
using (var ctx = geo.Open()) {
|
};
|
||||||
var points = new List<Point> {
|
if (ot && it) {
|
||||||
new(0, 0)
|
points.AddRange([new(SIZE / 2 - POINT, 0), new(SIZE / 2, -POINT / 2), new(SIZE / 2, POINT / 2), new(SIZE / 2 + POINT, 0)]);
|
||||||
};
|
} else if (ot) {
|
||||||
|
points.AddRange([new(SIZE / 2 - POINT, 0), new(SIZE / 2, -POINT), new(SIZE / 2 + POINT, 0)]);
|
||||||
ctx.BeginFigure(new((SIZE / 2 - POINT) * scale, 0), true, false);
|
} else if (it) {
|
||||||
if (ot && it) {
|
points.AddRange([new(SIZE / 2 - POINT, 0), new(SIZE / 2, POINT), new(SIZE / 2 + POINT, 0)]);
|
||||||
points.AddRange([new(SIZE / 2, -POINT / 2), new(SIZE / 2, POINT / 2), new(SIZE / 2 + POINT, 0)]);
|
}
|
||||||
} else if (ot) {
|
points.Add(new(SIZE, 0));
|
||||||
ctx.PolyLineTo([new(SIZE / 2 * scale, -POINT * scale), new((SIZE / 2 + POINT) * scale, 0)], true, false);
|
if (or && ir) {
|
||||||
} else if (it) {
|
points.AddRange([new(SIZE, SIZE / 2 - POINT), new(SIZE + POINT / 2, SIZE / 2), new(SIZE - POINT / 2, SIZE / 2), new(SIZE, SIZE / 2 + POINT)]);
|
||||||
ctx.PolyLineTo([new(SIZE / 2 * scale, POINT * scale), new((SIZE / 2 + POINT) * scale, 0)], true, false);
|
} else if (or) {
|
||||||
} else {
|
points.AddRange([new(SIZE, SIZE / 2 - POINT), new(SIZE + POINT, SIZE / 2), new(SIZE, SIZE / 2 + POINT)]);
|
||||||
ctx.ArcTo(new((SIZE / 2 + POINT) * scale, 0), size, 0, false, SweepDirection.Clockwise, true, false);
|
} else if (ir) {
|
||||||
}
|
points.AddRange([new(SIZE, SIZE / 2 - POINT), new(SIZE - POINT, SIZE / 2), new(SIZE, SIZE / 2 + POINT)]);
|
||||||
|
}
|
||||||
ctx.ArcTo(new(SIZE * scale, (SIZE / 2 - POINT) * scale), size, 0, false, SweepDirection.Clockwise, true, false);
|
points.Add(new(SIZE, SIZE));
|
||||||
points.Add(new(SIZE, 0));
|
if (ob && ib) {
|
||||||
if (or && ir) {
|
points.AddRange([new(SIZE / 2 + POINT, SIZE), new(SIZE / 2, SIZE + POINT / 2), new(SIZE / 2, SIZE - POINT / 2), new(SIZE / 2 - POINT, SIZE)]);
|
||||||
points.AddRange([new(SIZE, SIZE / 2 - POINT), new(SIZE + POINT / 2, SIZE / 2), new(SIZE - POINT / 2, SIZE / 2), new(SIZE, SIZE / 2 + POINT)]);
|
} else if (ob) {
|
||||||
} else if (or) {
|
points.AddRange([new(SIZE / 2 + POINT, SIZE), new(SIZE / 2, SIZE + POINT), new(SIZE / 2 - POINT, SIZE)]);
|
||||||
ctx.PolyLineTo([new((SIZE + POINT) * scale, SIZE / 2 * scale), new(SIZE * scale, (SIZE / 2 + POINT) * scale)], true, false);
|
} else if (ib) {
|
||||||
} else if (ir) {
|
points.AddRange([new(SIZE / 2 + POINT, SIZE), new(SIZE / 2, SIZE - POINT), new(SIZE / 2 - POINT, SIZE)]);
|
||||||
ctx.PolyLineTo([new((SIZE - POINT) * scale, SIZE / 2 * scale), new(SIZE * scale, (SIZE / 2 + POINT) * scale)], true, false);
|
}
|
||||||
} else {
|
points.Add(new(0, SIZE));
|
||||||
ctx.ArcTo(new(SIZE * scale, (SIZE / 2 + POINT) * scale), size, 0, false, SweepDirection.Clockwise, true, false);
|
if (ol && il) {
|
||||||
}
|
points.AddRange([new(0, SIZE / 2 + POINT), new(-POINT / 2, SIZE / 2), new(POINT / 2, SIZE / 2), new(0, SIZE / 2 - POINT)]);
|
||||||
|
} else if (ol) {
|
||||||
ctx.ArcTo(new((SIZE / 2 + POINT) * scale, SIZE * scale), size, 0, false, SweepDirection.Clockwise, true, false);
|
points.AddRange([new(0, SIZE / 2 + POINT), new(-POINT, SIZE / 2), new(0, SIZE / 2 - POINT)]);
|
||||||
points.Add(new(SIZE, SIZE));
|
} else if (il) {
|
||||||
if (ob && ib) {
|
points.AddRange([new(0, SIZE / 2 + POINT), new(POINT, SIZE / 2), new(0, SIZE / 2 - POINT)]);
|
||||||
points.AddRange([new(SIZE / 2 + POINT, SIZE), new(SIZE / 2, SIZE + POINT / 2), new(SIZE / 2, SIZE - POINT / 2), new(SIZE / 2 - POINT, SIZE)]);
|
|
||||||
} else if (ob) {
|
|
||||||
ctx.PolyLineTo([new(SIZE / 2 * scale, (SIZE + POINT) * scale), new((SIZE / 2 - POINT) * scale, SIZE * scale)], true, false);
|
|
||||||
} else if (ib) {
|
|
||||||
ctx.PolyLineTo([new(SIZE / 2 * scale, (SIZE - POINT) * scale), new((SIZE / 2 - POINT) * scale, SIZE * scale)], true, false);
|
|
||||||
} else {
|
|
||||||
ctx.ArcTo(new((SIZE / 2 - POINT) * scale, SIZE * scale), size, 0, false, SweepDirection.Clockwise, true, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx.ArcTo(new(0, (SIZE / 2 + POINT) * scale), size, 0, false, SweepDirection.Clockwise, true, false);
|
|
||||||
points.Add(new(0, SIZE));
|
|
||||||
if (ol && il) {
|
|
||||||
points.AddRange([new(0, SIZE / 2 + POINT), new(-POINT / 2, SIZE / 2), new(POINT / 2, SIZE / 2), new(0, SIZE / 2 - POINT)]);
|
|
||||||
} else if (ol) {
|
|
||||||
ctx.PolyLineTo([new(-POINT * scale, SIZE / 2 * scale), new(0, (SIZE / 2 - POINT) * scale)], true, false);
|
|
||||||
} else if (il) {
|
|
||||||
ctx.PolyLineTo([new(POINT * scale, SIZE / 2 * scale), new(0, (SIZE / 2 - POINT) * scale)], true, false);
|
|
||||||
} else {
|
|
||||||
ctx.ArcTo(new(0, (SIZE / 2 - POINT) * scale), size, 0, false, SweepDirection.Clockwise, true, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx.ArcTo(new((SIZE / 2 - POINT) * scale, 0), size, 0, false, SweepDirection.Clockwise, true, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_rect?.Data = geo;
|
_rect?.Points = [.. points.Select(p => new Point(p.X * scale, p.Y * scale))];
|
||||||
// [.. points.Select(p => new Point(p.X * scale, p.Y * scale))];
|
_rect?.StrokeThickness = 2;
|
||||||
_rect?.StrokeThickness = Graph.ToBorder(scale);
|
|
||||||
_rect?.SetValue(Canvas.LeftProperty, (CenterX - SIZE / 2) * scale);
|
_rect?.SetValue(Canvas.LeftProperty, (CenterX - SIZE / 2) * scale);
|
||||||
_rect?.SetValue(Canvas.TopProperty, (CenterY - SIZE / 2) * scale);
|
_rect?.SetValue(Canvas.TopProperty, (CenterY - SIZE / 2) * scale);
|
||||||
}
|
}
|
||||||
@@ -112,7 +89,7 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void Update(bool isHovering, bool isPressed) {
|
public void Update(bool isHovering, bool isPressed) {
|
||||||
_rect?.Fill = Highlight ?? Brushes.DarkGray;
|
_rect?.Stroke = isHovering ? Brushes.Black : Brushes.Black;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
using PIEHidNetCore;
|
using PIEHidNetCore;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
|
|
||||||
|
|||||||
@@ -484,7 +484,6 @@ namespace PamhagenSysCtrl.Windows {
|
|||||||
SetFastSelectButton(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,
|
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);
|
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) {
|
||||||
@@ -495,8 +494,6 @@ namespace PamhagenSysCtrl.Windows {
|
|||||||
foreach (var n in Graph.Nodes) {
|
foreach (var n in Graph.Nodes) {
|
||||||
if (n is Pump p) {
|
if (n is Pump p) {
|
||||||
p.Highlight = null;
|
p.Highlight = null;
|
||||||
} else if (n is PipeJoin j) {
|
|
||||||
j.Highlight = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -504,10 +501,8 @@ namespace PamhagenSysCtrl.Windows {
|
|||||||
SetFastSelectButton(FastSelectButton_EntryTrough_Stop, App.Plant?.IsTroughAugerActive ?? false ? 0 : 2);
|
SetFastSelectButton(FastSelectButton_EntryTrough_Stop, App.Plant?.IsTroughAugerActive ?? false ? 0 : 2);
|
||||||
SetFastSelectButton(FastSelectButton_MW1, App.Plant?.IsMW1Selected ?? false ? 1 : 0);
|
SetFastSelectButton(FastSelectButton_MW1, App.Plant?.IsMW1Selected ?? false ? 1 : 0);
|
||||||
SetFastSelectButton(FastSelectButton_MW2, App.Plant?.IsMW2Selected ?? 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_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_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_Forward, App.Plant?.MP2 == MotorState.Forward ? 1 : 0, !(App.Plant?.MP2HasClearance ?? false));
|
||||||
SetFastSelectButton(FastSelectButton_MP2_Stop, App.Plant?.MP2 == MotorState.Halt ? 2 : 0);
|
SetFastSelectButton(FastSelectButton_MP2_Stop, App.Plant?.MP2 == MotorState.Halt ? 2 : 0);
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user