diff --git a/Elwig/Helpers/Weighing/GassnerScale.cs b/Elwig/Helpers/Weighing/GassnerScale.cs index 489ac48..1c48a9e 100644 --- a/Elwig/Helpers/Weighing/GassnerScale.cs +++ b/Elwig/Helpers/Weighing/GassnerScale.cs @@ -118,5 +118,9 @@ namespace Elwig.Helpers.Weighing { public async Task RevokeFillingClearance() { await SetFillingClearance(false); } + + public Task SetDateAndTime(DateTime dateTime) { + throw new NotImplementedException("Für Waagen vom Typ 'Gassner' ist diese Funktion noch nicht implementiert"); + } } } diff --git a/Elwig/Helpers/Weighing/ICommandScale.cs b/Elwig/Helpers/Weighing/ICommandScale.cs index b06c842..33f006a 100644 --- a/Elwig/Helpers/Weighing/ICommandScale.cs +++ b/Elwig/Helpers/Weighing/ICommandScale.cs @@ -1,3 +1,4 @@ +using System; using System.Threading.Tasks; namespace Elwig.Helpers.Weighing { @@ -31,5 +32,10 @@ namespace Elwig.Helpers.Weighing { /// Revoke clearance to fill the scale container /// Task RevokeFillingClearance(); + + /// + /// Try to set date and time on the scale + /// + Task SetDateAndTime(DateTime dateTime); } } diff --git a/Elwig/Helpers/Weighing/SysTecITScale.cs b/Elwig/Helpers/Weighing/SysTecITScale.cs index dbdd488..420ed2a 100644 --- a/Elwig/Helpers/Weighing/SysTecITScale.cs +++ b/Elwig/Helpers/Weighing/SysTecITScale.cs @@ -161,5 +161,10 @@ namespace Elwig.Helpers.Weighing { public async Task RevokeFillingClearance() { await SetFillingClearance(false); } + + public async Task SetDateAndTime(DateTime dateTime) { + await SendCommand($"ST{dateTime:dd.MM.yyHH:mm:ss}"); + await ReceiveResponse(); + } } } diff --git a/Elwig/Windows/MainWindow.xaml b/Elwig/Windows/MainWindow.xaml index 4c3ddb7..05aed47 100644 --- a/Elwig/Windows/MainWindow.xaml +++ b/Elwig/Windows/MainWindow.xaml @@ -25,6 +25,9 @@ + + + diff --git a/Elwig/Windows/MainWindow.xaml.cs b/Elwig/Windows/MainWindow.xaml.cs index de0b400..5692f8a 100644 --- a/Elwig/Windows/MainWindow.xaml.cs +++ b/Elwig/Windows/MainWindow.xaml.cs @@ -90,6 +90,21 @@ namespace Elwig.Windows { } catch { } } + private async void Menu_Scales_SetDateTime_Click(object sender, RoutedEventArgs evt) { + if (App.CommandScales.Count == 0) { + MessageBox.Show("Es sind keine geeigneten Waagen verfügbar!", "Datum und Uhrzeit setzen", MessageBoxButton.OK, MessageBoxImage.Error); + return; + } + foreach (var s in App.CommandScales) { + try { + await s.SetDateAndTime(DateTime.Now); + } catch (Exception exc) { + MessageBox.Show(exc.Message, "Fehler", MessageBoxButton.OK, MessageBoxImage.Error); + } + } + MessageBox.Show("Datum und Uhrzeit auf entsprechenden Waagen gesetzt!", "Datum und Uhrzeit setzen", MessageBoxButton.OK, MessageBoxImage.Information); + } + private void Menu_Database_Query_Click(object sender, RoutedEventArgs evt) { var w = new QueryWindow(); w.Show();