Add clearance logic to PamhagenPlant

This commit is contained in:
2026-08-04 15:30:08 +02:00
parent 0d65e419b9
commit 7b95cf4221
10 changed files with 459 additions and 94 deletions
+1 -1
View File
@@ -13,7 +13,7 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
public double Height { get; set; }
public double Angle { get; set; }
public bool IsActive {
public bool IsAnimationActive {
set {
if (value) {
_storyboard?.Resume();
@@ -17,10 +17,11 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
public ISet<IEdge> Inputs { get; init; }
public ISet<IEdge> Outputs { get; init; }
public bool IsActive {
get => _active;
public bool IsActive => CallbackActive();
public bool IsAnimationActive {
get => _animationActive;
set {
_active = value;
_animationActive = value;
if (value) {
_storyboard?.Resume();
} else {
@@ -29,15 +30,18 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
}
}
private bool _active;
protected Func<bool> CallbackActive;
private bool _animationActive;
private Shape? _rect;
private Polyline? _polyline;
private Storyboard? _storyboard;
public ConveyorBelt(string label, double x, double y) {
public ConveyorBelt(string label, double x, double y, Func<bool> cbActive) {
CenterX = x;
CenterY = y;
Label = label;
CallbackActive = cbActive;
Inputs = new HashSet<IEdge>();
Outputs = new HashSet<IEdge>();
}
@@ -97,12 +101,13 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
}
public void Update(bool isHovering, bool isPressed) {
IsAnimationActive = IsActive;
_rect?.Fill =
IsActive && isHovering && isPressed ? PamhagenBrushes.Red :
IsActive && isHovering ? PamhagenBrushes.Red :
!IsActive && isHovering && isPressed ? PamhagenBrushes.Green :
!IsActive && isHovering ? PamhagenBrushes.Green :
IsActive ? PamhagenBrushes.Green :
IsAnimationActive && isHovering && isPressed ? PamhagenBrushes.Red :
IsAnimationActive && isHovering ? PamhagenBrushes.Red :
!IsAnimationActive && isHovering && isPressed ? PamhagenBrushes.Green :
!IsAnimationActive && isHovering ? PamhagenBrushes.Green :
IsAnimationActive ? PamhagenBrushes.Green :
Brushes.WhiteSmoke;
}
}
@@ -16,25 +16,29 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
public ISet<IEdge> Inputs { get; init; }
public ISet<IEdge> Outputs { get; init; }
public bool IsActive {
get => _active;
public bool IsActive => CallbackActive();
public bool IsAnimationActive {
get => _animationActive;
set {
_active = value;
_auger?.IsActive = value;
_animationActive = value;
_auger?.IsAnimationActive = value;
}
}
private bool _active;
protected Func<bool> CallbackActive;
private bool _animationActive;
private Shape? _inner;
private Shape? _outer;
private Auger? _auger;
private TextBlock? _text;
public EncasedAuger(string label, double x, double y, double angle = 0) {
public EncasedAuger(string label, double x, double y, Func<bool> cbActive, double angle = 0) {
CenterX = x;
CenterY = y;
Label = label;
Angle = angle;
CallbackActive = cbActive;
Inputs = new HashSet<IEdge>();
Outputs = new HashSet<IEdge>();
}
@@ -80,12 +84,13 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
}
public void Update(bool isHovering, bool isPressed) {
IsAnimationActive = IsActive;
_inner?.Fill =
IsActive && isHovering && isPressed ? PamhagenBrushes.Red :
IsActive && isHovering ? PamhagenBrushes.Red :
!IsActive && isHovering && isPressed ? PamhagenBrushes.Green :
!IsActive && isHovering ? PamhagenBrushes.Green :
IsActive ? PamhagenBrushes.Green :
IsAnimationActive && isHovering && isPressed ? PamhagenBrushes.Red :
IsAnimationActive && isHovering ? PamhagenBrushes.Red :
!IsAnimationActive && isHovering && isPressed ? PamhagenBrushes.Green :
!IsAnimationActive && isHovering ? PamhagenBrushes.Green :
IsAnimationActive ? PamhagenBrushes.Green :
Brushes.WhiteSmoke;
}
}
+16 -11
View File
@@ -16,11 +16,12 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
public ISet<IEdge> Inputs { get; init; }
public ISet<IEdge> Outputs { get; init; }
public bool IsActive {
get => _active;
public bool IsActive => CallbackActive();
public bool IsAnimationActive {
get => _animationActive;
set {
_active = value;
_auger?.IsActive = value;
_animationActive = value;
_auger?.IsAnimationActive = value;
if (value) {
_doorTransform?.BeginAnimation(
RotateTransform.AngleProperty,
@@ -41,7 +42,9 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
}
}
private bool _active;
protected Func<bool> CallbackActive;
private bool _animationActive;
private Shape? _inner;
private Shape? _outer;
private TextBlock? _text;
@@ -49,10 +52,11 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
private Shape? _door;
private RotateTransform? _doorTransform;
public EntryTrough(string label, double x, double y) {
public EntryTrough(string label, double x, double y, Func<bool> cbActive) {
CenterX = x;
CenterY = y;
Label = label;
CallbackActive = cbActive;
Inputs = new HashSet<IEdge>();
Outputs = new HashSet<IEdge>();
}
@@ -99,12 +103,13 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
}
public void Update(bool isHovering, bool isPressed) {
IsAnimationActive = IsActive;
_inner?.Fill =
IsActive && isHovering && isPressed ? PamhagenBrushes.Red :
IsActive && isHovering ? PamhagenBrushes.Red :
!IsActive && isHovering && isPressed ? PamhagenBrushes.Green :
!IsActive && isHovering ? PamhagenBrushes.Green :
IsActive ? PamhagenBrushes.Green :
IsAnimationActive && isHovering && isPressed ? PamhagenBrushes.Red :
IsAnimationActive && isHovering ? PamhagenBrushes.Red :
!IsAnimationActive && isHovering && isPressed ? PamhagenBrushes.Green :
!IsAnimationActive && isHovering ? PamhagenBrushes.Green :
IsAnimationActive ? PamhagenBrushes.Green :
Brushes.WhiteSmoke;
}
}
+20 -2
View File
@@ -15,14 +15,26 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
public ISet<IEdge> Inputs { get; init; }
public ISet<IEdge> Outputs { get; init; }
public Brush? Highlight { get; set; }
public bool IsActive => CallbackActive();
public bool HasClearance => CallbackClearance();
public bool IsSelected => CallbackSelected(this);
protected Func<bool> CallbackActive;
protected Func<bool> CallbackClearance;
protected Func<Pump, bool> CallbackSelected;
private Shape? _circle;
private Shape? _triangle;
private TextBlock? _text;
public Pump(string label, double x, double y) {
public Pump(string label, double x, double y, Func<bool> cbActive, Func<bool> cbClearance, Func<Pump, bool> cbSelected) {
CenterX = x;
CenterY = y;
Label = label;
CallbackActive = cbActive;
CallbackClearance = cbClearance;
CallbackSelected = cbSelected;
Inputs = new HashSet<IEdge>();
Outputs = new HashSet<IEdge>();
}
@@ -63,7 +75,13 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
}
public void Update(bool isHovering, bool isPresed) {
_circle?.Fill = isHovering ? Brushes.LightGray : Brushes.WhiteSmoke;
_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);
}
}
}
+5 -2
View File
@@ -15,7 +15,9 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
public ISet<IEdge> Inputs { get; init; }
public ISet<IEdge> Outputs { get; init; }
public bool IsActive { get; set; }
public bool IsActive => CallbackActive();
protected Func<bool> CallbackActive;
private TextBlock? _text;
private Shape? _rect;
@@ -24,10 +26,11 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
private Shape? _bottomInner;
private Shape? _bottomOuter;
public Rebler(string label, double x, double y) {
public Rebler(string label, double x, double y, Func<bool> cbActive) {
CenterX = x;
CenterY = y;
Label = label;
CallbackActive = cbActive;
Inputs = new HashSet<IEdge>();
Outputs = new HashSet<IEdge>();
}