Add status bar in DeliveryAdminWindow
This commit is contained in:
@ -10,6 +10,7 @@ using System.Net.Sockets;
|
||||
using Elwig.Dialogs;
|
||||
using System.Text;
|
||||
using System.Numerics;
|
||||
using Elwig.Models;
|
||||
|
||||
namespace Elwig.Helpers {
|
||||
public static partial class Utils {
|
||||
@ -21,6 +22,7 @@ namespace Elwig.Helpers {
|
||||
|
||||
public static readonly Regex SerialRegex = GeneratedSerialRegex();
|
||||
public static readonly Regex TcpRegex = GeneratedTcpRegex();
|
||||
public static readonly Regex PartialDateRegex = GeneratedPartialDateRegex();
|
||||
|
||||
[GeneratedRegex("^serial://([A-Za-z0-9]+):([0-9]+)(,([5-9]),([NOEMSnoems]),(0|1|1\\.5|2|))?$", RegexOptions.Compiled)]
|
||||
private static partial Regex GeneratedSerialRegex();
|
||||
@ -28,6 +30,9 @@ namespace Elwig.Helpers {
|
||||
[GeneratedRegex("^tcp://([A-Za-z0-9._-]+):([0-9]+)$", RegexOptions.Compiled)]
|
||||
private static partial Regex GeneratedTcpRegex();
|
||||
|
||||
[GeneratedRegex(@"^(0?[1-9]|[12][0-9]|3[01])\.(0?[1-9]|1[0-2])\.$", RegexOptions.Compiled)]
|
||||
private static partial Regex GeneratedPartialDateRegex();
|
||||
|
||||
private static readonly ushort[] Crc16ModbusTable = {
|
||||
0x0000, 0xC0C1, 0xC181, 0x0140, 0xC301, 0x03C0, 0x0280, 0xC241,
|
||||
0xC601, 0x06C0, 0x0780, 0xC741, 0x0500, 0xC5C1, 0xC481, 0x0440,
|
||||
@ -242,5 +247,15 @@ namespace Elwig.Helpers {
|
||||
0 => "\u00b1", // plus minus
|
||||
> 0 => "+",
|
||||
};
|
||||
|
||||
public static double AggregateDeliveryPartsKmw(IEnumerable<DeliveryPart> parts)
|
||||
=> parts.Aggregate(
|
||||
(Weight: 0, Kmw: 0.0),
|
||||
(sum, item) => (
|
||||
sum.Weight + item.Weight,
|
||||
(sum.Kmw * sum.Weight + item.Kmw * item.Weight) / (sum.Weight + item.Weight)
|
||||
),
|
||||
sum => sum.Kmw
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user