New project Genesis/GenesisStatus:

- for all assembly and shipping checks,
implemented in
- CordonelAssemblyLine,
- ProductionProcessShippingMode,
- RegisterStore
This commit is contained in:
Thomas Wiedebusch
2023-03-01 17:20:44 +01:00
parent c795de584b
commit e52b55a5e4
14 changed files with 460 additions and 166 deletions
+67
View File
@@ -149,6 +149,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TempFlansh", "TempFlansh\Te
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DynamicStremingLogAnalyzer", "Ui\DynamicStremingLogAnalyzer\DynamicStremingLogAnalyzer.csproj", "{652ECA13-A411-4789-8814-6823965947CB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GenesisStatus", "Hardware\WaterMeter\Genesis\GenesisStatus\GenesisStatus\GenesisStatus.csproj", "{0F646872-D8DC-4EE5-989F-D4C73F0ACE3F}"
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
Utils\DateTimeServerShared\DateTimeServerShared.projitems*{4806d89a-fbfb-41bc-aaa7-2242444bf55a}*SharedItemsImports = 4
@@ -3383,6 +3385,70 @@ Global
{652ECA13-A411-4789-8814-6823965947CB}.XP32bit|x64.Build.0 = Release|Any CPU
{652ECA13-A411-4789-8814-6823965947CB}.XP32bit|x86.ActiveCfg = Release|Any CPU
{652ECA13-A411-4789-8814-6823965947CB}.XP32bit|x86.Build.0 = Release|Any CPU
{0F646872-D8DC-4EE5-989F-D4C73F0ACE3F}._MANUAL_CONTROL|Any CPU.ActiveCfg = Release|Any CPU
{0F646872-D8DC-4EE5-989F-D4C73F0ACE3F}._MANUAL_CONTROL|Any CPU.Build.0 = Release|Any CPU
{0F646872-D8DC-4EE5-989F-D4C73F0ACE3F}._MANUAL_CONTROL|Mixed Platforms.ActiveCfg = Release|Any CPU
{0F646872-D8DC-4EE5-989F-D4C73F0ACE3F}._MANUAL_CONTROL|Mixed Platforms.Build.0 = Release|Any CPU
{0F646872-D8DC-4EE5-989F-D4C73F0ACE3F}._MANUAL_CONTROL|x64.ActiveCfg = Release|Any CPU
{0F646872-D8DC-4EE5-989F-D4C73F0ACE3F}._MANUAL_CONTROL|x64.Build.0 = Release|Any CPU
{0F646872-D8DC-4EE5-989F-D4C73F0ACE3F}._MANUAL_CONTROL|x86.ActiveCfg = Release|Any CPU
{0F646872-D8DC-4EE5-989F-D4C73F0ACE3F}._MANUAL_CONTROL|x86.Build.0 = Release|Any CPU
{0F646872-D8DC-4EE5-989F-D4C73F0ACE3F}.COM|Any CPU.ActiveCfg = Release|Any CPU
{0F646872-D8DC-4EE5-989F-D4C73F0ACE3F}.COM|Any CPU.Build.0 = Release|Any CPU
{0F646872-D8DC-4EE5-989F-D4C73F0ACE3F}.COM|Mixed Platforms.ActiveCfg = Release|Any CPU
{0F646872-D8DC-4EE5-989F-D4C73F0ACE3F}.COM|Mixed Platforms.Build.0 = Release|Any CPU
{0F646872-D8DC-4EE5-989F-D4C73F0ACE3F}.COM|x64.ActiveCfg = Release|Any CPU
{0F646872-D8DC-4EE5-989F-D4C73F0ACE3F}.COM|x64.Build.0 = Release|Any CPU
{0F646872-D8DC-4EE5-989F-D4C73F0ACE3F}.COM|x86.ActiveCfg = Release|Any CPU
{0F646872-D8DC-4EE5-989F-D4C73F0ACE3F}.COM|x86.Build.0 = Release|Any CPU
{0F646872-D8DC-4EE5-989F-D4C73F0ACE3F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0F646872-D8DC-4EE5-989F-D4C73F0ACE3F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0F646872-D8DC-4EE5-989F-D4C73F0ACE3F}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{0F646872-D8DC-4EE5-989F-D4C73F0ACE3F}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{0F646872-D8DC-4EE5-989F-D4C73F0ACE3F}.Debug|x64.ActiveCfg = Debug|Any CPU
{0F646872-D8DC-4EE5-989F-D4C73F0ACE3F}.Debug|x64.Build.0 = Debug|Any CPU
{0F646872-D8DC-4EE5-989F-D4C73F0ACE3F}.Debug|x86.ActiveCfg = Debug|Any CPU
{0F646872-D8DC-4EE5-989F-D4C73F0ACE3F}.Debug|x86.Build.0 = Debug|Any CPU
{0F646872-D8DC-4EE5-989F-D4C73F0ACE3F}.GenesisDisplayTool_V01|Any CPU.ActiveCfg = Release|Any CPU
{0F646872-D8DC-4EE5-989F-D4C73F0ACE3F}.GenesisDisplayTool_V01|Any CPU.Build.0 = Release|Any CPU
{0F646872-D8DC-4EE5-989F-D4C73F0ACE3F}.GenesisDisplayTool_V01|Mixed Platforms.ActiveCfg = Release|Any CPU
{0F646872-D8DC-4EE5-989F-D4C73F0ACE3F}.GenesisDisplayTool_V01|Mixed Platforms.Build.0 = Release|Any CPU
{0F646872-D8DC-4EE5-989F-D4C73F0ACE3F}.GenesisDisplayTool_V01|x64.ActiveCfg = Release|Any CPU
{0F646872-D8DC-4EE5-989F-D4C73F0ACE3F}.GenesisDisplayTool_V01|x64.Build.0 = Release|Any CPU
{0F646872-D8DC-4EE5-989F-D4C73F0ACE3F}.GenesisDisplayTool_V01|x86.ActiveCfg = Release|Any CPU
{0F646872-D8DC-4EE5-989F-D4C73F0ACE3F}.GenesisDisplayTool_V01|x86.Build.0 = Release|Any CPU
{0F646872-D8DC-4EE5-989F-D4C73F0ACE3F}.PerformTest|Any CPU.ActiveCfg = Release|Any CPU
{0F646872-D8DC-4EE5-989F-D4C73F0ACE3F}.PerformTest|Any CPU.Build.0 = Release|Any CPU
{0F646872-D8DC-4EE5-989F-D4C73F0ACE3F}.PerformTest|Mixed Platforms.ActiveCfg = Release|Any CPU
{0F646872-D8DC-4EE5-989F-D4C73F0ACE3F}.PerformTest|Mixed Platforms.Build.0 = Release|Any CPU
{0F646872-D8DC-4EE5-989F-D4C73F0ACE3F}.PerformTest|x64.ActiveCfg = Release|Any CPU
{0F646872-D8DC-4EE5-989F-D4C73F0ACE3F}.PerformTest|x64.Build.0 = Release|Any CPU
{0F646872-D8DC-4EE5-989F-D4C73F0ACE3F}.PerformTest|x86.ActiveCfg = Release|Any CPU
{0F646872-D8DC-4EE5-989F-D4C73F0ACE3F}.PerformTest|x86.Build.0 = Release|Any CPU
{0F646872-D8DC-4EE5-989F-D4C73F0ACE3F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0F646872-D8DC-4EE5-989F-D4C73F0ACE3F}.Release|Any CPU.Build.0 = Release|Any CPU
{0F646872-D8DC-4EE5-989F-D4C73F0ACE3F}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{0F646872-D8DC-4EE5-989F-D4C73F0ACE3F}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{0F646872-D8DC-4EE5-989F-D4C73F0ACE3F}.Release|x64.ActiveCfg = Release|Any CPU
{0F646872-D8DC-4EE5-989F-D4C73F0ACE3F}.Release|x64.Build.0 = Release|Any CPU
{0F646872-D8DC-4EE5-989F-D4C73F0ACE3F}.Release|x86.ActiveCfg = Release|Any CPU
{0F646872-D8DC-4EE5-989F-D4C73F0ACE3F}.Release|x86.Build.0 = Release|Any CPU
{0F646872-D8DC-4EE5-989F-D4C73F0ACE3F}.ReleaseTest|Any CPU.ActiveCfg = Release|Any CPU
{0F646872-D8DC-4EE5-989F-D4C73F0ACE3F}.ReleaseTest|Any CPU.Build.0 = Release|Any CPU
{0F646872-D8DC-4EE5-989F-D4C73F0ACE3F}.ReleaseTest|Mixed Platforms.ActiveCfg = Release|Any CPU
{0F646872-D8DC-4EE5-989F-D4C73F0ACE3F}.ReleaseTest|Mixed Platforms.Build.0 = Release|Any CPU
{0F646872-D8DC-4EE5-989F-D4C73F0ACE3F}.ReleaseTest|x64.ActiveCfg = Release|Any CPU
{0F646872-D8DC-4EE5-989F-D4C73F0ACE3F}.ReleaseTest|x64.Build.0 = Release|Any CPU
{0F646872-D8DC-4EE5-989F-D4C73F0ACE3F}.ReleaseTest|x86.ActiveCfg = Release|Any CPU
{0F646872-D8DC-4EE5-989F-D4C73F0ACE3F}.ReleaseTest|x86.Build.0 = Release|Any CPU
{0F646872-D8DC-4EE5-989F-D4C73F0ACE3F}.XP32bit|Any CPU.ActiveCfg = Release|Any CPU
{0F646872-D8DC-4EE5-989F-D4C73F0ACE3F}.XP32bit|Any CPU.Build.0 = Release|Any CPU
{0F646872-D8DC-4EE5-989F-D4C73F0ACE3F}.XP32bit|Mixed Platforms.ActiveCfg = Release|Any CPU
{0F646872-D8DC-4EE5-989F-D4C73F0ACE3F}.XP32bit|Mixed Platforms.Build.0 = Release|Any CPU
{0F646872-D8DC-4EE5-989F-D4C73F0ACE3F}.XP32bit|x64.ActiveCfg = Release|Any CPU
{0F646872-D8DC-4EE5-989F-D4C73F0ACE3F}.XP32bit|x64.Build.0 = Release|Any CPU
{0F646872-D8DC-4EE5-989F-D4C73F0ACE3F}.XP32bit|x86.ActiveCfg = Release|Any CPU
{0F646872-D8DC-4EE5-989F-D4C73F0ACE3F}.XP32bit|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -3449,6 +3515,7 @@ Global
{108FE49B-75E1-43F5-82DD-DA33FE99CBEC} = {03D4F23E-7E4A-4091-BC96-036C996D351A}
{62E5BA37-36AB-4F0A-BC12-554E7A1F1A39} = {03D4F23E-7E4A-4091-BC96-036C996D351A}
{652ECA13-A411-4789-8814-6823965947CB} = {03D4F23E-7E4A-4091-BC96-036C996D351A}
{0F646872-D8DC-4EE5-989F-D4C73F0ACE3F} = {B5F43F61-4448-4992-85B5-7EDFB82FD643}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {4BCB7B69-696C-436A-86F7-C91EA5588164}
+2
View File
@@ -48,7 +48,9 @@
<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/=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>
@@ -180,6 +180,10 @@
<Project>{2C6378C6-6BA1-4CEE-8992-8404D8369A90}</Project>
<Name>GenesisFile</Name>
</ProjectReference>
<ProjectReference Include="..\Hardware\WaterMeter\Genesis\GenesisStatus\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,6 +12,7 @@ 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.Logic.SoftwareAccessHelper;
@@ -577,15 +578,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");
var BatteryMilliAHrRating = meter.ReadRegister("POWERMON_BatteryMilliAHrRating");
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";
@@ -594,84 +590,25 @@ 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);
//var BatteryMilliAHrRatingV = BitConverter.ToUInt32(BatteryMilliAHrRating.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");
// (nowSecondsV / nowChargeV) * (2*BatteryMilliAHrRatingV * 1000 * 3600)
//(POWERMON_TotalUsedSeconds / POWERMON_TotalUsedCharge) * (POWERMON_BatteryQuantity * POWERMON_BatteryMilliAHrRating * 1000 * 3600) = lifetime in seconds
//Lifetime in seconds - POWERMON_TotalUsedSeconds = remaining lifetime.
var POWERMON_TotalUsedSeconds = (double)(RegisterConverter.ConvertTo<UInt32>(meter.ReadRegister("POWERMON_TotalUsedSeconds")));
var tmp_POWERMON_TotalUsedCharge = meter.ReadRegister("POWERMON_TotalUsedCharge", 8);
var POWERMON_TotalUsedCharge = BitConverter.ToUInt64(tmp_POWERMON_TotalUsedCharge.ToArray(), 0);
var POWERMON_BatteryQuantity = (double)RegisterConverter.ConvertTo<int>(meter.ReadRegister("POWERMON_BatteryQuantity"));
var POWERMON_BatteryMilliAHrRating = (double)RegisterConverter.ConvertTo<UInt16>(meter.ReadRegister("POWERMON_BatteryMilliAHrRating"));
var lifetimeInSeconds = (POWERMON_TotalUsedSeconds / (double)(POWERMON_TotalUsedCharge)) * (POWERMON_BatteryQuantity * POWERMON_BatteryMilliAHrRating * 1000 * 3600);
var remainingLifetime = lifetimeInSeconds - POWERMON_TotalUsedSeconds;
var sbMSG = new StringBuilder();
sbMSG.AppendLine($"Pcb = {meter.PcbId}");
sbMSG.AppendLine($"POWERMON_TotalUsedSeconds = {POWERMON_TotalUsedSeconds}");
sbMSG.AppendLine($"POWERMON_TotalUsedCharge = {POWERMON_TotalUsedCharge}");
sbMSG.AppendLine($"POWERMON_BatteryQuantity = {POWERMON_BatteryQuantity}");
sbMSG.AppendLine($"POWERMON_BatteryMilliAHrRating = {POWERMON_BatteryMilliAHrRating}");
sbMSG.AppendLine($"POWERMON_TotalUsedSeconds = {genesisStatus.ExceededLifeTime_s}");
sbMSG.AppendLine($"POWERMON_TotalUsedCharge = {genesisStatus.DrainedBatteryPower_uAs}");
sbMSG.AppendLine($"POWERMON_BatteryQuantity = {genesisStatus.BatteryQuantity}");
sbMSG.AppendLine($"POWERMON_BatteryMilliAHrRating = {genesisStatus.InitialBatteryLoad_mAh}");
sbMSG.AppendLine("");
sbMSG.AppendLine($"lifetimeInSeconds = (POWERMON_TotalUsedSeconds / POWERMON_TotalUsedCharge) * (POWERMON_BatteryQuantity * POWERMON_BatteryMilliAHrRating * 1000 * 3600)");
sbMSG.AppendLine($"{lifetimeInSeconds} = ({POWERMON_TotalUsedSeconds} / {POWERMON_TotalUsedCharge}) * ({POWERMON_BatteryQuantity} * {POWERMON_BatteryMilliAHrRating} * 1000 * 3600)");
sbMSG.AppendLine("");
sbMSG.AppendLine("remainingLifetime = lifetimeInSeconds - POWERMON_TotalUsedSeconds");
sbMSG.AppendLine($"{remainingLifetime} = {lifetimeInSeconds} - {POWERMON_TotalUsedSeconds}");
sbMSG.AppendLine("");
sbMSG.AppendLine($"in Years {(remainingLifetime / 86400 / 365)}");
sbMSG.AppendLine($"Remaining life time in years {genesisStatus.RemainingLifeTimeYears:F2}");
sbMSG.AppendLine($"Totally drained battery load in % {genesisStatus.DrainedBatteryLoadPercent:F2}");
//// Time Span in h in mAhr In % with one battery is 100%
////(((total used change difference / (Time span / 3600) ) / 3600000) / 19000)*100
var loadAtH = ((((double)POWERMON_TotalUsedCharge / ((double)POWERMON_TotalUsedSeconds / 3600)) / 3600000) / (19000 * 2)) * 100;
var totalUsed = (((double)POWERMON_TotalUsedCharge / 1000000 / 3.6) / ((19000 * 2))) * 100;
sbMSG.AppendLine($"in % {totalUsed}");
if (totalUsed >= 7.5)
if (genesisStatus.DrainedBatteryLoadPercent >= 7.5)
{
lblS08Text = "Batterieentladung über 7.5%";
lblS08Color = _progressError;
ret = false;
}
meter.WriteLog(sbMSG.ToString());
}
}
if (_skipProcessSteps == null || !_skipProcessSteps.SkipLUT)
@@ -679,8 +616,6 @@ namespace CordonelAssemblyLine.Model
if (ret)
{
lblS08Text = "2";
lblS08Color = _progressDone;
lblS10Color = _progressCurrent;
@@ -8,45 +8,66 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisPwd
/// - passwords,
/// - password-hashes (12 char from password - SHA1),
/// - Order number,
/// - Radio address and
/// - Radio address,
/// - Key set id,
/// - Password file id and
/// - Skeleton key.
/// </summary>
public class MeterPwdDb
{
//password file length is 160 bytes (8 passwords a 20 bytes SHA1)
/// <summary>
/// password file length is 160 bytes (8 passwords a 20 bytes SHA1)
/// </summary>
public const Int32 PwdFileLength = 160;
/// <summary>
/// Skeleton key index in password list.
/// </summary>
public const Int32 SkeletonKeyIdx = 2;
/// <summary>
/// Password Level 8 index in 8 elements password list.
/// </summary>
public const Int32 PwdLevel8Idx = 7;
/// <summary>
/// Order number for this Genesis.
/// </summary>
public Int64? OrderNumber = null;
/// <summary>
/// Optional radio address.
/// </summary>
public Int64? RadioAddress = null;
/// <summary>
/// Skeleton key for login if password file is not installed.
/// </summary>
public String Skeleton = "";
/// <summary>
/// Password, which is the Skeleton, if password file not installed, or the PwdLevel8, if the password file is installed .
/// </summary>
public String Password = "";
/// <summary>
/// List of hashes.
/// </summary>
public List<Byte[]> ListOfHashes = new List<Byte[]>();
/// <summary>
/// List of passwords.
/// </summary>
public List<Byte[]> ListOfPasswords = new List<Byte[]>();
/// <summary>
/// Radio key set identifier.
/// </summary>
public String KeySetId;
/// <summary>
/// Ident number of password file.
/// </summary>
public String PasswordFileIdent;
}
}
@@ -0,0 +1,109 @@
using System;
namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisStatus
{
/// <summary>
/// Status of Cordonel like:
/// - Battery drainage,
/// - Production date of electronics,
/// - Due date for production,
/// - Remaining life time,
/// - Special permissions for production capability check for
/// - Battery Drainage in %,
/// - Remaining Life Time in years,
/// - Production Due Date as DateTime.
/// </summary>
public class GenesisStatus
{
/// <summary>
/// PcbId.
/// </summary>
public String PcbId;
/// <summary>
/// Internally used to signal that production and shipping is proved and validated.
/// </summary>
public Boolean ProductionAccepted;
/// <summary>
/// Date and time of production of electronics.
/// </summary>
public DateTime KitronProductionDate;
/// <summary>
/// Last date until production has to be finished, can be extended by special permission
/// </summary>
public DateTime ProductionDueDate;
/// <summary>
/// Remaining life time for Cordonel in years based on battery drainage.
/// </summary>
public Double RemainingLifeTimeYears;
/// <summary>
/// Exceeded life time of all batteries in seconds.
/// </summary>
public UInt64 ExceededLifeTime_s;
/// <summary>
/// Required life time in years for assembly, is dependent on region and special permission.
/// </summary>
public Double RequiredLifeTimeYearsAssembly;
/// <summary>
/// Required life time in years for shipping, is dependent on region and special permission.
/// </summary>
public Double RequiredLifeTimeYearsShipping;
/// <summary>
/// Battery drainage in percent.
/// </summary>
public Double DrainedBatteryLoadPercent;
/// <summary>
/// Number of batteries attached to Cordonel.
/// </summary>
public Int32 BatteryQuantity;
/// <summary>
/// Initial capacity of one battery in mAh.
/// </summary>
public UInt64 InitialBatteryLoad_mAh;
/// <summary>
/// Drained capacity of all batteries in uAs.
/// </summary>
public UInt64 DrainedBatteryPower_uAs;
/// <summary>
/// Comment for approval and permissions reasons:
/// e.g. "On customer requirement for test purposes the life time isn't of importance".
/// </summary>
public String ApprovalComment;
/// <summary>
/// Name of approver for special permissions.
/// </summary>
public String ApproverName;
/// <summary>
/// Date of approval.
/// </summary>
public DateTime ApprovalDate;
/// <summary>
/// Battery drainage is extended by approval.
/// </summary>
public Boolean BatteryDrainageExtended;
/// <summary>
/// Remaining life time is reduced by approval.
/// </summary>
public Boolean RemainingLifeTimeReduced;
/// <summary>
/// Date until Cordonel has to be produced is extended by approval.
/// </summary>
public Boolean ProductionDueDateExtended;
}
}
@@ -0,0 +1,58 @@
<?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>{0F646872-D8DC-4EE5-989F-D4C73F0ACE3F}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Xylem.Common.Hardware.WaterMeter.Genesis.GenesisStatus</RootNamespace>
<AssemblyName>Xylem.Common.Hardware.WaterMeter.Genesis.GenesisStatus</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</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>
<ItemGroup>
<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.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="GenesisStatusHandler.cs" />
<Compile Include="GenesisStatus.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\GenesisCore\GenesisCore.csproj">
<Project>{04201E95-90A0-4B73-A72F-379739B2A3AE}</Project>
<Name>GenesisCore</Name>
</ProjectReference>
<ProjectReference Include="..\..\Registers\Registers.csproj">
<Project>{F4AAF7E6-7333-4284-B735-E32DEB076C64}</Project>
<Name>Registers</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
@@ -0,0 +1,94 @@
using System;
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore;
using Xylem.Common.Hardware.WaterMeter.Genesis.Registers;
namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisStatus
{
/// <summary>
/// Handler for the production status check. This will be feed by the DB.
/// - Calculation of drained battery,
/// - Assembly capability check,
/// - Shipping capability check.
/// </summary>
public static class GenesisStatusHandler
{
/// <summary>
/// Read and calculate life time information.
/// </summary>
/// <param name="currentGenesis"></param>
/// <param name="status"></param>
/// <returns></returns>
public static Boolean BuildLifeTimeInformation(GenesisMeter currentGenesis, GenesisStatus status)
{
Boolean retVal;
if (currentGenesis == null || status == null) return false;
// read information from genesis
try
{
if (!currentGenesis.IsLoggedOn) currentGenesis.Login();
status.ExceededLifeTime_s = RegisterConverter.ConvertTo<UInt32>(
currentGenesis.ReadRegister(Register.Powermon.BatteryExceededSeconds));
status.DrainedBatteryPower_uAs = RegisterConverter.ConvertTo<UInt64>(
currentGenesis.ReadRegister(Register.Powermon.BatteryDrainedLoad, 8));
status.BatteryQuantity = RegisterConverter.ConvertTo<Int32>(
currentGenesis.ReadRegister(Register.Powermon.BatteryQuantity));
status.InitialBatteryLoad_mAh = RegisterConverter.ConvertTo<UInt32>(
currentGenesis.ReadRegister(Register.Powermon.BatteryInitialLoad));
currentGenesis.Logout();
retVal = CalculateLifeTime(status);
}
catch (Exception)
{
retVal = false;
}
return retVal;
}
/// <summary>
/// Calculation of life time values.
/// </summary>
/// <param name="status"></param>
/// <returns>true if all calculations could be executed</returns>
public static Boolean CalculateLifeTime(GenesisStatus status)
{
var retVal = true;
// Calculate the initial overall battery load of all batteries in uAs as the drained load uses this unit.
var initialBatteryLoad_uAs = 1000 * 3600 * status.InitialBatteryLoad_mAh * (UInt64)status.BatteryQuantity;
// Relation of drained to initial load, set the battery to fully unloaded for failed check to force a recalculation
var drainedBatteryLoad_rel = 1.0;
if (initialBatteryLoad_uAs != 0)
{
drainedBatteryLoad_rel = (Double)status.DrainedBatteryPower_uAs / initialBatteryLoad_uAs;
}
else
{
retVal = false;
}
status.DrainedBatteryLoadPercent = drainedBatteryLoad_rel * 100;
// The estimated life time uses the drained load over the actual exceeded life time and assumes, that further on
// an identical load will be consumed over the remaining life cycle. The initial load will be multiplied with the
// drained load relation. Set the estimated time to the exceeded time to force a recalculation on failed input.
var estimatedLifeTime_s = (Double)status.ExceededLifeTime_s;
if (drainedBatteryLoad_rel != 0.0)
{
estimatedLifeTime_s = status.ExceededLifeTime_s / drainedBatteryLoad_rel;
}
else
{
retVal = false;
}
var remainingLifetime_s = estimatedLifeTime_s - status.ExceededLifeTime_s;
// convert the seconds to years
status.RemainingLifeTimeYears = remainingLifetime_s / 3600 / 24 / 365.25;
return retVal;
}
}
}
@@ -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("GenesisStatus")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("GenesisStatus")]
[assembly: AssemblyCopyright("Copyright © Microsoft 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("0f646872-d8dc-4ee5-989f-d4c73f0ace3f")]
// 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")]
@@ -89,6 +89,9 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.Registers
{
public static readonly String BatteryVoltage = "POWERMON_BatteryVoltage";
public static readonly String BatteryQuantity = "POWERMON_BatteryQuantity";
public static readonly String BatteryDrainedLoad = "POWERMON_TotalUsedCharge";
public static readonly String BatteryInitialLoad = "POWERMON_BatteryMilliAHrRating";
public static readonly String BatteryExceededSeconds = "POWERMON_TotalUsedSeconds";
}
@@ -1,11 +1,11 @@
using System;
using System.Linq;
using System.Windows.Controls;
using System.Windows.Threading;
using Newtonsoft.Json;
using ProductionUiCordonel.ProductionProcesses.Enum;
using ProductionUiCordonel.UserControls.FinalTest;
using Xylem.Common.CommonCore.Configuration;
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisStatus;
using Xylem.Common.Logic.SoftwareAccessHelper;
namespace ProductionUiCordonel.ProductionProcesses.Actions
@@ -108,9 +108,10 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
Progress = 50;
var nowSeconds = Meter.ReadRegister("POWERMON_TotalUsedSeconds");
var nowCharge = Meter.ReadRegister("POWERMON_TotalUsedCharge", 8);
if (nowCharge == null)
var genesisStatus = new GenesisStatus();
// this calculates all life time values
if (!GenesisStatusHandler.BuildLifeTimeInformation(Meter, genesisStatus))
{
UserControl.lblText.Dispatcher.Invoke(DispatcherPriority.Send,
@@ -122,26 +123,15 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
Meter.WriteLog("Batterie nicht lesbar");
break;
}
var nowChargeV = BitConverter.ToUInt64(nowCharge.ToArray(), 0);
var nowSecondsV = BitConverter.ToUInt32(nowSeconds.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 used for debug purposes
var loadAtH = nowChargeV / ((Double)nowSecondsV / 3600) / 3600000 / (19000 * 2) * 100;
var totalUsed = (Double)nowChargeV / 1000000 / 3.6 / (19000 * 2) * 100;
//lastFrame
Meter.WriteLog($"totalUsed at EOL {totalUsed}");
if (totalUsed > 10)
Meter.WriteLog($"totalUsed at EOL {genesisStatus.DrainedBatteryLoadPercent:F2}");
if (genesisStatus.DrainedBatteryLoadPercent > 10.0)
{
currentProcessState = ProductionProcessState.Error;
UserControl.lblText.Content = "Batterie über 15% entladen";
Meter.WriteLog("Batterie über 15% entladen");
UserControl.lblText.Content = "Batterie über 10% entladen";
Meter.WriteLog("Batterie über 10% entladen");
}
if (currentProcessState != ProductionProcessState.Error)
@@ -149,7 +139,7 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
currentProcessState = ProductionProcessState.Done;
return;
}
retriesRemaining = retriesRemaining - 1;
retriesRemaining -= 1;
currentProcessState = ProductionProcessState.Error;
}
@@ -157,10 +147,8 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
{
Meter.WriteLog($"{ex}");
currentProcessState = ProductionProcessState.Error;
retriesRemaining = retriesRemaining - 1;
retriesRemaining -= 1;
}
}
currentProcessState = ProductionProcessState.Error;
}
@@ -339,6 +339,10 @@
<Project>{AC434B18-4D7B-49BA-9AD5-0527C79E8297}</Project>
<Name>GenesisPwd</Name>
</ProjectReference>
<ProjectReference Include="..\Hardware\WaterMeter\Genesis\GenesisStatus\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>
@@ -629,6 +629,10 @@
<Project>{ac434b18-4d7b-49ba-9ad5-0527c79e8297}</Project>
<Name>GenesisPwd</Name>
</ProjectReference>
<ProjectReference Include="..\..\Hardware\WaterMeter\Genesis\GenesisStatus\GenesisStatus\GenesisStatus.csproj">
<Project>{0F646872-D8DC-4EE5-989F-D4C73F0ACE3F}</Project>
<Name>GenesisStatus</Name>
</ProjectReference>
<ProjectReference Include="..\..\Hardware\WaterMeter\Genesis\Protocols\ProtocolCore\ProtocolCore.csproj">
<Project>{8BDD2789-96D4-43EA-AAD7-0F49D0347998}</Project>
<Name>ProtocolCore</Name>
+32 -63
View File
@@ -17,6 +17,7 @@ using Xylem.Common.CommonCore.Configuration;
using Xylem.Common.CommonCore.Consts;
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisConfig;
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore;
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisStatus;
using Xylem.Common.Hardware.WaterMeter.Genesis.Registers;
using Xylem.Common.Hardware.WaterMeter.WaterMeterCore;
using Xylem.Common.Logic.ServiceCore;
@@ -2201,82 +2202,50 @@ namespace Xylem.Common.Ui.GenesisToolBox
private void btnBatLife_Click(Object sender, EventArgs e)
{
if (cbComSlot.SelectedItem != null) // && cbComSlot.SelectedValue is ListBoxItem)
if (cbComSlot.SelectedItem == null) return;
if (string.IsNullOrEmpty(cbComSlot.SelectedItem.ToString()) ||
!int.TryParse(cbComSlot.SelectedItem.ToString(), out var slotNR)) return;
try
{
Int32 slotNR = 0;
if (!string.IsNullOrEmpty(cbComSlot.SelectedItem.ToString()) &&
int.TryParse(cbComSlot.SelectedItem.ToString(), out slotNR))
conntect(slotNR);
foreach (var me in _meterBatch.ListOfMeters)
{
try
if (me is GenesisMeter)
{
conntect(slotNR);
foreach (var me in _meterBatch.ListOfMeters)
if (((GenesisMeter)me).IsLoggedOn)
{
if (me is GenesisMeter)
_currentGenesis = ((GenesisMeter)me);
var genesisStatus = new GenesisStatus();
if (GenesisStatusHandler.BuildLifeTimeInformation(_currentGenesis, genesisStatus))
{
if (((GenesisMeter)me).IsLoggedOn)
{
_currentGenesis = ((GenesisMeter)me);
var sbMSG = new StringBuilder();
sbMSG.AppendLine($"Pcb = {_currentGenesis.PcbId}");
var POWERMON_TotalUsedSeconds = (double)(RegisterConverter.ConvertTo<UInt32>(_currentGenesis.ReadRegister("POWERMON_TotalUsedSeconds")));
var tmp_POWERMON_TotalUsedCharge = _currentGenesis.ReadRegister("POWERMON_TotalUsedCharge", 8);
var POWERMON_TotalUsedCharge = BitConverter.ToUInt64(tmp_POWERMON_TotalUsedCharge.ToArray(), 0);
var POWERMON_BatteryQuantity = (double)RegisterConverter.ConvertTo<int>(_currentGenesis.ReadRegister("POWERMON_BatteryQuantity"));
var POWERMON_BatteryMilliAHrRating = (double)RegisterConverter.ConvertTo<UInt16>(_currentGenesis.ReadRegister("POWERMON_BatteryMilliAHrRating"));
var lifetimeInSeconds = (POWERMON_TotalUsedSeconds / (double)(POWERMON_TotalUsedCharge)) * (POWERMON_BatteryQuantity * POWERMON_BatteryMilliAHrRating * 1000 * 3600);
var remainingLifetime = lifetimeInSeconds - POWERMON_TotalUsedSeconds;
var sbMSG = new StringBuilder();
sbMSG.AppendLine($"Pcb = {_currentGenesis.PcbId}");
sbMSG.AppendLine($"POWERMON_TotalUsedSeconds = {POWERMON_TotalUsedSeconds}");
sbMSG.AppendLine($"POWERMON_TotalUsedCharge = {POWERMON_TotalUsedCharge}");
sbMSG.AppendLine($"POWERMON_BatteryQuantity = {POWERMON_BatteryQuantity}");
sbMSG.AppendLine($"POWERMON_BatteryMilliAHrRating = {POWERMON_BatteryMilliAHrRating}");
sbMSG.AppendLine("");
sbMSG.AppendLine($"lifetimeInSeconds = (POWERMON_TotalUsedSeconds / POWERMON_TotalUsedCharge) * (POWERMON_BatteryQuantity * POWERMON_BatteryMilliAHrRating * 1000 * 3600)");
sbMSG.AppendLine($"{lifetimeInSeconds} = ({POWERMON_TotalUsedSeconds} / {POWERMON_TotalUsedCharge}) * ({POWERMON_BatteryQuantity} * {POWERMON_BatteryMilliAHrRating} * 1000 * 3600)");
sbMSG.AppendLine("");
sbMSG.AppendLine("remainingLifetime = lifetimeInSeconds - POWERMON_TotalUsedSeconds");
sbMSG.AppendLine($"{remainingLifetime} = {lifetimeInSeconds} - {POWERMON_TotalUsedSeconds}");
sbMSG.AppendLine("");
sbMSG.AppendLine($"in Years {(remainingLifetime/86400/365)}");
//// Time Span in h in mAhr In % with one battery is 100%
////(((total used change difference / (Time span / 3600) ) / 3600000) / 19000)*100
var loadAtH = ((((double)POWERMON_TotalUsedCharge / ((double)POWERMON_TotalUsedSeconds / 3600)) / 3600000) / (19000 * 2)) * 100;
var totalUsed = (((double)POWERMON_TotalUsedCharge / 1000000 / 3.6) / ((19000 * 2))) * 100;
sbMSG.AppendLine($"in % {totalUsed}");
MessageBox.Show(sbMSG.ToString(), $"Battery for {_currentGenesis.PcbId} has remaning life time of {(remainingLifetime / 86400 / 365)} years");
}
sbMSG.AppendLine($"POWERMON_TotalUsedSeconds = {genesisStatus.ExceededLifeTime_s}");
sbMSG.AppendLine($"POWERMON_TotalUsedCharge = {genesisStatus.DrainedBatteryPower_uAs}");
sbMSG.AppendLine($"POWERMON_BatteryQuantity = {genesisStatus.BatteryQuantity}");
sbMSG.AppendLine($"POWERMON_BatteryMilliAHrRating = {genesisStatus.InitialBatteryLoad_mAh}");
sbMSG.AppendLine("");
sbMSG.AppendLine($"Remaining life time in years {genesisStatus.RemainingLifeTimeYears:F2}");
sbMSG.AppendLine($"Totally drained battery load in % {genesisStatus.DrainedBatteryLoadPercent:F2}");
MessageBox.Show(sbMSG.ToString(), $"Battery for {_currentGenesis.PcbId} has remaining life " +
$"time of {genesisStatus.RemainingLifeTimeYears:F2} years");
}
else
{
MessageBox.Show("Failed to get life time information");
}
}
}
catch (Exception ex)
{
return;
}
return;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
}
}