Add weight limit to scale
This commit is contained in:
@ -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);
|
||||
|
@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -36,6 +36,11 @@ namespace Elwig.Helpers.Weighing {
|
||||
/// </summary>
|
||||
bool HasFillingClearance { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The maximal configured weight limit of the scale in kg
|
||||
/// </summary>
|
||||
int? WeightLimit { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Get the current weight on the scale without performing a weighing process
|
||||
/// </summary>
|
||||
|
@ -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);
|
||||
|
Reference in New Issue
Block a user