From 092c5788a459ba6c9e3d7088705e4ab09b6357e5 Mon Sep 17 00:00:00 2001 From: Lorenz Stechauner Date: Fri, 23 Feb 2024 17:46:32 +0100 Subject: [PATCH] Weighing: Fix Baden scale --- .../{SchemberEventScale.cs => AveryEventScale.cs} | 8 ++++---- Elwig/Helpers/Weighing/Scale.cs | 4 ++-- Installer/Files/config.ini | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) rename Elwig/Helpers/Weighing/{SchemberEventScale.cs => AveryEventScale.cs} (87%) diff --git a/Elwig/Helpers/Weighing/SchemberEventScale.cs b/Elwig/Helpers/Weighing/AveryEventScale.cs similarity index 87% rename from Elwig/Helpers/Weighing/SchemberEventScale.cs rename to Elwig/Helpers/Weighing/AveryEventScale.cs index b84c6ef..56e0796 100644 --- a/Elwig/Helpers/Weighing/SchemberEventScale.cs +++ b/Elwig/Helpers/Weighing/AveryEventScale.cs @@ -6,9 +6,9 @@ using System.Threading.Tasks; using System.Windows; namespace Elwig.Helpers.Weighing { - public class SchemberEventScale : Scale, IEventScale, IDisposable { + public class AveryEventScale : Scale, IEventScale, IDisposable { - public string Manufacturer => "Schember"; + public string Manufacturer => "Avery"; public int InternalScaleNr => 1; public string Model { get; private set; } public string ScaleId { get; private set; } @@ -20,7 +20,7 @@ namespace Elwig.Helpers.Weighing { private bool IsRunning = true; private readonly Thread BackgroundThread; - public SchemberEventScale(string id, string model, string cnx, string? empty = null, string? filling = null, int? limit = null, string? log = null) : + public AveryEventScale(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; Model = model; @@ -60,7 +60,7 @@ namespace Elwig.Helpers.Weighing { line = await reader.ReadLineAsync(); if (LogPath != null) await File.AppendAllTextAsync(LogPath, $"{line}\r\n"); } - if (line == null || line.Length != 32 || line[0] != ' ' || line[9] != ' ' || line[15] != ' ' || line[20] != ' ') { + if (line == null || line.Length != 33 || line[0] != ' ' || line[9] != ' ' || line[15] != ' ' || line[20] != ' ' || line[32] != ' ') { throw new IOException($"Invalid event from scale: '{line}'"); } diff --git a/Elwig/Helpers/Weighing/Scale.cs b/Elwig/Helpers/Weighing/Scale.cs index 4a9f0f1..5981f3b 100644 --- a/Elwig/Helpers/Weighing/Scale.cs +++ b/Elwig/Helpers/Weighing/Scale.cs @@ -24,8 +24,8 @@ 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 == "Schember-Async") { - return new SchemberEventScale(config.Id, config.Model!, config.Connection!, config.Empty, config.Filling, limit, config.Log); + } else if (config.Type == "Avery-Async") { + return new AveryEventScale(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/Installer/Files/config.ini b/Installer/Files/config.ini index ae5e46f..6108064 100644 --- a/Installer/Files/config.ini +++ b/Installer/Files/config.ini @@ -22,7 +22,7 @@ file = database.sqlite3 ;log = waage.log ;[scale.B] -;type = Schember-Async +;type = Avery-Async ;model = L320 ;connection = tcp://10.0.0.1:1234 ;empty = OUT1:3000