Weighing: Differentiate between scale and terminal
This commit is contained in:
@@ -181,8 +181,8 @@ namespace Elwig.Documents {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var info = part.WeighingInfo;
|
var info = part.WeighingInfo;
|
||||||
weighing.Add(Italic("Waage:"))
|
weighing.Add(Italic("Waage/Terminal:"))
|
||||||
.Add(Normal(" " + (part.ScaleId ?? "?") + ", "))
|
.Add(Normal(" " + (info.ScaleId ?? "1") + "/" + (part.ScaleTerminalId ?? "?") + ", "))
|
||||||
.Add(Italic("ID:"))
|
.Add(Italic("ID:"))
|
||||||
.Add(Normal(" " + (info.Id ?? "?")));
|
.Add(Normal(" " + (info.Id ?? "?")));
|
||||||
if (info.Date != null || info.Time != null)
|
if (info.Date != null || info.Time != null)
|
||||||
|
|||||||
@@ -951,7 +951,7 @@ namespace Elwig.Helpers.Export {
|
|||||||
if (p.Unloading != null) obj["unloading"] = p.Unloading;
|
if (p.Unloading != null) obj["unloading"] = p.Unloading;
|
||||||
if (p.Temperature != null) obj["temperature"] = p.Temperature;
|
if (p.Temperature != null) obj["temperature"] = p.Temperature;
|
||||||
if (p.Acid != null) obj["acid"] = p.Acid;
|
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.WeighingData != null) obj["weighing_data"] = JsonNode.Parse(p.WeighingData);
|
||||||
if (p.WeighingReason != null) obj["weighing_reason"] = p.WeighingReason;
|
if (p.WeighingReason != null) obj["weighing_reason"] = p.WeighingReason;
|
||||||
return obj;
|
return obj;
|
||||||
@@ -1022,7 +1022,7 @@ namespace Elwig.Helpers.Export {
|
|||||||
Unloading = p["unloading"]?.AsValue().GetValue<string>() ?? ((p["lesewagen"]?.AsValue().GetValue<bool>() ?? false) ? DeliveryPart.Pumped : null),
|
Unloading = p["unloading"]?.AsValue().GetValue<string>() ?? ((p["lesewagen"]?.AsValue().GetValue<bool>() ?? false) ? DeliveryPart.Pumped : null),
|
||||||
Temperature = p["temperature"]?.AsValue().GetValue<double>(),
|
Temperature = p["temperature"]?.AsValue().GetValue<double>(),
|
||||||
Acid = p["acid"]?.AsValue().GetValue<double>(),
|
Acid = p["acid"]?.AsValue().GetValue<double>(),
|
||||||
ScaleId = p["scale_id"]?.AsValue().GetValue<string>(),
|
ScaleTerminalId = p["scale_terminal"]?.AsValue().GetValue<string>() ?? p["scale_id"]?.AsValue().GetValue<string>(),
|
||||||
WeighingData = p["weighing_data"]?.AsObject().ToJsonString(Utils.JsonOpts),
|
WeighingData = p["weighing_data"]?.AsObject().ToJsonString(Utils.JsonOpts),
|
||||||
WeighingReason = p["weighing_reason"]?.AsValue().GetValue<string>(),
|
WeighingReason = p["weighing_reason"]?.AsValue().GetValue<string>(),
|
||||||
}, createdAt == null || modifiedAt == null ? null :
|
}, createdAt == null || modifiedAt == null ? null :
|
||||||
|
|||||||
@@ -9,9 +9,8 @@ namespace Elwig.Helpers.Weighing {
|
|||||||
public class AveryEventScale : Scale, IEventScale, IDisposable {
|
public class AveryEventScale : Scale, IEventScale, IDisposable {
|
||||||
|
|
||||||
public string Manufacturer => "Avery";
|
public string Manufacturer => "Avery";
|
||||||
public int InternalScaleNr => 1;
|
|
||||||
public string Model { get; private set; }
|
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 IsReady { get; private set; }
|
||||||
public bool HasFillingClearance { get; private set; }
|
public bool HasFillingClearance { get; private set; }
|
||||||
|
|
||||||
@@ -19,13 +18,11 @@ namespace Elwig.Helpers.Weighing {
|
|||||||
|
|
||||||
private bool IsRunning = true;
|
private bool IsRunning = true;
|
||||||
private readonly Thread BackgroundThread;
|
private readonly Thread BackgroundThread;
|
||||||
private readonly string Connection;
|
|
||||||
|
|
||||||
public AveryEventScale(string id, string model, string cnx, string? log = null, bool required = true) :
|
public AveryEventScale(string id, string model, string cnx, string? log = null, bool required = true) :
|
||||||
base(cnx, null, null, null, log, true, !required) {
|
base(cnx, null, null, null, log, true, !required) {
|
||||||
ScaleId = id;
|
ScaleTerminalId = id;
|
||||||
Model = model;
|
Model = model;
|
||||||
Connection = cnx;
|
|
||||||
IsReady = true;
|
IsReady = true;
|
||||||
HasFillingClearance = false;
|
HasFillingClearance = false;
|
||||||
Stream.WriteTimeout = -1;
|
Stream.WriteTimeout = -1;
|
||||||
|
|||||||
+17
-17
@@ -5,18 +5,17 @@ using System.Text;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Elwig.Helpers.Weighing {
|
namespace Elwig.Helpers.Weighing {
|
||||||
public class GassnerScale : Scale, ICommandScale {
|
public class GassnerEnqScale : Scale, ICommandScale {
|
||||||
|
|
||||||
public string Manufacturer => "Gassner";
|
public string Manufacturer => "Gassner";
|
||||||
public int InternalScaleNr => 1;
|
|
||||||
public string Model { get; private set; }
|
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 IsReady { get; private set; }
|
||||||
public bool HasFillingClearance { 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) {
|
base(cnx, empty, filling, limit, log) {
|
||||||
ScaleId = id;
|
ScaleTerminalId = id;
|
||||||
Model = model;
|
Model = model;
|
||||||
IsReady = true;
|
IsReady = true;
|
||||||
HasFillingClearance = false;
|
HasFillingClearance = false;
|
||||||
@@ -24,10 +23,9 @@ namespace Elwig.Helpers.Weighing {
|
|||||||
Stream.ReadTimeout = 11000;
|
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) {
|
protected async Task SendCommand(byte[] cmd) {
|
||||||
byte[] cmd = [command];
|
|
||||||
await Stream.WriteAsync(cmd);
|
await Stream.WriteAsync(cmd);
|
||||||
if (LogPath != null) await File.AppendAllTextAsync(LogPath, Encoding.ASCII.GetString(cmd));
|
if (LogPath != null) await File.AppendAllTextAsync(LogPath, Encoding.ASCII.GetString(cmd));
|
||||||
}
|
}
|
||||||
@@ -53,15 +51,15 @@ namespace Elwig.Helpers.Weighing {
|
|||||||
return line[1..^1];
|
return line[1..^1];
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async Task<WeighingResult> Weigh(bool incIdentNr, bool retry = true) {
|
protected async Task<WeighingResult> Weigh(int? internalScaleNr, bool incIdentNr, bool retry = true) {
|
||||||
string record;
|
string record;
|
||||||
try {
|
try {
|
||||||
await SendCommand(incIdentNr ? '\x05' : '?');
|
await SendCommand(incIdentNr ? "\x05" : "?");
|
||||||
record = await ReceiveResponse();
|
record = await ReceiveResponse();
|
||||||
} catch (IOException) {
|
} catch (IOException) {
|
||||||
if (!retry || Tcp == null) throw;
|
if (!retry || Tcp == null) throw;
|
||||||
ReconnectTcp();
|
ReconnectTcp();
|
||||||
return await Weigh(incIdentNr, false);
|
return await Weigh(internalScaleNr, incIdentNr, false);
|
||||||
}
|
}
|
||||||
if (record.Length != 45)
|
if (record.Length != 45)
|
||||||
throw new FormatException("Invalid response from scale: Received record has invalid size");
|
throw new FormatException("Invalid response from scale: Received record has invalid size");
|
||||||
@@ -80,6 +78,7 @@ namespace Elwig.Helpers.Weighing {
|
|||||||
GrossWeight = int.Parse(brutto),
|
GrossWeight = int.Parse(brutto),
|
||||||
TareWeight = int.Parse(tara),
|
TareWeight = int.Parse(tara),
|
||||||
NetWeight = int.Parse(netto),
|
NetWeight = int.Parse(netto),
|
||||||
|
ScaleId = scaleNr,
|
||||||
WeighingId = identNr,
|
WeighingId = identNr,
|
||||||
FullWeighingId = identNr,
|
FullWeighingId = identNr,
|
||||||
Date = DateOnly.TryParseExact(date, "yyyyMMdd", out var d) ? d : null,
|
Date = DateOnly.TryParseExact(date, "yyyyMMdd", out var d) ? d : null,
|
||||||
@@ -87,12 +86,12 @@ namespace Elwig.Helpers.Weighing {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<WeighingResult> Weigh() {
|
public async Task<WeighingResult> Weigh(int? scaleNr = null) {
|
||||||
return await Weigh(true);
|
return await Weigh(scaleNr, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<WeighingResult> GetCurrentWeight() {
|
public async Task<WeighingResult> GetCurrentWeight(int? scaleNr = null) {
|
||||||
return await Weigh(false);
|
return await Weigh(scaleNr, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task Empty() {
|
public async Task Empty() {
|
||||||
@@ -126,8 +125,9 @@ namespace Elwig.Helpers.Weighing {
|
|||||||
await SetFillingClearance(false);
|
await SetFillingClearance(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task SetDateAndTime(DateTime dateTime) {
|
public async Task SetDateAndTime(DateTime dateTime) {
|
||||||
throw new NotImplementedException("Für Waagen vom Typ 'Gassner' ist diese Funktion noch nicht implementiert");
|
await SendCommand($"C{dateTime:yyyyMMddHHmmss}\r");
|
||||||
|
await ReceiveResponse();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -10,13 +10,13 @@ namespace Elwig.Helpers.Weighing {
|
|||||||
/// Get the current weight on the scale without performing a weighing process
|
/// Get the current weight on the scale without performing a weighing process
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Result of the weighing process (probably without a weighing id)</returns>
|
/// <returns>Result of the weighing process (probably without a weighing id)</returns>
|
||||||
Task<WeighingResult> GetCurrentWeight();
|
Task<WeighingResult> GetCurrentWeight(int? scaleNr = null);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Perform a weighing process
|
/// Perform a weighing process
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Result of the weighing process (including a weighing id)</returns>
|
/// <returns>Result of the weighing process (including a weighing id)</returns>
|
||||||
Task<WeighingResult> Weigh();
|
Task<WeighingResult> Weigh(int? scaleNr = null);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Empty the scale container or grant clearance to do so
|
/// Empty the scale container or grant clearance to do so
|
||||||
|
|||||||
@@ -18,12 +18,7 @@ namespace Elwig.Helpers.Weighing {
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Unique identificator of the scale
|
/// Unique identificator of the scale
|
||||||
/// </summary>
|
/// </summary>
|
||||||
string ScaleId { get; }
|
string ScaleTerminalId { get; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Internal identifying number of the scale in its system
|
|
||||||
/// </summary>
|
|
||||||
int InternalScaleNr { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Indicates if the scale is currently processing a request or not
|
/// Indicates if the scale is currently processing a request or not
|
||||||
|
|||||||
@@ -5,8 +5,7 @@ namespace Elwig.Helpers.Weighing {
|
|||||||
|
|
||||||
public string Manufacturer => "NONE";
|
public string Manufacturer => "NONE";
|
||||||
public string Model => "NONE";
|
public string Model => "NONE";
|
||||||
public string ScaleId => id;
|
public string ScaleTerminalId => id;
|
||||||
public int InternalScaleNr => 0;
|
|
||||||
public bool IsReady => false;
|
public bool IsReady => false;
|
||||||
public bool HasFillingClearance => false;
|
public bool HasFillingClearance => false;
|
||||||
public int? WeightLimit => null;
|
public int? WeightLimit => null;
|
||||||
|
|||||||
@@ -28,10 +28,10 @@ namespace Elwig.Helpers.Weighing {
|
|||||||
int? limit = config.Limit != null ? int.Parse(config.Limit) : null;
|
int? limit = config.Limit != null ? int.Parse(config.Limit) : null;
|
||||||
if (config.Type == "SysTec-IT") {
|
if (config.Type == "SysTec-IT") {
|
||||||
return new SysTecITScale(config.Id, config.Model!, config.Connection!, config.Empty, config.Filling, limit, config.Log);
|
return new SysTecITScale(config.Id, config.Model!, config.Connection!, config.Empty, config.Filling, limit, config.Log);
|
||||||
|
} 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-Async") {
|
} else if (config.Type == "Avery-Async") {
|
||||||
return new AveryEventScale(config.Id, config.Model!, config.Connection!, config.Log, config.Required);
|
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 {
|
} else {
|
||||||
throw new ArgumentException($"Invalid scale type: \"{config.Type}\"");
|
throw new ArgumentException($"Invalid scale type: \"{config.Type}\"");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,15 +8,14 @@ namespace Elwig.Helpers.Weighing {
|
|||||||
public class SysTecITScale : Scale, ICommandScale {
|
public class SysTecITScale : Scale, ICommandScale {
|
||||||
|
|
||||||
public string Manufacturer => "SysTec";
|
public string Manufacturer => "SysTec";
|
||||||
public int InternalScaleNr => 1;
|
|
||||||
public string Model { get; private set; }
|
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 IsReady { get; private set; }
|
||||||
public bool HasFillingClearance { 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) :
|
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) {
|
base(cnx, empty, filling, limit, log) {
|
||||||
ScaleId = id;
|
ScaleTerminalId = id;
|
||||||
Model = model;
|
Model = model;
|
||||||
IsReady = true;
|
IsReady = true;
|
||||||
HasFillingClearance = false;
|
HasFillingClearance = false;
|
||||||
@@ -74,15 +73,15 @@ namespace Elwig.Helpers.Weighing {
|
|||||||
return line[1..^3];
|
return line[1..^3];
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async Task<WeighingResult> Weigh(bool incIdentNr, bool retry = true) {
|
protected async Task<WeighingResult> Weigh(int internalScalNr, bool incIdentNr, bool retry = true) {
|
||||||
string record;
|
string record;
|
||||||
try {
|
try {
|
||||||
await SendCommand(incIdentNr ? $"RN{InternalScaleNr}" : $"RM{InternalScaleNr}");
|
await SendCommand(incIdentNr ? $"RN{internalScalNr}" : $"RM{internalScalNr}");
|
||||||
record = await ReceiveResponse();
|
record = await ReceiveResponse();
|
||||||
} catch (IOException) {
|
} catch (IOException) {
|
||||||
if (!retry || Tcp == null) throw;
|
if (!retry || Tcp == null) throw;
|
||||||
ReconnectTcp();
|
ReconnectTcp();
|
||||||
return await Weigh(incIdentNr, false);
|
return await Weigh(internalScalNr, incIdentNr, false);
|
||||||
}
|
}
|
||||||
if (record.Length != 62)
|
if (record.Length != 62)
|
||||||
throw new FormatException("Invalid response from scale: Received record has invalid size");
|
throw new FormatException("Invalid response from scale: Received record has invalid size");
|
||||||
@@ -114,6 +113,7 @@ namespace Elwig.Helpers.Weighing {
|
|||||||
GrossWeight = int.Parse(brutto),
|
GrossWeight = int.Parse(brutto),
|
||||||
TareWeight = int.Parse(tara),
|
TareWeight = int.Parse(tara),
|
||||||
NetWeight = int.Parse(netto),
|
NetWeight = int.Parse(netto),
|
||||||
|
ScaleId = scaleNr,
|
||||||
WeighingId = identNr,
|
WeighingId = identNr,
|
||||||
FullWeighingId = identNr != null ? $"{parsedDate:yyyy-MM-dd}/{identNr}" : null,
|
FullWeighingId = identNr != null ? $"{parsedDate:yyyy-MM-dd}/{identNr}" : null,
|
||||||
Date = parsedDate,
|
Date = parsedDate,
|
||||||
@@ -121,12 +121,12 @@ namespace Elwig.Helpers.Weighing {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<WeighingResult> Weigh() {
|
public async Task<WeighingResult> Weigh(int? scaleNr = 1) {
|
||||||
return await Weigh(true);
|
return await Weigh(scaleNr ?? 1, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<WeighingResult> GetCurrentWeight() {
|
public async Task<WeighingResult> GetCurrentWeight(int? scaleNr = 1) {
|
||||||
return await Weigh(false);
|
return await Weigh(scaleNr ?? 1, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task Empty() {
|
public async Task Empty() {
|
||||||
|
|||||||
@@ -21,6 +21,11 @@ namespace Elwig.Helpers.Weighing {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public int? NetWeight;
|
public int? NetWeight;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Reported id of the scale
|
||||||
|
/// </summary>
|
||||||
|
public string? ScaleId;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Weighing id (or IdentNr) provided by the scale
|
/// Weighing id (or IdentNr) provided by the scale
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -49,6 +54,7 @@ namespace Elwig.Helpers.Weighing {
|
|||||||
|
|
||||||
public readonly JsonObject ToJson() {
|
public readonly JsonObject ToJson() {
|
||||||
var obj = new JsonObject();
|
var obj = new JsonObject();
|
||||||
|
if (ScaleId != null) obj["scale"] = ScaleId;
|
||||||
if (FullWeighingId != null) obj["id"] = FullWeighingId;
|
if (FullWeighingId != null) obj["id"] = FullWeighingId;
|
||||||
if (WeighingId != null) obj["nr"] = int.Parse(WeighingId);
|
if (WeighingId != null) obj["nr"] = int.Parse(WeighingId);
|
||||||
if (Date != null) obj["date"] = $"{Date:yyyy-MM-dd}";
|
if (Date != null) obj["date"] = $"{Date:yyyy-MM-dd}";
|
||||||
|
|||||||
@@ -119,16 +119,17 @@ namespace Elwig.Models.Entities {
|
|||||||
public double? Acid { get; set; }
|
public double? Acid { get; set; }
|
||||||
|
|
||||||
[Column("scale_id")]
|
[Column("scale_id")]
|
||||||
public string? ScaleId { get; set; }
|
public string? ScaleTerminalId { get; set; }
|
||||||
|
|
||||||
[Column("weighing_data")]
|
[Column("weighing_data")]
|
||||||
public string? WeighingData { get; set; }
|
public string? WeighingData { get; set; }
|
||||||
[NotMapped]
|
[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 {
|
get {
|
||||||
try {
|
try {
|
||||||
var obj = JsonNode.Parse(WeighingData!)!.AsObject();
|
var obj = JsonNode.Parse(WeighingData!)!.AsObject();
|
||||||
return (
|
return (
|
||||||
|
obj["scale"]?.AsValue().GetValue<string>(),
|
||||||
obj["id"]?.AsValue().GetValue<string>(),
|
obj["id"]?.AsValue().GetValue<string>(),
|
||||||
obj["gross_weight"]?.AsValue().GetValue<int>(),
|
obj["gross_weight"]?.AsValue().GetValue<int>(),
|
||||||
obj["tare_weight"]?.AsValue().GetValue<int>(),
|
obj["tare_weight"]?.AsValue().GetValue<int>(),
|
||||||
@@ -137,7 +138,7 @@ namespace Elwig.Models.Entities {
|
|||||||
TimeOnly.TryParseExact(obj["time"]?.AsValue().GetValue<string>(), ["HH:mm:ss", "HH:mm"], out var t) ? t : null
|
TimeOnly.TryParseExact(obj["time"]?.AsValue().GetValue<string>(), ["HH:mm:ss", "HH:mm"], out var t) ? t : null
|
||||||
);
|
);
|
||||||
} catch {
|
} catch {
|
||||||
return (null, null, null, null, null, null);
|
return (null, null, null, null, null, null, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ namespace Elwig.Services {
|
|||||||
vm.IsGebunden = p.IsGebunden;
|
vm.IsGebunden = p.IsGebunden;
|
||||||
vm.Unloading = p.Unloading;
|
vm.Unloading = p.Unloading;
|
||||||
|
|
||||||
vm.ScaleId = p.ScaleId;
|
vm.ScaleTerminalId = p.ScaleTerminalId;
|
||||||
vm.WeighingData = p.WeighingData;
|
vm.WeighingData = p.WeighingData;
|
||||||
vm.ManualWeighingReason = p.WeighingReason;
|
vm.ManualWeighingReason = p.WeighingReason;
|
||||||
}
|
}
|
||||||
@@ -515,7 +515,7 @@ namespace Elwig.Services {
|
|||||||
|
|
||||||
Weight = vm.Weight!.Value,
|
Weight = vm.Weight!.Value,
|
||||||
IsManualWeighing = vm.IsManualWeighing,
|
IsManualWeighing = vm.IsManualWeighing,
|
||||||
ScaleId = vm.ScaleId,
|
ScaleTerminalId = vm.ScaleTerminalId,
|
||||||
WeighingData = vm.WeighingData,
|
WeighingData = vm.WeighingData,
|
||||||
WeighingReason = vm.ManualWeighingReason,
|
WeighingReason = vm.ManualWeighingReason,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ namespace Elwig.ViewModels {
|
|||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private string? _manualWeighingReason;
|
private string? _manualWeighingReason;
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private string? _scaleId;
|
private string? _scaleTerminalId;
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private string? _weighingData;
|
private string? _weighingData;
|
||||||
|
|
||||||
|
|||||||
@@ -85,10 +85,10 @@ namespace Elwig.Windows {
|
|||||||
if (n < 3) WeighingCButton.Visibility = Visibility.Hidden;
|
if (n < 3) WeighingCButton.Visibility = Visibility.Hidden;
|
||||||
if (n < 4) WeighingDButton.Visibility = Visibility.Hidden;
|
if (n < 4) WeighingDButton.Visibility = Visibility.Hidden;
|
||||||
if (n == 1) WeighingAButton.Content = "Wiegen";
|
if (n == 1) WeighingAButton.Content = "Wiegen";
|
||||||
if (n > 1) WeighingAButton.Content = $"Wiegen {App.CommandScales[0].ScaleId}";
|
if (n > 1) WeighingAButton.Content = $"Wiegen {App.CommandScales[0].ScaleTerminalId}";
|
||||||
if (n >= 2) WeighingBButton.Content = $"Wiegen {App.CommandScales[1].ScaleId}";
|
if (n >= 2) WeighingBButton.Content = $"Wiegen {App.CommandScales[1].ScaleTerminalId}";
|
||||||
if (n >= 3) WeighingCButton.Content = $"Wiegen {App.CommandScales[2].ScaleId}";
|
if (n >= 3) WeighingCButton.Content = $"Wiegen {App.CommandScales[2].ScaleTerminalId}";
|
||||||
if (n >= 4) WeighingDButton.Content = $"Wiegen {App.CommandScales[3].ScaleId}";
|
if (n >= 4) WeighingDButton.Content = $"Wiegen {App.CommandScales[3].ScaleTerminalId}";
|
||||||
WeighingManualButton.Margin = new Thickness(10, 10 + n * 32, 10, 10);
|
WeighingManualButton.Margin = new Thickness(10, 10 + n * 32, 10, 10);
|
||||||
foreach (var s in App.EventScales) {
|
foreach (var s in App.EventScales) {
|
||||||
s.WeighingEvent += Scale_Weighing;
|
s.WeighingEvent += Scale_Weighing;
|
||||||
@@ -366,7 +366,7 @@ namespace Elwig.Windows {
|
|||||||
private void InitialInputs() {
|
private void InitialInputs() {
|
||||||
ViewModel.LastScaleError = null;
|
ViewModel.LastScaleError = null;
|
||||||
ViewModel.WeighingData = null;
|
ViewModel.WeighingData = null;
|
||||||
ViewModel.ScaleId = null;
|
ViewModel.ScaleTerminalId = null;
|
||||||
ViewModel.ManualWeighingReason = null;
|
ViewModel.ManualWeighingReason = null;
|
||||||
|
|
||||||
ClearOriginalValues();
|
ClearOriginalValues();
|
||||||
@@ -651,13 +651,13 @@ namespace Elwig.Windows {
|
|||||||
private void OnWeighingResult(IScale scale, WeighingResult res) {
|
private void OnWeighingResult(IScale scale, WeighingResult res) {
|
||||||
if ((res.NetWeight ?? 0) > 0 && res.FullWeighingId != null) {
|
if ((res.NetWeight ?? 0) > 0 && res.FullWeighingId != null) {
|
||||||
ViewModel.Weight = res.NetWeight;
|
ViewModel.Weight = res.NetWeight;
|
||||||
ViewModel.ScaleId = scale.ScaleId;
|
ViewModel.ScaleTerminalId = scale.ScaleTerminalId;
|
||||||
ViewModel.WeighingData = res.ToJson().ToJsonString();
|
ViewModel.WeighingData = res.ToJson().ToJsonString();
|
||||||
ViewModel.ManualWeighingReason = null;
|
ViewModel.ManualWeighingReason = null;
|
||||||
ManualWeighingInput.IsChecked = false;
|
ManualWeighingInput.IsChecked = false;
|
||||||
} else {
|
} else {
|
||||||
ViewModel.Weight = null;
|
ViewModel.Weight = null;
|
||||||
ViewModel.ScaleId = null;
|
ViewModel.ScaleTerminalId = null;
|
||||||
ViewModel.WeighingData = null;
|
ViewModel.WeighingData = null;
|
||||||
}
|
}
|
||||||
ViewModel.LastScaleError = null;
|
ViewModel.LastScaleError = null;
|
||||||
@@ -771,7 +771,7 @@ namespace Elwig.Windows {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void EmptyScale() {
|
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;
|
if (scale is not ICommandScale cs) return;
|
||||||
cs.Empty();
|
cs.Empty();
|
||||||
}
|
}
|
||||||
@@ -953,7 +953,7 @@ namespace Elwig.Windows {
|
|||||||
ViewModel.Weight = res?.Item1;
|
ViewModel.Weight = res?.Item1;
|
||||||
ManualWeighingInput.IsChecked = true;
|
ManualWeighingInput.IsChecked = true;
|
||||||
ViewModel.ManualWeighingReason = res?.Item2;
|
ViewModel.ManualWeighingReason = res?.Item2;
|
||||||
ViewModel.ScaleId = null;
|
ViewModel.ScaleTerminalId = null;
|
||||||
ViewModel.WeighingData = null;
|
ViewModel.WeighingData = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ namespace Tests.UnitTests.WeighingTests {
|
|||||||
public class ScaleTestHaugsdorfDMA02 {
|
public class ScaleTestHaugsdorfDMA02 {
|
||||||
|
|
||||||
private MockScale Mock;
|
private MockScale Mock;
|
||||||
private GassnerScale Scale;
|
private GassnerEnqScale Scale;
|
||||||
|
|
||||||
[OneTimeSetUp]
|
[OneTimeSetUp]
|
||||||
public void SetupScale() {
|
public void SetupScale() {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ namespace Tests.UnitTests.WeighingTests {
|
|||||||
public class ScaleTestSitzendorfDMA03Baby {
|
public class ScaleTestSitzendorfDMA03Baby {
|
||||||
|
|
||||||
private MockScale Mock;
|
private MockScale Mock;
|
||||||
private GassnerScale Scale;
|
private GassnerEnqScale Scale;
|
||||||
|
|
||||||
[OneTimeSetUp]
|
[OneTimeSetUp]
|
||||||
public void SetupScale() {
|
public void SetupScale() {
|
||||||
|
|||||||
Reference in New Issue
Block a user