diff --git a/Common/.vs/config/applicationhost.config b/Common/.vs/config/applicationhost.config index ecc20ba7..de10b180 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 4f7efe21..757e019a 100644 --- a/Common/Common.sln +++ b/Common/Common.sln @@ -188,6 +188,16 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommonConsole", "CommonCons EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "modbus_master_csharp", "modbus_master_csharp\modbus_master_csharp.csproj", "{F14940F8-3C86-4BB7-A915-B021E4B3052D}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "eRegister", "eRegister", "{FBF162DF-A4C6-41D1-9324-5517C13C658B}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Protocols", "Protocols", "{1B519B0D-5E1C-4400-A8CE-F7B3CC045745}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StreamingProtocol", "Hardware\WaterMeter\eRegister\Protocols\StreamingProtocol.csproj", "{B6A19B80-0F0F-434C-A754-A7712FC208B2}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataPackages", "Hardware\WaterMeter\eRegister\DataPackages\DataPackages.csproj", "{C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "eRegisterCore", "Hardware\WaterMeter\eRegister\eRegisterCore\eRegisterCore.csproj", "{A83696BF-D8A2-4809-8424-CFE172AED5B6}" +EndProject Global GlobalSection(SharedMSBuildProjectFiles) = preSolution Utils\DateTimeServerShared\DateTimeServerShared.projitems*{4806d89a-fbfb-41bc-aaa7-2242444bf55a}*SharedItemsImports = 4 @@ -4382,6 +4392,198 @@ Global {F14940F8-3C86-4BB7-A915-B021E4B3052D}.XP32bit|x64.Build.0 = Release|Any CPU {F14940F8-3C86-4BB7-A915-B021E4B3052D}.XP32bit|x86.ActiveCfg = Release|Any CPU {F14940F8-3C86-4BB7-A915-B021E4B3052D}.XP32bit|x86.Build.0 = Release|Any CPU + {B6A19B80-0F0F-434C-A754-A7712FC208B2}._MANUAL_CONTROL|Any CPU.ActiveCfg = Release|Any CPU + {B6A19B80-0F0F-434C-A754-A7712FC208B2}._MANUAL_CONTROL|Any CPU.Build.0 = Release|Any CPU + {B6A19B80-0F0F-434C-A754-A7712FC208B2}._MANUAL_CONTROL|Mixed Platforms.ActiveCfg = Release|Any CPU + {B6A19B80-0F0F-434C-A754-A7712FC208B2}._MANUAL_CONTROL|Mixed Platforms.Build.0 = Release|Any CPU + {B6A19B80-0F0F-434C-A754-A7712FC208B2}._MANUAL_CONTROL|x64.ActiveCfg = Release|Any CPU + {B6A19B80-0F0F-434C-A754-A7712FC208B2}._MANUAL_CONTROL|x64.Build.0 = Release|Any CPU + {B6A19B80-0F0F-434C-A754-A7712FC208B2}._MANUAL_CONTROL|x86.ActiveCfg = Release|Any CPU + {B6A19B80-0F0F-434C-A754-A7712FC208B2}._MANUAL_CONTROL|x86.Build.0 = Release|Any CPU + {B6A19B80-0F0F-434C-A754-A7712FC208B2}.COM|Any CPU.ActiveCfg = Release|Any CPU + {B6A19B80-0F0F-434C-A754-A7712FC208B2}.COM|Any CPU.Build.0 = Release|Any CPU + {B6A19B80-0F0F-434C-A754-A7712FC208B2}.COM|Mixed Platforms.ActiveCfg = Release|Any CPU + {B6A19B80-0F0F-434C-A754-A7712FC208B2}.COM|Mixed Platforms.Build.0 = Release|Any CPU + {B6A19B80-0F0F-434C-A754-A7712FC208B2}.COM|x64.ActiveCfg = Release|Any CPU + {B6A19B80-0F0F-434C-A754-A7712FC208B2}.COM|x64.Build.0 = Release|Any CPU + {B6A19B80-0F0F-434C-A754-A7712FC208B2}.COM|x86.ActiveCfg = Release|Any CPU + {B6A19B80-0F0F-434C-A754-A7712FC208B2}.COM|x86.Build.0 = Release|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}.GenesisDisplayTool_V01|Any CPU.ActiveCfg = Release|Any CPU + {B6A19B80-0F0F-434C-A754-A7712FC208B2}.GenesisDisplayTool_V01|Any CPU.Build.0 = Release|Any CPU + {B6A19B80-0F0F-434C-A754-A7712FC208B2}.GenesisDisplayTool_V01|Mixed Platforms.ActiveCfg = Release|Any CPU + {B6A19B80-0F0F-434C-A754-A7712FC208B2}.GenesisDisplayTool_V01|Mixed Platforms.Build.0 = Release|Any CPU + {B6A19B80-0F0F-434C-A754-A7712FC208B2}.GenesisDisplayTool_V01|x64.ActiveCfg = Release|Any CPU + {B6A19B80-0F0F-434C-A754-A7712FC208B2}.GenesisDisplayTool_V01|x64.Build.0 = Release|Any CPU + {B6A19B80-0F0F-434C-A754-A7712FC208B2}.GenesisDisplayTool_V01|x86.ActiveCfg = Release|Any CPU + {B6A19B80-0F0F-434C-A754-A7712FC208B2}.GenesisDisplayTool_V01|x86.Build.0 = Release|Any CPU + {B6A19B80-0F0F-434C-A754-A7712FC208B2}.PerformTest|Any CPU.ActiveCfg = Release|Any CPU + {B6A19B80-0F0F-434C-A754-A7712FC208B2}.PerformTest|Any CPU.Build.0 = Release|Any CPU + {B6A19B80-0F0F-434C-A754-A7712FC208B2}.PerformTest|Mixed Platforms.ActiveCfg = Release|Any CPU + {B6A19B80-0F0F-434C-A754-A7712FC208B2}.PerformTest|Mixed Platforms.Build.0 = Release|Any CPU + {B6A19B80-0F0F-434C-A754-A7712FC208B2}.PerformTest|x64.ActiveCfg = Release|Any CPU + {B6A19B80-0F0F-434C-A754-A7712FC208B2}.PerformTest|x64.Build.0 = Release|Any CPU + {B6A19B80-0F0F-434C-A754-A7712FC208B2}.PerformTest|x86.ActiveCfg = Release|Any CPU + {B6A19B80-0F0F-434C-A754-A7712FC208B2}.PerformTest|x86.Build.0 = Release|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}.XP32bit|Any CPU.ActiveCfg = Release|Any CPU + {B6A19B80-0F0F-434C-A754-A7712FC208B2}.XP32bit|Any CPU.Build.0 = Release|Any CPU + {B6A19B80-0F0F-434C-A754-A7712FC208B2}.XP32bit|Mixed Platforms.ActiveCfg = Release|Any CPU + {B6A19B80-0F0F-434C-A754-A7712FC208B2}.XP32bit|Mixed Platforms.Build.0 = Release|Any CPU + {B6A19B80-0F0F-434C-A754-A7712FC208B2}.XP32bit|x64.ActiveCfg = Release|Any CPU + {B6A19B80-0F0F-434C-A754-A7712FC208B2}.XP32bit|x64.Build.0 = Release|Any CPU + {B6A19B80-0F0F-434C-A754-A7712FC208B2}.XP32bit|x86.ActiveCfg = Release|Any CPU + {B6A19B80-0F0F-434C-A754-A7712FC208B2}.XP32bit|x86.Build.0 = Release|Any CPU + {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}._MANUAL_CONTROL|Any CPU.ActiveCfg = Release|Any CPU + {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}._MANUAL_CONTROL|Any CPU.Build.0 = Release|Any CPU + {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}._MANUAL_CONTROL|Mixed Platforms.ActiveCfg = Release|Any CPU + {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}._MANUAL_CONTROL|Mixed Platforms.Build.0 = Release|Any CPU + {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}._MANUAL_CONTROL|x64.ActiveCfg = Release|Any CPU + {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}._MANUAL_CONTROL|x64.Build.0 = Release|Any CPU + {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}._MANUAL_CONTROL|x86.ActiveCfg = Release|Any CPU + {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}._MANUAL_CONTROL|x86.Build.0 = Release|Any CPU + {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.COM|Any CPU.ActiveCfg = Release|Any CPU + {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.COM|Any CPU.Build.0 = Release|Any CPU + {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.COM|Mixed Platforms.ActiveCfg = Release|Any CPU + {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.COM|Mixed Platforms.Build.0 = Release|Any CPU + {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.COM|x64.ActiveCfg = Release|Any CPU + {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.COM|x64.Build.0 = Release|Any CPU + {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.COM|x86.ActiveCfg = Release|Any CPU + {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.COM|x86.Build.0 = Release|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}.GenesisDisplayTool_V01|Any CPU.ActiveCfg = Release|Any CPU + {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.GenesisDisplayTool_V01|Any CPU.Build.0 = Release|Any CPU + {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.GenesisDisplayTool_V01|Mixed Platforms.ActiveCfg = Release|Any CPU + {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.GenesisDisplayTool_V01|Mixed Platforms.Build.0 = Release|Any CPU + {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.GenesisDisplayTool_V01|x64.ActiveCfg = Release|Any CPU + {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.GenesisDisplayTool_V01|x64.Build.0 = Release|Any CPU + {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.GenesisDisplayTool_V01|x86.ActiveCfg = Release|Any CPU + {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.GenesisDisplayTool_V01|x86.Build.0 = Release|Any CPU + {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.PerformTest|Any CPU.ActiveCfg = Release|Any CPU + {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.PerformTest|Any CPU.Build.0 = Release|Any CPU + {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.PerformTest|Mixed Platforms.ActiveCfg = Release|Any CPU + {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.PerformTest|Mixed Platforms.Build.0 = Release|Any CPU + {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.PerformTest|x64.ActiveCfg = Release|Any CPU + {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.PerformTest|x64.Build.0 = Release|Any CPU + {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.PerformTest|x86.ActiveCfg = Release|Any CPU + {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.PerformTest|x86.Build.0 = Release|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}.XP32bit|Any CPU.ActiveCfg = Release|Any CPU + {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.XP32bit|Any CPU.Build.0 = Release|Any CPU + {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.XP32bit|Mixed Platforms.ActiveCfg = Release|Any CPU + {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.XP32bit|Mixed Platforms.Build.0 = Release|Any CPU + {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.XP32bit|x64.ActiveCfg = Release|Any CPU + {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.XP32bit|x64.Build.0 = Release|Any CPU + {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.XP32bit|x86.ActiveCfg = Release|Any CPU + {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478}.XP32bit|x86.Build.0 = Release|Any CPU + {A83696BF-D8A2-4809-8424-CFE172AED5B6}._MANUAL_CONTROL|Any CPU.ActiveCfg = Release|Any CPU + {A83696BF-D8A2-4809-8424-CFE172AED5B6}._MANUAL_CONTROL|Any CPU.Build.0 = Release|Any CPU + {A83696BF-D8A2-4809-8424-CFE172AED5B6}._MANUAL_CONTROL|Mixed Platforms.ActiveCfg = Release|Any CPU + {A83696BF-D8A2-4809-8424-CFE172AED5B6}._MANUAL_CONTROL|Mixed Platforms.Build.0 = Release|Any CPU + {A83696BF-D8A2-4809-8424-CFE172AED5B6}._MANUAL_CONTROL|x64.ActiveCfg = Release|Any CPU + {A83696BF-D8A2-4809-8424-CFE172AED5B6}._MANUAL_CONTROL|x64.Build.0 = Release|Any CPU + {A83696BF-D8A2-4809-8424-CFE172AED5B6}._MANUAL_CONTROL|x86.ActiveCfg = Release|Any CPU + {A83696BF-D8A2-4809-8424-CFE172AED5B6}._MANUAL_CONTROL|x86.Build.0 = Release|Any CPU + {A83696BF-D8A2-4809-8424-CFE172AED5B6}.COM|Any CPU.ActiveCfg = Release|Any CPU + {A83696BF-D8A2-4809-8424-CFE172AED5B6}.COM|Any CPU.Build.0 = Release|Any CPU + {A83696BF-D8A2-4809-8424-CFE172AED5B6}.COM|Mixed Platforms.ActiveCfg = Release|Any CPU + {A83696BF-D8A2-4809-8424-CFE172AED5B6}.COM|Mixed Platforms.Build.0 = Release|Any CPU + {A83696BF-D8A2-4809-8424-CFE172AED5B6}.COM|x64.ActiveCfg = Release|Any CPU + {A83696BF-D8A2-4809-8424-CFE172AED5B6}.COM|x64.Build.0 = Release|Any CPU + {A83696BF-D8A2-4809-8424-CFE172AED5B6}.COM|x86.ActiveCfg = Release|Any CPU + {A83696BF-D8A2-4809-8424-CFE172AED5B6}.COM|x86.Build.0 = Release|Any CPU + {A83696BF-D8A2-4809-8424-CFE172AED5B6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A83696BF-D8A2-4809-8424-CFE172AED5B6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A83696BF-D8A2-4809-8424-CFE172AED5B6}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {A83696BF-D8A2-4809-8424-CFE172AED5B6}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {A83696BF-D8A2-4809-8424-CFE172AED5B6}.Debug|x64.ActiveCfg = Debug|Any CPU + {A83696BF-D8A2-4809-8424-CFE172AED5B6}.Debug|x64.Build.0 = Debug|Any CPU + {A83696BF-D8A2-4809-8424-CFE172AED5B6}.Debug|x86.ActiveCfg = Debug|Any CPU + {A83696BF-D8A2-4809-8424-CFE172AED5B6}.Debug|x86.Build.0 = Debug|Any CPU + {A83696BF-D8A2-4809-8424-CFE172AED5B6}.GenesisDisplayTool_V01|Any CPU.ActiveCfg = Release|Any CPU + {A83696BF-D8A2-4809-8424-CFE172AED5B6}.GenesisDisplayTool_V01|Any CPU.Build.0 = Release|Any CPU + {A83696BF-D8A2-4809-8424-CFE172AED5B6}.GenesisDisplayTool_V01|Mixed Platforms.ActiveCfg = Release|Any CPU + {A83696BF-D8A2-4809-8424-CFE172AED5B6}.GenesisDisplayTool_V01|Mixed Platforms.Build.0 = Release|Any CPU + {A83696BF-D8A2-4809-8424-CFE172AED5B6}.GenesisDisplayTool_V01|x64.ActiveCfg = Release|Any CPU + {A83696BF-D8A2-4809-8424-CFE172AED5B6}.GenesisDisplayTool_V01|x64.Build.0 = Release|Any CPU + {A83696BF-D8A2-4809-8424-CFE172AED5B6}.GenesisDisplayTool_V01|x86.ActiveCfg = Release|Any CPU + {A83696BF-D8A2-4809-8424-CFE172AED5B6}.GenesisDisplayTool_V01|x86.Build.0 = Release|Any CPU + {A83696BF-D8A2-4809-8424-CFE172AED5B6}.PerformTest|Any CPU.ActiveCfg = Release|Any CPU + {A83696BF-D8A2-4809-8424-CFE172AED5B6}.PerformTest|Any CPU.Build.0 = Release|Any CPU + {A83696BF-D8A2-4809-8424-CFE172AED5B6}.PerformTest|Mixed Platforms.ActiveCfg = Release|Any CPU + {A83696BF-D8A2-4809-8424-CFE172AED5B6}.PerformTest|Mixed Platforms.Build.0 = Release|Any CPU + {A83696BF-D8A2-4809-8424-CFE172AED5B6}.PerformTest|x64.ActiveCfg = Release|Any CPU + {A83696BF-D8A2-4809-8424-CFE172AED5B6}.PerformTest|x64.Build.0 = Release|Any CPU + {A83696BF-D8A2-4809-8424-CFE172AED5B6}.PerformTest|x86.ActiveCfg = Release|Any CPU + {A83696BF-D8A2-4809-8424-CFE172AED5B6}.PerformTest|x86.Build.0 = Release|Any CPU + {A83696BF-D8A2-4809-8424-CFE172AED5B6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A83696BF-D8A2-4809-8424-CFE172AED5B6}.Release|Any CPU.Build.0 = Release|Any CPU + {A83696BF-D8A2-4809-8424-CFE172AED5B6}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {A83696BF-D8A2-4809-8424-CFE172AED5B6}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {A83696BF-D8A2-4809-8424-CFE172AED5B6}.Release|x64.ActiveCfg = Release|Any CPU + {A83696BF-D8A2-4809-8424-CFE172AED5B6}.Release|x64.Build.0 = Release|Any CPU + {A83696BF-D8A2-4809-8424-CFE172AED5B6}.Release|x86.ActiveCfg = Release|Any CPU + {A83696BF-D8A2-4809-8424-CFE172AED5B6}.Release|x86.Build.0 = Release|Any CPU + {A83696BF-D8A2-4809-8424-CFE172AED5B6}.ReleaseTest|Any CPU.ActiveCfg = Release|Any CPU + {A83696BF-D8A2-4809-8424-CFE172AED5B6}.ReleaseTest|Any CPU.Build.0 = Release|Any CPU + {A83696BF-D8A2-4809-8424-CFE172AED5B6}.ReleaseTest|Mixed Platforms.ActiveCfg = Release|Any CPU + {A83696BF-D8A2-4809-8424-CFE172AED5B6}.ReleaseTest|Mixed Platforms.Build.0 = Release|Any CPU + {A83696BF-D8A2-4809-8424-CFE172AED5B6}.ReleaseTest|x64.ActiveCfg = Release|Any CPU + {A83696BF-D8A2-4809-8424-CFE172AED5B6}.ReleaseTest|x64.Build.0 = Release|Any CPU + {A83696BF-D8A2-4809-8424-CFE172AED5B6}.ReleaseTest|x86.ActiveCfg = Release|Any CPU + {A83696BF-D8A2-4809-8424-CFE172AED5B6}.ReleaseTest|x86.Build.0 = Release|Any CPU + {A83696BF-D8A2-4809-8424-CFE172AED5B6}.XP32bit|Any CPU.ActiveCfg = Release|Any CPU + {A83696BF-D8A2-4809-8424-CFE172AED5B6}.XP32bit|Any CPU.Build.0 = Release|Any CPU + {A83696BF-D8A2-4809-8424-CFE172AED5B6}.XP32bit|Mixed Platforms.ActiveCfg = Release|Any CPU + {A83696BF-D8A2-4809-8424-CFE172AED5B6}.XP32bit|Mixed Platforms.Build.0 = Release|Any CPU + {A83696BF-D8A2-4809-8424-CFE172AED5B6}.XP32bit|x64.ActiveCfg = Release|Any CPU + {A83696BF-D8A2-4809-8424-CFE172AED5B6}.XP32bit|x64.Build.0 = Release|Any CPU + {A83696BF-D8A2-4809-8424-CFE172AED5B6}.XP32bit|x86.ActiveCfg = Release|Any CPU + {A83696BF-D8A2-4809-8424-CFE172AED5B6}.XP32bit|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -4467,6 +4669,11 @@ Global {FD30EB7A-7809-4E62-9374-791D31877D6D} = {696A94BE-7237-4AE2-9E36-6059DE519971} {AFC428F5-0141-4A3F-BEF2-470A89D972F6} = {C17363DF-A043-4F25-8EBA-2B3B078227DC} {F14940F8-3C86-4BB7-A915-B021E4B3052D} = {B4F8545B-F379-42A5-BDE9-763FD7B79598} + {FBF162DF-A4C6-41D1-9324-5517C13C658B} = {5563DD3B-2287-4BED-97BF-F0389FF505AF} + {1B519B0D-5E1C-4400-A8CE-F7B3CC045745} = {FBF162DF-A4C6-41D1-9324-5517C13C658B} + {B6A19B80-0F0F-434C-A754-A7712FC208B2} = {1B519B0D-5E1C-4400-A8CE-F7B3CC045745} + {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478} = {FBF162DF-A4C6-41D1-9324-5517C13C658B} + {A83696BF-D8A2-4809-8424-CFE172AED5B6} = {FBF162DF-A4C6-41D1-9324-5517C13C658B} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {4BCB7B69-696C-436A-86F7-C91EA5588164} diff --git a/Common/CommonConsole/CommonConsole.csproj b/Common/CommonConsole/CommonConsole.csproj index d68d6e0d..02d1be4a 100644 --- a/Common/CommonConsole/CommonConsole.csproj +++ b/Common/CommonConsole/CommonConsole.csproj @@ -46,6 +46,7 @@ + @@ -53,6 +54,19 @@ - + + + {F7E3DF42-4D35-4A0C-9182-90438F9956E1} + ServiceCore + + + {1057AD21-BA22-4CAB-B3FE-88C5C9980E6A} + MeterProcessState + + + {8A619CD5-6C8D-420C-A132-7946C6F13E6E} + ByteArrayStyle + + \ No newline at end of file diff --git a/Common/CommonConsole/ProgramLogFileHelper.cs b/Common/CommonConsole/ProgramLogFileHelper.cs new file mode 100644 index 00000000..73804b9b --- /dev/null +++ b/Common/CommonConsole/ProgramLogFileHelper.cs @@ -0,0 +1,1030 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Globalization; +using System.Linq; +using System.Text; +using Xylem.Common.Logic.ServiceCore; + +namespace CommonConsole +{ + public class ProgramLogFileHelper + { + + public class resultRep + { + public double GreenLEDTime = 0.0; + public string Date { get; internal set; } + public DateTime DataDate { get; internal set; } + public string CustomerName { get; internal set; } + public string PcbId { get; internal set; } + public string Core { get; internal set; } + public string FW { get; internal set; } + public string POWERMON_BatteryVoltage { get; internal set; } + public string POWERMON_BatteryQuantity { get; internal set; } + public string GENESISFLOW_ScaledBilling { get; internal set; } + public string GENESISFLOW_SampleRate { get; internal set; } + public string IRDA_AdapterID { get; internal set; } + public string IRDA_PulseReportRate { get; internal set; } + public string METROLOGYASST_PulseResolution { get; internal set; } + public string METROLOGYASST_PulseEvenDistribution { get; internal set; } + public string POWERMON_TotalUsedCharge { get; internal set; } + public string POWERMON_TotalUsedSeconds { get; internal set; } + public string GENESISFLOW_LedMode { get; internal set; } + public string METROLOGYASST_PulseWeight { get; internal set; } + public string METROLOGYASST_PulseMode { get; internal set; } + public string METROLOGYASST_PulseLength { get; internal set; } + public String Source { get; internal set; } + public Boolean PwFileUpdate { get; internal set; } = false; + + + public void Calc() + { + + string[] formats = { "dd/MM/yyyy", "dd/M/yyyy", "d/M/yyyy", "d/MM/yyyy", + "dd/MM/yy", "dd/M/yy", "d/M/yy", "d/MM/yy"}; + + if (string.IsNullOrEmpty(Date) && DataDate == new DateTime()) + { + return; + } + if (DataDate == new DateTime()) + { + + + if (Date.Contains(":")) + { + if (DateTime.TryParseExact(Date.Trim().Substring(0, "yyyy-MM-dd".Length), "yyyy-MM-dd", null, DateTimeStyles.None, out var tmp)) + { + DataDate = tmp; + } + else + { + + } + + //2019-10-30 15:46:18.767 + } + else if (Date.Contains("/")) + { + if (DateTime.TryParseExact(Date.Trim(), "mm/dd/yyyy", new CultureInfo("us-US"), DateTimeStyles.None, out var tmp)) + { + DataDate = tmp; + } + else + + { + + var strDate = Date.Trim().Split('/'); + if (strDate[0].Length == 1) + { + strDate[0] = "0" + strDate[0]; + } + if (strDate[1].Length == 1) + { + strDate[1] = "0" + strDate[1]; + } + if (DateTime.TryParseExact(strDate[1] + "." + strDate[0] + "." + strDate[2], "dd.MM.yyyy", null, DateTimeStyles.None, out var tmphelp)) + { + DataDate = tmphelp; + } + else + { + + } + } + } + else if (Date.Contains("-")) + { + if (DateTime.TryParseExact(Date.Trim(), "dd.MM.yyyy", null, DateTimeStyles.None, out var tmp)) + { + DataDate = tmp; + } + else + { + + } + } + else + { + if (DateTime.TryParseExact(Date.Trim(), "dd.MM.yyyy", null, DateTimeStyles.None, out var tmp)) + { + DataDate = tmp; + } + else + { + + var strDate = Date.Replace(" ", "").Split('.'); + if (strDate[0].Length == 1) + { + strDate[0] = "0" + strDate[0]; + } + if (strDate[1].Length == 1) + { + strDate[1] = "0" + strDate[1]; + } + if (DateTime.TryParseExact(strDate[1] + "." + strDate[0] + "." + strDate[2], "dd.MM.yyyy", null, DateTimeStyles.None, out var tmphelp)) + { + DataDate = tmphelp; + } + + } + } + } + + if (!string.IsNullOrEmpty(POWERMON_BatteryQuantity)) + { + if (POWERMON_BatteryQuantity.Contains("1")) + { + BatteryQuantity = 1; + } + else + { + BatteryQuantity = 2; + } + + } + DrainedBatteryLoad_uAs = 0; + ExceededLifeTime_s = 0; + if (!string.IsNullOrEmpty(POWERMON_TotalUsedCharge) && POWERMON_TotalUsedCharge != "NULL") + { + if (POWERMON_TotalUsedCharge.Contains(" - ")) + { + var trim = POWERMON_TotalUsedCharge.LastIndexOf(" - ") + 3; + POWERMON_TotalUsedCharge = POWERMON_TotalUsedCharge.Substring(trim, POWERMON_TotalUsedCharge.Length - trim); + UInt64.TryParse(POWERMON_TotalUsedCharge, out DrainedBatteryLoad_uAs); + } + else + { + if (POWERMON_TotalUsedCharge.Length > "E2-AF-58-A3-00-00-00-00".Length) + { + POWERMON_TotalUsedCharge = POWERMON_TotalUsedCharge.Substring(0, "E2-AF-58-A3-00-00-00-00".Length); + } + String[] arr = POWERMON_TotalUsedCharge.Split('-'); + + Byte[] raw = new Byte[arr.Length]; + for (Int32 i = arr.Length - 1; i >= 0; i--) + { + raw[i] = Convert.ToByte(arr[i], 16); + } + if (POWERMON_TotalUsedCharge.Length == "C5-1F-04-BD".Length) + { + Calculated = false; + return; + } + DrainedBatteryLoad_uAs = BitConverter.ToUInt64(raw, 0); + } + + } + if (!string.IsNullOrEmpty(POWERMON_TotalUsedSeconds) && POWERMON_TotalUsedSeconds != "NULL") + { + if (POWERMON_TotalUsedSeconds.Contains(" - ")) + { + var trim = POWERMON_TotalUsedSeconds.LastIndexOf(" - ") + 3; + POWERMON_TotalUsedSeconds = POWERMON_TotalUsedSeconds.Substring(trim, POWERMON_TotalUsedSeconds.Length - trim); + UInt32.TryParse(POWERMON_TotalUsedSeconds, out ExceededLifeTime_s); + } + else + { + String[] arr = POWERMON_TotalUsedSeconds.Split('-'); + + Byte[] raw = new Byte[arr.Length]; + for (Int32 i = arr.Length - 1; i >= 0; i--) + { + raw[i] = Convert.ToByte(arr[i], 16); + } + ExceededLifeTime_s = BitConverter.ToUInt32(raw, 0); + } + + + } + + + + if (DrainedBatteryLoad_uAs == 0 || ExceededLifeTime_s == 0) + { + return; + } + + + + + + InitialBatteryLoad_mAh = 19000; + + + + + + // Calculate the initial overall battery load of all batteries in uAs as the drained load uses this unit. + var initialBatteryLoad_uAs = 1000 * 3600 * InitialBatteryLoad_mAh * (UInt64)BatteryQuantity; + + // Relation of drained to initial load, set the battery to fully unloaded for failed check to force a recalculation + var drainedBatteryLoad_rel = 1.0; + if (initialBatteryLoad_uAs != 0) + { + drainedBatteryLoad_rel = (Double)DrainedBatteryLoad_uAs / initialBatteryLoad_uAs; + } + + DrainedBatteryLoadPercent = drainedBatteryLoad_rel * 100; + + // The estimated life time uses the drained load over the actual exceeded life time and assumes, that further on + // an identical load will be consumed over the remaining life cycle. The initial load will be multiplied with the + // drained load relation. Set the estimated time to the exceeded time to force a recalculation on failed input. + var estimatedLifeTime_s = (Double)ExceededLifeTime_s; + if (drainedBatteryLoad_rel != 0.0) + { + estimatedLifeTime_s = ExceededLifeTime_s / drainedBatteryLoad_rel; + } + + var remainingLifetime_s = estimatedLifeTime_s - ExceededLifeTime_s; + // convert the seconds to years + RemainingLifeTimeYears = remainingLifetime_s / 3600 / 24 / 365.25; + + + UNTLimit = 1368000000 + (ExceededLifeTime_s * 77.7); + // + (POWERMON_TotalUsedSeconds * 77.7) This allows 1 % battery capacity usage during manufacture on top of an average consumption of 77.7uA + + + Calculated = true; + + } + public UInt32 ExceededLifeTime_s; + public UInt64 DrainedBatteryLoad_uAs; + public Int32 BatteryQuantity; + public UInt64 InitialBatteryLoad_mAh; + public Double DrainedBatteryLoadPercent; + public Double RemainingLifeTimeYears; + + public Double UNTLimit { get; private set; } + + public bool Calculated = false; + + + } + + private class GreenHistoryItem + { + + public int SR = 2; + public DateTime Time { get; set; } + + public bool Idel { get; set; } = false; + + public bool LedMode { get; set; } = false; + + public string Remark { get; set; } + + public bool HighConsumption { get; set; } + + public double SecondsInHighConsumption { get; set; } + + public void Cal() + { + if (Idel) + { + HighConsumption = false; + return; + } + if (!LedMode) + { + HighConsumption = false; + return; + } + if (SR == 2) + { + HighConsumption = false; + return; + } + HighConsumption = true; + } + + } + + public static void MainHelper(string[] args) + { + + #region stuff + //var listRes = new Dictionary>(); + + //foreach (var repFile in Directory.GetFiles("E:\\bat\\report\\")) + //{ + // var newlines = new List(); + + // var alllinesfromfile = File.ReadAllLines(repFile); + + // var R = new resultRep(); + // R.Source = "CUST"; + // foreach (var lc in alllinesfromfile) + // { + // if (lc.StartsWith("Datum:")) + // { R.Date = lc.Replace("Datum:", ""); } + // if (lc.StartsWith("Date:")) + // { R.Date = lc.Replace("Date:", ""); } + + + // if (lc.StartsWith("Kundenname:")) + // { R.CustomerName = lc.Replace("Kundenname:", ""); } + // if (lc.StartsWith("Customer Name:")) + // { R.CustomerName = lc.Replace("Customer Name:", ""); } + + // if (lc.StartsWith("PCB ID:")) + // { R.PcbId = lc.Replace("PCB ID:", "").Trim(); ; } + + // if (lc.StartsWith("Systemkern-Version:")) + // { R.Core = lc.Replace("Systemkern-Version:", ""); } + + // if (lc.StartsWith("System Core Revision:")) + // { R.Core = lc.Replace("System Core Revision:", ""); } + + + // if (lc.StartsWith("Nummer: 0x18 - V:")) + // { R.FW = lc.Replace("Nummer: 0x18 - V:", "").Replace(" - Name: FLEXNETVERSION", ""); } + + // if (lc.StartsWith("AppId: 0x18 - V:")) + // { R.FW = lc.Replace("AppId: 0x18 - V:", "").Replace(" - AppName: FLEXNETVERSION", ""); } + + + // if (lc.StartsWith("Lese Register: POWERMON_BatteryVoltage")) + // { R.POWERMON_BatteryVoltage = lc.Replace("Lese Register: POWERMON_BatteryVoltage", ""); } + // if (lc.StartsWith("Lese Register: POWERMON_BatteryQuantity")) + // { R.POWERMON_BatteryQuantity = lc.Replace("Lese Register: POWERMON_BatteryQuantity", ""); } + + // if (lc.StartsWith("Lese Register: POWERMON_TotalUsedCharge")) + // { R.POWERMON_TotalUsedCharge = lc.Replace("Lese Register: POWERMON_TotalUsedCharge", ""); } + + // if (lc.StartsWith("Lese Register: POWERMON_TotalUsedSeconds")) + // { R.POWERMON_TotalUsedSeconds = lc.Replace("Lese Register: POWERMON_TotalUsedSeconds", ""); } + // if (lc.StartsWith("Lese Register: GENESISFLOW_LedMode")) + // { R.GENESISFLOW_LedMode = lc.Replace("Lese Register: GENESISFLOW_LedMode", ""); } + // if (lc.StartsWith("Lese Register: METROLOGYASST_PulseWeight")) + // { R.METROLOGYASST_PulseWeight = lc.Replace("Lese Register: METROLOGYASST_PulseWeight", ""); } + // if (lc.StartsWith("Lese Register: METROLOGYASST_PulseMode")) + // { R.METROLOGYASST_PulseMode = lc.Replace("Lese Register: METROLOGYASST_PulseMode", ""); } + // if (lc.StartsWith("Lese Register: METROLOGYASST_PulseLength")) + // { R.METROLOGYASST_PulseLength = lc.Replace("Lese Register: METROLOGYASST_PulseLength", ""); } + + // if (lc.StartsWith("Lese Register: METROLOGYASST_PulseEvenDistribution")) + // { R.METROLOGYASST_PulseEvenDistribution = lc.Replace("Lese Register: METROLOGYASST_PulseEvenDistribution", ""); } + + // if (lc.StartsWith("Lese Register: METROLOGYASST_PulseResolution")) + // { R.METROLOGYASST_PulseResolution = lc.Replace("Lese Register: METROLOGYASST_PulseResolution", ""); } + + // if (lc.StartsWith("Lese Register: IRDA_PulseReportRate")) + // { R.IRDA_PulseReportRate = lc.Replace("Lese Register: IRDA_PulseReportRate", ""); } + + // if (lc.StartsWith("Lese Register: IRDA_AdapterID ")) + // { R.IRDA_AdapterID = lc.Replace("Lese Register: IRDA_AdapterID ", ""); } + + // if (lc.StartsWith("Lese Register: GENESISFLOW_SampleRate ")) + // { R.GENESISFLOW_SampleRate = lc.Replace("Lese Register: GENESISFLOW_SampleRate ", ""); } + + // if (lc.StartsWith("Lese Register: GENESISFLOW_ScaledBilling ")) + // { R.GENESISFLOW_ScaledBilling = lc.Replace("Lese Register: GENESISFLOW_ScaledBilling ", ""); } + + + // if (lc.StartsWith("Read register: POWERMON_BatteryVoltage")) + // { R.POWERMON_BatteryVoltage = lc.Replace("Read register: POWERMON_BatteryVoltage", ""); } + // if (lc.StartsWith("Read register: POWERMON_BatteryQuantity")) + // { R.POWERMON_BatteryQuantity = lc.Replace("Read register: POWERMON_BatteryQuantity", ""); } + + // if (lc.StartsWith("Read register: POWERMON_TotalUsedCharge")) + // { R.POWERMON_TotalUsedCharge = lc.Replace("Read register: POWERMON_TotalUsedCharge", ""); } + + // if (lc.StartsWith("Read register: POWERMON_TotalUsedSeconds")) + // { R.POWERMON_TotalUsedSeconds = lc.Replace("Read register: POWERMON_TotalUsedSeconds", ""); } + // if (lc.StartsWith("Read register: GENESISFLOW_LedMode")) + // { R.GENESISFLOW_LedMode = lc.Replace("Read register: GENESISFLOW_LedMode", ""); } + // if (lc.StartsWith("Read register: METROLOGYASST_PulseWeight")) + // { R.METROLOGYASST_PulseWeight = lc.Replace("Read register: METROLOGYASST_PulseWeight", ""); } + // if (lc.StartsWith("Read register: METROLOGYASST_PulseMode")) + // { R.METROLOGYASST_PulseMode = lc.Replace("Read register: METROLOGYASST_PulseMode", ""); } + // if (lc.StartsWith("Read register: METROLOGYASST_PulseLength")) + // { R.METROLOGYASST_PulseLength = lc.Replace("Read register: METROLOGYASST_PulseLength", ""); } + + // if (lc.StartsWith("Read register: METROLOGYASST_PulseEvenDistribution")) + // { R.METROLOGYASST_PulseEvenDistribution = lc.Replace("Read register: METROLOGYASST_PulseEvenDistribution", ""); } + + // if (lc.StartsWith("Read register: METROLOGYASST_PulseResolution")) + // { R.METROLOGYASST_PulseResolution = lc.Replace("Read register: METROLOGYASST_PulseResolution", ""); } + + // if (lc.StartsWith("Read register: IRDA_PulseReportRate")) + // { R.IRDA_PulseReportRate = lc.Replace("Read register: IRDA_PulseReportRate", ""); } + + // if (lc.StartsWith("Read register: IRDA_AdapterID ")) + // { R.IRDA_AdapterID = lc.Replace("Read register: IRDA_AdapterID ", ""); } + + // if (lc.StartsWith("Read register: GENESISFLOW_SampleRate ")) + // { R.GENESISFLOW_SampleRate = lc.Replace("Read register: GENESISFLOW_SampleRate ", ""); } + + // if (lc.StartsWith("Read register: GENESISFLOW_ScaledBilling ")) + // { R.GENESISFLOW_ScaledBilling = lc.Replace("Read register: GENESISFLOW_ScaledBilling ", ""); } + + // if (lc.StartsWith("Password file restore succeeded")) + // { + // R.PwFileUpdate = true; + // } + // if (lc.StartsWith("Paßwortdatei erfolgreich wiederhergestellt")) + // { + // R.PwFileUpdate = true; + // } + // // + // } + // if (!string.IsNullOrEmpty(R.PcbId)) + // { + // if (listRes.ContainsKey(R.PcbId)) + // { + // listRes[R.PcbId].Add(R); + // } + // else + // { + // listRes.Add(R.PcbId, new List() { R }); + // } + // } + + //} + + + + + //var listEOL = new Dictionary>(); + + //foreach (var item in listRes) + //{ + // Console.WriteLine($"'{item.Key}', "); + + //} + + + //Console.ReadLine(); + + + + //foreach (var line in File.ReadAllLines("E:\\bat\\History.csv")) + //{ + // var csvelm = line.Split(';'); + // var cPcbId = csvelm[1]; + // if (cPcbId.Length > 5) + // { + // var cAddress = csvelm[2]; + // var cValue = csvelm[3]; + // var cDate = csvelm[4]; + + + // } + + + //} + var listEOL = new Dictionary>(); + var pcbCheck = new List() { + 222830007, +222830022 , +222830068 , +222830076 , +222830077 , +222830097 , +222830099 , +222830101 , +222830109 , +222830112 , +222830118 , +222830121 , +222830153 , +222830172 , +222830174 , +222830213 , +222830249 , +222830296 , +230930011 , +230930019 , +230930032 , +230930049 , +230930051 , +230930059 , +230930122 , +230930127 , +230930128 , +230930129 , +230930136 , +230930137 , +230930143 , +230930149 , +230930227 , +230930228 , +230930237 , +230930277 , +230930279 , +230930280 , +230930281 , +230930299 , +230930308 , +230930325 , +230930329 , +230930382 , +230930387 , +230930391 , +230930396 , +230930403 , +230930408 , +230930411 }; + #endregion + + + if (true) + { + foreach (var item in pcbCheck) + { + //Console.WriteLine($"'{item.Key}', "); + //foreach (var re in item.Value) + //{ + // re.Calc(); + //} + var sbq = new StringBuilder(); + + sbq.AppendLine(" declare @PcbID as nvarchar(50) "); + sbq.AppendLine(" declare @Adress as nvarchar(50) "); + + sbq.AppendLine($" set @PcbID = '{item}' "); + + sbq.AppendLine(" SELECT [ID] "); + sbq.AppendLine(" ,[PcbId] "); + sbq.AppendLine(" ,[Address] "); + sbq.AppendLine(" ,[Value] "); + sbq.AppendLine(" ,[date] "); + sbq.AppendLine(" FROM [Auftrag].[dbo].[GenesisMeterRegisterHistory] "); + sbq.AppendLine(" where PcbId = @PcbID "); + sbq.AppendLine(" and (@Adress is null or [Address] = @Adress ) "); + sbq.AppendLine(" order by [date] desc "); + + + using (var dataacces = new SqlDataAccess("Data Source=SLASQL01.emea.sensus.net;;Initial Catalog=Auftrag;Persist Security Info=False;User ID=GenesisPasswordService;Password=PcbID;Connection Timeout=120")) + { + var dt = dataacces.ExecuteQuery(sbq.ToString()); + foreach (DataRow row in dt.Rows) + { + + resultRep currentRespons; + if (!listEOL.ContainsKey(item)) + { + listEOL.Add(item, new List()); + currentRespons = new resultRep() { DataDate = (DateTime)row["date"], PcbId = item.ToString(), Source = "PROD" }; + listEOL[item].Add(currentRespons); + + } + else + { + if (listEOL[item].Any(r => r.DataDate.Date == ((DateTime)row["date"]).Date)) + { + currentRespons = listEOL[item].First(r => r.DataDate.Date == ((DateTime)row["date"]).Date); + } + else + { + currentRespons = new resultRep() { DataDate = (DateTime)row["date"], PcbId = item.ToString(), Source = "PROD" }; + listEOL[item].Add(currentRespons); + } + + } + + + switch (row["Address"].ToString()) + { + case "12-12": + currentRespons.METROLOGYASST_PulseResolution = row["Value"].ToString(); + break; + case "12-11": + currentRespons.METROLOGYASST_PulseEvenDistribution = row["Value"].ToString(); + break; + case "12-02": + currentRespons.METROLOGYASST_PulseWeight = row["Value"].ToString(); + break; + case "12-03": + currentRespons.METROLOGYASST_PulseMode = row["Value"].ToString(); + break; + case "12-04": + currentRespons.METROLOGYASST_PulseLength = row["Value"].ToString(); + break; + case "0F-13": + currentRespons.GENESISFLOW_ScaledBilling = row["Value"].ToString(); + break; + case "0F-00": + currentRespons.GENESISFLOW_SampleRate = row["Value"].ToString(); + break; + case "0F-16": + currentRespons.GENESISFLOW_LedMode = row["Value"].ToString(); + break; + case "01-09": + var strTmp = row["Value"].ToString(); + if (strTmp.Length > "D5-7A-AC-24-00-00-00-00".Length) + { + strTmp.Substring(0, "D5-7A-AC-24-00-00-00-00".Length); + } + if (String.IsNullOrEmpty(currentRespons.POWERMON_TotalUsedCharge)) + { + currentRespons.POWERMON_TotalUsedCharge = strTmp; + } + else + { + if (strTmp.Length == "D5-7A-AC-24-00-00-00-00".Length) + { + currentRespons.POWERMON_TotalUsedCharge = strTmp; + } + else + { + + } + + } + + break; + case "01-0A": + if (row["Value"].ToString() != "00-00-00-00") + { + currentRespons.POWERMON_TotalUsedSeconds = row["Value"].ToString(); + + } + + break; + case "01-00": + if (row["Value"].ToString() != "00-00-00-00") + { + currentRespons.POWERMON_BatteryVoltage = row["Value"].ToString(); + } + break; + case "01-04": + currentRespons.POWERMON_BatteryQuantity = row["Value"].ToString(); + break; + case "14-09": + if (row["Value"].ToString() != "00-00-00-00") + { + currentRespons.IRDA_AdapterID = row["Value"].ToString(); + } + break; + case "14-00": + if (row["Value"].ToString() != "00-00-00-00") + { + currentRespons.IRDA_PulseReportRate = row["Value"].ToString(); + } + break; + default: + break; + } + + } + } + } + } + + + + + + var pcbDate = new Dictionary(); + + + + var sbLEDQery = new StringBuilder(); + + sbLEDQery.AppendLine("select * from GenesisMeterRegisterHistory where PcbId in ( "); + sbLEDQery.AppendLine(" "); + sbLEDQery.AppendLine("'230930011', "); + sbLEDQery.AppendLine("'230930127', "); + sbLEDQery.AppendLine("'230930281', "); + sbLEDQery.AppendLine("'230930129', "); + sbLEDQery.AppendLine("'230930137', "); + sbLEDQery.AppendLine("'230930280', "); + sbLEDQery.AppendLine("'230930411', "); + sbLEDQery.AppendLine("'230930049', "); + sbLEDQery.AppendLine("'230930279', "); + sbLEDQery.AppendLine("'222830068', "); + sbLEDQery.AppendLine("'222830076', "); + sbLEDQery.AppendLine("'222830174', "); + sbLEDQery.AppendLine("'222830121', "); + sbLEDQery.AppendLine("'222830112', "); + sbLEDQery.AppendLine("'230930059', "); + sbLEDQery.AppendLine("'222830022', "); + sbLEDQery.AppendLine("'222830099', "); + sbLEDQery.AppendLine("'230930122', "); + sbLEDQery.AppendLine("'230930051', "); + sbLEDQery.AppendLine("'230930227', "); + sbLEDQery.AppendLine("'230930382', "); + sbLEDQery.AppendLine("'230930391', "); + sbLEDQery.AppendLine("'230930408', "); + sbLEDQery.AppendLine("'230930308', "); + sbLEDQery.AppendLine("'222830109', "); + sbLEDQery.AppendLine("'230930128', "); + sbLEDQery.AppendLine("'222830077', "); + sbLEDQery.AppendLine("'222830101', "); + sbLEDQery.AppendLine("'222830007', "); + sbLEDQery.AppendLine("'222830249', "); + sbLEDQery.AppendLine("'230930019', "); + sbLEDQery.AppendLine("'230930299', "); + sbLEDQery.AppendLine("'230930396', "); + sbLEDQery.AppendLine("'230930387', "); + sbLEDQery.AppendLine("'222830118', "); + sbLEDQery.AppendLine("'230930403', "); + sbLEDQery.AppendLine("'230930228', "); + sbLEDQery.AppendLine("'222830097', "); + sbLEDQery.AppendLine("'230930237', "); + sbLEDQery.AppendLine("'230930032', "); + sbLEDQery.AppendLine("'230930149', "); + sbLEDQery.AppendLine("'222830213', "); + sbLEDQery.AppendLine("'230930143', "); + sbLEDQery.AppendLine("'230930136', "); + sbLEDQery.AppendLine("'230930329', "); + sbLEDQery.AppendLine("'230930277', "); + sbLEDQery.AppendLine("'230930325', "); + sbLEDQery.AppendLine("'222830296', "); + sbLEDQery.AppendLine("'222830153', "); + sbLEDQery.AppendLine("'222830172' "); + sbLEDQery.AppendLine(") "); + sbLEDQery.AppendLine("and Address in ('0F-16', '0F-00', '0F-22') order by PcbId, date"); + + var dic = new Dictionary>(); + var dateTimeold = new DateTime(); + var oldValue = false; + var oldPCbID = ""; + using (var dataacces = new SqlDataAccess("Data Source=SLASQL01.emea.sensus.net;;Initial Catalog=Auftrag;Persist Security Info=False;User ID=GenesisPasswordService;Password=PcbID;Connection Timeout=120")) + { + var dt = dataacces.ExecuteQuery(sbLEDQery.ToString()); + foreach (DataRow row in dt.Rows) + { + + var time = (DateTime)row["date"]; + + var pcb = (string)row["PcbId"]; + var reg = (string)row["Address"]; + var strVal = (string)row["Value"]; + bool State = false; + var re = ""; + + GreenHistoryItem last; + if (!dic.ContainsKey(pcb)) + { + dic.Add(pcb, new List()); + dic[pcb].Add(new GreenHistoryItem()); + } + + + last = dic[pcb].Last(); + var newItem = new GreenHistoryItem() { Time = time, Idel = last.Idel, SR = last.SR, LedMode = last.LedMode, Remark = "int" }; + + switch (reg) + { + case "0F-16": + if (strVal == "00-00-00-00") + { + newItem.LedMode = false; + re = "LED Mode off"; + } + else + { + re = "LED Mode On"; + newItem.LedMode = true; ; + } + break; + case "0F-22": + if (strVal == "00-00-00-00") + { + re = "Trigger active"; + newItem.Idel = false; + } + else + { + re = "Trigger idel"; + newItem.Idel = true; + } + break; + case "0F-21": + re = "Trigger active"; + newItem.Idel = false; + break; + case "0F-00": + if (strVal == "00-00-00-02") + { + newItem.SR = 2; + re = "Sampel rate 2"; + } + else + { + newItem.SR = 10; + re = "Sampel rate < 2"; + } + break; + + default: + break; + } + + newItem.Cal(); + dic[pcb].Add(newItem); + + oldPCbID = pcb; + + + } + } + Console.WriteLine("key;time;highconsumption;idel;ledmodeSR;totalConsomtion;add seconds;"); + var dicS = new Dictionary(); + foreach (var item in dic) + { + var s = 0.0; + int c = -1; + foreach (var gItem in item.Value) + { + + if (c >= 0) + { + if (!item.Value[c].HighConsumption) + { + //war aus + } + else if (item.Value[c].HighConsumption) + { + gItem.SecondsInHighConsumption = (gItem.Time - item.Value[c].Time).TotalSeconds; + s = s + gItem.SecondsInHighConsumption; + } + + } + if (item.Key == "230930325" || item.Key == "222830153" || item.Key == "230930329") + { + + + + + + Console.WriteLine($"{item.Key};{gItem.Time};{gItem.HighConsumption};{gItem.Idel};{gItem.LedMode};{gItem.SR};{gItem.SecondsInHighConsumption}; {s}"); + } + c = c + 1; + } + + dicS.Add(item.Key.ToString(), s); + } + + Console.WriteLine("PcbId;Date;RemainingLifeTimeYears;DrainedBatteryLoadPercent;ExceededLifeTime_s;DrainedBatteryLoad_uAs;UNTLimit;unt Pass;Green LED days"); + foreach (var item in listEOL) + { + if (item.Value != null && item.Value.Any()) + { + item.Value.ForEach(c => c.Calc()); + foreach (var rItem in item.Value.OrderByDescending(o => o.DataDate)) + { + + if (rItem.Calculated) + { + var s = 0.0; + if (dicS.ContainsKey(rItem.PcbId)) + { + s = dicS[rItem.PcbId]; + } + Console.WriteLine($"{rItem.PcbId};{rItem.DataDate};{rItem.RemainingLifeTimeYears};{rItem.DrainedBatteryLoadPercent};{rItem.ExceededLifeTime_s};{rItem.DrainedBatteryLoad_uAs};{rItem.UNTLimit};{rItem.DrainedBatteryLoad_uAs>= rItem.UNTLimit };{s/60/60/24}"); + break; + } + + + } + + + } + + } + foreach (var item in dic) + { + Console.WriteLine($"{item.Key};{item.Value}"); + } + Console.ReadLine(); + + + //foreach (var item in listRes) + //{ + // if (item.Value.Any(a => a.PwFileUpdate)) + // { + // foreach (var v in item.Value) + // { + // v.Calc(); + // Console.WriteLine($"{item.Key}; {v.DataDate}"); + // } + + // } + //} + + ////foreach (var item in listRes) + ////{ + //// if (item.Value.Any(a => !a.PwFileUpdate)) + //// { + //// Console.WriteLine($"{item.Key}; Prob Good"); + //// } + ////} + + //foreach (var item in listEOL.Where(c => c.Value.Any(r => r.Calculated))) + //{ + + //} + + //var sb = new StringBuilder(); + //foreach (var item in listRes) + //{ + + + // var Reps = item.Value.OrderBy(o => o.DataDate); + // var SbDate = new StringBuilder(); + // var SbSource = new StringBuilder(); + // var sbCore = new StringBuilder(); + // var sbCustomerName = new StringBuilder(); + // var sbDrainedBatteryLoadPercent = new StringBuilder(); + // var sbDrainedBatteryLoad_uAs = new StringBuilder(); + // var sbExceededLifeTime_s = new StringBuilder(); + // var sbPOWERMON_BatteryQuantity = new StringBuilder(); + // var sbRemainingLifeTimeYears = new StringBuilder(); + // var sbFW = new StringBuilder(); + // var sbGENESISFLOW_LedMode = new StringBuilder(); + // var sbGENESISFLOW_SampleRate = new StringBuilder(); + // var sbGENESISFLOW_ScaledBilling = new StringBuilder(); + // var sbIRDA_AdapterID = new StringBuilder(); + // var sbIRDA_PulseReportRate = new StringBuilder(); + // var sbMETROLOGYASST_PulseEvenDistribution = new StringBuilder(); + // var sbMETROLOGYASST_PulseLength = new StringBuilder(); + // var sbMETROLOGYASST_PulseMode = new StringBuilder(); + // var sbMETROLOGYASST_PulseResolution = new StringBuilder(); + // var sbMETROLOGYASST_PulseWeight = new StringBuilder(); + + + // foreach (var rep in Reps.Where(c => c.Calculated)) + // { + // SbDate.Append(rep.DataDate).Append(';'); + // SbSource.Append(rep.Source).Append(';'); + // sbCore.Append(rep.Core).Append(';'); + // sbCustomerName.Append(rep.CustomerName).Append(';'); + // sbDrainedBatteryLoadPercent.Append(rep.DrainedBatteryLoadPercent).Append(';'); + // sbDrainedBatteryLoad_uAs.Append(rep.DrainedBatteryLoad_uAs).Append(';'); + // sbExceededLifeTime_s.Append(rep.ExceededLifeTime_s).Append(';'); + // sbPOWERMON_BatteryQuantity.Append(rep.POWERMON_BatteryQuantity).Append(';'); + // sbRemainingLifeTimeYears.Append(rep.RemainingLifeTimeYears).Append(';'); + // sbFW.Append(rep.FW).Append(';'); + // sbGENESISFLOW_LedMode.Append(rep.GENESISFLOW_LedMode).Append(';'); + // sbGENESISFLOW_SampleRate.Append(rep.GENESISFLOW_SampleRate).Append(';'); + // sbGENESISFLOW_ScaledBilling.Append(rep.GENESISFLOW_ScaledBilling).Append(';'); + // sbIRDA_AdapterID.Append(rep.IRDA_AdapterID).Append(';'); + // sbIRDA_PulseReportRate.Append(rep.IRDA_PulseReportRate).Append(';'); + // sbMETROLOGYASST_PulseEvenDistribution.Append(rep.METROLOGYASST_PulseEvenDistribution).Append(';'); + // sbMETROLOGYASST_PulseLength.Append(rep.METROLOGYASST_PulseLength).Append(';'); + // sbMETROLOGYASST_PulseMode.Append(rep.METROLOGYASST_PulseMode).Append(';'); + // sbMETROLOGYASST_PulseResolution.Append(rep.METROLOGYASST_PulseResolution).Append(';'); + // sbMETROLOGYASST_PulseWeight.Append(rep.METROLOGYASST_PulseWeight).Append(';'); + + // } + // if (Reps.Any(c => c.Calculated && c.Source == "PROD") && Reps.Any(c => c.Calculated && c.Source == "CUST")) + // { + + + + // sb.AppendLine($"PCBId;{item.Key};"); + // sb.AppendLine($"Date;{SbDate}"); + // sb.AppendLine($"Source;{SbSource}"); + // sb.AppendLine($"Core;{sbCore}"); + // sb.AppendLine($"CustomerName;{sbCustomerName}"); + // sb.AppendLine($"DrainedBatteryLoadPercent;{sbDrainedBatteryLoadPercent}"); + // sb.AppendLine($"DrainedBatteryLoad_uAs;{sbDrainedBatteryLoad_uAs}"); + // sb.AppendLine($"ExceededLifeTime_s;{sbExceededLifeTime_s}"); + // sb.AppendLine($"POWERMON_BatteryQuantity;{sbPOWERMON_BatteryQuantity}"); + // sb.AppendLine($"RemainingLifeTimeYears;{sbRemainingLifeTimeYears}"); + // sb.AppendLine($"FW;{sbFW}"); + // sb.AppendLine($"GENESISFLOW_LedMode;{sbGENESISFLOW_LedMode}"); + // sb.AppendLine($"GENESISFLOW_SampleRate;{sbGENESISFLOW_SampleRate}"); + // sb.AppendLine($"GENESISFLOW_ScaledBilling;{sbGENESISFLOW_ScaledBilling}"); + // sb.AppendLine($"IRDA_AdapterID;{sbIRDA_AdapterID}"); + // sb.AppendLine($"IRDA_PulseReportRate;{sbIRDA_PulseReportRate}"); + // sb.AppendLine($"METROLOGYASST_PulseEvenDistribution;{sbMETROLOGYASST_PulseEvenDistribution}"); + // sb.AppendLine($"METROLOGYASST_PulseLength;{sbMETROLOGYASST_PulseLength}"); + // sb.AppendLine($"METROLOGYASST_PulseMode;{sbMETROLOGYASST_PulseMode}"); + // sb.AppendLine($"METROLOGYASST_PulseResolution;{sbMETROLOGYASST_PulseResolution}"); + // sb.AppendLine($"METROLOGYASST_PulseWeight;{sbMETROLOGYASST_PulseWeight}"); + // } + + //} + //sb.AppendLine(); + //sb.AppendLine(); + //sb.AppendLine($"PCbID;LastProdDate;LastCUSTDate;TotalDays;LastProd_DrainedBatteryLoadPercent ;LastCUST_DrainedBatteryLoadPercent;LastProd_RemainingLifeTimeYears ;LastCUST_RemainingLifeTimeYears; "); + + //foreach (var item in listRes) + //{ + // if (item.Value.Any(c => c.Calculated && c.Source == "PROD") && item.Value.Any(c => c.Calculated && c.Source == "CUST")) + // { + // var LastProd = item.Value.First(f => f.DataDate == item.Value.Where(c => c.Source == "PROD").Max(m => m.DataDate)); + // var LastCUST = item.Value.First(f => f.DataDate == item.Value.Where(c => c.Source == "CUST").Max(m => m.DataDate)); + + // if (LastProd.DataDate < LastCUST.DataDate) + // { + // var ts = LastCUST.DataDate - LastProd.DataDate; + // sb.AppendLine($"{item.Key};{LastProd.DataDate};{LastCUST.DataDate };{ts.TotalDays};{LastProd.DrainedBatteryLoadPercent} ;{LastCUST.DrainedBatteryLoadPercent};{LastProd.RemainingLifeTimeYears} ;{LastCUST.RemainingLifeTimeYears}; "); + // } + + // } + + + //} + + //File.WriteAllText("output.csv", sb.ToString()); + Console.ReadLine(); + } + } +} diff --git a/Common/CordonelPreadjustmentUi/CordonelPreadjustmentUi.csproj b/Common/CordonelPreadjustmentUi/CordonelPreadjustmentUi.csproj index 19793ddb..26eefd3b 100644 --- a/Common/CordonelPreadjustmentUi/CordonelPreadjustmentUi.csproj +++ b/Common/CordonelPreadjustmentUi/CordonelPreadjustmentUi.csproj @@ -106,6 +106,9 @@ + + + ..\packages\Newtonsoft.Json.13.0.3\lib\net40\Newtonsoft.Json.dll diff --git a/Common/CordonelPreadjustmentUi/MeterStateControl.Designer.cs b/Common/CordonelPreadjustmentUi/MeterStateControl.Designer.cs index 2655e871..aec05c13 100644 --- a/Common/CordonelPreadjustmentUi/MeterStateControl.Designer.cs +++ b/Common/CordonelPreadjustmentUi/MeterStateControl.Designer.cs @@ -87,6 +87,7 @@ // nUD_TempField_Celsius // this.nUD_TempField_Celsius.Anchor = System.Windows.Forms.AnchorStyles.None; + this.nUD_TempField_Celsius.BackColor = System.Drawing.SystemColors.InactiveCaption; this.nUD_TempField_Celsius.DecimalPlaces = 1; this.nUD_TempField_Celsius.Increment = new decimal(new int[] { 1, diff --git a/Common/CordonelPreadjustmentUi/MeterStateControl.cs b/Common/CordonelPreadjustmentUi/MeterStateControl.cs index 7026c3de..c42192a5 100644 --- a/Common/CordonelPreadjustmentUi/MeterStateControl.cs +++ b/Common/CordonelPreadjustmentUi/MeterStateControl.cs @@ -7,6 +7,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; +using Xylem.Common.Hardware.WaterMeter.Genesis.Registers; using Xylem.Common.Logic.SoftwareAccessHelper; using Xylem.Common.Ui.CordonelPreadjustmentUi.Helper.Extensions; @@ -292,7 +293,7 @@ namespace CordonelPreadjustmentUi } - private TempMode MeterTempMode; + public TempMode MeterTempMode; private List> TempFromTofLUT; internal void StartTempWatch(TempMode tempMode = TempMode.Hand) { @@ -308,40 +309,24 @@ namespace CordonelPreadjustmentUi var pcbid = "notFound"; try { - pcbid = Meter.GetPcbId(); - if (string.IsNullOrEmpty(pcbid)) + + if (Meter.Slot == 11) { - pcbid = Meter.GetPcbId(); - if (string.IsNullOrEmpty(pcbid)) - { - if (Meter.Slot == 11) - { - pcbid = "193400550"; - Meter.WriteLog($"Fake pcbid {pcbid} for 2016 slot 11"); - } - else if (Meter.Slot == 12) - { - pcbid = "193400388"; - Meter.WriteLog($"Fake pcbid {pcbid} for 2016 slot 12"); - } - - } + pcbid = "193400032"; + OverridePassword = "42133FF3682D"; + Meter.WriteLog($"Fake pcbid {pcbid} for 2015 slot 11"); } - if (string.IsNullOrEmpty(pcbid) || pcbid.Length < 5 || pcbid.Length == "1934193400388".Length) + else if (Meter.Slot == 12) { - if (Meter.Slot == 11) - { - pcbid = "193400550"; - Meter.WriteLog($"Fake pcbid {pcbid} for 2016 slot 11"); - } - else if (Meter.Slot == 12) - { - pcbid = "193400388"; - Meter.WriteLog($"Fake pcbid {pcbid} for 2016 slot 12"); - } + pcbid = "193400550"; + OverridePassword = "42133FF37D41"; + Meter.WriteLog($"Fake pcbid {pcbid} for 2015 slot 12"); } - + //Meter.Login(OverridePassword); + //Meter.WriteRegister(Register.Genesisflow.TriggerIdle, 0); + //Meter.WriteRegister(Register.Genesisflow.LedMode, 6); + //Meter.WriteRegister(Register.Genesisflow.SampleRate, 10); var resp = LocalWebRequest.GetRequest($"http://10.49.40.25/MeterProcessState/api/TempFlange/GetLut?PcbId={pcbid}", 50000); diff --git a/Common/CordonelPreadjustmentUi/PreAdjustmentControl.Designer.cs b/Common/CordonelPreadjustmentUi/PreAdjustmentControl.Designer.cs index d89c69cc..4d29ba25 100644 --- a/Common/CordonelPreadjustmentUi/PreAdjustmentControl.Designer.cs +++ b/Common/CordonelPreadjustmentUi/PreAdjustmentControl.Designer.cs @@ -576,6 +576,7 @@ // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224))))); this.Controls.Add(this.lblBuildDate); this.Controls.Add(this.cb_Metersize); this.Controls.Add(this.l_SettingsPreparationMetersize); diff --git a/Common/CordonelPreadjustmentUi/PreAdjustmentControl.cs b/Common/CordonelPreadjustmentUi/PreAdjustmentControl.cs index 51bad287..b1aaedd6 100644 --- a/Common/CordonelPreadjustmentUi/PreAdjustmentControl.cs +++ b/Common/CordonelPreadjustmentUi/PreAdjustmentControl.cs @@ -88,6 +88,7 @@ namespace CordonelPreadjustmentUi TempMeterStateCtls.Add(ctl); gB_TempMeters.Controls.Add(ctl); ctl.OnRequestDetails += Ctl_MouseEnter; + ctl.DoubleClick += Clt_ReConnect; tmpI = tmpI + 1; ctl.Enabled = true; @@ -126,7 +127,6 @@ namespace CordonelPreadjustmentUi { } - private void Ctl_MouseEnter(object sender, EventArgs e) { if (sender is MeterStateControl meterStateCtl) @@ -146,6 +146,22 @@ namespace CordonelPreadjustmentUi } + private void Clt_ReConnect(object sender, EventArgs e) + { + if (sender is TempMeterStateControl meterStateCtl) + { + if (this.InvokeRequired) + { + this.Invoke((Action)Clt_ReConnect, sender, e); + return; + } + + meterStateCtl.StartTempWatch(meterStateCtl.MeterTempMode); + } + + + } + public void SetTestBenchTemp(double temp) { if (pp != null) @@ -1686,7 +1702,7 @@ namespace CordonelPreadjustmentUi listOfProgrammParts.Add(new FlushProcess("First Flush", StatusPanelItems.Detect, PredefinedMessages.WaitUntilFlushFinished(pp.Setting.Culture), string.Empty, 2 * 60)); - listOfProgrammParts.Add(new PressureTestProcess("PreussureTest", StatusPanelItems.Prepare, PredefinedMessages.WaitUntilPreparationFinished(pp.Setting.Culture), PredefinedMessages.PreparationFailed(pp.Setting.Culture), 1 * 60)); + //listOfProgrammParts.Add(new PressureTestProcess("PreussureTest", StatusPanelItems.Prepare, PredefinedMessages.WaitUntilPreparationFinished(pp.Setting.Culture), PredefinedMessages.PreparationFailed(pp.Setting.Culture), 1 * 60)); listOfProgrammParts.Add(new PreparationProcess("Preparation", StatusPanelItems.Prepare, PredefinedMessages.WaitUntilPreparationFinished(pp.Setting.Culture), PredefinedMessages.PreparationFailed(pp.Setting.Culture), 1 * 60)); diff --git a/Common/CordonelPreadjustmentUi/Processes/Actions/LoginProcess.cs b/Common/CordonelPreadjustmentUi/Processes/Actions/LoginProcess.cs index e1655050..f6dc68d4 100644 --- a/Common/CordonelPreadjustmentUi/Processes/Actions/LoginProcess.cs +++ b/Common/CordonelPreadjustmentUi/Processes/Actions/LoginProcess.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; +using Xylem.Common.Hardware.WaterMeter.Genesis.Registers; using static CordonelPreadjustmentUi.PreAdjustmentControl; namespace CordonelPreadjustmentUi.Processes.Actions @@ -34,8 +35,40 @@ namespace CordonelPreadjustmentUi.Processes.Actions if (pp.Setting.GetTempUseTempFlansh()) { - pp.DebugMessage($"Load Temp {tempmeterctl.Slot} with {MeterStateControl.TempMode.CalcTof}\n"); + if (tempmeterctl.Meter.Slot == 11) + { + + tempmeterctl.OverridePassword = "42133FF3682D"; + } + else if (tempmeterctl.Meter.Slot == 12) + { + + + tempmeterctl.OverridePassword = "42133FF37D41"; + + } + + + + var Result = string.IsNullOrEmpty(tempmeterctl.OverridePassword) + ? tempmeterctl.Meter.Login() + : tempmeterctl.Meter.Login(tempmeterctl.OverridePassword); + if (!Result) + { + if (!tempmeterctl.Meter.Login(tempmeterctl.OverridePassword)) + { + pp.DebugMessage($"Login to Flansch failed"); + pp.Aborted = true; + } + + } + Thread.Sleep(100); + + pp.DebugMessage($"Load Temp {tempmeterctl.Slot} with {MeterStateControl.TempMode.CalcTof}\n"); + tempmeterctl.Meter.WriteRegister(Register.Genesisflow.TriggerIdle, 0); + tempmeterctl.Meter.WriteRegister(Register.Genesisflow.LedMode, 6); + tempmeterctl.Meter.WriteRegister(Register.Genesisflow.SampleRate, 10); try { tempmeterctl.StartTempWatch(MeterStateControl.TempMode.CalcTof); @@ -104,6 +137,7 @@ namespace CordonelPreadjustmentUi.Processes.Actions meterctl.Failed = !Result; if (!Result) { + pp.DebugMessage($"{ProcessName} procedure failed", meterctl.Slot, "APP", meterctl.Meter.PcbId); //pp.GenerateReturnNote(PredefinedMessages.LoginFailed(pp.Setting.Culture), meterctl); } diff --git a/Common/CordonelPreadjustmentUi/Processes/Actions/TemperatureCalibrationProcess.cs b/Common/CordonelPreadjustmentUi/Processes/Actions/TemperatureCalibrationProcess.cs index a040769a..a2e452eb 100644 --- a/Common/CordonelPreadjustmentUi/Processes/Actions/TemperatureCalibrationProcess.cs +++ b/Common/CordonelPreadjustmentUi/Processes/Actions/TemperatureCalibrationProcess.cs @@ -51,7 +51,7 @@ namespace CordonelPreadjustmentUi.Processes.Actions foreach (var avgTempCtls in listOFEnabledTempMeters) { var check = avgTempCtls.GetTemperature(); - if (check > 2 || ((double)check) != 25.0d ) + if (check > 5 && (double)check != 25.0d ) { avgTemp = avgTemp + avgTempCtls.GetTemperature(); TempFlanshCount = TempFlanshCount + 1; @@ -61,7 +61,11 @@ namespace CordonelPreadjustmentUi.Processes.Actions } if (TempFlanshCount == 0) { + System.Windows.Forms.MessageBox.Show("Fehler beim auslesen der TemperaturFlansche. Bitte per Hand eingeben"); skipMan = false; + + pp.RequestTempretureSelection(); + } else { @@ -80,12 +84,12 @@ namespace CordonelPreadjustmentUi.Processes.Actions //manual input foreach (var meterctl in MetersToProcess) { - meterctl.SetTemperature((decimal)25.0); + meterctl.SetTemperature((decimal)0); } pp.RequestTemperatur(); foreach (var meterctl in TempMeterStateCtls) { - meterctl.SetTemperature((decimal)25.0); + meterctl.SetTemperature((decimal)0); meterctl.OnTempretureChangedHandler += delegate (Object sender, EventArgsDecimal d) { decimal avgTemp = 0; @@ -144,6 +148,11 @@ namespace CordonelPreadjustmentUi.Processes.Actions { var originTemp = putTempIntoMeter.GetTemperature(); + if (originTemp == (decimal)25.0 || originTemp == (decimal)1 || originTemp == (decimal)0) + { + pp.DebugMessage($"Temperature check failed - default", putTempIntoMeter.Meter.Slot, "APP", putTempIntoMeter.Meter.PcbId); + return false; + } UInt32 TempToRegister = (UInt32)(originTemp * 4096); #region Set temperature calibration register diff --git a/Common/CordonelPreadjustmentUi/Processes/ProcessProgress.cs b/Common/CordonelPreadjustmentUi/Processes/ProcessProgress.cs index f12882b3..4446bbf3 100644 --- a/Common/CordonelPreadjustmentUi/Processes/ProcessProgress.cs +++ b/Common/CordonelPreadjustmentUi/Processes/ProcessProgress.cs @@ -102,7 +102,7 @@ namespace CordonelPreadjustmentUi.Processes.Itinerary public event EventHandler OnBubblesChanged; public event EventHandler OnRequestTempretureSelection; - internal void RequestTempretureSelection() + public void RequestTempretureSelection() { if (OnRequestTempretureSelection == null) { diff --git a/Common/Hardware/Interfaces/Protocols/TransmitProtocol/LedTransmitProtocol.cs b/Common/Hardware/Interfaces/Protocols/TransmitProtocol/LedTransmitProtocol.cs index 5ed21f63..29355685 100644 --- a/Common/Hardware/Interfaces/Protocols/TransmitProtocol/LedTransmitProtocol.cs +++ b/Common/Hardware/Interfaces/Protocols/TransmitProtocol/LedTransmitProtocol.cs @@ -36,6 +36,12 @@ namespace Xylem.Common.Hardware.Interfaces.Protocols.TransmitProtocol _receiveBufferFlushThreshold); } + public TransmitPortSettings GetTransmitPortSettings(UInt32 baudRate) + { + return new TransmitPortSettings(_protSyncByte, _protLengthIndex, ProtAddLength, _responseTimeoutMs, baudRate, + _receiveBufferFlushThreshold); + } + /// public override List DecodeDataForPhysicalLayer(String ident, Byte command, Byte[] payload, Boolean hideDataInLog = false) { diff --git a/Common/Hardware/WaterMeter/Genesis/GenesisCore/GenesisMeter.cs b/Common/Hardware/WaterMeter/Genesis/GenesisCore/GenesisMeter.cs index 9be51d7f..d7ac1dad 100644 --- a/Common/Hardware/WaterMeter/Genesis/GenesisCore/GenesisMeter.cs +++ b/Common/Hardware/WaterMeter/Genesis/GenesisCore/GenesisMeter.cs @@ -2051,7 +2051,10 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore try { - Logout(); + //todo only from Bench + //WriteRegister(Register.Genesisflow.SampleRate, 2, checkRegister: true); + //WriteRegister(Register.Genesisflow.LedMode, 0, checkRegister: true); + //Logout(); } catch (Exception) { @@ -2431,6 +2434,14 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore } } } + + public void TestBenchDispose() + { + if (IsLoggedOn) + { + + } + } #endregion } } \ No newline at end of file diff --git a/Common/Hardware/WaterMeter/Genesis/GenesisCore/_GenesisMeterMeasurement.cs b/Common/Hardware/WaterMeter/Genesis/GenesisCore/_GenesisMeterMeasurement.cs index 3f80239f..07293149 100644 --- a/Common/Hardware/WaterMeter/Genesis/GenesisCore/_GenesisMeterMeasurement.cs +++ b/Common/Hardware/WaterMeter/Genesis/GenesisCore/_GenesisMeterMeasurement.cs @@ -47,7 +47,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore { if (!SkipPreparationForTestBench) { - SkipPreparationForTestBench = true; + //SkipPreparationForTestBench = true; //TODO set display unit //TODO calculated overflow volume for display WriteRegister(Register.Genesisflow.SampleRate, 16, checkRegister: true); diff --git a/Common/Hardware/WaterMeter/Genesis/GenesisPwd/MeterPwdHandlerDb.cs b/Common/Hardware/WaterMeter/Genesis/GenesisPwd/MeterPwdHandlerDb.cs index 785ab928..9336541c 100644 --- a/Common/Hardware/WaterMeter/Genesis/GenesisPwd/MeterPwdHandlerDb.cs +++ b/Common/Hardware/WaterMeter/Genesis/GenesisPwd/MeterPwdHandlerDb.cs @@ -103,7 +103,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisPwd { var url = ServiceUrls.GenesisGetPasswordContainerServiceUrl(); - var requestResponse = LocalWebRequest.GetRequestWithError(url + pcbId, out var errorCode, 20000, isRetry: true); + var requestResponse = LocalWebRequest.GetRequestWithError(url + pcbId, out var errorCode, 30000, isRetry: true); if (errorCode == HttpStatusCode.OK.GetHashCode()) { passwordContainer = JsonConvert.DeserializeObject(requestResponse); diff --git a/Common/Hardware/WaterMeter/Genesis/GenesisStatus/GenesisStatus.cs b/Common/Hardware/WaterMeter/Genesis/GenesisStatus/GenesisStatus.cs index aff1d0a8..9e94084d 100644 --- a/Common/Hardware/WaterMeter/Genesis/GenesisStatus/GenesisStatus.cs +++ b/Common/Hardware/WaterMeter/Genesis/GenesisStatus/GenesisStatus.cs @@ -123,5 +123,8 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisStatus /// Date of approval. /// public DateTime ApprovalDate; + + public Double UNTLimit { get; internal set; } = 0; + public Boolean UNTStatus { get; internal set; } = false; } } diff --git a/Common/Hardware/WaterMeter/Genesis/GenesisStatus/GenesisStatusHandler.cs b/Common/Hardware/WaterMeter/Genesis/GenesisStatus/GenesisStatusHandler.cs index f9e8a0a1..e8a77525 100644 --- a/Common/Hardware/WaterMeter/Genesis/GenesisStatus/GenesisStatusHandler.cs +++ b/Common/Hardware/WaterMeter/Genesis/GenesisStatus/GenesisStatusHandler.cs @@ -136,6 +136,8 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisStatus // convert the seconds to years status.RemainingLifeTimeYears = remainingLifetime_s / 3600 / 24 / 365.25; + status.UNTLimit = 1368000000 + (status.ExceededLifeTime_s * 77.7); + status.UNTStatus = status.UNTLimit >= status.DrainedBatteryLoad_uAs; return retVal; } } diff --git a/Common/Hardware/WaterMeter/MagFlux/MagFluxCore/MagFluxMeter.cs b/Common/Hardware/WaterMeter/MagFlux/MagFluxCore/MagFluxMeter.cs index 5f3ce627..c39d1be9 100644 --- a/Common/Hardware/WaterMeter/MagFlux/MagFluxCore/MagFluxMeter.cs +++ b/Common/Hardware/WaterMeter/MagFlux/MagFluxCore/MagFluxMeter.cs @@ -1232,6 +1232,11 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.MagFluxCore } } } + + public void TestBenchDispose() + { + //nothing to do + } #endregion } } diff --git a/Common/Hardware/WaterMeter/MagFlux/Protocols/StreamingProtocol/StreamingDecoder.cs b/Common/Hardware/WaterMeter/MagFlux/Protocols/StreamingProtocol/StreamingDecoder.cs index f687ba7e..23e054a8 100644 --- a/Common/Hardware/WaterMeter/MagFlux/Protocols/StreamingProtocol/StreamingDecoder.cs +++ b/Common/Hardware/WaterMeter/MagFlux/Protocols/StreamingProtocol/StreamingDecoder.cs @@ -34,7 +34,7 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.Protocols.StreamingProtocol /// private readonly MagFluxRecord _dataMagFluxDefault = new MagFluxRecord { - VolumeCm = 0.0, + VolumeCm = 0.0, ForwardVolumeCm = 0.0, NegativeReverseVolumeCm = 0.0, TimeS = 0.0, @@ -43,7 +43,7 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.Protocols.StreamingProtocol UniqueId = "?", SensorId = "?", Crc = 0xFFFF, - OverflowVolumeCm = DefaultMagFluxOverflowVolumeCm, + OverflowVolumeCm = DefaultMagFluxOverflowVolumeCm, OverflowTimeS = CpuTimeOverflowS, IsValid = false }; @@ -158,7 +158,7 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.Protocols.StreamingProtocol } break; - } + } } catch (Exception) { @@ -201,7 +201,7 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.Protocols.StreamingProtocol // parse the floating point value of the flow rate which is a string containing the hex value as 32 bit var hex = UInt32.Parse(fields[(Int32)ProtLsubString.FlowRate], NumberStyles.AllowHexSpecifier); var floatValues = BitConverter.GetBytes(hex); - dataMagFluxRec.FlowRateCmPh = BitConverter.ToSingle(floatValues, 0) * + dataMagFluxRec.FlowRateCmPh = BitConverter.ToSingle(floatValues, 0) * LitersPerSecondToCmPerHourFactor; // get status and identifiers @@ -230,4 +230,4 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.Protocols.StreamingProtocol Crc } } -} \ No newline at end of file +} diff --git a/Common/Hardware/WaterMeter/WaterMeterCore/BatchActions/BatchCallTestBenchDispose.cs b/Common/Hardware/WaterMeter/WaterMeterCore/BatchActions/BatchCallTestBenchDispose.cs new file mode 100644 index 00000000..63d3bb98 --- /dev/null +++ b/Common/Hardware/WaterMeter/WaterMeterCore/BatchActions/BatchCallTestBenchDispose.cs @@ -0,0 +1,12 @@ +namespace Xylem.Common.Hardware.WaterMeter.WaterMeterCore.BatchActions +{ + /// + public class BatchCallTestBenchDispose: BatchCall + { + /// + public override void DoSingleAction(IMeter meter) + { + meter.TestBenchDispose(); + } + } +} diff --git a/Common/Hardware/WaterMeter/WaterMeterCore/IMeter.cs b/Common/Hardware/WaterMeter/WaterMeterCore/IMeter.cs index b34b1a08..72ca84b0 100644 --- a/Common/Hardware/WaterMeter/WaterMeterCore/IMeter.cs +++ b/Common/Hardware/WaterMeter/WaterMeterCore/IMeter.cs @@ -282,6 +282,6 @@ namespace Xylem.Common.Hardware.WaterMeter.WaterMeterCore /// Clear all object set up on runtime /// void DisposeMeter(); - + void TestBenchDispose(); } } \ No newline at end of file diff --git a/Common/Hardware/WaterMeter/WaterMeterCore/MeterBatch.cs b/Common/Hardware/WaterMeter/WaterMeterCore/MeterBatch.cs index 86ee18e3..793a9c9e 100644 --- a/Common/Hardware/WaterMeter/WaterMeterCore/MeterBatch.cs +++ b/Common/Hardware/WaterMeter/WaterMeterCore/MeterBatch.cs @@ -247,5 +247,11 @@ namespace Xylem.Common.Hardware.WaterMeter.WaterMeterCore } } + public void DisposeTestBench() + { + _logger.Info("Dispose batch make sure green LED is off"); + var batchCall = new BatchCallStopMeasurement(); + batchCall.RunAction(ListOfMeters); + } } } \ No newline at end of file diff --git a/Common/Hardware/WaterMeter/WaterMeterCore/WaterMeterCore.csproj b/Common/Hardware/WaterMeter/WaterMeterCore/WaterMeterCore.csproj index fb4040ce..69d96c85 100644 --- a/Common/Hardware/WaterMeter/WaterMeterCore/WaterMeterCore.csproj +++ b/Common/Hardware/WaterMeter/WaterMeterCore/WaterMeterCore.csproj @@ -254,6 +254,7 @@ + diff --git a/Common/Hardware/WaterMeter/WaterMeterCore/WaterMeterRegisters/obj/Debug/WaterMeterRegisters.csproj.CoreCompileInputs.cache b/Common/Hardware/WaterMeter/WaterMeterCore/WaterMeterRegisters/obj/Debug/WaterMeterRegisters.csproj.CoreCompileInputs.cache index 82bc2c16..d110f5fc 100644 --- a/Common/Hardware/WaterMeter/WaterMeterCore/WaterMeterRegisters/obj/Debug/WaterMeterRegisters.csproj.CoreCompileInputs.cache +++ b/Common/Hardware/WaterMeter/WaterMeterCore/WaterMeterRegisters/obj/Debug/WaterMeterRegisters.csproj.CoreCompileInputs.cache @@ -1 +1 @@ -bf6bb8fceb3db5a9977dadc407cf576684bf7127 +c43c40a030005a8f189e6179faf40a6d42bfef5c diff --git a/Common/Hardware/WaterMeter/eRegister/DataPackages/DataPackages.csproj b/Common/Hardware/WaterMeter/eRegister/DataPackages/DataPackages.csproj new file mode 100644 index 00000000..ffbb89a4 --- /dev/null +++ b/Common/Hardware/WaterMeter/eRegister/DataPackages/DataPackages.csproj @@ -0,0 +1,71 @@ + + + + + Debug + AnyCPU + {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478} + Library + Properties + Xylem.Common.Hardware.WaterMeter.ERegister.DataPackages + Xylem.Common.Hardware.WaterMeter.ERegister.DataPackages + v4.8 + 512 + true + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + false + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + false + + + + ..\..\..\..\packages\Newtonsoft.Json.13.0.3\lib\net40\Newtonsoft.Json.dll + + + + + + + + + + + + + + + + + {1B02C79E-0B19-43E2-8F6B-71EF0C786C97} + CommonCore + + + {6CCDB656-C676-4360-BABA-C4596AAD175D} + Measurements + + + {8bdd2789-96d4-43ea-aad7-0f49d0347998} + ProtocolCore + + + + + + + \ No newline at end of file diff --git a/Common/Hardware/WaterMeter/eRegister/DataPackages/ERegisterFlowDataEventArgs.cs b/Common/Hardware/WaterMeter/eRegister/DataPackages/ERegisterFlowDataEventArgs.cs new file mode 100644 index 00000000..76571285 --- /dev/null +++ b/Common/Hardware/WaterMeter/eRegister/DataPackages/ERegisterFlowDataEventArgs.cs @@ -0,0 +1,20 @@ +using System; +using Xylem.Common.Hardware.Interfaces.Protocols.ProtocolCore.EventArguments; + +namespace Xylem.Common.Hardware.WaterMeter.ERegister.DataPackages.EventArguments +{ + /// + public class ERegisterFlowDataEventArgs : BaseDataEventArgs + { + /// + /// new record from Stream + /// + public MeasurementRecords.ERegisterRecord NewData; + + /// + public override Object GetEventData() + { + return NewData; + } + } +} \ No newline at end of file diff --git a/Common/Hardware/WaterMeter/eRegister/DataPackages/MeasurementRecords.cs b/Common/Hardware/WaterMeter/eRegister/DataPackages/MeasurementRecords.cs new file mode 100644 index 00000000..3e492920 --- /dev/null +++ b/Common/Hardware/WaterMeter/eRegister/DataPackages/MeasurementRecords.cs @@ -0,0 +1,55 @@ +using System; +using System.Text; +using Xylem.Common.Metrology.Measurements; + +namespace Xylem.Common.Hardware.WaterMeter.ERegister.DataPackages.MeasurementRecords +{ + /// + /// + /// struct to hold Led record for protocol L (contains measurement record) + /// + public class ERegisterRecord : MeasurementRecord + { + + /// + /// Serial number of MagFlux + /// + public String UniqueId; + + /// + /// Status of sensor and electronics + /// + public UInt32 StatusBits; + + /// + /// String delimiter to separate elements in ToString() routine + /// + private const String StringDelimiter = "; \n"; + + /// + /// Get result as string + /// + /// + public override String ToString() + { + var sb = new StringBuilder(); + sb = sb.Append($"Volume [m³]: {VolumeCm}").Append(StringDelimiter) + .Append($"Negative Reverse Volume [m³]: {NegativeReverseVolumeCm}").Append(StringDelimiter) + .Append($"CPU Time [s]: {TimeS}").Append(StringDelimiter) + .Append($"FlowRate [m³/h]: {FlowRateCmPh}").Append(StringDelimiter) + .Append($"Status: 0x{StatusBits:X8}").Append(StringDelimiter) + .Append($"UniqueId: {UniqueId}").Append(StringDelimiter) + .Append($"CRC: 0x{Crc:X4}").Append(StringDelimiter) + .Append($"OverflowVolume [m³]: {OverflowVolumeCm}").Append(StringDelimiter) + .Append($"OverflowTime [s]: {OverflowTimeS}").Append(StringDelimiter) + .Append($"IsValid: {IsValid}").Append(StringDelimiter) + .Append($"ReceivedTime [UTC]: {ReceivedTime}").Append(StringDelimiter) + .Append($"DecodedTime [UTC]: {DecodedTime}").Append(StringDelimiter) + .Append($"SyncMarkRecord: {SyncMarkRecord}"); + return sb.ToString(); + } + + public long PcbID { get; set; } + public long Radio { get; set; } + } +} diff --git a/Common/Hardware/WaterMeter/eRegister/DataPackages/Properties/AssemblyInfo.cs b/Common/Hardware/WaterMeter/eRegister/DataPackages/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..0b651b8c --- /dev/null +++ b/Common/Hardware/WaterMeter/eRegister/DataPackages/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 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("DataPackages")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("DataPackages")] +[assembly: AssemblyCopyright("Copyright © 2023")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("c2808a8e-c0ba-44ec-b7b1-1c66ad3d8478")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Common/Hardware/WaterMeter/eRegister/DataPackages/packages.config b/Common/Hardware/WaterMeter/eRegister/DataPackages/packages.config new file mode 100644 index 00000000..121d3593 --- /dev/null +++ b/Common/Hardware/WaterMeter/eRegister/DataPackages/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Common/Hardware/WaterMeter/eRegister/Protocols/Properties/AssemblyInfo.cs b/Common/Hardware/WaterMeter/eRegister/Protocols/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..41621a5d --- /dev/null +++ b/Common/Hardware/WaterMeter/eRegister/Protocols/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 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("Xylem.Common.Hardware.WaterMeter.MagFlux.Protocols.StreamingProtocol")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Xylem")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("Copyright © Xylem 2023")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("d6b81c60-2763-4c4d-989f-90822f53b01a")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Common/Hardware/WaterMeter/eRegister/Protocols/StreamingDecoder.cs b/Common/Hardware/WaterMeter/eRegister/Protocols/StreamingDecoder.cs new file mode 100644 index 00000000..52e6f651 --- /dev/null +++ b/Common/Hardware/WaterMeter/eRegister/Protocols/StreamingDecoder.cs @@ -0,0 +1,219 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using Xylem.Common.Hardware.WaterMeter.ERegister.DataPackages.MeasurementRecords; + +using Xylem.Common.Utils.Crc16Ccitt; + +namespace Xylem.Common.Hardware.WaterMeter.eRegister.Protocols.StreamingProtocol +{ + /// + /// Data fields and definitions for GENESIS streaming protocol + /// + public class StreamingDecoder + { + private const Double MilliLitersToCmFactor = 1.0E-6; + private const Double CpuTimeToSecondsFactor = 1.0 / 0x10000; + private const Double CpuTimeOverflowS = 0x100000000 * CpuTimeToSecondsFactor; + private const Double LitersPerSecondToCmPerHourFactor = 3600.0 / 1000.0; + + private const Double DefaultVolumeScaleRawPerMl = 1024.0; + private const Double DefaultVolumeFactorRawToCm = MilliLitersToCmFactor / DefaultVolumeScaleRawPerMl; + private const Double MaxGenesisAccuVolumeRaw = UInt32.MaxValue; //0x100000000; //2^32 + private const Double DefaultAccuDutOverflowVolumeCm = MaxGenesisAccuVolumeRaw * DefaultVolumeFactorRawToCm; + + private const Double DisplayMlSetupDutOverflowVolumeCm = 1000.0; //overflow of LCD if set to ml + private const Double TofToSecondsFactor38Bit = 1.0 / 0x4000000000; // 2^38 + private const Double AmplitudeToVoltFactor = 1.0 / 0x400000 / 1000.0; // 2^22 100 0000 0000 0000 0000 0000b + private const Double PulseWidthToRelFactor = 1.0 / 0x100; // 2^8 + + //// protocol 'l' MagFlux + private const Double MaxMagFluxVolumeRaw = UInt64.MaxValue;//0x10000000000000000; //2^64 + private const Double DefaultMagFluxOverflowVolumeCm = MaxMagFluxVolumeRaw / MilliLitersToCmFactor; + ///// + ///// Default data for + ///// + private readonly ERegisterRecord _dataeRegisterDefault = new ERegisterRecord + { + VolumeCm = 0.0, + ForwardVolumeCm = 0.0, + NegativeReverseVolumeCm = 0.0, + TimeS = 0.0, + FlowRateCmPh = 0.0, + StatusBits = 0, + UniqueId = "?", + Crc = 0xFFFF, + OverflowVolumeCm = DefaultMagFluxOverflowVolumeCm, + OverflowTimeS = CpuTimeOverflowS, + IsValid = false + }; + + private ERegisterRecord _dataERegisterRec; + private readonly Boolean _ignoreCorruptedData; + private String _pcbIdMask; + private String _uniqueIdMask; + + /// + /// Constructor initializes all decoded members with default values + /// + public StreamingDecoder(Boolean ignoreCorruptedData = true) + { + _dataERegisterRec = _dataeRegisterDefault; + _ignoreCorruptedData = ignoreCorruptedData; + } + + /// + /// Data of MagFlux + /// + public ERegisterRecord dataERegister + { + get; private set; + } + + /// + /// Set decoding mask for streaming protocol, wipes out all not matching records: + /// - PcbIdMask equals the sensor serial no + /// - UniqueIdMask + /// + /// + /// + /// true if decoding was successful and data has been validated + /// + /// - Initial. + /// + public void SetDecodingMask(String pcbIdMask, String uniqueIdMask) + { + // the pcbId equals the sensorSn + _pcbIdMask = pcbIdMask; + _uniqueIdMask = uniqueIdMask; + } + + +////' Berechnung der Checksumme vom eRegister Optotelegramm +////' Input "Val 1] \t [Val 2] \t [Val 3] \t [Val 4] \t" ohne "CS" und CrLf !! +////' Output 2-Byte Hex Wert: +//private string CalculateCheckSum(strBytes) +// Dim i As Integer +// Dim iChecksum As Long +// iChecksum = 0 +// ' Bytesum([ Val 1 ] \t [ Val 2] \t [ Val 3] \t [ Val 4] \t) & 0xFF +// For i = 1 To Len(strBytes) - 2 +// ''Debug.Print i & ": " & Mid(strBytes, i, 1) & " = " & Asc(Mid(strBytes, i, 1)) & " sum=" & iChecksum +// iChecksum = iChecksum + Asc(Mid(strBytes, i, 1)) +// Next +// ' (only one byte, higher bits will be cut off). +// iChecksum = iChecksum And 255 +// ' This binary 1-byte value is then converted into two ASCII bytes +// CalculateCheckSum = Right("0" & Hex(iChecksum), 2) +//End Function + + + + /// + /// Decoding the raw message + /// + /// message received as one line delimited with LF + /// true if decoding was successful and data has been validated + /// + /// - Modified using common CRC check before branching to the protocol specific decoder. + /// + /// + /// - Introduced reverse volume. + /// + public Boolean DecodeMsg(String rawMsg) + { + var rawRecordIsValid = false; + try + { + //MagFlux test string: + //rawMsg = "@l 1bd911f 0 95b8d4 40cf9b5c 0 26004f5232500120373235 0 5863" + //Protocol version, DUT:Vol FWD [mL], DUT: Vol REV [ml], DUT:Time [s], DUT:Flow_LPS, DUT:StatusBitsHex, + //l, 29200671, 0, 149.7219849, 6.487714767, 0, + //DUT:UniqueId, DUT:SensorId, DUT:CRC + //4.59406E+25, 0, 22627 (0x5863) + + // The received message is a string with a line delimiter. + rawMsg = rawMsg.Replace('\t', ' '); + + //// The raw message fields are the separated values from the received string with a blank as field separator + var rawMsgFields = rawMsg.Split(' '); + dataERegister = new ERegisterRecord(); + if (rawMsgFields.Length == 5) + { + dataERegister.PcbID = long.Parse(rawMsgFields[0]); + + dataERegister.Radio = long.Parse(rawMsgFields[1]); + + dataERegister.VolumeCm = double.Parse(rawMsgFields[2]) / 1000 / 1000; + + dataERegister.TimeS = double.Parse(rawMsgFields[3]) / 1000; + + + + + dataERegister.Crc = ushort.Parse(rawMsgFields[4]); + rawRecordIsValid = true; + dataERegister.IsValid = rawRecordIsValid; + return rawRecordIsValid; + } + else + { + return rawRecordIsValid; + } + // PCB ID - RADIO - Vol - Time -CS + + + //// The last element is the CRC, the CRC can be separated, calculated and validated before trying to decode the content + //var rawRecordForCrc = ""; + //// get all fields excluding the CRC (length - 1) + //for (var x = 0; x < rawMsgFields.Length - 1; x++) + //{ + // rawRecordForCrc += rawMsgFields[x]; + // // add the field delimiter from raw data + // rawRecordForCrc += " "; + //} + + //// extract bytes of raw message for CRC calculation each character, CRC field is already removed + //var byteArraySize = rawRecordForCrc.Length; + //var byteArray = new Byte[byteArraySize]; + //for (var i = 0; i < byteArraySize; i++) + //{ + // byteArray[i] = (Byte)rawRecordForCrc[i]; + //} + + //// calculate the CRC from the received data + //var calculatedCrc = Crc16Ccitt.CalculateMsb1021(byteArray); + + //// extract received CRC + //var receivedCrc = UInt16.Parse(rawMsgFields[rawMsgFields.Length - 1], NumberStyles.HexNumber); + + //// compare received with calculated CRC and remind valid decoding + //rawRecordIsValid = calculatedCrc == receivedCrc; + + //switch (rawMsgFields[0]) + //{ + // case "@l": + // if (rawRecordIsValid || !_ignoreCorruptedData) + // { + // DecodeProtocolL(ref _dataMagFluxRec, rawMsgFields); + // if (string.Equals(_uniqueIdMask, _dataMagFluxRec.UniqueId) && + // string.Equals(_pcbIdMask, _dataMagFluxRec.SensorId)) + // { + // DataMagFlux = _dataMagFluxRec; + // _dataMagFluxRec.IsValid = rawRecordIsValid; + // } + // } + // break; + + // } + } + catch (Exception) + { + // ignored + } + return rawRecordIsValid; + } + + + } +} \ No newline at end of file diff --git a/Common/Hardware/WaterMeter/eRegister/Protocols/StreamingProtocol.cs b/Common/Hardware/WaterMeter/eRegister/Protocols/StreamingProtocol.cs new file mode 100644 index 00000000..1de6cbde --- /dev/null +++ b/Common/Hardware/WaterMeter/eRegister/Protocols/StreamingProtocol.cs @@ -0,0 +1,82 @@ +using System; +using Xylem.Common.Hardware.Interfaces.Ports.PortCore.EventArguments; +using Xylem.Common.Hardware.Interfaces.Protocols.ProtocolCore; +using Xylem.Common.Hardware.Interfaces.Protocols.ProtocolCore.EventArguments; +using Xylem.Common.Hardware.WaterMeter.ERegister.DataPackages; + +namespace Xylem.Common.Hardware.WaterMeter.eRegister.Protocols.StreamingProtocol +{ + /// + /// + /// Layer between CRC16CCITT handler and Events + /// block trashy telegrams + /// + public class StreamingProtocol : BaseProtocol + { + + /// + /// Decode data and hold results + /// + private StreamingDecoder _streamingDecode; + private readonly Boolean _ignoreCorruptedData; + private String _pcbIdMask; + private String _uniqueIdMask; + + /// + public override event EventHandler OnRecordIsDecoded; + + /// + /// Set decoding mask for streaming protocol, wipes out all not matching records: + /// - PcbIdMask equals the sensor serial no + /// - UniqueIdMask + /// + /// + /// + /// true if decoding was successful and data has been validated + /// + /// - Initial. + /// + public void SetDecodingMask(String pcbIdMask, String uniqueIdMask) + { + // the pcbId equals the sensorSn + _pcbIdMask = pcbIdMask; + _uniqueIdMask = uniqueIdMask; + } + /// + protected override void DecodeRecord(IPortDataEventArgs dataArgs) + { + var data = (String)dataArgs.GetData(); + + //Data decoding + _streamingDecode = new StreamingDecoder(_ignoreCorruptedData); + _streamingDecode.DecodeMsg(data); + + //Event for new data + if (_streamingDecode.dataERegister != null) + { + _streamingDecode.dataERegister.SyncMarkRecord = dataArgs.GetSyncMarkRecord(); + _streamingDecode.dataERegister.ReceivedTime = dataArgs.GetReceivedTime(); + + if (_streamingDecode.dataERegister.IsValid) + { + OnRecordIsDecoded?.Invoke(this, + new ERegister.DataPackages.EventArguments.ERegisterFlowDataEventArgs { NewData = _streamingDecode.dataERegister, RawData = data }); + } + else if (!_ignoreCorruptedData) + { + OnRecordIsDecoded?.Invoke(this, + new ERegister.DataPackages.EventArguments.ERegisterFlowDataEventArgs { NewData = _streamingDecode.dataERegister, RawData = data }); + } + + } + + //toDo: handle trashy telegrams + } + + /// + public StreamingProtocol(String ident, Boolean ignoreCorruptedData = true) : base(ident) + { + _ignoreCorruptedData = ignoreCorruptedData; + } + } +} \ No newline at end of file diff --git a/Common/Hardware/WaterMeter/eRegister/Protocols/StreamingProtocol.csproj b/Common/Hardware/WaterMeter/eRegister/Protocols/StreamingProtocol.csproj new file mode 100644 index 00000000..fa3e8685 --- /dev/null +++ b/Common/Hardware/WaterMeter/eRegister/Protocols/StreamingProtocol.csproj @@ -0,0 +1,86 @@ + + + + + Debug + AnyCPU + {B6A19B80-0F0F-434C-A754-A7712FC208B2} + Library + Properties + Xylem.Common.Hardware.WaterMeter.MagFlux.Protocols.StreamingProtocol + Xylem.Common.Hardware.WaterMeter.MagFlux.Protocols.StreamingProtocol + v4.8 + 512 + true + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\..\..\..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll + + + ..\..\..\..\..\packages\NLog.5.2.2\lib\net46\NLog.dll + + + + + + + + + + + + + + + + + + + + {1B02C79E-0B19-43E2-8F6B-71EF0C786C97} + CommonCore + + + {6CCDB656-C676-4360-BABA-C4596AAD175D} + Measurements + + + {91DEF0C0-AA4F-40AE-8F18-CB717FDE7E7F} + Crc16Ccitt + + + {2E139F63-B6FE-4EA9-A098-85364FE9B26C} + PortCore + + + {8BDD2789-96D4-43EA-AAD7-0F49D0347998} + ProtocolCore + + + {c2808a8e-c0ba-44ec-b7b1-1c66ad3d8478} + DataPackages + + + + + + + \ No newline at end of file diff --git a/Common/Hardware/WaterMeter/eRegister/Protocols/packages.config b/Common/Hardware/WaterMeter/eRegister/Protocols/packages.config new file mode 100644 index 00000000..e07979d0 --- /dev/null +++ b/Common/Hardware/WaterMeter/eRegister/Protocols/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/Common/Hardware/WaterMeter/eRegister/eRegisterCore/Properties/AssemblyInfo.cs b/Common/Hardware/WaterMeter/eRegister/eRegisterCore/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..38c25291 --- /dev/null +++ b/Common/Hardware/WaterMeter/eRegister/eRegisterCore/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 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("eRegisterCore")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("eRegisterCore")] +[assembly: AssemblyCopyright("Copyright © 2023")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("a83696bf-d8a2-4809-8424-cfe172aed5b6")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Common/Hardware/WaterMeter/eRegister/eRegisterCore/eRegisterCore.csproj b/Common/Hardware/WaterMeter/eRegister/eRegisterCore/eRegisterCore.csproj new file mode 100644 index 00000000..61c99b6e --- /dev/null +++ b/Common/Hardware/WaterMeter/eRegister/eRegisterCore/eRegisterCore.csproj @@ -0,0 +1,106 @@ + + + + + Debug + AnyCPU + {A83696BF-D8A2-4809-8424-CFE172AED5B6} + Library + Properties + Xylem.Common.Hardware.WaterMeter.eRegister.eRegisterCore + Xylem.Common.Hardware.WaterMeter.eRegister.eRegisterCore + v4.8 + 512 + true + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + false + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + false + + + + ..\..\..\..\packages\Newtonsoft.Json.13.0.3\lib\net40\Newtonsoft.Json.dll + + + ..\..\..\..\packages\NLog.5.2.2\lib\net35\NLog.dll + + + + + + + + + + + + + + + + + {1B02C79E-0B19-43E2-8F6B-71EF0C786C97} + CommonCore + + + {6CCDB656-C676-4360-BABA-C4596AAD175D} + Measurements + + + {a33e3c6d-eaae-4a20-a0ee-f9e6922fd029} + SoftwareAccessHelper + + + {4b88b0d3-e791-4774-9521-eabeacdc420e} + Logging + + + {2E139F63-B6FE-4EA9-A098-85364FE9B26C} + PortCore + + + {72037e89-4f63-4b3f-beff-4138e578ce99} + SerialPorts + + + {8BDD2789-96D4-43EA-AAD7-0F49D0347998} + ProtocolCore + + + {63E0AC5E-B7C8-4363-A2FE-BE489E648FF0} + TransmitProtocol + + + {8203abb8-38e5-472e-a742-33f38b7a74a6} + WaterMeterCore + + + {C2808A8E-C0BA-44EC-B7B1-1C66AD3D8478} + DataPackages + + + {b6a19b80-0f0f-434c-a754-a7712fc208b2} + StreamingProtocol + + + + + + + \ No newline at end of file diff --git a/Common/Hardware/WaterMeter/eRegister/eRegisterCore/eRegisterMeter.cs b/Common/Hardware/WaterMeter/eRegister/eRegisterCore/eRegisterMeter.cs new file mode 100644 index 00000000..18a22b6b --- /dev/null +++ b/Common/Hardware/WaterMeter/eRegister/eRegisterCore/eRegisterMeter.cs @@ -0,0 +1,693 @@ +using Newtonsoft.Json; +using NLog; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using Xylem.Common.CommonCore.Consts; +using Xylem.Common.Hardware.Interfaces.Ports.PortCore; +using Xylem.Common.Hardware.Interfaces.Ports.PortCore.EventArguments; +using Xylem.Common.Hardware.Interfaces.Ports.SerialPorts; +using Xylem.Common.Hardware.Interfaces.Protocols.ProtocolCore; +using Xylem.Common.Hardware.Interfaces.Protocols.ProtocolCore.EventArguments; +using Xylem.Common.Hardware.Interfaces.Protocols.TransmitProtocol; +using Xylem.Common.Hardware.WaterMeter.eRegister.Protocols.StreamingProtocol; +using Xylem.Common.Hardware.WaterMeter.ERegister.DataPackages.MeasurementRecords; +using Xylem.Common.Hardware.WaterMeter.WaterMeterCore.Consts; +using Xylem.Common.Metrology.Measurements; +using Xylem.Common.Metrology.Measurements.Consts; +using Xylem.Common.Utils.Logging; + +namespace Xylem.Common.Hardware.WaterMeter.eRegister.eRegisterCore +{ + public class eRegisterMeter : WaterMeterCore.IMeter, WaterMeterCore.IMeterEvents + { + public String SerialNumber + { + get; set; + } + + /// + public Int32 Slot + { + get; set; + } + + /// + public Int32 IntermediateUpdateTimeS + { + get; + set; + } = 10; + /// + /// to reduce the IrdA communication in test bench, preparation will be done once (when SkipPreparationForTestBench is true) + /// + public Boolean SkipPreparationForTestBench + { + get; set; + } + + private String _currentActionText = ""; + /// + /// Hold the current process name e.g. FlowTest, Preadjustment for logging + /// + public String CurrentActionText + { + get => _currentActionText; + set + { + _currentActionText = value; + SetLogger(); + } + } + private ILogger _logger; + + + + /// + /// streaming port assignment/info + /// + private IPort StreamingPort + { + get; + set; + } + + /// + /// streaming protocol assignment/info + /// + private StreamingProtocol StreamingProtocol; + + + /// + /// List of ongoing measurements, base- and calibration-measurements + /// + private List _listOfIMeasurement = new List(); + + /// + /// Enable raw record logging, if set every incoming package will be logged + /// + private Boolean _enableRawDataLogging; + + public event EventHandler OnProcessStatusChanged; + public event EventHandler OnErrorStatusChanged; + public event EventHandler OnInitCompleted; + public event EventHandler OnMeasurementInitCompleted; + public event EventHandler OnMeasurementCompleted; + public event EventHandler OnCalibInitCompleted; + public event EventHandler OnCalibCompleted; + public event EventHandler OnDisposeCompleted; + + /// + /// do not use it to set ProcessStatus + /// if you want to change ProcessStatus of this genesis use + /// is just store for some routines + /// + private ProcessState _myProcessStatus; + + /// + /// if state is change + /// + /// will be invoked. + /// on some states other events will be invoke as well + public ProcessState ProcessStatus + { + get => _myProcessStatus; + + private set + { + if (_myProcessStatus == value) + { + return; + } + + _myProcessStatus = value; + Invoker(OnProcessStatusChanged); + switch (value) + { + case ProcessState.InitIsActive: + Invoker(OnInitCompleted); + break; + case ProcessState.MeasurementIsActive: + Invoker(OnMeasurementInitCompleted); + break; + case ProcessState.MeasurementIsDone: + Invoker(OnMeasurementCompleted); + break; + case ProcessState.CalibrationIsActive: + Invoker(OnCalibInitCompleted); + break; + case ProcessState.CalibrationIsDone: + Invoker(OnCalibCompleted); + break; + case ProcessState.QRefDone: + case ProcessState.WaitForQRef: + case ProcessState.WaitForCalibration: + case ProcessState.WaitForMeasurement: + case ProcessState.IsNotInit: + //no extra event needed + break; + default: + throw new OverflowException("MagFlux measurement unknown process status"); + } + } + } + public void BuildAndCheckCalibFactorsAllChannels(Double refVolumeCm, Double? refTimeS = null, Double reqDeviationPercent = 0, Double maxCalibFactorTolerancePercent = 0) + { + //no calibration + } + + public Boolean CheckStateAfterMeasurement() + { + return true; + } + /// + /// A helper to invoke events only if someone is listening, otherwise nothing will happen + /// + /// Event handler to call + /// Sender (can be null) + /// Event arguments (can be null) + private void Invoker(EventHandler handler, Object sender = null, EventArgs e = null) + { + if (handler != null) + { + if (sender == null) + { + sender = this; + } + + if (e == null) + { + e = new EventArgs(); + } + + handler.Invoke(sender, e); + } + // ReSharper disable once RedundantIfElseBlock + else + { + //nobody is listening + } + } + + + /// + /// + /// Start Event listening, has to be called after + /// + public void ConnectMeter() + { + if (StreamingPort != null && StreamingPort.GetPortName() != BaseSerialPort.PortNotAssigned) + { + LinkPortToProtocol(StreamingPort, StreamingProtocol); + _logger.Trace($"Slot:{Slot} - StreamingPort and StreamingProtocol linked"); + StreamingProtocol.OnRecordIsDecoded += StreamingProtocol_ApplyDecodedRecord; + } + + + _logger.Debug($"Slot:{Slot} - Connected and communication started"); + } + + /// + /// Add a port to working queue + /// + /// On should one once added in runtime + /// + public void LinkPortToProtocol(IPort port, IProtocol protocol) + { + //for streaming mode only + if (port == null) + { + return; + } + + port.OnRawRecordReceived += delegate (Object o, BasePortDataEventArgs rawMsg) + { + protocol.FillDecodingBuffer(rawMsg); + }; + try + { + if (!port.IsOpen()) + { + port.Open(); + } + } + catch (Exception ex) + { + throw new ApplicationException($"Cannot Open Comport. Check TaskManager for other Genesis relevant programs and close them. Also check if the comport is valid! { Environment.NewLine }{ ex.Message}"); + } + + protocol.OnRecordReadyToSend += delegate (Object o, BasePortDataEventArgs dataToSend) + { + var data = (List)dataToSend.GetData(); + port.PortWrite(data.ToArray()); + }; + } + /// + /// Track all incoming led record packages (Calibration and Flow) + /// + /// + /// + /// I should be + /// otherwise this method does nothing + /// + private void StreamingProtocol_ApplyDecodedRecord(Object sender, BaseDataEventArgs e) + { + var result = e.GetEventData(); + if (result is IMeasurementRecord measurementRecord) + { + if (measurementRecord is ERegisterRecord record) + { + if (!record.IsValid) + { + return; + } + + } + + AddData(measurementRecord); + } + } + + + public void Dispose() + { + _logger.Trace($"Slot:{Slot} - Start to dispose"); + + StreamingProtocol.OnRecordIsDecoded -= StreamingProtocol_ApplyDecodedRecord; + + + LogRawData(false); + LogManager.Flush(); + //isPart of Logout + + + + StreamingPort?.Dispose(); + + StreamingProtocol?.Dispose(); + _logger.Trace($"Slot:{Slot} - Dispose is finished"); + } + + public void DisposeMeter() + { + Dispose(); + } + + public List GetAllMeasurementResults(Double? refVolume, Double? refTimeS, Boolean intermediateMeasurement = false, Int32? channel = null, MeasurementDirection dir = MeasurementDirection.TakeBoth) + { + if (!intermediateMeasurement && GetMeasurementState(channel) != MeasurementStates.IsCompleted) + { + throw new ApplicationException("Measurement is not completed"); + } + var mainMeasurement = _listOfIMeasurement.FirstOrDefault(m => m.GetType() == typeof(ERegisterRecord)); + + if (mainMeasurement == null) + { + throw new ApplicationException("Can not find an ongoing measurement"); + } + mainMeasurement.FlowDirectionforCalculatingVol = MeasurementDirection.TakeBoth; + + var results = new List(); + var mainResult = intermediateMeasurement + ? mainMeasurement.GetIntermediateMeasurementResult(refVolume, refTimeS) + : mainMeasurement.GetFinalMeasurementResult(refVolume, refTimeS); + results.Add(mainResult); + _logger.Info($"Slot:{Slot}, Channel:{mainMeasurement.GetChannel()} - MeasuredTime({mainResult.DutTimeS}s), " + + $"MeasuredVolume({mainResult.DutVolumeCm}Qm)"); + + foreach (var otherMeasurement in _listOfIMeasurement.Where(m => m.GetType() != typeof(ERegisterRecord))) + { + try + { + var otherResults = intermediateMeasurement + ? otherMeasurement.GetIntermediateMeasurementResult(refVolume, refTimeS) + : otherMeasurement.GetFinalMeasurementResult(refVolume, refTimeS); + _logger.Info($"Slot:{Slot}, Channel:{otherMeasurement.GetChannel()} - ChannelTime({otherResults.DutTimeS}s), " + + $"ChannelVolume({otherResults.DutVolumeCm}Qm)"); + results.Add(otherResults); + } + catch (Exception ex) + { + _logger.Warn($"Slot:{Slot}, No Results for channel:{otherMeasurement.GetChannel()} Ex: {ex.Message}"); + if (channel == null) + { + throw new ApplicationException($"Can not read result from channel:{otherMeasurement.GetChannel() } Ex: {ex.Message}"); + } + } + } + + return results; + } + + public MeasurementStates GetCalibrationState() + { + return GetMeasurementState(); + } + + public DisplayCodes GetLastProcessState() + { + throw new NotImplementedException(); + } + + public MeasurementResults GetMainMeasurementResult(Double? refVolume, Double? refTimeS, Boolean intermediateMeasurement = false, MeasurementDirection dir = MeasurementDirection.TakeBoth) + { + if (!intermediateMeasurement && GetMeasurementState(0) != MeasurementStates.IsCompleted) + { + throw new ApplicationException("Measurement is not completed"); + } + if (dir != MeasurementDirection.TakeOnlyBackward) + { + _logger.Info($"Slot:{Slot} - Wrong MeasurementDirection no backwards volume for eRegister"); + } + return GetAllMeasurementResults(refVolume, refTimeS, intermediateMeasurement, 0).First(); + + } + + public MeasurementStates GetMeasurementState(Int32? onlyChannelNr = null) + { + _logger.Trace($"Slot:{Slot} - Get measurement state"); + if (!_listOfIMeasurement.Any()) + { + return MeasurementStates.NotStarted; + } + + if (onlyChannelNr.HasValue) + { + var measurement = _listOfIMeasurement.First(f => f.GetChannel() == onlyChannelNr.Value); + return measurement.GetMeasurementState(); + } + return _listOfIMeasurement.Min(m => m.MeasurementState); + } + + public String GetPcbId() + { + return "1"; + } + + public void InitCalibration() + { + _logger.Info($"Slot:{Slot} - Init measurement"); + PreMeasurement(); + } + + public void InitMeasurement() + { + _logger.Info($"Slot:{Slot} - Init measurement"); + PreMeasurement(); + } + private void PreMeasurement() + { + if (!SkipPreparationForTestBench) + { + SkipPreparationForTestBench = true; + } + else + { + WriteLog("Wait on measurement start"); + } + ProcessStatus = ProcessState.WaitForMeasurement; + } + public Boolean Login() + { + return true; + } + + public Boolean Login(String password, Boolean runImmediately = true, Boolean skipReadMeterFwAndAssignRegisters = false) + { + return true; + } + + public Boolean Logout() + { + return true; + } + + public void LogRawData(Boolean on) + { + _enableRawDataLogging = on; + if (StreamingPort is Interfaces.Ports.SerialPorts.LedSerialPort port) + { + port.RecordStreamingRawData = _enableRawDataLogging; + } + } + + public Boolean RequestIntermediateMeasurementState(Int32? onlyChannelNr = null) + { + _logger.Trace($"Slot:{Slot} - Get measurement state"); + if (!_listOfIMeasurement.Any()) + { + return false; + } + Boolean? ret = null; + foreach (var item in _listOfIMeasurement) + { + if (!onlyChannelNr.HasValue || item.GetChannel() == onlyChannelNr.Value) + { + var measurement = _listOfIMeasurement.First(f => onlyChannelNr != null && f.GetChannel() == onlyChannelNr.Value); + if ((measurement.MeasurementState == MeasurementStates.IsRunning + || measurement.MeasurementState == MeasurementStates.IsWaitingForIntermediateData)) + { + measurement.RequestIntermediateRecord(); + if (!ret.HasValue) + { + ret = true; + } + } + else + { + ret = false; + } + } + } + return ret.HasValue ? ret.Value : false; + } + + public void SetCalibFactorsAllChannels(Boolean justLog = false) + { + throw new NotImplementedException(); + } + + public void SetLcdText(Boolean release, Byte[] textInHex) + { + // + } + + public void SetProcessState(DisplayCodes newState, Boolean webRequest = true) + { + // + } + + public void SetupFromConfigFile(Int32 slot, Boolean ignoreCorruptedData = true, Boolean useRequest = true, Boolean useStreaming = true) + { + Slot = slot; + var configFile = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Genesis", ProgramConfig.SerialConfigFileName); + + if (!System.IO.File.Exists(configFile)) + { + configFile = Path.Combine(ProgramConfig.SerialConfigFileName); + if (!File.Exists(configFile)) + { + throw new ApplicationException($"Configuration file {configFile} not found "); + } + } + var tr = new StreamReader(configFile); + var slotConfigList = JsonConvert.DeserializeObject(tr.ReadToEnd()); + + if (slotConfigList != null) + { + var slotConfig = slotConfigList.FirstOrDefault(t => t.Slot == slot); + + if (slotConfig == null) + { + throw new ApplicationException($"Slot:{slot} - File " + + $"{ProgramConfig.SerialConfigFileName} does not contain valid configuration"); + } + + SetupMagFluxMeter(slot, null, slotConfig.Streaming, ignoreCorruptedData); + + } + + _logger.Debug($"Slot:{slot} - Configuration loaded"); + } + + + /// + /// just internal setup. called on ctor or from vb6 setup function + /// + /// Slot Number for test-bench + /// for RFID/UART/IrDA Port + /// for LED Port + /// don´t send CRC error or telegrams with error flag to caller + /// + /// If you have a password for highest access level you need, if you don't want to access the meter + /// (just read led record) than you can leave it nullS + /// + private void SetupMagFluxMeter(Int32 slot, PortConfig? requestPort, PortConfig? streamingPort, + Boolean ignoreCorruptedData = true, String password = "") + { + Slot = slot; + //_password = password; + + if (streamingPort != null) + { + var ledTransmit = new LedTransmitProtocol(streamingPort.Value.PortName); + + var streamingIdent = $"Slot:{Slot}, Port:{streamingPort.Value.PortName}, Protocol:LED"; + + StreamingPort = new LedSerialPort(streamingIdent, streamingPort.Value.GetSerialPort(), + ledTransmit.GetTransmitPortSettings(9600)); + + + StreamingProtocol = new StreamingProtocol(streamingIdent, ignoreCorruptedData); + } + SetLogger(); + _logger.Debug($"Slot:{Slot} - Setup done"); + } + + + public void StartCalibration() + { + StartMeasurement(); + } + private void Measurement_ActionStateHasChanged(Object sender, EventArgs e) + { + SyncStreamingBuffer(SyncMarkRecord.DecodeIntermediate); + } + public void StartMeasurement() + { + _listOfIMeasurement = new List + { + new BaseMeasurement(Slot, typeof(ERegisterRecord), IntermediateUpdateTimeS) + }; + + foreach (var measurement in _listOfIMeasurement) + { + measurement.OnActionStateHasChanged += Measurement_ActionStateHasChanged; + } + + _logger.Info($"Slot:{Slot} - Start measurement"); + + ProcessStatus = ProcessState.MeasurementIsActive; + _listOfIMeasurement.ForEach(m => m.MeasurementState = MeasurementStates.IsWaitingForStartData); + SyncStreamingBuffer(SyncMarkRecord.SyncStart); + } + + public void StopCalibration() + { + StopMeasurement(); + } + + public void StopMeasurement() + { + _logger.Info($"Slot:{Slot} - Stop measurement"); + ProcessStatus = ProcessState.MeasurementIsDone; + _listOfIMeasurement.ForEach(m => m.MeasurementState = MeasurementStates.IsWaitingForEndData); + SyncStreamingBuffer(SyncMarkRecord.SyncEnd); + } + private void AddData(IMeasurementRecord newRecord) + { + + foreach (var measurement in _listOfIMeasurement) + { + if (measurement.GetType() != newRecord.GetType()) + { + continue; + } + + if (measurement.GetChannel() == newRecord.GetChannel()) + { + measurement.AddData(newRecord); + } + } + + // when every measurement has state IsRunning or every measurement has state IsCompleted, the streaming buffer set to skip decoding + if (_listOfIMeasurement.All(m => m.MeasurementState == MeasurementStates.IsRunning) + || _listOfIMeasurement.All(m => m.MeasurementState == MeasurementStates.IsCompleted)) + { + SyncStreamingBuffer(SyncMarkRecord.DecodeIntermediateQuality); + } + + } + + /// + /// Synchronization of the record for the streaming interface + /// + /// + /// + private void SyncStreamingBuffer(SyncMarkRecord markRecord) + { + if (StreamingPort == null) + { + throw new ApplicationException("Synchronization not possible due to undefined streaming port"); + } + + StreamingPort.SynchronizeReceiveBuffer(markRecord); + } + + public void TestBenchDispose() + { + //nothing todo + } + + public void WriteLog(String text) + { + _logger.Info($"Slot:{Slot} - {text}"); + } + + #region logging + private void SetLogger() + { + if (_logger != null) + { + LogManager.Flush(); + } + // the id is a combination of UniqueId stored in PcbId and SensorSN (SensorId) + + var id = !string.IsNullOrEmpty(SerialNumber) ? $"_SN{SerialNumber}" : "?"; + var fileName = $"eRegister_Slot_{Slot}"; + + if (string.IsNullOrEmpty(CurrentActionText)) + { + _logger = NLogHelper.CreateOrGetMultiLogger($"Slot:{Slot}", $"", "Meter", "MeterBase", "MeterBase"); + + } + else + { + _logger = NLogHelper.CreateOrGetMultiLogger($"Slot:{Slot}_{id}_{CurrentActionText}", "Slot", "Meter", "MeterBase", "MeterBase"); + + //TODO check with roland + if (StreamingPort is LedSerialPort) + { + var streamingIdent = $"LedRawData_Slot_{Slot}_{id}_{CurrentActionText}"; + + ((LedSerialPort)StreamingPort).Ident = streamingIdent; + ((LedSerialPort)StreamingPort).RefreshLogger(); + + + if (!string.IsNullOrEmpty(SerialNumber) && CurrentActionText.Contains("PG")) + { + + //var pathMain = NLogHelper.GetPath(_logger); + //var pathRaw = NLogHelper.GetPath(((LedSerialPort)StreamingPort).GetRawLogger()); + + //var basePath = Path.GetDirectoryName(pathMain); + + //var testRunString = CurrentActionText.Replace("PG", ""); + //var lastChat = pathMain.LastIndexOf('\\'); + //pathMain = pathMain.Substring(lastChat + 1); + //pathRaw = Path.GetFileName(pathRaw); + + //var tmpUrl = $"http://10.49.40.25/MeterProcessState/api/TestBench/SetMeterLogPathInfo?SerialNumber={SerialNumber}&TestRunId={testRunString}&BasePath={basePath}&MainLogName={pathMain}&LEDName={pathRaw}"; + //_logger.Debug($"Request Url: { tmpUrl}"); + ////ToDO: Update to service URl + //LocalWebRequest.GetRequest(tmpUrl); + } + } + } + } + + #endregion + + } +} diff --git a/Common/Hardware/WaterMeter/eRegister/eRegisterCore/packages.config b/Common/Hardware/WaterMeter/eRegister/eRegisterCore/packages.config new file mode 100644 index 00000000..e48cba92 --- /dev/null +++ b/Common/Hardware/WaterMeter/eRegister/eRegisterCore/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/Common/LaaProduction/LaaProduction.csproj b/Common/LaaProduction/LaaProduction.csproj index 2ffde5b6..1b6ed983 100644 --- a/Common/LaaProduction/LaaProduction.csproj +++ b/Common/LaaProduction/LaaProduction.csproj @@ -36,7 +36,7 @@ - true + false LaaProduction_SigningKey.snk diff --git a/Common/Logic/ProductionOrderCore/OrderData/OrderProgrammingParameters.cs b/Common/Logic/ProductionOrderCore/OrderData/OrderProgrammingParameters.cs index 22ffe7be..54cac767 100644 --- a/Common/Logic/ProductionOrderCore/OrderData/OrderProgrammingParameters.cs +++ b/Common/Logic/ProductionOrderCore/OrderData/OrderProgrammingParameters.cs @@ -49,11 +49,11 @@ namespace Xylem.Common.Logic.ProductionOrderCore.OrderData if (radioParams.RadioAddress != 0) { - ret.Add(new ProgrammingParameters("SENSUSRADIO_RadioAddress", BitConverter.GetBytes(radioParams.RadioAddress).Reverse().ToArray(), ProgrammingSource.Order, (UInt32)radioParams.RadioAddress, typeof(UInt32).ToString(), ReadCompare.Equal)); + ret.Add(new ProgrammingParameters("SENSUSRADIO_RadioAddress", BitConverter.GetBytes(radioParams.RadioAddress).Reverse().ToArray(), ProgrammingSource.Vako, (UInt32)radioParams.RadioAddress, typeof(UInt32).ToString(), ReadCompare.Equal)); if (radioParams.FrqOffset.HasValue) { - ret.Add(new ProgrammingParameters("SENSUSRADIO_FrequencyOffset", BitConverter.GetBytes(radioParams.FrqOffset.Value).Reverse().ToArray(), ProgrammingSource.Order, (Int16)radioParams.FrqOffset.Value, typeof(Int16).ToString(), ReadCompare.Equal)); + ret.Add(new ProgrammingParameters("SENSUSRADIO_FrequencyOffset", BitConverter.GetBytes(radioParams.FrqOffset.Value).Reverse().ToArray(), ProgrammingSource.Vako, (Int16)radioParams.FrqOffset.Value, typeof(Int16).ToString(), ReadCompare.Equal)); } @@ -63,10 +63,10 @@ namespace Xylem.Common.Logic.ProductionOrderCore.OrderData if (radioParams.PowerLevel > 0 && radioParams.PowerLevelOption > 0 && radioParams.ImpedanceCodeNew > 0 && radioParams.ImpedanceCodeOption > 0) { - ret.Add(new ProgrammingParameters("SENSUSRADIO_PowerLevel", BitConverter.GetBytes(radioParams.PowerLevel).Reverse().ToArray(),ProgrammingSource.Order, (ushort)radioParams.PowerLevel, typeof(ushort).ToString(), ReadCompare.Equal)); - ret.Add(new ProgrammingParameters("SENSUSRADIO_PowerLevelOption", BitConverter.GetBytes(radioParams.PowerLevelOption).Reverse().ToArray(), ProgrammingSource.Order, (ushort)radioParams.PowerLevelOption, typeof(ushort).ToString(), ReadCompare.Equal)); - ret.Add(new ProgrammingParameters("SENSUSRADIO_ImpedanceCodeNew", BitConverter.GetBytes(radioParams.ImpedanceCodeNew).Reverse().ToArray(), ProgrammingSource.Order, (UInt16)radioParams.ImpedanceCodeNew, typeof(UInt16).ToString(), ReadCompare.Equal)); - ret.Add(new ProgrammingParameters("SENSUSRADIO_ImpedanceCodeOption", BitConverter.GetBytes(radioParams.ImpedanceCodeOption).Reverse().ToArray(), ProgrammingSource.Order, (UInt16)radioParams.ImpedanceCodeOption, typeof(UInt16).ToString(), ReadCompare.Equal)); + ret.Add(new ProgrammingParameters("SENSUSRADIO_PowerLevel", BitConverter.GetBytes(radioParams.PowerLevel).Reverse().ToArray(),ProgrammingSource.Vako, (ushort)radioParams.PowerLevel, typeof(ushort).ToString(), ReadCompare.Equal)); + ret.Add(new ProgrammingParameters("SENSUSRADIO_PowerLevelOption", BitConverter.GetBytes(radioParams.PowerLevelOption).Reverse().ToArray(), ProgrammingSource.Vako, (ushort)radioParams.PowerLevelOption, typeof(ushort).ToString(), ReadCompare.Equal)); + ret.Add(new ProgrammingParameters("SENSUSRADIO_ImpedanceCodeNew", BitConverter.GetBytes(radioParams.ImpedanceCodeNew).Reverse().ToArray(), ProgrammingSource.Vako, (UInt16)radioParams.ImpedanceCodeNew, typeof(UInt16).ToString(), ReadCompare.Equal)); + ret.Add(new ProgrammingParameters("SENSUSRADIO_ImpedanceCodeOption", BitConverter.GetBytes(radioParams.ImpedanceCodeOption).Reverse().ToArray(), ProgrammingSource.Vako, (UInt16)radioParams.ImpedanceCodeOption, typeof(UInt16).ToString(), ReadCompare.Equal)); } } var rawVako = VakoDbAdapter.GetRawVako(connectionString, orderNr); diff --git a/Common/Logic/ProductionOrderCore/OrderData/ScanToSerialNr.cs b/Common/Logic/ProductionOrderCore/OrderData/ScanToSerialNr.cs index 5ed3cad0..cae19d67 100644 --- a/Common/Logic/ProductionOrderCore/OrderData/ScanToSerialNr.cs +++ b/Common/Logic/ProductionOrderCore/OrderData/ScanToSerialNr.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; namespace Xylem.Common.Logic.ProductionOrderCore.OrderData { @@ -45,6 +46,31 @@ namespace Xylem.Common.Logic.ProductionOrderCore.OrderData customerSr = scan.Substring(2, 9); return true; } + + + if (scan.Count( a => a == ',') == 2) + { + customerSr = scan.Split(',')[1] + ',';// 0, scan.IndexOf(",", StringComparison.Ordinal)); + } + + if (customerSr.StartsWith(prefix)) + { + customerSr = customerSr.Substring(prefix.Length, length); + if (!customerSr.EndsWith(",")) + { + + throw new ApplicationException("Could not parse serial number"); + } + + customerSr = customerSr.TrimEnd(','); + } + + + if (int.TryParse(customerSr, out var retCustom)) + { + internalSerialNr = retCustom; + return true; + } throw new ApplicationException("Could not parse serial number"); } diff --git a/Common/Logic/ProductionOrderCore/ProductionOrderCore.csproj b/Common/Logic/ProductionOrderCore/ProductionOrderCore.csproj index 992b49ff..3b5deb41 100644 --- a/Common/Logic/ProductionOrderCore/ProductionOrderCore.csproj +++ b/Common/Logic/ProductionOrderCore/ProductionOrderCore.csproj @@ -72,6 +72,9 @@ prompt MinimumRecommendedRules.ruleset + + false + ..\..\packages\Newtonsoft.Json.13.0.3\lib\net40\Newtonsoft.Json.dll @@ -83,7 +86,6 @@ - diff --git a/Common/ProductionUiCordonel/ProductionProcesses/Actions/ProductionCheckShippingState.cs b/Common/ProductionUiCordonel/ProductionProcesses/Actions/ProductionCheckShippingState.cs index 1921566b..b6c65871 100644 --- a/Common/ProductionUiCordonel/ProductionProcesses/Actions/ProductionCheckShippingState.cs +++ b/Common/ProductionUiCordonel/ProductionProcesses/Actions/ProductionCheckShippingState.cs @@ -113,7 +113,7 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions // this calculates all life time values if (!GenesisStatusHandler.BuildLifeTimeInformation(Meter, genesisStatus)) { - + UserControl.lblText.Dispatcher.Invoke(DispatcherPriority.Send, new Action(() => { @@ -132,13 +132,37 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions return; } + if (!genesisStatus.UNTStatus) + { + + //currentProcessState = ProductionProcessState.Error; + UserControl.lblText.Dispatcher.Invoke(DispatcherPriority.Send, + new Action(() => + { + UserControl.MessageBox($"UNT Limit überschritten Limit{genesisStatus.UNTLimit} vs {genesisStatus.DrainedBatteryLoad_uAs}"); + UserControl.lblText.Content = $"UNT Limit überschritten Limit{genesisStatus.UNTLimit} vs {genesisStatus.DrainedBatteryLoad_uAs}"; + } + )); + + + + Meter.WriteLog($"UNT Limit überschritten Limit{genesisStatus.UNTLimit} vs {genesisStatus.DrainedBatteryLoad_uAs}"); + } if (genesisStatus.RemainingLifeTimeYears < 20) { if (genesisStatus.DrainedBatteryLoadPercent > 8) { currentProcessState = ProductionProcessState.Error; - UserControl.lblText.Content = "Batterie über 10% entladen"; + UserControl.lblText.Dispatcher.Invoke(DispatcherPriority.Send, + new Action(() => + { + UserControl.MessageBox($"EMEA Limit überschritten Limit 8% vs {genesisStatus.DrainedBatteryLoadPercent}"); + UserControl.lblText.Content = "Batterie über 10% entladen"; + } + )); + + Meter.WriteLog("Batterie über 10% entladen"); } @@ -158,7 +182,15 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions if (Meter.LutCrc != $@"0x{int.Parse(res[8]):X4}") { currentProcessState = ProductionProcessState.Error; - UserControl.lblText.Content = "Lut not correct"; + + + + UserControl.lblText.Dispatcher.Invoke(DispatcherPriority.Send, + new Action(() => + { + UserControl.lblText.Content = "Lut not correct"; + } + )); } diff --git a/Common/ProductionUiCordonel/ProductionProcesses/Actions/ProductionProcessCheckAttachment.cs b/Common/ProductionUiCordonel/ProductionProcesses/Actions/ProductionProcessCheckAttachment.cs index 466b19d2..88e73fb7 100644 --- a/Common/ProductionUiCordonel/ProductionProcesses/Actions/ProductionProcessCheckAttachment.cs +++ b/Common/ProductionUiCordonel/ProductionProcesses/Actions/ProductionProcessCheckAttachment.cs @@ -66,6 +66,11 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions { try { + + + + + var a = LocalWebRequest.GetRequest($"{ServiceUrls.GenesisFinalCheckServiceUrl()}GetSingleVakoKey?ProductionOrderNumber={OrderNumber}&KeyName=C_GEN_PULS"); var myJsonResponse = JsonConvert.DeserializeObject(a); if (myJsonResponse.Value.ToLower() == "q" || myJsonResponse.Value.ToLower() == "k") diff --git a/Common/ProductionUiCordonel/ProductionProcesses/Actions/ProductionProcessConnect.cs b/Common/ProductionUiCordonel/ProductionProcesses/Actions/ProductionProcessConnect.cs index 2e20a3ae..64c0c049 100644 --- a/Common/ProductionUiCordonel/ProductionProcesses/Actions/ProductionProcessConnect.cs +++ b/Common/ProductionUiCordonel/ProductionProcesses/Actions/ProductionProcessConnect.cs @@ -1,10 +1,10 @@ -using System; +using Newtonsoft.Json; +using ProductionUiCordonel.ProductionProcesses.Enum; +using ProductionUiCordonel.UserControls.FinalTest; +using System; using System.Collections.Generic; using System.Threading.Tasks; using System.Windows.Controls; -using Newtonsoft.Json; -using ProductionUiCordonel.ProductionProcesses.Enum; -using ProductionUiCordonel.UserControls.FinalTest; using Xylem.Common.CommonCore.Configuration; using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore; using Xylem.Common.Hardware.WaterMeter.Genesis.Registers; @@ -60,7 +60,24 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions if (!Meter.IsLoggedOn) { NewStatus("Login wird gestartet"); - Meter.Login(); + if (!Meter.Login()) + { + + + var url = ServiceUrls.GenesisGetPasswordContainerServiceUrl(); + + var requestResponse = LocalWebRequest.GetRequestWithError(url + Meter.PcbId, out var errorCode, 30000, isRetry: true); + if (errorCode == System.Net.HttpStatusCode.OK.GetHashCode()) + { + var passwordContainer = JsonConvert.DeserializeObject(requestResponse); + if (Meter.Login(System.Text.Encoding.UTF8.GetString(passwordContainer.ListOfPasswords[7]))) + { + Xylem.Common.Hardware.WaterMeter.Genesis.GenesisPwd.MeterPwdHandlerDb.SetPwdFromSkeletonToLvl8inDd(Meter.PcbId, passwordContainer); + } + + } + } + } Meter.WriteRegister(Register.Genesisflow.SampleRate, 2); Meter.WriteRegister(Register.Genesisflow.LedMode, 0); @@ -83,11 +100,11 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions var url = $"{ServiceUrls.GenesisFinalCheckServiceUrl()}GetProgrammingParameters?PcbID={base.Meter.PcbId}"; var csdRet = LocalWebRequest.GetRequest(url, 80000); - + return JsonConvert.DeserializeObject>(csdRet); } - catch (Exception ) + catch (Exception) { return new List { diff --git a/Common/ProductionUiCordonel/ProductionProcesses/Actions/ProductionProcessFinalParametrizationVakoCsd.cs b/Common/ProductionUiCordonel/ProductionProcesses/Actions/ProductionProcessFinalParametrizationVakoCsd.cs index 01b5e765..5a577aae 100644 --- a/Common/ProductionUiCordonel/ProductionProcesses/Actions/ProductionProcessFinalParametrizationVakoCsd.cs +++ b/Common/ProductionUiCordonel/ProductionProcesses/Actions/ProductionProcessFinalParametrizationVakoCsd.cs @@ -129,7 +129,7 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions { throw new ApplicationException("Radio inconsistent between meter and programmingparameters"); } - foreach (var item in myJsonResponse.Where(m => m.Source == ProgrammingSource.Vako)) + foreach (var item in myJsonResponse.Where(m => m.Source == ProgrammingSource.Vako || m.Source == ProgrammingSource.Order )) { if (item.RegisterName == "CUSTOMER_LeakFlowThreshold") diff --git a/Common/ProductionUiCordonel/ProductionProcesses/Actions/ProductionProcessShippingMode.cs b/Common/ProductionUiCordonel/ProductionProcesses/Actions/ProductionProcessShippingMode.cs index 3c590842..e120d1a6 100644 --- a/Common/ProductionUiCordonel/ProductionProcesses/Actions/ProductionProcessShippingMode.cs +++ b/Common/ProductionUiCordonel/ProductionProcesses/Actions/ProductionProcessShippingMode.cs @@ -7,6 +7,7 @@ using System.Threading; using System.Windows.Controls; using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore; using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile; +using Xylem.Common.Hardware.WaterMeter.Genesis.Registers; namespace ProductionUiCordonel.ProductionProcesses.Actions { @@ -50,7 +51,10 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions hasRadio = Meter.RadioFrequencyMhz.HasValue; + if (doRestart) + { + } if (hasRadio) { @@ -74,7 +78,7 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions }; var rebootSucceeded = _meterResetPsu.MeterResetPsuExecute(); - Thread.Sleep(10000); + Thread.Sleep(16000); if (!Meter.Login()) { @@ -86,7 +90,15 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions currentProcessState = ProductionProcessState.Error; } } + Meter.WriteRegister("SYSTEM_ExitReason", 21, true, false); + var exitResult = RegisterConverter.ConvertTo(Meter.ReadRegister("SYSTEM_ExitReason")); + if (exitResult != 0) + { + Meter.WriteLog("PasswordFile incorrect"); + currentProcessState = ProductionProcessState.Error; + return; + } Boolean? hasDiffrences = null; foreach (var item in CheckValuesAfterBoot) @@ -206,10 +218,17 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions }; var rebootSucceeded = _meterResetPsu.MeterResetPsuExecute(); - Thread.Sleep(10000); + Thread.Sleep(16000); Meter.Login(); + Meter.WriteRegister("SYSTEM_ExitReason", 21, true, false); + var exitResult = RegisterConverter.ConvertTo(Meter.ReadRegister("SYSTEM_ExitReason")); - + if (exitResult != 0) + { + Meter.WriteLog("PasswordFile incorrect"); + currentProcessState = ProductionProcessState.Error; + return; + } Boolean? hasDiffrences = null; foreach (var item in CheckValuesAufterBoot) { diff --git a/Common/ProductionUiCordonel/UserControls/FinalTest/UcPlain.xaml.cs b/Common/ProductionUiCordonel/UserControls/FinalTest/UcPlain.xaml.cs index 7eb947cb..d92cb68c 100644 --- a/Common/ProductionUiCordonel/UserControls/FinalTest/UcPlain.xaml.cs +++ b/Common/ProductionUiCordonel/UserControls/FinalTest/UcPlain.xaml.cs @@ -1,4 +1,5 @@ -using System.Windows.Controls; +using System; +using System.Windows.Controls; namespace ProductionUiCordonel.UserControls.FinalTest { @@ -11,5 +12,10 @@ namespace ProductionUiCordonel.UserControls.FinalTest { InitializeComponent(); } + + internal void MessageBox(String v) + { + System.Windows.Forms.MessageBox.Show(v); + } } } diff --git a/Common/Service/MeterProcessState/Controllers/EasyAccessControler.cs b/Common/Service/MeterProcessState/Controllers/EasyAccessControler.cs index 7635d2ce..eee8e85c 100644 --- a/Common/Service/MeterProcessState/Controllers/EasyAccessControler.cs +++ b/Common/Service/MeterProcessState/Controllers/EasyAccessControler.cs @@ -230,7 +230,7 @@ namespace Xylem.Common.Service.MeterProcessState.Controllers query.AppendLine(" from [Auftrag].[dbo].[AuftragPositionSerienNr] apsn "); query.AppendLine(" inner join [Auftrag].[dbo].[AuftragPosition_Gesamt] apg on apg.AuftragNr = apsn.AuftragNr and apg.PositionNr = apsn.PositionNr and apg.Ort = 'L2' "); - query.AppendLine(" inner join [Auftrag].[dbo].[Pruefgang] pg on apsn.[Pruefgangnr] = pg.PruefgangNr and pg.PruefstationNr = 2016 "); + query.AppendLine(" inner join [Auftrag].[dbo].[Pruefgang] pg on apsn.[Pruefgangnr] = pg.PruefgangNr and pg.PruefstationNr in (2016,2015) "); query.AppendLine(" inner join [Auftrag].[dbo].Prueffehler pf on pg.[Pruefgangnr] = pf.PruefgangNr and pf.SerienNr = apsn.SerienNr "); @@ -242,6 +242,10 @@ namespace Xylem.Common.Service.MeterProcessState.Controllers query.AppendLine(" left outer join Identnr idt on idt.IdentNr = apg.Identnr "); + //query.AppendLine(" left outer join [MapPcbIdToSerialNumber] map on map.MapPcbIdToSerialNumber_SerialNumber = apsn.SerienNr "); + + + query.AppendLine($" where pg.Datum >= '{Start}' and pg.Datum <= '{End}' "); @@ -254,7 +258,7 @@ namespace Xylem.Common.Service.MeterProcessState.Controllers query.AppendLine(" inner join [Auftrag].[dbo].[AuftragPositionSerienNr] apsn on apsn.SerienNr = [MapPcbIdToSerialNumber_SerialNumber] and apsn.SerienNr not in (20702497,20702499,20717438) "); query.AppendLine(" "); query.AppendLine(" inner join[Auftrag].[dbo].[AuftragPosition_Gesamt] apg on apg.AuftragNr = apsn.AuftragNr and apg.PositionNr = apsn.PositionNr and apg.Ort = 'L2' "); - query.AppendLine(" inner join[Auftrag].[dbo].[Pruefgang] pg on apsn.[Pruefgangnr] = pg.PruefgangNr and pg.PruefstationNr = 2016 "); + query.AppendLine(" inner join[Auftrag].[dbo].[Pruefgang] pg on apsn.[Pruefgangnr] = pg.PruefgangNr and pg.PruefstationNr in (2016,2015) "); query.AppendLine(" inner join[Auftrag].[dbo].Prueffehler pf on pg.[Pruefgangnr] = pf.PruefgangNr and pf.SerienNr = [MapPcbIdToSerialNumber_SerialNumber] "); query.AppendLine(" "); query.AppendLine($" where pg.Datum >= '{Start}' and pg.Datum <= '{End}' "); diff --git a/Common/Service/MeterProcessState/Controllers/FinalCheckController.cs b/Common/Service/MeterProcessState/Controllers/FinalCheckController.cs index cddc97a5..b0cb4fab 100644 --- a/Common/Service/MeterProcessState/Controllers/FinalCheckController.cs +++ b/Common/Service/MeterProcessState/Controllers/FinalCheckController.cs @@ -652,7 +652,10 @@ namespace Xylem.Common.Service.MeterProcessState.Controllers SkipRadioCheck = (Boolean)dt.Rows[0]["SkipRadioParameters"]; } - + if (FrequencyIndicator == 0) + { + SkipRadioCheck = true; + } sb = new StringBuilder(); @@ -941,6 +944,54 @@ namespace Xylem.Common.Service.MeterProcessState.Controllers // return Request.CreateResponse(HttpStatusCode.OK, await Task.Run(() => { return listOfDnParams; })); //} + + [Route("SetMeterEOLState"), HttpPost] + public async Task SetMeterEOLState(int PcbID,int OrderNumber) + { + + try + { + + var sb = new StringBuilder(); + sb.AppendLine($" UPDATE [dbo].[CordonelEol] "); + sb.AppendLine($" SET "); + sb.AppendLine($" [CordonelEolPcbId] = {PcbID} "); + sb.AppendLine($" ,[CordonelEolOrderNumber] = {OrderNumber} "); + sb.AppendLine($" ,[CordonelEolDate] = CURRENT_TIMESTAMP "); + sb.AppendLine($" ,[CordonelEolPublishAction] = null "); + sb.AppendLine($" ,[CordonelEolSAPFeedback] = null "); + sb.AppendLine($" WHERE [CordonelEolPcbId] = {PcbID} "); + sb.AppendLine($" and [CordonelEolOrderNumber] = {OrderNumber} "); + sb.AppendLine($"IF @@ROWCOUNT = 0 "); + sb.AppendLine($" BEGIN "); + sb.AppendLine($" INSERT INTO [dbo].[CordonelEol] "); + sb.AppendLine($" ([CordonelEolPcbId] "); + sb.AppendLine($" ,[CordonelEolOrderNumber] "); + sb.AppendLine($" ,[CordonelEolDate] "); + sb.AppendLine($" ,[CordonelEolPublishAction] "); + sb.AppendLine($" ,[CordonelEolSAPFeedback]) "); + sb.AppendLine($" VALUES "); + sb.AppendLine($" ( {PcbID} "); + sb.AppendLine($" ,{OrderNumber} "); + sb.AppendLine($" ,CURRENT_TIMESTAMP "); + sb.AppendLine($" ,null "); + sb.AppendLine($" ,null) "); + sb.AppendLine($" END "); + + + using (var dataacces = new SqlDataAccess(GlobalConfig.ConnectionString.Value)) + { + + return Request.CreateResponse(HttpStatusCode.OK, await Task.Run(() => { return dataacces.ExecuteQuery(sb.ToString()) != null; })); + } + } + catch (Exception ex) + { + + return Request.CreateResponse(HttpStatusCode.ExpectationFailed, ex); + } + } + [Route("SetMetersizeProgrammingData"), HttpPost] public async Task SetMetersizeProgrammingData(MeterSize ParameterMeterSize, [FromBody] String listOfDnParamsRaw) { diff --git a/Common/Service/MeterProcessState/Controllers/FwUpdateController.cs b/Common/Service/MeterProcessState/Controllers/FwUpdateController.cs index e4167924..63d8cfe9 100644 --- a/Common/Service/MeterProcessState/Controllers/FwUpdateController.cs +++ b/Common/Service/MeterProcessState/Controllers/FwUpdateController.cs @@ -707,6 +707,8 @@ namespace Xylem.Common.Service.MeterProcessState.Controllers addOBJ.FileId = (Int32)row["FWUpdateReport_ID"]; addOBJ.Date = (DateTime)row["FWUpdateReport_Date"]; ret.Add(addOBJ); + //help to download all file to local store + //File.WriteAllText($"E:\\bat\\report\\{addOBJ.PcbId}_{addOBJ.FileId}.txt", addOBJ.Content); } } return Request.CreateResponse(HttpStatusCode.OK, ret); diff --git a/Common/Service/MeterProcessState/Controllers/OrderController.cs b/Common/Service/MeterProcessState/Controllers/OrderController.cs index 2f055a1c..e023a222 100644 --- a/Common/Service/MeterProcessState/Controllers/OrderController.cs +++ b/Common/Service/MeterProcessState/Controllers/OrderController.cs @@ -174,7 +174,12 @@ namespace Xylem.Common.Service.MeterProcessState.Controllers sb.AppendLine($" select distinct kunden.KundenNr as CustomerNumber, kunden.Name as CustomerName, kunden.Ort as CustomerLocation "); sb.AppendLine($" from Identnr ident "); - sb.AppendLine($" inner join Statistik_auftrag auftrag on auftrag.IdentNr = ident.IdentNr "); + // sb.AppendLine($" inner join Statistik_auftrag auftrag on auftrag.IdentNr = ident.IdentNr "); + + sb.AppendLine($" inner join AuftragPosition_Gesamt auftragPOS on auftragPOS.IdentNr = ident.IdentNr "); + + sb.AppendLine($" inner join Auftrag_Gesamt auftrag on auftrag.AuftragNr = auftragPOS.AuftragNr "); + sb.AppendLine($" inner join Kunde kunden on auftrag.KundenNr = kunden.KundenNr "); sb.AppendLine($" where ident.Typ = 'GNS' "); @@ -207,9 +212,13 @@ namespace Xylem.Common.Service.MeterProcessState.Controllers StringBuilder sb = new StringBuilder(); - sb.AppendLine($" select AuftragNr as CustomerOrderNumber, PositionNr as CustomerOrderPos ,Menge as Quantity, Katalognummer as CatalogNumber, Nennweite as Diameter,Baulaenge as Length from "); + sb.AppendLine($" select auftrag.AuftragNr as CustomerOrderNumber, PositionNr as CustomerOrderPos ,Menge as Quantity, Katalognummer as CatalogNumber, Nennweite as Diameter,Baulaenge as Length from "); sb.AppendLine($" Identnr ident "); - sb.AppendLine($" inner join Statistik_auftrag auftrag on auftrag.IdentNr = ident.IdentNr "); + //sb.AppendLine($" inner join Statistik_auftrag auftrag on auftrag.IdentNr = ident.IdentNr "); + + sb.AppendLine($" inner join AuftragPosition_Gesamt auftragPOS on auftragPOS.IdentNr = ident.IdentNr "); + + sb.AppendLine($" inner join Auftrag_Gesamt auftrag on auftrag.AuftragNr = auftragPOS.AuftragNr "); sb.AppendLine($" where ident.Typ = 'GNS' and auftrag.KundenNr = {CustomerNumber} "); diff --git a/Common/Service/MeterProcessState/Controllers/PasswordController.cs b/Common/Service/MeterProcessState/Controllers/PasswordController.cs index 00ea0cb1..321309b7 100644 --- a/Common/Service/MeterProcessState/Controllers/PasswordController.cs +++ b/Common/Service/MeterProcessState/Controllers/PasswordController.cs @@ -373,12 +373,150 @@ namespace Xylem.Common.Service.MeterProcessState.Controllers } + [Route("GetPasswordHashFileContentDebug")] + public async Task GetPasswordHashFileContentDebug(String PcbId) + { + try + { + var sbKeys = new StringBuilder(); + + var listOfHashes = new List(); + var sbOutPut = new StringBuilder(); + + var sbQuery = new StringBuilder(); + + sbQuery.AppendLine($" SELECT "); + sbQuery.AppendLine($" [Seriennummer] "); + sbQuery.AppendLine($" ,mps.MapPcbIdToSerialNumber_PcbId "); + sbQuery.AppendLine($" ,[Adresse] "); + sbQuery.AppendLine($" ,AuftragPosSNr.AuftragNr "); + sbQuery.AppendLine($" ,Auftrag.FertigungsauftragNr "); + sbQuery.AppendLine($" ,[GeschlossenDatum] "); + sbQuery.AppendLine($" ,[Vergabe_am] "); + sbQuery.AppendLine($" ,passwordtbl.KeySetId "); + sbQuery.AppendLine($" ,passwordtbl.orderNumber "); + sbQuery.AppendLine($" ,passwordtbl.Password "); + sbQuery.AppendLine($" ,passwordtbl.KitronSkeletonKey as Skeleton "); + sbQuery.AppendLine($" ,passwordtbl.ProcessorID as ProcessorUid "); + sbQuery.AppendLine($" FROM [Auftrag].[dbo].[Genesis_Meter] meter "); + sbQuery.AppendLine($" inner join MapPcbIdToSerialNumber mps" + + $" on mps.MapPcbIdToSerialNumber_SerialNumber = meter.Seriennummer and mps.MapPcbIdToSerialNumber_Deleted = 0 "); + sbQuery.AppendLine($" inner join[Auftrag].[dbo].[AuftragPositionSerienNr] AuftragPosSNr " + + $" on AuftragPosSNr.SerienNr = meter.Seriennummer and [Pruefgangnr] = 0 "); + sbQuery.AppendLine($" inner join[Auftrag].[dbo].[AlleAuftragPositionen] Auftrag" + + $" on Auftrag.AuftragNr = AuftragPosSNr.AuftragNr and AuftragPosSNr.PositionNr = Auftrag.PositionNr "); + + sbQuery.AppendLine($" left outer join[dbo].[Genesis_PcbPassword] passwordtbl" + + $" on passwordtbl.PcbId = mps.MapPcbIdToSerialNumber_PcbId "); + sbQuery.AppendLine($" where mps.MapPcbIdToSerialNumber_PcbId = '{PcbId}' "); + + + + + var result = new MeterPwdDb(); + + using (var dataAccess = new SqlDataAccess(GlobalConfig.connectionString.Value)) + { + var dt = dataAccess.ExecuteQuery(sbQuery.ToString()); + foreach (var item in dt.Select()) + { + result.OrderNumber = (Int32)item["FertigungsauftragNr"]; + result.RadioAddress = (Int64)item["Adresse"]; + result.Skeleton = (String)item["Skeleton"]; + result.Password = (String)item["Password"]; + result.PasswordFileIdent = (result.RadioAddress.HasValue && result.RadioAddress.Value != 0) ? result.RadioAddress.Value.ToString() : PcbId; + if (item["KeySetId"].GetType() != typeof(System.DBNull)) + { + result.KeySetId = (String)item["KeySetId"]; + } + sbKeys.AppendLine($"PcbId:{PcbId}"); + sbKeys.AppendLine($"ProcessorUid:{(String)item["ProcessorUid"]}"); + sbKeys.AppendLine($"Skeleton:{(String)item["Skeleton"]}"); + sbKeys.AppendLine($"Password:{(String)item["Password"]}"); + } + } + + if (!result.OrderNumber.HasValue) + { + return Request.CreateResponse(HttpStatusCode.InternalServerError, new PcbIdNotException(new Guid("160B4C44-6EF7-41DC-A48D-4B4105B4779B"))); + } + + Request.Headers.Add("X-Node-Token", "d5b8c0b2-81f6-4421-80d0-44eb2093e616"); + if (!Request.Headers.Contains("X-Node-Token")) + { + return Request.CreateResponse(HttpStatusCode.InternalServerError, new TokenRequiredException(new Guid("77895D13-CA58-48AB-8C5E-9CDB7F80C69D"))); + } + + if (string.IsNullOrEmpty(result.KeySetId)) + { + result.KeySetId = CreateKeySet(Request.Headers.GetValues("X-Node-Token").First(), 7); + //mapp keyset + MapKeySet(Request.Headers.GetValues("X-Node-Token").First(), result.KeySetId, result.OrderNumber.Value, result.PasswordFileIdent); + using (var dataAccess = new SqlDataAccess(GlobalConfig.connectionString.Value)) + { + var dt = dataAccess.ExecuteQuery( + $"update auftrag.[dbo].[Genesis_PcbPassword] set KeySetId = '{result.KeySetId}', [orderNumber] = {result.OrderNumber.Value}, [radioAdress] = {result.PasswordFileIdent} where PcbId = '{PcbId}'; select * from auftrag.[dbo].[Genesis_PcbPassword] where PcbId = '{PcbId}'"); + } + } + + var passwords = getKeys(Request.Headers.GetValues("X-Node-Token").First(), result.OrderNumber.Value.ToString(), result.PasswordFileIdent); + //pw lvl + passwords.Keys.Insert(2, new Key() { Index = 2, KeyKey = result.Skeleton }); + + var pwdLVL8 = ""; + if (passwords.Keys.Count > 7) + { + pwdLVL8 = passwords.Keys[7].KeyKey.Substring(0, 12); + } + + foreach (var keyLVL in passwords.Keys) + { + using (System.Security.Cryptography.SHA1Managed sha1 = new System.Security.Cryptography.SHA1Managed()) + { + var rawKey = keyLVL.KeyKey; + if (rawKey.Length > 12) + { + rawKey = rawKey.Substring(0, 12); + } + if (result.ListOfPasswords.Count <= 7) + { + result.ListOfPasswords.Add(Encoding.UTF8.GetBytes(rawKey)); + + var hash = sha1.ComputeHash(Encoding.UTF8.GetBytes(rawKey)); + result.ListOfHashes.Add(hash); + } + } + } + + sbKeys.AppendLine("passwords:"); + foreach (var item in result.ListOfPasswords) + { + sbKeys.AppendLine(BitConverter.ToString(item)); + } + sbKeys.AppendLine("hashes:"); + foreach (var item in result.ListOfHashes) + { + sbKeys.AppendLine(BitConverter.ToString(item)); + } + return Request.CreateResponse(HttpStatusCode.OK, await Task.Run(() => + { + return result; + })); + + } + catch (Exception ex) + { + return Request.CreateResponse(HttpStatusCode.ExpectationFailed, ex.ToString() + "
" + ex.InnerException.ToString()); + } + } [Route("GetPasswordHashFileContent")] public async Task GetPasswordHashFileContent(String PcbId) { try { + var sbKeys = new StringBuilder(); + var listOfHashes = new List(); var sbOutPut = new StringBuilder(); @@ -429,9 +567,14 @@ namespace Xylem.Common.Service.MeterProcessState.Controllers result.KeySetId = (String)item["KeySetId"]; } + } } + if (result.OrderNumber == 3219628) + { + result.PasswordFileIdent = "1" + result.PasswordFileIdent; + } if (!result.OrderNumber.HasValue) { @@ -465,7 +608,7 @@ namespace Xylem.Common.Service.MeterProcessState.Controllers { pwdLVL8 = passwords.Keys[7].KeyKey.Substring(0, 12); } - + foreach (var keyLVL in passwords.Keys) { using (System.Security.Cryptography.SHA1Managed sha1 = new System.Security.Cryptography.SHA1Managed()) @@ -478,16 +621,25 @@ namespace Xylem.Common.Service.MeterProcessState.Controllers if (result.ListOfPasswords.Count <= 7) { result.ListOfPasswords.Add(Encoding.UTF8.GetBytes(rawKey)); + var hash = sha1.ComputeHash(Encoding.UTF8.GetBytes(rawKey)); result.ListOfHashes.Add(hash); } } } - - - - return Request.CreateResponse(HttpStatusCode.OK, await Task.Run(() => + sbKeys.AppendLine($"PcbiD: {PcbId}"); + sbKeys.AppendLine("passwords:"); + foreach (var item in result.ListOfPasswords) { + sbKeys.AppendLine(BitConverter.ToString(item)); + } + sbKeys.AppendLine("hashes:"); + foreach (var item in result.ListOfHashes) + { + sbKeys.AppendLine(BitConverter.ToString(item)); + } + return Request.CreateResponse(HttpStatusCode.OK, await Task.Run(() => + { return result; })); diff --git a/Common/Service/MeterProcessState/Controllers/TempFlangeController.cs b/Common/Service/MeterProcessState/Controllers/TempFlangeController.cs index 9433d1cd..0c9af00d 100644 --- a/Common/Service/MeterProcessState/Controllers/TempFlangeController.cs +++ b/Common/Service/MeterProcessState/Controllers/TempFlangeController.cs @@ -58,8 +58,7 @@ namespace Service.MeterProcessState.Controllers PcbId = PcbId, RefTempC = RefTempC, AvgTof = AvgTof, - Active = true, - Timestamp = dt == default(DateTime) ? null : (DateTime?)dt + Active = true }); return await ctx.SaveChangesAsync() > 0; diff --git a/Common/Service/MeterProcessState/Controllers/TestBenchController.cs b/Common/Service/MeterProcessState/Controllers/TestBenchController.cs index b6ec7e54..c2be5ae3 100644 --- a/Common/Service/MeterProcessState/Controllers/TestBenchController.cs +++ b/Common/Service/MeterProcessState/Controllers/TestBenchController.cs @@ -65,6 +65,46 @@ [Route("GetMeterInfoForTestBench"), HttpGet] public IHttpActionResult GetMeterInfoForTestBench(String PcbID) { + var str = $@" + SELECT DISTINCT + [MapPcbIdToSerialNumber_SerialNumber] AS [SerialNr] + , [MapOrder].[CordonelAssignedPicking_FertigungsAuftragsNr] AS [FertigungsNr] + , [Meter].[Adresse] AS [RadioAddress] + , [KundeneigeneSerienNr] AS [CustomerSerialNr] + , (SELECT TOP 1 [ID] + FROM [CordonelMeterCalibrationResults] + WHERE [PcbId] = @{nameof(PcbID)} + ORDER BY [Date] DESC) AS [CalibrationRunID] + , (SELECT TOP 1 [StatusFertigung] + FROM [AuftragPositionSerienNr] + WHERE [SerienNr] = [MapPcbIdToSerialNumber_SerialNumber] + ORDER BY [AnlageDatum] DESC) AS [LastProcessState] + , [Nennweite] AS [Dn] + , (SELECT TOP 1 [Dn_InternalId] + FROM [CordonelMeterSizes] + WHERE [Dn_VakoID] = SUBSTRING([Identnr].[VakoCode], 4, 2)) AS [NewNennweiteID] + , [lut].[FileCrc] AS [LutCrc] + FROM [Cordonel_AssignedPicking] AS [MapOrder] + LEFT OUTER JOIN [MapPcbIdToSerialNumber] AS [map] + ON [MapOrder].[CordonelAssignedPicking_PcbId] = [map].[MapPcbIdToSerialNumber_PcbId] + AND [map].[MapPcbIdToSerialNumber_Deleted] = 0 + LEFT OUTER JOIN [AuftragPositionSerienNr] AS [mapSrn] + ON [map].[MapPcbIdToSerialNumber_SerialNumber] = [mapSrn].[SerienNr] + AND [mapSrn].[Pruefgangnr] = 0 + LEFT OUTER JOIN [AuftragPosition_gesamt] AS [auftraginfo] + ON [auftraginfo].[AuftragNr] = [mapSrn].[AuftragNr] + AND [auftraginfo].[PositionNr] = [mapSrn].[PositionNr] + LEFT OUTER JOIN [Genesis_Meter] AS [Meter] + ON [Meter].[Seriennummer] = [map].[MapPcbIdToSerialNumber_SerialNumber] + LEFT OUTER JOIN [Identnr] + ON [auftraginfo].[Identnr] = [Identnr].[IdentNr] + LEFT OUTER JOIN [Cordonel_Lut] AS [lut] + ON [lut].[MeterSize] = (SELECT TOP 1 [Dn_InternalId] + FROM [CordonelMeterSizes] + WHERE [Dn_VakoID] = SUBSTRING([Identnr].[VakoCode], 4, 2)) + AND [lut].[CurrentVersionForProd] = 1 + WHERE [MapOrder].[CordonelAssignedPicking_IsDeleted] = 0 + AND [MapOrder].[CordonelAssignedPicking_PcbId] = @{nameof(PcbID)} "; var results = SQLConnection .CreateSQLConnection(ConnectionString.Value) .CreateCommand($@" @@ -113,12 +153,12 @@ $"{x.GetInt()}", // SerialNr, $"{x.GetInt()}", // FertigungsNr, $"{x.GetLong()}", // RadioAddress, - $"{x.GetString()}", // CustomerSerialNr, - $"{x.GetInt()}", // CalibrationRunID, + $"{x.GetValue()}", // CustomerSerialNr, + $"{x.GetString()}", // CalibrationRunID, $"{x.GetValue()}", // LastProcessState, $"{x.GetInt()}", // Dn, $"{x.GetInt()}", // NewNennweiteID, - $"{x.GetInt()}", // LutCrc + $"{x.GetValue()}", // LutCrc }); if (results.Count() == 1) diff --git a/Common/Service/MeterProcessState/Data/CordonelTempLut.cs b/Common/Service/MeterProcessState/Data/CordonelTempLut.cs index b04aed92..dcf98725 100644 --- a/Common/Service/MeterProcessState/Data/CordonelTempLut.cs +++ b/Common/Service/MeterProcessState/Data/CordonelTempLut.cs @@ -16,6 +16,5 @@ public Boolean Active { get; set; } - public DateTime? Timestamp { get; set; } } } \ No newline at end of file diff --git a/Common/Service/ProductionService/App.config b/Common/Service/ProductionService/App.config index 63ffbc77..109432ca 100644 --- a/Common/Service/ProductionService/App.config +++ b/Common/Service/ProductionService/App.config @@ -9,6 +9,10 @@ + + + + diff --git a/Common/Service/ProductionService/ProductionService.csproj b/Common/Service/ProductionService/ProductionService.csproj index 88d37360..ec4a9d36 100644 --- a/Common/Service/ProductionService/ProductionService.csproj +++ b/Common/Service/ProductionService/ProductionService.csproj @@ -60,8 +60,8 @@ ..\..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll - - ..\..\packages\System.Runtime.CompilerServices.Unsafe.4.5.3\lib\net461\System.Runtime.CompilerServices.Unsafe.dll + + ..\..\packages\System.Runtime.CompilerServices.Unsafe.4.6.0-preview.18571.3\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll diff --git a/Common/Service/ProductionService/packages.config b/Common/Service/ProductionService/packages.config index 8d86a827..42ab8258 100644 --- a/Common/Service/ProductionService/packages.config +++ b/Common/Service/ProductionService/packages.config @@ -7,5 +7,5 @@ - + \ No newline at end of file diff --git a/Common/Tools/Tools.JsonToXlsHelper/obj/Debug/Tools.JsonToXlsHelper.csproj.CoreCompileInputs.cache b/Common/Tools/Tools.JsonToXlsHelper/obj/Debug/Tools.JsonToXlsHelper.csproj.CoreCompileInputs.cache index 8dda2975..84b6b3be 100644 --- a/Common/Tools/Tools.JsonToXlsHelper/obj/Debug/Tools.JsonToXlsHelper.csproj.CoreCompileInputs.cache +++ b/Common/Tools/Tools.JsonToXlsHelper/obj/Debug/Tools.JsonToXlsHelper.csproj.CoreCompileInputs.cache @@ -1 +1 @@ -247396738e2c5d26ac00f9df05c0cc5c61d7f33a +65d75c3322f8a137c69963cfdc0cb6f1ffacf62a diff --git a/Common/Ui/GenesisToolBox/FrmFileCURD.Designer.cs b/Common/Ui/GenesisToolBox/FrmFileCURD.Designer.cs index 6b035230..ef073875 100644 --- a/Common/Ui/GenesisToolBox/FrmFileCURD.Designer.cs +++ b/Common/Ui/GenesisToolBox/FrmFileCURD.Designer.cs @@ -66,6 +66,7 @@ this.btnAddReleaseConfig = new System.Windows.Forms.Button(); this.txtUpdateSW = new System.Windows.Forms.TextBox(); this.txtReleaseConfig = new System.Windows.Forms.TextBox(); + this.button3 = new System.Windows.Forms.Button(); this.groupBox2.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dgvFiles)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.filePartBindingSource)).BeginInit(); @@ -429,11 +430,22 @@ this.txtReleaseConfig.Size = new System.Drawing.Size(225, 20); this.txtReleaseConfig.TabIndex = 37; // + // button3 + // + this.button3.Location = new System.Drawing.Point(857, 28); + this.button3.Name = "button3"; + this.button3.Size = new System.Drawing.Size(75, 23); + this.button3.TabIndex = 38; + this.button3.Text = "button3"; + this.button3.UseVisualStyleBackColor = true; + this.button3.Click += new System.EventHandler(this.button3_Click_1); + // // FrmFileCURD // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(971, 815); + this.Controls.Add(this.button3); this.Controls.Add(this.txtReleaseConfig); this.Controls.Add(this.txtUpdateSW); this.Controls.Add(this.btnAddReleaseConfig); @@ -504,5 +516,6 @@ private System.Windows.Forms.Button btnAddReleaseConfig; private System.Windows.Forms.TextBox txtUpdateSW; private System.Windows.Forms.TextBox txtReleaseConfig; + private System.Windows.Forms.Button button3; } } \ No newline at end of file diff --git a/Common/Ui/GenesisToolBox/FrmFileCURD.cs b/Common/Ui/GenesisToolBox/FrmFileCURD.cs index 40f2ad03..f22e4edc 100644 --- a/Common/Ui/GenesisToolBox/FrmFileCURD.cs +++ b/Common/Ui/GenesisToolBox/FrmFileCURD.cs @@ -11,7 +11,7 @@ using Xylem.Common.CommonCore.Configuration; using Xylem.Common.Logic.ProductionOrderCore.FW; using Xylem.Common.Logic.ProductionOrderCore.OrderData; using Xylem.Common.Logic.SoftwareAccessHelper; - +using Xylem.ServiceFwUpdate.Common.FwUpdateDb; namespace Xylem.Common.Ui.GenesisToolBox { @@ -568,5 +568,40 @@ namespace Xylem.Common.Ui.GenesisToolBox { } + + private void button3_Click_1(Object sender, EventArgs e) + { + //var fwUpdRpt = new List(); + //try + //{ + // var url = ServiceUrls.DownloadFwUpdateReportServiceUrl(); + // if (pcbId > 0) + // { + // url += $"PcbId={pcbId}"; + // if (userId > 0) url += $"&UserId={userId}"; + // if (orderNr > 0) url += $"&OrderNr={orderNr}"; + // } + // else if (userId > 0) + // { + // url += $"UserId={userId}"; + // if (orderNr > 0) url += $"&OrderNr={orderNr}"; + // } + // else if (orderNr > 0) + // { + // url += $"OrderNr={orderNr}"; + // } + + // url += $"&readContent={readContent}"; + + // var requestResponse = LocalWebRequest.GetRequest(url, 20000); + // if (string.IsNullOrEmpty(requestResponse)) + // { + // DbIsConnected = false; + // return false; + // } + + // DbIsConnected = true; + // fwUpdRpt = JsonConvert.DeserializeObject>(requestResponse); + } } } diff --git a/Common/Ui/GenesisToolBox/FrmLowLevelTools.Designer.cs b/Common/Ui/GenesisToolBox/FrmLowLevelTools.Designer.cs index 2de8b0a7..ff022b65 100644 --- a/Common/Ui/GenesisToolBox/FrmLowLevelTools.Designer.cs +++ b/Common/Ui/GenesisToolBox/FrmLowLevelTools.Designer.cs @@ -80,6 +80,7 @@ this.label3 = new System.Windows.Forms.Label(); this.tbxFileToEraseDrive = new System.Windows.Forms.TextBox(); this.btnEraseFile = new System.Windows.Forms.Button(); + this.btnUploadPWFile = new System.Windows.Forms.Button(); this.grpSetup.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); this.groupBox1.SuspendLayout(); @@ -488,6 +489,7 @@ // // groupBox2 // + this.groupBox2.Controls.Add(this.btnUploadPWFile); this.groupBox2.Controls.Add(this.ddlLocation); this.groupBox2.Controls.Add(this.btnReadBatAndLog); this.groupBox2.Controls.Add(this.btnListFileDetails); @@ -495,7 +497,7 @@ this.groupBox2.Controls.Add(this.btnUploadConfig); this.groupBox2.Location = new System.Drawing.Point(417, 69); this.groupBox2.Name = "groupBox2"; - this.groupBox2.Size = new System.Drawing.Size(136, 150); + this.groupBox2.Size = new System.Drawing.Size(136, 183); this.groupBox2.TabIndex = 37; this.groupBox2.TabStop = false; this.groupBox2.Text = "Log"; @@ -605,6 +607,16 @@ this.btnEraseFile.UseVisualStyleBackColor = true; this.btnEraseFile.Click += new System.EventHandler(this.btnEraseFile_Click); // + // btnUploadPWFile + // + this.btnUploadPWFile.Location = new System.Drawing.Point(10, 145); + this.btnUploadPWFile.Name = "btnUploadPWFile"; + this.btnUploadPWFile.Size = new System.Drawing.Size(116, 25); + this.btnUploadPWFile.TabIndex = 42; + this.btnUploadPWFile.Text = "Upload Config"; + this.btnUploadPWFile.UseVisualStyleBackColor = true; + this.btnUploadPWFile.Click += new System.EventHandler(this.btnUploadPWFile_Click); + // // FrmLowLevelTools // this.AccessibleRole = System.Windows.Forms.AccessibleRole.Sound; @@ -701,5 +713,6 @@ private System.Windows.Forms.Button btnPulseModeOff; private System.Windows.Forms.ComboBox ddlLocation; private System.Windows.Forms.Button btnReadBatAndLog; + private System.Windows.Forms.Button btnUploadPWFile; } } \ No newline at end of file diff --git a/Common/Ui/GenesisToolBox/FrmLowLevelTools.cs b/Common/Ui/GenesisToolBox/FrmLowLevelTools.cs index e4a48cc2..0276e303 100644 --- a/Common/Ui/GenesisToolBox/FrmLowLevelTools.cs +++ b/Common/Ui/GenesisToolBox/FrmLowLevelTools.cs @@ -1267,6 +1267,65 @@ namespace Xylem.Common.Ui.GenesisToolBox }); } + /// + /// Read config file from meter and store it to disk. + /// + /// + /// - Initial + /// + private void btnUploadPWFile_Click(Object sender, EventArgs e) + { + + if (_currentGenesis == null) + { + return; + } + + if (_meterFile == null) + { + _meterFile = new MeterFile(_currentGenesis); + } + + //reset timer + _startTime = DateTimeOffset.UtcNow; + + LowLevelActionControl(true); + + var msg = @"Upload configuration file from meter"; + LogText(msg); + lblOverall.Text = msg; + lblActualProcess.Text = @"Read config file"; + + var rawData = new List(); + + Task.Factory.StartNew(() => + { + _currentGenesis.ReLogin(); + _meterFile.ReadMeterFile("0\\password", out var data); + rawData.AddRange(data); + }).ContinueWith(delegate + { + Invoke(new Action(() => + { + if (saveConfigFile.ShowDialog() == DialogResult.OK) + { + var fs = new FileStream(saveConfigFile.FileName, FileMode.OpenOrCreate); + var bw = new BinaryWriter(fs); + foreach (var t in rawData) + { + bw.Write(t); + } + + fs.Close(); + } + })); + + //add a blank line to separate next operation + LogText(""); + _currentGenesis.Logout(); + LowLevelActionControl(false); + }); + } /// /// Set date and time from PC to Cordonel /// diff --git a/Common/Ui/GenesisToolBox/FrmQsTool.Designer.cs b/Common/Ui/GenesisToolBox/FrmQsTool.Designer.cs new file mode 100644 index 00000000..48009e00 --- /dev/null +++ b/Common/Ui/GenesisToolBox/FrmQsTool.Designer.cs @@ -0,0 +1,137 @@ +namespace Xylem.Common.Ui.GenesisToolBox +{ + partial class FrmQsTool + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.lblState = new System.Windows.Forms.Label(); + this.btnConnect = new System.Windows.Forms.Button(); + this.label1 = new System.Windows.Forms.Label(); + this.cbComSlot = new System.Windows.Forms.ComboBox(); + this.btnWrite = new System.Windows.Forms.Button(); + this.btnRead = new System.Windows.Forms.Button(); + this.btnLogout = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // lblState + // + this.lblState.AutoSize = true; + this.lblState.Location = new System.Drawing.Point(12, 51); + this.lblState.Name = "lblState"; + this.lblState.Size = new System.Drawing.Size(78, 13); + this.lblState.TabIndex = 9; + this.lblState.Text = "Not connected"; + // + // btnConnect + // + this.btnConnect.Location = new System.Drawing.Point(212, 8); + this.btnConnect.Name = "btnConnect"; + this.btnConnect.Size = new System.Drawing.Size(85, 30); + this.btnConnect.TabIndex = 8; + this.btnConnect.Text = "Connect"; + this.btnConnect.UseVisualStyleBackColor = true; + this.btnConnect.Click += new System.EventHandler(this.btnConnect_Click); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(12, 21); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(25, 13); + this.label1.TabIndex = 7; + this.label1.Text = "Slot"; + // + // cbComSlot + // + this.cbComSlot.FormattingEnabled = true; + this.cbComSlot.Location = new System.Drawing.Point(83, 12); + this.cbComSlot.Name = "cbComSlot"; + this.cbComSlot.Size = new System.Drawing.Size(104, 21); + this.cbComSlot.TabIndex = 6; + this.cbComSlot.Text = "1"; + // + // btnWrite + // + this.btnWrite.Location = new System.Drawing.Point(24, 164); + this.btnWrite.Name = "btnWrite"; + this.btnWrite.Size = new System.Drawing.Size(129, 53); + this.btnWrite.TabIndex = 1; + this.btnWrite.Text = "Led Off"; + this.btnWrite.UseVisualStyleBackColor = true; + this.btnWrite.Click += new System.EventHandler(this.btnWrite_Click); + // + // btnRead + // + this.btnRead.Location = new System.Drawing.Point(24, 105); + this.btnRead.Name = "btnRead"; + this.btnRead.Size = new System.Drawing.Size(129, 53); + this.btnRead.TabIndex = 0; + this.btnRead.Text = "Lifetime Read"; + this.btnRead.UseVisualStyleBackColor = true; + this.btnRead.Click += new System.EventHandler(this.btnRead_Click); + // + // btnLogout + // + this.btnLogout.Location = new System.Drawing.Point(303, 8); + this.btnLogout.Name = "btnLogout"; + this.btnLogout.Size = new System.Drawing.Size(85, 30); + this.btnLogout.TabIndex = 12; + this.btnLogout.Text = "Logout"; + this.btnLogout.UseVisualStyleBackColor = true; + this.btnLogout.Click += new System.EventHandler(this.btnLogout_Click); + // + // FrmQsTool + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(587, 450); + this.Controls.Add(this.btnLogout); + this.Controls.Add(this.lblState); + this.Controls.Add(this.btnConnect); + this.Controls.Add(this.label1); + this.Controls.Add(this.cbComSlot); + this.Controls.Add(this.btnRead); + this.Controls.Add(this.btnWrite); + this.Name = "FrmQsTool"; + this.Text = "FrmConfigurations"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmConfigurations_FormClosing); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label lblState; + private System.Windows.Forms.Button btnConnect; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.ComboBox cbComSlot; + private System.Windows.Forms.Button btnLogout; + private System.Windows.Forms.Button btnWrite; + private System.Windows.Forms.Button btnRead; + } +} \ No newline at end of file diff --git a/Common/Ui/GenesisToolBox/FrmQsTool.cs b/Common/Ui/GenesisToolBox/FrmQsTool.cs new file mode 100644 index 00000000..9a03071e --- /dev/null +++ b/Common/Ui/GenesisToolBox/FrmQsTool.cs @@ -0,0 +1,242 @@ +using Newtonsoft.Json; +using NLog; +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; +using System.Windows.Forms; +using Xylem.Common.CommonCore.Consts; +using Xylem.Common.Hardware.Interfaces.Ports.PortCore; +using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisConfig; +using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore; +using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisStatus; +using Xylem.Common.Hardware.WaterMeter.Genesis.Registers; +using Xylem.Common.Hardware.WaterMeter.WaterMeterCore; +using Xylem.Common.Utils.Logging; + +namespace Xylem.Common.Ui.GenesisToolBox +{ + + + + + + public partial class FrmQsTool : Form + { + private GenesisMeter _currentGenesis; + private String _currentPcbId; + private MeterBatch _meterBatch = new MeterBatch(); + private readonly ILogger logger = NLogHelper.CreateOrGetLogger("GenesisConfigurator"); + + public FrmQsTool() + { + InitializeComponent(); + + + _meterBatch = new MeterBatch(); + + var configfile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), nameof(Xylem.Common.Hardware.WaterMeter.Genesis), ProgramConfig.SerialConfigFileName); + + if (!File.Exists(configfile)) + { + throw new ApplicationException($"Configuration file {configfile} not found "); + } + var tr = new StreamReader(configfile); + var meterConfigList = JsonConvert.DeserializeObject(tr.ReadToEnd()); + cbComSlot.Items.Clear(); + var listSlots = new List(); + foreach (var item in meterConfigList) + { + cbComSlot.Items.Add(item.Slot); + listSlots.Add(item.Slot); + } + if (cbComSlot.Items.Count >= 1) + { + cbComSlot.SelectedItem = cbComSlot.Items[0]; + } + + //foreach (var info in typeof(Register).GetNestedTypes()) + //{ + // cbPreselection.Items.Add(info.Name); + //} + } + + private void btnLogout_Click(Object sender, EventArgs e) + { + if (_currentGenesis != null && _currentGenesis.IsLoggedOn) + { + _currentGenesis.Logout(); + } + + _currentPcbId = ""; + + } + + private void btnConnect_Click(Object sender, EventArgs e) + { + if (cbComSlot.SelectedItem != null) // && cbComSlot.SelectedValue is ListBoxItem) + { + Int32 slotNR = 0; + if (!string.IsNullOrEmpty(cbComSlot.SelectedItem.ToString()) && + int.TryParse(cbComSlot.SelectedItem.ToString(), out slotNR)) + { + conntect(slotNR); + + } + } + } + + private void btnRead_Click(Object sender, EventArgs e) + { + if (_currentGenesis != null && _currentGenesis.IsLoggedOn) + { + if (cbComSlot.SelectedItem == null) + { + return; + } + + if (string.IsNullOrEmpty(cbComSlot.SelectedItem.ToString()) || + !int.TryParse(cbComSlot.SelectedItem.ToString(), out var slotNR)) + { + return; + } + + try + { + //conntect(slotNR); + foreach (var me in _meterBatch.ListOfMeters) + { + if (me is GenesisMeter) + { + if (((GenesisMeter)me).IsLoggedOn) + { + _currentGenesis = ((GenesisMeter)me); + + var genesisStatus = new GenesisStatus(); + if (GenesisStatusHandler.BuildLifeTimeInformation(_currentGenesis, genesisStatus)) + { + + var sbMSG = new StringBuilder(); + sbMSG.AppendLine($"Pcb = {_currentGenesis.PcbId}"); + + sbMSG.AppendLine($"POWERMON_TotalUsedSeconds = {genesisStatus.ExceededLifeTime_s}"); + sbMSG.AppendLine($"POWERMON_TotalUsedCharge = {genesisStatus.DrainedBatteryLoad_uAs}"); + sbMSG.AppendLine($"POWERMON_BatteryQuantity = {genesisStatus.BatteryQuantity}"); + sbMSG.AppendLine($"POWERMON_BatteryMilliAHrRating = {genesisStatus.InitialBatteryLoad_mAh}"); + sbMSG.AppendLine(""); + sbMSG.AppendLine($"Remaining life time in years {genesisStatus.RemainingLifeTimeYears:F2}"); + sbMSG.AppendLine($"Totally drained battery load in % {genesisStatus.DrainedBatteryLoadPercent:F2}"); + + MessageBox.Show(sbMSG.ToString(), $"Battery for {_currentGenesis.PcbId} has remaining life " + + $"time of {genesisStatus.RemainingLifeTimeYears:F2} years"); + } + else + { + MessageBox.Show("Failed to get life time information"); + } + } + } + } + } + catch (Exception ex) + { + MessageBox.Show(ex.ToString()); + } + + + } + + + + } + + private void btnWrite_Click(Object sender, EventArgs e) + { + + if (cbComSlot.SelectedItem == null) + { + return; + } + + if (string.IsNullOrEmpty(cbComSlot.SelectedItem.ToString()) || + !int.TryParse(cbComSlot.SelectedItem.ToString(), out var slotNR)) + { + return; + } + if (!_currentGenesis.IsLoggedOn) + { + _currentGenesis.Login(); + + } + _currentGenesis.WriteRegister(Register.Genesisflow.SampleRate, 2); + _currentGenesis.WriteRegister(Register.Genesisflow.LedMode, 0); + _currentGenesis.WriteRegister(Register.Genesisflow.TriggerActive, 1); + + } + + + private void conntect(Int32 slotNR) + { + try + { + _meterBatch.RemoveAllMeters(); + _currentGenesis = new GenesisMeter(); + //_currentGenesis.IsDevelopmentUsage = true; //Make sure to set this before login + try + { + _currentGenesis.SetupFromConfigFile(slotNR); + _currentGenesis.EnableAutoLogon(); + _meterBatch.AddMeter(_currentGenesis); + } + catch (Exception ex) + { + logger.Error(ex, $"Slot #{slotNR} failed: {ex.Message}"); + lblState.Text = "Failed"; + } + _currentGenesis.Login(); + _currentPcbId = _currentGenesis.PcbId; + + if (_currentGenesis.IsLoggedOn) + { + lblState.Text = _currentGenesis.PcbId; + } + else + { + lblState.Text = "Failed"; + } + + + } + catch (Exception ex) + { + logger.Error(ex, ex.Message); + } + } + + + private void btnDisplayDefault_Click(Object sender, EventArgs e) + { + + if (_currentGenesis != null && _currentGenesis.IsLoggedOn) + { + + _currentGenesis.WriteRegister("GENESISFLOW_SealDisplay", 0); + _currentGenesis.WriteRegister("CUSTOMER_Locale", 0); + _currentGenesis.WriteRegister("GENESISFLOW_DisplayPow10", 253); + _currentGenesis.WriteRegister("GENESISFLOW_DisplayUnits", 0); + _currentGenesis.WriteRegister("METROLOGYASST_FlowUnits", 1); + _currentGenesis.StoreAllConfigurations(); + _currentGenesis.WriteRegister("SENSUSRADIO_SYSTEMSTATE", 0xFF, true, false); + } + } + + + + + private void FrmConfigurations_FormClosing(Object sender, FormClosingEventArgs e) + { + _meterBatch.Dispose(); + } + } +} + diff --git a/Common/Ui/GenesisToolBox/FrmQsTool.resx b/Common/Ui/GenesisToolBox/FrmQsTool.resx new file mode 100644 index 00000000..1af7de15 --- /dev/null +++ b/Common/Ui/GenesisToolBox/FrmQsTool.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Common/Ui/GenesisToolBox/GenesisToolBox.csproj b/Common/Ui/GenesisToolBox/GenesisToolBox.csproj index f8786c75..664552da 100644 --- a/Common/Ui/GenesisToolBox/GenesisToolBox.csproj +++ b/Common/Ui/GenesisToolBox/GenesisToolBox.csproj @@ -224,6 +224,12 @@ FrmCalibrationResults.cs + + Form + + + FrmQsTool.cs + Form @@ -461,6 +467,9 @@ FrmCalibrationResults.cs + + FrmQsTool.cs + FrmConfigurations.cs @@ -628,6 +637,10 @@
+ + {4806D89A-FBFB-41BC-AAA7-2242444BF55A} + FwUpdateDb + {9EB1F659-6F73-4F65-BCAB-4114FD94F5FC} CommonCore.Configuration diff --git a/Common/Ui/GenesisToolBox/frmLeagcyTestApp.cs b/Common/Ui/GenesisToolBox/frmLeagcyTestApp.cs index 7192da00..daa4b9f4 100644 --- a/Common/Ui/GenesisToolBox/frmLeagcyTestApp.cs +++ b/Common/Ui/GenesisToolBox/frmLeagcyTestApp.cs @@ -428,12 +428,13 @@ namespace GenesisToolBox container.meterTestSettings[i].FlowTesting = true; container.meterTestSettings[i].PreAdjustment = false; container.meterTestSettings[i].SerialNr = $"450000{slotNr}"; - container.meterTestSettings[i].meterType = MeterTypes.MagFlux; + container.meterTestSettings[i].meterType = MeterTypes.eRegister; + } i++; } - + ctlBatch.SetTestSetupContainer(container); diff --git a/Common/Ui/GenesisToolBox/frmMainForm.Designer.cs b/Common/Ui/GenesisToolBox/frmMainForm.Designer.cs index de24ac86..6544e498 100644 --- a/Common/Ui/GenesisToolBox/frmMainForm.Designer.cs +++ b/Common/Ui/GenesisToolBox/frmMainForm.Designer.cs @@ -42,7 +42,7 @@ this.gpLAA = new System.Windows.Forms.GroupBox(); this.button5 = new System.Windows.Forms.Button(); this.button2 = new System.Windows.Forms.Button(); - this.btnPara = new System.Windows.Forms.Button(); + this.btnQsTool = new System.Windows.Forms.Button(); this.btnRegHistory = new System.Windows.Forms.Button(); this.btnPassword = new System.Windows.Forms.Button(); this.btnLowLevelTools = new System.Windows.Forms.Button(); @@ -190,13 +190,13 @@ // this.gpLAA.Controls.Add(this.button5); this.gpLAA.Controls.Add(this.button2); - this.gpLAA.Controls.Add(this.btnPara); + this.gpLAA.Controls.Add(this.btnQsTool); this.gpLAA.Controls.Add(this.btnRegHistory); this.gpLAA.Controls.Add(this.btnPassword); this.gpLAA.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.gpLAA.Location = new System.Drawing.Point(186, 27); this.gpLAA.Name = "gpLAA"; - this.gpLAA.Size = new System.Drawing.Size(168, 235); + this.gpLAA.Size = new System.Drawing.Size(168, 245); this.gpLAA.TabIndex = 20; this.gpLAA.TabStop = false; this.gpLAA.Text = "Production LAA"; @@ -225,17 +225,17 @@ this.button2.UseVisualStyleBackColor = true; this.button2.Click += new System.EventHandler(this.button2_Click_1); // - // btnPara + // btnQsTool // - this.btnPara.Enabled = false; - this.btnPara.Location = new System.Drawing.Point(5, 103); - this.btnPara.Name = "btnPara"; - this.btnPara.Size = new System.Drawing.Size(156, 40); - this.btnPara.TabIndex = 19; - this.btnPara.Text = "Parameterization"; - this.btnPara.UseMnemonic = false; - this.btnPara.UseVisualStyleBackColor = true; - this.btnPara.Click += new System.EventHandler(this.btnPara_Click); + this.btnQsTool.Enabled = false; + this.btnQsTool.Location = new System.Drawing.Point(5, 103); + this.btnQsTool.Name = "btnQsTool"; + this.btnQsTool.Size = new System.Drawing.Size(156, 40); + this.btnQsTool.TabIndex = 19; + this.btnQsTool.Text = "QS Tool"; + this.btnQsTool.UseMnemonic = false; + this.btnQsTool.UseVisualStyleBackColor = true; + this.btnQsTool.Click += new System.EventHandler(this.btnQsTool_Click); // // btnRegHistory // @@ -261,7 +261,7 @@ // // btnLowLevelTools // - this.btnLowLevelTools.Location = new System.Drawing.Point(4, 158); + this.btnLowLevelTools.Location = new System.Drawing.Point(4, 153); this.btnLowLevelTools.Name = "btnLowLevelTools"; this.btnLowLevelTools.Size = new System.Drawing.Size(157, 40); this.btnLowLevelTools.TabIndex = 22; @@ -277,9 +277,9 @@ this.gbDeveloper.Controls.Add(this.btnFiles); this.gbDeveloper.Controls.Add(this.btnLegacyTestApp); this.gbDeveloper.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.gbDeveloper.Location = new System.Drawing.Point(186, 282); + this.gbDeveloper.Location = new System.Drawing.Point(186, 293); this.gbDeveloper.Name = "gbDeveloper"; - this.gbDeveloper.Size = new System.Drawing.Size(168, 204); + this.gbDeveloper.Size = new System.Drawing.Size(168, 193); this.gbDeveloper.TabIndex = 21; this.gbDeveloper.TabStop = false; this.gbDeveloper.Text = "Developer"; @@ -288,7 +288,7 @@ // BtnFileSplit // this.BtnFileSplit.Enabled = false; - this.BtnFileSplit.Location = new System.Drawing.Point(4, 114); + this.BtnFileSplit.Location = new System.Drawing.Point(4, 111); this.BtnFileSplit.Name = "BtnFileSplit"; this.BtnFileSplit.Size = new System.Drawing.Size(157, 40); this.BtnFileSplit.TabIndex = 18; @@ -300,7 +300,7 @@ // btnFiles // this.btnFiles.Enabled = false; - this.btnFiles.Location = new System.Drawing.Point(4, 68); + this.btnFiles.Location = new System.Drawing.Point(4, 65); this.btnFiles.Name = "btnFiles"; this.btnFiles.Size = new System.Drawing.Size(157, 40); this.btnFiles.TabIndex = 16; @@ -311,7 +311,7 @@ // btnLegacyTestApp // this.btnLegacyTestApp.Enabled = false; - this.btnLegacyTestApp.Location = new System.Drawing.Point(4, 24); + this.btnLegacyTestApp.Location = new System.Drawing.Point(4, 19); this.btnLegacyTestApp.Name = "btnLegacyTestApp"; this.btnLegacyTestApp.Size = new System.Drawing.Size(157, 40); this.btnLegacyTestApp.TabIndex = 15; @@ -343,14 +343,14 @@ // loginMenuItem // this.loginMenuItem.Name = "loginMenuItem"; - this.loginMenuItem.Size = new System.Drawing.Size(180, 22); + this.loginMenuItem.Size = new System.Drawing.Size(112, 22); this.loginMenuItem.Text = "Login"; this.loginMenuItem.Click += new System.EventHandler(this.OnLoginClick); // // logoutMenuItem // this.logoutMenuItem.Name = "logoutMenuItem"; - this.logoutMenuItem.Size = new System.Drawing.Size(180, 22); + this.logoutMenuItem.Size = new System.Drawing.Size(112, 22); this.logoutMenuItem.Text = "Logout"; this.logoutMenuItem.Click += new System.EventHandler(this.OnLogoutClick); // @@ -392,7 +392,7 @@ private System.Windows.Forms.Button btnAlarm; private System.Windows.Forms.Button btnSetup; private System.Windows.Forms.GroupBox gpLAA; - private System.Windows.Forms.Button btnPara; + private System.Windows.Forms.Button btnQsTool; private System.Windows.Forms.Button btnRegHistory; private System.Windows.Forms.Button btnPassword; private System.Windows.Forms.GroupBox gbDeveloper; diff --git a/Common/Ui/GenesisToolBox/frmMainForm.cs b/Common/Ui/GenesisToolBox/frmMainForm.cs index a7f99fce..cf6f7326 100644 --- a/Common/Ui/GenesisToolBox/frmMainForm.cs +++ b/Common/Ui/GenesisToolBox/frmMainForm.cs @@ -419,7 +419,7 @@ btnPassword.Tag = SoftwareFunctions.LAA_PASSWORD; btnRegHistory.Tag = SoftwareFunctions.LAA_REGISTER_HISTORY; - btnPara.Tag = SoftwareFunctions.LAA_PARAMETERIZATION; + btnQsTool.Tag = SoftwareFunctions.LAA_PARAMETERIZATION; button2.Tag = SoftwareFunctions.LAA_PROCESS_PARAMETER; button5.Tag = SoftwareFunctions.LAA_MAPPING_NA; @@ -550,5 +550,13 @@ } #endregion Form initialization + + private void btnQsTool_Click(Object sender, EventArgs e) + { + var form = new FrmQsTool(); + form.Show(); + form.Closed += Form_Closed; + Hide(); + } } } diff --git a/Common/Ui/GenesisToolBox/frmMainForm.resx b/Common/Ui/GenesisToolBox/frmMainForm.resx index 13fa4e76..c99000d9 100644 --- a/Common/Ui/GenesisToolBox/frmMainForm.resx +++ b/Common/Ui/GenesisToolBox/frmMainForm.resx @@ -120,4 +120,7 @@ 17, 17 + + 25 + \ No newline at end of file diff --git a/Common/Ui/GenesisToolBox/frmPassword.Designer.cs b/Common/Ui/GenesisToolBox/frmPassword.Designer.cs index c22ea105..ce94f1bb 100644 --- a/Common/Ui/GenesisToolBox/frmPassword.Designer.cs +++ b/Common/Ui/GenesisToolBox/frmPassword.Designer.cs @@ -30,7 +30,6 @@ { this.components = new System.ComponentModel.Container(); this.btnGet = new System.Windows.Forms.Button(); - this.btnSet = new System.Windows.Forms.Button(); this.txtPcbID = new System.Windows.Forms.TextBox(); this.txtSkeletonKey = new System.Windows.Forms.TextBox(); this.lblPcbID = new System.Windows.Forms.Label(); @@ -52,6 +51,8 @@ this.barProgressDb = new System.Windows.Forms.ProgressBar(); this.tmrProgressPcb = new System.Windows.Forms.Timer(this.components); this.tmrProgressDb = new System.Windows.Forms.Timer(this.components); + this.label4 = new System.Windows.Forms.Label(); + this.txtProductionPassword = new System.Windows.Forms.TextBox(); this.grpSetup.SuspendLayout(); this.grpDataBase.SuspendLayout(); this.SuspendLayout(); @@ -66,16 +67,6 @@ this.btnGet.UseVisualStyleBackColor = true; this.btnGet.Click += new System.EventHandler(this.btnGet_Click); // - // btnSet - // - this.btnSet.Location = new System.Drawing.Point(291, 64); - this.btnSet.Name = "btnSet"; - this.btnSet.Size = new System.Drawing.Size(54, 25); - this.btnSet.TabIndex = 1; - this.btnSet.Text = "Set"; - this.btnSet.UseVisualStyleBackColor = true; - this.btnSet.Click += new System.EventHandler(this.btnSet_Click); - // // txtPcbID // this.txtPcbID.Location = new System.Drawing.Point(9, 67); @@ -194,6 +185,8 @@ // // grpDataBase // + this.grpDataBase.Controls.Add(this.label4); + this.grpDataBase.Controls.Add(this.txtProductionPassword); this.grpDataBase.Controls.Add(this.label3); this.grpDataBase.Controls.Add(this.txtLvl8); this.grpDataBase.Controls.Add(this.btnErasePwdFile); @@ -205,7 +198,6 @@ this.grpDataBase.Controls.Add(this.lblPcbID); this.grpDataBase.Controls.Add(this.txtSkeletonKey); this.grpDataBase.Controls.Add(this.txtPcbID); - this.grpDataBase.Controls.Add(this.btnSet); this.grpDataBase.Controls.Add(this.btnGet); this.grpDataBase.Location = new System.Drawing.Point(7, 101); this.grpDataBase.Name = "grpDataBase"; @@ -279,6 +271,24 @@ this.barProgressDb.TabIndex = 24; this.barProgressDb.Visible = false; // + // label4 + // + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(121, 129); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(50, 13); + this.label4.TabIndex = 32; + this.label4.Text = "Prod PW"; + //this.label4.Click += new System.EventHandler(this.label4_Click); + // + // txtProductionPassword + // + this.txtProductionPassword.Location = new System.Drawing.Point(116, 145); + this.txtProductionPassword.Name = "txtProductionPassword"; + this.txtProductionPassword.Size = new System.Drawing.Size(102, 20); + this.txtProductionPassword.TabIndex = 31; + //this.txtProductionPassword.TextChanged += new System.EventHandler(this.textBox1_TextChanged); + // // FrmPassword // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -301,7 +311,6 @@ #endregion private System.Windows.Forms.Button btnGet; - private System.Windows.Forms.Button btnSet; private System.Windows.Forms.TextBox txtPcbID; private System.Windows.Forms.TextBox txtSkeletonKey; private System.Windows.Forms.Label lblPcbID; @@ -323,5 +332,7 @@ private System.Windows.Forms.Button btnErasePwdFile; private System.Windows.Forms.Label label3; private System.Windows.Forms.TextBox txtLvl8; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.TextBox txtProductionPassword; } } \ No newline at end of file diff --git a/Common/Ui/GenesisToolBox/frmPassword.cs b/Common/Ui/GenesisToolBox/frmPassword.cs index b403c0c2..090f95bc 100644 --- a/Common/Ui/GenesisToolBox/frmPassword.cs +++ b/Common/Ui/GenesisToolBox/frmPassword.cs @@ -253,7 +253,7 @@ namespace Xylem.Common.Ui.GenesisToolBox txtPcbID.Text = ""; txtSkeletonKey.Text = ""; btnGet.Enabled = false; - btnSet.Enabled = false; + //btnSet.Enabled = false; if (!string.IsNullOrEmpty(cbComSlot.SelectedItem.ToString()) && int.TryParse(cbComSlot.SelectedItem.ToString(), out slotNr)) { @@ -327,7 +327,7 @@ namespace Xylem.Common.Ui.GenesisToolBox txtPcbID.Text = ""; txtSkeletonKey.Text = ""; btnGet.Enabled = false; - btnSet.Enabled = false; + btnWritePwdFile.Enabled = false; } @@ -353,11 +353,11 @@ namespace Xylem.Common.Ui.GenesisToolBox if (txtPcbID.Text.Length > 7 && txtSkeletonKey.Text.Length == 12 && lblConnectPcb.Text == StrNotConnected) { - btnSet.Enabled = true; + //btnSet.Enabled = true; } else { - btnSet.Enabled = false; + //btnSet.Enabled = false; } } diff --git a/Common/Ui/GenesisToolBox/frmRegisterStore.resx b/Common/Ui/GenesisToolBox/frmRegisterStore.resx index 4f7ffa5a..a284be9b 100644 --- a/Common/Ui/GenesisToolBox/frmRegisterStore.resx +++ b/Common/Ui/GenesisToolBox/frmRegisterStore.resx @@ -123,4 +123,7 @@ 133, 17 + + 26 + \ No newline at end of file diff --git a/Common/Ui/GenesisToolBox/packages.config b/Common/Ui/GenesisToolBox/packages.config index a1e8efea..2521e3a4 100644 --- a/Common/Ui/GenesisToolBox/packages.config +++ b/Common/Ui/GenesisToolBox/packages.config @@ -1,6 +1,5 @@  - diff --git a/Common/Ui/LegacyGenesisControl/ITstCont.cs b/Common/Ui/LegacyGenesisControl/ITstCont.cs index 031b5629..154072fc 100644 --- a/Common/Ui/LegacyGenesisControl/ITstCont.cs +++ b/Common/Ui/LegacyGenesisControl/ITstCont.cs @@ -38,7 +38,7 @@ namespace XylemCommonUiLegacyGenCtl - void SetMeterTestSettings(int Slot, string SerialNr, bool FlowAdjustment, double FlowAdjustmentTarget, bool PreAdjustment, bool FlowTesting, bool MagFlux, bool Cordonel, bool ReversFlow); + void SetMeterTestSettings(int Slot, string SerialNr, bool FlowAdjustment, double FlowAdjustmentTarget, bool PreAdjustment, bool FlowTesting, bool MagFlux, bool Cordonel,bool eRegister, bool ReversFlow); string GetMeterSerialNr(int Slot); bool GetFlowAdjustment(int Slot); bool GetPreAdjustment(int Slot); diff --git a/Common/Ui/LegacyGenesisControl/LegacyGenCtl.csproj b/Common/Ui/LegacyGenesisControl/LegacyGenCtl.csproj index 99c99052..0ce6fce8 100644 --- a/Common/Ui/LegacyGenesisControl/LegacyGenCtl.csproj +++ b/Common/Ui/LegacyGenesisControl/LegacyGenCtl.csproj @@ -205,6 +205,10 @@ {8BDD2789-96D4-43EA-AAD7-0F49D0347998} ProtocolCore + + {A83696BF-D8A2-4809-8424-CFE172AED5B6} + eRegisterCore + {0E524D43-7B66-45CD-AA74-41D51AFC3D99} DataPackages diff --git a/Common/Ui/LegacyGenesisControl/PreAdjWr.cs b/Common/Ui/LegacyGenesisControl/PreAdjWr.cs index 83743c9c..0a1262ff 100644 --- a/Common/Ui/LegacyGenesisControl/PreAdjWr.cs +++ b/Common/Ui/LegacyGenesisControl/PreAdjWr.cs @@ -300,7 +300,7 @@ namespace XylemCommonUiLegacyGenCtl var c = TestsetuptContainer.meterTestSettings.Count(); - TestsetuptContainer.meterTestResults = new MeterTestResults[c]; + TestsetuptContainer.meterTestResults = new MeterTestResults[10]; int WaitTimeM = 5; wrappedControl.StatusLabel("MagFlux Zeroflow is running"); diff --git a/Common/Ui/LegacyGenesisControl/TstContHlp.cs b/Common/Ui/LegacyGenesisControl/TstContHlp.cs index 86bcc775..e35050dc 100644 --- a/Common/Ui/LegacyGenesisControl/TstContHlp.cs +++ b/Common/Ui/LegacyGenesisControl/TstContHlp.cs @@ -178,7 +178,7 @@ namespace XylemCommonUiLegacyGenCtl #region MeterStuff - public void SetMeterTestSettings(int Slot, string SerialNr, bool FlowAdjustment, double FlowAdjustmentTarget, bool PreAdjustment, bool FlowTesting, bool MagFlux, bool Cordonel,bool ReversFlow) + public void SetMeterTestSettings(int Slot, string SerialNr, bool FlowAdjustment, double FlowAdjustmentTarget, bool PreAdjustment, bool FlowTesting, bool MagFlux, bool Cordonel,bool eRegister,bool ReversFlow) { HanldWrongInputMeters(Slot); @@ -208,6 +208,11 @@ namespace XylemCommonUiLegacyGenCtl { testSetup.meterTestSettings[Slot - 1].meterType = Xylem.Common.Hardware.WaterMeter.WaterMeterCore.MeterTypes.Cordonel; } + if (eRegister) + { + testSetup.meterTestSettings[Slot - 1].meterType = Xylem.Common.Hardware.WaterMeter.WaterMeterCore.MeterTypes.eRegister; + } + testSetup.meterTestSettings[Slot - 1].FlowTestingOnlyForward = true; testSetup.meterTestSettings[Slot - 1].FlowTestingOnlyRevers = false; diff --git a/Common/Ui/LegacyGenesisControl/ctlBatch.cs b/Common/Ui/LegacyGenesisControl/ctlBatch.cs index ac6deec1..31723d2b 100644 --- a/Common/Ui/LegacyGenesisControl/ctlBatch.cs +++ b/Common/Ui/LegacyGenesisControl/ctlBatch.cs @@ -17,6 +17,7 @@ using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; using Xylem.Common.CommonCore.Configuration; +using Xylem.Common.Hardware.WaterMeter.eRegister.eRegisterCore; using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore; using Xylem.Common.Hardware.WaterMeter.Genesis.Registers; using Xylem.Common.Hardware.WaterMeter.MagFlux.MagFluxCore; @@ -760,6 +761,10 @@ namespace XylemCommonUiLegacyGenCtl case MeterTypes.MagFlux: meter = new MagFluxMeter(); break; + case MeterTypes.eRegister: + meter = new eRegisterMeter(); + break; + default: meter = new GenesisMeter(); break; @@ -892,8 +897,8 @@ namespace XylemCommonUiLegacyGenCtl if (!TestSetupContainer.meterTestSettings.Any(f => f != null && f.Slot == slot)) { - TestSetupContainer.meterTestSettings[slot] = new MeterTestSettings() { SerialNr = serialNumber, Slot = slot, FlowAdjustment = true, FlowTesting = true }; - TestSetupContainer.meterTestResults[slot] = new MeterTestResults() { SerialNr = serialNumber, Slot = slot, meterType = MeterTypes.MagFlux, Results = new List() }; + TestSetupContainer.meterTestSettings[slot - 1] = new MeterTestSettings() { SerialNr = serialNumber, Slot = slot, FlowAdjustment = true, FlowTesting = true }; + TestSetupContainer.meterTestResults[slot - 1] = new MeterTestResults() { SerialNr = serialNumber, Slot = slot, meterType = MeterTypes.MagFlux, Results = new List() }; } AddMeter(serialNumber, slot, true); @@ -1001,7 +1006,7 @@ namespace XylemCommonUiLegacyGenCtl //FF-55-00-00 var meter = batch.ListOfMeters.First(f => f.Slot == slot); var state = DisplayCodes.FlowTested; - + if (meter is MagFluxMeter mag) { @@ -1027,11 +1032,11 @@ namespace XylemCommonUiLegacyGenCtl mag.WriteCalibrationTestBench(result.Results); } } - catch (Exception ex ) + catch (Exception ex) { MessageBox.Show(ex.Message); } - + @@ -1546,7 +1551,7 @@ namespace XylemCommonUiLegacyGenCtl } catch (Exception ex) { - + _logger.Error(ex, $"error on GetResults Slot={Slot},Chnnl={Chnnl},refVolQm={refVolQm},refTimeS={refTimeS}"); return null; } @@ -1576,6 +1581,14 @@ namespace XylemCommonUiLegacyGenCtl { t = MeasurementDirection.TakeOnlyForward; } + if (testset.meterType == MeterTypes.eRegister) + { + t = MeasurementDirection.TakeBoth; + } + } + else + { + _logger.Warn($"No TestSetupContainer found ({TestSetupContainer != null}) or no MeterTestsetting found ({TestSetupContainer.meterTestSettings != null}) or no Testsettings for Slot {Slot} found ({TestSetupContainer.meterTestSettings.Any(ts => ts != null && ts.Slot == Slot)}) "); } } catch (Exception ex) @@ -1583,8 +1596,8 @@ namespace XylemCommonUiLegacyGenCtl _logger.Error(ex, $"error on GetResults find Testcontainer Slot={Slot},Chnnl={Chnnl},refVolQm={refVolQm},refTimeS={refTimeS}"); throw; } - - result = GetMeasurementResult(Slot, Chnnl, refVolQm, refTimeS,t); + + result = GetMeasurementResult(Slot, Chnnl, refVolQm, refTimeS, t); if (!result.HasValue) { @@ -1618,32 +1631,38 @@ namespace XylemCommonUiLegacyGenCtl try { - - if (TestSetupContainer.meterTestResults == null) + if (TestSetupContainer != null) { - // MessageBox.Show("meterTestResults emtpty on getresults"); - var countMeters = TestSetupContainer.meterTestSettings?.Count() ?? 10; - - TestSetupContainer.meterTestResults = new MeterTestResults[countMeters]; - } - if (!TestSetupContainer.meterTestResults.Any(f => f != null && f.Slot == Slot)) - { - // MessageBox.Show("meterTestResults not found on getresults"); - TestSetupContainer.meterTestResults[Slot - 1].Results = new List(); - } - - var results = TestSetupContainer.meterTestResults[Slot - 1].Results; - if (!results.Any(f => f.MeasuredRefFlowQmPerH == result.Value.RefFlowRateCmPh)) - { - results.Add(new Xylem.Common.Hardware.WaterMeter.DataPackages.MeasurementRecords.FlowDeviations() + if (TestSetupContainer.meterTestResults == null) { - MeasuredRefFlowQmPerH = result.Value.RefFlowRateCmPh ?? 0, - RefTimeS = result.Value.RefTimeS ?? 0, - RequierdFlowQmPerH = result.Value.RefFlowRateCmPh ?? 0, - RequierdTimeS = result.Value.RefTimeS ?? 0, - MeasuredDutFlowQmPerH = result.Value.DutFlowRateCmPh ?? 0, - DutTimeS = result.Value.DutTimeS, - }); + TestSetupContainer.meterTestResults = new MeterTestResults[10]; + + + } + if (!TestSetupContainer.meterTestResults.Any(f => f != null && f.Slot == Slot)) + { + TestSetupContainer.meterTestResults[Slot - 1] = new MeterTestResults(); + TestSetupContainer.meterTestResults[Slot - 1].Slot = Slot; + TestSetupContainer.meterTestResults[Slot - 1].Results = new List(); + } + + var results = TestSetupContainer.meterTestResults[Slot - 1].Results; + if (!results.Any(f => f.MeasuredRefFlowQmPerH == result.Value.RefFlowRateCmPh)) + { + results.Add(new Xylem.Common.Hardware.WaterMeter.DataPackages.MeasurementRecords.FlowDeviations() + { + MeasuredRefFlowQmPerH = result.Value.RefFlowRateCmPh ?? 0, + RefTimeS = result.Value.RefTimeS ?? 0, + RequierdFlowQmPerH = result.Value.RefFlowRateCmPh ?? 0, + RequierdTimeS = result.Value.RefTimeS ?? 0, + MeasuredDutFlowQmPerH = result.Value.DutFlowRateCmPh ?? 0, + DutTimeS = result.Value.DutTimeS, + }); + } + } + else + { + _logger.Error($"error no TestSetupcontainer on GetResults add testresult Slot={Slot},Chnnl={Chnnl},refVolQm={refVolQm},refTimeS={refTimeS}"); } } catch (Exception ex) @@ -2310,6 +2329,7 @@ namespace XylemCommonUiLegacyGenCtl { if (batch != null) { + batch.DisposeTestBench(); batch.RemoveAllMeters(); batch.Dispose(); } diff --git a/Common/Ui/LegacyGenesisControl/ctlCRdy.cs b/Common/Ui/LegacyGenesisControl/ctlCRdy.cs index 9cd94310..6bd67257 100644 --- a/Common/Ui/LegacyGenesisControl/ctlCRdy.cs +++ b/Common/Ui/LegacyGenesisControl/ctlCRdy.cs @@ -462,6 +462,11 @@ namespace XylemCommonUiLegacyGenCtl { meter.WriteRegister(Register.Genesisflow.TriggerIdle, 0, true, true); } + meter.WriteRegister("GENESISFLOW_SealDisplay", 0, true, true); + meter.WriteRegister("GENESISFLOW_DisplayPow10", new Byte[] { 0x00, 0x00, 0x00, 0xFA }, true, true); + meter.WriteRegister("GENESISFLOW_DisplayUnits", 0, true, true); + + meter.InitMeasurement(); diff --git a/Common/Ui/SPSHelper/SPSCheck/App.config b/Common/Ui/SPSHelper/SPSCheck/App.config new file mode 100644 index 00000000..9c05822f --- /dev/null +++ b/Common/Ui/SPSHelper/SPSCheck/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Common/Ui/SPSHelper/SPSCheck/Program.cs b/Common/Ui/SPSHelper/SPSCheck/Program.cs new file mode 100644 index 00000000..6651ed60 --- /dev/null +++ b/Common/Ui/SPSHelper/SPSCheck/Program.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Xylem.Common.Hardware.Plc.Siemens.Client.TestbenchAdapter; + +namespace SPSCheck +{ + class Program + { + static void Main(string[] args) + { + try + { + var c = new Vb6Testbench(); + + Console.WriteLine("URL:"); + c.Connect(Console.ReadLine()); + + } + catch (Exception ex) + { + + Console.WriteLine(ex.Message) +; } + + } + } +} diff --git a/Common/Ui/SPSHelper/SPSCheck/Properties/AssemblyInfo.cs b/Common/Ui/SPSHelper/SPSCheck/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..5e9827ec --- /dev/null +++ b/Common/Ui/SPSHelper/SPSCheck/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 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("SPSCheck")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("SPSCheck")] +[assembly: AssemblyCopyright("Copyright © 2023")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("1903344f-7ba5-4c38-b672-3ca81aa62b51")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Common/Ui/SPSHelper/SPSCheck/SPSCheck.csproj b/Common/Ui/SPSHelper/SPSCheck/SPSCheck.csproj new file mode 100644 index 00000000..e144ae9b --- /dev/null +++ b/Common/Ui/SPSHelper/SPSCheck/SPSCheck.csproj @@ -0,0 +1,59 @@ + + + + + Debug + AnyCPU + {1903344F-7BA5-4C38-B672-3CA81AA62B51} + Exe + SPSCheck + SPSCheck + v4.5.1 + 512 + true + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + {494AB06C-10C4-43F8-BC8A-92088EB35867} + TestbenchAdapter + + + + \ No newline at end of file diff --git a/ServiceFwUpdate/UI/ServiceFwUpdateSw/Properties/Resources.de.Designer.cs b/ServiceFwUpdate/UI/ServiceFwUpdateSw/Properties/Resources.de.Designer.cs deleted file mode 100644 index e69de29b..00000000 diff --git a/ServiceFwUpdate/Ui/ServiceFwUpdateLoader/FwUpdateLoader.csproj b/ServiceFwUpdate/Ui/ServiceFwUpdateLoader/FwUpdateLoader.csproj index 99b8b0cb..8a8f013e 100644 --- a/ServiceFwUpdate/Ui/ServiceFwUpdateLoader/FwUpdateLoader.csproj +++ b/ServiceFwUpdate/Ui/ServiceFwUpdateLoader/FwUpdateLoader.csproj @@ -67,7 +67,7 @@ true - true + false @@ -75,7 +75,7 @@ ..\..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll - ..\..\packages\NLog.5.2.2\lib\net46\NLog.dll + ..\..\packages\NLog.5.0.0\lib\net46\NLog.dll @@ -141,8 +141,6 @@ Resources.de.resx True - - diff --git a/ServiceFwUpdate/Ui/ServiceFwUpdateLoader/packages.config b/ServiceFwUpdate/Ui/ServiceFwUpdateLoader/packages.config index f4c28169..8bbdc90c 100644 --- a/ServiceFwUpdate/Ui/ServiceFwUpdateLoader/packages.config +++ b/ServiceFwUpdate/Ui/ServiceFwUpdateLoader/packages.config @@ -1,5 +1,5 @@  - + \ No newline at end of file diff --git a/ServiceFwUpdate/Ui/ServiceFwUpdateSw/ServiceFwUpdateSw.csproj b/ServiceFwUpdate/Ui/ServiceFwUpdateSw/ServiceFwUpdateSw.csproj index dfb61791..fe41eb4a 100644 --- a/ServiceFwUpdate/Ui/ServiceFwUpdateSw/ServiceFwUpdateSw.csproj +++ b/ServiceFwUpdate/Ui/ServiceFwUpdateSw/ServiceFwUpdateSw.csproj @@ -77,13 +77,14 @@ + ..\..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll - ..\..\packages\NLog.5.2.2\lib\net46\NLog.dll + ..\..\packages\NLog.5.0.0\lib\net46\NLog.dll diff --git a/ServiceFwUpdate/Ui/ServiceFwUpdateSw/packages.config b/ServiceFwUpdate/Ui/ServiceFwUpdateSw/packages.config index 707b4fed..1d772562 100644 --- a/ServiceFwUpdate/Ui/ServiceFwUpdateSw/packages.config +++ b/ServiceFwUpdate/Ui/ServiceFwUpdateSw/packages.config @@ -1,7 +1,7 @@  - + \ No newline at end of file