This commit is contained in:
@@ -22,6 +22,7 @@ namespace PamhagenSysCtrl.Windows {
|
||||
}
|
||||
|
||||
private void Menu_Settings_ManualControl_Click(object sender, RoutedEventArgs evt) {
|
||||
App.Plant?.ManualControlMode = Menu_Settings_ManualControl.IsChecked;
|
||||
if (Menu_Settings_ManualControl.IsChecked) {
|
||||
foreach (var win in Application.Current.Windows) {
|
||||
if (win is ManualControlWindow w) {
|
||||
@@ -38,6 +39,7 @@ namespace PamhagenSysCtrl.Windows {
|
||||
}
|
||||
}
|
||||
}
|
||||
OnUpdate(null, null);
|
||||
}
|
||||
|
||||
private void Menu_Settings_OverridePathClearances_Click(object sender, RoutedEventArgs evt) {
|
||||
@@ -85,27 +87,37 @@ namespace PamhagenSysCtrl.Windows {
|
||||
_lastSource = null;
|
||||
}
|
||||
foreach (var c in clicked) {
|
||||
if (_lastSource == null && Graph.SelectedPaths.Any(p => p.Start == c)) {
|
||||
var path = Graph.SelectedPaths.First(p => p.Start == c);
|
||||
if (!path.Hops.Any(h => (h.Node as Pump)?.IsActive ?? false)) {
|
||||
Graph.RemovePath(path);
|
||||
if (App.Plant?.ManualControlMode ?? false) {
|
||||
if (c is Valve v) {
|
||||
if (v.WantOpen) {
|
||||
App.Plant.CloseV(v.Nr);
|
||||
} else {
|
||||
App.Plant.OpenV(v.Nr);
|
||||
}
|
||||
}
|
||||
} else if (_lastSource != null && c is ISink sink) {
|
||||
var res = Graph.GetPath([_lastSource, .._path, sink], (n) => n is not ISink && (n is not Valve v || !v.IsLocked));
|
||||
if (res is Path path) {
|
||||
Graph.AddPath(path);
|
||||
} else {
|
||||
if (_lastSource == null && Graph.SelectedPaths.Any(p => p.Start == c)) {
|
||||
var path = Graph.SelectedPaths.First(p => p.Start == c);
|
||||
if (!path.Hops.Any(h => (h.Node as Pump)?.IsActive ?? false)) {
|
||||
Graph.RemovePath(path);
|
||||
}
|
||||
} else if (_lastSource != null && c is ISink sink) {
|
||||
var res = Graph.GetPath([_lastSource, .. _path, sink], (n) => n is not ISink && (n is not Valve v || !v.IsLocked));
|
||||
if (res is Path path) {
|
||||
Graph.AddPath(path);
|
||||
_lastSource = null;
|
||||
}
|
||||
} else if (_lastSource != null) {
|
||||
var path = Graph.GetPath([_lastSource, .. _path, c], (n) => n is not ISink && (n is not Valve v || !v.IsLocked));
|
||||
if (path != null) {
|
||||
_path.Add(c);
|
||||
}
|
||||
} else if (c is ISource source) {
|
||||
_lastSource = source;
|
||||
_path = [];
|
||||
} else {
|
||||
_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 {
|
||||
if (c is EntryTrough trough) {
|
||||
@@ -208,35 +220,42 @@ namespace PamhagenSysCtrl.Windows {
|
||||
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);
|
||||
}
|
||||
|
||||
_hover = Graph.GetHover(pos.X, pos.Y);
|
||||
if (_lastSource != null && (_hover.Count > 0 || _path.Count > 0)) {
|
||||
List<INode> points = [_lastSource, .. _path];
|
||||
if (_hover.Count > 0 && !points.Contains(_hover.First())) {
|
||||
points.Add(_hover.First());
|
||||
if (App.Plant?.ManualControlMode ?? false) {
|
||||
foreach (var src in Graph.Nodes.Where(n => n is Pump)) {
|
||||
Graph.ColorPipesByValves(src, PamhagenBrushes.Green, (src as Pump)?.State ?? default, PamhagenBrushes.DimOrange);
|
||||
}
|
||||
if (points.Count >= 2) {
|
||||
var res = Graph.GetPath(points, (n) => n is not ISink && (n is not Valve v || !v.IsLocked));
|
||||
if (res is Path path) {
|
||||
Graph.ColorPipesAdjacientToPath(path, PamhagenBrushes.Green, false, PamhagenBrushes.DimOrange);
|
||||
} else {
|
||||
foreach (var p in Graph.SelectedPaths) {
|
||||
Graph.ColorPipesAdjacientToPath(p, PamhagenBrushes.Green, p.Hops.Select(h => (h.Node as Pump)?.State ?? default).FirstOrDefault(n => n != MotorState.Halt), PamhagenBrushes.DimOrange);
|
||||
}
|
||||
if (_lastSource != null && (_hover.Count > 0 || _path.Count > 0)) {
|
||||
List<INode> points = [_lastSource, .. _path];
|
||||
if (_hover.Count > 0 && !points.Contains(_hover.First())) {
|
||||
points.Add(_hover.First());
|
||||
}
|
||||
if (points.Count >= 2) {
|
||||
var res = Graph.GetPath(points, (n) => n is not ISink && (n is not Valve v || !v.IsLocked));
|
||||
if (res is Path path) {
|
||||
Graph.ColorPipesAdjacientToPath(path, PamhagenBrushes.Green, default, PamhagenBrushes.DimOrange);
|
||||
}
|
||||
}
|
||||
} else if (_lastSource == null && _hover.Count > 0 && Graph.SelectedPaths.Any(p => p.Start == _hover.First())) {
|
||||
var path = Graph.SelectedPaths.First(p => p.Start == _hover.First());
|
||||
var pumpActive = path.Hops.Any(h => (h.Node as Pump)?.IsActive ?? false);
|
||||
if (pumpActive) {
|
||||
foreach (var pump in path.Hops.Select(h => h.Node as Pump).Where(p => p != null)) {
|
||||
pump?.Highlight = PamhagenBrushes.Red;
|
||||
}
|
||||
} else {
|
||||
Graph.ColorPipesAdjacientToPath(path, PamhagenBrushes.Red, default, null);
|
||||
}
|
||||
}
|
||||
} else if (_lastSource == null && _hover.Count > 0 && Graph.SelectedPaths.Any(p => p.Start == _hover.First())) {
|
||||
var path = Graph.SelectedPaths.First(p => p.Start == _hover.First());
|
||||
var pumpActive = path.Hops.Any(h => (h.Node as Pump)?.IsActive ?? false);
|
||||
if (pumpActive) {
|
||||
foreach (var pump in path.Hops.Select(h => h.Node as Pump).Where(p => p != null)) {
|
||||
pump?.Highlight = PamhagenBrushes.Red;
|
||||
if (_lastSource != null) {
|
||||
foreach (var edge in _lastSource.Outputs) {
|
||||
edge.Highlight = PamhagenBrushes.Green;
|
||||
}
|
||||
} else {
|
||||
Graph.ColorPipesAdjacientToPath(path, PamhagenBrushes.Red, false, null);
|
||||
}
|
||||
}
|
||||
if (_lastSource != null) {
|
||||
foreach (var edge in _lastSource.Outputs) {
|
||||
edge.Highlight = PamhagenBrushes.Green;
|
||||
}
|
||||
}
|
||||
Graph.Update(_hover, down);
|
||||
|
||||
Reference in New Issue
Block a user