From b8926ef93f4aabf1e6f26b39273da87008add6dd Mon Sep 17 00:00:00 2001 From: Michal Buzik Date: Thu, 7 May 2026 21:30:19 +0200 Subject: [PATCH] Add unit tests for `OptoHeadTest` handling simulated Genesis readers, refine project references, and increment assembly version to `3.9.3079.1`. --- .../API/InterfaceGCIToLaatzen.cs | 2 +- TBF.sln | 375 ---- TBF/Properties/AssemblyInfo.cs | 4 +- .../BridgeComponents/GciBridge/GciBridge.cs | 42 +- .../communication/OptoHeadTest.cs | 404 ++-- .../communication/RadioService.cs | 585 +++--- .../communication/common/LedState.cs | 9 + TBF/TBF.csproj | 1677 +++++++++-------- .../communication/OptoHeadTest_Test.cs | 151 ++ .../implementations/GenesisSmartReaderTest.cs | 3 +- TBFTests/TBFTests.csproj | 2 +- 11 files changed, 1714 insertions(+), 1540 deletions(-) create mode 100644 TBF/Rig/RegisterReaders/GenesisRegReader/communication/common/LedState.cs create mode 100644 TBFTests/Rig/RegisterReaders/GenesisRegReader/communication/OptoHeadTest_Test.cs diff --git a/GenesisCordonelInterface/API/InterfaceGCIToLaatzen.cs b/GenesisCordonelInterface/API/InterfaceGCIToLaatzen.cs index 4a762eb46..aeff08a17 100644 --- a/GenesisCordonelInterface/API/InterfaceGCIToLaatzen.cs +++ b/GenesisCordonelInterface/API/InterfaceGCIToLaatzen.cs @@ -125,7 +125,7 @@ namespace GenesisCordonelInterface.API #region ================================== Helpers ================================== - private GenesisMeter GetMeter(int slot) + public GenesisMeter GetMeter(int slot) { var meter = _meterBatch.ListOfMeters .OfType() diff --git a/TBF.sln b/TBF.sln index f94f8b782..0b2e1ba0f 100644 --- a/TBF.sln +++ b/TBF.sln @@ -202,18 +202,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LegacyGenCtl", "ExternalPro EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "eRegisterCore", "ExternalProjects\Laatzen\Genesis\Common\Hardware\WaterMeter\eRegister\eRegisterCore\eRegisterCore.csproj", "{A83696BF-D8A2-4809-8424-CFE172AED5B6}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataPackages", "ExternalProjects\Laatzen\Genesis\Common\Hardware\WaterMeter\eRegister\DataPackages\DataPackages.csproj", "{C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StreamingProtocol", "ExternalProjects\Laatzen\Genesis\Common\Hardware\WaterMeter\eRegister\Protocols\StreamingProtocol.csproj", "{B6A19B80-0F0F-434C-A754-A7712FC208B2}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MagFluxCore", "ExternalProjects\Laatzen\Genesis\Common\Hardware\WaterMeter\MagFlux\MagFluxCore\MagFluxCore.csproj", "{B5DA260C-71CC-45CA-B79E-D1B376AF718C}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataPackages", "ExternalProjects\Laatzen\Genesis\Common\Hardware\WaterMeter\MagFlux\DataPackages\DataPackages.csproj", "{BA17D20E-0CEB-4B27-9772-2392BD750ED5}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StreamingProtocol", "ExternalProjects\Laatzen\Genesis\Common\Hardware\WaterMeter\MagFlux\Protocols\StreamingProtocol\StreamingProtocol.csproj", "{D6B81C60-2763-4C4D-989F-90822F53B01A}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RequestProtocol", "ExternalProjects\Laatzen\Genesis\Common\Hardware\WaterMeter\MagFlux\Protocols\RequestProtocol\RequestProtocol.csproj", "{00748F11-4B49-4D8B-93C4-4A11A210CCE2}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tools.JsonToXlsHelper", "ExternalProjects\Laatzen\Genesis\Common\Tools\Tools.JsonToXlsHelper\Tools.JsonToXlsHelper.csproj", "{20F137FD-C25E-42B7-A68F-58C746475897}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MagFluxConfig", "ExternalProjects\Laatzen\Genesis\Common\Hardware\WaterMeter\MagFlux\MagFluxConfig\MagFluxConfig.csproj", "{70398B99-B134-4BBD-968B-7399B70C3CE2}" @@ -5600,150 +5590,6 @@ Global {A83696BF-D8A2-4809-8424-CFE172AED5B6}.XP32bit|x64.Build.0 = Debug|Any CPU {A83696BF-D8A2-4809-8424-CFE172AED5B6}.XP32bit|x86.ActiveCfg = Debug|Any CPU {A83696BF-D8A2-4809-8424-CFE172AED5B6}.XP32bit|x86.Build.0 = Debug|Any CPU - {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}._MANUAL_CONTROL|Any CPU.ActiveCfg = Debug|Any CPU - {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}._MANUAL_CONTROL|Any CPU.Build.0 = Debug|Any CPU - {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}._MANUAL_CONTROL|Mixed Platforms.ActiveCfg = Debug|Any CPU - {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}._MANUAL_CONTROL|Mixed Platforms.Build.0 = Debug|Any CPU - {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}._MANUAL_CONTROL|x64.ActiveCfg = Debug|Any CPU - {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}._MANUAL_CONTROL|x64.Build.0 = Debug|Any CPU - {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}._MANUAL_CONTROL|x86.ActiveCfg = Debug|Any CPU - {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}._MANUAL_CONTROL|x86.Build.0 = Debug|Any CPU - {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.COM|Any CPU.ActiveCfg = Debug|Any CPU - {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.COM|Any CPU.Build.0 = Debug|Any CPU - {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.COM|Mixed Platforms.ActiveCfg = Debug|Any CPU - {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.COM|Mixed Platforms.Build.0 = Debug|Any CPU - {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.COM|x64.ActiveCfg = Debug|Any CPU - {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.COM|x64.Build.0 = Debug|Any CPU - {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.COM|x86.ActiveCfg = Debug|Any CPU - {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.COM|x86.Build.0 = Debug|Any CPU - {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.Debug|x64.ActiveCfg = Debug|Any CPU - {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.Debug|x64.Build.0 = Debug|Any CPU - {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.Debug|x86.ActiveCfg = Debug|Any CPU - {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.Debug|x86.Build.0 = Debug|Any CPU - {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.Debug-local IIS-CUST|Any CPU.ActiveCfg = Debug|Any CPU - {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.Debug-local IIS-CUST|Any CPU.Build.0 = Debug|Any CPU - {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.Debug-local IIS-CUST|Mixed Platforms.ActiveCfg = Debug|Any CPU - {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.Debug-local IIS-CUST|Mixed Platforms.Build.0 = Debug|Any CPU - {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.Debug-local IIS-CUST|x64.ActiveCfg = Debug|Any CPU - {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.Debug-local IIS-CUST|x64.Build.0 = Debug|Any CPU - {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.Debug-local IIS-CUST|x86.ActiveCfg = Debug|Any CPU - {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.Debug-local IIS-CUST|x86.Build.0 = Debug|Any CPU - {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.PerformTest|Any CPU.ActiveCfg = Debug|Any CPU - {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.PerformTest|Any CPU.Build.0 = Debug|Any CPU - {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.PerformTest|Mixed Platforms.ActiveCfg = Debug|Any CPU - {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.PerformTest|Mixed Platforms.Build.0 = Debug|Any CPU - {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.PerformTest|x64.ActiveCfg = Debug|Any CPU - {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.PerformTest|x64.Build.0 = Debug|Any CPU - {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.PerformTest|x86.ActiveCfg = Debug|Any CPU - {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.PerformTest|x86.Build.0 = Debug|Any CPU - {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.Release|Any CPU.Build.0 = Release|Any CPU - {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.Release|x64.ActiveCfg = Release|Any CPU - {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.Release|x64.Build.0 = Release|Any CPU - {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.Release|x86.ActiveCfg = Release|Any CPU - {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.Release|x86.Build.0 = Release|Any CPU - {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.ReleaseTest|Any CPU.ActiveCfg = Release|Any CPU - {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.ReleaseTest|Any CPU.Build.0 = Release|Any CPU - {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.ReleaseTest|Mixed Platforms.ActiveCfg = Release|Any CPU - {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.ReleaseTest|Mixed Platforms.Build.0 = Release|Any CPU - {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.ReleaseTest|x64.ActiveCfg = Release|Any CPU - {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.ReleaseTest|x64.Build.0 = Release|Any CPU - {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.ReleaseTest|x86.ActiveCfg = Release|Any CPU - {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.ReleaseTest|x86.Build.0 = Release|Any CPU - {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.VPN_Debug|Any CPU.ActiveCfg = VPN_Debug|Any CPU - {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.VPN_Debug|Any CPU.Build.0 = VPN_Debug|Any CPU - {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.VPN_Debug|Mixed Platforms.ActiveCfg = VPN_Debug|Any CPU - {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.VPN_Debug|Mixed Platforms.Build.0 = VPN_Debug|Any CPU - {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.VPN_Debug|x64.ActiveCfg = VPN_Debug|Any CPU - {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.VPN_Debug|x64.Build.0 = VPN_Debug|Any CPU - {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.VPN_Debug|x86.ActiveCfg = VPN_Debug|Any CPU - {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.VPN_Debug|x86.Build.0 = VPN_Debug|Any CPU - {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.XP32bit|Any CPU.ActiveCfg = Debug|Any CPU - {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.XP32bit|Any CPU.Build.0 = Debug|Any CPU - {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.XP32bit|Mixed Platforms.ActiveCfg = Debug|Any CPU - {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.XP32bit|Mixed Platforms.Build.0 = Debug|Any CPU - {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.XP32bit|x64.ActiveCfg = Debug|Any CPU - {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.XP32bit|x64.Build.0 = Debug|Any CPU - {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.XP32bit|x86.ActiveCfg = Debug|Any CPU - {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.XP32bit|x86.Build.0 = Debug|Any CPU - {B6A19B80-0F0F-434C-A754-A7712FC208B2}._MANUAL_CONTROL|Any CPU.ActiveCfg = Debug|Any CPU - {B6A19B80-0F0F-434C-A754-A7712FC208B2}._MANUAL_CONTROL|Any CPU.Build.0 = Debug|Any CPU - {B6A19B80-0F0F-434C-A754-A7712FC208B2}._MANUAL_CONTROL|Mixed Platforms.ActiveCfg = Debug|Any CPU - {B6A19B80-0F0F-434C-A754-A7712FC208B2}._MANUAL_CONTROL|Mixed Platforms.Build.0 = Debug|Any CPU - {B6A19B80-0F0F-434C-A754-A7712FC208B2}._MANUAL_CONTROL|x64.ActiveCfg = Debug|Any CPU - {B6A19B80-0F0F-434C-A754-A7712FC208B2}._MANUAL_CONTROL|x64.Build.0 = Debug|Any CPU - {B6A19B80-0F0F-434C-A754-A7712FC208B2}._MANUAL_CONTROL|x86.ActiveCfg = Debug|Any CPU - {B6A19B80-0F0F-434C-A754-A7712FC208B2}._MANUAL_CONTROL|x86.Build.0 = Debug|Any CPU - {B6A19B80-0F0F-434C-A754-A7712FC208B2}.COM|Any CPU.ActiveCfg = Debug|Any CPU - {B6A19B80-0F0F-434C-A754-A7712FC208B2}.COM|Any CPU.Build.0 = Debug|Any CPU - {B6A19B80-0F0F-434C-A754-A7712FC208B2}.COM|Mixed Platforms.ActiveCfg = Debug|Any CPU - {B6A19B80-0F0F-434C-A754-A7712FC208B2}.COM|Mixed Platforms.Build.0 = Debug|Any CPU - {B6A19B80-0F0F-434C-A754-A7712FC208B2}.COM|x64.ActiveCfg = Debug|Any CPU - {B6A19B80-0F0F-434C-A754-A7712FC208B2}.COM|x64.Build.0 = Debug|Any CPU - {B6A19B80-0F0F-434C-A754-A7712FC208B2}.COM|x86.ActiveCfg = Debug|Any CPU - {B6A19B80-0F0F-434C-A754-A7712FC208B2}.COM|x86.Build.0 = Debug|Any CPU - {B6A19B80-0F0F-434C-A754-A7712FC208B2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B6A19B80-0F0F-434C-A754-A7712FC208B2}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B6A19B80-0F0F-434C-A754-A7712FC208B2}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {B6A19B80-0F0F-434C-A754-A7712FC208B2}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {B6A19B80-0F0F-434C-A754-A7712FC208B2}.Debug|x64.ActiveCfg = Debug|Any CPU - {B6A19B80-0F0F-434C-A754-A7712FC208B2}.Debug|x64.Build.0 = Debug|Any CPU - {B6A19B80-0F0F-434C-A754-A7712FC208B2}.Debug|x86.ActiveCfg = Debug|Any CPU - {B6A19B80-0F0F-434C-A754-A7712FC208B2}.Debug|x86.Build.0 = Debug|Any CPU - {B6A19B80-0F0F-434C-A754-A7712FC208B2}.Debug-local IIS-CUST|Any CPU.ActiveCfg = Debug|Any CPU - {B6A19B80-0F0F-434C-A754-A7712FC208B2}.Debug-local IIS-CUST|Any CPU.Build.0 = Debug|Any CPU - {B6A19B80-0F0F-434C-A754-A7712FC208B2}.Debug-local IIS-CUST|Mixed Platforms.ActiveCfg = Debug|Any CPU - {B6A19B80-0F0F-434C-A754-A7712FC208B2}.Debug-local IIS-CUST|Mixed Platforms.Build.0 = Debug|Any CPU - {B6A19B80-0F0F-434C-A754-A7712FC208B2}.Debug-local IIS-CUST|x64.ActiveCfg = Debug|Any CPU - {B6A19B80-0F0F-434C-A754-A7712FC208B2}.Debug-local IIS-CUST|x64.Build.0 = Debug|Any CPU - {B6A19B80-0F0F-434C-A754-A7712FC208B2}.Debug-local IIS-CUST|x86.ActiveCfg = Debug|Any CPU - {B6A19B80-0F0F-434C-A754-A7712FC208B2}.Debug-local IIS-CUST|x86.Build.0 = Debug|Any CPU - {B6A19B80-0F0F-434C-A754-A7712FC208B2}.PerformTest|Any CPU.ActiveCfg = Debug|Any CPU - {B6A19B80-0F0F-434C-A754-A7712FC208B2}.PerformTest|Any CPU.Build.0 = Debug|Any CPU - {B6A19B80-0F0F-434C-A754-A7712FC208B2}.PerformTest|Mixed Platforms.ActiveCfg = Debug|Any CPU - {B6A19B80-0F0F-434C-A754-A7712FC208B2}.PerformTest|Mixed Platforms.Build.0 = Debug|Any CPU - {B6A19B80-0F0F-434C-A754-A7712FC208B2}.PerformTest|x64.ActiveCfg = Debug|Any CPU - {B6A19B80-0F0F-434C-A754-A7712FC208B2}.PerformTest|x64.Build.0 = Debug|Any CPU - {B6A19B80-0F0F-434C-A754-A7712FC208B2}.PerformTest|x86.ActiveCfg = Debug|Any CPU - {B6A19B80-0F0F-434C-A754-A7712FC208B2}.PerformTest|x86.Build.0 = Debug|Any CPU - {B6A19B80-0F0F-434C-A754-A7712FC208B2}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B6A19B80-0F0F-434C-A754-A7712FC208B2}.Release|Any CPU.Build.0 = Release|Any CPU - {B6A19B80-0F0F-434C-A754-A7712FC208B2}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {B6A19B80-0F0F-434C-A754-A7712FC208B2}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {B6A19B80-0F0F-434C-A754-A7712FC208B2}.Release|x64.ActiveCfg = Release|Any CPU - {B6A19B80-0F0F-434C-A754-A7712FC208B2}.Release|x64.Build.0 = Release|Any CPU - {B6A19B80-0F0F-434C-A754-A7712FC208B2}.Release|x86.ActiveCfg = Release|Any CPU - {B6A19B80-0F0F-434C-A754-A7712FC208B2}.Release|x86.Build.0 = Release|Any CPU - {B6A19B80-0F0F-434C-A754-A7712FC208B2}.ReleaseTest|Any CPU.ActiveCfg = Release|Any CPU - {B6A19B80-0F0F-434C-A754-A7712FC208B2}.ReleaseTest|Any CPU.Build.0 = Release|Any CPU - {B6A19B80-0F0F-434C-A754-A7712FC208B2}.ReleaseTest|Mixed Platforms.ActiveCfg = Release|Any CPU - {B6A19B80-0F0F-434C-A754-A7712FC208B2}.ReleaseTest|Mixed Platforms.Build.0 = Release|Any CPU - {B6A19B80-0F0F-434C-A754-A7712FC208B2}.ReleaseTest|x64.ActiveCfg = Release|Any CPU - {B6A19B80-0F0F-434C-A754-A7712FC208B2}.ReleaseTest|x64.Build.0 = Release|Any CPU - {B6A19B80-0F0F-434C-A754-A7712FC208B2}.ReleaseTest|x86.ActiveCfg = Release|Any CPU - {B6A19B80-0F0F-434C-A754-A7712FC208B2}.ReleaseTest|x86.Build.0 = Release|Any CPU - {B6A19B80-0F0F-434C-A754-A7712FC208B2}.VPN_Debug|Any CPU.ActiveCfg = VPN_Debug|Any CPU - {B6A19B80-0F0F-434C-A754-A7712FC208B2}.VPN_Debug|Any CPU.Build.0 = VPN_Debug|Any CPU - {B6A19B80-0F0F-434C-A754-A7712FC208B2}.VPN_Debug|Mixed Platforms.ActiveCfg = VPN_Debug|Any CPU - {B6A19B80-0F0F-434C-A754-A7712FC208B2}.VPN_Debug|Mixed Platforms.Build.0 = VPN_Debug|Any CPU - {B6A19B80-0F0F-434C-A754-A7712FC208B2}.VPN_Debug|x64.ActiveCfg = VPN_Debug|Any CPU - {B6A19B80-0F0F-434C-A754-A7712FC208B2}.VPN_Debug|x64.Build.0 = VPN_Debug|Any CPU - {B6A19B80-0F0F-434C-A754-A7712FC208B2}.VPN_Debug|x86.ActiveCfg = VPN_Debug|Any CPU - {B6A19B80-0F0F-434C-A754-A7712FC208B2}.VPN_Debug|x86.Build.0 = VPN_Debug|Any CPU - {B6A19B80-0F0F-434C-A754-A7712FC208B2}.XP32bit|Any CPU.ActiveCfg = Debug|Any CPU - {B6A19B80-0F0F-434C-A754-A7712FC208B2}.XP32bit|Any CPU.Build.0 = Debug|Any CPU - {B6A19B80-0F0F-434C-A754-A7712FC208B2}.XP32bit|Mixed Platforms.ActiveCfg = Debug|Any CPU - {B6A19B80-0F0F-434C-A754-A7712FC208B2}.XP32bit|Mixed Platforms.Build.0 = Debug|Any CPU - {B6A19B80-0F0F-434C-A754-A7712FC208B2}.XP32bit|x64.ActiveCfg = Debug|Any CPU - {B6A19B80-0F0F-434C-A754-A7712FC208B2}.XP32bit|x64.Build.0 = Debug|Any CPU - {B6A19B80-0F0F-434C-A754-A7712FC208B2}.XP32bit|x86.ActiveCfg = Debug|Any CPU - {B6A19B80-0F0F-434C-A754-A7712FC208B2}.XP32bit|x86.Build.0 = Debug|Any CPU {B5DA260C-71CC-45CA-B79E-D1B376AF718C}._MANUAL_CONTROL|Any CPU.ActiveCfg = Debug|Any CPU {B5DA260C-71CC-45CA-B79E-D1B376AF718C}._MANUAL_CONTROL|Any CPU.Build.0 = Debug|Any CPU {B5DA260C-71CC-45CA-B79E-D1B376AF718C}._MANUAL_CONTROL|Mixed Platforms.ActiveCfg = Debug|Any CPU @@ -5816,222 +5662,6 @@ Global {B5DA260C-71CC-45CA-B79E-D1B376AF718C}.XP32bit|x64.Build.0 = Debug|Any CPU {B5DA260C-71CC-45CA-B79E-D1B376AF718C}.XP32bit|x86.ActiveCfg = Debug|Any CPU {B5DA260C-71CC-45CA-B79E-D1B376AF718C}.XP32bit|x86.Build.0 = Debug|Any CPU - {BA17D20E-0CEB-4B27-9772-2392BD750ED5}._MANUAL_CONTROL|Any CPU.ActiveCfg = _MANUAL_CONTROL|Any CPU - {BA17D20E-0CEB-4B27-9772-2392BD750ED5}._MANUAL_CONTROL|Any CPU.Build.0 = _MANUAL_CONTROL|Any CPU - {BA17D20E-0CEB-4B27-9772-2392BD750ED5}._MANUAL_CONTROL|Mixed Platforms.ActiveCfg = _MANUAL_CONTROL|x64 - {BA17D20E-0CEB-4B27-9772-2392BD750ED5}._MANUAL_CONTROL|Mixed Platforms.Build.0 = _MANUAL_CONTROL|x64 - {BA17D20E-0CEB-4B27-9772-2392BD750ED5}._MANUAL_CONTROL|x64.ActiveCfg = _MANUAL_CONTROL|x64 - {BA17D20E-0CEB-4B27-9772-2392BD750ED5}._MANUAL_CONTROL|x64.Build.0 = _MANUAL_CONTROL|x64 - {BA17D20E-0CEB-4B27-9772-2392BD750ED5}._MANUAL_CONTROL|x86.ActiveCfg = _MANUAL_CONTROL|x86 - {BA17D20E-0CEB-4B27-9772-2392BD750ED5}._MANUAL_CONTROL|x86.Build.0 = _MANUAL_CONTROL|x86 - {BA17D20E-0CEB-4B27-9772-2392BD750ED5}.COM|Any CPU.ActiveCfg = COM|Any CPU - {BA17D20E-0CEB-4B27-9772-2392BD750ED5}.COM|Any CPU.Build.0 = COM|Any CPU - {BA17D20E-0CEB-4B27-9772-2392BD750ED5}.COM|Mixed Platforms.ActiveCfg = COM|x64 - {BA17D20E-0CEB-4B27-9772-2392BD750ED5}.COM|Mixed Platforms.Build.0 = COM|x64 - {BA17D20E-0CEB-4B27-9772-2392BD750ED5}.COM|x64.ActiveCfg = COM|x64 - {BA17D20E-0CEB-4B27-9772-2392BD750ED5}.COM|x64.Build.0 = COM|x64 - {BA17D20E-0CEB-4B27-9772-2392BD750ED5}.COM|x86.ActiveCfg = COM|x86 - {BA17D20E-0CEB-4B27-9772-2392BD750ED5}.COM|x86.Build.0 = COM|x86 - {BA17D20E-0CEB-4B27-9772-2392BD750ED5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {BA17D20E-0CEB-4B27-9772-2392BD750ED5}.Debug|Any CPU.Build.0 = Debug|Any CPU - {BA17D20E-0CEB-4B27-9772-2392BD750ED5}.Debug|Mixed Platforms.ActiveCfg = Debug|x64 - {BA17D20E-0CEB-4B27-9772-2392BD750ED5}.Debug|Mixed Platforms.Build.0 = Debug|x64 - {BA17D20E-0CEB-4B27-9772-2392BD750ED5}.Debug|x64.ActiveCfg = Debug|x64 - {BA17D20E-0CEB-4B27-9772-2392BD750ED5}.Debug|x64.Build.0 = Debug|x64 - {BA17D20E-0CEB-4B27-9772-2392BD750ED5}.Debug|x86.ActiveCfg = Debug|x86 - {BA17D20E-0CEB-4B27-9772-2392BD750ED5}.Debug|x86.Build.0 = Debug|x86 - {BA17D20E-0CEB-4B27-9772-2392BD750ED5}.Debug-local IIS-CUST|Any CPU.ActiveCfg = Debug|Any CPU - {BA17D20E-0CEB-4B27-9772-2392BD750ED5}.Debug-local IIS-CUST|Any CPU.Build.0 = Debug|Any CPU - {BA17D20E-0CEB-4B27-9772-2392BD750ED5}.Debug-local IIS-CUST|Mixed Platforms.ActiveCfg = Debug|x64 - {BA17D20E-0CEB-4B27-9772-2392BD750ED5}.Debug-local IIS-CUST|Mixed Platforms.Build.0 = Debug|x64 - {BA17D20E-0CEB-4B27-9772-2392BD750ED5}.Debug-local IIS-CUST|x64.ActiveCfg = Debug|x64 - {BA17D20E-0CEB-4B27-9772-2392BD750ED5}.Debug-local IIS-CUST|x64.Build.0 = Debug|x64 - {BA17D20E-0CEB-4B27-9772-2392BD750ED5}.Debug-local IIS-CUST|x86.ActiveCfg = Debug|x86 - {BA17D20E-0CEB-4B27-9772-2392BD750ED5}.Debug-local IIS-CUST|x86.Build.0 = Debug|x86 - {BA17D20E-0CEB-4B27-9772-2392BD750ED5}.PerformTest|Any CPU.ActiveCfg = PerformTest|Any CPU - {BA17D20E-0CEB-4B27-9772-2392BD750ED5}.PerformTest|Any CPU.Build.0 = PerformTest|Any CPU - {BA17D20E-0CEB-4B27-9772-2392BD750ED5}.PerformTest|Mixed Platforms.ActiveCfg = PerformTest|x64 - {BA17D20E-0CEB-4B27-9772-2392BD750ED5}.PerformTest|Mixed Platforms.Build.0 = PerformTest|x64 - {BA17D20E-0CEB-4B27-9772-2392BD750ED5}.PerformTest|x64.ActiveCfg = PerformTest|x64 - {BA17D20E-0CEB-4B27-9772-2392BD750ED5}.PerformTest|x64.Build.0 = PerformTest|x64 - {BA17D20E-0CEB-4B27-9772-2392BD750ED5}.PerformTest|x86.ActiveCfg = PerformTest|x86 - {BA17D20E-0CEB-4B27-9772-2392BD750ED5}.PerformTest|x86.Build.0 = PerformTest|x86 - {BA17D20E-0CEB-4B27-9772-2392BD750ED5}.Release|Any CPU.ActiveCfg = Release|Any CPU - {BA17D20E-0CEB-4B27-9772-2392BD750ED5}.Release|Any CPU.Build.0 = Release|Any CPU - {BA17D20E-0CEB-4B27-9772-2392BD750ED5}.Release|Mixed Platforms.ActiveCfg = Release|x64 - {BA17D20E-0CEB-4B27-9772-2392BD750ED5}.Release|Mixed Platforms.Build.0 = Release|x64 - {BA17D20E-0CEB-4B27-9772-2392BD750ED5}.Release|x64.ActiveCfg = Release|x64 - {BA17D20E-0CEB-4B27-9772-2392BD750ED5}.Release|x64.Build.0 = Release|x64 - {BA17D20E-0CEB-4B27-9772-2392BD750ED5}.Release|x86.ActiveCfg = Release|x86 - {BA17D20E-0CEB-4B27-9772-2392BD750ED5}.Release|x86.Build.0 = Release|x86 - {BA17D20E-0CEB-4B27-9772-2392BD750ED5}.ReleaseTest|Any CPU.ActiveCfg = Release|Any CPU - {BA17D20E-0CEB-4B27-9772-2392BD750ED5}.ReleaseTest|Any CPU.Build.0 = Release|Any CPU - {BA17D20E-0CEB-4B27-9772-2392BD750ED5}.ReleaseTest|Mixed Platforms.ActiveCfg = Release|x64 - {BA17D20E-0CEB-4B27-9772-2392BD750ED5}.ReleaseTest|Mixed Platforms.Build.0 = Release|x64 - {BA17D20E-0CEB-4B27-9772-2392BD750ED5}.ReleaseTest|x64.ActiveCfg = Release|x64 - {BA17D20E-0CEB-4B27-9772-2392BD750ED5}.ReleaseTest|x64.Build.0 = Release|x64 - {BA17D20E-0CEB-4B27-9772-2392BD750ED5}.ReleaseTest|x86.ActiveCfg = Release|x86 - {BA17D20E-0CEB-4B27-9772-2392BD750ED5}.ReleaseTest|x86.Build.0 = Release|x86 - {BA17D20E-0CEB-4B27-9772-2392BD750ED5}.VPN_Debug|Any CPU.ActiveCfg = VPN_Debug|Any CPU - {BA17D20E-0CEB-4B27-9772-2392BD750ED5}.VPN_Debug|Any CPU.Build.0 = VPN_Debug|Any CPU - {BA17D20E-0CEB-4B27-9772-2392BD750ED5}.VPN_Debug|Mixed Platforms.ActiveCfg = VPN_Debug|x64 - {BA17D20E-0CEB-4B27-9772-2392BD750ED5}.VPN_Debug|Mixed Platforms.Build.0 = VPN_Debug|x64 - {BA17D20E-0CEB-4B27-9772-2392BD750ED5}.VPN_Debug|x64.ActiveCfg = VPN_Debug|x64 - {BA17D20E-0CEB-4B27-9772-2392BD750ED5}.VPN_Debug|x64.Build.0 = VPN_Debug|x64 - {BA17D20E-0CEB-4B27-9772-2392BD750ED5}.VPN_Debug|x86.ActiveCfg = VPN_Debug|x86 - {BA17D20E-0CEB-4B27-9772-2392BD750ED5}.VPN_Debug|x86.Build.0 = VPN_Debug|x86 - {BA17D20E-0CEB-4B27-9772-2392BD750ED5}.XP32bit|Any CPU.ActiveCfg = XP32bit|Any CPU - {BA17D20E-0CEB-4B27-9772-2392BD750ED5}.XP32bit|Any CPU.Build.0 = XP32bit|Any CPU - {BA17D20E-0CEB-4B27-9772-2392BD750ED5}.XP32bit|Mixed Platforms.ActiveCfg = XP32bit|x64 - {BA17D20E-0CEB-4B27-9772-2392BD750ED5}.XP32bit|Mixed Platforms.Build.0 = XP32bit|x64 - {BA17D20E-0CEB-4B27-9772-2392BD750ED5}.XP32bit|x64.ActiveCfg = XP32bit|x64 - {BA17D20E-0CEB-4B27-9772-2392BD750ED5}.XP32bit|x64.Build.0 = XP32bit|x64 - {BA17D20E-0CEB-4B27-9772-2392BD750ED5}.XP32bit|x86.ActiveCfg = XP32bit|x86 - {BA17D20E-0CEB-4B27-9772-2392BD750ED5}.XP32bit|x86.Build.0 = XP32bit|x86 - {D6B81C60-2763-4C4D-989F-90822F53B01A}._MANUAL_CONTROL|Any CPU.ActiveCfg = Debug|Any CPU - {D6B81C60-2763-4C4D-989F-90822F53B01A}._MANUAL_CONTROL|Any CPU.Build.0 = Debug|Any CPU - {D6B81C60-2763-4C4D-989F-90822F53B01A}._MANUAL_CONTROL|Mixed Platforms.ActiveCfg = Debug|Any CPU - {D6B81C60-2763-4C4D-989F-90822F53B01A}._MANUAL_CONTROL|Mixed Platforms.Build.0 = Debug|Any CPU - {D6B81C60-2763-4C4D-989F-90822F53B01A}._MANUAL_CONTROL|x64.ActiveCfg = Debug|Any CPU - {D6B81C60-2763-4C4D-989F-90822F53B01A}._MANUAL_CONTROL|x64.Build.0 = Debug|Any CPU - {D6B81C60-2763-4C4D-989F-90822F53B01A}._MANUAL_CONTROL|x86.ActiveCfg = Debug|Any CPU - {D6B81C60-2763-4C4D-989F-90822F53B01A}._MANUAL_CONTROL|x86.Build.0 = Debug|Any CPU - {D6B81C60-2763-4C4D-989F-90822F53B01A}.COM|Any CPU.ActiveCfg = Debug|Any CPU - {D6B81C60-2763-4C4D-989F-90822F53B01A}.COM|Any CPU.Build.0 = Debug|Any CPU - {D6B81C60-2763-4C4D-989F-90822F53B01A}.COM|Mixed Platforms.ActiveCfg = Debug|Any CPU - {D6B81C60-2763-4C4D-989F-90822F53B01A}.COM|Mixed Platforms.Build.0 = Debug|Any CPU - {D6B81C60-2763-4C4D-989F-90822F53B01A}.COM|x64.ActiveCfg = Debug|Any CPU - {D6B81C60-2763-4C4D-989F-90822F53B01A}.COM|x64.Build.0 = Debug|Any CPU - {D6B81C60-2763-4C4D-989F-90822F53B01A}.COM|x86.ActiveCfg = Debug|Any CPU - {D6B81C60-2763-4C4D-989F-90822F53B01A}.COM|x86.Build.0 = Debug|Any CPU - {D6B81C60-2763-4C4D-989F-90822F53B01A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D6B81C60-2763-4C4D-989F-90822F53B01A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D6B81C60-2763-4C4D-989F-90822F53B01A}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {D6B81C60-2763-4C4D-989F-90822F53B01A}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {D6B81C60-2763-4C4D-989F-90822F53B01A}.Debug|x64.ActiveCfg = Debug|Any CPU - {D6B81C60-2763-4C4D-989F-90822F53B01A}.Debug|x64.Build.0 = Debug|Any CPU - {D6B81C60-2763-4C4D-989F-90822F53B01A}.Debug|x86.ActiveCfg = Debug|Any CPU - {D6B81C60-2763-4C4D-989F-90822F53B01A}.Debug|x86.Build.0 = Debug|Any CPU - {D6B81C60-2763-4C4D-989F-90822F53B01A}.Debug-local IIS-CUST|Any CPU.ActiveCfg = Debug|Any CPU - {D6B81C60-2763-4C4D-989F-90822F53B01A}.Debug-local IIS-CUST|Any CPU.Build.0 = Debug|Any CPU - {D6B81C60-2763-4C4D-989F-90822F53B01A}.Debug-local IIS-CUST|Mixed Platforms.ActiveCfg = Debug|Any CPU - {D6B81C60-2763-4C4D-989F-90822F53B01A}.Debug-local IIS-CUST|Mixed Platforms.Build.0 = Debug|Any CPU - {D6B81C60-2763-4C4D-989F-90822F53B01A}.Debug-local IIS-CUST|x64.ActiveCfg = Debug|Any CPU - {D6B81C60-2763-4C4D-989F-90822F53B01A}.Debug-local IIS-CUST|x64.Build.0 = Debug|Any CPU - {D6B81C60-2763-4C4D-989F-90822F53B01A}.Debug-local IIS-CUST|x86.ActiveCfg = Debug|Any CPU - {D6B81C60-2763-4C4D-989F-90822F53B01A}.Debug-local IIS-CUST|x86.Build.0 = Debug|Any CPU - {D6B81C60-2763-4C4D-989F-90822F53B01A}.PerformTest|Any CPU.ActiveCfg = Debug|Any CPU - {D6B81C60-2763-4C4D-989F-90822F53B01A}.PerformTest|Any CPU.Build.0 = Debug|Any CPU - {D6B81C60-2763-4C4D-989F-90822F53B01A}.PerformTest|Mixed Platforms.ActiveCfg = Debug|Any CPU - {D6B81C60-2763-4C4D-989F-90822F53B01A}.PerformTest|Mixed Platforms.Build.0 = Debug|Any CPU - {D6B81C60-2763-4C4D-989F-90822F53B01A}.PerformTest|x64.ActiveCfg = Debug|Any CPU - {D6B81C60-2763-4C4D-989F-90822F53B01A}.PerformTest|x64.Build.0 = Debug|Any CPU - {D6B81C60-2763-4C4D-989F-90822F53B01A}.PerformTest|x86.ActiveCfg = Debug|Any CPU - {D6B81C60-2763-4C4D-989F-90822F53B01A}.PerformTest|x86.Build.0 = Debug|Any CPU - {D6B81C60-2763-4C4D-989F-90822F53B01A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D6B81C60-2763-4C4D-989F-90822F53B01A}.Release|Any CPU.Build.0 = Release|Any CPU - {D6B81C60-2763-4C4D-989F-90822F53B01A}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {D6B81C60-2763-4C4D-989F-90822F53B01A}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {D6B81C60-2763-4C4D-989F-90822F53B01A}.Release|x64.ActiveCfg = Release|Any CPU - {D6B81C60-2763-4C4D-989F-90822F53B01A}.Release|x64.Build.0 = Release|Any CPU - {D6B81C60-2763-4C4D-989F-90822F53B01A}.Release|x86.ActiveCfg = Release|Any CPU - {D6B81C60-2763-4C4D-989F-90822F53B01A}.Release|x86.Build.0 = Release|Any CPU - {D6B81C60-2763-4C4D-989F-90822F53B01A}.ReleaseTest|Any CPU.ActiveCfg = Release|Any CPU - {D6B81C60-2763-4C4D-989F-90822F53B01A}.ReleaseTest|Any CPU.Build.0 = Release|Any CPU - {D6B81C60-2763-4C4D-989F-90822F53B01A}.ReleaseTest|Mixed Platforms.ActiveCfg = Release|Any CPU - {D6B81C60-2763-4C4D-989F-90822F53B01A}.ReleaseTest|Mixed Platforms.Build.0 = Release|Any CPU - {D6B81C60-2763-4C4D-989F-90822F53B01A}.ReleaseTest|x64.ActiveCfg = Release|Any CPU - {D6B81C60-2763-4C4D-989F-90822F53B01A}.ReleaseTest|x64.Build.0 = Release|Any CPU - {D6B81C60-2763-4C4D-989F-90822F53B01A}.ReleaseTest|x86.ActiveCfg = Release|Any CPU - {D6B81C60-2763-4C4D-989F-90822F53B01A}.ReleaseTest|x86.Build.0 = Release|Any CPU - {D6B81C60-2763-4C4D-989F-90822F53B01A}.VPN_Debug|Any CPU.ActiveCfg = VPN_Debug|Any CPU - {D6B81C60-2763-4C4D-989F-90822F53B01A}.VPN_Debug|Any CPU.Build.0 = VPN_Debug|Any CPU - {D6B81C60-2763-4C4D-989F-90822F53B01A}.VPN_Debug|Mixed Platforms.ActiveCfg = VPN_Debug|Any CPU - {D6B81C60-2763-4C4D-989F-90822F53B01A}.VPN_Debug|Mixed Platforms.Build.0 = VPN_Debug|Any CPU - {D6B81C60-2763-4C4D-989F-90822F53B01A}.VPN_Debug|x64.ActiveCfg = VPN_Debug|Any CPU - {D6B81C60-2763-4C4D-989F-90822F53B01A}.VPN_Debug|x64.Build.0 = VPN_Debug|Any CPU - {D6B81C60-2763-4C4D-989F-90822F53B01A}.VPN_Debug|x86.ActiveCfg = VPN_Debug|Any CPU - {D6B81C60-2763-4C4D-989F-90822F53B01A}.VPN_Debug|x86.Build.0 = VPN_Debug|Any CPU - {D6B81C60-2763-4C4D-989F-90822F53B01A}.XP32bit|Any CPU.ActiveCfg = Debug|Any CPU - {D6B81C60-2763-4C4D-989F-90822F53B01A}.XP32bit|Any CPU.Build.0 = Debug|Any CPU - {D6B81C60-2763-4C4D-989F-90822F53B01A}.XP32bit|Mixed Platforms.ActiveCfg = Debug|Any CPU - {D6B81C60-2763-4C4D-989F-90822F53B01A}.XP32bit|Mixed Platforms.Build.0 = Debug|Any CPU - {D6B81C60-2763-4C4D-989F-90822F53B01A}.XP32bit|x64.ActiveCfg = Debug|Any CPU - {D6B81C60-2763-4C4D-989F-90822F53B01A}.XP32bit|x64.Build.0 = Debug|Any CPU - {D6B81C60-2763-4C4D-989F-90822F53B01A}.XP32bit|x86.ActiveCfg = Debug|Any CPU - {D6B81C60-2763-4C4D-989F-90822F53B01A}.XP32bit|x86.Build.0 = Debug|Any CPU - {00748F11-4B49-4D8B-93C4-4A11A210CCE2}._MANUAL_CONTROL|Any CPU.ActiveCfg = Debug|Any CPU - {00748F11-4B49-4D8B-93C4-4A11A210CCE2}._MANUAL_CONTROL|Any CPU.Build.0 = Debug|Any CPU - {00748F11-4B49-4D8B-93C4-4A11A210CCE2}._MANUAL_CONTROL|Mixed Platforms.ActiveCfg = Debug|Any CPU - {00748F11-4B49-4D8B-93C4-4A11A210CCE2}._MANUAL_CONTROL|Mixed Platforms.Build.0 = Debug|Any CPU - {00748F11-4B49-4D8B-93C4-4A11A210CCE2}._MANUAL_CONTROL|x64.ActiveCfg = Debug|Any CPU - {00748F11-4B49-4D8B-93C4-4A11A210CCE2}._MANUAL_CONTROL|x64.Build.0 = Debug|Any CPU - {00748F11-4B49-4D8B-93C4-4A11A210CCE2}._MANUAL_CONTROL|x86.ActiveCfg = Debug|Any CPU - {00748F11-4B49-4D8B-93C4-4A11A210CCE2}._MANUAL_CONTROL|x86.Build.0 = Debug|Any CPU - {00748F11-4B49-4D8B-93C4-4A11A210CCE2}.COM|Any CPU.ActiveCfg = Debug|Any CPU - {00748F11-4B49-4D8B-93C4-4A11A210CCE2}.COM|Any CPU.Build.0 = Debug|Any CPU - {00748F11-4B49-4D8B-93C4-4A11A210CCE2}.COM|Mixed Platforms.ActiveCfg = Debug|Any CPU - {00748F11-4B49-4D8B-93C4-4A11A210CCE2}.COM|Mixed Platforms.Build.0 = Debug|Any CPU - {00748F11-4B49-4D8B-93C4-4A11A210CCE2}.COM|x64.ActiveCfg = Debug|Any CPU - {00748F11-4B49-4D8B-93C4-4A11A210CCE2}.COM|x64.Build.0 = Debug|Any CPU - {00748F11-4B49-4D8B-93C4-4A11A210CCE2}.COM|x86.ActiveCfg = Debug|Any CPU - {00748F11-4B49-4D8B-93C4-4A11A210CCE2}.COM|x86.Build.0 = Debug|Any CPU - {00748F11-4B49-4D8B-93C4-4A11A210CCE2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {00748F11-4B49-4D8B-93C4-4A11A210CCE2}.Debug|Any CPU.Build.0 = Debug|Any CPU - {00748F11-4B49-4D8B-93C4-4A11A210CCE2}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {00748F11-4B49-4D8B-93C4-4A11A210CCE2}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {00748F11-4B49-4D8B-93C4-4A11A210CCE2}.Debug|x64.ActiveCfg = Debug|Any CPU - {00748F11-4B49-4D8B-93C4-4A11A210CCE2}.Debug|x64.Build.0 = Debug|Any CPU - {00748F11-4B49-4D8B-93C4-4A11A210CCE2}.Debug|x86.ActiveCfg = Debug|Any CPU - {00748F11-4B49-4D8B-93C4-4A11A210CCE2}.Debug|x86.Build.0 = Debug|Any CPU - {00748F11-4B49-4D8B-93C4-4A11A210CCE2}.Debug-local IIS-CUST|Any CPU.ActiveCfg = Debug|Any CPU - {00748F11-4B49-4D8B-93C4-4A11A210CCE2}.Debug-local IIS-CUST|Any CPU.Build.0 = Debug|Any CPU - {00748F11-4B49-4D8B-93C4-4A11A210CCE2}.Debug-local IIS-CUST|Mixed Platforms.ActiveCfg = Debug|Any CPU - {00748F11-4B49-4D8B-93C4-4A11A210CCE2}.Debug-local IIS-CUST|Mixed Platforms.Build.0 = Debug|Any CPU - {00748F11-4B49-4D8B-93C4-4A11A210CCE2}.Debug-local IIS-CUST|x64.ActiveCfg = Debug|Any CPU - {00748F11-4B49-4D8B-93C4-4A11A210CCE2}.Debug-local IIS-CUST|x64.Build.0 = Debug|Any CPU - {00748F11-4B49-4D8B-93C4-4A11A210CCE2}.Debug-local IIS-CUST|x86.ActiveCfg = Debug|Any CPU - {00748F11-4B49-4D8B-93C4-4A11A210CCE2}.Debug-local IIS-CUST|x86.Build.0 = Debug|Any CPU - {00748F11-4B49-4D8B-93C4-4A11A210CCE2}.PerformTest|Any CPU.ActiveCfg = Debug|Any CPU - {00748F11-4B49-4D8B-93C4-4A11A210CCE2}.PerformTest|Any CPU.Build.0 = Debug|Any CPU - {00748F11-4B49-4D8B-93C4-4A11A210CCE2}.PerformTest|Mixed Platforms.ActiveCfg = Debug|Any CPU - {00748F11-4B49-4D8B-93C4-4A11A210CCE2}.PerformTest|Mixed Platforms.Build.0 = Debug|Any CPU - {00748F11-4B49-4D8B-93C4-4A11A210CCE2}.PerformTest|x64.ActiveCfg = Debug|Any CPU - {00748F11-4B49-4D8B-93C4-4A11A210CCE2}.PerformTest|x64.Build.0 = Debug|Any CPU - {00748F11-4B49-4D8B-93C4-4A11A210CCE2}.PerformTest|x86.ActiveCfg = Debug|Any CPU - {00748F11-4B49-4D8B-93C4-4A11A210CCE2}.PerformTest|x86.Build.0 = Debug|Any CPU - {00748F11-4B49-4D8B-93C4-4A11A210CCE2}.Release|Any CPU.ActiveCfg = Release|Any CPU - {00748F11-4B49-4D8B-93C4-4A11A210CCE2}.Release|Any CPU.Build.0 = Release|Any CPU - {00748F11-4B49-4D8B-93C4-4A11A210CCE2}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {00748F11-4B49-4D8B-93C4-4A11A210CCE2}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {00748F11-4B49-4D8B-93C4-4A11A210CCE2}.Release|x64.ActiveCfg = Release|Any CPU - {00748F11-4B49-4D8B-93C4-4A11A210CCE2}.Release|x64.Build.0 = Release|Any CPU - {00748F11-4B49-4D8B-93C4-4A11A210CCE2}.Release|x86.ActiveCfg = Release|Any CPU - {00748F11-4B49-4D8B-93C4-4A11A210CCE2}.Release|x86.Build.0 = Release|Any CPU - {00748F11-4B49-4D8B-93C4-4A11A210CCE2}.ReleaseTest|Any CPU.ActiveCfg = Release|Any CPU - {00748F11-4B49-4D8B-93C4-4A11A210CCE2}.ReleaseTest|Any CPU.Build.0 = Release|Any CPU - {00748F11-4B49-4D8B-93C4-4A11A210CCE2}.ReleaseTest|Mixed Platforms.ActiveCfg = Release|Any CPU - {00748F11-4B49-4D8B-93C4-4A11A210CCE2}.ReleaseTest|Mixed Platforms.Build.0 = Release|Any CPU - {00748F11-4B49-4D8B-93C4-4A11A210CCE2}.ReleaseTest|x64.ActiveCfg = Release|Any CPU - {00748F11-4B49-4D8B-93C4-4A11A210CCE2}.ReleaseTest|x64.Build.0 = Release|Any CPU - {00748F11-4B49-4D8B-93C4-4A11A210CCE2}.ReleaseTest|x86.ActiveCfg = Release|Any CPU - {00748F11-4B49-4D8B-93C4-4A11A210CCE2}.ReleaseTest|x86.Build.0 = Release|Any CPU - {00748F11-4B49-4D8B-93C4-4A11A210CCE2}.VPN_Debug|Any CPU.ActiveCfg = VPN_Debug|Any CPU - {00748F11-4B49-4D8B-93C4-4A11A210CCE2}.VPN_Debug|Any CPU.Build.0 = VPN_Debug|Any CPU - {00748F11-4B49-4D8B-93C4-4A11A210CCE2}.VPN_Debug|Mixed Platforms.ActiveCfg = VPN_Debug|Any CPU - {00748F11-4B49-4D8B-93C4-4A11A210CCE2}.VPN_Debug|Mixed Platforms.Build.0 = VPN_Debug|Any CPU - {00748F11-4B49-4D8B-93C4-4A11A210CCE2}.VPN_Debug|x64.ActiveCfg = VPN_Debug|Any CPU - {00748F11-4B49-4D8B-93C4-4A11A210CCE2}.VPN_Debug|x64.Build.0 = VPN_Debug|Any CPU - {00748F11-4B49-4D8B-93C4-4A11A210CCE2}.VPN_Debug|x86.ActiveCfg = VPN_Debug|Any CPU - {00748F11-4B49-4D8B-93C4-4A11A210CCE2}.VPN_Debug|x86.Build.0 = VPN_Debug|Any CPU - {00748F11-4B49-4D8B-93C4-4A11A210CCE2}.XP32bit|Any CPU.ActiveCfg = Debug|Any CPU - {00748F11-4B49-4D8B-93C4-4A11A210CCE2}.XP32bit|Any CPU.Build.0 = Debug|Any CPU - {00748F11-4B49-4D8B-93C4-4A11A210CCE2}.XP32bit|Mixed Platforms.ActiveCfg = Debug|Any CPU - {00748F11-4B49-4D8B-93C4-4A11A210CCE2}.XP32bit|Mixed Platforms.Build.0 = Debug|Any CPU - {00748F11-4B49-4D8B-93C4-4A11A210CCE2}.XP32bit|x64.ActiveCfg = Debug|Any CPU - {00748F11-4B49-4D8B-93C4-4A11A210CCE2}.XP32bit|x64.Build.0 = Debug|Any CPU - {00748F11-4B49-4D8B-93C4-4A11A210CCE2}.XP32bit|x86.ActiveCfg = Debug|Any CPU - {00748F11-4B49-4D8B-93C4-4A11A210CCE2}.XP32bit|x86.Build.0 = Debug|Any CPU {20F137FD-C25E-42B7-A68F-58C746475897}._MANUAL_CONTROL|Any CPU.ActiveCfg = _MANUAL_CONTROL|Any CPU {20F137FD-C25E-42B7-A68F-58C746475897}._MANUAL_CONTROL|Any CPU.Build.0 = _MANUAL_CONTROL|Any CPU {20F137FD-C25E-42B7-A68F-58C746475897}._MANUAL_CONTROL|Mixed Platforms.ActiveCfg = _MANUAL_CONTROL|x64 @@ -6214,12 +5844,7 @@ Global {62E5BA37-36AB-4F0A-BC12-554E7A1F1A39} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8} {60765BF4-6165-4F2F-8756-1C699826265D} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8} {A83696BF-D8A2-4809-8424-CFE172AED5B6} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8} - {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8} - {B6A19B80-0F0F-434C-A754-A7712FC208B2} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8} {B5DA260C-71CC-45CA-B79E-D1B376AF718C} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8} - {BA17D20E-0CEB-4B27-9772-2392BD750ED5} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8} - {D6B81C60-2763-4C4D-989F-90822F53B01A} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8} - {00748F11-4B49-4D8B-93C4-4A11A210CCE2} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8} {20F137FD-C25E-42B7-A68F-58C746475897} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8} {70398B99-B134-4BBD-968B-7399B70C3CE2} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8} EndGlobalSection diff --git a/TBF/Properties/AssemblyInfo.cs b/TBF/Properties/AssemblyInfo.cs index 3c0c127e6..177d870aa 100644 --- a/TBF/Properties/AssemblyInfo.cs +++ b/TBF/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // Build Number // Revision // -[assembly: AssemblyVersion("3.9.3069.1")] -[assembly: AssemblyFileVersion("3.9.3069.1")] +[assembly: AssemblyVersion("3.9.3079.1")] +[assembly: AssemblyFileVersion("3.9.3079.1")] diff --git a/TBF/Rig/BridgeComponents/GciBridge/GciBridge.cs b/TBF/Rig/BridgeComponents/GciBridge/GciBridge.cs index a6ddb8b52..92d619f15 100644 --- a/TBF/Rig/BridgeComponents/GciBridge/GciBridge.cs +++ b/TBF/Rig/BridgeComponents/GciBridge/GciBridge.cs @@ -307,14 +307,31 @@ namespace TBF.Rig.BridgeComponents.GciBridge public async Task InitSlotAsync( GciPublicModels.GciInitSlotRequest request) { - EnsureExternalInterface(); - + if (request == null) throw new ArgumentNullException(nameof(request)); if (request.SlotId <= 0) throw new ArgumentException("Invalid slot id."); + if (string.Equals(request.RequestPort?.Type, "SIMULATE", StringComparison.OrdinalIgnoreCase)) + { + log.InfoFormat("{0}: InitSlotAsync invoked. {1}, SIMULATE", Name, request); + await Task.Delay(500); + log.InfoFormat("{0}: InitSlotAsync SIMULATE finished.", Name); + + return new GciPublicModels.GciInitSlotResult() + { + SlotId = request.SlotId, + Success = true, + AlreadyExists = false, + Updated = false, + Message = "Simulated", + }; + } + + EnsureExternalInterface(); + var result = await gciExternalInterface.InitSlotAsync(request); log.InfoFormat("{0}: InitSlotAsync invoked. {1}, Result={2}", Name, request, result); @@ -337,14 +354,31 @@ namespace TBF.Rig.BridgeComponents.GciBridge public async Task UpdateSlotAsync( GciPublicModels.GciInitSlotRequest request) { - EnsureExternalInterface(); - + if (request == null) throw new ArgumentNullException(nameof(request)); if (request.SlotId <= 0) throw new ArgumentException("Invalid slot id."); + + if (string.Equals(request.RequestPort?.Type, "SIMULATE", StringComparison.OrdinalIgnoreCase)) + { + log.InfoFormat("{0}: UpdateSlotAsync invoked. {1}, SIMULATE", Name, request); + await Task.Delay(500); + log.InfoFormat("{0}: UpdateSlotAsync SIMULATE finished.", Name); + return new GciPublicModels.GciInitSlotResult() + { + SlotId = request.SlotId, + Success = true, + AlreadyExists = false, + Updated = true, + Message = "Simulated", + }; + } + + EnsureExternalInterface(); + var result = await gciExternalInterface.UpdateSlotAsync(request); log.InfoFormat("{0}: UpdateSlotAsync invoked. {1}, Result={2}", Name, request, result); diff --git a/TBF/Rig/RegisterReaders/GenesisRegReader/communication/OptoHeadTest.cs b/TBF/Rig/RegisterReaders/GenesisRegReader/communication/OptoHeadTest.cs index 976be3ead..8038124d5 100644 --- a/TBF/Rig/RegisterReaders/GenesisRegReader/communication/OptoHeadTest.cs +++ b/TBF/Rig/RegisterReaders/GenesisRegReader/communication/OptoHeadTest.cs @@ -4,6 +4,7 @@ using Common; using GenesisCordonelInterface.API; using log4net; using TBF.Rig.BridgeComponents.GciBridge; +using TBF.Rig.RegisterReaders.GenesisRegReader.communication.common; using TBF.Rig.RegisterReaders.GenesisRegReader.implementations; using TBF.Rig.TestMethods.iPerlCommunication.communication.C4.diagnosticLed; @@ -17,25 +18,83 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.communication private GenesisSmartReader genesisHead; //private SerialDriver serialDriver; + + - public void BuildConnection(GenesisSmartReader genesidHead) + public async Task BuildConnection(GenesisSmartReader genesidHead) { - //TODO BUMI make fix rebuild - PublicModels.GciInitSlotRequest request = new PublicModels.GciInitSlotRequest + await BuildConnectionAsync(genesidHead).ConfigureAwait(false); + } + public async Task BuildConnectionAsync(GenesisSmartReader genesidHead) + { + if (genesidHead == null) + throw new ArgumentNullException(nameof(genesidHead)); + + bool simulation = genesidHead.DebugLevel == DebugMode.Simulate; + + var request = new PublicModels.GciInitSlotRequest { SlotId = genesidHead.GetSlotNr, ConfigSource = PublicModels.GciConfigSource.InterfaceInputConfig, PasswordSource = PublicModels.GciPasswordSource.InterfaceInputPassword, - RequestPort = new PublicModels.GciPortConfig{ PortName = $"COM{genesidHead.RfidComPortNr}", Type = PublicModels.MapPortType("IRDA")}, - StreamingPort = new PublicModels.GciPortConfig{ PortName = $"COM{genesidHead.OptoComPortNr}", Type = string.Empty} + + RequestPort = new PublicModels.GciPortConfig + { + PortName = $"COM{genesidHead.RfidComPortNr}", + Type = simulation ? "SIMULATE" : PublicModels.MapPortType("IRDA") + }, + + StreamingPort = new PublicModels.GciPortConfig + { + PortName = $"COM{genesidHead.OptoComPortNr}", + Type = simulation ? "SIMULATE" : string.Empty + } }; - genesidHead?.CommInterfaceBridge.InitSlotAsync(request); - log.Debug("BuildConnection() - SlotNr: " + genesidHead.GetSlotNr + " initialized"); - genesidHead?.CommInterfaceBridge?.UpdateSlotAsync(request); - log.Debug("BuildConnection() - SlotNr: " + genesidHead.GetSlotNr + " updated!"); + + log.Debug($"BuildConnection() - SlotNr: {genesidHead.GetSlotNr} initializing... Request: {request}"); + + var bridge = genesidHead.CommInterfaceBridge; + if (bridge == null) + throw new InvalidOperationException("CommInterfaceBridge is null."); + + var initResult = await WithTimeout( + bridge.InitSlotAsync(request), + TimeSpan.FromSeconds(15), + "InitSlotAsync timeout"); + + log.Debug($"BuildConnection() - SlotNr: {genesidHead.GetSlotNr} initialized. Result: {initResult}"); + + if (initResult == null) + throw new InvalidOperationException("InitSlotAsync returned null."); + + var updateResult = await WithTimeout( + bridge.UpdateSlotAsync(request), + TimeSpan.FromSeconds(15), + "UpdateSlotAsync timeout"); + + log.Debug($"BuildConnection() - SlotNr: {genesidHead.GetSlotNr} updated! Result: {updateResult}"); + + if (updateResult == null) + throw new InvalidOperationException("UpdateSlotAsync returned null."); + slotDefined = true; } + private static async Task WithTimeout( + Task task, + TimeSpan timeout, + string timeoutMessage) + { + var timeoutTask = Task.Delay(timeout); + + var completedTask = await Task.WhenAny(task, timeoutTask); + + if (completedTask == timeoutTask) + throw new TimeoutException(timeoutMessage); + + return await task; + } + public OptoHeadTest(GenesisSmartReader genesisHead) { this.genesisHead = genesisHead; @@ -51,62 +110,20 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.communication // serialDriver = null; } + private bool isConnected = false; private bool slotDefined = false; public bool IsSlotDefined { get => slotDefined; } - - - public void DisposeSlot() - { - slotDefined = false; - } + public bool IsConnected { get => isConnected; } - public async Task ReadSerialNrAsync() + public void DisposeSlot() { slotDefined = false; isConnected = false; } + + public async Task ReadRequest_PCBAsync(GenesisSmartReader genesisHead) { try { - if (genesisHead == null) - return false; + log.Debug("ReadRequest_PCB called for iHead: " + genesisHead); - if (string.IsNullOrEmpty(genesisHead.CommInterface)) - return false; - - if (genesisHead.CommInterfaceBridge == null) - return false; - - if (!IsSlotDefined) - BuildConnection(genesisHead); - - GciBridge gciBridge = genesisHead.CommInterfaceBridge; - - gciBridge.GciBridgeCfg.EnableExternalAccess = true; - gciBridge.GciBridgeCfg.EnableGuiAccess = false; - gciBridge.Initialize(); - - RadioService headService = new RadioService(gciBridge); - - string pcbId = await headService.ReadRequest_PCBAsync(genesisHead); - - return !string.IsNullOrEmpty(pcbId); - } - catch (Exception ex) - { - log.Error($"ReadSerialNr(COM{genesisHead?.RfidComPortNr}) - Exception: {ex}"); - return false; - } - } - - public string ReadRequest_PCB() - { - // if (genesisHead.DebugLevel == DebugMode.Simulate) - // { - // log.Debug("ReadRequest_PCB() - Simulated response"); - // return "-OK Simulated response-"; - // } - - try - { - log.Debug("ReadRequest_PCB called for iHead: " + genesisHead.ToString()); if (genesisHead == null) return string.Empty; @@ -118,31 +135,60 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.communication if (!IsSlotDefined) { - BuildConnection(genesisHead); + await BuildConnectionAsync(genesisHead); + } + + if (genesisHead.DebugLevel == DebugMode.Simulate) + { + log.Debug("ReadRequest_PCB() - Simulated response"); + return "-OK Simulated PCB-"; } GciBridge gciBridge = genesisHead.CommInterfaceBridge; + log.Debug("ReadRequest_PCB() - GciBridge created"); gciBridge.GciBridgeCfg.EnableExternalAccess = true; gciBridge.GciBridgeCfg.EnableGuiAccess = false; + gciBridge.Initialize(); + log.Debug("ReadRequest_PCB() - GciBridge initialized"); - RadioService headService = new RadioService(gciBridge); - string serialNo = headService.ReadRequest_PCB(ref genesisHead); - log.Info( - $"PCB Number: {serialNo} on COM{genesisHead.RfidComPortNr} SlotNr: {genesisHead.GetSlotNr} serialDriver: {genesisHead?.CommInterfaceBridge}"); + + + ReadPcbResult pcbResult = await headService.ReadRequest_PCBAsync(genesisHead, isConnected); + + if (pcbResult == null) + { + log.Info( $"PCB Number NOT found on COM{genesisHead.RfidComPortNr} SlotNr: {genesisHead.GetSlotNr}"); + return string.Empty; + } + + isConnected = pcbResult.IsConnected; + + string serialNo = pcbResult.PcbId; + log.Info( $"PCB Number: {serialNo} on COM{genesisHead.RfidComPortNr} SlotNr: {genesisHead.GetSlotNr}"); + return serialNo; } catch (Exception ex) { - log.Error("ReadRequest_PCB() - Exception:" + ex.StackTrace); - return (ex.Message.ToString()); + log.Error("ReadRequest_PCBAsync() - Exception:", ex); + return ex.Message; } } + public string ReadRequest_PCB() + { + return Task.Run(() => ReadRequest_PCBAsync(genesisHead)) + .GetAwaiter() + .GetResult(); + } + + + /// /// Set Test mode /// @@ -150,19 +196,71 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.communication /// public bool SetTestMode() { - if (!IsSlotDefined) - { - BuildConnection(genesisHead); - } - - log.Debug("SetTestMode called for iHead: " + genesisHead.ToString()); - bool activityModeActive = SetActivityMode_Active(); - bool optActiveMode = SetOptTestMode(); - - log.Debug("SetTestMode result: optoMod-> " + optActiveMode + " meterModeActive ->" + activityModeActive); - return (optActiveMode && activityModeActive); + return Task.Run(SetTestMode_Async) + .GetAwaiter() + .GetResult(); } - + + + public async Task SetTestMode_Async() + { + try + { + log.Debug("ReadRequest_PCB called for iHead: " + genesisHead); + + if (genesisHead == null) + return false; + + if (string.IsNullOrEmpty(genesisHead.CommInterface)) + return false; + + if (genesisHead.CommInterfaceBridge == null) + return false; + + if (!IsSlotDefined) + { + await BuildConnectionAsync(genesisHead); + } + + if (genesisHead.DebugLevel == DebugMode.Simulate) + { + log.Debug("ReadRequest_PCB() - Simulated response"); + return true; + } + + GciBridge gciBridge = genesisHead.CommInterfaceBridge; + + log.Debug("ReadRequest_PCB() - GciBridge created"); + + gciBridge.GciBridgeCfg.EnableExternalAccess = true; + gciBridge.GciBridgeCfg.EnableGuiAccess = false; + gciBridge.Initialize(); + + log.Debug("ReadRequest_PCB() - GciBridge initialized"); + + RadioService headService = new RadioService(gciBridge); + + + var ledModeAsync = await headService.SetLedMode_Async(genesisHead,LedState.active, isConnected); + + if (!ledModeAsync) + { + log.Info( $"FAILED - SET LED MODE ACTIVE on COM{genesisHead.RfidComPortNr} SlotNr: {genesisHead.GetSlotNr}"); + return false; + } + + isConnected = true; + + + return ledModeAsync; + } + catch (Exception ex) + { + log.Error("ReadRequest_PCBAsync() - Exception:", ex); + return ex.Message; + } + } + /// /// Set Active mode /// @@ -170,16 +268,69 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.communication /// public bool SetActiveMode() { - if (!IsSlotDefined) + return Task.Run(SetActiveMode_Async) + .GetAwaiter() + .GetResult(); + } + + + public async Task SetActiveMode_Async() + { + try { - BuildConnection(genesisHead); - } + log.Debug("ReadRequest_PCB called for iHead: " + genesisHead); - log.Debug("SetActiveMode called for iHead: " + genesisHead.ToString()); - bool optActiveMode = SetOptActiveMode(genesisHead); - //bool activityModeIdle = SetActivityMode_Idle(); - - return optActiveMode; + if (genesisHead == null) + return false; + + if (string.IsNullOrEmpty(genesisHead.CommInterface)) + return false; + + if (genesisHead.CommInterfaceBridge == null) + return false; + + if (!IsSlotDefined) + { + await BuildConnectionAsync(genesisHead); + } + + if (genesisHead.DebugLevel == DebugMode.Simulate) + { + log.Debug("ReadRequest_PCB() - Simulated response"); + return true; + } + + GciBridge gciBridge = genesisHead.CommInterfaceBridge; + + log.Debug("ReadRequest_PCB() - GciBridge created"); + + gciBridge.GciBridgeCfg.EnableExternalAccess = true; + gciBridge.GciBridgeCfg.EnableGuiAccess = false; + gciBridge.Initialize(); + + log.Debug("ReadRequest_PCB() - GciBridge initialized"); + + RadioService headService = new RadioService(gciBridge); + + + var ledModeAsync = await headService.SetLedMode_Async(genesisHead,LedState.active, isConnected); + + if (!ledModeAsync) + { + log.Info( $"FAILED - SET LED MODE ACTIVE on COM{genesisHead.RfidComPortNr} SlotNr: {genesisHead.GetSlotNr}"); + return false; + } + + isConnected = true; + + + return ledModeAsync; + } + catch (Exception ex) + { + log.Error("ReadRequest_PCBAsync() - Exception:", ex); + return false; + } } /// @@ -242,7 +393,7 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.communication // if (genesisHead != null) // { // if(genesisHead.RfidComPortNr != 0 && !genesisHead?.CommInterfaceBridgeComponent?.GciExternalInterface?.IsConnected == false) - // BuildConnection(genesisHead); + // BuildConnection(genesisHead).ConfigureAwait(false).GetAwaiter().GetResult(); // // // RadioService headService = new RadioService(genesisHead?.CommInterfaceBridgeComponent); @@ -304,7 +455,7 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.communication // if (iHead != null) // { // if(genesisHead.RfidComPortNr != 0 && !genesisHead?.CommInterfaceBridgeComponent?.GciExternalInterface?.IsConnected == false) - // BuildConnection(genesisHead); + // BuildConnection(genesisHead).ConfigureAwait(false).GetAwaiter().GetResult(); // // RadioService headService = new RadioService(genesisHead?.CommInterfaceBridgeComponent); // return headService.SetOptActiveMode(iHead); @@ -324,26 +475,65 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.communication /// /// /// - private bool SetActivityMode_Active() + private async Task SetActivityMode_Active() { - // try - // { - // if (genesisHead != null) - // { - // if (genesisHead.RfidComPortNr != 0 && - // !genesisHead?.CommInterfaceBridgeComponent?.GciExternalInterface?.IsConnected == false) - // BuildConnection(genesisHead); - // - // log.Debug("SetActivityMode_Active called for iHead: " + genesisHead.ToString()); - // RadioService headService = new RadioService(genesisHead?.CommInterfaceBridgeComponent); - // return headService.SetActivityMode_Active(genesisHead); - // } - // } - // catch (Exception ex) - // { - // log.Error("SetActivityMode_Active() - Exception:" + ex.StackTrace); - // } + try + { + log.Debug("ReadRequest_PCB called for iHead: " + genesisHead); + + if (genesisHead == null) + return false; + + if (string.IsNullOrEmpty(genesisHead.CommInterface)) + return false; + + if (genesisHead.CommInterfaceBridge == null) + return false; + + if (!IsSlotDefined) + { + await BuildConnectionAsync(genesisHead); + } + + if (genesisHead.DebugLevel == DebugMode.Simulate) + { + log.Debug("ReadRequest_PCB() - Simulated response"); + return true; + } + + GciBridge gciBridge = genesisHead.CommInterfaceBridge; + + log.Debug("ReadRequest_PCB() - GciBridge created"); + + gciBridge.GciBridgeCfg.EnableExternalAccess = true; + gciBridge.GciBridgeCfg.EnableGuiAccess = false; + + gciBridge.Initialize(); + + log.Debug("ReadRequest_PCB() - GciBridge initialized"); + + RadioService headService = new RadioService(gciBridge); + ReadPcbResult pcbResult = await headService.SetActivityMode_Active(genesisHead, isConnected); + + if (pcbResult == null) + { + log.Info( $"PCB Number NOT found on COM{genesisHead.RfidComPortNr} SlotNr: {genesisHead.GetSlotNr}"); + return false; + } + + isConnected = pcbResult.IsConnected; + + string serialNo = pcbResult.PcbId; + log.Info( $"PCB Number: {serialNo} on COM{genesisHead.RfidComPortNr} SlotNr: {genesisHead.GetSlotNr}"); + + return true; + } + catch (Exception ex) + { + log.Error("ReadRequest_PCBAsync() - Exception:", ex); + return false; + } return false; } @@ -362,7 +552,7 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.communication // { // if (genesisHead.RfidComPortNr != 0 && // !genesisHead?.CommInterfaceBridgeComponent?.GciExternalInterface?.IsConnected == false) - // BuildConnection(genesisHead); + // BuildConnection(genesisHead).ConfigureAwait(false).GetAwaiter().GetResult(); // // log.Debug("SetActivityMode_Idle called for iHead: " + genesisHead.ToString()); // @@ -407,7 +597,7 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.communication // // if (genesisHead.RfidComPortNr != 0 && // !genesisHead?.CommInterfaceBridgeComponent?.GciExternalInterface?.IsConnected == false) - // BuildConnection(genesisHead); + // BuildConnection(genesisHead).ConfigureAwait(false).GetAwaiter().GetResult(); // // RadioService headService = new RadioService(genesisHead?.CommInterfaceBridgeComponent); // genesisHead.ConfigStruct.PCBNumberString = headService.ReadRequest_PCB(ref genesisHead); @@ -416,7 +606,7 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.communication // // if (ledState != DiagnosticLedState.StatusUnknown) // do set // { - // genesisHead.ConfigStruct.OpthoStatusMode = headService.SetOptoStatusMode(genesisHead, ledState); + // genesisHead.ConfigStruct.OpthoStatusMode = headService.SetLedMode_Async(genesisHead, ledState); // } // else // { diff --git a/TBF/Rig/RegisterReaders/GenesisRegReader/communication/RadioService.cs b/TBF/Rig/RegisterReaders/GenesisRegReader/communication/RadioService.cs index 2ca6f3693..d5e5d26fa 100644 --- a/TBF/Rig/RegisterReaders/GenesisRegReader/communication/RadioService.cs +++ b/TBF/Rig/RegisterReaders/GenesisRegReader/communication/RadioService.cs @@ -4,20 +4,37 @@ using System.Threading.Tasks; using GenesisCordonelInterface.API; using log4net; using TBF.Rig.BridgeComponents.GciBridge; +using TBF.Rig.RegisterReaders.GenesisRegReader.common; +using TBF.Rig.RegisterReaders.GenesisRegReader.communication.common; using TBF.Rig.RegisterReaders.GenesisRegReader.implementations; using TBF.Rig.TestMethods.iPerlCommunication.communication.C4.diagnosticLed; using TBF.Rig.TestMethods.iPerlCommunication.communication.C4.protocolCommons; +using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore; +using PublicModels = TBF.Rig.BridgeComponents.GciBridge.Interfaces.PublicModels; namespace TBF.Rig.RegisterReaders.GenesisRegReader.communication { + public class ReadPcbResult + { + public bool IsConnected { get; set; } + + public bool IsValidPcb { get; set; } + + public string PcbId { get; set; } + + public string Message { get; set; } + } + public class RadioService { private static readonly ILog log = LogManager.GetLogger(typeof(RadioService)); static string okResponse = "Command complete, no errors"; static string errorResponse = "Unable to execute"; - + + private bool bConnected = false; + private GciBridge _bridge; public RadioService(GciBridge genesisHeadCommInterfaceBridgeComponent) @@ -25,259 +42,397 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.communication this._bridge = genesisHeadCommInterfaceBridgeComponent; log.Debug("RadioService created with GciBridge= " + genesisHeadCommInterfaceBridgeComponent + ""); } - - public async Task ReadRequest_PCBAsyn1(GenesisSmartReader iHead) + + private async Task EnsureConnectedAsync( + GenesisSmartReader head, + bool isConnected, + CancellationToken token = default) { - if (iHead?.CommInterfaceBridge == null) - return null; - - var connectTask = iHead.CommInterfaceBridge.ConnectAsync(iHead.GetSlotNr); - - // Wait either for ConnectAsync or timeout - if (await Task.WhenAny(connectTask, Task.Delay(TimeSpan.FromMinutes(1))) != connectTask) + if (head?.CommInterfaceBridge == null) { - // Timed out - return null; + return new ReadPcbResult + { + IsConnected = false, + IsValidPcb = false, + Message = "CommInterfaceBridge is null." + }; + } + + if (isConnected) + { + return new ReadPcbResult + { + IsConnected = true, + IsValidPcb = false, + Message = "Already connected." + }; + } + + log.Debug("Connecting..."); + + var connectTask = head.CommInterfaceBridge.ConnectAsync(head.GetSlotNr, token); + var timeoutTask = Task.Delay(TimeSpan.FromMinutes(1), token); + + var completedTask = await Task.WhenAny(connectTask, timeoutTask); + + if (completedTask != connectTask) + { + return new ReadPcbResult + { + IsConnected = false, + IsValidPcb = false, + Message = "Connect timeout." + }; } var result = await connectTask; - if (result == null || !result.Success || !result.IsLoggedOn) - return null; - - string pcbId = result.PcbId; - - if (!string.IsNullOrEmpty(pcbId)) + if (result == null )//|| !result.Success) { - if (iHead.ConfigStruct != null) - iHead.ConfigStruct.PCBNumberString = pcbId; - - return pcbId; + return new ReadPcbResult + { + IsConnected = false, + IsValidPcb = false, + Message = result == null ? "Connect result is null." : "Connect failed." + }; } - return null; + return new ReadPcbResult + { + IsConnected = true, + IsValidPcb = false, + Message = "Connected OK." + }; + } + + + public async Task FindKeyStone( + string txtPCBId, + CancellationToken token = default) + { + string pcbId = txtPCBId?.Trim(); + + if (string.IsNullOrWhiteSpace(pcbId)) + throw new Exception("PCB ID is empty."); + + token.ThrowIfCancellationRequested(); + + PublicModels.UdsPasswordResult result = await _bridge.GetPasswordAsync(pcbId, token); + + log.Debug("GetPasswordAsync PCB=" + pcbId + " Result: " + result); + + return result; + } + + public async Task LoginByPasswordAsync( + int slotId, string txtPassword, + CancellationToken token = default) + { + if (string.IsNullOrWhiteSpace(txtPassword)) + throw new Exception("PASSWORD is empty."); + + token.ThrowIfCancellationRequested(); + + GenesisCordonelInterface.API.PublicModels.GciLoginResult result = await _bridge.LoginAsync(slotId, token); + + log.Debug($"LoginByPasswordAsync( Slot: {slotId}) Result: " + result); + + return result; } - public async Task ReadRequest_PCBAsync(GenesisSmartReader iHead) + public async Task ReadRequest_PCBAsync( GenesisSmartReader head, bool isConnected) { - log.Debug("ReadRequest_PCB called for iHead: " + iHead); - - if (iHead?.CommInterfaceBridge == null) - return null; - - using var cts = new CancellationTokenSource(TimeSpan.FromMinutes(1)); - - PublicModels.GciConnectResult result; - - try - { - log.Debug("ReadRequest_PCB() - calling ConnectAsync"); - - result = await iHead.CommInterfaceBridge - .ConnectAsync(iHead.GetSlotNr, cts.Token) - .ConfigureAwait(false); - - log.Debug("ReadRequest_PCB() - ConnectAsync completed"); - } - catch (OperationCanceledException) - { - log.Debug("ReadRequest_PCB() - ConnectAsync timeout/cancelled"); - return null; - } - catch (Exception ex) - { - log.Error("ReadRequest_PCB() - ConnectAsync failed", ex); - return null; - } - - if (result == null || !result.Success || !result.IsLoggedOn) - { - log.Debug("ReadRequest_PCB() - invalid result: " + result); - return null; - } - - string pcbId = result.PcbId; - - if (string.IsNullOrEmpty(pcbId)) - { - log.Debug("ReadRequest_PCB() - pcbId is empty"); - return null; - } - - if (iHead.ConfigStruct != null) - { - iHead.ConfigStruct.PCBNumberString = pcbId; - log.Debug("ReadRequest_PCB() - PCBNumberString: " + pcbId); - } - - return pcbId; - } - - public string ReadRequest_PCB(ref GenesisSmartReader iHead) - { - var head = iHead; // <-- copy to local (no longer ref) - log.Debug("ReadRequest_PCB called for iHead: " + head); if (head?.CommInterfaceBridge == null) - return null; + { + return new ReadPcbResult + { + IsConnected = false, + IsValidPcb = false, + Message = "CommInterfaceBridge is null." + }; + } try { - var connectTask = Task.Run(async () => - await head.CommInterfaceBridge.ConnectAsync(head.GetSlotNr) - ); + // CONNECT ONLY IF NEEDED + var connectResult = + await EnsureConnectedAsync(head, isConnected); - var completedTask = Task.WhenAny( - connectTask, - Task.Delay(TimeSpan.FromMinutes(1)) - ).GetAwaiter().GetResult(); - - if (completedTask != connectTask) + if (!connectResult.IsConnected) { - log.Debug("ReadRequest_PCB() - Timeout happened"); - return null; + return connectResult; } - var result = connectTask.GetAwaiter().GetResult(); - log.Debug("ReadRequest_PCB() - Result: " + result); + isConnected = true; - if (result == null || !result.Success || !result.IsLoggedOn) - return null; + log.Debug($"ReadRequest_PCB() connect - {connectResult.Message}"); + - var pcbId = result.PcbId; - log.Debug("Result pcbId: " + pcbId); + // PCB READ LOOP + string validPcbId = null; + int maxAttempts = 5; + DateTime startTime = DateTime.UtcNow; + TimeSpan maxDuration = TimeSpan.FromSeconds(10); - if (!string.IsNullOrEmpty(pcbId) && head.ConfigStruct != null) + //LOOP + for (int attempt = 1; attempt <= maxAttempts; attempt++) { - head.ConfigStruct.PCBNumberString = pcbId; - log.Debug("Result set to ConfigStruct.PCBNumberString = " + head.ConfigStruct.PCBNumberString); + if (DateTime.UtcNow - startTime > maxDuration) + { + log.Debug("ReadRequest_PCB() - PCB max duration exceeded"); + break; + } + + log.Debug($"ReadRequest_PCB() - PCB attempt {attempt}/{maxAttempts}"); + var pcbTask = head.CommInterfaceBridge.GetPcbIdAsync(head.GetSlotNr); + var timeoutTaskPcb = Task.Delay(TimeSpan.FromSeconds(5)); + var completedTaskPcb = await Task.WhenAny(pcbTask, timeoutTaskPcb); + + if (completedTaskPcb != pcbTask) + { + log.Debug($"ReadRequest_PCB() PCB attempt {attempt} - Timeout"); + continue; + } + + var resultPCB = await pcbTask; + + // VALIDATION BLOCK + { + if (resultPCB == null) + { + log.Debug($"ReadRequest_PCB() PCB attempt {attempt} - result is null"); + continue; + } + + if (!resultPCB.Success) + { + log.Debug($"ReadRequest_PCB() PCB attempt {attempt} - Success=false"); + continue; + } + + string pcbId = resultPCB.PcbId; + + if (string.IsNullOrWhiteSpace(pcbId)) + { + log.Debug($"ReadRequest_PCB() PCB attempt {attempt} - PCB empty"); + continue; + } + + pcbId = pcbId.Trim(); + + if (pcbId.Length != 9) + { + log.Debug( $"ReadRequest_PCB() PCB attempt {attempt} - Invalid PCB length: '{pcbId}', len={pcbId.Length}"); + continue; + } + + validPcbId = pcbId; + log.Debug($"ReadRequest_PCB() PCB valid: {validPcbId}"); + break; + } } - return pcbId; + if (string.IsNullOrEmpty(validPcbId)) + { + return new ReadPcbResult + { + IsConnected = isConnected, + IsValidPcb = false, + PcbId = null, + Message = "Valid PCB not found." + }; + } + + if (head.ConfigStruct != null) + { + head.ConfigStruct.PCBNumberString = validPcbId; + } + + return new ReadPcbResult + { + IsConnected = isConnected, + IsValidPcb = true, + PcbId = validPcbId, + Message = "PCB OK" + }; } catch (Exception ex) { - log.Error("ReadRequest_PCB() failed", ex); - return null; - } - } + log.Error("ReadRequest_PCBAsync() failed", ex); - public string ReadRequest_PCB2(ref GenesisSmartReader iHead) - { - return ReadRequest_PCBAsync(iHead).GetAwaiter().GetResult(); - } - - public string ReadRequest_PCB1(ref GenesisSmartReader iHead) - { - log.Debug("ReadRequest_PCB called for iHead: " + iHead.ToString()); - if (iHead?.CommInterfaceBridge == null) - return null; - - // -- connection -- - var connectTask = iHead.CommInterfaceBridge.ConnectAsync(iHead.GetSlotNr); - log.Debug("ReadRequest_PCB() - ConnectAsync created, Now waiting for result"); - - var completedTask = Task.WhenAny( - connectTask, - Task.Delay(TimeSpan.FromMinutes(1)) - ).GetAwaiter().GetResult(); - - log.Debug("ReadRequest_PCB() - CompletedTask: " + completedTask); - - // Timeout happened - if (completedTask != connectTask) - { - log.Debug("ReadRequest_PCB() - Timeout happened"); - return null; - } - - var result = connectTask.GetAwaiter().GetResult(); - log.Debug("ReadRequest_PCB() - ConnectAsync completed"); - - if (result == null || !result.Success || !result.IsLoggedOn) - return null; - log.Debug("ReadRequest_PCB() - result: " + result); - //~ -- connection -- - - string pcbId = result.PcbId; - log.Debug("ReadRequest_PCB() - pcbId: " + pcbId); - - if (!string.IsNullOrEmpty(pcbId)) - { - if (iHead.ConfigStruct != null) + return new ReadPcbResult { - iHead.ConfigStruct.PCBNumberString = pcbId; - log.Debug("ReadRequest_PCB() - iHead.ConfigStruct.PCBNumberString: " + - iHead.ConfigStruct.PCBNumberString); + IsConnected = isConnected, + IsValidPcb = false, + PcbId = null, + Message = ex.Message + }; + } + } + + public async Task PrepareLoginAdnConnect_Async( + GenesisSmartReader iHead, + bool isConnected, + CancellationToken token = default) + { + log.Debug("PrepareLoginAdnConnect_Async called for iHead: " + iHead + " isConnected: " + isConnected); + + if (iHead?.CommInterfaceBridge == null) + return false; + + try + { + token.ThrowIfCancellationRequested(); + + // GET SLOT - CHECK CONNECTION, LOGGING + //TODO BUMI doplnit !!!!!!!!!!!!! + + var connectResult = await EnsureConnectedAsync(iHead, isConnected, token); + + if (!connectResult.IsConnected) + return false; + + //isConnected = connectResult.IsConnected; + + log.Debug($"GetActivityStatusMode() connect - {connectResult.Message}"); + + + //get stored PCB - Keystone + string pcb = iHead.ConfigStruct?.PCBNumberString; + + if (string.IsNullOrWhiteSpace(pcb)) + return false; + + log.Debug( $"GetActivityStatusMode() Start Find Keystone Slot: {iHead.GetSlotNr} PCB:{iHead.SerialNr} Calib PCB:{pcb} - find keystone"); + + var keyStoneResult = await FindKeyStone(pcb, token); + + if (keyStoneResult == null || !keyStoneResult.Success) + return false; + + //LOGIN + + log.Debug( $"GetActivityStatusMode() Start Login Slot: {iHead.GetSlotNr} PCB:{iHead.SerialNr} Calib PCB:{pcb} - login"); + GenesisCordonelInterface.API.PublicModels.GciLoginResult loginByPasswordAsync = + await LoginByPasswordAsync(iHead.GetSlotNr, keyStoneResult.Password, token); + + if (loginByPasswordAsync == null || !loginByPasswordAsync.Success) + { + return false; } - return pcbId; + log.Debug($"GetActivityStatusMode() Login OK"); + return true; + } + catch (OperationCanceledException) + { + log.Debug("GetActivityStatusMode() canceled."); + return false; } - - log.Debug("ReadRequest_PCB() - pcbId is empty"); - return null; } - public ProtocolStatuses GetActivityStatusMode(GenesisSmartReader iHead) + public static readonly String LedMode = "GENESISFLOW_LedMode"; + + public async Task GetActivityLedStatusMode_Async( + GenesisSmartReader iHead, + bool isConnected, + CancellationToken token = default) { + log.Debug("GetActivityLedStatusMode_Async called for iHead: " + iHead + " isConnected: " + isConnected); + if (iHead?.CommInterfaceBridge == null) - return ProtocolStatuses.Unknown; + return LedState.Unknown; - var connectResult = iHead.CommInterfaceBridge - .ConnectAsync(iHead.GetSlotNr) - .GetAwaiter() - .GetResult(); - - if (connectResult == null || !connectResult.Success || !connectResult.IsLoggedOn) - return ProtocolStatuses.Unknown; - - var pcbResult = iHead.CommInterfaceBridge - .GetPcbIdAsync(iHead.GetSlotNr) - .GetAwaiter() - .GetResult(); - - if (pcbResult == null || !pcbResult.Success || string.IsNullOrWhiteSpace(pcbResult.PcbId)) - return ProtocolStatuses.Unknown; - - if (iHead.ConfigStruct != null) + try { - iHead.ConfigStruct.PCBNumberString = pcbResult.PcbId; - } + var loginAdnConnectAsync = await PrepareLoginAdnConnect_Async(iHead, isConnected, token); + + if (!loginAdnConnectAsync) + return LedState.Unknown; - return ProtocolStatuses.Active; + //Get Activity Status + + GenesisCordonelInterface.API.PublicModels.RegisterReadResult registerReadResult = + await _bridge.ReadRegisterAsync(iHead.GetSlotNr,LedMode, token); + + if (registerReadResult == null || !registerReadResult.Success) + { + return LedState.Unknown; + } + log.Debug($"GetActivityStatusMode() Read Register OK Response: {registerReadResult}"); + try + { + byte[] bytes = HexFormatter.HexStringToByteArray(registerReadResult.RawHex); + //Convert byte array to int + if (bytes == null || bytes.Length < 4) + { + log.Debug("Invalid byte array length"); + return LedState.Unknown; + } + + int value = BitConverter.ToInt32(bytes, 0); + + // continue your real status logic here... + return value == 6 ? LedState.active : LedState.inactive; + }catch(Exception ex) + { + log.Error("GetActivityStatusMode() failed", ex); + return LedState.Unknown; + } + } + catch (OperationCanceledException) + { + log.Debug("GetActivityLedStatusMode_Async() canceled."); + return LedState.Unknown; + } + catch (Exception ex) + { + log.Error("GetActivityLedStatusMode_Async() failed", ex); + return LedState.Unknown; + } } - public DiagnosticLedState SetOptoStatusMode(GenesisSmartReader iHead, DiagnosticLedState opthoStatusMode) + public async Task SetLedMode_Async(GenesisSmartReader iHead, LedState ledMode, bool isConnected, + CancellationToken token = default) { + log.Debug("SetLedMode_Async called for iHead: " + iHead + " isConnected: " + isConnected); + + log.Debug("GetActivityLedStatusMode_Async called for iHead: " + iHead + " isConnected: " + isConnected); + if (iHead?.CommInterfaceBridge == null) - return DiagnosticLedState.StatusUnknown; + return false; - var connectResult = iHead.CommInterfaceBridge - .ConnectAsync(iHead.GetSlotNr) - .GetAwaiter() - .GetResult(); - - if (connectResult == null || !connectResult.Success || !connectResult.IsLoggedOn) - return DiagnosticLedState.StatusUnknown; - - //SetDiagnosticLEDState - - var pcbResult = iHead.CommInterfaceBridge - .GetPcbIdAsync(iHead.GetSlotNr) - .GetAwaiter() - .GetResult(); - - if (pcbResult == null || !pcbResult.Success || string.IsNullOrWhiteSpace(pcbResult.PcbId)) - return DiagnosticLedState.StatusUnknown; - - if (iHead.ConfigStruct != null) + try { - iHead.ConfigStruct.PCBNumberString = pcbResult.PcbId; + var loginAdnConnectAsync = await PrepareLoginAdnConnect_Async(iHead, isConnected, token); + + if (!loginAdnConnectAsync) + return false; + + //Get Activity Status + byte valueLed = (ledMode == LedState.active) ? (byte)6 : (byte)0; + + var registerWriteResult = await _bridge.WriteRegisterAsync(iHead.GetSlotNr,LedMode, valueLed, false, false, token); + + if (registerWriteResult == null || !registerWriteResult.Success) + { + return false; + } + log.Debug($"GetActivityStatusMode() Read Register OK Response: {registerWriteResult}"); + return true; + } + catch (OperationCanceledException) + { + log.Debug("GetActivityLedStatusMode_Async() canceled."); + return false; + } + catch (Exception ex) + { + log.Error("GetActivityLedStatusMode_Async() failed", ex); + return false; } - - - return DiagnosticLedState.StatusUnknown; } @@ -316,18 +471,26 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.communication } - public bool SetActivityMode_Active(GenesisSmartReader iHead) + public async Task SetActivityMode_Active(GenesisSmartReader iHead, + bool isConnected, CancellationToken token = default) { + log.Debug("SetActivityMode_Active called for iHead: " + iHead + " isConnected: " + isConnected); + if (iHead?.CommInterfaceBridge == null) return false; - var connectResult = iHead.CommInterfaceBridge - .ConnectAsync(iHead.GetSlotNr) - .GetAwaiter() - .GetResult(); + try + { + token.ThrowIfCancellationRequested(); - if (connectResult == null || !connectResult.Success || !connectResult.IsLoggedOn) - return false; + var connectResult = await EnsureConnectedAsync(iHead, isConnected,token); + + if (!connectResult.IsConnected) + return false; + + isConnected = connectResult.IsConnected; + + log.Debug($"GetActivityStatusMode() connect - {connectResult.Message}"); //Set LED to state 4 // string version = _bridge?.GciExternalInterface?.GetPcbId(iHead.GetSlotNr); diff --git a/TBF/Rig/RegisterReaders/GenesisRegReader/communication/common/LedState.cs b/TBF/Rig/RegisterReaders/GenesisRegReader/communication/common/LedState.cs new file mode 100644 index 000000000..7589f6a89 --- /dev/null +++ b/TBF/Rig/RegisterReaders/GenesisRegReader/communication/common/LedState.cs @@ -0,0 +1,9 @@ +namespace TBF.Rig.RegisterReaders.GenesisRegReader.communication.common +{ + public enum LedState : int + { + Unknown = -1, + inactive = 0, + active = 1, + } +} \ No newline at end of file diff --git a/TBF/TBF.csproj b/TBF/TBF.csproj index 5e713a976..624951d28 100644 --- a/TBF/TBF.csproj +++ b/TBF/TBF.csproj @@ -1430,137 +1430,138 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + UserControl GenesisHeadTestCtrl.cs - + UserControl GenesisCfgCtrl.cs - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + UserControl - - + + UserControl - - - + + + UserControl @@ -1573,15 +1574,15 @@ IperlUniHeadTestCtrl.cs - - - - - - - - - + + + + + + + + + UserControl @@ -1600,67 +1601,67 @@ CycleBeginningForm.cs - + UserControl EntryFormCfgCtrl.cs - - + + Form TestStartEndForm.cs - - - - - - - + + + + + + + UserControl RRCfgCtrl.cs - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + UserControl @@ -1679,68 +1680,68 @@ PoseidonHeadTestCtrl.cs - - - - - + + + + + UserControl RRCfgCtrl.cs - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + UserControl RRCfgCtrl.cs - - - - - - - - - + + + + + + + + + Component - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + Form @@ -1759,38 +1760,38 @@ WMErrorsForm48.cs - - - - - - - - - - - + + + + + + + + + + + UserControl TestMethodCfgCtrl.cs - - - - - - - - + + + + + + + + UserControl TestMethodCfgCtrl.cs - + Form @@ -1800,491 +1801,491 @@ Component - - - - - - - - - - - - + + + + + + + + + + + + UserControl TestMethodCfgCtrl.cs - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + UserControl TestMethodCfgCtrl.cs - - - - - + + + + + UserControl TestMethodCfgCtrl.cs - - - - - - - + + + + + + + UserControl TestMethodCfgCtrl.cs - + Component - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Form - - - - - - - - - - - - - + + + + + + + + + + + + + UserControl - + UserControl - - - - - - - - - - - + + + + + + + + + + + UserControl - - - + + + Component - - - - - + + + + + Form S640CommForm.cs - - - - - - - - + + + + + + + + UserControl TestMethodCfgCtrl.cs - - - - + + + + UserControl TestMethodCfgCtrl.cs - - - - - - - - - + + + + + + + + + UserControl TestMethodCfgCtrl.cs - - - - - - - - - + + + + + + + + + UserControl TestMethodCfgCtrl.cs - - - - - - - - - + + + + + + + + + UserControl TestMethodCfgCtrl.cs - - - - - - + + + + + + UserControl TestMethodCfgCtrl.cs - - - - - + + + + + UserControl TestMethodCfgCtrl.cs - - - - - - - + + + + + + + UserControl TestMethodCfgCtrl.cs - - - - - - - - - + + + + + + + + + UserControl TestMethodCfgCtrl.cs - - - - - + + + + + UserControl TestMethodCfgCtrl.cs - - - - + + + + UserControl TestMethodCfgCtrl.cs - - - - - + + + + + UserControl TestMethodCfgCtrl.cs - - - - + + + + UserControl TestMethodCfgCtrl.cs - - - - + + + + UserControl TestMethodCfgCtrl.cs - - - - - + + + + + UserControl TestMethodCfgCtrl.cs - - - - + + + + UserControl TestMethodCfgCtrl.cs - - - - - + + + + + UserControl TestMethodCfgCtrl.cs - - - - - + + + + + UserControl TestMethodCfgCtrl.cs - - - - + + + + UserControl TestMethodCfgCtrl.cs - - - - - + + + + + UserControl TestMethodCfgCtrl.cs - - - - + + + + UserControl TestMethodCfgCtrl.cs - - - - + + + + UserControl TestMethodCfgCtrl.cs - - - - + + + + UserControl TestMethodCfgCtrl.cs - - - - + + + + UserControl GrabImageCfgCtrl.cs - - - - - + + + + + UserControl CfgCtrl.cs - - - - - + + + + + Form ManualEntryForm.cs - + UserControl ManualEntryCfgCtrl.cs - - - - - - - - + + + + + + + + Form @@ -2303,11 +2304,11 @@ ManualPulsesForm24.cs - - - - - + + + + + Form @@ -2326,212 +2327,212 @@ WMPulsesForm24.cs - - - + + + UserControl - - + + UserControl TestMethodCfgCtrl.cs - - - - - - - - - - - - - + + + + + + + + + + + + + UserControl TestMethodCfgCtrl.cs - - - - - + + + + + UserControl DiverterCfgCtrl.cs - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + UserControl RegValveCfgCtrl.cs - - - - - - - + + + + + + + UserControl RegValveCfgCtrl.cs - - - - - + + + + + UserControl RegValveTandemCfgCtrl.cs - - - - - - - + + + + + + + UserControl RegValveCfgCtrl.cs - - - - - - - - - - - - - - + + + + + + + + + + + + + + Form SmartCommunicationForm.cs - - - - - - - - + + + + + + + + Form CoverTestForm.cs - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + Form WaterLevelForm.cs - - - - - - + + + + + + UserControl TankCfgCtrl.cs - - - + + + UserControl WaterMeterCfgCtrl.cs - - - - - - - + + + + + + + UserControl PumpCfgCtrl.cs - + Form @@ -2544,15 +2545,15 @@ CycleEndForm.cs - - + + UserControl EntryFormCfgCtrl.cs - + Form @@ -2565,35 +2566,35 @@ CycleEndForm.cs - - + + UserControl EntryFormCfgCtrl.cs - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + Form @@ -2606,60 +2607,60 @@ MessageBoxForm.cs - - - - - - - - - - - + + + + + + + + + + + Form WMErrorsForm.cs - - - + + + UserControl - - - - - + + + + + UserControl TestMethodCfgCtrl.cs - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + True True @@ -2675,70 +2676,70 @@ True Strings.zh-CN.resx - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + True True Strings.resx - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Form @@ -2769,7 +2770,7 @@ CalibCertificateCtrl.cs - + Form @@ -2890,7 +2891,7 @@ Component - + UserControl @@ -2924,17 +2925,17 @@ UserControl - + UserControl CalendarTabPageCtrl.cs - - - - + + + + Form @@ -2947,14 +2948,14 @@ EventToolTipCtrl.cs - + UserControl UserControl - + UserControl @@ -2988,26 +2989,26 @@ CameraPictureFullCtrl.cs - + UserControl PicturesTabPageCtrl.cs - + Form DummyDlg.cs - - - - - - + + + + + + UserControl @@ -3032,9 +3033,9 @@ MainWnd.cs - - - + + + Form @@ -3065,7 +3066,7 @@ ProceduresDlg.cs - + UserControl @@ -3132,7 +3133,7 @@ Roi3.cs - + Form @@ -3157,7 +3158,7 @@ PreviousResultCtrl.cs - + Form @@ -3200,7 +3201,7 @@ DatabaseSettingsDlg.cs - + Form @@ -3234,8 +3235,8 @@ ErrorDlg.cs - - + + Form @@ -3299,8 +3300,8 @@ TestProgressCtrl.cs - - + + GciBridgeCfgCtrl.cs @@ -3711,16 +3712,16 @@ RRCfgCtrl.cs - - + + GenesisHeadTestCtrl.cs GenesisCfgCtrl.cs - - + + IPerlUniCfgCtrl.cs @@ -3838,10 +3839,10 @@ GrabImageCfgCtrl.cs - - - - + + + + CfgCtrl.cs @@ -3955,7 +3956,7 @@ Designer Strings.cs.Designer.cs - + Designer @@ -3968,8 +3969,8 @@ Designer - - + + ResXFileCodeGenerator Strings.zh-CN.Designer.cs @@ -4256,8 +4257,8 @@ TestProgressCtrl.cs - - + + Always @@ -4300,7 +4301,7 @@ PreserveNewest - + Designer @@ -4318,7 +4319,7 @@ - + @@ -4343,17 +4344,17 @@ - + - - - - - - - - + + + + + + + + Always @@ -4366,37 +4367,37 @@ Always - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + Always Always - + Always diff --git a/TBFTests/Rig/RegisterReaders/GenesisRegReader/communication/OptoHeadTest_Test.cs b/TBFTests/Rig/RegisterReaders/GenesisRegReader/communication/OptoHeadTest_Test.cs new file mode 100644 index 000000000..22fafba88 --- /dev/null +++ b/TBFTests/Rig/RegisterReaders/GenesisRegReader/communication/OptoHeadTest_Test.cs @@ -0,0 +1,151 @@ +using System; +using System.Diagnostics; +using System.Reflection; +using Common; +using JetBrains.Annotations; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using TBF.Rig.BridgeComponents.GciBridge; +using TBF.Rig.RegisterReaders.GenesisRegReader; +using TBF.Rig.RegisterReaders.GenesisRegReader.communication; +using TBF.Rig.RegisterReaders.GenesisRegReader.implementations; +using Factory = TBF.Rig.RegisterReaders.GenesisRegReader.Factory; + +namespace TBFTests.Rig.RegisterReaders.GenesisRegReader.communication +{ + [TestClass] + [TestSubject(typeof(GenesisSmartReader))] + public class OptoHeadTest_Test + { + private const string BridgeName = "GciBridge_Test"; + + private static GenesisCfg CreateConnectionCfg() + { + var factory = new Factory(); + var cfg = new GenesisCfg(factory); + + SetPrivateFieldByNames(cfg, 1, + "slotNr", + "_slotNr"); + + SetPrivateFieldByNames(cfg, 1, + "rfidComPortNr", + "_rfidComPortNr"); + + SetPrivateFieldByNames(cfg, 2, + "optoComPortNr", + "_optoComPortNr"); + + SetPrivateFieldByNames(cfg, BridgeName, + "communicationInterfaceBridge", + "_communicationInterfaceBridge"); + + return cfg; + } + + private static GenesisSmartReader CreateSimulatedGenesisReader() + { + var cfg = CreateConnectionCfg(); + + var reader = new GenesisSmartReader(cfg); + + SetPrivateFieldByNames(reader, + "Genesis1", + "name", + "_name"); + + SetPrivateFieldByNames(reader, + DebugMode.Simulate, + "debugLevel", + "_debugLevel"); + + var bridge = new GciBridge(); + + SetPrivateFieldByNames(bridge, + BridgeName, + "name", + "_name"); + + InjectBridge(reader, bridge); + + return reader; + } + + private static void InjectBridge( + GenesisSmartReader reader, + GciBridge bridge) + { + SetPrivateFieldByNames(reader, + bridge, + "commInterfaceBridge", + "_commInterfaceBridge"); + } + + private static void SetPrivateFieldByNames( + object target, + object value, + params string[] fieldNames) + { + foreach (var fieldName in fieldNames) + { + var field = target.GetType().GetField( + fieldName, + BindingFlags.Instance | + BindingFlags.NonPublic | + BindingFlags.Public); + + if (field != null) + { + field.SetValue(target, value); + return; + } + } + + throw new MissingFieldException( + target.GetType().FullName, + string.Join(" or ", fieldNames)); + } + + [TestMethod] + public void BuildConnection_Simulation_ShouldWaitForInitAndUpdate_AndFinishWithin1500ms() + { + // Arrange + var reader = CreateSimulatedGenesisReader(); + + var optoHeadTest = new OptoHeadTest(reader); + + var stopwatch = Stopwatch.StartNew(); + + // Act + optoHeadTest.BuildConnection(reader); + + stopwatch.Stop(); + + // Assert + Assert.IsTrue( + stopwatch.ElapsedMilliseconds >= 950, + $"BuildConnection finished too fast. " + + $"InitSlotAsync + UpdateSlotAsync were probably not awaited. " + + $"Elapsed={stopwatch.ElapsedMilliseconds}ms"); + + Assert.IsTrue( + stopwatch.ElapsedMilliseconds <= 1500, + $"BuildConnection took too long. " + + $"Elapsed={stopwatch.ElapsedMilliseconds}ms"); + } + + [TestMethod] + public void BuildConnection_NullGenesisHead_ShouldThrowArgumentNullException() + { + // Arrange + var reader = CreateSimulatedGenesisReader(); + + var optoHeadTest = new OptoHeadTest(reader); + + // Act + Assert + Assert.ThrowsException(() => + { + optoHeadTest.BuildConnection(null); + }); + } + } +} \ No newline at end of file diff --git a/TBFTests/Rig/RegisterReaders/GenesisRegReader/implementations/GenesisSmartReaderTest.cs b/TBFTests/Rig/RegisterReaders/GenesisRegReader/implementations/GenesisSmartReaderTest.cs index 2bebb3947..ed7019577 100644 --- a/TBFTests/Rig/RegisterReaders/GenesisRegReader/implementations/GenesisSmartReaderTest.cs +++ b/TBFTests/Rig/RegisterReaders/GenesisRegReader/implementations/GenesisSmartReaderTest.cs @@ -785,6 +785,7 @@ namespace TBFTests.Rig.RegisterReaders.GenesisRegReader.implementations Assert.AreEqual(10.0, sut.TimestampSecStart, 0.0001); Assert.AreEqual(20.0, sut.TimestampSecEnd, 0.0001); } - + + } } \ No newline at end of file diff --git a/TBFTests/TBFTests.csproj b/TBFTests/TBFTests.csproj index 69a472d5b..4f1b3a087 100644 --- a/TBFTests/TBFTests.csproj +++ b/TBFTests/TBFTests.csproj @@ -107,6 +107,7 @@ + @@ -163,7 +164,6 @@ TBF -