Add Tanks 1-5
This commit is contained in:
@@ -35,6 +35,7 @@ namespace PamhagenSysCtrl.Helpers {
|
||||
public FillState FillLevelT7 => Sensors.FillingLevelTanks[6];
|
||||
public FillState FillLevelT8 => Sensors.FillingLevelTanks[7];
|
||||
public FillState FillLevelT9 => Sensors.FillingLevelTanks[8];
|
||||
public FillState[] TankFillLevels => Sensors.FillingLevelTanks;
|
||||
public double GradationOe => Sensors.GradationOe;
|
||||
public MotorState PresseQuerSchnecke => Sensors.PresseQuerSchnecke;
|
||||
|
||||
|
||||
@@ -22,6 +22,16 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
return p;
|
||||
}
|
||||
|
||||
public Inlet CreateInlet(INode start, ISink end) {
|
||||
Nodes.Add(start);
|
||||
Nodes.Add(end);
|
||||
var p = new Inlet(start, end, start.CenterX > end.CenterX);
|
||||
start.Outputs.Add(p);
|
||||
end.Inputs.Add(p);
|
||||
Edges.Add(p);
|
||||
return p;
|
||||
}
|
||||
|
||||
public Path? GetPath(INode start, INode end, Func<INode, bool>? valid = null) {
|
||||
if (!Nodes.Contains(start) || !Nodes.Contains(end)) throw new ArgumentException("Start/end node not contained in graph");
|
||||
valid ??= a => true;
|
||||
@@ -35,8 +45,11 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
}
|
||||
|
||||
var p = GetPath(o.End, end, valid);
|
||||
if (p != null && (path == null || p.Value.Hops.Count() + 1 < path.Value.Hops.Count())) {
|
||||
path = new(start, [(o, o.End), ..p.Value.Hops]);
|
||||
if (p != null) {
|
||||
var p2 = new Path(start, [(o, o.End), .. p.Value.Hops]);
|
||||
if (path == null || p2.Length < path.Value.Length) {
|
||||
path = p2;
|
||||
}
|
||||
}
|
||||
}
|
||||
return path != null ? new(start, path.Value.Hops) : null;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
public interface ISink : INode {
|
||||
public double TopY { get; }
|
||||
public bool IsFull { get; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
public class Inlet : IEdge {
|
||||
|
||||
public INode Start { get; set; }
|
||||
public INode End => Sink;
|
||||
public ISink Sink { get; set; }
|
||||
public bool Orientation { get; set; }
|
||||
public bool Highlight { get; set; }
|
||||
|
||||
private Line? _outer1;
|
||||
private Line? _outer2;
|
||||
private Line? _inner1;
|
||||
private Line? _inner2;
|
||||
|
||||
public Inlet(INode start, ISink end, bool orientation = false) {
|
||||
Start = start;
|
||||
Sink = end;
|
||||
Orientation = orientation;
|
||||
}
|
||||
|
||||
public void Draw(Canvas canvas) {
|
||||
var x1 = Start.CenterX;
|
||||
var y1 = Start.CenterY;
|
||||
var x2 = Start.CenterX;
|
||||
var y2 = Sink.TopY - 10;
|
||||
var x3 = Start.CenterX + (Orientation ? -10 : 10);
|
||||
var y3 = Sink.TopY + 10;
|
||||
_outer1 = new Line() {
|
||||
X1 = x1,
|
||||
Y1 = y1,
|
||||
X2 = x2,
|
||||
Y2 = y2,
|
||||
StrokeThickness = 10,
|
||||
Stroke = Brushes.Black,
|
||||
StrokeStartLineCap = PenLineCap.Square,
|
||||
StrokeEndLineCap = PenLineCap.Round,
|
||||
};
|
||||
_inner1 = new Line() {
|
||||
X1 = x1,
|
||||
Y1 = y1,
|
||||
X2 = x2,
|
||||
Y2 = y2,
|
||||
StrokeThickness = 6,
|
||||
Stroke = Brushes.DarkGray,
|
||||
StrokeStartLineCap = PenLineCap.Square,
|
||||
StrokeEndLineCap = PenLineCap.Round,
|
||||
};
|
||||
_outer2 = new Line() {
|
||||
X1 = x2,
|
||||
Y1 = y2,
|
||||
X2 = x3,
|
||||
Y2 = y3,
|
||||
StrokeThickness = 10,
|
||||
Stroke = Brushes.Black,
|
||||
StrokeStartLineCap = PenLineCap.Round,
|
||||
StrokeEndLineCap = PenLineCap.Flat,
|
||||
};
|
||||
_inner2 = new Line() {
|
||||
X1 = x2,
|
||||
Y1 = y2,
|
||||
X2 = x3,
|
||||
Y2 = y3,
|
||||
StrokeThickness = 6,
|
||||
Stroke = Brushes.DarkGray,
|
||||
StrokeStartLineCap = PenLineCap.Round,
|
||||
StrokeEndLineCap = PenLineCap.Flat,
|
||||
};
|
||||
canvas.Children.Add(_outer1);
|
||||
canvas.Children.Add(_outer2);
|
||||
canvas.Children.Add(_inner1);
|
||||
canvas.Children.Add(_inner2);
|
||||
}
|
||||
|
||||
public bool Update(double x, double y) {
|
||||
_inner1?.Stroke = Highlight ? Brushes.Green : Brushes.DarkGray;
|
||||
_inner2?.Stroke = Highlight ? Brushes.Green : Brushes.DarkGray;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,8 @@
|
||||
namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
public record struct Path(INode Start, IEnumerable<(IEdge Edge, INode Node)> Hops);
|
||||
public record struct Path(
|
||||
INode Start,
|
||||
IEnumerable<(IEdge Edge, INode Node)> Hops)
|
||||
{
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,16 @@
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
class Tank : INode, ISink, ISource {
|
||||
|
||||
public const double WIDTH = 60;
|
||||
public const double HEIGHT = 100;
|
||||
|
||||
public double CenterX { get; set; }
|
||||
public double CenterY { get; set; }
|
||||
public double TopY => CenterY - HEIGHT / 2;
|
||||
public string Label { get; set; }
|
||||
public bool IsFull => CallbackIsFull();
|
||||
public bool IsFilled => CallbackIsFilled();
|
||||
@@ -26,11 +32,21 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
}
|
||||
|
||||
public void Draw(Canvas canvas) {
|
||||
|
||||
var rect = new Rectangle() {
|
||||
Width = WIDTH,
|
||||
Height = HEIGHT,
|
||||
Stroke = Brushes.Black,
|
||||
StrokeThickness = 2,
|
||||
Fill = Brushes.White,
|
||||
};
|
||||
rect.SetValue(Canvas.LeftProperty, CenterX - WIDTH / 2);
|
||||
rect.SetValue(Canvas.TopProperty, CenterY - HEIGHT / 2);
|
||||
canvas.Children.Add(rect);
|
||||
}
|
||||
|
||||
public bool Update(double x, double y) {
|
||||
return false;
|
||||
var hover = Math.Abs(x - CenterX) <= WIDTH / 2 && Math.Abs(y - CenterY) <= HEIGHT / 2;
|
||||
return hover;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user