From 3edc7df3a9e2e27dd97ff45b8d40b29c78071f83 Mon Sep 17 00:00:00 2001 From: Stoyan Zlatev Date: Fri, 24 Jan 2025 12:10:40 +0100 Subject: [PATCH] e-register manual programming --- Common/.vs/config/applicationhost.config | 2 +- Common/Common.sln | 67 + Common/CommonConsole/CommonConsole.csproj | 4 - Common/CommonConsole/Program.cs | 214 +-- .../SerialDataExtensions.cs | 59 +- .../SIRTBroadcaster.Internal.cs | 12 +- .../EregisterCheckFinalizationTask.cs | 12 +- .../EregisterExtensions.cs | 2 +- .../Features/ChangeDataLoggerSettings.cs | 96 +- .../ChangeFixedDateReadingSettings.cs | 95 +- .../Features/ChangeSensusRFEncryptionKey.cs | 4 +- .../Features/DebugCmd.cs | 2 + .../Features/Pam.cs | 2 + .../Models/EregisterProgrammingParameters.cs | 52 +- Common/Ui/Common.GUI/App.config | 14 + Common/Ui/Common.GUI/App.xaml | 9 + Common/Ui/Common.GUI/App.xaml.cs | 34 + Common/Ui/Common.GUI/Common.GUI.csproj | 186 +++ .../EregisterFeaturesItemsControl.xaml | 38 + .../EregisterFeaturesItemsControl.xaml.cs | 9 + Common/Ui/Common.GUI/Controls/MainLayout.xaml | 38 + .../Ui/Common.GUI/Controls/MainLayout.xaml.cs | 44 + Common/Ui/Common.GUI/Controls/MainMenu.xaml | 10 + .../Ui/Common.GUI/Controls/MainMenu.xaml.cs | 9 + Common/Ui/Common.GUI/MainWindow.xaml | 6 + Common/Ui/Common.GUI/MainWindow.xaml.cs | 9 + .../Models/Base/User32DllImports.cs | 52 + .../Common.GUI/Models/Base/WindowCommands.cs | 17 + .../Eregister/ManualProgrammingPage.xaml | 158 +++ .../Eregister/ManualProgrammingPage.xaml.cs | 9 + Common/Ui/Common.GUI/Pages/MainPage.xaml | 10 + Common/Ui/Common.GUI/Pages/MainPage.xaml.cs | 9 + Common/Ui/Common.GUI/Pages/TestPage.xaml | 10 + Common/Ui/Common.GUI/Pages/TestPage.xaml.cs | 28 + .../Properties/AssemblyInfo.cs | 6 +- .../Properties/Resources.Designer.cs | 46 +- .../Properties/Resources.resx | 0 .../Properties/Settings.Designer.cs | 22 +- .../Properties/Settings.settings | 0 .../Ui/Common.GUI/ViewModels/Base/Command.cs | 25 + .../Common.GUI/ViewModels/Base/Command[T].cs | 25 + .../ViewModels/Base/MessageHandler.cs | 11 + Common/Ui/Common.GUI/ViewModels/Base/VM.cs | 31 + Common/Ui/Common.GUI/ViewModels/Base/VM[T].cs | 18 + .../ViewModels/Controls/MainLayoutVM.cs | 24 + .../ViewModels/Controls/MainMenuVM.cs | 24 + .../ViewModels/Controls/MessageVM.cs | 17 + .../Eregister/EregisterFeatureItemVM.cs | 86 ++ .../Eregister/EregisterManualProgrammingVM.cs | 155 +++ .../Common.GUI/ViewModels/Pages/MainPageVM.cs | 9 + Common/Ui/Common.GUI/ViewModels/VMLocator.cs | 42 + Common/Ui/Common.GUI/packages.config | 8 + Common/Ui/Common.UI.VFM/App.config | 9 - Common/Ui/Common.UI.VFM/Common.UI.VFM.csproj | 194 --- .../Converters/BooleanInverterConverter.cs | 24 - .../BooleanToVisibilityConverter.cs | 25 - .../ProcessStateToImageConverter.cs | 36 - .../ProcessStateToImageSourceConverter.cs | 36 - .../ProcessstateToColorConverter.cs | 34 - .../Converters/StringToVisibilityConverter.cs | 25 - .../Common.UI.VFM/Models/OmniShipmentModel.cs | 1167 ----------------- .../Common.UI.VFM/Models/OmniValuesModel.cs | 118 -- .../Ui/Common.UI.VFM/Models/ProcessResult.cs | 11 - .../Ui/Common.UI.VFM/Models/ProcessState.cs | 11 - .../Common.UI.VFM/ViewModels/AppViewModel.cs | 88 -- .../ViewModels/EmptyViewModel.cs | 6 - .../ViewModels/MainWindowViewModel.cs | 12 - .../ViewModels/ProcessStepViewModel.cs | 49 - .../ViewModels/ShipmnetViewModel.cs | 224 ---- Common/Ui/Common.UI.VFM/Views/App.xaml | 165 --- Common/Ui/Common.UI.VFM/Views/App.xaml.cs | 12 - Common/Ui/Common.UI.VFM/Views/EmptyView.xaml | 8 - .../Ui/Common.UI.VFM/Views/EmptyView.xaml.cs | 9 - Common/Ui/Common.UI.VFM/Views/MainWindow.xaml | 28 - .../Ui/Common.UI.VFM/Views/MainWindow.xaml.cs | 9 - .../Ui/Common.UI.VFM/Views/ShipmentView.xaml | 178 --- .../Common.UI.VFM/Views/ShipmentView.xaml.cs | 43 - Common/Ui/Common.UI/Common.UI.csproj | 18 + Common/Ui/Common.UI/Controls/SIRT.xaml | 5 + Common/Ui/Common.UI/Controls/SIRT.xaml.cs | 77 ++ .../Common.UI/Infrastructure/Appsettings.cs | 22 +- .../Common.UI/Infrastructure/ErrorManager.cs | 25 + Common/Ui/Common.UI/MainWindow.xaml | 2 +- .../Models/EregisterManualProgrammingModel.cs | 14 + .../Pages/EregisterManualProgramming.xaml | 14 + .../Pages/EregisterManualProgramming.xaml.cs | 9 + .../Common.UI/ViewModels/Controls/SIRTVM.cs | 8 + .../EregisterManualProgrammingVM.cs | 15 + 88 files changed, 1805 insertions(+), 2796 deletions(-) create mode 100644 Common/Ui/Common.GUI/App.config create mode 100644 Common/Ui/Common.GUI/App.xaml create mode 100644 Common/Ui/Common.GUI/App.xaml.cs create mode 100644 Common/Ui/Common.GUI/Common.GUI.csproj create mode 100644 Common/Ui/Common.GUI/Controls/Eregister/EregisterFeaturesItemsControl.xaml create mode 100644 Common/Ui/Common.GUI/Controls/Eregister/EregisterFeaturesItemsControl.xaml.cs create mode 100644 Common/Ui/Common.GUI/Controls/MainLayout.xaml create mode 100644 Common/Ui/Common.GUI/Controls/MainLayout.xaml.cs create mode 100644 Common/Ui/Common.GUI/Controls/MainMenu.xaml create mode 100644 Common/Ui/Common.GUI/Controls/MainMenu.xaml.cs create mode 100644 Common/Ui/Common.GUI/MainWindow.xaml create mode 100644 Common/Ui/Common.GUI/MainWindow.xaml.cs create mode 100644 Common/Ui/Common.GUI/Models/Base/User32DllImports.cs create mode 100644 Common/Ui/Common.GUI/Models/Base/WindowCommands.cs create mode 100644 Common/Ui/Common.GUI/Pages/Eregister/ManualProgrammingPage.xaml create mode 100644 Common/Ui/Common.GUI/Pages/Eregister/ManualProgrammingPage.xaml.cs create mode 100644 Common/Ui/Common.GUI/Pages/MainPage.xaml create mode 100644 Common/Ui/Common.GUI/Pages/MainPage.xaml.cs create mode 100644 Common/Ui/Common.GUI/Pages/TestPage.xaml create mode 100644 Common/Ui/Common.GUI/Pages/TestPage.xaml.cs rename Common/Ui/{Common.UI.VFM => Common.GUI}/Properties/AssemblyInfo.cs (94%) rename Common/Ui/{Common.UI.VFM => Common.GUI}/Properties/Resources.Designer.cs (82%) rename Common/Ui/{Common.UI.VFM => Common.GUI}/Properties/Resources.resx (100%) rename Common/Ui/{Common.UI.VFM => Common.GUI}/Properties/Settings.Designer.cs (82%) rename Common/Ui/{Common.UI.VFM => Common.GUI}/Properties/Settings.settings (100%) create mode 100644 Common/Ui/Common.GUI/ViewModels/Base/Command.cs create mode 100644 Common/Ui/Common.GUI/ViewModels/Base/Command[T].cs create mode 100644 Common/Ui/Common.GUI/ViewModels/Base/MessageHandler.cs create mode 100644 Common/Ui/Common.GUI/ViewModels/Base/VM.cs create mode 100644 Common/Ui/Common.GUI/ViewModels/Base/VM[T].cs create mode 100644 Common/Ui/Common.GUI/ViewModels/Controls/MainLayoutVM.cs create mode 100644 Common/Ui/Common.GUI/ViewModels/Controls/MainMenuVM.cs create mode 100644 Common/Ui/Common.GUI/ViewModels/Controls/MessageVM.cs create mode 100644 Common/Ui/Common.GUI/ViewModels/Eregister/EregisterFeatureItemVM.cs create mode 100644 Common/Ui/Common.GUI/ViewModels/Eregister/EregisterManualProgrammingVM.cs create mode 100644 Common/Ui/Common.GUI/ViewModels/Pages/MainPageVM.cs create mode 100644 Common/Ui/Common.GUI/ViewModels/VMLocator.cs create mode 100644 Common/Ui/Common.GUI/packages.config delete mode 100644 Common/Ui/Common.UI.VFM/App.config delete mode 100644 Common/Ui/Common.UI.VFM/Common.UI.VFM.csproj delete mode 100644 Common/Ui/Common.UI.VFM/Converters/BooleanInverterConverter.cs delete mode 100644 Common/Ui/Common.UI.VFM/Converters/BooleanToVisibilityConverter.cs delete mode 100644 Common/Ui/Common.UI.VFM/Converters/ProcessStateToImageConverter.cs delete mode 100644 Common/Ui/Common.UI.VFM/Converters/ProcessStateToImageSourceConverter.cs delete mode 100644 Common/Ui/Common.UI.VFM/Converters/ProcessstateToColorConverter.cs delete mode 100644 Common/Ui/Common.UI.VFM/Converters/StringToVisibilityConverter.cs delete mode 100644 Common/Ui/Common.UI.VFM/Models/OmniShipmentModel.cs delete mode 100644 Common/Ui/Common.UI.VFM/Models/OmniValuesModel.cs delete mode 100644 Common/Ui/Common.UI.VFM/Models/ProcessResult.cs delete mode 100644 Common/Ui/Common.UI.VFM/Models/ProcessState.cs delete mode 100644 Common/Ui/Common.UI.VFM/ViewModels/AppViewModel.cs delete mode 100644 Common/Ui/Common.UI.VFM/ViewModels/EmptyViewModel.cs delete mode 100644 Common/Ui/Common.UI.VFM/ViewModels/MainWindowViewModel.cs delete mode 100644 Common/Ui/Common.UI.VFM/ViewModels/ProcessStepViewModel.cs delete mode 100644 Common/Ui/Common.UI.VFM/ViewModels/ShipmnetViewModel.cs delete mode 100644 Common/Ui/Common.UI.VFM/Views/App.xaml delete mode 100644 Common/Ui/Common.UI.VFM/Views/App.xaml.cs delete mode 100644 Common/Ui/Common.UI.VFM/Views/EmptyView.xaml delete mode 100644 Common/Ui/Common.UI.VFM/Views/EmptyView.xaml.cs delete mode 100644 Common/Ui/Common.UI.VFM/Views/MainWindow.xaml delete mode 100644 Common/Ui/Common.UI.VFM/Views/MainWindow.xaml.cs delete mode 100644 Common/Ui/Common.UI.VFM/Views/ShipmentView.xaml delete mode 100644 Common/Ui/Common.UI.VFM/Views/ShipmentView.xaml.cs create mode 100644 Common/Ui/Common.UI/Controls/SIRT.xaml create mode 100644 Common/Ui/Common.UI/Controls/SIRT.xaml.cs create mode 100644 Common/Ui/Common.UI/Infrastructure/ErrorManager.cs create mode 100644 Common/Ui/Common.UI/Models/EregisterManualProgrammingModel.cs create mode 100644 Common/Ui/Common.UI/Pages/EregisterManualProgramming.xaml create mode 100644 Common/Ui/Common.UI/Pages/EregisterManualProgramming.xaml.cs create mode 100644 Common/Ui/Common.UI/ViewModels/Controls/SIRTVM.cs create mode 100644 Common/Ui/Common.UI/ViewModels/EregisterManualProgrammingVM.cs diff --git a/Common/.vs/config/applicationhost.config b/Common/.vs/config/applicationhost.config index de10b180..a894c3cf 100644 --- a/Common/.vs/config/applicationhost.config +++ b/Common/.vs/config/applicationhost.config @@ -155,7 +155,7 @@ - + diff --git a/Common/Common.sln b/Common/Common.sln index c66a9a2b..fe22063d 100644 --- a/Common/Common.sln +++ b/Common/Common.sln @@ -820,6 +820,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Debug", "Debug", "{7C77A79B EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "TempPE", "TempPE", "{91CA9896-2288-4967-8991-AC49A77B6058}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Common.GUI", "Ui\Common.GUI\Common.GUI.csproj", "{25A3BC33-563A-41EC-A1CB-4C5F520DDD53}" +EndProject Global GlobalSection(SharedMSBuildProjectFiles) = preSolution Utils\DateTimeServerShared\DateTimeServerShared.projitems*{4806d89a-fbfb-41bc-aaa7-2242444bf55a}*SharedItemsImports = 4 @@ -5846,6 +5848,70 @@ Global {FDE234FD-FF24-479F-B5CA-DFB74B4636DA}.XP32bit|x64.Build.0 = Release|Any CPU {FDE234FD-FF24-479F-B5CA-DFB74B4636DA}.XP32bit|x86.ActiveCfg = Release|Any CPU {FDE234FD-FF24-479F-B5CA-DFB74B4636DA}.XP32bit|x86.Build.0 = Release|Any CPU + {25A3BC33-563A-41EC-A1CB-4C5F520DDD53}._MANUAL_CONTROL|Any CPU.ActiveCfg = Release|Any CPU + {25A3BC33-563A-41EC-A1CB-4C5F520DDD53}._MANUAL_CONTROL|Any CPU.Build.0 = Release|Any CPU + {25A3BC33-563A-41EC-A1CB-4C5F520DDD53}._MANUAL_CONTROL|Mixed Platforms.ActiveCfg = Release|Any CPU + {25A3BC33-563A-41EC-A1CB-4C5F520DDD53}._MANUAL_CONTROL|Mixed Platforms.Build.0 = Release|Any CPU + {25A3BC33-563A-41EC-A1CB-4C5F520DDD53}._MANUAL_CONTROL|x64.ActiveCfg = Release|Any CPU + {25A3BC33-563A-41EC-A1CB-4C5F520DDD53}._MANUAL_CONTROL|x64.Build.0 = Release|Any CPU + {25A3BC33-563A-41EC-A1CB-4C5F520DDD53}._MANUAL_CONTROL|x86.ActiveCfg = Release|Any CPU + {25A3BC33-563A-41EC-A1CB-4C5F520DDD53}._MANUAL_CONTROL|x86.Build.0 = Release|Any CPU + {25A3BC33-563A-41EC-A1CB-4C5F520DDD53}.COM|Any CPU.ActiveCfg = Release|Any CPU + {25A3BC33-563A-41EC-A1CB-4C5F520DDD53}.COM|Any CPU.Build.0 = Release|Any CPU + {25A3BC33-563A-41EC-A1CB-4C5F520DDD53}.COM|Mixed Platforms.ActiveCfg = Release|Any CPU + {25A3BC33-563A-41EC-A1CB-4C5F520DDD53}.COM|Mixed Platforms.Build.0 = Release|Any CPU + {25A3BC33-563A-41EC-A1CB-4C5F520DDD53}.COM|x64.ActiveCfg = Release|Any CPU + {25A3BC33-563A-41EC-A1CB-4C5F520DDD53}.COM|x64.Build.0 = Release|Any CPU + {25A3BC33-563A-41EC-A1CB-4C5F520DDD53}.COM|x86.ActiveCfg = Release|Any CPU + {25A3BC33-563A-41EC-A1CB-4C5F520DDD53}.COM|x86.Build.0 = Release|Any CPU + {25A3BC33-563A-41EC-A1CB-4C5F520DDD53}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {25A3BC33-563A-41EC-A1CB-4C5F520DDD53}.Debug|Any CPU.Build.0 = Debug|Any CPU + {25A3BC33-563A-41EC-A1CB-4C5F520DDD53}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {25A3BC33-563A-41EC-A1CB-4C5F520DDD53}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {25A3BC33-563A-41EC-A1CB-4C5F520DDD53}.Debug|x64.ActiveCfg = Debug|Any CPU + {25A3BC33-563A-41EC-A1CB-4C5F520DDD53}.Debug|x64.Build.0 = Debug|Any CPU + {25A3BC33-563A-41EC-A1CB-4C5F520DDD53}.Debug|x86.ActiveCfg = Debug|Any CPU + {25A3BC33-563A-41EC-A1CB-4C5F520DDD53}.Debug|x86.Build.0 = Debug|Any CPU + {25A3BC33-563A-41EC-A1CB-4C5F520DDD53}.GenesisDisplayTool_V01|Any CPU.ActiveCfg = Release|Any CPU + {25A3BC33-563A-41EC-A1CB-4C5F520DDD53}.GenesisDisplayTool_V01|Any CPU.Build.0 = Release|Any CPU + {25A3BC33-563A-41EC-A1CB-4C5F520DDD53}.GenesisDisplayTool_V01|Mixed Platforms.ActiveCfg = Release|Any CPU + {25A3BC33-563A-41EC-A1CB-4C5F520DDD53}.GenesisDisplayTool_V01|Mixed Platforms.Build.0 = Release|Any CPU + {25A3BC33-563A-41EC-A1CB-4C5F520DDD53}.GenesisDisplayTool_V01|x64.ActiveCfg = Release|Any CPU + {25A3BC33-563A-41EC-A1CB-4C5F520DDD53}.GenesisDisplayTool_V01|x64.Build.0 = Release|Any CPU + {25A3BC33-563A-41EC-A1CB-4C5F520DDD53}.GenesisDisplayTool_V01|x86.ActiveCfg = Release|Any CPU + {25A3BC33-563A-41EC-A1CB-4C5F520DDD53}.GenesisDisplayTool_V01|x86.Build.0 = Release|Any CPU + {25A3BC33-563A-41EC-A1CB-4C5F520DDD53}.PerformTest|Any CPU.ActiveCfg = Release|Any CPU + {25A3BC33-563A-41EC-A1CB-4C5F520DDD53}.PerformTest|Any CPU.Build.0 = Release|Any CPU + {25A3BC33-563A-41EC-A1CB-4C5F520DDD53}.PerformTest|Mixed Platforms.ActiveCfg = Release|Any CPU + {25A3BC33-563A-41EC-A1CB-4C5F520DDD53}.PerformTest|Mixed Platforms.Build.0 = Release|Any CPU + {25A3BC33-563A-41EC-A1CB-4C5F520DDD53}.PerformTest|x64.ActiveCfg = Release|Any CPU + {25A3BC33-563A-41EC-A1CB-4C5F520DDD53}.PerformTest|x64.Build.0 = Release|Any CPU + {25A3BC33-563A-41EC-A1CB-4C5F520DDD53}.PerformTest|x86.ActiveCfg = Release|Any CPU + {25A3BC33-563A-41EC-A1CB-4C5F520DDD53}.PerformTest|x86.Build.0 = Release|Any CPU + {25A3BC33-563A-41EC-A1CB-4C5F520DDD53}.Release|Any CPU.ActiveCfg = Release|Any CPU + {25A3BC33-563A-41EC-A1CB-4C5F520DDD53}.Release|Any CPU.Build.0 = Release|Any CPU + {25A3BC33-563A-41EC-A1CB-4C5F520DDD53}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {25A3BC33-563A-41EC-A1CB-4C5F520DDD53}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {25A3BC33-563A-41EC-A1CB-4C5F520DDD53}.Release|x64.ActiveCfg = Release|Any CPU + {25A3BC33-563A-41EC-A1CB-4C5F520DDD53}.Release|x64.Build.0 = Release|Any CPU + {25A3BC33-563A-41EC-A1CB-4C5F520DDD53}.Release|x86.ActiveCfg = Release|Any CPU + {25A3BC33-563A-41EC-A1CB-4C5F520DDD53}.Release|x86.Build.0 = Release|Any CPU + {25A3BC33-563A-41EC-A1CB-4C5F520DDD53}.ReleaseTest|Any CPU.ActiveCfg = Release|Any CPU + {25A3BC33-563A-41EC-A1CB-4C5F520DDD53}.ReleaseTest|Any CPU.Build.0 = Release|Any CPU + {25A3BC33-563A-41EC-A1CB-4C5F520DDD53}.ReleaseTest|Mixed Platforms.ActiveCfg = Release|Any CPU + {25A3BC33-563A-41EC-A1CB-4C5F520DDD53}.ReleaseTest|Mixed Platforms.Build.0 = Release|Any CPU + {25A3BC33-563A-41EC-A1CB-4C5F520DDD53}.ReleaseTest|x64.ActiveCfg = Release|Any CPU + {25A3BC33-563A-41EC-A1CB-4C5F520DDD53}.ReleaseTest|x64.Build.0 = Release|Any CPU + {25A3BC33-563A-41EC-A1CB-4C5F520DDD53}.ReleaseTest|x86.ActiveCfg = Release|Any CPU + {25A3BC33-563A-41EC-A1CB-4C5F520DDD53}.ReleaseTest|x86.Build.0 = Release|Any CPU + {25A3BC33-563A-41EC-A1CB-4C5F520DDD53}.XP32bit|Any CPU.ActiveCfg = Release|Any CPU + {25A3BC33-563A-41EC-A1CB-4C5F520DDD53}.XP32bit|Any CPU.Build.0 = Release|Any CPU + {25A3BC33-563A-41EC-A1CB-4C5F520DDD53}.XP32bit|Mixed Platforms.ActiveCfg = Release|Any CPU + {25A3BC33-563A-41EC-A1CB-4C5F520DDD53}.XP32bit|Mixed Platforms.Build.0 = Release|Any CPU + {25A3BC33-563A-41EC-A1CB-4C5F520DDD53}.XP32bit|x64.ActiveCfg = Release|Any CPU + {25A3BC33-563A-41EC-A1CB-4C5F520DDD53}.XP32bit|x64.Build.0 = Release|Any CPU + {25A3BC33-563A-41EC-A1CB-4C5F520DDD53}.XP32bit|x86.ActiveCfg = Release|Any CPU + {25A3BC33-563A-41EC-A1CB-4C5F520DDD53}.XP32bit|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -6052,6 +6118,7 @@ Global {B2EAC69C-22C9-41D5-987B-5E1F435C0CBC} = {A778164E-C265-4B13-82A1-FF227AC3D668} {7C77A79B-646C-4CF8-AD1C-930E0B059829} = {B2EAC69C-22C9-41D5-987B-5E1F435C0CBC} {91CA9896-2288-4967-8991-AC49A77B6058} = {7C77A79B-646C-4CF8-AD1C-930E0B059829} + {25A3BC33-563A-41EC-A1CB-4C5F520DDD53} = {03D4F23E-7E4A-4091-BC96-036C996D351A} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {4BCB7B69-696C-436A-86F7-C91EA5588164} diff --git a/Common/CommonConsole/CommonConsole.csproj b/Common/CommonConsole/CommonConsole.csproj index 2301cee5..9e65aefb 100644 --- a/Common/CommonConsole/CommonConsole.csproj +++ b/Common/CommonConsole/CommonConsole.csproj @@ -70,10 +70,6 @@ {62490923-CD17-45A6-B79F-A027927C75B5} Common.Logic.Extensions.SQL - - {1057AD21-BA22-4CAB-B3FE-88C5C9980E6A} - MeterProcessState - diff --git a/Common/CommonConsole/Program.cs b/Common/CommonConsole/Program.cs index ecbd9f6e..483cfeb9 100644 --- a/Common/CommonConsole/Program.cs +++ b/Common/CommonConsole/Program.cs @@ -1,124 +1,148 @@ namespace CommonConsole { - using Common.Hardware.SIRT; - using Common.Hardware.SIRT.Parameters; using Common.Hardware.WaterMeter.eRegister; using Common.Hardware.WaterMeter.eRegister.Features; - using Newtonsoft.Json; + using Common.Hardware.WaterMeter.eRegister.Models; using System; - using System.Collections.Concurrent; - using System.IO; - using System.Net; - using System.Net.Http; - using static Xylem.Common.Service.MeterProcessState.Controllers.OldPasswordController; + using System.Collections.Generic; + using System.Linq; + using System.Reflection; - public class Program + public static class Program { + public class FeatureDictionary : SortedDictionary + { + public PropertyInfo FeatureInfo { get; set; } + } + public static void Main() { + var features = new SortedDictionary>>(); - ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => + void ParseType(Type type) { - return true; - }; - // $"https://nodes.sms-esaap.com:8081/api/v3/custom/keysetkeys?orderNumber=3229547&radioAdress=241630563" - using (var request = new HttpRequestMessage(HttpMethod.Put, $"https://nodes.sms-esaap.com:8081/api/v3/custom/keysetkeys?orderNumber=3229547&radioAdress=241630563")) - { - request.Headers.Add("Cache-Control", "no-cache"); - request.Headers.Add("X-Node-Token", "d5b8c0b2-81f6-4421-80d0-44eb2093e616"); - - using (var response = new HttpClient().SendAsync(request).Result) + foreach (var property in type.GetProperties(BindingFlags.Public | BindingFlags.Instance)) { - var content = response.Content.ReadAsStringAsync().Result; - var x = MeterPw.FromJson(content); + var propertyType = property.PropertyType; + + if (!typeof(Pam).IsAssignableFrom(propertyType)) + { + continue; + } + + var pamAttribute = property.GetCustomAttribute(); + + if (pamAttribute is null) + { + continue; + } + + var isSingleCmd = pamAttribute.IsSingleCmd; + + if (!features.ContainsKey(isSingleCmd)) + { + features[isSingleCmd] = new SortedDictionary>(); + } + + var _features = features[isSingleCmd]; + var authBytes = pamAttribute.AuthLevel.AuthBytes(); + var authLevel = $"{authBytes.LastOrDefault():X2}"; + + if (authBytes.Length > 0) + { + authLevel = $"{authBytes[1]:X2}"; + } + + if (!_features.ContainsKey(authLevel)) + { + _features[authLevel] = new SortedDictionary(); + } + + var __features = _features[authLevel]; + var pam = Activator.CreateInstance(property.PropertyType) as Pam; + var cmdHex = pam.CmdHex; + + if (cmdHex.Length == 2) + { + cmdHex = $"00-{cmdHex}"; + } + + if (!__features.ContainsKey(cmdHex)) + { + __features[cmdHex] = new FeatureDictionary(); + } + + var ___features = __features[cmdHex]; + ___features.FeatureInfo = property; + + foreach (var _property in propertyType.GetProperties(BindingFlags.Public | BindingFlags.Instance)) + { + if (_property.CanWrite && _property.PropertyType != typeof(byte[])) + { + ___features[_property.Name] = _property; + } + } } } - //var client = new SIRTClient("COM6"); + ParseType(typeof(EregisterFeatures)); + ParseType(typeof(EregisterDebugFeatures)); - //client.OpenConnection(); - //Console.ReadKey(); - //client.CloseConnection(); - } - } + var types = new HashSet(); - public class SIRTClient - { - private readonly ConcurrentDictionary tasks; - private readonly SIRTBroadcaster broadcaster; - - public SIRTClient(string comPort) - { - this.tasks = new ConcurrentDictionary(); - this.broadcaster = new SIRTBroadcaster(comPort); - this.broadcaster.Activated += this.Broadcaster_Activated; - this.broadcaster.Connected += this.Broadcaster_Connected; - this.broadcaster.Disconnected += this.Broadcaster_Disconnected; - this.broadcaster.Logging += this.Broadcaster_Logging; - this.broadcaster.MessageReceived += this.Broadcaster_MessageReceived; - } - - internal void CloseConnection() => this.broadcaster.Close(); - - internal void OpenConnection() => this.broadcaster.Open(); - - private void Broadcaster_Activated() - { - Console.WriteLine(nameof(Broadcaster_Activated)); - - this.tasks.GetOrAdd(4291796386, _ => + foreach (var kvp in features) { - var task = new EregisterTask(868) + Console.WriteLine(kvp.Key ? "Single PAM:" : "Combined PAM:"); + + foreach (var _kvp in kvp.Value) { - Cmd = SIRTMessage.W_PAM, - P1 = new P811 + Console.WriteLine($" Auth level {_kvp.Key}:"); + + foreach (var __kvp in _kvp.Value) { - DelPamSemi = true, - }, - Data = new ChangeRadioId - { - Address = 309030150 + Console.WriteLine($" {__kvp.Key} {__kvp.Value.FeatureInfo.Name}"); - }.Append(new ProvidePin - { - AuthLevel = AuthLevel.III - }), - RequestAddress = 4291796386, - ResponseAddress = 309030150 - }; + foreach (var ___kvp in __kvp.Value) + { + Console.WriteLine($"\t\t{___kvp.Key} - {___kvp.Value.PropertyType.Name}"); - task.Completed += this.Task_Completed; + types.Add(___kvp.Value.PropertyType.Name); + } + } + } + } - this.broadcaster.EnqueueTask(task); + Console.WriteLine(); - return task; - }); - } + var _types = types.ToList(); + _types.Sort(); - private void Broadcaster_Connected() => Console.WriteLine(nameof(Broadcaster_Connected)); - - private void Broadcaster_Disconnected() => Console.WriteLine(nameof(Broadcaster_Disconnected)); - - private void Broadcaster_Logging(string message) - { - - } - - private void Broadcaster_MessageReceived(SIRTMessage message) - { - - } - - private void Task_Completed(SIRTTask task) - { - task.Completed -= this.Task_Completed; - - Console.WriteLine($"Task_Completed: {task}"); - File.WriteAllText($"..\\..\\Tasks\\{task.RequestAddress}.json", JsonConvert.SerializeObject(task, new JsonSerializerSettings + foreach (var type in _types) { - Formatting = Formatting.Indented - })); + Console.WriteLine(type); + } + + Console.WriteLine(); } } -} \ No newline at end of file +} + +//AuthLevel +//Boolean +//Byte +//DecimalPointLocations +//FactoryState +//Int32 +//MBusModes +//MessurementUnits +//MeterTypes +//Options +//OTAMode +//RegisterMode +//ResetMode +//String +//Types +//UInt16 +//UInt32 +//WakeUpMode \ No newline at end of file diff --git a/Common/Hardware/Common.Hardware.Ports/SerialDataExtensions.cs b/Common/Hardware/Common.Hardware.Ports/SerialDataExtensions.cs index 9e1a8411..893d1674 100644 --- a/Common/Hardware/Common.Hardware.Ports/SerialDataExtensions.cs +++ b/Common/Hardware/Common.Hardware.Ports/SerialDataExtensions.cs @@ -1,32 +1,54 @@ namespace Common.Hardware.Ports { + using System; using System.Collections.Generic; using System.Text.RegularExpressions; public static class SerialDataExtensions { + private const int ByteSize = 8; + private const int SByteSize = 16; + private const int Int16Size = 16; + private const int UInt16Size = 16; + private const int Int32Size = 32; + private const int UInt32Size = 32; + private const int Int64Size = 64; + private const int UInt64Size = 64; + public static byte[] GetBitsBE(this byte value) { - var bytes = new byte[8]; + var bits = new byte[ByteSize]; for (int i = 7, x = 0; i >= 0; i--, x++) { - bytes[x] = (byte)((value >> i) % 2); + bits[x] = (byte)((value >> i) & 1); } - return bytes; + return bits; } public static byte[] GetBitsLE(this byte value) { - var bytes = new byte[8]; + var bits = new byte[ByteSize]; - for (var i = 0; i < 8; i++) + for (var i = 0; i < ByteSize; i++) { - bytes[i] = (byte)((value >> i) % 2); + bits[i] = (byte)((value >> i) & 1); } - return bytes; + return bits; + } + + public static byte[] GetBitsLE(this ushort value) + { + var bits = new byte[UInt16Size]; + + for (var i = 0; i < UInt16Size; i++) + { + bits[i] = (byte)((value >> i) & 1); + } + + return bits; } public static byte GetByteLE(this byte[] bits) @@ -38,7 +60,7 @@ var value = default(byte); - for (var i = 0; i < 8; i++) + for (var i = 0; i < ByteSize; i++) { value ^= (byte)(bits[i] << i); } @@ -417,6 +439,27 @@ return value; } + public static ushort ToUIint16LEFromBits(this byte[] bits) + { + const int size = 16; + + if (bits is null) + { + bits = new byte[size]; + } + + Array.Resize(ref bits, size); + + ushort value = 0; + + for (var i = 0; i < size; i++) + { + value ^= (ushort)(bits[i] << i); + } + + return value; + } + public static uint ToUInt32LE(this byte[] bytes, int start = 0) { var value = default(uint); diff --git a/Common/Hardware/Common.Hardware.SIRT/SIRTBroadcaster.Internal.cs b/Common/Hardware/Common.Hardware.SIRT/SIRTBroadcaster.Internal.cs index f03c9878..2fe77f9c 100644 --- a/Common/Hardware/Common.Hardware.SIRT/SIRTBroadcaster.Internal.cs +++ b/Common/Hardware/Common.Hardware.SIRT/SIRTBroadcaster.Internal.cs @@ -161,23 +161,15 @@ this.processingTask = Task.Factory.StartNew(() => { var manualResetEventSlim = new ManualResetEventSlim(); - var addresses = default(ICollection); while (!this.cancellationToken.IsCancellationRequested) { - // addresses = this.GetAddressesInPamPool(); - foreach (var tasksQueue in this.tasks.Values.ToArray()) { if (tasksQueue.TryPeek(out var task) && task.State == SIRTTaskState.Pending) { - // if (addresses.Count < 5 && !addresses.Any(x => x == task.RequestAddress) && !addresses.Any(x => x == task.ResponseAddress)) - { - this.serialPort.Write(task.Start()); - this.Logging?.Invoke(task.ToString()); - - // addresses.Add(task.RequestAddress); - } + this.serialPort.Write(task.Start()); + this.Logging?.Invoke(task.ToString()); } manualResetEventSlim.Wait(100); diff --git a/Common/Hardware/WaterMeter/eRegister/Common.Hardware.WaterMeter.eRegister/EregisterCheckFinalizationTask.cs b/Common/Hardware/WaterMeter/eRegister/Common.Hardware.WaterMeter.eRegister/EregisterCheckFinalizationTask.cs index 6a5f50ed..b7a27551 100644 --- a/Common/Hardware/WaterMeter/eRegister/Common.Hardware.WaterMeter.eRegister/EregisterCheckFinalizationTask.cs +++ b/Common/Hardware/WaterMeter/eRegister/Common.Hardware.WaterMeter.eRegister/EregisterCheckFinalizationTask.cs @@ -100,14 +100,10 @@ private EregisterProgrammingParameters GetProgrammingParameters() { var alarms = new AlarmsMask(this.SEMI.AlarmActiveInformation); - var dataLogContent = new ChangeDataLoggerSettings - { - LogContent = this.SEMI.LogContent - }; - var fdrLogContent = new ChangeDataLoggerSettings - { - LogContent = this.SEMI.FixedDateReadingContent - }; + var dataLogContent = new ChangeDataLoggerSettings(); + dataLogContent.SetLogContent(this.SEMI.LogContent); + var fdrLogContent = new ChangeDataLoggerSettings(); + fdrLogContent.SetLogContent(this.SEMI.FixedDateReadingContent); var parameters = new EregisterProgrammingParameters { diff --git a/Common/Hardware/WaterMeter/eRegister/Common.Hardware.WaterMeter.eRegister/EregisterExtensions.cs b/Common/Hardware/WaterMeter/eRegister/Common.Hardware.WaterMeter.eRegister/EregisterExtensions.cs index 7530c7e9..f14df26e 100644 --- a/Common/Hardware/WaterMeter/eRegister/Common.Hardware.WaterMeter.eRegister/EregisterExtensions.cs +++ b/Common/Hardware/WaterMeter/eRegister/Common.Hardware.WaterMeter.eRegister/EregisterExtensions.cs @@ -207,7 +207,7 @@ if (authLevel != AuthLevel.O) { - var _bytes = ((long)authLevel).GetBytesLE(); + var _bytes = ((ulong)authLevel).GetBytesLE(); Array.Resize(ref bytes, 6); Array.Copy(_bytes, 0, bytes, 0, 6); diff --git a/Common/Hardware/WaterMeter/eRegister/Common.Hardware.WaterMeter.eRegister/Features/ChangeDataLoggerSettings.cs b/Common/Hardware/WaterMeter/eRegister/Common.Hardware.WaterMeter.eRegister/Features/ChangeDataLoggerSettings.cs index b98e45fa..d6798580 100644 --- a/Common/Hardware/WaterMeter/eRegister/Common.Hardware.WaterMeter.eRegister/Features/ChangeDataLoggerSettings.cs +++ b/Common/Hardware/WaterMeter/eRegister/Common.Hardware.WaterMeter.eRegister/Features/ChangeDataLoggerSettings.cs @@ -4,96 +4,106 @@ public class ChangeDataLoggerSettings : Pam { + private readonly byte[] contentBits = new byte[16]; + public ChangeDataLoggerSettings() : base(5, ChangeDataLoggerSettings) { } public ushort TimeInterval { get; set; } - - public ushort LogContent { get; set; } - public byte ForwardCounter + public ushort LogContent => this.contentBits.ToUIint16LEFromBits(); + + public bool ForwardCounter { - get => (byte)(this.LogContent >> 12 & 1); - set => this.LogContent ^= (ushort)(value << 12); + get => this.contentBits[12] == 1; + set => this.contentBits[12] = (byte)(value ? 1 : 0); } - public byte TimeOfMinimumFlow + public bool TimeOfMinimumFlow { - get => (byte)(this.LogContent >> 11 & 1); - set => this.LogContent ^= (ushort)(value << 11); + get => this.contentBits[11] == 1; + set => this.contentBits[11] = (byte)(value ? 1 : 0); } - public byte MinimumFlow + public bool MinimumFlow { - get => (byte)(this.LogContent >> 10 & 1); - set => this.LogContent ^= (ushort)(value << 10); + get => this.contentBits[10] == 1; + set => this.contentBits[10] = (byte)(value ? 1 : 0); } - public byte TimeOfBrokenPipe + public bool TimeOfBrokenPipe { - get => (byte)(this.LogContent >> 9 & 1); - set => this.LogContent ^= (ushort)(value << 9); + get => this.contentBits[9] == 1; + set => this.contentBits[9] = (byte)(value ? 1 : 0); } - public byte BrokenPipeFlow + public bool BrokenPipeFlow { - get => (byte)(this.LogContent >> 8 & 1); - set => this.LogContent ^= (ushort)(value << 8); + get => this.contentBits[8] == 1; + set => this.contentBits[8] = (byte)(value ? 1 : 0); } - public byte CurrentFlow + public bool CurrentFlow { - get => (byte)(this.LogContent >> 7 & 1); - set => this.LogContent ^= (ushort)(value << 7); + get => this.contentBits[7] == 1; + set => this.contentBits[7] = (byte)(value ? 1 : 0); } - public byte TimeOfPeakFlow + public bool TimeOfPeakFlow { - get => (byte)(this.LogContent >> 6 & 1); - set => this.LogContent ^= (ushort)(value << 6); + get => this.contentBits[6] == 1; + set => this.contentBits[6] = (byte)(value ? 1 : 0); } - public byte PeakFlow + public bool PeakFlow { - get => (byte)(this.LogContent >> 5 & 1); - set => this.LogContent ^= (ushort)(value << 5); + get => this.contentBits[5] == 1; + set => this.contentBits[5] = (byte)(value ? 1 : 0); } - public byte TimeOfMaximumFlow + public bool TimeOfMaximumFlow { - get => (byte)(this.LogContent >> 4 & 1); - set => this.LogContent ^= (ushort)(value << 4); + get => this.contentBits[4] == 1; + set => this.contentBits[4] = (byte)(value ? 1 : 0); } - public byte MaximumFlow + public bool MaximumFlow { - get => (byte)(this.LogContent >> 3 & 1); - set => this.LogContent ^= (ushort)(value << 3); + get => this.contentBits[3] == 1; + set => this.contentBits[3] = (byte)(value ? 1 : 0); } - public byte BackwardVolume + public bool BackwardVolume { - get => (byte)(this.LogContent >> 2 & 1); - set => this.LogContent ^= (ushort)(value << 2); + get => this.contentBits[2] == 1; + set => this.contentBits[2] = (byte)(value ? 1 : 0); } - public byte Counter + public bool Counter { - get => (byte)(this.LogContent >> 1 & 1); - set => this.LogContent ^= (ushort)(value << 1); + get => this.contentBits[1] == 1; + set => this.contentBits[1] = (byte)(value ? 1 : 0); } - public byte AlarmState + public bool AlarmState { - get => (byte)(this.LogContent >> 0 & 1); - set => this.LogContent ^= (ushort)(value << 0); + get => this.contentBits[0] == 1; + set => this.contentBits[0] = (byte)(value ? 1 : 0); } + public void SetLogContent(ushort value) + => value.GetBitsLE() + .CopyTo(this.contentBits, 0); + public override byte[] ToByteArray() { - this.TimeInterval.GetBytesBE().CopyTo(this.bytes, 1); - this.LogContent.GetBytesBE().CopyTo(this.bytes, 3); + this.TimeInterval + .GetBytesBE() + .CopyTo(this.bytes, 1); + this.LogContent + .GetBytesBE() + .CopyTo(this.bytes, 3); return base.ToByteArray(); } diff --git a/Common/Hardware/WaterMeter/eRegister/Common.Hardware.WaterMeter.eRegister/Features/ChangeFixedDateReadingSettings.cs b/Common/Hardware/WaterMeter/eRegister/Common.Hardware.WaterMeter.eRegister/Features/ChangeFixedDateReadingSettings.cs index 818e7e7c..1afad12b 100644 --- a/Common/Hardware/WaterMeter/eRegister/Common.Hardware.WaterMeter.eRegister/Features/ChangeFixedDateReadingSettings.cs +++ b/Common/Hardware/WaterMeter/eRegister/Common.Hardware.WaterMeter.eRegister/Features/ChangeFixedDateReadingSettings.cs @@ -4,6 +4,8 @@ public class ChangeFixedDateReadingSettings : Pam { + private readonly byte[] contentBits = new byte[16]; + public ChangeFixedDateReadingSettings() : base(4, ChangeFixedDateReadingSettings) { } @@ -14,88 +16,97 @@ set => this.bytes[1] = value; } - public ushort LogContent + public ushort LogContent => this.contentBits.ToUIint16LEFromBits(); + + public bool ForwardCounter { - get => this.bytes.ToUInt16BE(2); - set => value.GetBytesBE().CopyTo(this.bytes, 2); + get => this.contentBits[12] == 1; + set => this.contentBits[12] = (byte)(value ? 1 : 0); } - public byte ForwardCounter + public bool TimeOfMinimumFlow { - get => (byte)(this.LogContent >> 12 & 1); - set => this.LogContent ^= (ushort)(value << 12); + get => this.contentBits[11] == 1; + set => this.contentBits[11] = (byte)(value ? 1 : 0); } - public byte TimeOfMinimumFlow + public bool MinimumFlow { - get => (byte)(this.LogContent >> 11 & 1); - set => this.LogContent ^= (ushort)(value << 11); + get => this.contentBits[10] == 1; + set => this.contentBits[10] = (byte)(value ? 1 : 0); } - public byte MinimumFlow + public bool TimeOfBrokenPipe { - get => (byte)(this.LogContent >> 10 & 1); - set => this.LogContent ^= (ushort)(value << 10); + get => this.contentBits[9] == 1; + set => this.contentBits[9] = (byte)(value ? 1 : 0); } - public byte TimeOfBrokenPipe + public bool BrokenPipeFlow { - get => (byte)(this.LogContent >> 9 & 1); - set => this.LogContent ^= (ushort)(value << 9); + get => this.contentBits[8] == 1; + set => this.contentBits[8] = (byte)(value ? 1 : 0); } - public byte BrokenPipeFlow + public bool CurrentFlow { - get => (byte)(this.LogContent >> 8 & 1); - set => this.LogContent ^= (ushort)(value << 8); + get => this.contentBits[7] == 1; + set => this.contentBits[7] = (byte)(value ? 1 : 0); } - public byte CurrentFlow + public bool TimeOfPeakFlow { - get => (byte)(this.LogContent >> 7 & 1); - set => this.LogContent ^= (ushort)(value << 7); + get => this.contentBits[6] == 1; + set => this.contentBits[6] = (byte)(value ? 1 : 0); } - public byte TimeOfPeakFlow + public bool PeakFlow { - get => (byte)(this.LogContent >> 6 & 1); - set => this.LogContent ^= (ushort)(value << 6); + get => this.contentBits[5] == 1; + set => this.contentBits[5] = (byte)(value ? 1 : 0); } - public byte PeakFlow + public bool TimeOfMaximumFlow { - get => (byte)(this.LogContent >> 5 & 1); - set => this.LogContent ^= (ushort)(value << 5); + get => this.contentBits[4] == 1; + set => this.contentBits[4] = (byte)(value ? 1 : 0); } - public byte TimeOfMaximumFlow + public bool MaximumFlow { - get => (byte)(this.LogContent >> 4 & 1); - set => this.LogContent ^= (ushort)(value << 4); + get => this.contentBits[3] == 1; + set => this.contentBits[3] = (byte)(value ? 1 : 0); } - public byte MaximumFlow + public bool BackwardVolume { - get => (byte)(this.LogContent >> 3 & 1); - set => this.LogContent ^= (ushort)(value << 3); + get => this.contentBits[2] == 1; + set => this.contentBits[2] = (byte)(value ? 1 : 0); } - public byte BackwardVolume + public bool Counter { - get => (byte)(this.LogContent >> 2 & 1); - set => this.LogContent ^= (ushort)(value << 2); + get => this.contentBits[1] == 1; + set => this.contentBits[1] = (byte)(value ? 1 : 0); } - public byte Counter + public bool AlarmState { - get => (byte)(this.LogContent >> 1 & 1); - set => this.LogContent ^= (ushort)(value << 1); + get => this.contentBits[0] == 1; + set => this.contentBits[0] = (byte)(value ? 1 : 0); } - public byte AlarmState + public void SetLogContent(ushort value) + => value.GetBitsLE() + .CopyTo(this.contentBits, 0); + + public override byte[] ToByteArray() { - get => (byte)(this.LogContent >> 0 & 1); - set => this.LogContent ^= (ushort)(value << 0); + this.LogContent + .GetBytesBE() + .CopyTo(this.bytes, 3); + + return base.ToByteArray(); } } } diff --git a/Common/Hardware/WaterMeter/eRegister/Common.Hardware.WaterMeter.eRegister/Features/ChangeSensusRFEncryptionKey.cs b/Common/Hardware/WaterMeter/eRegister/Common.Hardware.WaterMeter.eRegister/Features/ChangeSensusRFEncryptionKey.cs index ab0f7839..e66b33b5 100644 --- a/Common/Hardware/WaterMeter/eRegister/Common.Hardware.WaterMeter.eRegister/Features/ChangeSensusRFEncryptionKey.cs +++ b/Common/Hardware/WaterMeter/eRegister/Common.Hardware.WaterMeter.eRegister/Features/ChangeSensusRFEncryptionKey.cs @@ -34,7 +34,9 @@ public string HexKey { - get => BitConverter.ToString(this.Key).Replace("-", string.Empty); + get => BitConverter + .ToString(this.Key) + .Replace("-", string.Empty); set => this.Key = value.GetEncryptionKey(); } } diff --git a/Common/Hardware/WaterMeter/eRegister/Common.Hardware.WaterMeter.eRegister/Features/DebugCmd.cs b/Common/Hardware/WaterMeter/eRegister/Common.Hardware.WaterMeter.eRegister/Features/DebugCmd.cs index c8f1a46d..82be7450 100644 --- a/Common/Hardware/WaterMeter/eRegister/Common.Hardware.WaterMeter.eRegister/Features/DebugCmd.cs +++ b/Common/Hardware/WaterMeter/eRegister/Common.Hardware.WaterMeter.eRegister/Features/DebugCmd.cs @@ -5,6 +5,8 @@ protected DebugCmd(byte code) : base(3, GetDebug) => this.bytes[2] = code; + public override string CmdHex => $"{base.CmdHex}-{this.bytes[2]:X2}"; + public static implicit operator byte[](DebugCmd cmd) => cmd.bytes; /// diff --git a/Common/Hardware/WaterMeter/eRegister/Common.Hardware.WaterMeter.eRegister/Features/Pam.cs b/Common/Hardware/WaterMeter/eRegister/Common.Hardware.WaterMeter.eRegister/Features/Pam.cs index 2a5599c4..c7e793ad 100644 --- a/Common/Hardware/WaterMeter/eRegister/Common.Hardware.WaterMeter.eRegister/Features/Pam.cs +++ b/Common/Hardware/WaterMeter/eRegister/Common.Hardware.WaterMeter.eRegister/Features/Pam.cs @@ -12,6 +12,8 @@ this.bytes[0] = cmd; } + public virtual string CmdHex => $"{this.bytes[0]:X2}"; + public Pam Append(Pam pam) { var appendBytes = pam.ToByteArray(); diff --git a/Common/Hardware/WaterMeter/eRegister/Common.Hardware.WaterMeter.eRegister/Models/EregisterProgrammingParameters.cs b/Common/Hardware/WaterMeter/eRegister/Common.Hardware.WaterMeter.eRegister/Models/EregisterProgrammingParameters.cs index 854f5d59..c996a37f 100644 --- a/Common/Hardware/WaterMeter/eRegister/Common.Hardware.WaterMeter.eRegister/Models/EregisterProgrammingParameters.cs +++ b/Common/Hardware/WaterMeter/eRegister/Common.Hardware.WaterMeter.eRegister/Models/EregisterProgrammingParameters.cs @@ -123,85 +123,85 @@ public ushort Data_Logging_Period { get; set; } [CompareProperty] - public byte Data_Logging_Forward_Counter { get; set; } + public bool Data_Logging_Forward_Counter { get; set; } [CompareProperty] - public byte Data_Logging_Time_Of_Minimum_Flow { get; set; } + public bool Data_Logging_Time_Of_Minimum_Flow { get; set; } [CompareProperty] - public byte Data_Logging_Minimum_Flow { get; set; } + public bool Data_Logging_Minimum_Flow { get; set; } [CompareProperty] - public byte Data_Logging_Time_Of_Broken_Pipe { get; set; } + public bool Data_Logging_Time_Of_Broken_Pipe { get; set; } [CompareProperty] - public byte Data_Logging_Broken_Pipe_Flow { get; set; } + public bool Data_Logging_Broken_Pipe_Flow { get; set; } [CompareProperty] - public byte Data_Logging_Current_Flow { get; set; } + public bool Data_Logging_Current_Flow { get; set; } [CompareProperty] - public byte Data_Logging_Time_Of_Peak_Flow { get; set; } + public bool Data_Logging_Time_Of_Peak_Flow { get; set; } [CompareProperty] - public byte Data_Logging_Peak_Flow { get; set; } + public bool Data_Logging_Peak_Flow { get; set; } [CompareProperty] - public byte Data_Logging_Time_Of_Maximum_Flow { get; set; } + public bool Data_Logging_Time_Of_Maximum_Flow { get; set; } [CompareProperty] - public byte Data_Logging_Maximum_Flow { get; set; } + public bool Data_Logging_Maximum_Flow { get; set; } [CompareProperty] - public byte Data_Logging_Backward_Volume { get; set; } + public bool Data_Logging_Backward_Volume { get; set; } [CompareProperty] - public byte Data_Logging_Counter { get; set; } + public bool Data_Logging_Counter { get; set; } [CompareProperty] - public byte Data_Logging_Alarm_State { get; set; } + public bool Data_Logging_Alarm_State { get; set; } [CompareProperty] public byte FDR_Day_Of_Data_Reading { get; set; } [CompareProperty] - public byte FDR_Forward_Counter { get; set; } + public bool FDR_Forward_Counter { get; set; } [CompareProperty] - public byte FDR_Time_Of_Minimum_Flow { get; set; } + public bool FDR_Time_Of_Minimum_Flow { get; set; } [CompareProperty] - public byte FDR_Minimum_Flow { get; set; } + public bool FDR_Minimum_Flow { get; set; } [CompareProperty] - public byte FDR_Time_Of_Broken_Pipe { get; set; } + public bool FDR_Time_Of_Broken_Pipe { get; set; } [CompareProperty] - public byte FDR_Broken_Pipe_Flow { get; set; } + public bool FDR_Broken_Pipe_Flow { get; set; } [CompareProperty] - public byte FDR_Current_Flow { get; set; } + public bool FDR_Current_Flow { get; set; } [CompareProperty] - public byte FDR_Time_Of_Peak_Flow { get; set; } + public bool FDR_Time_Of_Peak_Flow { get; set; } [CompareProperty] - public byte FDR_Peak_Flow { get; set; } + public bool FDR_Peak_Flow { get; set; } [CompareProperty] - public byte FDR_Time_Of_Maximum_Flow { get; set; } + public bool FDR_Time_Of_Maximum_Flow { get; set; } [CompareProperty] - public byte FDR_Maximum_Flow { get; set; } + public bool FDR_Maximum_Flow { get; set; } [CompareProperty] - public byte FDR_Backward_Volume { get; set; } + public bool FDR_Backward_Volume { get; set; } [CompareProperty] - public byte FDR_Counter { get; set; } + public bool FDR_Counter { get; set; } [CompareProperty] - public byte FDR_Alarm_State { get; set; } + public bool FDR_Alarm_State { get; set; } public byte PowerLevelHex { get; set; } diff --git a/Common/Ui/Common.GUI/App.config b/Common/Ui/Common.GUI/App.config new file mode 100644 index 00000000..1fff8fbf --- /dev/null +++ b/Common/Ui/Common.GUI/App.config @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Common/Ui/Common.GUI/App.xaml b/Common/Ui/Common.GUI/App.xaml new file mode 100644 index 00000000..bda5c114 --- /dev/null +++ b/Common/Ui/Common.GUI/App.xaml @@ -0,0 +1,9 @@ + + + + + diff --git a/Common/Ui/Common.GUI/App.xaml.cs b/Common/Ui/Common.GUI/App.xaml.cs new file mode 100644 index 00000000..53bdd1f0 --- /dev/null +++ b/Common/Ui/Common.GUI/App.xaml.cs @@ -0,0 +1,34 @@ +namespace Common.GUI +{ + using Common.GUI.Models.Base; + + using System; + using System.Text.RegularExpressions; + using System.Windows; + + public partial class App : Application + { + private void Application_Startup(object sender, StartupEventArgs args) + { + if (!User32DllImports.ShowRunningInstance()) + { + var mainWindow = new MainWindow(); + this.MainWindow = mainWindow; + this.MainWindow.Show(); + this.NavigateToPage(args, mainWindow); + } + } + + private void NavigateToPage(StartupEventArgs args, MainWindow mainWindow) + { + var argsLine = string.Join(" ", args.Args ?? Array.Empty()); + var pageMatch = Regex.Match(argsLine, "--page\\s*(?[a-zA-Z0-9]+)"); + + if (pageMatch.Success) + { + var page = $"Pages/{pageMatch.Groups["page"].Value}.xaml"; + mainWindow.Source = new Uri(page, UriKind.Relative); + } + } + } +} diff --git a/Common/Ui/Common.GUI/Common.GUI.csproj b/Common/Ui/Common.GUI/Common.GUI.csproj new file mode 100644 index 00000000..14bcb5ba --- /dev/null +++ b/Common/Ui/Common.GUI/Common.GUI.csproj @@ -0,0 +1,186 @@ + + + + + Debug + AnyCPU + {25A3BC33-563A-41EC-A1CB-4C5F520DDD53} + WinExe + Common.GUI + Common.GUI + v4.8.1 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + true + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + IDE0003;IDE0049; + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\..\packages\Microsoft.Bcl.AsyncInterfaces.9.0.1\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll + + + ..\..\packages\Microsoft.Extensions.DependencyInjection.9.0.1\lib\net462\Microsoft.Extensions.DependencyInjection.dll + + + ..\..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.9.0.1\lib\net462\Microsoft.Extensions.DependencyInjection.Abstractions.dll + + + + + + ..\..\packages\System.Runtime.CompilerServices.Unsafe.6.1.0\lib\net462\System.Runtime.CompilerServices.Unsafe.dll + + + ..\..\packages\System.Threading.Tasks.Extensions.4.6.0\lib\net462\System.Threading.Tasks.Extensions.dll + + + + + + + + + 4.0 + + + + + + + + MSBuild:Compile + Designer + + + EregisterFeaturesItemsControl.xaml + + + ManualProgrammingPage.xaml + + + + + + TestPage.xaml + + + + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + MSBuild:Compile + Designer + + + App.xaml + Code + + + + + + + + + + + MainLayout.xaml + + + MainMenu.xaml + + + MainPage.xaml + + + MainWindow.xaml + Code + + + Designer + MSBuild:Compile + + + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + ResXFileCodeGenerator + Resources.Designer.cs + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + + + + + + + + + {4E8BB839-D40A-488C-88CE-F21811F1F476} + Common.Hardware.WaterMeter.eRegister + + + + + del /Q /S *.xml *.pdb + + \ No newline at end of file diff --git a/Common/Ui/Common.GUI/Controls/Eregister/EregisterFeaturesItemsControl.xaml b/Common/Ui/Common.GUI/Controls/Eregister/EregisterFeaturesItemsControl.xaml new file mode 100644 index 00000000..e76da192 --- /dev/null +++ b/Common/Ui/Common.GUI/Controls/Eregister/EregisterFeaturesItemsControl.xaml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Common/Ui/Common.GUI/Controls/Eregister/EregisterFeaturesItemsControl.xaml.cs b/Common/Ui/Common.GUI/Controls/Eregister/EregisterFeaturesItemsControl.xaml.cs new file mode 100644 index 00000000..63cdb90c --- /dev/null +++ b/Common/Ui/Common.GUI/Controls/Eregister/EregisterFeaturesItemsControl.xaml.cs @@ -0,0 +1,9 @@ +namespace Common.GUI.Controls.Eregister +{ + using System.Windows.Controls; + + public partial class EregisterFeaturesItemsControl : ItemsControl + { + public EregisterFeaturesItemsControl() => this.InitializeComponent(); + } +} diff --git a/Common/Ui/Common.GUI/Controls/MainLayout.xaml b/Common/Ui/Common.GUI/Controls/MainLayout.xaml new file mode 100644 index 00000000..1b9d3881 --- /dev/null +++ b/Common/Ui/Common.GUI/Controls/MainLayout.xaml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + diff --git a/Common/Ui/Common.GUI/Controls/MainLayout.xaml.cs b/Common/Ui/Common.GUI/Controls/MainLayout.xaml.cs new file mode 100644 index 00000000..becad84e --- /dev/null +++ b/Common/Ui/Common.GUI/Controls/MainLayout.xaml.cs @@ -0,0 +1,44 @@ +namespace Common.GUI.Controls +{ + using System.Windows; + using System.Windows.Controls; + using System.Windows.Markup; + + [ContentProperty(nameof(Content))] + public partial class MainLayout : Grid + { + public static readonly DependencyProperty ContentProperty = DependencyProperty.Register( + name: nameof(Content) + , propertyType: typeof(Grid) + , ownerType: typeof(MainLayout) + , typeMetadata: new PropertyMetadata(default(Grid), ContentChanged)); + + public MainLayout() => this.InitializeComponent(); + + public Grid Content + { + get => this.GetValue(ContentProperty) as Grid; + set => this.SetValue(ContentProperty, value); + } + + private static void ContentChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs args) + { + if (dependencyObject is MainLayout mainLayout) + { + var children = mainLayout.Children; + + if (args.OldValue is UIElement oldContent) + { + children.Remove(oldContent); + } + + if (args.NewValue is UIElement newContent) + { + children.Insert(1, newContent); + + Grid.SetRow(newContent, 1); + } + } + } + } +} diff --git a/Common/Ui/Common.GUI/Controls/MainMenu.xaml b/Common/Ui/Common.GUI/Controls/MainMenu.xaml new file mode 100644 index 00000000..f6ef7fe3 --- /dev/null +++ b/Common/Ui/Common.GUI/Controls/MainMenu.xaml @@ -0,0 +1,10 @@ + + + + + + + diff --git a/Common/Ui/Common.GUI/Controls/MainMenu.xaml.cs b/Common/Ui/Common.GUI/Controls/MainMenu.xaml.cs new file mode 100644 index 00000000..3edb5a4d --- /dev/null +++ b/Common/Ui/Common.GUI/Controls/MainMenu.xaml.cs @@ -0,0 +1,9 @@ +namespace Common.GUI.Controls +{ + using System.Windows.Controls; + + public partial class MainMenu : Menu + { + public MainMenu() => this.InitializeComponent(); + } +} diff --git a/Common/Ui/Common.GUI/MainWindow.xaml b/Common/Ui/Common.GUI/MainWindow.xaml new file mode 100644 index 00000000..882d75bf --- /dev/null +++ b/Common/Ui/Common.GUI/MainWindow.xaml @@ -0,0 +1,6 @@ + + diff --git a/Common/Ui/Common.GUI/MainWindow.xaml.cs b/Common/Ui/Common.GUI/MainWindow.xaml.cs new file mode 100644 index 00000000..a5fd89b9 --- /dev/null +++ b/Common/Ui/Common.GUI/MainWindow.xaml.cs @@ -0,0 +1,9 @@ +namespace Common.GUI +{ + using System.Windows.Navigation; + + public partial class MainWindow : NavigationWindow + { + public MainWindow() => this.InitializeComponent(); + } +} diff --git a/Common/Ui/Common.GUI/Models/Base/User32DllImports.cs b/Common/Ui/Common.GUI/Models/Base/User32DllImports.cs new file mode 100644 index 00000000..0ffe13bd --- /dev/null +++ b/Common/Ui/Common.GUI/Models/Base/User32DllImports.cs @@ -0,0 +1,52 @@ +namespace Common.GUI.Models.Base +{ + using System; + using System.Diagnostics; + using System.Runtime.InteropServices; + + internal class User32DllImports + { + [DllImport("User32.dll", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + internal static extern bool IsIconic([In] IntPtr windowHandle); + + [DllImport("User32.dll", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + internal static extern bool SetForegroundWindow([In] IntPtr windowHandle); + + [DllImport("User32.dll", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + internal static extern bool ShowWindow([In] IntPtr windowHandle, [In] WindowCommands command); + + public static bool ShowRunningInstance() + { + var currentProcess = Process.GetCurrentProcess(); + var runningInstanceShown = false; + + foreach (var process in Process.GetProcessesByName(currentProcess.ProcessName)) + { + if (process.Id != currentProcess.Id && process.MainModule.FileName == currentProcess.MainModule.FileName) + { + var windowHandle = process.MainWindowHandle; + + if (windowHandle != IntPtr.Zero) + { + if (IsIconic(windowHandle)) + { + ShowWindow(windowHandle, WindowCommands.Restore); + } + + SetForegroundWindow(windowHandle); + App.Current.Shutdown(); + + runningInstanceShown = true; + + break; + } + } + } + + return runningInstanceShown; + } + } +} diff --git a/Common/Ui/Common.GUI/Models/Base/WindowCommands.cs b/Common/Ui/Common.GUI/Models/Base/WindowCommands.cs new file mode 100644 index 00000000..494266d2 --- /dev/null +++ b/Common/Ui/Common.GUI/Models/Base/WindowCommands.cs @@ -0,0 +1,17 @@ +namespace Common.GUI.Models.Base +{ + internal enum WindowCommands : int + { + Hide = 0x0, + ShowNormal = 0x1, + ShowMinimized = 0x2, + ShowMaximized = 0x3, + ShowNormalNotActive = 0x4, + Minimize = 0x6, + ShowMinimizedNotActive = 0x7, + ShowCurrentNotActive = 0x8, + Restore = 0x9, + ShowDefault = 0xA, + ForceMinimize = 0xB + } +} diff --git a/Common/Ui/Common.GUI/Pages/Eregister/ManualProgrammingPage.xaml b/Common/Ui/Common.GUI/Pages/Eregister/ManualProgrammingPage.xaml new file mode 100644 index 00000000..9478e280 --- /dev/null +++ b/Common/Ui/Common.GUI/Pages/Eregister/ManualProgrammingPage.xaml @@ -0,0 +1,158 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Common/Ui/Common.GUI/Pages/Eregister/ManualProgrammingPage.xaml.cs b/Common/Ui/Common.GUI/Pages/Eregister/ManualProgrammingPage.xaml.cs new file mode 100644 index 00000000..fc770be6 --- /dev/null +++ b/Common/Ui/Common.GUI/Pages/Eregister/ManualProgrammingPage.xaml.cs @@ -0,0 +1,9 @@ +namespace Common.GUI.Pages.Eregister +{ + using System.Windows.Controls; + + public partial class ManualProgrammingPage : Page + { + public ManualProgrammingPage() => this.InitializeComponent(); + } +} diff --git a/Common/Ui/Common.GUI/Pages/MainPage.xaml b/Common/Ui/Common.GUI/Pages/MainPage.xaml new file mode 100644 index 00000000..3f0ffc3d --- /dev/null +++ b/Common/Ui/Common.GUI/Pages/MainPage.xaml @@ -0,0 +1,10 @@ + + + + + + diff --git a/Common/Ui/Common.GUI/Pages/MainPage.xaml.cs b/Common/Ui/Common.GUI/Pages/MainPage.xaml.cs new file mode 100644 index 00000000..b0cb1c3c --- /dev/null +++ b/Common/Ui/Common.GUI/Pages/MainPage.xaml.cs @@ -0,0 +1,9 @@ +namespace Common.GUI +{ + using System.Windows.Controls; + + public partial class MainPage : Page + { + public MainPage() => this.InitializeComponent(); + } +} diff --git a/Common/Ui/Common.GUI/Pages/TestPage.xaml b/Common/Ui/Common.GUI/Pages/TestPage.xaml new file mode 100644 index 00000000..e764d3c7 --- /dev/null +++ b/Common/Ui/Common.GUI/Pages/TestPage.xaml @@ -0,0 +1,10 @@ + + + + + + diff --git a/Common/Ui/Common.GUI/Pages/TestPage.xaml.cs b/Common/Ui/Common.GUI/Pages/TestPage.xaml.cs new file mode 100644 index 00000000..482112ce --- /dev/null +++ b/Common/Ui/Common.GUI/Pages/TestPage.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Common.GUI.Pages +{ + /// + /// Interaction logic for TestPage.xaml + /// + public partial class TestPage : Page + { + public TestPage() + { + InitializeComponent(); + } + } +} diff --git a/Common/Ui/Common.UI.VFM/Properties/AssemblyInfo.cs b/Common/Ui/Common.GUI/Properties/AssemblyInfo.cs similarity index 94% rename from Common/Ui/Common.UI.VFM/Properties/AssemblyInfo.cs rename to Common/Ui/Common.GUI/Properties/AssemblyInfo.cs index 0734f41a..9b394dc2 100644 --- a/Common/Ui/Common.UI.VFM/Properties/AssemblyInfo.cs +++ b/Common/Ui/Common.GUI/Properties/AssemblyInfo.cs @@ -7,12 +7,12 @@ using System.Windows; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. -[assembly: AssemblyTitle("Common.UI.VFM")] +[assembly: AssemblyTitle("Common.GUI")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Common.UI.VFM")] -[assembly: AssemblyCopyright("Copyright © 2024")] +[assembly: AssemblyProduct("Common.GUI")] +[assembly: AssemblyCopyright("Copyright © 2025")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] diff --git a/Common/Ui/Common.UI.VFM/Properties/Resources.Designer.cs b/Common/Ui/Common.GUI/Properties/Resources.Designer.cs similarity index 82% rename from Common/Ui/Common.UI.VFM/Properties/Resources.Designer.cs rename to Common/Ui/Common.GUI/Properties/Resources.Designer.cs index c5e9f5f1..c3332d76 100644 --- a/Common/Ui/Common.UI.VFM/Properties/Resources.Designer.cs +++ b/Common/Ui/Common.GUI/Properties/Resources.Designer.cs @@ -8,10 +8,10 @@ // //------------------------------------------------------------------------------ -namespace Common.UI.VFM.Properties { - using System; - - +namespace Common.GUI.Properties +{ + + /// /// A strongly-typed resource class, for looking up localized strings, etc. /// @@ -19,43 +19,51 @@ namespace Common.UI.VFM.Properties { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources { - + internal class Resources + { + private static global::System.Resources.ResourceManager resourceMan; - + private static global::System.Globalization.CultureInfo resourceCulture; - + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() { + internal Resources() + { } - + /// /// Returns the cached ResourceManager instance used by this class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Common.UI.VFM.Properties.Resources", typeof(Resources).Assembly); + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Common.GUI.Properties.Resources", typeof(Resources).Assembly); resourceMan = temp; } return resourceMan; } } - + /// /// Overrides the current thread's CurrentUICulture property for all /// resource lookups using this strongly typed resource class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { + internal static global::System.Globalization.CultureInfo Culture + { + get + { return resourceCulture; } - set { + set + { resourceCulture = value; } } diff --git a/Common/Ui/Common.UI.VFM/Properties/Resources.resx b/Common/Ui/Common.GUI/Properties/Resources.resx similarity index 100% rename from Common/Ui/Common.UI.VFM/Properties/Resources.resx rename to Common/Ui/Common.GUI/Properties/Resources.resx diff --git a/Common/Ui/Common.UI.VFM/Properties/Settings.Designer.cs b/Common/Ui/Common.GUI/Properties/Settings.Designer.cs similarity index 82% rename from Common/Ui/Common.UI.VFM/Properties/Settings.Designer.cs rename to Common/Ui/Common.GUI/Properties/Settings.Designer.cs index 020e3775..741bf374 100644 --- a/Common/Ui/Common.UI.VFM/Properties/Settings.Designer.cs +++ b/Common/Ui/Common.GUI/Properties/Settings.Designer.cs @@ -8,17 +8,21 @@ // //------------------------------------------------------------------------------ -namespace Common.UI.VFM.Properties { - - +namespace Common.GUI.Properties +{ + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.9.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { - + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default { - get { + + public static Settings Default + { + get + { return defaultInstance; } } diff --git a/Common/Ui/Common.UI.VFM/Properties/Settings.settings b/Common/Ui/Common.GUI/Properties/Settings.settings similarity index 100% rename from Common/Ui/Common.UI.VFM/Properties/Settings.settings rename to Common/Ui/Common.GUI/Properties/Settings.settings diff --git a/Common/Ui/Common.GUI/ViewModels/Base/Command.cs b/Common/Ui/Common.GUI/ViewModels/Base/Command.cs new file mode 100644 index 00000000..36c5c599 --- /dev/null +++ b/Common/Ui/Common.GUI/ViewModels/Base/Command.cs @@ -0,0 +1,25 @@ +namespace Common.GUI.ViewModels.Base +{ + using System; + using System.Windows.Input; + + public class Command : ICommand + { + private readonly Action executable; + + public Command(Action executable) + => this.executable = executable; + + public event EventHandler CanExecuteChanged + { + add => CommandManager.RequerySuggested += value; + remove => CommandManager.RequerySuggested -= value; + } + + public bool CanExecute(object _) + => this.executable != null; + + public void Execute(object _) + => this.executable?.Invoke(); + } +} diff --git a/Common/Ui/Common.GUI/ViewModels/Base/Command[T].cs b/Common/Ui/Common.GUI/ViewModels/Base/Command[T].cs new file mode 100644 index 00000000..3054c5cb --- /dev/null +++ b/Common/Ui/Common.GUI/ViewModels/Base/Command[T].cs @@ -0,0 +1,25 @@ +namespace Common.GUI.ViewModels.Base +{ + using System; + using System.Windows.Input; + + public class Command : ICommand + { + private readonly Action executable; + + public Command(Action executable) + => this.executable = executable; + + public event EventHandler CanExecuteChanged + { + add => CommandManager.RequerySuggested += value; + remove => CommandManager.RequerySuggested -= value; + } + + public bool CanExecute(object _) + => this.executable != null; + + public void Execute(object o) + => this.executable?.Invoke(o is T t ? t : default(T)); + } +} diff --git a/Common/Ui/Common.GUI/ViewModels/Base/MessageHandler.cs b/Common/Ui/Common.GUI/ViewModels/Base/MessageHandler.cs new file mode 100644 index 00000000..dda5d4d8 --- /dev/null +++ b/Common/Ui/Common.GUI/ViewModels/Base/MessageHandler.cs @@ -0,0 +1,11 @@ +namespace Common.GUI.ViewModels.Base +{ + using Common.GUI.ViewModels.Controls; + + using System; + + public class MessageHandler + { + public event Action MessageReceived; + } +} diff --git a/Common/Ui/Common.GUI/ViewModels/Base/VM.cs b/Common/Ui/Common.GUI/ViewModels/Base/VM.cs new file mode 100644 index 00000000..e7a32eeb --- /dev/null +++ b/Common/Ui/Common.GUI/ViewModels/Base/VM.cs @@ -0,0 +1,31 @@ +namespace Common.GUI.ViewModels.Base +{ + using System; + using System.ComponentModel; + using System.Runtime.CompilerServices; + + public class VM : INotifyPropertyChanged, IDisposable + { + public VM() + { + + } + + public event PropertyChangedEventHandler PropertyChanged; + + public virtual void Dispose() + { + + } + + protected void NotifyPropertyChanged([CallerMemberName] string member = "") + => this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(member)); + + protected void SetValue(Action setterAction, [CallerMemberName] string member = "") + { + setterAction?.Invoke(); + + this.NotifyPropertyChanged(member); + } + } +} diff --git a/Common/Ui/Common.GUI/ViewModels/Base/VM[T].cs b/Common/Ui/Common.GUI/ViewModels/Base/VM[T].cs new file mode 100644 index 00000000..4cd5f9ce --- /dev/null +++ b/Common/Ui/Common.GUI/ViewModels/Base/VM[T].cs @@ -0,0 +1,18 @@ +namespace Common.GUI.ViewModels.Base +{ + using System; + using System.Runtime.CompilerServices; + + public class VM : VM where T : VM + { + protected void SetValue(Action setterAction, [CallerMemberName] string member = "") + { + if (this is T t) + { + setterAction?.Invoke(t); + + this.NotifyPropertyChanged(member); + } + } + } +} diff --git a/Common/Ui/Common.GUI/ViewModels/Controls/MainLayoutVM.cs b/Common/Ui/Common.GUI/ViewModels/Controls/MainLayoutVM.cs new file mode 100644 index 00000000..2b46e78f --- /dev/null +++ b/Common/Ui/Common.GUI/ViewModels/Controls/MainLayoutVM.cs @@ -0,0 +1,24 @@ +namespace Common.GUI.ViewModels.Controls +{ + using Common.GUI.Models.Base; + using Common.GUI.ViewModels.Base; + + using System.Collections.ObjectModel; + + public class MainLayoutVM : VM + { + private readonly MessageHandler messageHandler; + + public MainLayoutVM(MessageHandler messageHandler) + { + this.messageHandler = messageHandler; + this.messageHandler.MessageReceived += this.MessageReceived; + this.Messages = new ObservableCollection(); + } + + public ObservableCollection Messages { get; } + + private void MessageReceived(MessageVM message) + => this.Messages.Add(message); + } +} diff --git a/Common/Ui/Common.GUI/ViewModels/Controls/MainMenuVM.cs b/Common/Ui/Common.GUI/ViewModels/Controls/MainMenuVM.cs new file mode 100644 index 00000000..ae743985 --- /dev/null +++ b/Common/Ui/Common.GUI/ViewModels/Controls/MainMenuVM.cs @@ -0,0 +1,24 @@ +namespace Common.GUI.ViewModels.Controls +{ + using Common.GUI.ViewModels.Base; + + using System; + using System.Windows.Input; + using System.Windows.Navigation; + + public class MainMenuVM : VM + { + public MainMenuVM() + => this.NavigateCommand = new Command(this.NavigateCommandHandler); + + public ICommand NavigateCommand { get; } + + private void NavigateCommandHandler(string page) + { + if (App.Current.MainWindow is NavigationWindow navigationWindow) + { + navigationWindow.Navigate(new Uri(page, UriKind.Relative)); + } + } + } +} diff --git a/Common/Ui/Common.GUI/ViewModels/Controls/MessageVM.cs b/Common/Ui/Common.GUI/ViewModels/Controls/MessageVM.cs new file mode 100644 index 00000000..e4247ab6 --- /dev/null +++ b/Common/Ui/Common.GUI/ViewModels/Controls/MessageVM.cs @@ -0,0 +1,17 @@ +namespace Common.GUI.ViewModels.Controls +{ + using Common.GUI.ViewModels.Base; + + public class MessageVM : VM + { + public MessageVM(string title, string message) + { + this.Title = title; + this.Message = message; + } + + public string Title { get; } + + public string Message { get; } + } +} diff --git a/Common/Ui/Common.GUI/ViewModels/Eregister/EregisterFeatureItemVM.cs b/Common/Ui/Common.GUI/ViewModels/Eregister/EregisterFeatureItemVM.cs new file mode 100644 index 00000000..e24e6b11 --- /dev/null +++ b/Common/Ui/Common.GUI/ViewModels/Eregister/EregisterFeatureItemVM.cs @@ -0,0 +1,86 @@ +namespace Common.GUI.ViewModels.Eregister +{ + using Common.GUI.ViewModels.Base; + + using System; + using System.Collections.Generic; + using System.Collections.ObjectModel; + using System.Reflection; + + public class EregisterFeatureItemVM : VM + { + public string Header { get; set; } + + public ObservableCollection ItemsSource { get; } + = new ObservableCollection(); + } + + public class EregisterFeatureParameterItemVM : EregisterFeatureItemVM + { + private readonly PropertyInfo propertyInfo; + + public EregisterFeatureParameterItemVM(PropertyInfo propertyInfo, string header) + { + this.Header = header; + this.propertyInfo = propertyInfo; + } + + private object value; + public object Value + { + get => this.value; + set => this.SetValue(() => this.value = value); + } + } + + public class EregisterFeatureBooleanValueVM : EregisterFeatureParameterItemVM + { + public EregisterFeatureBooleanValueVM(PropertyInfo propertyInfo, string header) : base(propertyInfo, header) + { + } + } + + public class EregisterFeatureByteValueVM : EregisterFeatureParameterItemVM + { + public EregisterFeatureByteValueVM(PropertyInfo propertyInfo, string header) : base(propertyInfo, header) + { + } + } + + public class EregisterFeatureInt32ValueVM : EregisterFeatureParameterItemVM + { + public EregisterFeatureInt32ValueVM(PropertyInfo propertyInfo, string header) : base(propertyInfo, header) + { + } + } + + public class EregisterFeatureUInt16ValueVM : EregisterFeatureParameterItemVM + { + public EregisterFeatureUInt16ValueVM(PropertyInfo propertyInfo, string header) : base(propertyInfo, header) + { + } + } + + public class EregisterFeatureUInt32ValueVM : EregisterFeatureParameterItemVM + { + public EregisterFeatureUInt32ValueVM(PropertyInfo propertyInfo, string header) : base(propertyInfo, header) + { + } + } + + public class EregisterFeatureStringValueVM : EregisterFeatureParameterItemVM + { + public EregisterFeatureStringValueVM(PropertyInfo propertyInfo, string header) : base(propertyInfo, header) + { + } + } + + public class EregisterFeatureOptionValueVM : EregisterFeatureParameterItemVM + { + public EregisterFeatureOptionValueVM(PropertyInfo propertyInfo, string header) + : base(propertyInfo, header) + => this.Options = Enum.GetNames(propertyInfo.PropertyType); + + public ICollection Options { get; set; } + } +} \ No newline at end of file diff --git a/Common/Ui/Common.GUI/ViewModels/Eregister/EregisterManualProgrammingVM.cs b/Common/Ui/Common.GUI/ViewModels/Eregister/EregisterManualProgrammingVM.cs new file mode 100644 index 00000000..406ca0bf --- /dev/null +++ b/Common/Ui/Common.GUI/ViewModels/Eregister/EregisterManualProgrammingVM.cs @@ -0,0 +1,155 @@ +namespace Common.GUI.ViewModels.Eregister +{ + using Common.GUI.ViewModels.Base; + using Common.Hardware.WaterMeter.eRegister.Features; + using Common.Hardware.WaterMeter.eRegister.Models; + + using System; + using System.Collections.Generic; + using System.Collections.ObjectModel; + using System.Reflection; + + public class EregisterManualProgrammingVM : VM + { + public EregisterManualProgrammingVM() + { + this.ItemsSource = new ObservableCollection(); + + this.InitializeEregisterManualProgrammingVM(); + } + + public ObservableCollection ItemsSource { get; } + + private void InitializeEregisterManualProgrammingVM() + { + var features = new SortedDictionary>>(); + + void ParseType(Type type) + { + foreach (var property in type.GetProperties(BindingFlags.Public | BindingFlags.Instance)) + { + var propertyType = property.PropertyType; + + if (!typeof(Pam).IsAssignableFrom(propertyType)) + { + continue; + } + + var pamAttribute = property.GetCustomAttribute(); + + if (pamAttribute is null) + { + continue; + } + + var isSingleCmd = pamAttribute.IsSingleCmd; + + if (!features.ContainsKey(isSingleCmd)) + { + features[isSingleCmd] = new SortedDictionary>(); + } + + var _features = features[isSingleCmd]; + var authLevel = $"{pamAttribute.AuthLevel}"; + + if (!_features.ContainsKey(authLevel)) + { + _features[authLevel] = new SortedDictionary(); + } + + var __features = _features[authLevel]; + var pam = Activator.CreateInstance(property.PropertyType) as Pam; + var cmdHex = $"{property.Name}: {pam.CmdHex}"; + + if (!__features.ContainsKey(cmdHex)) + { + __features[cmdHex] = new FeatureDictionary(); + } + + var ___features = __features[cmdHex]; + ___features.FeatureInfo = property; + + foreach (var _property in propertyType.GetProperties(BindingFlags.Public | BindingFlags.Instance)) + { + if (_property.CanWrite && _property.PropertyType != typeof(byte[])) + { + ___features[_property.Name] = _property; + } + } + } + } + + ParseType(typeof(EregisterFeatures)); + ParseType(typeof(EregisterDebugFeatures)); + + foreach (var kvp in features) + { + var type = kvp.Key ? "Single PAM" : "Multi PAM"; + + foreach (var _kvp in kvp.Value) + { + var _item = new EregisterFeatureItemVM + { + Header = $"{type} - Auth level {_kvp.Key}" + }; + + foreach (var __kvp in _kvp.Value) + { + var __item = new EregisterFeatureItemVM + { + Header = $"{__kvp.Key}" + }; + + foreach (var ___kvp in __kvp.Value) + { + var header = ___kvp.Key; + var propertyInfo = ___kvp.Value; + var propertyType = propertyInfo.PropertyType; + var ___item = default(EregisterFeatureParameterItemVM); + + if (propertyType == typeof(bool)) + { + ___item = new EregisterFeatureBooleanValueVM(propertyInfo, header); + } + else if (propertyType == typeof(byte)) + { + ___item = new EregisterFeatureByteValueVM(propertyInfo, header); + } + else if (propertyType == typeof(int)) + { + ___item = new EregisterFeatureInt32ValueVM(propertyInfo, header); + } + else if (propertyType == typeof(ushort)) + { + ___item = new EregisterFeatureUInt16ValueVM(propertyInfo, header); + } + else if (propertyType == typeof(uint)) + { + ___item = new EregisterFeatureUInt32ValueVM(propertyInfo, header); + } + else if (propertyType.IsEnum) + { + ___item = new EregisterFeatureOptionValueVM(propertyInfo, header); + } + else + { + ___item = new EregisterFeatureStringValueVM(propertyInfo, header); + } + + __item.ItemsSource.Add(___item); + } + + _item.ItemsSource.Add(__item); + } + + this.ItemsSource.Add(_item); + } + } + } + } + + public class FeatureDictionary : SortedDictionary + { + public PropertyInfo FeatureInfo { get; set; } + } +} diff --git a/Common/Ui/Common.GUI/ViewModels/Pages/MainPageVM.cs b/Common/Ui/Common.GUI/ViewModels/Pages/MainPageVM.cs new file mode 100644 index 00000000..d819cd20 --- /dev/null +++ b/Common/Ui/Common.GUI/ViewModels/Pages/MainPageVM.cs @@ -0,0 +1,9 @@ +namespace Common.GUI.ViewModels.Pages +{ + using Common.GUI.ViewModels.Base; + + public class MainPageVM : VM + { + + } +} diff --git a/Common/Ui/Common.GUI/ViewModels/VMLocator.cs b/Common/Ui/Common.GUI/ViewModels/VMLocator.cs new file mode 100644 index 00000000..59a2d5ad --- /dev/null +++ b/Common/Ui/Common.GUI/ViewModels/VMLocator.cs @@ -0,0 +1,42 @@ +namespace Common.GUI.ViewModels +{ + using Common.GUI.ViewModels.Base; + using Common.GUI.ViewModels.Controls; + using Common.GUI.ViewModels.Eregister; + using Common.GUI.ViewModels.Pages; + + using Microsoft.Extensions.DependencyInjection; + + using System.Windows; + + public class VMLocator + { + private static readonly ServiceProvider serviceProvider = ConfigureServices(); + + public VMLocator() => App.Current.Exit += this.App_Exit; + + public MainLayoutVM MainLayoutVM => serviceProvider.GetService(); + + public MainMenuVM MainMenuVM => serviceProvider.GetService(); + + public MainPageVM MainPageVM => serviceProvider.GetService(); + + public EregisterManualProgrammingVM EregisterManualProgrammingVM => serviceProvider.GetService(); + + private void App_Exit(object sender, ExitEventArgs args) + { + App.Current.Exit -= this.App_Exit; + + serviceProvider.Dispose(); + } + + private static ServiceProvider ConfigureServices() + => new ServiceCollection() + .AddScoped() + .AddTransient() + .AddTransient() + .AddScoped() + .AddScoped() + .BuildServiceProvider(); + } +} diff --git a/Common/Ui/Common.GUI/packages.config b/Common/Ui/Common.GUI/packages.config new file mode 100644 index 00000000..7e6b54f2 --- /dev/null +++ b/Common/Ui/Common.GUI/packages.config @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/Common/Ui/Common.UI.VFM/App.config b/Common/Ui/Common.UI.VFM/App.config deleted file mode 100644 index db41839e..00000000 --- a/Common/Ui/Common.UI.VFM/App.config +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/Common/Ui/Common.UI.VFM/Common.UI.VFM.csproj b/Common/Ui/Common.UI.VFM/Common.UI.VFM.csproj deleted file mode 100644 index 91aa3759..00000000 --- a/Common/Ui/Common.UI.VFM/Common.UI.VFM.csproj +++ /dev/null @@ -1,194 +0,0 @@ - - - - - Debug - AnyCPU - {9C1C5522-E986-4FD6-8F2F-19821D704A88} - WinExe - Common.UI.VFM - Common.UI.VFM - v4.6 - 512 - {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 4 - true - - true - \\SLA12IIS01\LaaProductionWeb\vfm\ - true - Web - true - Foreground - 7 - Days - false - false - true - http://sla12iis01.emea.sensus.net/LaaProductionWeb/vfm/ - true - publish.htm - 7 - 1.0.0.%2a - false - true - true - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - false - IDE0003;IDE0049; - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - false - - - 2AAD7D379BFB7F46CA9B0F35907CFDA28F27D632 - - - Common.UI.VFM_1_TemporaryKey.pfx - - - true - - - false - - - - - - - - - - - - - 4.0 - - - - - - - - MSBuild:Compile - Designer - - - - - - - - - - - - - - - ShipmentView.xaml - - - Designer - MSBuild:Compile - - - MSBuild:Compile - Designer - - - App.xaml - Code - - - - EmptyView.xaml - - - - MainWindow.xaml - Code - - - Designer - MSBuild:Compile - - - - - - Code - - - True - True - Resources.resx - - - True - Settings.settings - True - - - ResXFileCodeGenerator - Resources.Designer.cs - - - - SettingsSingleFileGenerator - Settings.Designer.cs - - - - - {9AE071C0-DB12-4E09-A3C7-43F6DCD518D6} - Common.Hardware.Ports - - - {9D89FA2A-1217-4CE9-B217-E7602B974EA9} - Common.Hardware.WaterMeter.OmniPlus.Features - - - {6480CC2A-AB54-4A26-8413-D5141431C080} - Common.Hardware.WaterMeter.OmniPlus - - - {57ddae1e-fd6b-47e0-ad5e-8ccfad07f1d7} - Common.Logic.Extensions.Http - - - {62490923-CD17-45A6-B79F-A027927C75B5} - Common.Logic.Extensions.SQL - - - - - False - Microsoft .NET Framework 4.6 %28x86 and x64%29 - true - - - False - .NET Framework 3.5 SP1 - false - - - - \ No newline at end of file diff --git a/Common/Ui/Common.UI.VFM/Converters/BooleanInverterConverter.cs b/Common/Ui/Common.UI.VFM/Converters/BooleanInverterConverter.cs deleted file mode 100644 index 4a9e190c..00000000 --- a/Common/Ui/Common.UI.VFM/Converters/BooleanInverterConverter.cs +++ /dev/null @@ -1,24 +0,0 @@ -namespace Common.UI.VFM.Converters -{ - using System; - using System.Globalization; - using System.Windows.Data; - - public class BooleanInverterConverter : IValueConverter - { - public Object Convert(Object value, Type targetType, Object parameter, CultureInfo culture) - { - if (value is Boolean _value) - { - return !_value; - } - - return false; - } - - public Object ConvertBack(Object value, Type targetType, Object parameter, CultureInfo culture) - { - throw new NotImplementedException(); - } - } -} diff --git a/Common/Ui/Common.UI.VFM/Converters/BooleanToVisibilityConverter.cs b/Common/Ui/Common.UI.VFM/Converters/BooleanToVisibilityConverter.cs deleted file mode 100644 index f2a3a80f..00000000 --- a/Common/Ui/Common.UI.VFM/Converters/BooleanToVisibilityConverter.cs +++ /dev/null @@ -1,25 +0,0 @@ -namespace Common.UI.VFM.Converters -{ - using System; - using System.Globalization; - using System.Windows; - using System.Windows.Data; - - public class BooleanToVisibilityConverter : IValueConverter - { - public Object Convert(Object value, Type targetType, Object parameter, CultureInfo culture) - { - if (value is Boolean visible && visible) - { - return Visibility.Visible; - } - - return Visibility.Collapsed; - } - - public Object ConvertBack(Object value, Type targetType, Object parameter, CultureInfo culture) - { - throw new NotImplementedException(); - } - } -} diff --git a/Common/Ui/Common.UI.VFM/Converters/ProcessStateToImageConverter.cs b/Common/Ui/Common.UI.VFM/Converters/ProcessStateToImageConverter.cs deleted file mode 100644 index ae52593c..00000000 --- a/Common/Ui/Common.UI.VFM/Converters/ProcessStateToImageConverter.cs +++ /dev/null @@ -1,36 +0,0 @@ -namespace Common.UI.VFM.Converters -{ - using Common.UI.VFM.Models; - - using System; - using System.Globalization; - using System.Windows; - using System.Windows.Data; - - public class ProcessStateToImageConverter : IValueConverter - { - public Object Convert(Object value, Type targetType, Object parameter, CultureInfo culture) - { - var ressources = Application.Current.Resources; - - if (value is ProcessState state) - { - switch (state) - { - case ProcessState.Undefined: return ressources["BiPlay"]; - case ProcessState.Started: return ressources["BiPause"]; - case ProcessState.Success: return ressources["BiCheck"]; - case ProcessState.Warning: return ressources["BiWarning"]; - case ProcessState.Error: return ressources["BiError"]; - } - } - - return ressources["PlayCircleDrawingImage"]; - } - - public Object ConvertBack(Object value, Type targetType, Object parameter, CultureInfo culture) - { - throw new NotImplementedException(); - } - } -} diff --git a/Common/Ui/Common.UI.VFM/Converters/ProcessStateToImageSourceConverter.cs b/Common/Ui/Common.UI.VFM/Converters/ProcessStateToImageSourceConverter.cs deleted file mode 100644 index 548e85c9..00000000 --- a/Common/Ui/Common.UI.VFM/Converters/ProcessStateToImageSourceConverter.cs +++ /dev/null @@ -1,36 +0,0 @@ -namespace Common.UI.VFM.Converters -{ - using Common.UI.VFM.Models; - - using System; - using System.Globalization; - using System.Windows; - using System.Windows.Data; - - public class ProcessStateToImageSourceConverter : IValueConverter - { - public Object Convert(Object value, Type targetType, Object parameter, CultureInfo culture) - { - var ressources = Application.Current.Resources; - - if (value is ProcessState state) - { - switch (state) - { - case ProcessState.Undefined: return ressources["PlayCircleDrawingImage"]; - case ProcessState.Started: return ressources["PauseCircleDrawingImage"]; - case ProcessState.Success: return ressources["CheckCircleDrawingImage"]; - case ProcessState.Warning: return ressources["WarningCircleDrawingImage"]; - case ProcessState.Error: return ressources["ErrorCircleDrawingImage"]; - } - } - - return ressources["PlayCircleDrawingImage"]; - } - - public Object ConvertBack(Object value, Type targetType, Object parameter, CultureInfo culture) - { - throw new NotImplementedException(); - } - } -} diff --git a/Common/Ui/Common.UI.VFM/Converters/ProcessstateToColorConverter.cs b/Common/Ui/Common.UI.VFM/Converters/ProcessstateToColorConverter.cs deleted file mode 100644 index 6b2eb51d..00000000 --- a/Common/Ui/Common.UI.VFM/Converters/ProcessstateToColorConverter.cs +++ /dev/null @@ -1,34 +0,0 @@ -namespace Common.UI.VFM.Converters -{ - using Common.UI.VFM.Models; - - using System; - using System.Globalization; - using System.Windows.Data; - using System.Windows.Media; - - public class ProcessstateToColorConverter : IValueConverter - { - public Object Convert(Object value, Type targetType, Object parameter, CultureInfo culture) - { - if (value is ProcessState state) - { - switch (state) - { - case ProcessState.Undefined: return Brushes.DimGray; - case ProcessState.Started: return Brushes.DimGray; - case ProcessState.Success: return Brushes.Green; - case ProcessState.Warning: return Brushes.DimGray; - case ProcessState.Error: return Brushes.Red; - } - } - - return Brushes.DimGray; - } - - public Object ConvertBack(Object value, Type targetType, Object parameter, CultureInfo culture) - { - throw new NotImplementedException(); - } - } -} diff --git a/Common/Ui/Common.UI.VFM/Converters/StringToVisibilityConverter.cs b/Common/Ui/Common.UI.VFM/Converters/StringToVisibilityConverter.cs deleted file mode 100644 index a1f69046..00000000 --- a/Common/Ui/Common.UI.VFM/Converters/StringToVisibilityConverter.cs +++ /dev/null @@ -1,25 +0,0 @@ -namespace Common.UI.VFM.Converters -{ - using System; - using System.Globalization; - using System.Windows; - using System.Windows.Data; - - public class StringToVisibilityConverter : IValueConverter - { - public Object Convert(Object value, Type targetType, Object parameter, CultureInfo culture) - { - if (value is String text && !String.IsNullOrWhiteSpace(text)) - { - return Visibility.Visible; - } - - return Visibility.Collapsed; - } - - public Object ConvertBack(Object value, Type targetType, Object parameter, CultureInfo culture) - { - throw new NotImplementedException(); - } - } -} diff --git a/Common/Ui/Common.UI.VFM/Models/OmniShipmentModel.cs b/Common/Ui/Common.UI.VFM/Models/OmniShipmentModel.cs deleted file mode 100644 index fcc55aeb..00000000 --- a/Common/Ui/Common.UI.VFM/Models/OmniShipmentModel.cs +++ /dev/null @@ -1,1167 +0,0 @@ -namespace Common.UI.VFM.Models -{ - using Common.Hardware.WaterMeter.OmniPlus; - using Common.Hardware.WaterMeter.OmniPlus.Features; - using Common.Logic.Extensions.Http; - using Common.Logic.Extensions.Http.Interfaces; - using Common.Logic.Extensions.SQL; - - using System; - using System.Collections.Generic; - using System.ComponentModel.DataAnnotations; - using System.Linq; - using System.Reflection; - using System.Threading; - - public class OmniShipmentModel - { - private readonly String portName; - private readonly IHttpClient http; - private readonly SQLConnection mssql; - private readonly OmniConnection omni; - private OmniValuesModel values; - - public OmniShipmentModel(String portName, String sqlConnectionString, String labelsURL) - { - this.portName = portName; - this.omni = new OmniConnection(); - this.http = new HttpClient().WithBaseURL(labelsURL); - this.mssql = new SQLConnection(sqlConnectionString); - } - - public String CustId { get; set; } - - public String MeterPcb { get; set; } - - public IDictionary> GetProcesses() - => this - .GetType() - .GetMethods(BindingFlags.NonPublic | BindingFlags.Instance) - .Where(x => x.ReturnParameter.ParameterType == typeof(ProcessResult)) - .ToDictionary(key => key.GetCustomAttribute() - ?.GetName() - ?? key.Name - , val => (Func)val.CreateDelegate(typeof(Func), this)); - - internal Boolean WasPrinted() - => this.mssql - .CreateCommand($@" - SELECT COUNT(*) - FROM [OmniExport] - WHERE [CustomerSN] = @{nameof(this.CustId)} - AND [PCBAID] = @{nameof(this.MeterPcb)}") - .SetParameter(nameof(this.MeterPcb), this.MeterPcb) - .SetParameter(nameof(this.CustId), this.CustId) - .FirstOrDefault(x => x.GetValue(0)) > 0; - - internal void Initialize() - { - this.values = new OmniValuesModel(); - - this.omni.UseUniPro(this.portName); - } - - internal void Finish() - { - if (!String.IsNullOrWhiteSpace(this.MeterPcb)) - { - var debug = this.omni.Telegrams?.ToString(); - - if (!String.IsNullOrWhiteSpace(debug)) - { - this.mssql - .CreateCommand($@" - UPDATE [OmniTestRuns] - SET [Debug] = ISNULL([Debug], '') + '\n' + @{nameof(debug)} - WHERE [Id] = @{nameof(this.values.TestRunId)}") - .SetParameter(nameof(this.values.TestRunId), this.values.TestRunId) - .SetParameter(nameof(debug), debug) - .ExecuteNonQuery(); - } - } - - this.omni.Disconnect(); - } - - [Display(Name = "Produktionsauftragsdaten laden")] - internal ProcessResult LoadProductionOrderData() - { - var any = this.mssql - .CreateCommand($@" - SELECT [ap].[AuftragNr] - , [ap].[PositionNr] - , [ap].[FertigungsauftragNr] - , [ap].[IdentNr] - , [ap].[Menge] - , (SELECT TOP 1 [x].[Nr] - FROM (SELECT [apsn].[SerienNr] - , ROW_NUMBER() OVER (PARTITION BY [apsn].[PositionNr] ORDER BY [apsn].[SerienNr]) AS [Nr] - FROM [AuftragPositionSerienNr] AS [apsn] - WHERE [apsn].[AuftragNr] = [ap].[AuftragNr] - AND [apsn].[PositionNr] = [ap].[PositionNr]) AS [x] - WHERE [x].[SerienNr] = [aps].[SerienNr]) - AS [BoxNr] - , [aps].[SerienNr] - , [aps].[KundeneigeneSerienNr] - , [aps].[FabNr] - , [aps].[StatusFertigung] - , [od].[PartNr] - , [od].[DescriptionL1] - , [od].[DescriptionL2] - , [od].[Variant] - FROM [AuftragPositionSerienNr] AS [aps] - JOIN [AuftragPosition] AS [ap] - ON [aps].[AuftragNr] = [ap].[AuftragNr] - AND [aps].[PositionNr] = [ap].[PositionNr] - JOIN [OmniDefaults] AS [od] - ON [ap].[IdentNr] = [od].[IdentNr] - WHERE [KundeneigeneSerienNr] = @{nameof(this.CustId)}") - .SetParameter(nameof(this.CustId), this.CustId) - .FirstOrDefault(reader => - { - this.values.Orderno = reader.GetValue(0); - this.values.Positionno = reader.GetValue(1); - this.values.ProductionOrderno = reader.GetValue(2); - this.values.OrderIdentno = reader.GetValue(3); - this.values.Count = reader.GetValue(4); - this.values.Boxno = reader.GetValue(5); - this.values.Serialno = reader.GetValue(6); - this.values.DbCustId = reader.GetValue(7); - this.values.FactId = reader.GetValue(8); - this.values.ProductionStatus = reader.GetValue(9); - this.values.Partno = reader.GetValue(10); - this.values.DescriptionL1 = reader.GetValue(11); - this.values.DescriptionL2 = reader.GetValue(12); - this.values.Variant = reader.GetValue(13); - - return true; - }); - - if (any) - { - return new ProcessResult - { - State = ProcessState.Warning, - Message = $"{this.values.DescriptionL1} - {(this.values.Variant.StartsWith("R", StringComparison.InvariantCultureIgnoreCase) ? "SCHWARZE" : "GRAUE")} AUSFÜHRUNG!!!", - }; - } - else - { - return new ProcessResult - { - State = ProcessState.Error, - Message = $"Für die Kundeneigeneseriennummer: {this.CustId} - wurden keine Auftragsdaten gefunden!" - }; - } - } - - [Display(Name = "Prüfungsgebnisse laden")] - internal ProcessResult LoadProductionTestData() - { - var testIdentNr = default(Int32); - var descriptionL1 = default(String); - var any = this.mssql - .CreateCommand($@" - SELECT TOP 1 - [TP3].[GPM] - , [TR].[Q3_Acc] - , [TP2].[GPM] - , [TR].[Q2_Acc] - , [TP1].[GPM] - , [TR].[Q1_Acc] - , [TR].[EndDate] - , [TR].[Succeeded] - , [TR].[CrrfAfter] - , [TR].[Id] - , [TR].[ManifacturingTime] - , [OD].[IdentNr] - , [OD].[DescriptionL1] - FROM [OmniTestRuns] AS [TR] - JOIN [OmniTestPoints] AS [TP1] - ON [TP1].[Id] = [TR].[Q1_TpId] - JOIN [OmniTestPoints] AS [TP2] - ON [TP2].[Id] = [TR].[Q2_TpId] - JOIN [OmniTestPoints] AS [TP3] - ON [TP3].[Id] = [TR].[Q3_TpId] - JOIN [OmniDefaults] AS [OD] - ON [TR].[DefaultId] = [OD].[Id] - WHERE [TR].[BuildInfo] = @{nameof(this.MeterPcb)} - ORDER BY [TR].[Id] DESC") - .SetParameter(nameof(this.MeterPcb), this.MeterPcb) - .FirstOrDefault(reader => - { - this.values.MaxGPM = reader.GetValue(0); - this.values.MaxACC = reader.GetValue(1); - this.values.MidGPM = reader.GetValue(2); - this.values.MidACC = reader.GetValue(3); - this.values.MinGPM = reader.GetValue(4); - this.values.MinACC = reader.GetValue(5); - this.values.TestDate = reader.GetValue(6); - this.values.Succeeded = reader.GetValue(7); - this.values.CalibrationFactor = reader.GetValue(8); - this.values.TestRunId = reader.GetValue(9); - - var date = new Epoch20000101 - { - DateTime = reader.GetValue(10) - }; - var _default = new Epoch20000101(); - - this.values.ManifacturingTime = date.SecondsSince; - - if (this.values.ManifacturingTime <= _default.SecondsSince || this.values.ManifacturingTime >= DateTime.Now.TimeOfDay.TotalSeconds) - { - var random = new Epoch20000101 - { - DateTime = new DateTime(2023, 07, 13, 9, 45, 12) - }; - - this.values.ManifacturingTime = random.SecondsSince; - } - - testIdentNr = reader.GetValue(11); - descriptionL1 = reader.GetValue(12); - - return true; - }); - - if (any) - { - if (!this.values.Succeeded) - { - return new ProcessResult - { - State = ProcessState.Error, - Message = $"{this.MeterPcb} - wurde nicht erfolgreich geprüft!", - }; - } - else if (this.values.OrderIdentno != testIdentNr) - { - return new ProcessResult - { - State = ProcessState.Error, - Message = $"{this.MeterPcb} - gehört nicht zu dem eingegebene Kundeneigeneseriennummer: {this.CustId}! \n{descriptionL1}", - }; - } - - return new ProcessResult - { - State = ProcessState.Success - }; - } - else - { - return new ProcessResult - { - State = ProcessState.Error, - Message = $"Für die Zählernummer: {this.MeterPcb} - wurden keine Prüfergebnisse gefunden!" - }; - } - } - - [Display(Name = "Standardwerte laden")] - internal ProcessResult LoadDefaultValues() - { - var identno = this.values.OrderIdentno; - var any = this.mssql - .CreateCommand($@" - SELECT [d].[Size] - , [d].[Range] - , [d].[Direction] - , [d].[IntPart] - , [d].[Fraction] - , [d].[Crf] - , [d].[Ppr] - , [d].[MeterUnits] - , [d].[FlowUnits] - , [d].[FlowRate] - , [d].[PulseWeight] - , [d].[PulseWidth] - , [d].[PulseUpdate] - , [d].[AlarmPercistancePeriodDays] - , [d].[DataLogIntervalMinutes] - , [d].[NumberOfReadingDigits] - , [d].[OptionalUniDirFields] - , [d].[ReadingPreset] - , [d].[DeviceID] - , [d].[LeakAlarmGPM] - , [d].[LeakAlarmTime] - , [d].[HighFlowAlarmGPM] - , [d].[HighFlowAlarmTime] - , [d].[ReverseFlowAlarmGPM] - , [d].[ReverseFlowAlarmTime] - FROM [OmniDefaults] AS [d] - WHERE [d].[IdentNr] = @{nameof(identno)}") - .SetParameter(nameof(identno), identno) - .FirstOrDefault(reader => - { - this.values.Size = reader.GetValue(0); - this.values.Range = reader.GetValue(1); - this.values.Direction = reader.GetValue(2); - this.values.IntPart = reader.GetValue(3); - this.values.Fraction = reader.GetValue(4); - this.values.Crf = reader.GetValue(5); - this.values.Ppr = reader.GetValue(6); - this.values.MeterUnits = reader.GetValue(7); - this.values.FlowUnits = reader.GetValue(8); - this.values.FlowRate = reader.GetValue(9); - this.values.PulseWeight = reader.GetValue(10); - this.values.PulseWidth = reader.GetValue(11); - this.values.PulseUpdate = reader.GetValue(12); - this.values.AlarmPercistancePeriodDays = reader.GetValue(13); - this.values.DataLogIntervalMinutes = reader.GetValue(14); - this.values.NumberOfReadingDigits = reader.GetValue(15); - this.values.OptionalUniDirFields = reader.GetValue(16); - this.values.ReadingPreset = reader.GetValue(17); - this.values.DeviceID = reader.GetValue(18); - this.values.LeakAlarmGPM = reader.GetValue(19); - this.values.LeakAlarmHours = reader.GetValue(20); - this.values.HighFlowAlarmGPM = reader.GetValue(21); - this.values.HighFlowAlarmHours = reader.GetValue(22); - this.values.ReverseFlowAlarmGPM = reader.GetValue(23); - this.values.ReverseFlowAlarmMinutes = reader.GetValue(24); - - return true; - }); - - if (any) - { - return new ProcessResult - { - State = ProcessState.Success - }; - } - else - { - return new ProcessResult - { - State = ProcessState.Error, - Message = $"Für die Identnummer: {identno} - wurden keine standardwerte gefunden!" - }; - } - } - - [Display(Name = "Siegel öffnen")] - internal ProcessResult UnsealMeter() - { - var seal = this.omni.FactorySeal(); - - if (!seal.Completed) - { - return new ProcessResult - { - State = ProcessState.Error, - Message = $"Fehler: '{seal.Status}' - beim Lesen des Siegelstatus!" - }; - } - else if (seal.Sealed) - { - seal = this.omni.FactorySeal(false); - - if (!seal.Completed) - { - return new ProcessResult - { - State = ProcessState.Error, - Message = $"Fehler: '{seal.Status}' - beim Entsiegeln!" - }; - } - - seal = this.omni.FactorySeal(); - - if (!seal.Completed) - { - return new ProcessResult - { - State = ProcessState.Error, - Message = $"Fehler: '{seal.Status}' - beim Lesen des Siegelstatus!" - }; - } - else if (seal.Sealed) - { - return new ProcessResult - { - State = ProcessState.Error, - Message = $"Fehler: '{seal.Status}' - beim Entsiegeln!" - }; - } - } - - return new ProcessResult - { - State = ProcessState.Success - }; - } - - [Display(Name = "E-Head-Nr ablesen")] - internal ProcessResult ReadEheadPcb() - { - var eheadPcb = this.omni.ViewEheadPCB(); - - if (!eheadPcb.Completed) - { - return new ProcessResult - { - State = ProcessState.Error, - Message = $"Fehler: '{eheadPcb.Status}' - beim Lesen der E-Head-PCB!" - }; - } - else if (String.IsNullOrWhiteSpace(eheadPcb.Value)) - { - return new ProcessResult - { - State = ProcessState.Error, - Message = $"Ungültige E-Head-PCB!" - }; - } - - this.values.EheadPcb = eheadPcb.Value; - - return new ProcessResult - { - State = ProcessState.Success, - Message = $"E-Head-PCB: {this.values.EheadPcb}" - }; - } - - [Display(Name = "Systemparameter überprüfen")] - internal ProcessResult VerifySystemParameters() - { - var systemParameters = this.omni.ViewSystemParameters(); - - if (!systemParameters.Completed) - { - return new ProcessResult - { - State = ProcessState.Error, - Message = $"Fehler: '{systemParameters.Status}' - beim Lesen der Systemparameter!" - }; - } - else if (!systemParameters.IsValid) - { - return new ProcessResult - { - State = ProcessState.Error, - Message = $"Fehler: {systemParameters.ValidationMessage} - ungültige Systemparameter!" - }; - } - - this.values.SystemParameters = systemParameters; - - return new ProcessResult - { - State = ProcessState.Success - }; - } - - [Display(Name = "Konfigurationsparameter überprüfen")] - internal ProcessResult ViewConfigurationParameters() - { - var configurationParameters = this.omni.ViewConfigurationParameters(); - - if (!configurationParameters.Completed) - { - return new ProcessResult - { - State = ProcessState.Error, - Message = $"Fehler: '{configurationParameters.Status}' - beim Lesen der Konfigurationsparameter!" - }; - } - - this.values.ConfigurationParameters = configurationParameters; - - return new ProcessResult - { - State = ProcessState.Success - }; - } - - [Display(Name = "System Reboot")] - internal ProcessResult RebootMeter() - { - var systemReset = this.omni.Set(new SystemTime()); - - if (!systemReset.Completed) - { - return new ProcessResult - { - State = ProcessState.Error, - Message = "Fehler bei Reboot!" - }; - } - - var test = new FeatureResponse(); - - for (var i = 0; i < 20; i++) - { - test = this.omni.ViewBuildInformation(); - - if (test.Completed) - { - break; - } - - Thread.Sleep(1000); - } - - if (!test.Completed) - { - return new ProcessResult - { - State = ProcessState.Error, - Message = "OMNI reagiert nicht mehr!" - }; - } - - return new ProcessResult - { - State = ProcessState.Success - }; - } - - [Display(Name = "Registereinstellungen Schreiben")] - internal ProcessResult WriteRegisterSettings() - { - Thread.Sleep(1000); - - var response = this.omni.Set(new RegisterSettings - { - IntPart = this.values.IntPart, - Fraction = (UInt16)this.values.Fraction, - Size = this.values.Size, - Range = this.values.Range, - VolumePerPulseUnits = 0x00, - MeterUnits = this.values.MeterUnits, - FlowUnits = this.values.FlowUnits, - FlowRate = this.values.FlowRate, - FactoryCorrection = (SByte)(this.values.CalibrationFactor * 10), - FieldCorrection = 0x00, - PulseWeight = this.values.PulseWeight, - PulseWidth = this.values.PulseWidth, - PulseUpdate = this.values.PulseUpdate, - }); - - if (!response.Completed) - { - return new ProcessResult - { - State = ProcessState.Error, - Message = "Fehler beim Schreiben die Registereinstellungen!" - }; - } - - return new ProcessResult - { - State = ProcessState.Success - }; - } - - [Display(Name = "Konfigurationseinstellungen Schreiben")] - internal ProcessResult WriteConfigurationParameters() - { - Thread.Sleep(1000); - - var configuration = new ConfigurationParametersSet - { - BuildInfo = this.MeterPcb, - ProgrammableID = this.CustId, - FactoryID = this.values.FactId.ToString(), - AlarmPercistancePeriodDays = this.values.AlarmPercistancePeriodDays, - DataLogIntervalMinutes = (UInt16)this.values.DataLogIntervalMinutes, - ManifacturingTime = this.values.ManifacturingTime, - NumberOfReadingDigits = (SByte)this.values.NumberOfReadingDigits, - OptionalUniDirFields = (UInt16)this.values.OptionalUniDirFields, - ReadingPreset = this.values.ReadingPreset, - RebootCount = 0, - SystemTime = Epoch20000101.UTCNow, - DeviceID = this.values.DeviceID - }; - var response = this.omni.Set(configuration); - - if (!response.Completed) - { - return new ProcessResult - { - State = ProcessState.Error, - Message = "Fehler beim Schreiben die Konfigurationseinstellungen!" - }; - } - - return new ProcessResult - { - State = ProcessState.Success - }; - } - - [Display(Name = "Leseeinheit und Auflösung entfernen")] - internal ProcessResult ClearReadingUnitsAndResolution() - { - Thread.Sleep(1000); - - var response = this.omni.ClearDisplay(); - - if (!response.Completed) - { - return new ProcessResult - { - State = ProcessState.Error, - Message = "Fehler beim Zurücksetzen der Anzeige!" - }; - } - - return new ProcessResult - { - State = ProcessState.Success - }; - } - - [Display(Name = "Alarme einrichten")] - internal ProcessResult SettingAlarms() - { - Thread.Sleep(1000); - - var response = this.omni.Set(new LeakAlarm - { - FlowRateGPM = this.values.LeakAlarmGPM, - TimeLimitHours = (UInt32)this.values.LeakAlarmHours - }); - - if (!response.Completed) - { - return new ProcessResult - { - State = ProcessState.Error, - Message = "Der Leckalarm ist nicht eingestellt!" - }; - } - - Thread.Sleep(1000); - - response = this.omni.Set(new HighFlowAlarm - { - FlowRateGPM = this.values.HighFlowAlarmGPM, - TimeLimitHours = (UInt32)this.values.HighFlowAlarmHours - }); - - if (!response.Completed) - { - return new ProcessResult - { - State = ProcessState.Error, - Message = "Der Alarm für hohen Durchfluss ist nicht eingestellt!" - }; - } - - Thread.Sleep(1000); - - response = this.omni.Set(new ReverseFlowAlarm - { - FlowRateGPM = this.values.ReverseFlowAlarmGPM, - TimeLimitMinutes = (UInt32)this.values.ReverseFlowAlarmMinutes - }); - - if (!response.Completed) - { - return new ProcessResult - { - State = ProcessState.Error, - Message = "Der Rückflussalarm ist nicht eingestellt!" - }; - } - - Thread.Sleep(1000); - - response = this.omni.ClearAlarms(); - - if (!response.Completed) - { - return new ProcessResult - { - State = ProcessState.Error, - Message = "Alarme werden nicht gelöscht!" - }; - } - - Thread.Sleep(1000); - - response = this.omni.EnableNFC(); - - if (!response.Completed) - { - return new ProcessResult - { - State = ProcessState.Error, - Message = "NFC ist nicht aktiviert!" - }; - } - - return new ProcessResult - { - State = ProcessState.Success - }; - } - - [Display(Name = "Programmierung überprüfen")] - internal ProcessResult CheckProgramming() - { - Thread.Sleep(1000); - - var alarmsState = this.omni.ViewAlarmsState(); - - if (!alarmsState.Completed) - { - return new ProcessResult - { - State = ProcessState.Error, - Message = "Alarmeinstellungen können nicht angezeigt werden!" - }; - } - else if (!alarmsState.IsValid) - { - return new ProcessResult - { - State = ProcessState.Error, - Message = "Ungültige Alarmeinstellungen!" - }; - } - - var parameters = this.omni.ViewSystemParameters(); - - if (!parameters.Completed) - { - return new ProcessResult - { - State = ProcessState.Error, - Message = "Fehler beim Ablesen die Systemparameter nach die Versiegelung!" - }; - } - else if (!parameters.IsValid) - { - return new ProcessResult - { - State = ProcessState.Error, - Message = "Diese OMNI hat ungültige Systemparameter nach die Versiegelung!" - }; - } - else if (parameters.BuildInfo.Value != this.MeterPcb.ToString()) - { - return new ProcessResult - { - State = ProcessState.Error, - Message = "Pcb stimmt nicht überein!" - }; - } - - var settings = this.omni.ViewRegisterSettings(); - var factoryCorrection = settings.FactoryCorrection; - - if (!settings.Completed) - { - return new ProcessResult - { - State = ProcessState.Error, - Message = "Registereinstellungen können nicht angezeigt werden!" - }; - } - - var configuration = this.omni.ViewConfigurationParameters(); - - if (configuration.ProgrammableID.Value != this.CustId) - { - return new ProcessResult - { - State = ProcessState.Error, - Message = "Cust-ID ist ungültig!" - }; - } - - if (configuration.FactoryID.Value != this.values.FactId.ToString()) - { - return new ProcessResult - { - State = ProcessState.Error, - Message = "Fact-ID ist ungültig!" - }; - } - - return new ProcessResult - { - State = factoryCorrection == 0 ? ProcessState.Warning : ProcessState.Success, - Message = factoryCorrection == 0 ? $"Factory correction: {factoryCorrection / 10.0}" : null, - }; - } - - [Display(Name = "OMNI versiegeln")] - internal ProcessResult SealMeter() - { - var response = this.omni.FactorySeal(true); - - if (!response.Completed) - { - return new ProcessResult - { - State = ProcessState.Error, - Message = "OMNI ist nicht versiegelt!" - }; - } - - response = this.omni.FactorySeal(); - - if (!response.Completed) - { - return new ProcessResult - { - State = ProcessState.Error, - Message = "Der Siegelstatus kann nicht angezeigt werden!" - }; - } - else if (!response.Sealed) - { - return new ProcessResult - { - State = ProcessState.Error, - Message = "OMNI ist nicht versiegelt!" - }; - } - - return new ProcessResult - { - State = ProcessState.Success - }; - } - - //[Display(Name = "Prüflabel drucken")] - //internal ProcessResult PrintTestLabel() - //{ - // var body = new StringBuilder(); - // var culture = new CultureInfo("en-US"); - - // body.AppendLine($"PcbId = {this.MeterPcb};"); - // body.AppendLine($"Orderno = {this.values.Orderno};"); - // body.AppendLine($"Posno = {this.values.Positionno};"); - // body.AppendLine($"TestDate = {this.values.TestDate:dd-MM-yyyy};"); - // body.AppendLine($"Partno = {this.values.Partno};"); - // body.AppendLine($"DescriptionL1 = {this.values.DescriptionL1};"); - // body.AppendLine($"DescriptionL2 = {this.values.DescriptionL2};"); - // body.AppendLine($"CustId = {this.values.DbCustId};"); - // body.AppendLine($"FactId = {this.values.FactId};"); - // body.AppendLine($"QmaxGPM = {this.values.MaxGPM.ToString("0.0", culture)};"); - // body.AppendLine($"QmidGPM = {this.values.MidGPM.ToString("0.00", culture)};"); - // body.AppendLine($"QminGPM = {this.values.MinGPM.ToString("0.00", culture)};"); - // body.AppendLine($"QmaxACC = {this.values.MaxACC.ToString("0.0", culture)};"); - // body.AppendLine($"QmidACC = {this.values.MidACC.ToString("0.0", culture)};"); - // body.AppendLine($"QminACC = {this.values.MinACC.ToString("0.0", culture)};"); - - // var response = this.http - // .PostRequest("/aspx/api.aspx") - // .AddQueryParameter("action", nameof(PrintTestLabel)) - // .WithPlainBody(body.ToString()) - // .GetResponse(); - - // return new ProcessResult - // { - // State = response.Succeeded ? ProcessState.Success : ProcessState.Error, - // Message = String.Join("\n", response?.Errors?.Select(x => $"{x.Key}: {x.Value}") ?? new String[] { response.Exception?.ToString() }) - // }; - //} - - //[Display(Name = "Kartonlabel drucken")] - //internal ProcessResult PrintBoxLabel() - //{ - // var body = new StringBuilder(); - - // body.AppendLine($"CustId = {this.values.DbCustId};"); - // body.AppendLine($"Title = OMNI+™ ({this.values.Variant}) Chamber"); - // body.AppendLine($"DescriptionL1 = {this.values.DescriptionL1};"); - // body.AppendLine($"DescriptionL2 = {this.values.DescriptionL2};"); - // body.AppendLine($"Partno = {this.values.Partno};"); - // body.AppendLine($"Orderno = {this.values.Orderno};"); - // body.AppendLine($"BoxDate = {DateTime.Now:dd-MM-yyyy};"); - // body.AppendLine($"Boxno = {this.values.Boxno};"); - // body.AppendLine($"Quantity = {this.values.Count};"); - - // var response = this.http - // .PostRequest("/aspx/api.aspx") - // .AddQueryParameter("action", nameof(PrintBoxLabel)) - // .WithPlainBody(body.ToString()) - // .GetResponse(); - - // return new ProcessResult - // { - // State = response.Succeeded ? ProcessState.Success : ProcessState.Error, - // Message = String.Join("\n", response?.Errors?.Select(x => $"{x.Key}: {x.Value}") ?? new String[] { response.Exception?.ToString() }) - // }; - //} - - //[Display(Name = "Daten Export")] - //internal ProcessResult ExportData() - //{ - // var testRun = this.values.TestRunId; - // var serialno = this.values.Serialno; - // var meterPcb = this.values.MeterPcb; - // var eheadPcb = this.values.EheadPcb; - // var prueffehlerInfo = $"{DateTime.Now:dd-MM-yyyy HH:mm:ss}"; - // var state = ProcessState.Success; - // var message = String.Empty; - - // var hasTestResults = this.mssql - // .CreateCommand($@"SELECT COUNT(1) FROM Prueffehler WHERE SerienNr = @{nameof(serialno)}") - // .SetParameter(nameof(serialno), serialno) - // .FirstOrDefault(x => x.GetValue(0)) > 0; - - // if (hasTestResults) - // { - // var updated = this.UpdateTestResults(testRun, serialno, prueffehlerInfo); - - // if (!updated) - // { - // state = ProcessState.Warning; - // message += $"Prueffehler wurde nicht aktualisiert.{Environment.NewLine}"; - // } - // } - // else - // { - // var created = this.AddTestResults(testRun, serialno, prueffehlerInfo); - - // if (!created) - // { - // state = ProcessState.Warning; - // message = $"Prueffehler wurde nicht geschrieben.{Environment.NewLine}"; - // } - // } - - // var exported = this.mssql - // .CreateCommand($@"SELECT COUNT(1) FROM PushExt.dbo.OmniExport WHERE ManufacturingSN = @{nameof(serialno)}") - // .SetParameter(nameof(serialno), serialno) - // .FirstOrDefault(x => x.GetValue(0)) > 0; - - // if (exported) - // { - // var updated = this.UpdateExport(testRun, serialno, eheadPcb); - - // if (!updated) - // { - // state = ProcessState.Warning; - // message += $"OmniExport wurde nicht aktualisiert.{Environment.NewLine}"; - // } - // } - // else - // { - // var created = this.AddExport(testRun, serialno, eheadPcb); - - // if (!created) - // { - // state = ProcessState.Warning; - // message = $"OmniExport wurde nicht geschrieben.{Environment.NewLine}"; - // } - // } - - // var aps_updated = UpdateOrderPositionSerialNo(meterPcb); - - // if (!aps_updated) - // { - // state = ProcessState.Warning; - // message = "APSN wurde nicht Aktualisiert.\n"; - // } - - // return new ProcessResult - // { - // State = state, - // Message = message - // }; - //} - - private Boolean UpdateOrderPositionSerialNo(String pcb) - => this.mssql - .CreateCommand($@" - UPDATE AuftragPositionSerienNr - SET Pruefgangnr = y.Pruefgang - , PruefgangDatum = y.EndDate - , Wiederholungen = y.Wiederholungen - , Einbauplatz = y.SlotNr - , Bemerkung = 'Inserted after omni export' - , StatusFertigung = 30 - FROM AuftragPositionSerienNr AS aps - JOIN OmniExport AS oe - ON oe.ManufacturingSN = aps.SerienNr - JOIN (SELECT TOP 1 - Pruefgang - , EndDate - , Wiederholungen - , SlotNr - , BuildInfo - FROM (SELECT ROW_NUMBER() OVER (PARTITION BY BuildInfo ORDER BY Id) AS Wiederholungen - , BuildInfo - , Pruefgang - , EndDate - , SlotNr - FROM OmniTestRuns - WHERE BuildInfo = @{nameof(pcb)} - AND Q1_TpId IS NOT NULL) AS x - ORDER BY x.Wiederholungen DESC) AS y - ON oe.PCBAID = y.BuildInfo") - .SetParameter(nameof(pcb), pcb) - .ExecuteNonQuery() == 1; - - private Boolean AddExport(Int32 testRun, Int32 serialno, String eheadPcb) - => this.mssql - .CreateCommand($@" - INSERT INTO [OmniExport] - ( [OrderNumber] - , [LineNumber] - , [ManufacturingSN] - , [CustomerSN] - , [MeterSN] - , [PCBAID] - , [EhatPCBAID] - , [ManufactureDate] - , [ShipDate] - , [Flow1] - , [Flow2] - , [Flow3] - , [Flow4] - , [Flow5] - , [Flow6] - , [PartNumber]) - SELECT TOP 1 - [apsn].[AuftragNr] - , [apsn].[PositionNr] - , [apsn].[SerienNr] - , [apsn].[KundeneigeneSerienNr] - , [apsn].[FabNr] - , [tr].[BuildInfo] - , @{nameof(eheadPcb)} - , [tr].[EndDate] - , GETDATE() - , ISNULL([tr].[Q1_Acc], 0.0) - , ISNULL([tr].[Q2_Acc], 0.0) - , ISNULL([tr].[Q3_Acc], 0.0) - , ISNULL([tr].[Q4_Acc], 0.0) - , ISNULL([tr].[Q5_Acc], 0.0) - , ISNULL([tr].[Q6_Acc], 0.0) - , [od].[PartNr] - FROM [Auftrag].[dbo].[OmniTestRuns] AS [tr] - JOIN [Auftrag].[dbo].[OmniDefaults] AS [od] - ON [tr].[DefaultId] = [od].[Id] - JOIN (SELECT TOP 1 - [aps].[AuftragNr] - , [aps].[PositionNr] - , [aps].[SerienNr] - , [aps].[KundeneigeneSerienNr] - , [aps].[FabNr] - , [ap].[IdentNr] - FROM [Auftrag].[dbo].[AuftragPositionSerienNr] AS [aps] - JOIN [Auftrag].[dbo].[AuftragPosition] AS [ap] - ON [aps].[AuftragNr] = [ap].[AuftragNr] - AND [aps].[PositionNr] = [ap].[PositionNr] - WHERE [aps].[SerienNr] = @{nameof(serialno)}) - AS [apsn] - ON [apsn].[IdentNr] = [od].[IdentNr] - WHERE [tr].[Id] = @{nameof(testRun)} - ORDER BY [tr].[Id] DESC") - .SetParameter(nameof(testRun), testRun) - .SetParameter(nameof(serialno), serialno) - .SetParameter(nameof(eheadPcb), eheadPcb) - .ExecuteNonQuery() == 1; - - private Boolean AddTestResults(Int32 testRun, Int32 serialno, String prueffehlerInfo) - => this.mssql - .CreateCommand($@" - INSERT INTO [Prueffehler] - ( [SerienNr] - , [PruefgangNr] - , [PruefDatum] - , [PP1_Fehler] - , [PP2_Fehler] - , [PP3_Fehler] - , [PP4_Fehler] - , [PP5_Fehler] - , [PP6_Fehler] - , [PP7_Fehler] - , [PP8_Fehler] - , [PP9_Fehler] - , [PP10_Fehler] - , [Info]) - SELECT TOP 1 - @{nameof(serialno)} - , [tr].[Pruefgang] - , ISNULL([tr].[EndDate], [tr].[AddDate]) - , [tr].[Q1_Acc] - 100.0 - , [tr].[Q2_Acc] - 100.0 - , [tr].[Q3_Acc] - 100.0 - , [tr].[Q4_Acc] - 100.0 - , [tr].[Q5_Acc] - 100.0 - , [tr].[Q6_Acc] - 100.0 - , [tr].[Q7_Acc] - 100.0 - , [tr].[Q8_Acc] - 100.0 - , [tr].[Q9_Acc] - 100.0 - , [tr].[Q10_Acc] - 100.0 - , @{nameof(prueffehlerInfo)} - FROM [OmniTestRuns] AS [tr] - WHERE [tr].[Id] = @{nameof(testRun)}") - .SetParameter(nameof(testRun), testRun) - .SetParameter(nameof(serialno), serialno) - .SetParameter(nameof(prueffehlerInfo), prueffehlerInfo) - .ExecuteNonQuery() == 1; - - private Boolean UpdateExport(Int32 testRun, Int32 serialno, String ehead) - => this.mssql - .CreateCommand($@" - UPDATE PushExt.dbo.OmniExport - SET EhatPCBAID = @{nameof(ehead)} - , PCBAID = tr.BuildInfo - , ManufactureDate = tr.EndDate - , ShipDate = GETDATE() - , Flow1 = ISNULL(tr.Q1_Acc, 0.0) - , Flow2 = ISNULL(tr.Q2_Acc, 0.0) - , Flow3 = ISNULL(tr.Q3_Acc, 0.0) - , Flow4 = ISNULL(tr.Q4_Acc, 0.0) - , Flow5 = ISNULL(tr.Q5_Acc, 0.0) - , Flow6 = ISNULL(tr.Q6_Acc, 0.0) - FROM PushExt.dbo.OmniExport AS oe - JOIN (SELECT TOP 1 - BuildInfo - , Q1_Acc - , Q2_Acc - , Q3_Acc - , Q4_Acc - , Q5_Acc - , Q6_Acc - , EndDate - , @{nameof(serialno)} AS SerialNr - FROM Auftrag.dbo.OmniTestRuns - WHERE Id = @{nameof(testRun)}) AS tr - ON oe.ManufacturingSN = tr.SerialNr") - .SetParameter(nameof(testRun), testRun) - .SetParameter(nameof(serialno), serialno) - .SetParameter(nameof(ehead), ehead) - .ExecuteNonQuery() == 1; - - private Boolean UpdateTestResults(Int32 testRun, Int32 serialno, String prueffehlerInfo) - => this.mssql - .CreateCommand($@" - UPDATE Prueffehler - SET PruefDatum = ISNULL(tr.EndDate, tr.AddDate) - , PP1_Fehler = tr.Q1_Acc - 100.0 - , PP2_Fehler = tr.Q2_Acc - 100.0 - , PP3_Fehler = tr.Q3_Acc - 100.0 - , PP4_Fehler = tr.Q4_Acc - 100.0 - , PP5_Fehler = tr.Q5_Acc - 100.0 - , PP6_Fehler = tr.Q6_Acc - 100.0 - , PP7_Fehler = tr.Q7_Acc - 100.0 - , PP8_Fehler = tr.Q8_Acc - 100.0 - , PP9_Fehler = tr.Q9_Acc - 100.0 - , PP10_Fehler = tr.Q10_Acc - 100.0 - , Info = @{nameof(prueffehlerInfo)} - FROM Prueffehler AS pf - JOIN OmniTestRuns AS tr - ON pf.PruefgangNr = tr.Pruefgang - WHERE tr.Id = @{nameof(testRun)} - AND pf.SerienNr = @{nameof(serialno)}") - .SetParameter(nameof(testRun), testRun) - .SetParameter(nameof(serialno), serialno) - .SetParameter(nameof(prueffehlerInfo), prueffehlerInfo) - .ExecuteNonQuery() == 1; - } -} - diff --git a/Common/Ui/Common.UI.VFM/Models/OmniValuesModel.cs b/Common/Ui/Common.UI.VFM/Models/OmniValuesModel.cs deleted file mode 100644 index 123e062d..00000000 --- a/Common/Ui/Common.UI.VFM/Models/OmniValuesModel.cs +++ /dev/null @@ -1,118 +0,0 @@ -namespace Common.UI.VFM.Models -{ - using System; - using Common.Hardware.WaterMeter.OmniPlus.Features; - - public class OmniValuesModel - { - public Int32 Orderno { get; set; } - - public Int16 Positionno { get; set; } - - public Int32 ProductionOrderno { get; set; } - - public Int32 OrderIdentno { get; set; } - - public Int32 Count { get; set; } - - public Int32 Boxno { get; set; } - - public Int32 Serialno { get; set; } - - public String DbCustId { get; set; } - - public Int32 FactId { get; set; } - - public String EheadPcb { get; set; } - - public String MeterPcb { get; set; } - - public Byte ProductionStatus { get; set; } - - public String Partno { get; set; } - - public String DescriptionL1 { get; set; } - - public String DescriptionL2 { get; set; } - - public String Variant { get; set; } - - public String SQLErrors { get; set; } - - public Double MaxGPM { get; set; } - - public Double MaxACC { get; set; } - - public Double MidGPM { get; set; } - - public Double MidACC { get; set; } - - public Double MinGPM { get; set; } - - public Double MinACC { get; set; } - - public DateTime TestDate { get; set; } - - public Boolean Succeeded { get; set; } - - public Single CalibrationFactor { get; set; } - - public Int32 TestRunId { get; set; } - - public Byte Size { get; set; } - - public Byte Range { get; set; } - - public Byte Direction { get; set; } - - public Byte IntPart { get; set; } - - public Int32 Fraction { get; set; } - - public Int16 Crf { get; set; } - - public Byte Ppr { get; set; } - - public Byte MeterUnits { get; set; } - - public Byte FlowUnits { get; set; } - - public Byte FlowRate { get; set; } - - public Byte PulseWeight { get; set; } - - public Byte PulseWidth { get; set; } - - public Byte PulseUpdate { get; set; } - - public Byte AlarmPercistancePeriodDays { get; set; } - - public Int32 DataLogIntervalMinutes { get; set; } - - public Int16 NumberOfReadingDigits { get; set; } - - public Int32 OptionalUniDirFields { get; set; } - - public String ReadingPreset { get; set; } - - public String DeviceID { get; set; } - - public Single LeakAlarmGPM { get; set; } - - public Int64 LeakAlarmHours { get; set; } - - public Single HighFlowAlarmGPM { get; set; } - - public Int64 HighFlowAlarmHours { get; set; } - - public Single ReverseFlowAlarmGPM { get; set; } - - public Int64 ReverseFlowAlarmMinutes { get; set; } - - public UInt32 ManifacturingTime { get; set; } - - public SystemParameters SystemParameters { get; set; } - - public ConfigurationParameters ConfigurationParameters { get; set; } - } -} \ No newline at end of file diff --git a/Common/Ui/Common.UI.VFM/Models/ProcessResult.cs b/Common/Ui/Common.UI.VFM/Models/ProcessResult.cs deleted file mode 100644 index 1159729e..00000000 --- a/Common/Ui/Common.UI.VFM/Models/ProcessResult.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace Common.UI.VFM.Models -{ - using System; - - public class ProcessResult - { - public ProcessState State { get; set; } - - public String Message { get; set; } - } -} diff --git a/Common/Ui/Common.UI.VFM/Models/ProcessState.cs b/Common/Ui/Common.UI.VFM/Models/ProcessState.cs deleted file mode 100644 index e71ba423..00000000 --- a/Common/Ui/Common.UI.VFM/Models/ProcessState.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace Common.UI.VFM.Models -{ - public enum ProcessState - { - Undefined = -1, - Started = 0, - Success = 1, - Warning = 2, - Error = 3, - } -} diff --git a/Common/Ui/Common.UI.VFM/ViewModels/AppViewModel.cs b/Common/Ui/Common.UI.VFM/ViewModels/AppViewModel.cs deleted file mode 100644 index 658fd7d0..00000000 --- a/Common/Ui/Common.UI.VFM/ViewModels/AppViewModel.cs +++ /dev/null @@ -1,88 +0,0 @@ -namespace Common.UI.VFM.ViewModels -{ - using Common.UI.VFM.Views; - - using System; - using System.ComponentModel; - using System.Configuration; - using System.Runtime.CompilerServices; - using System.Windows; - using System.Windows.Input; - - public class AppViewModel : INotifyPropertyChanged - { - protected AppViewModel() => App.Exiting += this.Dispose; - - public event PropertyChangedEventHandler PropertyChanged; - - protected String PortName => ConfigurationManager.AppSettings[nameof(this.PortName)]; - - protected String SqlConnectionString => ConfigurationManager.AppSettings[nameof(this.SqlConnectionString)]; - - protected String LabelServer => ConfigurationManager.AppSettings[nameof(this.LabelServer)]; - - public virtual void Dispose() => App.Exiting -= this.Dispose; - - protected void NotifyPropertyChanged([CallerMemberName] String property = "") - => this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(property)); - - protected void Set(Action setExpression, [CallerMemberName] String property = "") - { - setExpression?.Invoke(); - - this.NotifyPropertyChanged(property); - } - - protected class Command : ICommand - { - private readonly Action executable; - - public Command(Action executable) - { - this.executable = executable; - } - - public event EventHandler CanExecuteChanged - { - add => CommandManager.RequerySuggested += value; - remove => CommandManager.RequerySuggested -= value; - } - - public bool CanExecute(Object _) - { - return this.executable != null; - } - - public void Execute(Object _) - { - this.executable?.Invoke(); - } - } - - protected class Command : ICommand - { - private readonly Action executable; - - public Command(Action executable) - { - this.executable = executable; - } - - public event EventHandler CanExecuteChanged - { - add => CommandManager.RequerySuggested += value; - remove => CommandManager.RequerySuggested -= value; - } - - public bool CanExecute(Object _) - { - return this.executable != null; - } - - public void Execute(Object parameter) - { - this.executable?.Invoke(parameter is T t ? t : default(T)); - } - } - } -} diff --git a/Common/Ui/Common.UI.VFM/ViewModels/EmptyViewModel.cs b/Common/Ui/Common.UI.VFM/ViewModels/EmptyViewModel.cs deleted file mode 100644 index aef2523b..00000000 --- a/Common/Ui/Common.UI.VFM/ViewModels/EmptyViewModel.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Common.UI.VFM.ViewModels -{ - public class EmptyViewModel : AppViewModel - { - } -} diff --git a/Common/Ui/Common.UI.VFM/ViewModels/MainWindowViewModel.cs b/Common/Ui/Common.UI.VFM/ViewModels/MainWindowViewModel.cs deleted file mode 100644 index 700d7115..00000000 --- a/Common/Ui/Common.UI.VFM/ViewModels/MainWindowViewModel.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace Common.UI.VFM.ViewModels -{ - public class MainWindowViewModel : AppViewModel - { - private AppViewModel content; - public AppViewModel Content - { - get => this.content ?? new ShipmnetViewModel(); - set => this.Set(() => this.content = value); - } - } -} diff --git a/Common/Ui/Common.UI.VFM/ViewModels/ProcessStepViewModel.cs b/Common/Ui/Common.UI.VFM/ViewModels/ProcessStepViewModel.cs deleted file mode 100644 index fe1596e4..00000000 --- a/Common/Ui/Common.UI.VFM/ViewModels/ProcessStepViewModel.cs +++ /dev/null @@ -1,49 +0,0 @@ -namespace Common.UI.VFM.ViewModels -{ - using Common.UI.VFM.Models; - - using System; - using System.Collections.Generic; - using System.Windows; - - public class ProcessStepViewModel : AppViewModel - { - private readonly Func process; - - public ProcessStepViewModel(String name, Func process) - { - this.Name = name; - this.process = process; - this.State = ProcessState.Undefined; - } - - public String Name { get; } - - private ProcessState state; - public ProcessState State - { - get => this.state; - set => this.Set(() => this.state = value); - } - - private String message; - public String Message - { - get => this.message; - set => this.Set(() => this.message = value); - } - - internal ProcessResult StartProcessing() - { - this.State = ProcessState.Started; - var result = this.process.Invoke(); - this.State = result.State; - this.Message = result.Message; - - return result; - } - - public static implicit operator ProcessStepViewModel(KeyValuePair> kvp) - => new ProcessStepViewModel(kvp.Key, kvp.Value); - } -} diff --git a/Common/Ui/Common.UI.VFM/ViewModels/ShipmnetViewModel.cs b/Common/Ui/Common.UI.VFM/ViewModels/ShipmnetViewModel.cs deleted file mode 100644 index b3c52967..00000000 --- a/Common/Ui/Common.UI.VFM/ViewModels/ShipmnetViewModel.cs +++ /dev/null @@ -1,224 +0,0 @@ -namespace Common.UI.VFM.ViewModels -{ - using Common.UI.VFM.Models; - - using System; - using System.Collections.Generic; - using System.Collections.ObjectModel; - using System.Threading; - using System.Threading.Tasks; - using System.Windows.Input; - - public class ShipmnetViewModel : AppViewModel - { - private readonly OmniShipmentModel model; - - public ShipmnetViewModel() : base() - { - this.resetted = true; - this.model = new OmniShipmentModel(this.PortName, this.SqlConnectionString, this.LabelServer); - this.ResetProcessState = new Command(this.ResetProcessStateHandler); - this.StartProcessing = new Command(this.StartProcessingHandler); - this.ReprintBoxLable = new Command(this.ReprintBoxLableHandler); - this.ReprintTestLable = new Command(this.ReprintTestLableHandler); - this.Processes = new ObservableCollection(this.LoadProcesses()); - } - - public String CustId - { - get => this.model.CustId; - set => this.Set(() => - { - this.model.CustId = value?.Trim(); - this.ReprintEnabled = !this.Proccessing && this.model.WasPrinted(); - }); - } - - public String MeterPcb - { - get => this.model.MeterPcb; - set => this.Set(() => - { - this.model.MeterPcb = value?.Trim(); - this.ReprintEnabled = !this.Proccessing && this.model.WasPrinted(); - }); - } - - private Boolean reprintEnabled; - public Boolean ReprintEnabled - { - get => this.reprintEnabled; - set => this.Set(() => this.reprintEnabled = value); - } - - private String message; - public String Message - { - get => this.message; - set => this.Set(() => this.message = value); - } - - private Boolean resetted; - private Boolean processing; - public Boolean Proccessing - { - get => this.processing; - set => this.Set(() => this.processing = value); - } - - public ICommand ResetProcessState { get; } - - public ICommand StartProcessing { get; } - - public ICommand ReprintBoxLable { get; } - - public ICommand ReprintTestLable { get; } - - public ObservableCollection Processes { get; } - - private IEnumerable LoadProcesses() - { - foreach (var kvp in this.model.GetProcesses()) - { - yield return kvp; - } - } - - private void ReprintBoxLableHandler() - { - if (!this.Proccessing) - { - Task.Factory - .StartNew(state => - { - if (state is ShipmnetViewModel viewModel) - { - var model = viewModel.model; - model.LoadProductionOrderData(); - model.LoadProductionTestData(); - model.LoadDefaultValues(); - // model.PrintBoxLabel(); - } - - }, this, CancellationToken.None) - .ContinueWith(task => - { - if (task.AsyncState is ShipmnetViewModel viewModel) - { - if (task.Exception != null) - { - viewModel.Message = task.Exception.Message; - } - - viewModel.Proccessing = false; - } - }); - } - } - - private void ReprintTestLableHandler() - { - if (!this.Proccessing) - { - Task.Factory - .StartNew(state => - { - if (state is ShipmnetViewModel viewModel) - { - var model = viewModel.model; - model.LoadProductionOrderData(); - model.LoadProductionTestData(); - model.LoadDefaultValues(); - // model.PrintTestLabel(); - } - - }, this, CancellationToken.None) - .ContinueWith(task => - { - if (task.AsyncState is ShipmnetViewModel viewModel) - { - if (task.Exception != null) - { - viewModel.Message = task.Exception.Message; - } - - viewModel.Proccessing = false; - } - }); - } - } - - private void ResetProcessStateHandler() - { - if (!this.resetted) - { - this.resetted = true; - this.CustId = default(String); - this.MeterPcb = default(String); - this.Message = default(String); - - foreach (var process in this.Processes) - { - process.State = ProcessState.Undefined; - process.Message = default(String); - } - } - } - - private void StartProcessingHandler() - { - if (!this.Proccessing && this.resetted) - { - Task.Factory - .StartNew(state => - { - if (state is ShipmnetViewModel viewModel) - { - viewModel.resetted = false; - viewModel.Proccessing = true; - viewModel.ReprintEnabled = false; - viewModel.Message = "Programmierung lauft ... Bitte warten!"; - - viewModel.model.Initialize(); - - var proccessed = true; - - foreach (var process in viewModel.Processes) - { - var result = process.StartProcessing(); - - if (result.State == ProcessState.Error) - { - viewModel.Message = "Programmierung wurde abgebrochen!"; - proccessed = false; - - break; - } - } - - if (proccessed) - { - viewModel.model.Finish(); - - viewModel.Message = "Programmierung erfolgreich abgeschlossen! Etiketten werden gedruckt."; - } - - viewModel.Proccessing = false; - viewModel.ReprintEnabled = true; - } - - }, this, CancellationToken.None) - .ContinueWith(task => - { - if (task.AsyncState is ShipmnetViewModel viewModel) - { - if (task.Exception != null) - { - viewModel.Message = task.Exception.Message; - } - } - }); - } - } - } -} diff --git a/Common/Ui/Common.UI.VFM/Views/App.xaml b/Common/Ui/Common.UI.VFM/Views/App.xaml deleted file mode 100644 index 0528552f..00000000 --- a/Common/Ui/Common.UI.VFM/Views/App.xaml +++ /dev/null @@ -1,165 +0,0 @@ - - - - - - - - - - - - - - - - M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14m0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16 - M6.271 5.055a.5.5 0 0 1 .52.038l3.5 2.5a.5.5 0 0 1 0 .814l-3.5 2.5A.5.5 0 0 1 6 10.5v-5a.5.5 0 0 1 .271-.445 - - - - - - - - - - - - M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14m0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16 - M5 6.25a1.25 1.25 0 1 1 2.5 0v3.5a1.25 1.25 0 1 1-2.5 0zm3.5 0a1.25 1.25 0 1 1 2.5 0v3.5a1.25 1.25 0 1 1-2.5 0z - - - - - - - - - - - - M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14m0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16 - m10.97 4.97-.02.022-3.473 4.425-2.093-2.094a.75.75 0 0 0-1.06 1.06L6.97 11.03a.75.75 0 0 0 1.079-.02l3.992-4.99a.75.75 0 0 0-1.071-1.05 - - - - - - - - - - - - M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14m0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16 - M7.002 11a1 1 0 1 1 2 0 1 1 0 0 1-2 0M7.1 4.995a.905.905 0 1 1 1.8 0l-.35 3.507a.552.552 0 0 1-1.1 0z - - - - - - - - - - - - M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14m0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16 - M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Common/Ui/Common.UI.VFM/Views/App.xaml.cs b/Common/Ui/Common.UI.VFM/Views/App.xaml.cs deleted file mode 100644 index ea234045..00000000 --- a/Common/Ui/Common.UI.VFM/Views/App.xaml.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace Common.UI.VFM.Views -{ - using System; - using System.Windows; - - public partial class App : Application - { - internal static event Action Exiting; - - protected override void OnExit(ExitEventArgs e) => Exiting?.Invoke(); - } -} diff --git a/Common/Ui/Common.UI.VFM/Views/EmptyView.xaml b/Common/Ui/Common.UI.VFM/Views/EmptyView.xaml deleted file mode 100644 index d166f681..00000000 --- a/Common/Ui/Common.UI.VFM/Views/EmptyView.xaml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - diff --git a/Common/Ui/Common.UI.VFM/Views/EmptyView.xaml.cs b/Common/Ui/Common.UI.VFM/Views/EmptyView.xaml.cs deleted file mode 100644 index b2425033..00000000 --- a/Common/Ui/Common.UI.VFM/Views/EmptyView.xaml.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Common.UI.VFM.Views -{ - using System.Windows.Controls; - - public partial class EmptyView : Grid - { - public EmptyView() => this.InitializeComponent(); - } -} diff --git a/Common/Ui/Common.UI.VFM/Views/MainWindow.xaml b/Common/Ui/Common.UI.VFM/Views/MainWindow.xaml deleted file mode 100644 index 09fae66b..00000000 --- a/Common/Ui/Common.UI.VFM/Views/MainWindow.xaml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/Common/Ui/Common.UI.VFM/Views/MainWindow.xaml.cs b/Common/Ui/Common.UI.VFM/Views/MainWindow.xaml.cs deleted file mode 100644 index 9f8fe8c6..00000000 --- a/Common/Ui/Common.UI.VFM/Views/MainWindow.xaml.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Common.UI.VFM.Views -{ - using System.Windows; - - public partial class MainWindow : Window - { - public MainWindow() => this.InitializeComponent(); - } -} diff --git a/Common/Ui/Common.UI.VFM/Views/ShipmentView.xaml b/Common/Ui/Common.UI.VFM/Views/ShipmentView.xaml deleted file mode 100644 index bc7ce24a..00000000 --- a/Common/Ui/Common.UI.VFM/Views/ShipmentView.xaml +++ /dev/null @@ -1,178 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -