diff --git a/Elwig/App.xaml.cs b/Elwig/App.xaml.cs
index bb674d4..08d171b 100644
--- a/Elwig/App.xaml.cs
+++ b/Elwig/App.xaml.cs
@@ -47,8 +47,9 @@ namespace Elwig {
var cnx = s[3];
var empty = s[4];
var filling = s[5];
+ int? limit = s[6] == null ? null : int.Parse(s[6]);
if (type == "systec") {
- list.AddLast(new SystecScale(scaleNr, model, cnx, empty, filling));
+ list.AddLast(new SystecScale(scaleNr, model, cnx, empty, filling, limit));
}
} catch (Exception e) {
MessageBox.Show($"Unable to create scale {s[0]}:\n\n{e.Message}", "Scale Error", MessageBoxButton.OK, MessageBoxImage.Error);
diff --git a/Elwig/Helpers/Config.cs b/Elwig/Helpers/Config.cs
index 4d7e47a..a95ed67 100644
--- a/Elwig/Helpers/Config.cs
+++ b/Elwig/Helpers/Config.cs
@@ -48,7 +48,8 @@ namespace Elwig.Helpers {
if (ini != null) {
foreach (var s in ini.Sections.Where(s => s.SectionName.StartsWith("scale."))) {
ScaleList.AddLast(new string[] {
- s.SectionName[6..], s.Keys["type"], s.Keys["model"], s.Keys["connection"], s.Keys["empty"], s.Keys["filling"]
+ s.SectionName[6..], s.Keys["type"], s.Keys["model"], s.Keys["connection"],
+ s.Keys["empty"], s.Keys["filling"], s.Keys["limit"]
});
}
}
@@ -62,6 +63,7 @@ namespace Elwig.Helpers {
file.Write($"\r\n[scale.{s[0]}]\r\ntype = {s[1]}\r\nmodel = {s[2]}\r\nconnection = {s[3]}\r\n");
if (s[4] != null) file.Write($"empty = {s[4]}\r\n");
if (s[5] != null) file.Write($"filling = {s[5]}\r\n");
+ if (s[6] != null) file.Write($"limit = {s[6]}\r\n");
}
}
}
diff --git a/Elwig/Helpers/Weighing/IScale.cs b/Elwig/Helpers/Weighing/IScale.cs
index 51b2e5d..b13baf5 100644
--- a/Elwig/Helpers/Weighing/IScale.cs
+++ b/Elwig/Helpers/Weighing/IScale.cs
@@ -36,6 +36,11 @@ namespace Elwig.Helpers.Weighing {
///
bool HasFillingClearance { get; }
+ ///
+ /// The maximal configured weight limit of the scale in kg
+ ///
+ int? WeightLimit { get; }
+
///
/// Get the current weight on the scale without performing a weighing process
///
diff --git a/Elwig/Helpers/Weighing/SystecScale.cs b/Elwig/Helpers/Weighing/SystecScale.cs
index 10bcf83..b4fcb84 100644
--- a/Elwig/Helpers/Weighing/SystecScale.cs
+++ b/Elwig/Helpers/Weighing/SystecScale.cs
@@ -29,8 +29,9 @@ namespace Elwig.Helpers.Weighing {
public int ScaleNr { get; private set; }
public bool IsReady { get; private set; }
public bool HasFillingClearance { get; private set; }
+ public int? WeightLimit { get; private set; }
- public SystecScale(int scaleNr, string model, string connection, string? empty = null, string? fill = null) {
+ public SystecScale(int scaleNr, string model, string connection, string? empty = null, string? fill = null, int? limit = null) {
ScaleNr = scaleNr;
Model = model;
IsReady = true;
@@ -81,6 +82,9 @@ namespace Elwig.Helpers.Weighing {
EmptyDelay = int.Parse(parts[1]);
}
FillingClearanceMode = ConvertOutput(fill);
+ WeightLimit = limit;
+ if (FillingClearanceMode != null && WeightLimit == null)
+ throw new ArgumentException("Weight limit has to be set, if filling clearance supervision is enalbed");
Writer = new(stream, Encoding.ASCII, -1, true);
Reader = new(stream, Encoding.ASCII, false, -1, true);