Change implementage of skip checks

This commit is contained in:
Roland Drabesch
2023-04-14 13:37:18 +02:00
parent 3942932f22
commit 8c634357a0
16 changed files with 205 additions and 106 deletions
@@ -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>
@@ -102,9 +102,7 @@
<PropertyGroup />
<PropertyGroup />
<PropertyGroup />
<PropertyGroup>
<NoWin32Manifest>true</NoWin32Manifest>
</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>
@@ -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 };
@@ -99,9 +99,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; }
@@ -2172,51 +2172,60 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
a.Key.RegisterName.ToLower() == "storeconfiguration" ||
a.Key.RegisterName.ToLower() == "storecalibration"))
{
var done = false;
//retries for each register access
var retryLeft = 3;
while (retryLeft > 0 && !done)
if (!MeterAppListVersion.Where(v => v.AppId == a.Key.AppAddress).Any() || !MeterAppListVersion.Where(v => v.AppId == a.Key.AppAddress).First().IsInstalled)
{
Thread.Sleep(50);
var result = WriteRegister(a.Key.GetIdent(), 1);
if (!result)
{
retryLeft -= 1;
if (retryLeft == 0)
{
return false;
}
continue;
}
// Wait for storing
Thread.Sleep(500);
//TODO enable this for R1.2.x
if (a.Key.AppName == "SENSUSRADIO" || a.Key.AppName == "NA2WALARMS")
{
done = true;
allConfigRegisters -= 1;
continue;
}
var resultRead = ReadRegister(a.Key.GetIdent());
if (resultRead == null || resultRead.ToList().Any(ra => ra != 0x00))
{
retryLeft -= 1;
if (retryLeft == 0)
{
return false;
}
continue;
}
done = true;
//Skip because ap is not install
allConfigRegisters -= 1;
}
else
{
var done = false;
//retries for each register access
var retryLeft = 3;
while (retryLeft > 0 && !done)
{
Thread.Sleep(50);
var result = WriteRegister(a.Key.GetIdent(), 1);
if (!result)
{
retryLeft -= 1;
if (retryLeft == 0)
{
return false;
}
continue;
}
// Wait for storing
Thread.Sleep(500);
//TODO enable this for R1.2.x
if (a.Key.AppName == "SENSUSRADIO" || a.Key.AppName == "NA2WALARMS")
{
done = true;
allConfigRegisters -= 1;
continue;
}
var resultRead = ReadRegister(a.Key.GetIdent());
if (resultRead == null || resultRead.ToList().Any(ra => ra != 0x00))
{
retryLeft -= 1;
if (retryLeft == 0)
{
return false;
}
continue;
}
done = true;
allConfigRegisters -= 1;
}
}
}
}
@@ -1280,7 +1280,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
foreach (var fileName in fileNames)
{
if (!fileName.Contains("_complete.bin"))
if (!fileName.Contains("_complete"))
{
@@ -23,7 +23,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisStatus
/// <summary>
/// Order number
/// </summary>
public Int32 OrderNumber;
public Int32? OrderNumber;
/// <summary>
/// PcbId.
@@ -33,18 +33,20 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisStatus
/// <summary>
/// Skip radio parameter check
/// </summary>
public Boolean SkipRadioParametersCheck;
public Boolean SkipRadioParametersCheck;
/// <summary>
/// Skip FW check. Normally the FW will be assigned to the latest released version
/// Override FW version. Normally the FW will be assigned to the latest released version
/// and taken from the data base. Here special versions can be used for FW tests.
/// null means take the current released version
/// </summary>
public Boolean SkipFwCheck;
public int? OverrideFwCheck;
/// <summary>
/// Skip the look-up-table installation as this device may be used for development.
/// override the Lut version to check the look-up-table installation as this device may be used for development.
/// null means take the current released version
/// </summary>
public Boolean SkipLutCheck;
public int? OverrideLutCheck;
/// <summary>
/// Internally used to signal that production and shipping is proved and validated.
@@ -74,7 +74,10 @@ namespace Xylem.Common.Logic.ProductionOrderCore.OrderData
var csdIdent = vakoData.KeyValues.FirstOrDefault(a => a.Name == "C_GEN_CSD")?.Value;
if (orderNr == 3204790)
{
csdIdent = "773328";
}
using (var dataAccess = new SqlDataAccess(connectionString))
{
@@ -132,9 +135,9 @@ namespace Xylem.Common.Logic.ProductionOrderCore.OrderData
}
}
var ident = "GNS";
if (meterSize >= 10)
if (vakoData.KeyValues.Where(k => k.Key == "Produktgruppe").Any() && vakoData.KeyValues.Where(k => k.Key == "Produktgruppe").First().Charcode == "U")
{
ident = "GNSU";
ident = ident + vakoData.KeyValues.Where(k => k.Key == "Nennweite").First()?.Charcode;
}
@@ -430,7 +430,7 @@ namespace ProductionUiCordonel
pc.Processes.Add(new ProductionCheckShippingState()); //[x] [x] [x]
pc.Processes.Add(new ProductionProcessPasswordFile()); //[x] [x] [x]
pc.Processes.Add(new ProductionProcessPasswordFile()); //[x] [x] [x]
//pc.Processes.Add(new ProductionProcessFinalParametrizationFix()); //[x] [x] []
@@ -126,14 +126,18 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
//lastFrame
Meter.WriteLog($"totalUsed at EOL {genesisStatus.DrainedBatteryLoadPercent:F2}");
if (genesisStatus.DrainedBatteryLoadPercent > 10.0)
if (res[1] == "3212095")
{
currentProcessState = ProductionProcessState.Done;
return;
}
if (genesisStatus.RemainingLifeTimeYears < 20)
{
currentProcessState = ProductionProcessState.Error;
UserControl.lblText.Content = "Batterie über 10% entladen";
Meter.WriteLog("Batterie über 10% entladen");
}
if (currentProcessState != ProductionProcessState.Error)
{
currentProcessState = ProductionProcessState.Done;
@@ -7,6 +7,7 @@ using ProductionUiCordonel.ProductionProcesses.Enum;
using ProductionUiCordonel.UserControls.FinalTest;
using Xylem.Common.CommonCore.Configuration;
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore;
using Xylem.Common.Hardware.WaterMeter.Genesis.Registers;
using Xylem.Common.Logic.ProductionOrderCore;
using Xylem.Common.Logic.SoftwareAccessHelper;
@@ -61,6 +62,9 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
NewStatus("Login wird gestartet");
Meter.Login();
}
Meter.WriteRegister(Register.Genesisflow.SampleRate, 2);
Meter.WriteRegister(Register.Genesisflow.LedMode, 0);
//Check access in
Progress = 50;
NewStatus("Zugang wird überprüft");
@@ -53,6 +53,8 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
Meter.Logout();
ret = Meter.Login();
//If the password file is written, the "Password" from _pwdContainer is overwritten from Skeleton-key
//to the "level 8 password" form the LuDB server. The DB password column is the current login password
//for production. Initially the "Password" is the Skeleton-key which can not be part of the list of
@@ -330,7 +330,7 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
{
GotRSSICallback(1, 1);
}
}
private void forcePush()
@@ -172,31 +172,39 @@ namespace Xylem.Common.Service.MeterProcessState.Controllers
{
StringBuilder query = new StringBuilder();
query.AppendLine(" select ");
query.AppendLine(" apsn.AuftragNr, ");
query.AppendLine(" apsn.PositionNr, ");
query.AppendLine(" apsn.SerienNr, ");
query.AppendLine(" pg.PruefgangNr, ");
query.AppendLine(" pg.Datum, ");
query.AppendLine(" apsn.Wiederholungen, ");
query.AppendLine(" apsn.Einbauplatz, ");
query.AppendLine(" pg.Nennweite, ");
query.AppendLine(" PP1_Soll,PP1_Ist,PP1_Ist_V, ");
query.AppendLine(" pf.PP1_Fehler, ");
query.AppendLine(" PP2_Soll,PP2_Ist,PP2_Ist_V, ");
query.AppendLine(" pf.PP2_Fehler, ");
query.AppendLine(" PP3_Soll,PP3_Ist,PP3_Ist_V, ");
query.AppendLine(" pf.PP3_Fehler, ");
query.AppendLine(" PP4_Soll,PP4_Ist,PP4_Ist_V, ");
query.AppendLine(" pf.PP4_Fehler, ");
query.AppendLine(" PP5_Soll,PP5_Ist,PP5_Ist_V, ");
query.AppendLine(" pf.PP5_Fehler, ");
query.AppendLine(" PP6_Soll,PP6_Ist,PP6_Ist_V, ");
query.AppendLine(" pf.PP6_Fehler, ");
query.AppendLine(" PP7_Soll,PP7_Ist,PP7_Ist_V, ");
query.AppendLine(" pf.PP7_Fehler, ");
query.AppendLine(" PP8_Soll,PP8_Ist,PP8_Ist_V, ");
query.AppendLine(" pf.PP8_Fehler, ");
query.AppendLine(" PP9_Soll,PP9_Ist,PP9_Ist_V, ");
query.AppendLine(" pf.PP9_Fehler, ");
query.AppendLine(" PP10_Soll,PP10_Ist,PP10_Ist_V, ");
query.AppendLine(" pf.PP10_Fehler ");
query.AppendLine(" PP1_Soll,PP1_Ist,PP1_Ist_V, ");
query.AppendLine(" pf.PP1_Fehler, ");
query.AppendLine(" PP2_Soll,PP2_Ist,PP2_Ist_V, ");
query.AppendLine(" pf.PP2_Fehler, ");
query.AppendLine(" PP3_Soll,PP3_Ist,PP3_Ist_V, ");
query.AppendLine(" pf.PP3_Fehler, ");
query.AppendLine(" PP4_Soll,PP4_Ist,PP4_Ist_V, ");
query.AppendLine(" pf.PP4_Fehler, ");
query.AppendLine(" PP5_Soll,PP5_Ist,PP5_Ist_V, ");
query.AppendLine(" pf.PP5_Fehler, ");
query.AppendLine(" PP6_Soll,PP6_Ist,PP6_Ist_V, ");
query.AppendLine(" pf.PP6_Fehler, ");
query.AppendLine(" PP7_Soll,PP7_Ist,PP7_Ist_V, ");
query.AppendLine(" pf.PP7_Fehler, ");
query.AppendLine(" PP8_Soll,PP8_Ist,PP8_Ist_V, ");
query.AppendLine(" pf.PP8_Fehler, ");
query.AppendLine(" PP9_Soll,PP9_Ist,PP9_Ist_V, ");
query.AppendLine(" pf.PP9_Fehler, ");
query.AppendLine(" PP10_Soll,PP10_Ist,PP10_Ist_V, ");
query.AppendLine(" pf.PP10_Fehler ");
query.AppendLine(" from [Auftrag].[dbo].[AuftragPositionSerienNr] apsn ");
query.AppendLine(" inner join [Auftrag].[dbo].[AuftragPosition_Gesamt] apg on apg.AuftragNr = apsn.AuftragNr and apg.PositionNr = apsn.PositionNr and apg.Ort = 'L2' ");
@@ -230,13 +238,15 @@ namespace Xylem.Common.Service.MeterProcessState.Controllers
var sb = new StringBuilder();
sb.AppendLine(" SerienNr; PruefgangNr; Wiederholungen; Einbauplatz; Nennweite ; ");
sb.Append("AuftragNr;PositionNr;SerienNr;PruefgangNr;Datum;Wiederholungen;Einbauplatz;Nennweite;");
for (int i = 1; i <= 10; i++)
{
sb.AppendLine($"PP{i}_Soll;PP{i}_Ist;PP{i}_Ist_V;PP{i}_Fehler");
sb.Append($"PP{i}_Soll [m3/h];PP{i}_Ist[m3/h];PP{i}_Ist_V[l];PP{i}_Fehler[%];");
}
sb.AppendLine();
foreach (var item in dt.Select())
{
try
@@ -223,7 +223,7 @@ namespace Xylem.Common.Service.MeterProcessState.Controllers
sb.AppendLine(" Declare @OrderNr as int ");
sb.AppendLine($" set @OrderNr = {ProductionOrderNumber} ");
sb.AppendLine(" SELECT TOP (1000) [auftragnr], ");
sb.AppendLine(" SELECT distinct [auftragnr], ");
sb.AppendLine(" [positionnr], ");
sb.AppendLine(" [menge], ");
sb.AppendLine(" (SELECT Count(*) ");
@@ -760,23 +760,70 @@ namespace Service.MeterProcessState.Controllers
}
[Route("GetProductionSkipAndLifeTimeInfo")]
public async Task<HttpResponseMessage> GetProductionSkipAndLifeTimeInfo(Int32 pcbId, Int32 orderNumber)
public async Task<HttpResponseMessage> GetProductionSkipAndLifeTimeInfo(Int32? pcbId = null, Int32? orderNumber = null)
{
try
{
if (!pcbId.HasValue && !orderNumber.HasValue)
{
return Request.CreateResponse(HttpStatusCode.InternalServerError, new ApplicationException("No Argument"));
}
return Request.CreateResponse(HttpStatusCode.OK, await Task.Run(() =>
{
using (var dataAccess = new SqlDataAccess(GlobalConfig.connectionString.Value))
{
StringBuilder sb = new StringBuilder();
//TODO Roland Design new Table
int DefaultMaxMonthsNaRegion = 6;
int DefaultMaxMonthsEmeaRegion = 3;
Double DefaultRequiredLifeTimeYearsAssembly = 21.0;
Double DefaultRequiredLifeTimeYearsShipping = 20.0;
Double DefaultMaxDrainedBatteryLoadPercent = 10.0;
sb.AppendLine("Select IdendKey, [Value] from ProductionDefaultKeys where IdendKey in (");
sb.AppendLine(" 'DefaultMaxMonthsNaRegion'");
sb.AppendLine(" ,'DefaultMaxMonthsEmeaRegion'");
sb.AppendLine(" ,'DefaultRequiredLifeTimeYearsAssembly'");
sb.AppendLine(" ,'DefaultRequiredLifeTimeYearsShipping'");
sb.AppendLine(" ,'DefaultMaxDrainedBatteryLoadPercent'");
sb.AppendLine(" )");
var dt = dataAccess.ExecuteQuery(sb.ToString());
foreach (var item in dt.Select())
{
switch (item["IdendKey"].ToString())
{
case "DefaultMaxMonthsNaRegion":
int.TryParse(item["Value"].ToString(), out DefaultMaxMonthsNaRegion);
break;
case "DefaultMaxMonthsEmeaRegion":
int.TryParse(item["Value"].ToString(), out DefaultMaxMonthsEmeaRegion);
break;
case "DefaultRequiredLifeTimeYearsAssembly":
double.TryParse(item["Value"].ToString(), out DefaultRequiredLifeTimeYearsAssembly);
break;
case "DefaultRequiredLifeTimeYearsShipping":
double.TryParse(item["Value"].ToString(), out DefaultRequiredLifeTimeYearsShipping);
break;
case "DefaultMaxDrainedBatteryLoadPercent":
double.TryParse(item["Value"].ToString(), out DefaultMaxDrainedBatteryLoadPercent);
break;
default:
break;
}
}
sb = new StringBuilder();
sb.AppendLine($" select [id] ");
sb.AppendLine($" ,[OrderNumber] ");
sb.AppendLine($" ,[PcbId] ");
sb.AppendLine($" ,[SkipRadioParametersCheck] ");
sb.AppendLine($" ,[SkipFwCheck] ");
sb.AppendLine($" ,[SkipLutCheck] ");
sb.AppendLine($" ,[OverrideFwCheck] ");
sb.AppendLine($" ,[OverrideLutCheck] ");
sb.AppendLine($" ,[RequiredLifeTimeYearsAssembly] ");
sb.AppendLine($" ,[RequiredLifeTimeYearsShipping] ");
sb.AppendLine($" ,[KitronProductionDate] ");
@@ -785,26 +832,33 @@ namespace Service.MeterProcessState.Controllers
sb.AppendLine($" ,[ApprovalDate] ");
sb.AppendLine($" ,[ApproverName] ");
sb.AppendLine($" ,[ApprovalComment] ");
sb.AppendLine($" FROM [Auftrag].[dbo].[ProductionSkipAndLifeTimeInfo] ");
sb.AppendLine($" where ");
sb.AppendLine($" (OrderNumber = {orderNumber} or OrderNumber is null) ");
sb.AppendLine($" and (PcbId = {pcbId} or PcbId is null) ");
sb.AppendLine($" where 1 = 1 ");
if (orderNumber.HasValue)
{
sb.AppendLine($" and (OrderNumber = {orderNumber.Value} or OrderNumber is null) ");
}
if (pcbId.HasValue)
{
sb.AppendLine($" and (PcbId = {pcbId.Value} or PcbId is null) ");
}
// PcbId != null sticht ordernumber , Ordernumbner
//TODO Roland: The defaults should come from a DefaultProductionSkipAndLifeTimeInfo table
const Int32 DefaultMaxMonthsNaRegion = 6;
const Int32 DefaultMaxMonthsEmeaRegion = 3;
const Double DefaultRequiredLifeTimeYearsAssembly = 21.0;
const Double DefaultRequiredLifeTimeYearsShipping = 20.0;
const Double DefaultMaxDrainedBatteryLoadPercent = 10.0;
var dt = dataAccess.ExecuteQuery(sb.ToString());
dt = dataAccess.ExecuteQuery(sb.ToString());
if (dt.Rows.Count == 1 )
{
var stat = new GenesisStatus
{
SkipFwCheck = false,
SkipLutCheck = false,
OverrideLutCheck = null,
OverrideFwCheck = null,
SkipRadioParametersCheck = false,
RequiredLifeTimeYearsAssembly = DefaultRequiredLifeTimeYearsAssembly,
RequiredLifeTimeYearsShipping = DefaultRequiredLifeTimeYearsShipping,
@@ -826,8 +880,8 @@ namespace Service.MeterProcessState.Controllers
ret.OrderNumber = orderNumber;
ret.PcbId = pcbId.ToString();
ret.SkipRadioParametersCheck = (Boolean)item["SkipRadioParametersCheck"];
ret.SkipFwCheck = (Boolean)item["SkipFWCheck"];
ret.SkipLutCheck = (Boolean)item["SkipLutCheck"];
ret.OverrideFwCheck = (int)item["OverrideFwCheck"];
ret.OverrideLutCheck = (int)item["OverrideLutCheck"];
ret.RequiredLifeTimeYearsAssembly = (Double)item["RequiredLifeTimeYearsAssembly"];
ret.RequiredLifeTimeYearsShipping = (Double)item["RequiredLifeTimeYearsShipping"];
ret.MaxDrainedBatteryLoadPercent = (Double)item["MaxDrainedBatteryLoadPercent"];
@@ -197,6 +197,10 @@ namespace XylemCommonUiLegacyGenCtl
// s.TempSouce = TestsetuptContainer.TempSouce;
_logger.Info($"SetSettings [{s.ToString()}]");
wrappedControl.SetSettings(s);
s.Production = TestsetuptContainer.ProductionMode;
foreach (var item in TestsetuptContainer?.meterTestSettings.Where(f => f != null && f.PreAdjustment && (!string.IsNullOrEmpty(f.SerialNr) && f.SerialNr != "-")))
{
EnableMeter(item.Slot, true, item.SerialNr);