Merge branch 'main' into Dev_CUST

This commit is contained in:
Thomas Wiedebusch
2024-04-11 16:20:17 +02:00
7 changed files with 99 additions and 53 deletions
+1 -1
View File
@@ -155,7 +155,7 @@
</site>
<site name="MeterProcessState" id="2">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="D:\Projekte\SENSUS_GitLab\laa_production\Common\Service\MeterProcessState" />
<virtualDirectory path="/" physicalPath="D:\Projekte\SENSUS_GitLab\LAA_PRODUCTION\Common\Service\MeterProcessState" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:56011:localhost" />
@@ -5,7 +5,7 @@
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{D0C8D887-ED52-40AB-A069-90BCE0E801E2}</ProjectGuid>
<OutputType>WinExe</OutputType>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Xylem.Common.Ui.CordonelPreadjustmentUi</RootNamespace>
<AssemblyName>Xylem.Common.Ui.CordonelPreadjustmentUi</AssemblyName>
@@ -110,9 +110,7 @@
<PropertyGroup />
<PropertyGroup />
<PropertyGroup />
<PropertyGroup>
<NoWin32Manifest>true</NoWin32Manifest>
</PropertyGroup>
<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\net40\Newtonsoft.Json.dll</HintPath>
@@ -159,61 +159,31 @@ namespace CordonelPreadjustmentUi.Processes.Actions
Ok = true;
#endregion
#region Calculate mean value
if (true)
for (UInt16 Path = 0; Path < meterctl.Meter.listOfTotalTimeOfFlightSPerPath.GetPathCount(); Path++)
{
var meanVal = meterctl.Meter.listOfTotalTimeOfFlightSPerPath.Get(1).ToList().Mean();
pp.DebugMessage($"Calculate mean value {meanVal} at {meterctl.Meter.Slot}; PATH{(1 + 1).ToString(pp.Setting.Culture)}", meterctl.Meter.Slot, "DC", meterctl.Meter.PcbId);
var meanVal = meterctl.Meter.listOfTotalTimeOfFlightSPerPath.Get(Path).ToList().Mean();
pp.DebugMessage($"Calculate mean value {meanVal} at {meterctl.Meter.Slot}; PATH{(Path + 1).ToString(pp.Setting.Culture)}", meterctl.Meter.Slot, "DC", meterctl.Meter.PcbId);
//earlier TofAvgMeanTotal
//TofAvgMean.Update(Path, meanVal);
if (meanVal == 0)
{
pp.DebugMessage($"Mean value is zero at {meterctl.Meter.Slot}; PATH{(1 + 1).ToString(pp.Setting.Culture)}; Value = {Math.Round(meanVal, 4).ToString("000.0000", pp.Setting.Culture)}", meterctl.Meter.Slot, "DC", meterctl.Meter.PcbId);
pp.DebugMessage($"Mean value is zero at {meterctl.Meter.Slot}; PATH{(Path + 1).ToString(pp.Setting.Culture)}; Value = {Math.Round(meanVal, 4).ToString("000.0000", pp.Setting.Culture)}", meterctl.Meter.Slot, "DC", meterctl.Meter.PcbId);
meterctl.Meter.calibrationResult.AddAdditionalLog($"" +
$"PATH {1 + 1}", Math.Round(meanVal, 4).ToString("000.0000", pp.Setting.Culture));
$"PATH {Path + 1}", Math.Round(meanVal, 4).ToString("000.0000", pp.Setting.Culture));
if (CheckAbort(false, meterctl)) { return false; }
}
pp.DebugMessage($"Mean value at {meterctl.Meter.Slot}; PATH{(1 + 1).ToString(pp.Setting.Culture)}; Value = {Math.Round(meanVal, 4).ToString("000.0000", pp.Setting.Culture)}", meterctl.Meter.Slot, "DC", meterctl.Meter.PcbId);
pp.DebugMessage($"Mean value at {meterctl.Meter.Slot}; PATH{(Path + 1).ToString(pp.Setting.Culture)}; Value = {Math.Round(meanVal, 4).ToString("000.0000", pp.Setting.Culture)}", meterctl.Meter.Slot, "DC", meterctl.Meter.PcbId);
meterctl.Meter.calibrationResult.AddAdditionalLog($"Amp. Test Mean value PATH {1 + 1}", $"at {FirstHitLevelPercentage}={Math.Round(meanVal, 4).ToString("000.0000", pp.Setting.Culture)}");
var cTofAvgMeanTotal = TofAvgMeanTotal.Get(1).ToList();
meterctl.Meter.calibrationResult.AddAdditionalLog($"Amp. Test Mean value PATH {Path + 1}", $"at {FirstHitLevelPercentage}={Math.Round(meanVal, 4).ToString("000.0000", pp.Setting.Culture)}");
var cTofAvgMeanTotal = TofAvgMeanTotal.Get(Path).ToList();
cTofAvgMeanTotal.Add(meanVal);
TofAvgMeanTotal.Update(1, cTofAvgMeanTotal);
TofAvgMeanTotal.Update(Path, cTofAvgMeanTotal);
//meterctl.Meter.listOfTotalTimeOfFlightSPerPath.Update(Path,new List<Double>());
}
else
{
for (UInt16 Path = 0; Path < meterctl.Meter.listOfTotalTimeOfFlightSPerPath.GetPathCount(); Path++)
{
var meanVal = meterctl.Meter.listOfTotalTimeOfFlightSPerPath.Get(Path).ToList().Mean();
pp.DebugMessage($"Calculate mean value {meanVal} at {meterctl.Meter.Slot}; PATH{(Path + 1).ToString(pp.Setting.Culture)}", meterctl.Meter.Slot, "DC", meterctl.Meter.PcbId);
//earlier TofAvgMeanTotal
//TofAvgMean.Update(Path, meanVal);
if (meanVal == 0)
{
pp.DebugMessage($"Mean value is zero at {meterctl.Meter.Slot}; PATH{(Path + 1).ToString(pp.Setting.Culture)}; Value = {Math.Round(meanVal, 4).ToString("000.0000", pp.Setting.Culture)}", meterctl.Meter.Slot, "DC", meterctl.Meter.PcbId);
meterctl.Meter.calibrationResult.AddAdditionalLog($"" +
$"PATH {Path + 1}", Math.Round(meanVal, 4).ToString("000.0000", pp.Setting.Culture));
if (CheckAbort(false, meterctl)) { return false; }
}
pp.DebugMessage($"Mean value at {meterctl.Meter.Slot}; PATH{(Path + 1).ToString(pp.Setting.Culture)}; Value = {Math.Round(meanVal, 4).ToString("000.0000", pp.Setting.Culture)}", meterctl.Meter.Slot, "DC", meterctl.Meter.PcbId);
meterctl.Meter.calibrationResult.AddAdditionalLog($"Amp. Test Mean value PATH {Path + 1}", $"at {FirstHitLevelPercentage}={Math.Round(meanVal, 4).ToString("000.0000", pp.Setting.Culture)}");
var cTofAvgMeanTotal = TofAvgMeanTotal.Get(Path).ToList();
cTofAvgMeanTotal.Add(meanVal);
TofAvgMeanTotal.Update(Path, cTofAvgMeanTotal);
//meterctl.Meter.listOfTotalTimeOfFlightSPerPath.Update(Path,new List<Double>());
}
}
#endregion
}
@@ -252,7 +222,7 @@ namespace CordonelPreadjustmentUi.Processes.Actions
var tmpOptimalPoint = 0;
var tmpDistanceLeft = 0.0;
var tmpDistanceRight = 0.0;
var r = CalculateOptimalPoint(pp, meterctl.Meter.Slot, TofAvgMeanTotal.Get(Path).ToList(), out tmpDistanceLeft, out tmpDistanceRight, out tmpOptimalPoint);
OptimalPoint.Update(Path, tmpOptimalPoint);
DistanceLeft.Update(Path, tmpDistanceLeft);
@@ -607,19 +607,23 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.Protocols.RequestProtocol
/// <remarks date="2024-Apr-11" author="T.Wiedebusch">
/// - Exit multiple read date if retries exceeded increased to <see cref="CommunicationConfig.MaxRequestRetries"/>.
/// </remarks>
/// <remarks date="2024-Apr-11 Version 2" author="T.Wiedebusch">
/// - Rewound to version from 06.09.2023 14:44:33 before Commit 8c9d7704.
/// </remarks>
public RequestRecord CommandToMeter(Byte command, RegisterDefinition meterRegister = null,
Byte[] payload = null, Int32 expectedLength = 4, Boolean hideDataInLog = false,
Byte[] payload = null, Int32? expectedLength = null, Boolean hideDataInLog = false,
UInt16 skipRetryErrorCode = CommunicationConfig.SkipRetryErrorCode)
{
if (command == Commands.MultipleReadData && meterRegister != null && meterRegister.DataType == typeof(String))
{
var completeResponse = new List<Byte>();
while (!completeResponse.Contains(0) && _recordInProcess.RetryCtr <= CommunicationConfig.MaxRequestRetries)
//TODO THW check this including the recursive call CommandToMeter
while (true)
{
var cRecord = CommandToMeter(Commands.ReadData, meterRegister, payload, 4, hideDataInLog,
skipRetryErrorCode);
var cRecord = CommandToMeter(Commands.ReadData, meterRegister, payload, expectedLength,
hideDataInLog, skipRetryErrorCode);
var rest = ProcessRecordList();
if (rest == RequestAcknowledgeState.Ok && cRecord?.ResponsePayload != null)
if (rest == RequestAcknowledgeState.Ok && cRecord != null && cRecord.ResponsePayload != null)
{
completeResponse.AddRange(cRecord.ResponsePayload);
if (cRecord.ResponsePayload.Contains(0))
@@ -627,11 +631,68 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.Protocols.RequestProtocol
cRecord.ResponsePayload = completeResponse;
OnMeterRegisterUpdated?.Invoke(this,
new RegisterUpdatedEventArgs(meterRegister, completeResponse.ToArray()));
if (expectedLength.HasValue && completeResponse.Count < expectedLength.Value)
{
_logger.Debug("Too Short. Payload contains zero");
}
return cRecord;
}
}
else
{
if (expectedLength.HasValue && completeResponse.Any() &&
completeResponse.Count < expectedLength.Value)
{
if (rest != RequestAcknowledgeState.Ok)
{
_logger.Debug($"Too Short.Request Acknowledge State is {rest}");
}
else if (cRecord == null)
{
_logger.Debug("Too Short.Record is empty or null");
}
else if (cRecord.ResponsePayload == null)
{
_logger.Debug("Too Short.ResponsePayload is empty or null");
}
else
{
_logger.Debug("Too Short.Unkown reason");
}
}
return cRecord;
}
}
}
//if (command == Commands.MultipleReadData && meterRegister != null && meterRegister.DataType == typeof(String))
//{
// var completeResponse = new List<Byte>();
// while (!completeResponse.Contains(0) && _recordInProcess.RetryCtr <= CommunicationConfig.MaxRequestRetries)
// {
// var cRecord = CommandToMeter(Commands.ReadData, meterRegister, payload, 4, hideDataInLog,
// skipRetryErrorCode);
// var rest = ProcessRecordList();
// if (rest == RequestAcknowledgeState.Ok && cRecord?.ResponsePayload != null)
// {
// completeResponse.AddRange(cRecord.ResponsePayload);
// if (cRecord.ResponsePayload.Contains(0))
// {
// cRecord.ResponsePayload = completeResponse;
// OnMeterRegisterUpdated?.Invoke(this,
// new RegisterUpdatedEventArgs(meterRegister, completeResponse.ToArray()));
// return cRecord;
// }
// }
// if (cRecord?.ResponsePayload == null)
// {
// return null;
// }
// }
//}
//the minimum payload is one 4 byte chunk
var chunkSize = RegisterDefinition.ChunkSize;
if (payload == null)
@@ -674,7 +735,20 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.Protocols.RequestProtocol
if (command == Commands.MultipleReadData)
{
var numberOfChunks = (UInt16)(expectedLength / chunkSize);
//TODO THW create expected size out of meterRegister.DataType
if (!expectedLength.HasValue)
{
if ((meterRegister.DataType == typeof(UInt64) || meterRegister.DataType == typeof(Int64)))
{
expectedLength = 8;
}
else
{
expectedLength = 24;
}
}
var numberOfChunks = (UInt16)(expectedLength.Value / chunkSize);
if (expectedLength % chunkSize != 0)
numberOfChunks++;
requestProtocol.Add((Byte)(numberOfChunks & 0xFF));
@@ -1 +1 @@
bf6bb8fceb3db5a9977dadc407cf576684bf7127
8fbe991b217e7692af4817ad205b768685aa5a72
@@ -1 +1 @@
247396738e2c5d26ac00f9df05c0cc5c61d7f33a
1babc7d629fd8c486aff20f4990c117c2e58a68f
@@ -1461,6 +1461,9 @@ namespace Xylem.ServiceFwUpdate.Ui.FwUpdateBuilder
/// <remarks date="2021-Apr-13" author="Thomas Wiedebusch">
/// - Initial.
/// </remarks>
/// <remarks date="2024-Apr-11" author="Thomas Wiedebusch">
/// - Added builder opertor id.
/// </remarks>
private void CheckUserRegistration()
{
if (_fwUpdateDbAccess == null || _regUser == null)
@@ -1481,6 +1484,7 @@ namespace Xylem.ServiceFwUpdate.Ui.FwUpdateBuilder
{
_regUser.AccountActive = user.AccountActive;
_regUser.FullName = user.FullName;
_regUser.Id = user.Id;
break;
}