diff --git a/Elwig/Documents/DeliveryNote.cs b/Elwig/Documents/DeliveryNote.cs index a95f45f..ea7bf04 100644 --- a/Elwig/Documents/DeliveryNote.cs +++ b/Elwig/Documents/DeliveryNote.cs @@ -181,8 +181,8 @@ namespace Elwig.Documents { } } else { var info = part.WeighingInfo; - weighing.Add(Italic("Waage:")) - .Add(Normal(" " + (part.ScaleId ?? "?") + ", ")) + weighing.Add(Italic("Waage/Terminal:")) + .Add(Normal(" " + (info.ScaleId ?? "?") + "/" + (part.ScaleTerminalId ?? "?") + ", ")) .Add(Italic("ID:")) .Add(Normal(" " + (info.Id ?? "?"))); if (info.Date != null || info.Time != null) diff --git a/Elwig/Helpers/Export/ElwigData.cs b/Elwig/Helpers/Export/ElwigData.cs index f8ab3d8..32f6c83 100644 --- a/Elwig/Helpers/Export/ElwigData.cs +++ b/Elwig/Helpers/Export/ElwigData.cs @@ -951,7 +951,7 @@ namespace Elwig.Helpers.Export { if (p.Unloading != null) obj["unloading"] = p.Unloading; if (p.Temperature != null) obj["temperature"] = p.Temperature; if (p.Acid != null) obj["acid"] = p.Acid; - if (p.ScaleId != null) obj["scale_id"] = p.ScaleId; + if (p.ScaleTerminalId != null) obj["scale_terminal"] = p.ScaleTerminalId; if (p.WeighingData != null) obj["weighing_data"] = JsonNode.Parse(p.WeighingData); if (p.WeighingReason != null) obj["weighing_reason"] = p.WeighingReason; return obj; @@ -1022,7 +1022,7 @@ namespace Elwig.Helpers.Export { Unloading = p["unloading"]?.AsValue().GetValue() ?? ((p["lesewagen"]?.AsValue().GetValue() ?? false) ? DeliveryPart.Pumped : null), Temperature = p["temperature"]?.AsValue().GetValue(), Acid = p["acid"]?.AsValue().GetValue(), - ScaleId = p["scale_id"]?.AsValue().GetValue(), + ScaleTerminalId = p["scale_terminal"]?.AsValue().GetValue() ?? p["scale_id"]?.AsValue().GetValue(), WeighingData = p["weighing_data"]?.AsObject().ToJsonString(Utils.JsonOpts), WeighingReason = p["weighing_reason"]?.AsValue().GetValue(), }, createdAt == null || modifiedAt == null ? null : diff --git a/Elwig/Helpers/Weighing/AveryEventScale.cs b/Elwig/Helpers/Weighing/AveryEventScale.cs index 3458079..bc1516c 100644 --- a/Elwig/Helpers/Weighing/AveryEventScale.cs +++ b/Elwig/Helpers/Weighing/AveryEventScale.cs @@ -9,9 +9,8 @@ namespace Elwig.Helpers.Weighing { public class AveryEventScale : Scale, IEventScale, IDisposable { public string Manufacturer => "Avery"; - public int InternalScaleNr => 1; public string Model { get; private set; } - public string ScaleId { get; private set; } + public string ScaleTerminalId { get; private set; } public bool IsReady { get; private set; } public bool HasFillingClearance { get; private set; } @@ -19,13 +18,11 @@ namespace Elwig.Helpers.Weighing { private bool IsRunning = true; private readonly Thread BackgroundThread; - private readonly string Connection; public AveryEventScale(string id, string model, string cnx, string? log = null, bool required = true) : base(cnx, null, null, null, log, true, !required) { - ScaleId = id; + ScaleTerminalId = id; Model = model; - Connection = cnx; IsReady = true; HasFillingClearance = false; Stream.WriteTimeout = -1; diff --git a/Elwig/Helpers/Weighing/GassnerScale.cs b/Elwig/Helpers/Weighing/GassnerEnqScale.cs similarity index 77% rename from Elwig/Helpers/Weighing/GassnerScale.cs rename to Elwig/Helpers/Weighing/GassnerEnqScale.cs index 32406bb..33aa3b8 100644 --- a/Elwig/Helpers/Weighing/GassnerScale.cs +++ b/Elwig/Helpers/Weighing/GassnerEnqScale.cs @@ -5,18 +5,17 @@ using System.Text; using System.Threading.Tasks; namespace Elwig.Helpers.Weighing { - public class GassnerScale : Scale, ICommandScale { + public class GassnerEnqScale : Scale, ICommandScale { public string Manufacturer => "Gassner"; - public int InternalScaleNr => 1; public string Model { get; private set; } - public string ScaleId { get; private set; } + public string ScaleTerminalId { get; private set; } public bool IsReady { get; private set; } public bool HasFillingClearance { get; private set; } - public GassnerScale(string id, string model, string cnx, string? empty = null, string? filling = null, int? limit = null, string? log = null) : + public GassnerEnqScale(string id, string model, string cnx, string? empty = null, string? filling = null, int? limit = null, string? log = null) : base(cnx, empty, filling, limit, log) { - ScaleId = id; + ScaleTerminalId = id; Model = model; IsReady = true; HasFillingClearance = false; @@ -24,10 +23,9 @@ namespace Elwig.Helpers.Weighing { Stream.ReadTimeout = 11000; } - protected Task SendCommand(char command) => SendCommand(Convert.ToByte(command)); + protected Task SendCommand(string command) => SendCommand(Encoding.ASCII.GetBytes(command)); - protected async Task SendCommand(byte command) { - byte[] cmd = [command]; + protected async Task SendCommand(byte[] cmd) { await Stream.WriteAsync(cmd); if (LogPath != null) await File.AppendAllTextAsync(LogPath, Encoding.ASCII.GetString(cmd)); } @@ -53,15 +51,15 @@ namespace Elwig.Helpers.Weighing { return line[1..^1]; } - protected async Task Weigh(bool incIdentNr, bool retry = true) { + protected async Task Weigh(int? internalScaleNr, bool incIdentNr, bool retry = true) { string record; try { - await SendCommand(incIdentNr ? '\x05' : '?'); + await SendCommand(incIdentNr ? "\x05" : "?"); record = await ReceiveResponse(); } catch (IOException) { if (!retry || Tcp == null) throw; ReconnectTcp(); - return await Weigh(incIdentNr, false); + return await Weigh(internalScaleNr, incIdentNr, false); } if (record.Length != 45) throw new FormatException("Invalid response from scale: Received record has invalid size"); @@ -80,6 +78,7 @@ namespace Elwig.Helpers.Weighing { GrossWeight = int.Parse(brutto), TareWeight = int.Parse(tara), NetWeight = int.Parse(netto), + ScaleId = scaleNr, WeighingId = identNr, FullWeighingId = identNr, Date = DateOnly.TryParseExact(date, "yyyyMMdd", out var d) ? d : null, @@ -87,12 +86,12 @@ namespace Elwig.Helpers.Weighing { }; } - public async Task Weigh() { - return await Weigh(true); + public async Task Weigh(int? scaleNr = null) { + return await Weigh(scaleNr, true); } - public async Task GetCurrentWeight() { - return await Weigh(false); + public async Task GetCurrentWeight(int? scaleNr = null) { + return await Weigh(scaleNr, false); } public async Task Empty() { @@ -126,8 +125,9 @@ namespace Elwig.Helpers.Weighing { await SetFillingClearance(false); } - public Task SetDateAndTime(DateTime dateTime) { - throw new NotImplementedException("Für Waagen vom Typ 'Gassner' ist diese Funktion noch nicht implementiert"); + public async Task SetDateAndTime(DateTime dateTime) { + await SendCommand($"C{dateTime:yyyyMMddHHmmss}\r"); + await ReceiveResponse(); } } } diff --git a/Elwig/Helpers/Weighing/ICommandScale.cs b/Elwig/Helpers/Weighing/ICommandScale.cs index 33f006a..92d1f7e 100644 --- a/Elwig/Helpers/Weighing/ICommandScale.cs +++ b/Elwig/Helpers/Weighing/ICommandScale.cs @@ -10,13 +10,13 @@ namespace Elwig.Helpers.Weighing { /// Get the current weight on the scale without performing a weighing process /// /// Result of the weighing process (probably without a weighing id) - Task GetCurrentWeight(); + Task GetCurrentWeight(int? scaleNr = null); /// /// Perform a weighing process /// /// Result of the weighing process (including a weighing id) - Task Weigh(); + Task Weigh(int? scaleNr = null); /// /// Empty the scale container or grant clearance to do so diff --git a/Elwig/Helpers/Weighing/IScale.cs b/Elwig/Helpers/Weighing/IScale.cs index 070ae89..6fa53ea 100644 --- a/Elwig/Helpers/Weighing/IScale.cs +++ b/Elwig/Helpers/Weighing/IScale.cs @@ -18,12 +18,7 @@ namespace Elwig.Helpers.Weighing { /// /// Unique identificator of the scale /// - string ScaleId { get; } - - /// - /// Internal identifying number of the scale in its system - /// - int InternalScaleNr { get; } + string ScaleTerminalId { get; } /// /// Indicates if the scale is currently processing a request or not diff --git a/Elwig/Helpers/Weighing/InvalidScale.cs b/Elwig/Helpers/Weighing/InvalidScale.cs index 7db66b7..47cad2b 100644 --- a/Elwig/Helpers/Weighing/InvalidScale.cs +++ b/Elwig/Helpers/Weighing/InvalidScale.cs @@ -5,8 +5,7 @@ namespace Elwig.Helpers.Weighing { public string Manufacturer => "NONE"; public string Model => "NONE"; - public string ScaleId => id; - public int InternalScaleNr => 0; + public string ScaleTerminalId => id; public bool IsReady => false; public bool HasFillingClearance => false; public int? WeightLimit => null; diff --git a/Elwig/Helpers/Weighing/Scale.cs b/Elwig/Helpers/Weighing/Scale.cs index 68b8dae..82cd62d 100644 --- a/Elwig/Helpers/Weighing/Scale.cs +++ b/Elwig/Helpers/Weighing/Scale.cs @@ -28,10 +28,10 @@ namespace Elwig.Helpers.Weighing { int? limit = config.Limit != null ? int.Parse(config.Limit) : null; if (config.Type == "SysTec-IT") { return new SysTecITScale(config.Id, config.Model!, config.Connection!, config.Empty, config.Filling, limit, config.Log); - } else if (config.Type == "Avery-Async") { + } else if (config.Type == "Gassner-Enq" || config.Type == "Gassner") { + return new GassnerEnqScale(config.Id, config.Model!, config.Connection!, config.Empty, config.Filling, limit, config.Log); + } else if (config.Type == "Avery-Event" || config.Type == "Avery-Async") { return new AveryEventScale(config.Id, config.Model!, config.Connection!, config.Log, config.Required); - } else if (config.Type == "Gassner") { - return new GassnerScale(config.Id, config.Model!, config.Connection!, config.Empty, config.Filling, limit, config.Log); } else { throw new ArgumentException($"Invalid scale type: \"{config.Type}\""); } diff --git a/Elwig/Helpers/Weighing/SysTecITScale.cs b/Elwig/Helpers/Weighing/SysTecITScale.cs index 7dc7bb3..5b1170a 100644 --- a/Elwig/Helpers/Weighing/SysTecITScale.cs +++ b/Elwig/Helpers/Weighing/SysTecITScale.cs @@ -8,15 +8,14 @@ namespace Elwig.Helpers.Weighing { public class SysTecITScale : Scale, ICommandScale { public string Manufacturer => "SysTec"; - public int InternalScaleNr => 1; public string Model { get; private set; } - public string ScaleId { get; private set; } + public string ScaleTerminalId { get; private set; } public bool IsReady { get; private set; } public bool HasFillingClearance { get; private set; } public SysTecITScale(string id, string model, string cnx, string? empty = null, string? filling = null, int? limit = null, string? log = null) : base(cnx, empty, filling, limit, log) { - ScaleId = id; + ScaleTerminalId = id; Model = model; IsReady = true; HasFillingClearance = false; @@ -74,15 +73,15 @@ namespace Elwig.Helpers.Weighing { return line[1..^3]; } - protected async Task Weigh(bool incIdentNr, bool retry = true) { + protected async Task Weigh(int internalScalNr, bool incIdentNr, bool retry = true) { string record; try { - await SendCommand(incIdentNr ? $"RN{InternalScaleNr}" : $"RM{InternalScaleNr}"); + await SendCommand(incIdentNr ? $"RN{internalScalNr}" : $"RM{internalScalNr}"); record = await ReceiveResponse(); } catch (IOException) { if (!retry || Tcp == null) throw; ReconnectTcp(); - return await Weigh(incIdentNr, false); + return await Weigh(internalScalNr, incIdentNr, false); } if (record.Length != 62) throw new FormatException("Invalid response from scale: Received record has invalid size"); @@ -114,6 +113,7 @@ namespace Elwig.Helpers.Weighing { GrossWeight = int.Parse(brutto), TareWeight = int.Parse(tara), NetWeight = int.Parse(netto), + ScaleId = scaleNr, WeighingId = identNr, FullWeighingId = identNr != null ? $"{parsedDate:yyyy-MM-dd}/{identNr}" : null, Date = parsedDate, @@ -121,12 +121,12 @@ namespace Elwig.Helpers.Weighing { }; } - public async Task Weigh() { - return await Weigh(true); + public async Task Weigh(int? scaleNr = 1) { + return await Weigh(scaleNr ?? 1, true); } - public async Task GetCurrentWeight() { - return await Weigh(false); + public async Task GetCurrentWeight(int? scaleNr = 1) { + return await Weigh(scaleNr ?? 1, false); } public async Task Empty() { diff --git a/Elwig/Helpers/Weighing/WeighingResult.cs b/Elwig/Helpers/Weighing/WeighingResult.cs index 5447a49..d69afbc 100644 --- a/Elwig/Helpers/Weighing/WeighingResult.cs +++ b/Elwig/Helpers/Weighing/WeighingResult.cs @@ -21,6 +21,11 @@ namespace Elwig.Helpers.Weighing { /// public int? NetWeight; + /// + /// Reported id of the scale + /// + public string? ScaleId; + /// /// Weighing id (or IdentNr) provided by the scale /// @@ -49,6 +54,7 @@ namespace Elwig.Helpers.Weighing { public readonly JsonObject ToJson() { var obj = new JsonObject(); + if (ScaleId != null) obj["scale"] = ScaleId; if (FullWeighingId != null) obj["id"] = FullWeighingId; if (WeighingId != null) obj["nr"] = int.Parse(WeighingId); if (Date != null) obj["date"] = $"{Date:yyyy-MM-dd}"; diff --git a/Elwig/Models/Entities/DeliveryPart.cs b/Elwig/Models/Entities/DeliveryPart.cs index 0eb5d82..9b94652 100644 --- a/Elwig/Models/Entities/DeliveryPart.cs +++ b/Elwig/Models/Entities/DeliveryPart.cs @@ -119,16 +119,17 @@ namespace Elwig.Models.Entities { public double? Acid { get; set; } [Column("scale_id")] - public string? ScaleId { get; set; } + public string? ScaleTerminalId { get; set; } [Column("weighing_data")] public string? WeighingData { get; set; } [NotMapped] - public (string? Id, int? Gross, int? Tare, int? Net, DateOnly? Date, TimeOnly? Time) WeighingInfo { + public (string? ScaleId, string? Id, int? Gross, int? Tare, int? Net, DateOnly? Date, TimeOnly? Time) WeighingInfo { get { try { var obj = JsonNode.Parse(WeighingData!)!.AsObject(); return ( + obj["scale"]?.AsValue().GetValue(), obj["id"]?.AsValue().GetValue(), obj["gross_weight"]?.AsValue().GetValue(), obj["tare_weight"]?.AsValue().GetValue(), @@ -137,7 +138,7 @@ namespace Elwig.Models.Entities { TimeOnly.TryParseExact(obj["time"]?.AsValue().GetValue(), ["HH:mm:ss", "HH:mm"], out var t) ? t : null ); } catch { - return (null, null, null, null, null, null); + return (null, null, null, null, null, null, null); } } } diff --git a/Elwig/Services/DeliveryService.cs b/Elwig/Services/DeliveryService.cs index 9d20349..b55bb6e 100644 --- a/Elwig/Services/DeliveryService.cs +++ b/Elwig/Services/DeliveryService.cs @@ -67,7 +67,7 @@ namespace Elwig.Services { vm.IsGebunden = p.IsGebunden; vm.Unloading = p.Unloading; - vm.ScaleId = p.ScaleId; + vm.ScaleTerminalId = p.ScaleTerminalId; vm.WeighingData = p.WeighingData; vm.ManualWeighingReason = p.WeighingReason; } @@ -515,7 +515,7 @@ namespace Elwig.Services { Weight = vm.Weight!.Value, IsManualWeighing = vm.IsManualWeighing, - ScaleId = vm.ScaleId, + ScaleTerminalId = vm.ScaleTerminalId, WeighingData = vm.WeighingData, WeighingReason = vm.ManualWeighingReason, }; diff --git a/Elwig/ViewModels/DeliveryAdminViewModel.cs b/Elwig/ViewModels/DeliveryAdminViewModel.cs index fa9c2bd..9d41b87 100644 --- a/Elwig/ViewModels/DeliveryAdminViewModel.cs +++ b/Elwig/ViewModels/DeliveryAdminViewModel.cs @@ -25,7 +25,7 @@ namespace Elwig.ViewModels { [ObservableProperty] private string? _manualWeighingReason; [ObservableProperty] - private string? _scaleId; + private string? _scaleTerminalId; [ObservableProperty] private string? _weighingData; diff --git a/Elwig/Windows/DeliveryAdminWindow.xaml.cs b/Elwig/Windows/DeliveryAdminWindow.xaml.cs index a714b2d..c305659 100644 --- a/Elwig/Windows/DeliveryAdminWindow.xaml.cs +++ b/Elwig/Windows/DeliveryAdminWindow.xaml.cs @@ -85,10 +85,10 @@ namespace Elwig.Windows { if (n < 3) WeighingCButton.Visibility = Visibility.Hidden; if (n < 4) WeighingDButton.Visibility = Visibility.Hidden; if (n == 1) WeighingAButton.Content = "Wiegen"; - if (n > 1) WeighingAButton.Content = $"Wiegen {App.CommandScales[0].ScaleId}"; - if (n >= 2) WeighingBButton.Content = $"Wiegen {App.CommandScales[1].ScaleId}"; - if (n >= 3) WeighingCButton.Content = $"Wiegen {App.CommandScales[2].ScaleId}"; - if (n >= 4) WeighingDButton.Content = $"Wiegen {App.CommandScales[3].ScaleId}"; + if (n > 1) WeighingAButton.Content = $"Wiegen {App.CommandScales[0].ScaleTerminalId}"; + if (n >= 2) WeighingBButton.Content = $"Wiegen {App.CommandScales[1].ScaleTerminalId}"; + if (n >= 3) WeighingCButton.Content = $"Wiegen {App.CommandScales[2].ScaleTerminalId}"; + if (n >= 4) WeighingDButton.Content = $"Wiegen {App.CommandScales[3].ScaleTerminalId}"; WeighingManualButton.Margin = new Thickness(10, 10 + n * 32, 10, 10); foreach (var s in App.EventScales) { s.WeighingEvent += Scale_Weighing; @@ -366,7 +366,7 @@ namespace Elwig.Windows { private void InitialInputs() { ViewModel.LastScaleError = null; ViewModel.WeighingData = null; - ViewModel.ScaleId = null; + ViewModel.ScaleTerminalId = null; ViewModel.ManualWeighingReason = null; ClearOriginalValues(); @@ -651,13 +651,13 @@ namespace Elwig.Windows { private void OnWeighingResult(IScale scale, WeighingResult res) { if ((res.NetWeight ?? 0) > 0 && res.FullWeighingId != null) { ViewModel.Weight = res.NetWeight; - ViewModel.ScaleId = scale.ScaleId; + ViewModel.ScaleTerminalId = scale.ScaleTerminalId; ViewModel.WeighingData = res.ToJson().ToJsonString(); ViewModel.ManualWeighingReason = null; ManualWeighingInput.IsChecked = false; } else { ViewModel.Weight = null; - ViewModel.ScaleId = null; + ViewModel.ScaleTerminalId = null; ViewModel.WeighingData = null; } ViewModel.LastScaleError = null; @@ -771,7 +771,7 @@ namespace Elwig.Windows { } private void EmptyScale() { - var scale = App.Scales.Where(s => s.ScaleId == ViewModel.ScaleId).FirstOrDefault(); + var scale = App.Scales.Where(s => s.ScaleTerminalId == ViewModel.ScaleTerminalId).FirstOrDefault(); if (scale is not ICommandScale cs) return; cs.Empty(); } @@ -953,7 +953,7 @@ namespace Elwig.Windows { ViewModel.Weight = res?.Item1; ManualWeighingInput.IsChecked = true; ViewModel.ManualWeighingReason = res?.Item2; - ViewModel.ScaleId = null; + ViewModel.ScaleTerminalId = null; ViewModel.WeighingData = null; } diff --git a/Tests/UnitTests/DocumentTests/DeliveryNoteTest.cs b/Tests/UnitTests/DocumentTests/DeliveryNoteTest.cs index 281bab5..98ab9d2 100644 --- a/Tests/UnitTests/DocumentTests/DeliveryNoteTest.cs +++ b/Tests/UnitTests/DocumentTests/DeliveryNoteTest.cs @@ -23,7 +23,7 @@ namespace Tests.UnitTests.DocumentTests { 1 Grüner Veltliner Qualitätswein 73 15,0 3 219 Herkunft: Österreich / Weinland / Niederösterreich / Matzner Hügel / Hohenruppersdorf / KG Hohenruppersdorf - Waage: 1, ID: 321 – 09:02, 01.10.2020 + Waage/Terminal: ?/1, ID: 321 – 09:02, 01.10.2020 Brutto: 3 219 kg – Tara: 0 kg – Netto: 3 219 kg – gerebelt gewogen """)); }); @@ -49,13 +49,13 @@ namespace Tests.UnitTests.DocumentTests { 1 Grüner Veltliner Qualitätswein 82 16,7 4 002 Herkunft: Österreich / Weinland / Niederösterreich / Matzner Hügel / Hohenruppersdorf / KG Hohenruppersdorf - Waage: ?, ID: ? (gerebelt gewogen) + Waage/Terminal: ?/?, ID: ? (gerebelt gewogen) """)); Assert.That(text, Contains.Substring(""" 2 Grüner Veltliner Qualitätswein 75 15,3 481 Herkunft: Österreich / Weinland / Niederösterreich / Matzner Hügel / Hohenruppersdorf / KG Hohenruppersdorf - Waage: ?, ID: ? (gerebelt gewogen) + Waage/Terminal: ?/?, ID: ? (gerebelt gewogen) """)); Assert.That(text, Contains.Substring("Gesamt: 81 16,5 4 483")); }); @@ -80,19 +80,19 @@ namespace Tests.UnitTests.DocumentTests { 1 Grüner Veltliner Wein 75 15,4 2 561 Herkunft: Österreich / Matzner Hügel / Hohenruppersdorf / KG Hohenruppersdorf - Waage: ?, ID: ? (gerebelt gewogen) + Waage/Terminal: ?/?, ID: ? (gerebelt gewogen) """)); Assert.That(text, Contains.Substring(""" 2 Grüner Veltliner Kabinett Wein 87 17,6 3 129 Herkunft: Österreich / Matzner Hügel / Hohenruppersdorf / KG Hohenruppersdorf - Waage: ?, ID: ? (gerebelt gewogen) + Waage/Terminal: ?/?, ID: ? (gerebelt gewogen) """)); Assert.That(text, Contains.Substring(""" 3 Grüner Veltliner Wein 79 16,1 1 280 Herkunft: Österreich / Matzner Hügel / Hohenruppersdorf / KG Hohenruppersdorf - Waage: ?, ID: ? (gerebelt gewogen) + Waage/Terminal: ?/?, ID: ? (gerebelt gewogen) """)); Assert.That(text, Contains.Substring("Gesamt: 81 16,5 6 970")); }); @@ -118,14 +118,14 @@ namespace Tests.UnitTests.DocumentTests { Bewirtschaftung: Bio (AT-BIO-302) Herkunft: Österreich / Wolkersdorfer Hochleithen / Wolkersdorf im Weinviertel / KG Wolkersdorf - Waage: ?, ID: ? (gerebelt gewogen) + Waage/Terminal: ?/?, ID: ? (gerebelt gewogen) """)); Assert.That(text, Contains.Substring(""" 2 Grüner Veltliner Qualitätswein 75 15,4 2 134 Bewirtschaftung: Bio (AT-BIO-302) Herkunft: Österreich / Weinland / Niederösterreich / Wolkersdorfer Hochleithen / Wolkersdorf im Weinviertel / KG Wolkersdorf - Waage: ?, ID: ? (gerebelt gewogen) + Waage/Terminal: ?/?, ID: ? (gerebelt gewogen) """)); Assert.That(text, Contains.Substring("Gesamt: 78 15,9 5 332")); }); @@ -152,12 +152,12 @@ namespace Tests.UnitTests.DocumentTests { Herkunft: Österreich / Weinland / Niederösterreich / Matzner Hügel / Hohenruppersdorf / KG Hohenruppersdorf Zu-/Abschläge: Geschädigte Trauben −10,00 % - Waage: ?, ID: ? (gerebelt gewogen) + Waage/Terminal: ?/?, ID: ? (gerebelt gewogen) 2 Grüner Veltliner Kabinett Kabinett 87 17,7 1 873 Herkunft: Österreich / Weinland / Niederösterreich / Matzner Hügel / Hohenruppersdorf / KG Hohenruppersdorf Zu-/Abschläge: Keine Voranmeldung −0,1000 €/kg - Waage: ?, ID: ? (gerebelt gewogen) + Waage/Terminal: ?/?, ID: ? (gerebelt gewogen) Gesamt: 87 17,6 4 860 """)); } diff --git a/Tests/UnitTests/WeighingTests/ScaleTestGrInzersdorfL246.cs b/Tests/UnitTests/WeighingTests/ScaleTestGrInzersdorfL246.cs index 66d3cdf..d063bec 100644 --- a/Tests/UnitTests/WeighingTests/ScaleTestGrInzersdorfL246.cs +++ b/Tests/UnitTests/WeighingTests/ScaleTestGrInzersdorfL246.cs @@ -31,16 +31,19 @@ namespace Tests.UnitTests.WeighingTests { Mock.Weight = 1235; Assert.That(await Scale!.GetCurrentWeight(), Is.EqualTo(new WeighingResult { GrossWeight = 1235, TareWeight = 0, NetWeight = 1235, + ScaleId = "1", Date = new DateOnly(2020, 10, 17), Time = new TimeOnly(14, 23), })); Mock.Weight = 1240; Assert.That(await Scale!.GetCurrentWeight(), Is.EqualTo(new WeighingResult { GrossWeight = 1240, TareWeight = 0, NetWeight = 1240, + ScaleId = "1", Date = new DateOnly(2020, 10, 17), Time = new TimeOnly(14, 23), })); Mock.Weight = 1245; Assert.That(await Scale!.GetCurrentWeight(), Is.EqualTo(new WeighingResult { GrossWeight = 1245, TareWeight = 0, NetWeight = 1245, + ScaleId = "1", Date = new DateOnly(2020, 10, 17), Time = new TimeOnly(14, 23), })); } @@ -50,19 +53,19 @@ namespace Tests.UnitTests.WeighingTests { Mock.Weight = 1235; Assert.That(await Scale!.Weigh(), Is.EqualTo(new WeighingResult { GrossWeight = 1235, TareWeight = 0, NetWeight = 1235, - WeighingId = "1", FullWeighingId = $"2020-10-17/1", + ScaleId = "1", WeighingId = "1", FullWeighingId = $"2020-10-17/1", Date = new DateOnly(2020, 10, 17), Time = new TimeOnly(14, 23), })); Mock.Weight = 3335; Assert.That(await Scale!.Weigh(), Is.EqualTo(new WeighingResult { GrossWeight = 3335, TareWeight = 0, NetWeight = 3335, - WeighingId = "2", FullWeighingId = $"2020-10-17/2", + ScaleId = "1", WeighingId = "2", FullWeighingId = $"2020-10-17/2", Date = new DateOnly(2020, 10, 17), Time = new TimeOnly(14, 23), })); Mock.Weight = 6420; Assert.That(await Scale!.Weigh(), Is.EqualTo(new WeighingResult { GrossWeight = 6420, TareWeight = 0, NetWeight = 6420, - WeighingId = "3", FullWeighingId = $"2020-10-17/3", + ScaleId = "1", WeighingId = "3", FullWeighingId = $"2020-10-17/3", Date = new DateOnly(2020, 10, 17), Time = new TimeOnly(14, 23), })); } diff --git a/Tests/UnitTests/WeighingTests/ScaleTestHaugsdorfDMA02.cs b/Tests/UnitTests/WeighingTests/ScaleTestHaugsdorfDMA02.cs index b315c1a..265873b 100644 --- a/Tests/UnitTests/WeighingTests/ScaleTestHaugsdorfDMA02.cs +++ b/Tests/UnitTests/WeighingTests/ScaleTestHaugsdorfDMA02.cs @@ -5,7 +5,7 @@ namespace Tests.UnitTests.WeighingTests { public class ScaleTestHaugsdorfDMA02 { private MockScale Mock; - private GassnerScale Scale; + private GassnerEnqScale Scale; [OneTimeSetUp] public void SetupScale() { @@ -32,29 +32,23 @@ namespace Tests.UnitTests.WeighingTests { Mock.Weight = 1234; Mock.Tare = 0; Assert.That(await Scale!.GetCurrentWeight(), Is.EqualTo(new WeighingResult { - GrossWeight = 1234, - TareWeight = 0, - NetWeight = 1234, - Date = new DateOnly(2020, 10, 15), - Time = new TimeOnly(12, 34), + GrossWeight = 1234, TareWeight = 0, NetWeight = 1234, + ScaleId = "1", + Date = new DateOnly(2020, 10, 15), Time = new TimeOnly(12, 34), })); Mock.Weight = 1235; Mock.Tare = 46; Assert.That(await Scale!.GetCurrentWeight(), Is.EqualTo(new WeighingResult { - GrossWeight = 1281, - TareWeight = 46, - NetWeight = 1235, - Date = new DateOnly(2020, 10, 15), - Time = new TimeOnly(12, 34), + GrossWeight = 1281, TareWeight = 46, NetWeight = 1235, + ScaleId = "1", + Date = new DateOnly(2020, 10, 15), Time = new TimeOnly(12, 34), })); Mock.Weight = 1236; Mock.Tare = 92; Assert.That(await Scale!.GetCurrentWeight(), Is.EqualTo(new WeighingResult { - GrossWeight = 1328, - TareWeight = 92, - NetWeight = 1236, - Date = new DateOnly(2020, 10, 15), - Time = new TimeOnly(12, 34), + GrossWeight = 1328, TareWeight = 92, NetWeight = 1236, + ScaleId = "1", + Date = new DateOnly(2020, 10, 15), Time = new TimeOnly(12, 34), })); } @@ -63,35 +57,23 @@ namespace Tests.UnitTests.WeighingTests { Mock.Weight = 1234; Mock.Tare = 92; Assert.That(await Scale!.Weigh(), Is.EqualTo(new WeighingResult { - GrossWeight = 1326, - TareWeight = 92, - NetWeight = 1234, - WeighingId = "1", - FullWeighingId = "1", - Date = new DateOnly(2020, 10, 15), - Time = new TimeOnly(12, 34), + GrossWeight = 1326, TareWeight = 92, NetWeight = 1234, + ScaleId = "1", WeighingId = "1", FullWeighingId = "1", + Date = new DateOnly(2020, 10, 15), Time = new TimeOnly(12, 34), })); Mock.Weight = 3333; Mock.Tare = 41; Assert.That(await Scale!.Weigh(), Is.EqualTo(new WeighingResult { - GrossWeight = 3374, - TareWeight = 41, - NetWeight = 3333, - WeighingId = "2", - FullWeighingId = "2", - Date = new DateOnly(2020, 10, 15), - Time = new TimeOnly(12, 34), + GrossWeight = 3374, TareWeight = 41, NetWeight = 3333, + ScaleId = "1", WeighingId = "2", FullWeighingId = "2", + Date = new DateOnly(2020, 10, 15), Time = new TimeOnly(12, 34), })); Mock.Weight = 4321; Mock.Tare = 0; Assert.That(await Scale!.Weigh(), Is.EqualTo(new WeighingResult { - GrossWeight = 4321, - TareWeight = 0, - NetWeight = 4321, - WeighingId = "3", - FullWeighingId = "3", - Date = new DateOnly(2020, 10, 15), - Time = new TimeOnly(12, 34), + GrossWeight = 4321, TareWeight = 0, NetWeight = 4321, + ScaleId = "1", WeighingId = "3", FullWeighingId = "3", + Date = new DateOnly(2020, 10, 15), Time = new TimeOnly(12, 34), })); } diff --git a/Tests/UnitTests/WeighingTests/ScaleTestMatzenIT3000A.cs b/Tests/UnitTests/WeighingTests/ScaleTestMatzenIT3000A.cs index b8810d4..c1ea599 100644 --- a/Tests/UnitTests/WeighingTests/ScaleTestMatzenIT3000A.cs +++ b/Tests/UnitTests/WeighingTests/ScaleTestMatzenIT3000A.cs @@ -31,16 +31,19 @@ namespace Tests.UnitTests.WeighingTests { Mock.Weight = 1234; Assert.That(await Scale!.GetCurrentWeight(), Is.EqualTo(new WeighingResult { GrossWeight = 1234, TareWeight = 0, NetWeight = 1234, + ScaleId = "1", Date = new DateOnly(2020, 10, 15), Time = new TimeOnly(12, 34), })); Mock.Weight = 1235; Assert.That(await Scale!.GetCurrentWeight(), Is.EqualTo(new WeighingResult { GrossWeight = 1235, TareWeight = 0, NetWeight = 1235, + ScaleId = "1", Date = new DateOnly(2020, 10, 15), Time = new TimeOnly(12, 34), })); Mock.Weight = 1236; Assert.That(await Scale!.GetCurrentWeight(), Is.EqualTo(new WeighingResult { GrossWeight = 1236, TareWeight = 0, NetWeight = 1236, + ScaleId = "1", Date = new DateOnly(2020, 10, 15), Time = new TimeOnly(12, 34), })); } @@ -50,19 +53,19 @@ namespace Tests.UnitTests.WeighingTests { Mock.Weight = 1234; Assert.That(await Scale!.Weigh(), Is.EqualTo(new WeighingResult { GrossWeight = 1234, TareWeight = 0, NetWeight = 1234, - WeighingId = "1", FullWeighingId = $"2020-10-15/1", + ScaleId = "1", WeighingId = "1", FullWeighingId = $"2020-10-15/1", Date = new DateOnly(2020, 10, 15), Time = new TimeOnly(12, 34), })); Mock.Weight = 3333; Assert.That(await Scale!.Weigh(), Is.EqualTo(new WeighingResult { GrossWeight = 3333, TareWeight = 0, NetWeight = 3333, - WeighingId = "2", FullWeighingId = $"2020-10-15/2", + ScaleId = "1", WeighingId = "2", FullWeighingId = $"2020-10-15/2", Date = new DateOnly(2020, 10, 15), Time = new TimeOnly(12, 34), })); Mock.Weight = 4321; Assert.That(await Scale!.Weigh(), Is.EqualTo(new WeighingResult { GrossWeight = 4321, TareWeight = 0, NetWeight = 4321, - WeighingId = "3", FullWeighingId = $"2020-10-15/3", + ScaleId = "1", WeighingId = "3", FullWeighingId = $"2020-10-15/3", Date = new DateOnly(2020, 10, 15), Time = new TimeOnly(12, 34), })); } diff --git a/Tests/UnitTests/WeighingTests/ScaleTestSitzendorfDMA03Baby.cs b/Tests/UnitTests/WeighingTests/ScaleTestSitzendorfDMA03Baby.cs index 96b24f7..76743d9 100644 --- a/Tests/UnitTests/WeighingTests/ScaleTestSitzendorfDMA03Baby.cs +++ b/Tests/UnitTests/WeighingTests/ScaleTestSitzendorfDMA03Baby.cs @@ -5,7 +5,7 @@ namespace Tests.UnitTests.WeighingTests { public class ScaleTestSitzendorfDMA03Baby { private MockScale Mock; - private GassnerScale Scale; + private GassnerEnqScale Scale; [OneTimeSetUp] public void SetupScale() { @@ -32,29 +32,23 @@ namespace Tests.UnitTests.WeighingTests { Mock.Weight = 1234; Mock.Tare = 0; Assert.That(await Scale!.GetCurrentWeight(), Is.EqualTo(new WeighingResult { - GrossWeight = 1234, - TareWeight = 0, - NetWeight = 1234, - Date = new DateOnly(2020, 10, 15), - Time = new TimeOnly(12, 34), + GrossWeight = 1234, TareWeight = 0, NetWeight = 1234, + ScaleId = "1", + Date = new DateOnly(2020, 10, 15), Time = new TimeOnly(12, 34), })); Mock.Weight = 1235; Mock.Tare = 46; Assert.That(await Scale!.GetCurrentWeight(), Is.EqualTo(new WeighingResult { - GrossWeight = 1281, - TareWeight = 46, - NetWeight = 1235, - Date = new DateOnly(2020, 10, 15), - Time = new TimeOnly(12, 34), + GrossWeight = 1281, TareWeight = 46, NetWeight = 1235, + ScaleId = "1", + Date = new DateOnly(2020, 10, 15), Time = new TimeOnly(12, 34), })); Mock.Weight = 1236; Mock.Tare = 92; Assert.That(await Scale!.GetCurrentWeight(), Is.EqualTo(new WeighingResult { - GrossWeight = 1328, - TareWeight = 92, - NetWeight = 1236, - Date = new DateOnly(2020, 10, 15), - Time = new TimeOnly(12, 34), + GrossWeight = 1328, TareWeight = 92, NetWeight = 1236, + ScaleId = "1", + Date = new DateOnly(2020, 10, 15), Time = new TimeOnly(12, 34), })); } @@ -63,35 +57,23 @@ namespace Tests.UnitTests.WeighingTests { Mock.Weight = 1234; Mock.Tare = 92; Assert.That(await Scale!.Weigh(), Is.EqualTo(new WeighingResult { - GrossWeight = 1326, - TareWeight = 92, - NetWeight = 1234, - WeighingId = "1", - FullWeighingId = "1", - Date = new DateOnly(2020, 10, 15), - Time = new TimeOnly(12, 34), + GrossWeight = 1326, TareWeight = 92, NetWeight = 1234, + ScaleId = "1", WeighingId = "1", FullWeighingId = "1", + Date = new DateOnly(2020, 10, 15), Time = new TimeOnly(12, 34), })); Mock.Weight = 3333; Mock.Tare = 41; Assert.That(await Scale!.Weigh(), Is.EqualTo(new WeighingResult { - GrossWeight = 3374, - TareWeight = 41, - NetWeight = 3333, - WeighingId = "2", - FullWeighingId = "2", - Date = new DateOnly(2020, 10, 15), - Time = new TimeOnly(12, 34), + GrossWeight = 3374, TareWeight = 41, NetWeight = 3333, + ScaleId = "1", WeighingId = "2", FullWeighingId = "2", + Date = new DateOnly(2020, 10, 15), Time = new TimeOnly(12, 34), })); Mock.Weight = 4321; Mock.Tare = 0; Assert.That(await Scale!.Weigh(), Is.EqualTo(new WeighingResult { - GrossWeight = 4321, - TareWeight = 0, - NetWeight = 4321, - WeighingId = "3", - FullWeighingId = "3", - Date = new DateOnly(2020, 10, 15), - Time = new TimeOnly(12, 34), + GrossWeight = 4321, TareWeight = 0, NetWeight = 4321, + ScaleId = "1", WeighingId = "3", FullWeighingId = "3", + Date = new DateOnly(2020, 10, 15), Time = new TimeOnly(12, 34), })); } diff --git a/Tests/UnitTests/WeighingTests/ScaleTestWolkersdorfIT6000E.cs b/Tests/UnitTests/WeighingTests/ScaleTestWolkersdorfIT6000E.cs index e866557..feba11c 100644 --- a/Tests/UnitTests/WeighingTests/ScaleTestWolkersdorfIT6000E.cs +++ b/Tests/UnitTests/WeighingTests/ScaleTestWolkersdorfIT6000E.cs @@ -40,21 +40,25 @@ namespace Tests.UnitTests.WeighingTests { MockA.Weight = 1234; Assert.That(await ScaleA!.GetCurrentWeight(), Is.EqualTo(new WeighingResult { GrossWeight = 1234, TareWeight = 0, NetWeight = 1234, + ScaleId = "1", Date = new DateOnly(2020, 10, 8), Time = new TimeOnly(8, 47), })); MockB.Weight = 3456; Assert.That(await ScaleB!.GetCurrentWeight(), Is.EqualTo(new WeighingResult { GrossWeight = 3456, TareWeight = 0, NetWeight = 3456, + ScaleId = "1", Date = new DateOnly(2020, 10, 8), Time = new TimeOnly(8, 47), })); MockA.Weight = 1236; Assert.That(await ScaleA!.GetCurrentWeight(), Is.EqualTo(new WeighingResult { GrossWeight = 1236, TareWeight = 0, NetWeight = 1236, + ScaleId = "1", Date = new DateOnly(2020, 10, 8), Time = new TimeOnly(8, 47), })); MockB.Weight = 3457; Assert.That(await ScaleB!.GetCurrentWeight(), Is.EqualTo(new WeighingResult { GrossWeight = 3457, TareWeight = 0, NetWeight = 3457, + ScaleId = "1", Date = new DateOnly(2020, 10, 8), Time = new TimeOnly(8, 47), })); } @@ -64,25 +68,25 @@ namespace Tests.UnitTests.WeighingTests { MockA.Weight = 1234; Assert.That(await ScaleA!.Weigh(), Is.EqualTo(new WeighingResult { GrossWeight = 1234, TareWeight = 0, NetWeight = 1234, - WeighingId = "1", FullWeighingId = $"2020-10-08/1", + ScaleId = "1", WeighingId = "1", FullWeighingId = $"2020-10-08/1", Date = new DateOnly(2020, 10, 8), Time = new TimeOnly(8, 47), })); MockB.Weight = 3456; Assert.That(await ScaleB!.Weigh(), Is.EqualTo(new WeighingResult { GrossWeight = 3456, TareWeight = 0, NetWeight = 3456, - WeighingId = "1", FullWeighingId = $"2020-10-08/1", + ScaleId = "1", WeighingId = "1", FullWeighingId = $"2020-10-08/1", Date = new DateOnly(2020, 10, 8), Time = new TimeOnly(8, 47), })); MockA.Weight = 4321; Assert.That(await ScaleA!.Weigh(), Is.EqualTo(new WeighingResult { GrossWeight = 4321, TareWeight = 0, NetWeight = 4321, - WeighingId = "2", FullWeighingId = $"2020-10-08/2", + ScaleId = "1", WeighingId = "2", FullWeighingId = $"2020-10-08/2", Date = new DateOnly(2020, 10, 8), Time = new TimeOnly(8, 47), })); MockB.Weight = 3333; Assert.That(await ScaleB!.Weigh(), Is.EqualTo(new WeighingResult { GrossWeight = 3333, TareWeight = 0, NetWeight = 3333, - WeighingId = "2", FullWeighingId = $"2020-10-08/2", + ScaleId = "1", WeighingId = "2", FullWeighingId = $"2020-10-08/2", Date = new DateOnly(2020, 10, 8), Time = new TimeOnly(8, 47), })); }