Weighing: Set Date/Time of scales at startup
Test / Run tests (push) Successful in 1m59s

This commit is contained in:
2026-08-01 23:14:02 +02:00
parent bc093f31db
commit d44d82a614
4 changed files with 10 additions and 4 deletions
+7 -1
View File
@@ -145,7 +145,13 @@ namespace Elwig {
var list = new List<IScale>();
foreach (var s in Config.Scales) {
try {
list.Add(Scale.FromConfig(s));
var scale = Scale.FromConfig(s);
if (scale is ICommandScale cmd) {
try {
await cmd.SetDateAndTime(DateTime.Now);
} catch { }
}
list.Add(scale);
} catch (Exception exc) {
list.Add(new InvalidScale(s.Id));
if (s.Required)
+1 -1
View File
@@ -188,7 +188,7 @@ namespace Elwig.Documents {
if (info.Date != null || info.Time != null)
weighing.Add(Normal(" \u2013 "));
if (info.Time != null)
weighing.Add(Normal($"{info.Time:HH:mm}"));
weighing.Add(Normal($"{info.Time:HH:mm:ss}"));
if (info.Date != null)
weighing.Add(Normal($", {info.Date:dd.MM.yyyy}"));
if (info.Gross != null && info.Tare != null && info.Net != null) {
+1 -1
View File
@@ -49,7 +49,7 @@ namespace Elwig.Helpers.Weighing {
/// <returns>&lt;[GrossWeight-TaraWeight=]NetWeight/WeighingId/Date/Time&gt;</returns>
public override readonly string ToString() {
var w = NetWeight != null ? (GrossWeight != null && TareWeight != null ? $"{GrossWeight}-{TareWeight}=" : "") + $"{NetWeight}kg" : "";
return $"<{w}/{WeighingId}/{Date:yyyy-MM-dd}/{Time:HH:mm}>";
return $"<{w}/{WeighingId}/{Date:yyyy-MM-dd}/{Time:HH:mm:ss}>";
}
public readonly JsonObject ToJson() {
@@ -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/Terminal: ?/1, ID: 321 09:02, 01.10.2020
Waage/Terminal: ?/1, ID: 321 09:02:46, 01.10.2020
Brutto: 3 219 kg Tara: 0 kg Netto: 3 219 kg gerebelt gewogen
"""));
});