2020-06-03 07:31:06 +00:00
|
|
|
|
using Dirichlet.Numerics;
|
|
|
|
|
|
///
|
2020-05-26 08:28:40 +00:00
|
|
|
|
/// Copyright (c) 2020 Sensus Slovensko a.s.
|
|
|
|
|
|
///
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
|
using System.Drawing.Drawing2D;
|
|
|
|
|
|
|
|
|
|
|
|
namespace SchematicDrawing
|
|
|
|
|
|
{
|
|
|
|
|
|
public static class Const
|
|
|
|
|
|
{
|
2020-06-03 07:31:06 +00:00
|
|
|
|
public const int GridSize = 10;
|
2020-06-17 21:17:50 +00:00
|
|
|
|
public const int SecondaryStart = 10000;
|
2020-06-03 07:31:06 +00:00
|
|
|
|
public const int Vacuum = 1000000;
|
|
|
|
|
|
}
|
2020-05-26 08:28:40 +00:00
|
|
|
|
|
2020-06-03 07:31:06 +00:00
|
|
|
|
public enum Element
|
|
|
|
|
|
{
|
|
|
|
|
|
None = 0,
|
|
|
|
|
|
Body = 1, /// Item body (component image)
|
|
|
|
|
|
Label = 2, /// Item label
|
|
|
|
|
|
MeasuredVal = 4, /// Item measured value
|
|
|
|
|
|
Setpoint = 8, /// Item setpoint
|
|
|
|
|
|
Node = 16, /// A node of an item
|
|
|
|
|
|
Pipe = 32, /// Pipe between two nodes
|
2020-05-26 08:28:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public enum Shape
|
|
|
|
|
|
{
|
|
|
|
|
|
Ambient,
|
2022-01-21 15:08:03 +00:00
|
|
|
|
Clamping,
|
|
|
|
|
|
Cover,
|
2020-05-26 08:28:40 +00:00
|
|
|
|
Cross,
|
|
|
|
|
|
Div,
|
2022-01-21 15:08:03 +00:00
|
|
|
|
EmergencyStop,
|
2020-05-26 08:28:40 +00:00
|
|
|
|
FlowM,
|
|
|
|
|
|
Junction,
|
|
|
|
|
|
Knee,
|
2021-11-04 11:37:37 +00:00
|
|
|
|
ParallelFlowM,
|
2020-05-26 08:28:40 +00:00
|
|
|
|
PressM,
|
|
|
|
|
|
Pump,
|
|
|
|
|
|
PumpFM,
|
|
|
|
|
|
RegV,
|
2020-06-03 07:31:06 +00:00
|
|
|
|
Scale,
|
2020-05-26 08:28:40 +00:00
|
|
|
|
Sink,
|
|
|
|
|
|
Tank,
|
|
|
|
|
|
Tee,
|
|
|
|
|
|
TempM,
|
2022-01-21 15:08:03 +00:00
|
|
|
|
UniCB,
|
2020-06-03 07:31:06 +00:00
|
|
|
|
Vacuum,
|
2020-05-26 08:28:40 +00:00
|
|
|
|
Valve,
|
|
|
|
|
|
WaterM,
|
2022-04-14 11:41:53 +00:00
|
|
|
|
|
|
|
|
|
|
Count,
|
|
|
|
|
|
Custom,
|
2020-05-26 08:28:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public enum Sz
|
|
|
|
|
|
{
|
2020-06-03 07:31:06 +00:00
|
|
|
|
None,
|
2020-05-26 08:28:40 +00:00
|
|
|
|
S,
|
|
|
|
|
|
M,
|
|
|
|
|
|
L,
|
|
|
|
|
|
XL,
|
|
|
|
|
|
Count,
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public enum Orient
|
|
|
|
|
|
{
|
|
|
|
|
|
R,
|
|
|
|
|
|
Dn,
|
|
|
|
|
|
L,
|
|
|
|
|
|
Up,
|
|
|
|
|
|
Count,
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-06-03 07:31:06 +00:00
|
|
|
|
public enum RouteCouple
|
2020-05-26 08:28:40 +00:00
|
|
|
|
{
|
2020-06-03 07:31:06 +00:00
|
|
|
|
None,
|
|
|
|
|
|
OpenWhen1,
|
|
|
|
|
|
ClosedWhen1,
|
2020-05-26 08:28:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static class Utils
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Return coordinates of the vector in direction Orient
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="orient">Orient</param>
|
|
|
|
|
|
/// <returns>Vector</returns>
|
|
|
|
|
|
public static Point GetVect(Orient orient)
|
|
|
|
|
|
{
|
|
|
|
|
|
switch (orient)
|
|
|
|
|
|
{
|
|
|
|
|
|
default:
|
2020-06-03 07:31:06 +00:00
|
|
|
|
case Orient.R: return new Point(1, 0);
|
2020-05-26 08:28:40 +00:00
|
|
|
|
case Orient.Up: return new Point(0, -1);
|
2020-06-03 07:31:06 +00:00
|
|
|
|
case Orient.L: return new Point(-1, 0);
|
2020-05-26 08:28:40 +00:00
|
|
|
|
case Orient.Dn: return new Point(0, 1);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Return coordinates of the vector perpendicular to Orient
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="orient">Orient</param>
|
|
|
|
|
|
/// <returns>Perpendicular vector</returns>
|
|
|
|
|
|
public static Point GetNormalVect(Orient orient)
|
|
|
|
|
|
{
|
|
|
|
|
|
switch (orient)
|
|
|
|
|
|
{
|
|
|
|
|
|
default:
|
2020-06-03 07:31:06 +00:00
|
|
|
|
case Orient.R: return new Point(0, 1);
|
2020-05-26 08:28:40 +00:00
|
|
|
|
case Orient.Up: return new Point(1, 0);
|
2020-06-03 07:31:06 +00:00
|
|
|
|
case Orient.L: return new Point(0, -1);
|
2020-05-26 08:28:40 +00:00
|
|
|
|
case Orient.Dn: return new Point(-1, 0);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2020-06-03 07:31:06 +00:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Returns true when item is hidden (both X and Y coordinates are 0)
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="item">Drawing item</param>
|
|
|
|
|
|
/// <returns>true when hidden</returns>
|
|
|
|
|
|
public static bool IsHidden(IDrawingItem item)
|
|
|
|
|
|
{
|
|
|
|
|
|
return (item.X == 0) && (item.Y == 0);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Updates distances of graph edges of IRouteBasedDrewingItem (valve, pump, ...) after route chanage.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="route">Route</param>
|
|
|
|
|
|
/// <param name="item">Item</param>
|
|
|
|
|
|
public static void UpdateGraphEdges(UInt128 route, IRouteBasedDrawingItem item)
|
|
|
|
|
|
{
|
|
|
|
|
|
bool routeBit = (route & (((UInt128)1) << item.BitNr)) != 0;
|
|
|
|
|
|
foreach (var gedge in item.EdgesToSet) gedge.UpdateFromRoute(item.Inverted ? (!routeBit) : routeBit);
|
|
|
|
|
|
}
|
2020-05-26 08:28:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|