This commit is contained in:
Roland Drabesch
2023-08-31 09:45:14 +02:00
822 changed files with 47455 additions and 46536 deletions
+2 -2
View File
@@ -14,5 +14,5 @@ using System.Reflection;
//[assembly: AssemblyVersion("1.2.*.0")]
[assembly: AssemblyVersion("2.3.4.*")]
[assembly: AssemblyFileVersion("2.3.4.0")]
[assembly: AssemblyVersion("2.6.1.*")]
[assembly: AssemblyFileVersion("2.6.1.0")]
+1 -1
View File
@@ -155,7 +155,7 @@
</site>
<site name="MeterProcessState" id="2">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\ProgrammeSensus\Repo\Lab\La_Operations\laa_production\Common\Service\MeterProcessState" />
<virtualDirectory path="/" physicalPath="C:\Users\SZLATEV\source\repos\laa_production\Common\Service\MeterProcessState" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:56011:localhost" />
+1219 -67
View File
File diff suppressed because it is too large Load Diff
+5
View File
@@ -18,6 +18,7 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=accu/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Applic/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Approver/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=artefact/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Battey/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=binfile/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=BUGFIX/@EntryIndexedValue">True</s:Boolean>
@@ -46,7 +47,11 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=licence/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Metrology/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=METROLOGYASST/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=mettbl/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Milli/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Modbus/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=PCBID/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=perc/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Preadjustment/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=prot/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=RFID/@EntryIndexedValue">True</s:Boolean>
+5 -1
View File
@@ -23,11 +23,15 @@
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=Property/@EntryIndexedValue">&lt;Policy Inspect="False" Prefix="" Suffix="" Style="Aa_bb" /&gt;</s:String>
<s:String x:Key="/Default/Environment/AssemblyExplorer/XmlDocument/@EntryValue">&lt;AssemblyExplorer&gt;&#xD;
&lt;Assembly Path="D:\Projekte\SENSUS_tfs_workspaces\WorkBenchV2\Main\Common\Ui\IrdaFunctionalTestApp\bin\Debug\Xylem.Common.Hardware.WaterMeter.Genesis.DataPackages.dll" /&gt;&#xD;
&lt;Assembly Path="D:\Projekte\SENSUS_GitLab\laa_production\Common\Hardware\WaterMeter\Genesis\GenesisPwd\bin\Debug\Newtonsoft.Json.dll" /&gt;&#xD;
&lt;/AssemblyExplorer&gt;</s:String>
<s:Boolean x:Key="/Default/Environment/ExcludedFiles/FilesAndFoldersToSkip/=1057AD21_002DBA22_002D4CAB_002DB3FE_002D88C5C9980E6A_002Fd_003AScripts_002Ff_003Ajquery_002D1_002E10_002E2_002Eintellisense_002Ejs/@EntryIndexedValue">True</s:Boolean>
<s:String x:Key="/Default/Environment/Hierarchy/Build/SolBuilderDuo/UseMsbuildSolutionBuilder/@EntryValue">NewVersion</s:String>
<s:Boolean x:Key="/Default/Environment/Hierarchy/EntityFrameworkOptions/IsAlreadyNotifiedAboutEntityFramework/@EntryValue">True</s:Boolean>
<s:String x:Key="/Default/Environment/Highlighting/HighlightingSourceSnapshotLocation/@EntryValue">C:\Users\Thomas\AppData\Local\Temp\JetBrains\ReSharperPlatformVs15\vAny_33007af5\CoverageData\_Common.-1885154465\Snapshot\snapshot.utdcvr</s:String>
+6
View File
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8.1" />
</startup>
</configuration>
+63
View File
@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{AFC428F5-0141-4A3F-BEF2-470A89D972F6}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>CommonConsole</RootNamespace>
<AssemblyName>CommonConsole</AssemblyName>
<TargetFrameworkVersion>v4.8.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\CommonMessurementUnits\CommonMessurementUnits.csproj">
<Project>{17C15B79-9A9E-4079-8FE2-0E563F18CA01}</Project>
<Name>CommonMessurementUnits</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
+54
View File
@@ -0,0 +1,54 @@
namespace CommonConsole
{
using CommonMessurementUnits;
using Newtonsoft.Json;
using System;
public class Program
{
public static void Main(string[] args)
{
int x = 3;
Console.WriteLine($"From Int32: {x}");
byte[] xb = x.GetBytes();
Console.WriteLine($"Bits: {string.Join("", xb.GetBits())}");
Console.WriteLine($"Hex bytes: {xb.ToHex()}");
int y = BitConverter.ToInt32(xb, 0);
Console.WriteLine($"To Int32: {y}");
Console.WriteLine();
var model = new TestClass
{
Current = 130,
Flow = 40,
Pressure = 250000,
Temperature = 21,
Time = 960,
Volume = 40,
};
var modelJson = JsonConvert.SerializeObject(model, Formatting.Indented);
var testModel = JsonConvert.DeserializeObject<TestClass>(modelJson);
Console.WriteLine($"To Json: {modelJson}");
Console.WriteLine($"From Json: {JsonConvert.SerializeObject(testModel, Formatting.Indented)}");
}
}
public class TestClass
{
public Current Current { get; set; }
public Flow Flow { get; set; }
public Pressure Pressure { get; set; }
public Temperature Temperature { get; set; }
public Time Time { get; set; }
public Volume Volume { get; set; }
}
}
@@ -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("CommonConsole")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("CommonConsole")]
[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("afc428f5-0141-4a3f-bef2-470a89d972f6")]
// 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")]
+4
View File
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net481" />
</packages>
@@ -76,12 +76,16 @@
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\..\ServiceFwUpdate\packages\Newtonsoft.Json.12.0.3\lib\net40\Newtonsoft.Json.dll</HintPath>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net40\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.5.2.2\lib\net35\NLog.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\.shared\SharedAssemblyInfo.cs">
+72 -6
View File
@@ -33,6 +33,9 @@ namespace Xylem.Common.CommonCore.Configuration
private const String DefaultSetCordonelAppVersionServiceUrl =
"http://sla12iis01.emea.sensus.net/MeterProcessState/api/ProccesState/SetCordonelProgress?PcbId=";
private const String DefaultGetProductionSkipAndLifeTimeInfoUrl =
"http://sla12iis01.emea.sensus.net/MeterProcessState/api/ProccesState/GetProductionSkipAndLifeTimeInfo?PcbId=";
private const String DefaultGetCordonelAppVersionServiceUrl =
"http://sla12iis01.emea.sensus.net/MeterProcessState/api/ProccesState/GetCordonelAppVersion?PcbId=";
@@ -144,12 +147,8 @@ namespace Xylem.Common.CommonCore.Configuration
private const String DefaultMeterInfoForTestBench =
"http://sla12iis01.emea.sensus.net/MeterProcessState/api/TestBench/GetMeterInfoForTestBench?PcbID=";
//private const String DefaultCordonelFwInfoUrl =
// "http://sla12iis01.emea.sensus.net/MeterProcessState/api/FileUpToDate/GetCordonelFw";
private const String DefaultCordonelFwInfoUrl =
"http://localhost:56011/api/FileUpToDate/GetCordonelFw";
"http://sla12iis01.emea.sensus.net/MeterProcessState/api/FileUpToDate/GetCordonelFw";
//private const String DefaultGenesisGetOrderNumberServiceUrl =
@@ -188,8 +187,61 @@ namespace Xylem.Common.CommonCore.Configuration
// "http://localhost:56011/api/SoftwareAccess/GetVersionIsValid";
private const String PressureSensorTestURL_GetTestSpec
= "http://sla12iis01.emea.sensus.net/MeterProcessState/api/CordonelPressureSensorTest/GetTestSpec";
private const String PressureSensorTestURL_PostTestResults
= "http://sla12iis01.emea.sensus.net/MeterProcessState/api/CordonelPressureSensorTest/PostTestResults";
/// <summary>
/// usage: string.Format(CordonelPressureSensorTestURL_GetTestResults, pcbId);
/// </summary>
private const String PressureSensorTestURL_GetTestResults
= "http://sla12iis01.emea.sensus.net/MeterProcessState/api/CordonelPressureSensorTest/GetTestResults/{0}";
public const string LaaProductionAPI
#if DEBUG == false // when false uses always the production url.
= "http://localhost:59768";
#else
= "http://sla12iis01.emea.sensus.net";
#endif
/// <summary>
/// GET: test specification for water meter with pressure sensor.
/// </summary>
public static string GetPressureSensorSpecificationURL
#if DEBUG
=> "http://localhost:56011/api/CordonelPressureSensorTest/GetTestSpec";
#else
=> ConfigurationManager.AppSettings[nameof(GetPressureSensorSpecificationURL)]
?? PressureSensorTestURL_GetTestSpec;
#endif
/// <summary>
/// POST: test result for water meter with pressure sensor.
/// </summary>
public static string PostPressureSensorResultURL
#if DEBUG
=> "http://localhost:56011/api/CordonelPressureSensorTest/PostTestResults";
#else
=> ConfigurationManager.AppSettings[nameof(PostPressureSensorResultURL)]
?? PressureSensorTestURL_PostTestResults;
#endif
/// <summary>
/// GET: a list of test results for the water meter with specified pcbId.
/// </summary>
public static string PressureSensorResultsURL<T>(this T pcbId)
{
#if DEBUG
var url = "http://localhost:56011/api/CordonelPressureSensorTest/GetTestResults/{0}";
#else
var url = ConfigurationManager.AppSettings[nameof(PressureSensorResultsURL)] ?? PressureSensorTestURL_GetTestResults;
#endif
return string.Format(url, pcbId);
}
/// <summary>
/// List all Cordonel FW packages.
@@ -309,6 +361,20 @@ namespace Xylem.Common.CommonCore.Configuration
DefaultSetCordonelAppVersionServiceUrl;
}
/// <summary>
/// Get all production infos for skip process checks or limits for production like:
/// - Battery drained percentage upper limit,
/// - Production due date for a special register,
/// - Required life time for assembly line,
/// - Required life time for shipping line.
/// </summary>
/// <returns></returns>
public static String GetProductionSkipAndLifeTimeInfoServiceUrl()
{
return ConfigurationManager.AppSettings["GetProductionSkipAndLifeTimeInfoUrl"] ??
DefaultGetProductionSkipAndLifeTimeInfoUrl;
}
/// <summary>
/// Get all applications versions installed to a specific Cordonel.
/// </summary>
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="12.0.3" targetFramework="net40" />
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net40" />
<package id="NLog" version="5.2.2" targetFramework="net40" />
</packages>
+9 -2
View File
@@ -81,6 +81,7 @@
<Link>Properties\SharedAssemblyInfo.cs</Link>
</Compile>
<Compile Include="Consts\ProgramConfig.cs" />
<Compile Include="Consts\Constants.cs" />
<Compile Include="Consts\SyncMarkRecord.cs" />
<Compile Include="Exceptions\DB\PcbIdNotException.cs" />
<Compile Include="Exceptions\ICommonException.cs" />
@@ -90,9 +91,15 @@
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\..\ServiceFwUpdate\packages\Newtonsoft.Json.12.0.3\lib\net40\Newtonsoft.Json.dll</HintPath>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net40\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.5.2.2\lib\net35\NLog.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
+19
View File
@@ -0,0 +1,19 @@
using System;
namespace Xylem.Common.CommonCore.Consts
{
/// <summary>
/// Constants for inter-program exchange
/// </summary>
public static class Constants
{
/// <summary>
/// Marker for lack of information in strings e.g. for region, size, LutCrc, ...
/// </summary>
public const String StrUnknown = "?";
/// <summary>
/// Marker for wildcard in search operations
/// </summary>
public const String StrWildcard = "*";
}
}
@@ -61,11 +61,16 @@
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\..\..\ServiceFwUpdate\packages\Newtonsoft.Json.12.0.3\lib\net40\Newtonsoft.Json.dll</HintPath>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\..\packages\Newtonsoft.Json.13.0.3\lib\net40\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\..\packages\NLog.5.2.2\lib\net35\NLog.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="12.0.3" targetFramework="net40" />
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net40" />
<package id="NLog" version="5.2.2" targetFramework="net40" />
</packages>
+2 -1
View File
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="12.0.3" targetFramework="net40" />
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net40" />
<package id="NLog" version="5.2.2" targetFramework="net40" />
</packages>
+31
View File
@@ -0,0 +1,31 @@
namespace CommonMessurementUnits
{
public abstract class Base
{
public const int MsInSec = 1000;
public const int SecInMin = 60;
public const int MinInH = 60;
public const int HInDay = 24;
public const int MlInL = 1000;
public const int LInm3 = 1000;
public const int PInBar = 100000;
public const int MAInH = 1000;
protected double value;
public override string ToString()
=> this.value.ToString();
public override bool Equals(object obj)
=> this.value.Equals(obj);
public override int GetHashCode()
=> this.value.GetHashCode();
public static explicit operator double (Base @base)
=> @base?.value ?? default(double);
public static explicit operator double? (Base @base)
=> @base?.value;
}
}
@@ -0,0 +1,117 @@
namespace CommonMessurementUnits
{
using System;
using System.Linq;
using System.Text;
public static class BitExtensions
{
public static byte[] GetBits(this byte[] bytes)
{
if (bytes is null)
{
return Array.Empty<byte>();
}
var bytesCount = bytes.Length;
var bitsCount = bytesCount * 8;
var bits = new byte[bitsCount];
var bit = 0;
foreach (var @byte in bytes)
{
for (int b = 7; b >= 0; b--)
{
bits[bit++] = (byte)((@byte >> b) % 2);
}
}
return bits;
}
public static byte[] GetBytes(this byte value, int take = 1)
=> BitConverter.GetBytes(value).Take(take);
public static byte[] GetBytes(this sbyte value, int take = 2)
=> BitConverter.GetBytes(value).Take(take);
public static byte[] GetBytes(this short value, int take = 2)
=> BitConverter.GetBytes(value).Take(2);
public static byte[] GetBytes(this ushort value, int take = 2)
=> BitConverter.GetBytes(value).Take(2);
public static byte[] GetBytes(this int value, int take = 4)
=> BitConverter.GetBytes(value).Take(take);
public static byte[] GetBytes(this uint value, int take = 4)
=> BitConverter.GetBytes(value).Take(take);
public static byte[] GetBytes(this long value, int take = 8)
=> BitConverter.GetBytes(value).Take(take);
public static byte[] GetBytes(this ulong value, int take = 8)
=> BitConverter.GetBytes(value).Take(take);
public static byte[] GetBytes(this double value)
=> BitConverter.GetBytes(value);
public static byte[] GetBytes(this string value)
=> Encoding.ASCII.GetBytes(value);
public static byte[] Swap(this byte[] bytes)
{
if (bytes is null)
{
return Array.Empty<byte>();
}
var length = bytes.Length;
var swapped = new byte[length];
for (int x = 0; x < length; x++)
{
swapped[x] = bytes[length - x - 1];
}
return swapped;
}
public static byte[] Take(this byte[] bytesSRC, int count)
{
if (bytesSRC is null || count < 0)
{
return Array.Empty<byte>();
}
var bytesDST = new byte[count];
Array.Copy(bytesSRC, 0, bytesDST, 0, count);
return bytesDST;
}
public static string ToHex(this byte[] value, string separator = " ")
{
if (value is null)
{
return string.Empty;
}
return BitConverter.ToString(value).Replace("-", separator);
}
public static byte[] FromHex(this string value, string separator = " ")
{
if (string.IsNullOrWhiteSpace(value))
{
return Array.Empty<byte>();
}
return value
.Split(new[] { separator }, StringSplitOptions.RemoveEmptyEntries)
.Select(x => byte.TryParse(x, out byte b) ? b : default(byte))
.ToArray();
}
}
}
@@ -0,0 +1,80 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{17C15B79-9A9E-4079-8FE2-0E563F18CA01}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>CommonMessurementUnits</RootNamespace>
<AssemblyName>CommonMessurementUnits</AssemblyName>
<TargetFrameworkVersion>v4.8.1</TargetFrameworkVersion>
<Authors>Stoyan Zlatev</Authors>
<Company>Sensus - a Xylem brand</Company>
<Description>A lighter and better way to convert numbers in messurement units.</Description>
<Copyright>2023</Copyright>
<PackageProjectUrl>https://slm.sms-esaap.com/la_operations/laapackages/</PackageProjectUrl>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<FileVersion>1.0.0.0</FileVersion>
<Version>1.0.0</Version>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>true</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>CommonMessurementUnits.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Base.cs" />
<Compile Include="BitExtensions.cs" />
<Compile Include="Current.cs" />
<Compile Include="Flow.cs" />
<Compile Include="JsonConverters\CurrentConverter.cs" />
<Compile Include="JsonConverters\FlowConverter.cs" />
<Compile Include="JsonConverters\PressureConverter.cs" />
<Compile Include="JsonConverters\TemperatureConverter.cs" />
<Compile Include="JsonConverters\TimeConverter.cs" />
<Compile Include="JsonConverters\VolumeConverter.cs" />
<Compile Include="Pressure.cs" />
<Compile Include="Temperature.cs" />
<Compile Include="Volume.cs" />
<Compile Include="Time.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="CommonMessurementUnits.snk" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
+28
View File
@@ -0,0 +1,28 @@
namespace CommonMessurementUnits
{
using CommonMessurementUnits.JsonConverters;
using Newtonsoft.Json;
[JsonConverter(typeof(CurrentConverter))]
public class Current : Base
{
public double MiliampereHours
{
get => this.AmpereHours * MAInH;
set => this.AmpereHours = value / MAInH;
}
public double AmpereHours
{
get => this.value;
set => this.value = value;
}
public static implicit operator Current(double x)
=> new Current { value = x };
public static implicit operator Current(double? x)
=> new Current { value = x ?? 0 };
}
}
+28
View File
@@ -0,0 +1,28 @@
namespace CommonMessurementUnits
{
using CommonMessurementUnits.JsonConverters;
using Newtonsoft.Json;
[JsonConverter(typeof(FlowConverter))]
public class Flow : Base
{
public double CubicMeterInHour
{
get => this.value;
set => this.value = value;
}
public double LiterInMinute
{
get => this.CubicMeterInHour / MinInH * LInm3;
set => this.CubicMeterInHour = value * MinInH / LInm3;
}
public static implicit operator Flow(double x)
=> new Flow { value = x };
public static implicit operator Flow(double? x)
=> new Flow { value = x ?? 0 };
}
}
@@ -0,0 +1,27 @@
namespace CommonMessurementUnits.JsonConverters
{
using Newtonsoft.Json;
using System;
public class CurrentConverter : JsonConverter<Current>
{
public override Current ReadJson(JsonReader reader, Type objectType, Current existingValue, bool hasExistingValue, JsonSerializer serializer)
{
while (reader.ValueType != typeof(double))
{
reader.Read();
}
if (reader.Value is double value)
{
return value;
}
return existingValue;
}
public override void WriteJson(JsonWriter writer, Current value, JsonSerializer serializer)
=> writer.WriteValue((double)value);
}
}
@@ -0,0 +1,27 @@
namespace CommonMessurementUnits.JsonConverters
{
using Newtonsoft.Json;
using System;
public class FlowConverter : JsonConverter<Flow>
{
public override Flow ReadJson(JsonReader reader, Type objectType, Flow existingValue, bool hasExistingValue, JsonSerializer serializer)
{
while (reader.ValueType != typeof(double))
{
reader.Read();
}
if (reader.Value is double value)
{
return value;
}
return existingValue;
}
public override void WriteJson(JsonWriter writer, Flow value, JsonSerializer serializer)
=> writer.WriteValue((double)value);
}
}
@@ -0,0 +1,27 @@
namespace CommonMessurementUnits.JsonConverters
{
using System;
using Newtonsoft.Json;
public class PressureConverter : JsonConverter<Pressure>
{
public override Pressure ReadJson(JsonReader reader, Type objectType, Pressure existingValue, bool hasExistingValue, JsonSerializer serializer)
{
while (reader.ValueType != typeof(double))
{
reader.Read();
}
if (reader.Value is double value)
{
return value;
}
return existingValue;
}
public override void WriteJson(JsonWriter writer, Pressure value, JsonSerializer serializer)
=> writer.WriteValue((double)value);
}
}
@@ -0,0 +1,27 @@
namespace CommonMessurementUnits.JsonConverters
{
using Newtonsoft.Json;
using System;
public class TemperatureConverter : JsonConverter<Temperature>
{
public override Temperature ReadJson(JsonReader reader, Type objectType, Temperature existingValue, bool hasExistingValue, JsonSerializer serializer)
{
while (reader.ValueType != typeof(double))
{
reader.Read();
}
if (reader.Value is double value)
{
return value;
}
return existingValue;
}
public override void WriteJson(JsonWriter writer, Temperature value, JsonSerializer serializer)
=> writer.WriteValue((double)value);
}
}
@@ -0,0 +1,27 @@
namespace CommonMessurementUnits.JsonConverters
{
using System;
using Newtonsoft.Json;
public class TimeConverter : JsonConverter<Time>
{
public override Time ReadJson(JsonReader reader, Type objectType, Time existingValue, bool hasExistingValue, JsonSerializer serializer)
{
while (reader.ValueType != typeof(double))
{
reader.Read();
}
if (reader.Value is double value)
{
return value;
}
return existingValue;
}
public override void WriteJson(JsonWriter writer, Time value, JsonSerializer serializer)
=> writer.WriteValue((double)value);
}
}
@@ -0,0 +1,27 @@
namespace CommonMessurementUnits.JsonConverters
{
using System;
using Newtonsoft.Json;
public class VolumeConverter : JsonConverter<Volume>
{
public override Volume ReadJson(JsonReader reader, Type objectType, Volume existingValue, bool hasExistingValue, JsonSerializer serializer)
{
while (reader.ValueType != typeof(double))
{
reader.Read();
}
if (reader.Value is double value)
{
return value;
}
return existingValue;
}
public override void WriteJson(JsonWriter writer, Volume value, JsonSerializer serializer)
=> writer.WriteValue((double)value);
}
}
+28
View File
@@ -0,0 +1,28 @@
namespace CommonMessurementUnits
{
using CommonMessurementUnits.JsonConverters;
using Newtonsoft.Json;
[JsonConverter(typeof(PressureConverter))]
public class Pressure : Base
{
public double Pascal
{
get => this.value;
set => this.value = value;
}
public double Bar
{
get => this.Pascal / PInBar;
set => this.Pascal = value * PInBar;
}
public static implicit operator Pressure(double x)
=> new Pressure { value = x };
public static implicit operator Pressure(double? x)
=> new Pressure { value = x ?? 0 };
}
}
@@ -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("CommonMessurementUnits")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("CommonMessurementUnits")]
[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("17c15b79-9a9e-4079-8fe2-0e563f18ca01")]
// 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")]
@@ -0,0 +1,22 @@
namespace CommonMessurementUnits
{
using CommonMessurementUnits.JsonConverters;
using Newtonsoft.Json;
[JsonConverter(typeof(TemperatureConverter))]
public class Temperature : Base
{
public double Celsius
{
get => this.value;
set => this.value = value;
}
public static implicit operator Temperature(double x)
=> new Temperature { value = x };
public static implicit operator Temperature(double? x)
=> new Temperature { value = x ?? 0 };
}
}
+46
View File
@@ -0,0 +1,46 @@
namespace CommonMessurementUnits
{
using CommonMessurementUnits.JsonConverters;
using Newtonsoft.Json;
[JsonConverter(typeof(TimeConverter))]
public class Time : Base
{
public double Miliseconds
{
get => this.Seconds * MsInSec;
set => this.Seconds = value / MsInSec;
}
public double Seconds
{
get => this.value;
set => this.value = value;
}
public double Minutes
{
get => this.Seconds / SecInMin;
set => this.Seconds = value * SecInMin;
}
public double Hours
{
get => this.Minutes / MinInH;
set => this.Minutes = value * MinInH;
}
public double Days
{
get => this.Hours / HInDay;
set => this.Hours = value * HInDay;
}
public static implicit operator Time(double x)
=> new Time { value = x };
public static implicit operator Time(double? x)
=> new Time { value = x ?? 0 };
}
}
+34
View File
@@ -0,0 +1,34 @@
namespace CommonMessurementUnits
{
using CommonMessurementUnits.JsonConverters;
using Newtonsoft.Json;
[JsonConverter(typeof(VolumeConverter))]
public class Volume : Base
{
public double Mililiter
{
get => this.Liter * MlInL;
set => this.Liter = value / MlInL;
}
public double Liter
{
get => this.value * LInm3;
set => this.value = value / LInm3;
}
public double CubicMeter
{
get => this.value;
set => this.value = value;
}
public static implicit operator Volume(double x)
=> new Volume { value = x };
public static implicit operator Volume(double? x)
=> new Volume { value = x ?? 0 };
}
}
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net481" />
</packages>
@@ -71,13 +71,16 @@
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.5.2.2\lib\net46\NLog.dll</HintPath>
</Reference>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c" />
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Data" />
<Reference Include="System.IO.Compression" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
@@ -180,6 +183,10 @@
<Project>{2C6378C6-6BA1-4CEE-8992-8404D8369A90}</Project>
<Name>GenesisFile</Name>
</ProjectReference>
<ProjectReference Include="..\Hardware\WaterMeter\Genesis\GenesisStatus\GenesisStatus.csproj">
<Project>{0F646872-D8DC-4EE5-989F-D4C73F0ACE3F}</Project>
<Name>GenesisStatus</Name>
</ProjectReference>
<ProjectReference Include="..\Hardware\WaterMeter\Genesis\Registers\Registers.csproj">
<Project>{F4AAF7E6-7333-4284-B735-E32DEB076C64}</Project>
<Name>Registers</Name>
@@ -12,8 +12,10 @@ using System.Threading.Tasks;
using System.Timers;
using Xylem.Common.CommonCore.Configuration;
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore;
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore.Consts;
using Xylem.Common.Hardware.WaterMeter.Genesis.Registers;
using Xylem.Common.Hardware.WaterMeter.WaterMeterCore;
using Xylem.Common.Hardware.WaterMeter.WaterMeterCore.Consts;
using Xylem.Common.Logic.ProductionOrderCore.TestResults;
using Xylem.Common.Logic.SoftwareAccessHelper;
using Xylem.Common.Utils.Logging;
@@ -117,7 +119,7 @@ namespace CordonelAssemblyLine.Model
public LeakViewModel(Int32 slotNR, Int32? stationID = null)
{
_logger = NLogHelper.CreateOrGetLogger("ProductionUI");
//_logger = NLogHelper.CreateOrGetLogger("ProductionUI");
StationID = stationID;
SlotNr = slotNR;
tmrAutoDetect = new Timer(intervalWithoutDetect);
@@ -338,10 +340,10 @@ namespace CordonelAssemblyLine.Model
{
var url = ServiceUrls.MeterProcessStateUrl();
var status = Xylem.Common.Hardware.WaterMeter.WaterMeterCore.Consts.DisplayCodes.PressureTestedFailed;
var status = DisplayCodes.PressureTestedFailed;
if (successfull)
{
status = Xylem.Common.Hardware.WaterMeter.WaterMeterCore.Consts.DisplayCodes.PressureTested;
status = DisplayCodes.PressureTested;
}
try
{
@@ -354,7 +356,7 @@ namespace CordonelAssemblyLine.Model
if (!isStored)
{
OnStoreDone?.Invoke(null, new StringArgs("Kann nicht gespeichert werden"));
status = Xylem.Common.Hardware.WaterMeter.WaterMeterCore.Consts.DisplayCodes.PressureTestedFailed;
status = DisplayCodes.PressureTestedFailed;
}
@@ -365,12 +367,12 @@ namespace CordonelAssemblyLine.Model
catch (Exception ex)
{
Log(ex.Message);
status = Xylem.Common.Hardware.WaterMeter.WaterMeterCore.Consts.DisplayCodes.PressureTestedFailed;
status = DisplayCodes.PressureTestedFailed;
OnStoreDone?.Invoke(null, new StringArgs($"Kann nicht gespeichert werden.Fehler: {ex.Message}"));
}
if (status == Xylem.Common.Hardware.WaterMeter.WaterMeterCore.Consts.DisplayCodes.PressureTested)
if (status == DisplayCodes.PressureTested)
{
OnStoreDone?.Invoke(null, new StringArgs("Ergebnis gespeichert der Zähler weiter bearbeitet werden."));
return;
@@ -13,6 +13,7 @@ using System.Threading;
using System.Threading.Tasks;
using Xylem.Common.CommonCore.Configuration;
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore;
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore.Consts;
using Xylem.Common.Hardware.WaterMeter.Genesis.Registers;
using Xylem.Common.Hardware.WaterMeter.WaterMeterCore;
using Xylem.Common.Hardware.WaterMeter.WaterMeterCore.Consts;
@@ -26,7 +27,7 @@ namespace CordonelAssemblyLine.Model
public event EventHandler<String> OnMsgRaise;
public MarriageViewModel(String scannerPort, Int32 slotNr)
{
_logger = NLogHelper.CreateOrGetLogger("ProductionUI");
//_logger = NLogHelper.CreateOrGetLogger("ProductionUI");
_scannerPort = scannerPort;
_slotNr = slotNr;
}
+107 -112
View File
@@ -12,8 +12,10 @@ using System.Threading.Tasks;
using Xylem.Common.CommonCore.Configuration;
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore;
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile;
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisStatus;
using Xylem.Common.Hardware.WaterMeter.Genesis.Registers;
using Xylem.Common.Hardware.WaterMeter.WaterMeterCore;
using Xylem.Common.Hardware.WaterMeter.WaterMeterCore.Consts;
using Xylem.Common.Logic.SoftwareAccessHelper;
using static Ui.ProductionControls.ctlPictureProgressBar;
@@ -242,14 +244,14 @@ namespace CordonelAssemblyLine.Model
}
}
private readonly System.Windows.Media.Brush _progressWaiting =
(System.Windows.Media.Brush) new System.Windows.Media.BrushConverter().ConvertFromString("Aquamarine");
private readonly System.Windows.Media.Brush _progressCurrent =
(System.Windows.Media.Brush) new System.Windows.Media.BrushConverter().ConvertFromString("yellow");
private readonly System.Windows.Media.Brush _progressDone =
(System.Windows.Media.Brush) new System.Windows.Media.BrushConverter().ConvertFromString("green");
private readonly System.Windows.Media.Brush _progressError =
(System.Windows.Media.Brush) new System.Windows.Media.BrushConverter().ConvertFromString("red");
private readonly System.Windows.Media.Brush _progressWaiting =
(System.Windows.Media.Brush)new System.Windows.Media.BrushConverter().ConvertFromString("Aquamarine");
private readonly System.Windows.Media.Brush _progressCurrent =
(System.Windows.Media.Brush)new System.Windows.Media.BrushConverter().ConvertFromString("yellow");
private readonly System.Windows.Media.Brush _progressDone =
(System.Windows.Media.Brush)new System.Windows.Media.BrushConverter().ConvertFromString("green");
private readonly System.Windows.Media.Brush _progressError =
(System.Windows.Media.Brush)new System.Windows.Media.BrushConverter().ConvertFromString("red");
private System.Windows.Media.Brush _lblS01Color;
@@ -430,7 +432,7 @@ namespace CordonelAssemblyLine.Model
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
Task _s;
private Task _s;
/// <summary>
/// Initial start of assembling
@@ -563,7 +565,7 @@ namespace CordonelAssemblyLine.Model
if (meter.Login())
{
meter.SetProcessState(Xylem.Common.Hardware.WaterMeter.WaterMeterCore.Consts.DisplayCodes.PickingStarted);
meter.SetProcessState(DisplayCodes.PickingStarted);
var ret = RunCheck(checkAppsIdVersion, frequency, meterSize, pressurePresent, meter);
lblS08Color = _progressWaiting;
if (ret)
@@ -577,11 +579,10 @@ namespace CordonelAssemblyLine.Model
ret = false;
}
var genesisStatus = new GenesisStatus();
var nowSeconds = meter.ReadRegister("POWERMON_TotalUsedSeconds");
var nowCharge = meter.ReadRegister("POWERMON_TotalUsedCharge", 8);
var mfgCharge = meter.ReadRegister("CUSTOMER_MfgCharge");
if (nowCharge == null || nowSeconds == null)
// this calculates all life time values
if (!GenesisStatusHandler.BuildLifeTimeInformation(meter, genesisStatus))
{
meter.WriteLog("Batterie nicht lesbar");
lblS08Text = "Batterie nicht lesbar";
@@ -590,29 +591,31 @@ namespace CordonelAssemblyLine.Model
}
else
{
var nowChargeV = BitConverter.ToUInt64(nowCharge.ToArray(), 0);
var nowSecondsV = BitConverter.ToUInt32(nowSeconds.ToArray(), 0);
var mfgChargeV = BitConverter.ToUInt32(mfgCharge.ToArray(), 0);
//// Time Span in h in mAhr In % with one battery is 100%
////(((total used change difference / (Time span / 3600) ) / 3600000) / 19000)*100
// ReSharper disable once UnusedVariable
var loadAtH = nowChargeV / ((Double)nowSecondsV / 3600) / 3600000 / (19000 * 2) * 100;
var totalUsed = (Double)nowChargeV / 1000000 / 3.6 / (19000 * 2) * 100;
SetState($"Battery Total Used {totalUsed}%");
SetState($"Battery Total Charge {nowChargeV}uAs");
SetState($"Battery MFG Charge {mfgChargeV}uAs");
var sbMSG = new StringBuilder();
sbMSG.AppendLine($"Pcb = {meter.PcbId}");
if (totalUsed >= 7.5)
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}");
if (genesisStatus.RemainingLifeTimeYears >= 21 || genesisStatus.DrainedBatteryLoadPercent <= 1)
{
lblS08Text = "Batterieentladung über 7.5%";
lblS08Text = $"{genesisStatus.RemainingLifeTimeYears} Jahre";
}
else
{
lblS08Text = $"{genesisStatus.RemainingLifeTimeYears} Jahre";
lblS08Color = _progressError;
ret = false;
}
meter.WriteLog(sbMSG.ToString());
}
}
if (_skipProcessSteps == null || !_skipProcessSteps.SkipLUT)
@@ -620,83 +623,75 @@ namespace CordonelAssemblyLine.Model
if (ret)
{
lblS08Text = "2";
lblS08Color = _progressDone;
lblS10Color = _progressCurrent;
if (_orderDetails.MeterSize <= 1)
StringBuilder sbUrl = new StringBuilder();
sbUrl.Append("http://10.49.40.25/MeterProcessState/api/FileUpToDate/GetLutFiles");
sbUrl.Append($"?Metersize={_orderDetails.MeterSize}");
sbUrl.Append("&ForProd=true");
//?Metersize=2&Region=EMEA&
if (_orderDetails.FrequencyIndicator != 0)
{
lblS10Color = _progressDone;
lblS10Text = "Keine LUT für DN40/50";
//get ema
sbUrl.Append("&Region=EMEA");
}
else
{
StringBuilder sbUrl = new StringBuilder();
sbUrl.Append("http://10.49.40.25/MeterProcessState/api/FileUpToDate/GetLutFiles");
sbUrl.Append($"?Metersize={_orderDetails.MeterSize}");
sbUrl.Append("&ForProd=true");
//?Metersize=2&Region=EMEA&
if (_orderDetails.FrequencyIndicator != 0)
{
//get ema
sbUrl.Append("&Region=EMEA");
}
else
{
//get na
sbUrl.Append("&Region=NA");
}
//get na
sbUrl.Append("&Region=NA");
}
try
{
var retLut = LocalWebRequest.GetRequest(sbUrl.ToString(), 80000);
var a = JsonConvert.DeserializeObject<List<CordonelMetrologyLut>>(retLut);
try
{
var retLut = LocalWebRequest.GetRequest(sbUrl.ToString(), 80000);
var a = JsonConvert.DeserializeObject<List<CordonelMetrologyLut>>(retLut);
if (a.Count == 1)
if (a.Count == 1)
{
SetState($"Vergleich abgeschlossen:{State}");
var lut = a.First();
lblS10Text = $"Update {lut.FileCrc:0x8}";
var meterLutUpdate = new MeterLutUpdate(meter);
var loadResult = meterLutUpdate.LoadLutFromStream(lut.FileName, lut.FileContent.ToList());
var updateResult = meterLutUpdate.UpdateMeterLut();
if (loadResult && updateResult)
{
SetState($"Vergleich abgeschlossen:{State}");
var lut = a.First();
lblS10Text = $"Update {lut.FileCrc:0x8}";
var meterLutUpdate = new MeterLutUpdate(meter);
var loadResult = meterLutUpdate.LoadLutFromStream(lut.FileName, lut.FileContent.ToList());
var updateResult = meterLutUpdate.UpdateMeterLut();
if (loadResult && updateResult)
{
lblS10Text = $"{lut.FileName} in meter";
lblS10Color = _progressDone;
}
else
{
Result = "Fehler beim Update";
SetState(Result);
lblS10Text = Result;
lblS10Color = _progressError;
ret = false;
}
lblS10Text = $"{lut.FileName} in meter";
lblS10Color = _progressDone;
}
else
{
Result = "Keine eindeutige LUT gefunden";
Result = "Fehler beim Update";
SetState(Result);
lblS10Color = _progressError;
lblS10Text = Result;
lblS10Color = _progressError;
ret = false;
}
}
catch (Exception)
else
{
Result = "Fehler beim LUT Update";
Result = "Keine eindeutige LUT gefunden";
SetState(Result);
lblS10Color = _progressError;
lblS10Text = Result;
return false;
ret = false;
}
}
catch (Exception)
{
Result = "Fehler beim LUT Update";
SetState(Result);
lblS10Color = _progressError;
lblS10Text = Result;
return false;
}
}
}
else
@@ -710,7 +705,7 @@ namespace CordonelAssemblyLine.Model
{
meter.ReLogin();
}
meter.SetProcessState(Xylem.Common.Hardware.WaterMeter.WaterMeterCore.Consts.DisplayCodes.PickingTested);
meter.SetProcessState(DisplayCodes.PickingTested);
var url = $"{ServiceUrls.MeterProcessStateUrl()}SetPickingState?PcbID={meter.PcbId}&FertigungsauftragsNr={_order}";
var retString = LocalWebRequest.PostRequestAsyncAndGetContent(url);
@@ -722,7 +717,7 @@ namespace CordonelAssemblyLine.Model
}
else
{
meter.SetProcessState(Xylem.Common.Hardware.WaterMeter.WaterMeterCore.Consts.DisplayCodes.PickingFailed);
meter.SetProcessState(DisplayCodes.PickingFailed);
}
}
}
@@ -789,7 +784,7 @@ namespace CordonelAssemblyLine.Model
SetState("Pcb mit Drucksensor. Laut Auftrag keiner verbaut");
lblS05Text = "Drucksensor vorhanden!";
meter.WriteLog(State);
}
else
{
@@ -1103,7 +1098,7 @@ namespace CordonelAssemblyLine.Model
lblS04Color = _progressCurrent;
}
}
}
break;
case PickingStateMachine.Compare:
@@ -1114,35 +1109,35 @@ namespace CordonelAssemblyLine.Model
lblS09Color = _progressCurrent;
//Rule from J.Schulz, 9 months for customers with immediately usage here temporary decided on order volume
//minDate = minDate.AddMonths(_orderOverview.OrderOverViewCordonel.Count < 5 ? -9 : -3);
// The production date has to be at least within the last 3 months from now backwards
minDate = minDate.AddMonths(-3);
SetState($"Register wurde am {_orderOverview.KitronProductionDate } hergestellt, für diesen Auftrag " +
$"muss das Register nach dem {minDate} hergestellt worden sein");
lblS09Text = $"{_orderOverview.KitronProductionDate}";
////Rule from J.Schulz, 9 months for customers with immediately usage here temporary decided on order volume
////minDate = minDate.AddMonths(_orderOverview.OrderOverViewCordonel.Count < 5 ? -9 : -3);
//TODO may be useful to introduce SkipRegisterOldness instead of SkipBatteyCheck will be used for oldness of register
if (_skipProcessSteps == null || !_skipProcessSteps.SkipBatteyCheck)
{
if (_orderOverview.KitronProductionDate <= minDate)
{
SetState($"Fehlgeschlagen Register ist zu alt! Bitte QS informieren. Kitron-Produktionsdatum: {_orderOverview.KitronProductionDate }");
//// The production date has to be at least within the last 3 months from now backwards
//minDate = minDate.AddMonths(-3);
//SetState($"Register wurde am {_orderOverview.KitronProductionDate } hergestellt, für diesen Auftrag " +
// $"muss das Register nach dem {minDate} hergestellt worden sein");
//lblS09Text = $"{_orderOverview.KitronProductionDate}";
_state = PickingStateMachine.MeterError;
lblS09Color = _progressError;
var b = (System.Windows.Media.Brush)converter.ConvertFromString("#FFFF00");
b.Freeze();
ResultColor = b;
break;
}
}
else
{
SetState($"Produktionsdatum wird nicht überprüft Sonderfreigabe Nr.:{_skipProcessSteps.Id} von {_skipProcessSteps.Name}");
}
////TODO may be useful to introduce SkipRegisterOldness instead of SkipBatteyCheck will be used for oldness of register
//if (_skipProcessSteps == null || !_skipProcessSteps.SkipBatteyCheck)
//{
// if (_orderOverview.KitronProductionDate <= minDate)
// {
// SetState($"Fehlgeschlagen Register ist zu alt! Bitte QS informieren. Kitron-Produktionsdatum: {_orderOverview.KitronProductionDate }");
// _state = PickingStateMachine.MeterError;
// lblS09Color = _progressError;
// var b = (System.Windows.Media.Brush)converter.ConvertFromString("#FFFF00");
// b.Freeze();
// ResultColor = b;
// break;
// }
//}
//else
//{
// SetState($"Produktionsdatum wird nicht überprüft Sonderfreigabe Nr.:{_skipProcessSteps.Id} von {_skipProcessSteps.Name}");
//}
lblS09Color = _progressDone;
if (Compare(_orderDetails.CheckAppsIdVersion, _orderDetails.FrequencyIndicator, _orderDetails.MeterSize, _orderDetails.PressurePresent))
+2 -1
View File
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="12.0.3" targetFramework="net46" />
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net46" />
<package id="NLog" version="5.2.2" targetFramework="net46" />
</packages>
@@ -102,9 +102,14 @@
<PropertyGroup />
<PropertyGroup />
<PropertyGroup />
<PropertyGroup />
<PropertyGroup />
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net40\Newtonsoft.Json.dll</HintPath>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net40\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.5.2.2\lib\net35\NLog.dll</HintPath>
</Reference>
<Reference Include="PdfSharp, Version=1.50.5147.0, Culture=neutral, PublicKeyToken=f94615aa0424f9eb, processorArchitecture=MSIL">
<HintPath>..\packages\PDFsharp.1.50.5147\lib\net20\PdfSharp.dll</HintPath>
@@ -113,9 +118,14 @@
<HintPath>..\packages\PDFsharp.1.50.5147\lib\net20\PdfSharp.Charting.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http">
<HintPath>..\..\..\..\..\..\..\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.8\System.Net.Http.dll</HintPath>
</Reference>
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="GenerateReport.cs" />
@@ -152,6 +162,8 @@
<DependentUpon>PreAdjustmentControl.cs</DependentUpon>
</Compile>
<Compile Include="PreAdjustmentSettingsContainer.cs" />
<Compile Include="Processes\Actions\MagFluxZeroFlow.cs" />
<Compile Include="Processes\Actions\PressureTestProcess.cs" />
<Compile Include="Processes\Actions\FlushProcess.cs" />
<Compile Include="Processes\Actions\PrepareTestProcess.cs" />
<Compile Include="Processes\Actions\AmplitudeTestProcess.cs" />
@@ -225,6 +237,10 @@
<Project>{2E139F63-B6FE-4EA9-A098-85364FE9B26C}</Project>
<Name>PortCore</Name>
</ProjectReference>
<ProjectReference Include="..\Hardware\Interfaces\Protocols\ProtocolCore\ProtocolCore.csproj">
<Project>{8BDD2789-96D4-43EA-AAD7-0F49D0347998}</Project>
<Name>ProtocolCore</Name>
</ProjectReference>
<ProjectReference Include="..\Hardware\WaterMeter\Genesis\DataPackages\DataPackages.csproj">
<Project>{0E524D43-7B66-45CD-AA74-41D51AFC3D99}</Project>
<Name>DataPackages</Name>
@@ -6,6 +6,7 @@ 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.WaterMeterCore;
@@ -28,6 +28,18 @@ namespace Xylem.Common.Ui.CordonelPreadjustmentUi.Parameters
FlowrateQmH = 100;
DurationS = 120;
break;
case MeterSize.DN100:
FlowrateQmH = 140;
DurationS = 120;
break;
case MeterSize.DN125:
FlowrateQmH = 140;
DurationS = 120;
break;
case MeterSize.DN150:
FlowrateQmH = 200;
DurationS = 120;
break;
default:
Message = $"Warning no parameter for meter size {meterSize.GetHashCode()} use default!{Environment.NewLine}";
FlowrateQmH = 40;
@@ -11,7 +11,9 @@ using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore.Consts;
using Xylem.Common.Hardware.WaterMeter.WaterMeterCore;
using Xylem.Common.Hardware.WaterMeter.WaterMeterCore.Consts;
using Xylem.Common.Logic.ProductionOrderCore.OrderData;
using Xylem.Common.Ui.CordonelPreadjustmentUi.Parameters;
@@ -393,6 +395,7 @@ namespace CordonelPreadjustmentUi
{
this.l_ZeroFlowCal_TempCal.ForeColor = color;
}
public enum StatusPanelItems
{
None = 0,
@@ -1675,15 +1678,21 @@ namespace CordonelPreadjustmentUi
List<IProcess> listOfProgrammParts = new List<IProcess>();
listOfProgrammParts.Add(new PrepareTestProcess("PrepareTest", StatusPanelItems.Detect, string.Empty, string.Empty, 1 * 60));
listOfProgrammParts.Add(new LoginProcess("Login", StatusPanelItems.Detect, PredefinedMessages.WaitUntilLoginFinished(pp.Setting.Culture), PredefinedMessages.LoginFailed(pp.Setting.Culture), 1 * 60));
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 PreparationProcess("Preparation", StatusPanelItems.Prepare, PredefinedMessages.WaitUntilPreparationFinished(pp.Setting.Culture), PredefinedMessages.PreparationFailed(pp.Setting.Culture), 1 * 60));
if (!pp.Setting.TempOnly)
{
listOfProgrammParts.Add(new AmplitudeTestProcess("Amplitude Test", StatusPanelItems.Amplitude, PredefinedMessages.WaitUntilAmplitudeTestFinished(pp.Setting.Culture), PredefinedMessages.AmplitudeFailed(pp.Setting.Culture), 4 * 60));
@@ -1857,7 +1866,7 @@ namespace CordonelPreadjustmentUi
{
if (!pp.IsAutomaticMode)
{
checkMeterForFailed.Meter.SetProcessState(Xylem.Common.Hardware.WaterMeter.WaterMeterCore.Consts.DisplayCodes.ZeroFlowFailed);
checkMeterForFailed.Meter.SetProcessState(DisplayCodes.ZeroFlowFailed);
}
}
@@ -1930,7 +1939,7 @@ namespace CordonelPreadjustmentUi
}
}
private void PushProgressBars(int totalSecondsEstm, DateTimeOffset totalStart, int currentProccessEstm, DateTimeOffset currentProccessStartTime)
public void PushProgressBars(int totalSecondsEstm, DateTimeOffset totalStart, int currentProccessEstm, DateTimeOffset currentProccessStartTime)
{
if (this.InvokeRequired)
{
@@ -63,6 +63,7 @@ namespace CordonelPreadjustmentUi
public Int32 OffsetTestBadDataLimit { get; internal set; } = 3;
#endregion
public bool Production = true;
private string CultureStr;
public List<Int32> TempMeters = new List<Int32>() { 1, 10 };
@@ -122,7 +123,7 @@ namespace CordonelPreadjustmentUi
Double upperTempLimit = 35,
Double lowerTempLimit = 15,
Double tempDeviationLimit = 1,
Int32 ampTestTofRecordingTime = 2,
Int32 ampTestTofRecordingTime = 6,
Double ampTestTriggerValue = 0.5,
bool ampTestGenerateLogfiles = true,
bool ampTestGenerateMeanValuesFile = true,
@@ -6,7 +6,9 @@ using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using Xylem.Common.CommonCore.Configuration;
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore.Consts;
using Xylem.Common.Hardware.WaterMeter.Genesis.Registers;
using Xylem.Common.Hardware.WaterMeter.WaterMeterCore.Consts;
using Xylem.Common.Logic.SoftwareAccessHelper;
using static CordonelPreadjustmentUi.PreAdjustmentControl;
@@ -151,7 +153,7 @@ namespace CordonelPreadjustmentUi.Processes.Actions
{
if (pp.IsAutomaticMode)
{
meterctl.Meter.SetProcessState(Xylem.Common.Hardware.WaterMeter.WaterMeterCore.Consts.DisplayCodes.ZeroFlowFailed);
meterctl.Meter.SetProcessState(DisplayCodes.ZeroFlowFailed);
}
pp.DebugMessage($"{ProcessName} procedure failed", meterctl.Slot, "APP", meterctl.Meter.PcbId);
pp.GenerateReturnNote(PredefinedMessages.CompletionFailed(pp.Setting.Culture), meterctl);
@@ -0,0 +1,62 @@
//using CordonelPreadjustmentUi.Processes;
//using CordonelPreadjustmentUi.Processes.Itinerary;
//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Threading.Tasks;
//using static CordonelPreadjustmentUi.PreAdjustmentControl;
//namespace Xylem.Common.Ui.CordonelPreadjustmentUi.Processes.Actions
//{
// public class MagFluxZeroFlowProcess : BaseProcess
// {
// public MagFluxZeroFlowProcess(string processName, StatusPanelItems panelState, string performMessage, string failedMessage, int? expectedTimeS) : base(processName, panelState, performMessage, failedMessage, expectedTimeS)
// {
// }
// public override List<Task> StartWork()
// {
// return doWorkProcess(base.CurrentProcessProgress);
// }
// private List<Task> doWorkProcess(ProcessProgress currentProcessProgress)
// {
// private List<Task> doWorkProcess(ProcessProgress pp)
// {
// var MetersToProcess = MeterStateCtls.Where(e => e.IsEnabled).ToList();
// var listOfProcessTask = new List<Task>();
// listOfProcessTask.Add(new Task<bool>(() =>
// {
// pp.DebugMessage($"Performing {ProcessName} procedure", null, "APP");
// var ZeroOffsetTime = DateTimeOffset.UtcNow.AddMinutes(2);
// var MetersToProcess = MeterStateCtls.Where(e => e.IsEnabled).ToList();
// while (ZeroOffsetTime > DateTimeOffset.UtcNow)
// {
// Thread.Sleep(1000);
// }
// return true;
// }));
// return listOfProcessTask;
// }
// }
// }
//}
@@ -16,8 +16,6 @@ namespace CordonelPreadjustmentUi.Processes.Actions
{
public class PreparationProcess : BaseProcess
{
public PreparationProcess(string processName, StatusPanelItems panelState, string performMessage, string failedMessage, int? expectedTimeS) : base(processName, panelState, performMessage, failedMessage, expectedTimeS)
{
}
@@ -99,9 +97,17 @@ namespace CordonelPreadjustmentUi.Processes.Actions
Ok = WriteRegisterSafe(meterctl.Meter, "Samplerate", Register.Genesisflow.SampleRate, pp.Setting.Samplerate);
if (CheckAbort(Ok, meterctl)) { return Ok; }
Ok = WriteRegisterSafe(meterctl.Meter, "Metersize", Register.Genesisflow.MeterSize, pp.Setting.MeterSize.GetHashCode(), false);
if (CheckAbort(Ok, meterctl)) { return Ok; }
if (pp.Setting.Production)
{
Ok = WriteRegisterSafe(meterctl.Meter, "Metersize", Register.Genesisflow.MeterSize, pp.Setting.MeterSize.GetHashCode(), false);
if (CheckAbort(Ok, meterctl)) { return Ok; }
}
else
{
WriteRegisterSafe(meterctl.Meter, "Metersize", Register.Genesisflow.MeterSize, pp.Setting.MeterSize.GetHashCode(), false);
if (CheckAbort(Ok, meterctl)) { return Ok; }
}
Ok = WriteRegisterSafe(meterctl.Meter, "LED mode", Register.Genesisflow.LedMode, pp.Setting.LedMode.GetHashCode());
if (CheckAbort(Ok, meterctl)) { return Ok; }
@@ -0,0 +1,256 @@
namespace CordonelPreadjustmentUi.Processes.Actions
{
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Xylem.Common.CommonCore.Configuration;
using Xylem.Common.Hardware.WaterMeter.Genesis.Registers;
using Xylem.Common.Logic.SoftwareAccessHelper;
using static CordonelPreadjustmentUi.PreAdjustmentControl;
/// <summary>
/// Process for cordonel water meters with pressure sensor.
/// </summary>
/// <remarks date="2023-05-23" author="Stoyan Zlatev">
/// Just started implementing pressure test for water meters with pressure sensor.
/// </remarks>
public class PressureTestProcess : BaseProcess
{
/// <summary>
/// Read / Write is pressure present for the water meter.
/// </summary>
/// <remarks date="2023-05-23" author="Stoyan Zlatev">
/// Just started implementing pressure test for water meters with pressure sensor.
/// </remarks>
private const string PRESSURE_PRESENT = "METROLOGYASST_PressurePresent";
/// <summary>
/// Read / Write pressure measurements for the water meter.
/// </summary>
/// <remarks date="2023-05-23" author="Stoyan Zlatev">
/// Just started implementing pressure test for water meters with pressure sensor.
/// </remarks>
private const string PRESSURE_MEASURE = "METROLOGYASST_PressureMeasure";
/// <summary>
/// Constructor for passing parameters to the base constructor of the derived class.
/// </summary>
/// <param name="processName">The name used to show into the GUI.</param>
/// <param name="panelState">TODO: Get the right description. Probably the state for the box into the GUI. ???</param>
/// <param name="performMessage">TODO: Get the right description. Probably the success message to show into the GUI. ???</param>
/// <param name="failedMessage">TODO: Get the right description. Probably the error message to show into the GUI. ???</param>
/// <param name="expectedTimeS">TODO: Get the right description. Probably the expected time for process the pressure tests. ???</param>
/// <remarks date="2023-05-23" author="Stoyan Zlatev">
/// Just started implementing pressure test for water meters with pressure sensor.
/// </remarks>
public PressureTestProcess(string processName, StatusPanelItems panelState, string performMessage, string failedMessage, int? expectedTimeS)
: base(processName, panelState, performMessage, failedMessage, expectedTimeS)
{
}
/// <summary>
/// Determinates and initializes a list of pressure measure tests processes on the logedin cordonels with pressure sensor.
/// Programm workflow for Cordonels with pressure sensor.
/// When any of the water meters has presure sensor - load the test specification.
/// Acording to the test specification process all meters, also the referenz on workplaces 11 and 12.
/// <list type="number">
/// <listheader>Measurement as follow.</listheader>
/// <item>Measure starts with <see cref="PRESSURE_MEASURE"/> = 1</item>
/// <item>Then registry is readeded and comaired to the referenz meters acording to the specification.</item>
/// </list>
/// </summary>
/// <returns>Returns a <see cref="List{Task}"/> for processing the pressure tests on the goggedin cordonels.</returns>
/// <remarks date="2023-05-23" author="Stoyan Zlatev">
/// Just started implementing pressure test for water meters with pressure sensor.
/// </remarks>
public override List<Task> StartWork()
{
/// List of the processes to start.
var listOfPresureTestTasks = new List<Task>();
var pressureTestSpecification = default(PressureTestSpecification);
var pressureTestSpecificationLoaded = false;
/// Just to not lose from focus the process progrss object.
var processProgress = base.CurrentProcessProgress;
var minPressureReferenzValue = default(int?);
var maxPressureReferenzValue = default(int?);
/// Looping trough all <see cref="MeterStateControl"/>s to determinate whitch are with pressure sensor.
foreach (var meterStateControl in base.MeterStateCtls)
{
/// If the meter is enabled and pressure sensor is present a new pressure mesure task should be initialized and added to the processes list.
if (meterStateControl.IsEnabled)
{
/// Getting the meter object from the state control.
var meter = meterStateControl.Meter;
/// Reads the buffer for determinating if the pressure sensor is present.
var isPressurePresentBuffer = meter.ReadRegister(PRESSURE_PRESENT);
/// Converted value for determinating if the pressure sensor is present.
var isPressurePresent = RegisterConverter.ConvertTo<bool>(isPressurePresentBuffer);
if (!isPressurePresent)
{
processProgress.DebugMessage($"Watermeter has no pressure sensor!", meterStateControl.Slot, "DC", meter.PcbId);
continue;
}
/// Loads the pressure test specification from the defined web service if not yet loaded.
if (pressureTestSpecification is null && !pressureTestSpecificationLoaded)
{
pressureTestSpecificationLoaded = true;
pressureTestSpecification = this.LoadPressureTestSpecification();
/// if loading fails
if (pressureTestSpecification is null)
{
processProgress.DebugMessage($"Test specification could not be loaded properly!", meterStateControl.Slot, "DC", meter.PcbId);
// TODO: Handle possible exceptions by making http request.
continue;
}
}
/// Initialize min and max referenz values ones for all meters
if (minPressureReferenzValue is null)
{
/// setting the min and max values on their oposit values.
/// checking the equality later will set up a value by 1 or more referenz meters.
minPressureReferenzValue = int.MaxValue;
maxPressureReferenzValue = int.MinValue;
if (processProgress.Setting.GetTempUseTempFlansh() || TempMeterStateCtls.Any(a => a.IsEnabled))
{
/// Determinates the min and max values aus temperatur meters list.
foreach (var referenzMeterState in base.TempMeterStateCtls)
{
if (referenzMeterState.IsEnabled)
{
var referenzMeter = referenzMeterState.Meter;
/// Reset meter pressure
referenzMeter.WriteRegister(PRESSURE_MEASURE, 1);
if (!referenzMeter.IsLoggedOn)
{
referenzMeter.Login();
}
var referenzPressureBuffer = referenzMeter.ReadRegister(PRESSURE_MEASURE);
var referenzPressure = RegisterConverter.ConvertTo<int>(referenzPressureBuffer);
if (referenzPressure < minPressureReferenzValue)
{
minPressureReferenzValue = referenzPressure;
}
if (referenzPressure > maxPressureReferenzValue)
{
maxPressureReferenzValue = referenzPressure;
}
}
}
}
/// Continue if min pressure value is still its oposit for the type. There was no referenz zehler found.
if (minPressureReferenzValue == int.MaxValue)
{
processProgress.DebugMessage($"No referenz watermeter found!", meterStateControl.Slot, "DC", meter.PcbId);
continue;
}
listOfPresureTestTasks.Add(new Task<bool>(() =>
{
var measuredTestValues = new int[pressureTestSpecification.NumberOfMeasurements];
var measurementDelyInS = pressureTestSpecification.TimeMeasurementsInS * 1000;
var numberOfMeasurements = pressureTestSpecification.NumberOfMeasurements;
var testDate = DateTime.Now;
for (int measurement = 0; measurement < numberOfMeasurements; measurement++)
{
/// Reset meter pressure
meter.WriteRegister(PRESSURE_MEASURE, 1);
/// Read the new meter pressure
var pressureMeasureBuffer = meter.ReadRegister(PRESSURE_MEASURE);
var pressureInPascals = RegisterConverter.ConvertTo<int>(pressureMeasureBuffer);
measuredTestValues[measurement] = pressureInPascals;
processProgress.DebugMessage($"Measure {measurement + 1}: {pressureInPascals}Pa", meterStateControl.Slot, "DC", meter.PcbId);
/// Dely only for first n - 1 measurements
if (measurement < numberOfMeasurements - 1)
{
Thread.Sleep(measurementDelyInS);
}
}
var avgPressure = (int)measuredTestValues.Average();
var testPassed = minPressureReferenzValue <= avgPressure && avgPressure <= maxPressureReferenzValue;
var avgPressureInBars = avgPressure / 100_000F;
processProgress.DebugMessage($"Average pressure: {avgPressure}Pa", meterStateControl.Slot, "DC", meter.PcbId);
processProgress.DebugMessage($"Average pressure: {avgPressureInBars}Bar", meterStateControl.Slot, "DC", meter.PcbId);
if (!this.PostPressureTestResult(meter.PcbId, avgPressureInBars, testPassed, testDate))
{
processProgress.DebugMessage($"Test result was not posted!", meterStateControl.Slot, "DC", meter.PcbId);
return false;
}
return testPassed;
}));
}
}
}
return listOfPresureTestTasks;
}
private PressureTestSpecification LoadPressureTestSpecification()
{
try
{
var responseContent = LocalWebRequest.GetRequest(ServiceUrls.GetPressureSensorSpecificationURL);
return JsonConvert.DeserializeObject<PressureTestSpecification>(responseContent);
}
catch (Exception e)
{
return null;
}
}
private bool PostPressureTestResult(string pcbIdText, float avgPressure, bool passed, DateTime testDate)
{
try
{
return LocalWebRequest.PostRequestAsync(ServiceUrls.PostPressureSensorResultURL, json: new
{
PcbId = int.TryParse(pcbIdText, out int pcbId) ? pcbId : default(int?),
AvgPressureInBar = avgPressure,
TestPassed = passed,
TestDate = testDate,
});
}
catch (Exception e)
{
return false;
}
}
}
internal class PressureTestSpecification
{
public int NumberOfMeasurements { get; set; }
public int TimeMeasurementsInS { get; set; }
public float MaxDeviationInBar { get; set; }
}
}
@@ -20,6 +20,7 @@ namespace CordonelPreadjustmentUi.Processes
public readonly string PerformMessage;
public readonly int ExpectedTimeS;
public DateTimeOffset StartTime;
public BaseProcess(string processName, StatusPanelItems panelState, string performMessage, string failedMessage, int? expectedTimeS = null)
{
ProcessName = processName;
@@ -30,6 +31,7 @@ namespace CordonelPreadjustmentUi.Processes
ExpectedTimeS = expectedTimeS.HasValue ? expectedTimeS.Value : 0;
}
internal List<MeterStateControl> AllMeterStateCtrls()
{
var r = new List<MeterStateControl>();
@@ -75,29 +77,29 @@ namespace CordonelPreadjustmentUi.Processes
var completTasks = new Task(() =>
{
try
{
while (!listOfProcessTasks.All(t => t.IsCompleted))
{
try
if (pp.CancellationSource != null && pp.CancellationSource.IsCancellationRequested)
{
while (!listOfProcessTasks.All(t => t.IsCompleted))
{
if (pp.CancellationSource != null && pp.CancellationSource.IsCancellationRequested)
{
return;
}
Thread.Sleep(5);
}
GetSequenceResult($"{ProcessName} sequence");
pp.IsBusy = false;
return;
}
catch (Exception ex)
{
Thread.Sleep(5);
}
throw new ApplicationException("Error on waiting for completition", ex);
}
GetSequenceResult($"{ProcessName} sequence");
pp.IsBusy = false;
}
catch (Exception ex)
{
throw new ApplicationException("Error on waiting for completition", ex);
}
});
});
completTasks.Start();
@@ -4,7 +4,6 @@ using System.Globalization;
using System.Threading;
using Logic.ProductionToProductMapper.Cordonel;
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore.Consts;
using Xylem.Common.Hardware.WaterMeter.WaterMeterCore.Consts;
using Xylem.Common.Ui.CordonelPreadjustmentUi;
using System.Collections.Generic;
using Xylem.Common.Logic.ProductionOrderCore.OrderData;
@@ -9,6 +9,8 @@ using System.Linq;
using System.Threading;
using Logic.ProductionToProductMapper.Cordonel;
using Xylem.Common.CommonCore.Consts;
using Xylem.Common.Hardware.Interfaces.Ports.PortCore;
using Xylem.Common.Hardware.Interfaces.Protocols.ProtocolCore.EventArguments;
using Xylem.Common.Hardware.WaterMeter.Genesis.DataPackages.EventArguments;
using Xylem.Common.Hardware.WaterMeter.Genesis.DataPackages.MeasurementRecords;
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisConfig;
@@ -1,5 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="GetPressureSensorSpecificationURL" value="http://sla12iis01.emea.sensus.net/MeterProcessState/api/CordonelPressureSensorTest/GetTestSpec"/>
<add key="PostPressureSensorResultURL" value="http://sla12iis01.emea.sensus.net/MeterProcessState/api/CordonelPressureSensorTest/PostTestResults"/>
<add key="PressureSensorResultsURL" value="http://sla12iis01.emea.sensus.net/MeterProcessState/api/CordonelPressureSensorTest/GetTestResults/{0}"/>
</appSettings>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="12.0.3" targetFramework="net40" />
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net40" />
<package id="NLog" version="5.2.2" targetFramework="net40" />
<package id="PDFsharp" version="1.50.5147" targetFramework="net40" />
</packages>
@@ -4,6 +4,7 @@ using System.Management;
using System.Text;
using System.Text.RegularExpressions;
using Newtonsoft.Json;
using Xylem.Common.CommonCore.Consts;
namespace Xylem.Common.Cryptology.Security
@@ -86,7 +87,7 @@ namespace Xylem.Common.Cryptology.Security
/// </remarks>
public static String GetPcNameFromHwId(String hardwareId)
{
if (!hardwareId.Contains(SeparatorPcFromHwId)) return "?";
if (!hardwareId.Contains(SeparatorPcFromHwId)) return Constants.StrUnknown;
var hwIdFields = hardwareId.Split(Convert.ToChar(SeparatorPcFromHwId));
return hwIdFields[0];
}
+14 -2
View File
@@ -16,6 +16,7 @@
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@@ -56,12 +57,17 @@
<Reference Include="BouncyCastle.Crypto, Version=1.8.1.0, Culture=neutral, PublicKeyToken=0e99375e54769942">
<HintPath>..\..\packages\BouncyCastle.Crypto.dll.1.8.1\lib\BouncyCastle.Crypto.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\..\packages\NLog.5.2.2\lib\net46\NLog.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.DirectoryServices.AccountManagement" />
<Reference Include="System.IO.Compression" />
<Reference Include="System.Management" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
@@ -79,5 +85,11 @@
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\CommonCore\CommonCore.csproj">
<Project>{1B02C79E-0B19-43E2-8F6B-71EF0C786C97}</Project>
<Name>CommonCore</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
+2 -1
View File
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="BouncyCastle.Crypto.dll" version="1.8.1" targetFramework="net472" />
<package id="Newtonsoft.Json" version="12.0.3" targetFramework="net472" />
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net472" />
<package id="NLog" version="5.2.2" targetFramework="net472" />
</packages>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,7 +1,7 @@
using System;
using System.IO.Ports;
namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisConfig
namespace Xylem.Common.Hardware.Interfaces.Ports.PortCore
{
/// <summary>
/// Collection of port settings
@@ -94,7 +94,10 @@
<Compile Include="EventArguments\ListBytePortDataEventArgs.cs" />
<Compile Include="EventArguments\StringPortDataEventArgs.cs" />
<Compile Include="IPort.cs" />
<Compile Include="PortConfig.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SlotConfig.cs" />
<Compile Include="SlotType.cs" />
<Compile Include="TransmitPortSettings.cs" />
</ItemGroup>
<ItemGroup>
@@ -104,9 +107,15 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\..\..\..\..\ServiceFwUpdate\packages\Newtonsoft.Json.12.0.3\lib\net40\Newtonsoft.Json.dll</HintPath>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\Newtonsoft.Json.13.0.3\lib\net40\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\NLog.5.2.2\lib\net35\NLog.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
@@ -1,6 +1,6 @@
using System;
namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisConfig
namespace Xylem.Common.Hardware.Interfaces.Ports.PortCore
{
/// <summary>
/// Container for port configuration
@@ -0,0 +1,17 @@
namespace Xylem.Common.Hardware.Interfaces.Ports.PortCore
{
/// <summary>
/// Definition of type for slot
/// </summary>
public enum SlotType
{
/// <summary>
/// Cordonel used as DUT with two serial ports
/// </summary>
DutMeter,
/// <summary>
/// Cordonel used as temperature meter with one serial port streaming the temperature
/// </summary>
TemperatureMeter,
}
}
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="12.0.3" targetFramework="net40" />
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net40" />
<package id="NLog" version="5.2.2" targetFramework="net40" />
</packages>
@@ -290,7 +290,7 @@ namespace Xylem.Common.Hardware.Interfaces.Ports.SerialPorts
//put the actual time stamp to this record being able to assign it correctly
//even if the decoding is delayed. This time stamp will be used to do the first
//synchronization at start and stop of the measurement. Therefor the serial buffer
//synchronization at start and stop of the measurement. Therefore the serial buffer
//has to be flushed in advance to avoid wrong time stamp to "old" records
_receiveTimeStampPc = DateTimeOffset.UtcNow;
@@ -438,7 +438,7 @@ namespace Xylem.Common.Hardware.Interfaces.Ports.SerialPorts
//read line of ASCII indicated by syncByte == null
if (null == PortSettingsForTransmitProtocol.ProtSyncByte)
{
//exit is timeout or received line
//exit is timeout from serialPort or received line
var rxStringRecord = _serialPort.ReadLine();
if (!string.IsNullOrEmpty(rxStringRecord))
@@ -554,11 +554,16 @@ namespace Xylem.Common.Hardware.Interfaces.Ports.SerialPorts
{ throw; }
catch (TimeoutException)
{
//ATTENTION: This "_serialPort.DiscardInBuffer()" caused a lot of trouble as it flushes a few incoming
//bytes and therefore destroys the already started data stream. Here it had been left in to indicate
//this critical issue!
/*-------------------------------DO NOT ACTIVATE-----------------------------------------------------*/
//flush receive buffer at timeout to force task to enter JoinWaitSleep state in finally
//if (_serialPort.IsOpen)
//{
// _serialPort.DiscardInBuffer();
//}
/*---------------------------------------------------------------------------------------------------*/
_byteDataLogger.Trace($"{Ident} Read timeout({InterByteReadDelayMs}ms)");
//_byteDataLogger.Trace($"{Ident} Read timeout({PortSettingsForTransmitProtocol.ResponseTimeoutMs}ms)");
@@ -673,7 +678,6 @@ namespace Xylem.Common.Hardware.Interfaces.Ports.SerialPorts
_serialPort.Write(txByteList.ToArray(), 0, txByteList.Count);
//TODO THW flush before sending NOT after
// flush the buffer for MOXA, to avoid two subsequent communications assembled to one communication!
_serialPort.BaseStream.Flush();
@@ -684,8 +688,5 @@ namespace Xylem.Common.Hardware.Interfaces.Ports.SerialPorts
_byteDataLogger.Error($"{Ident} {ex.Message}");
}
}
#region Prop
#endregion
}
}
@@ -215,14 +215,16 @@
<Compile Include="UartSerialPort.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\..\..\..\..\ServiceFwUpdate\packages\Newtonsoft.Json.12.0.3\lib\net40\Newtonsoft.Json.dll</HintPath>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\Newtonsoft.Json.13.0.3\lib\net40\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\NLog.4.6.7\lib\net40-client\NLog.dll</HintPath>
<Reference Include="NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\NLog.5.2.2\lib\net35\NLog.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Net" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\CommonCore\CommonCore.csproj">
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="12.0.3" targetFramework="net40" />
<package id="NLog" version="4.6.7" targetFramework="net40" />
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net40" />
<package id="NLog" version="5.2.2" targetFramework="net40" />
</packages>
@@ -3,10 +3,10 @@ using System.Collections.Concurrent;
using System.Threading;
using Xylem.Common.CommonCore.ThreadWatcher;
using Xylem.Common.Hardware.Interfaces.Ports.PortCore.EventArguments;
using Xylem.Common.Hardware.Interfaces.Protocols.ProtocolCore.EventArguments;
using Xylem.Common.Hardware.Interfaces.Protocols.TransmitProtocol;
using Xylem.Common.Hardware.WaterMeter.Genesis.DataPackages.EventArguments;
namespace Xylem.Common.Hardware.WaterMeter.Genesis.Protocols.ProtocolCore
namespace Xylem.Common.Hardware.Interfaces.Protocols.ProtocolCore
{
/// <inheritdoc />
/// <summary>
@@ -31,7 +31,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.Protocols.ProtocolCore
/// <summary>
/// Ident is a combined string of Slot, Port, Protocol and Type
/// </summary>
public readonly String Ident;
protected readonly String Ident;
private ITransmitProtocol _transmitProtocol;
/// <summary>
/// Starting decoding thread
@@ -56,7 +56,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.Protocols.ProtocolCore
/// <remarks date="2018-Feb-14" author="T.Wiedebusch">
/// - Initial
/// </remarks>
public void Dispose()
public virtual void Dispose()
{
//Cancel receive tokens
_decodingToken.Cancel();
@@ -70,7 +70,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.Protocols.ProtocolCore
while (_decodingThread.ThreadState != ThreadState.Stopped && timeoutCounter > 0)
{
Thread.Sleep(1);
timeoutCounter = timeoutCounter - 1;
timeoutCounter -= 1;
}
if (_decodingThread.ThreadState != ThreadState.Stopped)
@@ -110,9 +110,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.Protocols.ProtocolCore
{
while (!_decodingToken.IsCancellationRequested)
{
IPortDataEventArgs receivedRecord;
while (_decodingFifo.TryDequeue(out receivedRecord))
while (_decodingFifo.TryDequeue(out var receivedRecord))
{
DecodeRecord(receivedRecord);
}
@@ -129,7 +127,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.Protocols.ProtocolCore
/// The decoding routine
/// </summary>
/// <param name="data"></param>
public abstract void DecodeRecord(IPortDataEventArgs data);
protected abstract void DecodeRecord(IPortDataEventArgs data);
/// <inheritdoc />
public ITransmitProtocol GetTransmitProtocol()
@@ -1,6 +1,6 @@
using System;
namespace Xylem.Common.Hardware.WaterMeter.Genesis.DataPackages.EventArguments
namespace Xylem.Common.Hardware.Interfaces.Protocols.ProtocolCore.EventArguments
{
/// <inheritdoc />
@@ -1,9 +1,9 @@
using System;
using Xylem.Common.Hardware.Interfaces.Ports.PortCore.EventArguments;
using Xylem.Common.Hardware.Interfaces.Protocols.ProtocolCore.EventArguments;
using Xylem.Common.Hardware.Interfaces.Protocols.TransmitProtocol;
using Xylem.Common.Hardware.WaterMeter.Genesis.DataPackages.EventArguments;
namespace Xylem.Common.Hardware.WaterMeter.Genesis.Protocols.ProtocolCore
namespace Xylem.Common.Hardware.Interfaces.Protocols.ProtocolCore
{
/// <inheritdoc />
/// <summary>
@@ -1,7 +1,7 @@
using System.Runtime.InteropServices;
using System.Reflection;
[assembly: AssemblyTitle("Xylem.Common.Hardware.WaterMeter.Protocols.ProtocolCore")]
[assembly: AssemblyTitle("Xylem.Common.Hardware.Interfaces.Protocols.ProtocolCore")]
[assembly: AssemblyDescription("")]
[assembly: Guid("1A402949-095C-4039-8AE3-6594A7FB2242")]
@@ -7,8 +7,8 @@
<ProjectGuid>{8BDD2789-96D4-43EA-AAD7-0F49D0347998}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Xylem.Common.Hardware.WaterMeter.Genesis.Protocols.ProtocolCore</RootNamespace>
<AssemblyName>Xylem.Common.Hardware.WaterMeter.Genesis.Protocols.ProtocolCore</AssemblyName>
<RootNamespace>Xylem.Common.Hardware.Interfaces.Protocols.ProtocolCore</RootNamespace>
<AssemblyName>Xylem.Common.Hardware.Interfaces.Protocols.ProtocolCore</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
@@ -51,7 +51,7 @@
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<LangVersion>6</LangVersion>
<DocumentationFile>bin\x86\Debug\Xylem.Common.Hardware.WaterMeter.Genesis.Protocols.ProtocolCore.xml</DocumentationFile>
<DocumentationFile>bin\x86\Debug\Xylem.Common.Hardware.Interfaces.Protocols.ProtocolCore.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
@@ -174,44 +174,44 @@
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\..\..\..\..\..\ServiceFwUpdate\packages\Newtonsoft.Json.12.0.3\lib\net40\Newtonsoft.Json.dll</HintPath>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\Newtonsoft.Json.13.0.3\lib\net40\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\..\..\..\..\packages\NLog.4.6.7\lib\net40-client\NLog.dll</HintPath>
<Reference Include="NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\NLog.5.2.2\lib\net35\NLog.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\..\..\..\.shared\SharedAssemblyInfo.cs">
<Compile Include="..\..\..\..\.shared\SharedAssemblyInfo.cs">
<Link>Properties\SharedAssemblyInfo.cs</Link>
</Compile>
<Compile Include="BaseProtocol.cs" />
<Compile Include="EventArguments\BaseDataEventArgs.cs" />
<Compile Include="IProtocol.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\..\CommonCore\ThreadWatcher\ThreadWatcher.csproj">
<Project>{94ca71f3-c5d7-4ec6-ba47-fa8eea3c9406}</Project>
<ProjectReference Include="..\..\..\..\CommonCore\ThreadWatcher\ThreadWatcher.csproj">
<Project>{94CA71F3-C5D7-4EC6-BA47-FA8EEA3C9406}</Project>
<Name>ThreadWatcher</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\..\Interfaces\Ports\PortCore\PortCore.csproj">
<Project>{2e139f63-b6fe-4ea9-a098-85364fe9b26c}</Project>
<ProjectReference Include="..\..\Ports\PortCore\PortCore.csproj">
<Project>{2E139F63-B6FE-4EA9-A098-85364FE9B26C}</Project>
<Name>PortCore</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\..\Interfaces\Protocols\TransmitProtocol\TransmitProtocol.csproj">
<ProjectReference Include="..\TransmitProtocol\TransmitProtocol.csproj">
<Project>{63E0AC5E-B7C8-4363-A2FE-BE489E648FF0}</Project>
<Name>TransmitProtocol</Name>
</ProjectReference>
<ProjectReference Include="..\..\DataPackages\DataPackages.csproj">
<Project>{0e524d43-7b66-45cd-aa74-41d51afc3d99}</Project>
<Name>DataPackages</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net40" />
<package id="NLog" version="5.2.2" targetFramework="net40" />
</packages>
@@ -20,7 +20,7 @@ namespace Xylem.Common.Hardware.Interfaces.Protocols.TransmitProtocol
public abstract void SetDefaultResponseTimeout();
public abstract List<Byte> DecodeDataForPhysicalLayer(Byte command, Byte[] payload);
public abstract List<Byte> DecodeDataForPhysicalLayer(Byte command, Byte[] payload, Boolean hideDateInLog = false);
public abstract List<Byte> DecodeDataForLogicLayer(List<Byte> rawData);
@@ -28,7 +28,7 @@ namespace Xylem.Common.Hardware.Interfaces.Protocols.TransmitProtocol
/// <summary>
/// Send out data (including transport protocol specific data like CRC) to physical port (like UART or IrDA)
/// </summary>
List<Byte> DecodeDataForPhysicalLayer(Byte command , Byte[] payload);
List<Byte> DecodeDataForPhysicalLayer(Byte command , Byte[] payload, Boolean hideDateInLog = false);
/// <summary>
/// Received data have to be checked and converted to request protocol
@@ -139,7 +139,11 @@ namespace Xylem.Common.Hardware.Interfaces.Protocols.TransmitProtocol
/// <remarks date="2018-Mar-13" author="T.Wiedebusch">
/// - Initial
/// </remarks>
public override List<Byte> DecodeDataForPhysicalLayer(Byte requestProtocolCommand, Byte[] requestProtocolPayload)
/// <remarks date="2023-Mai-16" author="T.Wiedebusch">
/// - Hide data in log forwarded to DecodeDateForPhysicalLayer to hide passwords in log files.
/// </remarks>
public override List<Byte> DecodeDataForPhysicalLayer(Byte requestProtocolCommand, Byte[] requestProtocolPayload,
Boolean hideDateInLog = false)
{
var irdaCrcInputBuffer = new List<Byte>
{
@@ -165,7 +169,10 @@ namespace Xylem.Common.Hardware.Interfaces.Protocols.TransmitProtocol
irdaRecord.Add((Byte)(crcResult & 0xFF));
irdaRecord.Add((Byte)(crcResult >> 8));
Logger.Info($"DecodeDataForPhysicalLayer PC->Cordonel({BitConverter.ToString(irdaRecord.ToArray())})");
// avoid logging of passwords or other sensitive data
Logger.Info(hideDateInLog
? "DecodeDataForPhysicalLayer PC->Cordonel(*******************)"
: $"DecodeDataForPhysicalLayer PC->Cordonel({BitConverter.ToString(irdaRecord.ToArray())})");
return irdaRecord;
}
@@ -37,7 +37,7 @@ namespace Xylem.Common.Hardware.Interfaces.Protocols.TransmitProtocol
}
/// <inheritdoc />
public override List<Byte> DecodeDataForPhysicalLayer(Byte command, Byte[] payload)
public override List<Byte> DecodeDataForPhysicalLayer(Byte command, Byte[] payload, Boolean hideDateInLog = false)
{
throw new ApplicationException("Streaming port cannot send data");
}
@@ -97,14 +97,16 @@
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\..\..\..\..\ServiceFwUpdate\packages\Newtonsoft.Json.12.0.3\lib\net40\Newtonsoft.Json.dll</HintPath>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\Newtonsoft.Json.13.0.3\lib\net40\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\NLog.4.6.7\lib\net40-client\NLog.dll</HintPath>
<Reference Include="NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\NLog.5.2.2\lib\net35\NLog.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\..\..\.shared\SharedAssemblyInfo.cs">
@@ -25,9 +25,7 @@ namespace Xylem.Common.Hardware.Interfaces.Protocols.TransmitProtocol
private const Int32 UartSyncByteLength = 1; //length of syncByte
private const Int32 UartHeaderLength = 4; //length excluding syncByte and CRC
private const Int32 UartCrcLength = 2;
private const Int32 UartProtocolFrameLength = UartSyncByteLength + UartHeaderLength
+ UartCrcLength;
private const Int32 UartProtocolFrameLength = UartSyncByteLength + UartHeaderLength + UartCrcLength;
private const Byte UartSyncByte = 0x5B;
//The UART length covers all bytes excluding the syncByte length
@@ -113,7 +111,8 @@ namespace Xylem.Common.Hardware.Interfaces.Protocols.TransmitProtocol
}
/// <inheritdoc />
public override List<Byte> DecodeDataForPhysicalLayer(Byte requestProtocolCommand, Byte[] requestProtocolPayload)
public override List<Byte> DecodeDataForPhysicalLayer(Byte requestProtocolCommand,
Byte[] requestProtocolPayload, Boolean hideDataInLog = false)
{
var uartHeader = new List<Byte>();
var uartPayload = requestProtocolPayload.ToList();
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="12.0.3" targetFramework="net40" />
<package id="NLog" version="4.6.7" targetFramework="net40" />
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net40" />
<package id="NLog" version="5.2.2" targetFramework="net40" />
</packages>
@@ -93,11 +93,11 @@
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\..\..\..\..\packages\NLog.4.5.6\lib\net45\NLog.dll</HintPath>
<Private>True</Private>
<Reference Include="NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\..\..\..\..\packages\NLog.5.2.2\lib\net45\NLog.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.IO.Compression" />
<Reference Include="System.ServiceModel" />
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="NLog" version="5.2.2" targetFramework="net451" />
</packages>
@@ -132,10 +132,11 @@
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<ItemGroup>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\..\..\..\..\packages\NLog.4.6.7\lib\net45\NLog.dll</HintPath>
<Reference Include="NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\..\..\..\..\packages\NLog.5.2.2\lib\net45\NLog.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="NLog" version="4.6.7" targetFramework="net451" />
<package id="NLog" version="5.2.2" targetFramework="net451" />
<package id="NLog.Config" version="4.5.6" targetFramework="net451" />
<package id="NLog.Schema" version="4.5.6" targetFramework="net451" />
</packages>
@@ -136,8 +136,8 @@
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\..\..\..\..\packages\NLog.4.6.7\lib\net45\NLog.dll</HintPath>
<Reference Include="NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\..\..\..\..\packages\NLog.5.2.2\lib\net45\NLog.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.configuration" />
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="NLog" version="4.6.7" targetFramework="net451" />
<package id="NLog" version="5.2.2" targetFramework="net451" />
<package id="NLog.Config" version="4.5.6" targetFramework="net451" />
<package id="NLog.Schema" version="4.5.6" targetFramework="net451" />
</packages>
@@ -60,12 +60,17 @@
<OutputPath>bin\x64\_MANUAL_CONTROL\</OutputPath>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\..\..\..\..\ServiceFwUpdate\packages\Newtonsoft.Json.12.0.3\lib\net40\Newtonsoft.Json.dll</HintPath>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\Newtonsoft.Json.13.0.3\lib\net40\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\NLog.5.2.2\lib\net35\NLog.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\..\..\.shared\SharedAssemblyInfo.cs">
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="12.0.3" targetFramework="net40" />
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net40" />
<package id="NLog" version="5.2.2" targetFramework="net40" />
</packages>
@@ -215,7 +215,6 @@
<Compile Include="..\..\..\..\.shared\SharedAssemblyInfo.cs">
<Link>Properties\SharedAssemblyInfo.cs</Link>
</Compile>
<Compile Include="EventArguments\BaseDataEventArgs.cs" />
<Compile Include="EventArguments\CalibDataEventArgs.cs" />
<Compile Include="EventArguments\FlowDataEventArgs.cs" />
<Compile Include="EventArguments\RegisterUpdateEventArgs.cs" />
@@ -228,13 +227,15 @@
<Compile Include="TempTofCalc.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\..\..\..\..\ServiceFwUpdate\packages\Newtonsoft.Json.12.0.3\lib\net40\Newtonsoft.Json.dll</HintPath>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\Newtonsoft.Json.13.0.3\lib\net40\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\NLog.4.6.7\lib\net40-client\NLog.dll</HintPath>
<Reference Include="NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\NLog.5.2.2\lib\net35\NLog.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\CommonCore\CommonCore.csproj">
@@ -245,6 +246,10 @@
<Project>{6CCDB656-C676-4360-BABA-C4596AAD175D}</Project>
<Name>Measurements</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\Interfaces\Protocols\ProtocolCore\ProtocolCore.csproj">
<Project>{8BDD2789-96D4-43EA-AAD7-0F49D0347998}</Project>
<Name>ProtocolCore</Name>
</ProjectReference>
<ProjectReference Include="..\Registers\Registers.csproj">
<Project>{F4AAF7E6-7333-4284-B735-E32DEB076C64}</Project>
<Name>Registers</Name>
@@ -253,6 +258,7 @@
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.

Some files were not shown because too many files have changed in this diff Show More