stichproben meter process state

This commit is contained in:
Stoyan Zlatev 2025-02-05 10:10:04 +01:00
parent e1bf863f8b
commit 9e2f9b18bd
10 changed files with 156 additions and 116 deletions

View File

@ -63,6 +63,10 @@
<Project>{4E8BB839-D40A-488C-88CE-F21811F1F476}</Project>
<Name>Common.Hardware.WaterMeter.eRegister</Name>
</ProjectReference>
<ProjectReference Include="..\Stichproben\Stichproben.csproj">
<Project>{F69A79FA-548D-4E21-887E-01FABDAD9E73}</Project>
<Name>Stichproben</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@ -3,6 +3,8 @@
using Common.Hardware.WaterMeter.eRegister.Features;
using Common.Hardware.WaterMeter.eRegister.Models;
using Stichproben.Cordonel;
using System;
using System.Collections.Generic;
using System.Reflection;
@ -10,6 +12,14 @@
public static class Program
{
public static void Main()
{
var stichproben = new Stichproben(typeof(Program).Assembly.Location);
stichproben.ShouldBePressureTested(123);
}
public static void ___Main()
{
var features = new List<EregisterFeature>();

View File

@ -16,6 +16,7 @@ namespace CordonelAssemblyLine
public Leak(CancellationToken globalCancellationToken, Int32 slotNR, Int32? stationID = null, String Tester= "-")
{
InitializeComponent();
ViewModel = new LeakViewModel(slotNR, stationID);
ViewModel.TesterName = Tester;
DataContext = ViewModel;
@ -33,12 +34,6 @@ namespace CordonelAssemblyLine
private void BtnPresueOk_Click(Object sender, RoutedEventArgs e)
{
var ret = ViewModel.StoreData(true);
if (ret && int.TryParse($"{ViewModel?.CurrentPcbID}", out var pcbId))
{
ShouldBePressureTestedModal.Check(pcbId);
MessageBox.Show("Ergebnis gespeichert der Zähler weiterbearbeitet werden.");
}
}
private void LockForPressureTest()

View File

@ -18,6 +18,7 @@ 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 Stichproben.Cordonel;
namespace CordonelAssemblyLine.Model
{
@ -132,6 +133,7 @@ namespace CordonelAssemblyLine.Model
private Timer tmrAutoDetect;
private readonly Stichproben.Cordonel.Stichproben stichproben;
public LeakViewModel(Int32 slotNR, Int32? stationID = null)
{
@ -149,7 +151,7 @@ namespace CordonelAssemblyLine.Model
$"2*10^-7 { System.Environment.NewLine} " +
"0,0000002";
this.stichproben = new Stichproben.Cordonel.Stichproben(typeof(LeakViewModel).Assembly.Location);
}
public Boolean isHydraulicStaion()
@ -361,9 +363,9 @@ namespace CordonelAssemblyLine.Model
{
status = DisplayCodes.PressureTested;
}
try
{
url = url + $"SetPressureStateDetailed";
var mutedResult = Result.ToBase();
@ -375,10 +377,30 @@ namespace CordonelAssemblyLine.Model
status = DisplayCodes.PressureTestedFailed;
}
if (int.TryParse($"{this.CurrentPcbID}", out var pcbId))
{
CurrentMeter.Login();
var result = this.stichproben.ShouldBePressureTested(pcbId);
if (result.ShouldBePressureTested)
{
CurrentMeter.SetProcessState(DisplayCodes.PressureTestedPending);
OnStoreDone?.Invoke(null, new StringPressureArgs($"Stichproben regel - {result.Rule}% von {result.Count} Stk. Dieser Zähler muss zur Druckprüfung!", false));
}
else
{
CurrentMeter.SetProcessState(status);
OnStoreDone?.Invoke(null, new StringPressureArgs("Ergebnis gespeichert der Zähler kann weiterbearbeitet werden. Dieser Zähler muss NICHT zur Druckprüfung", false));
}
CurrentMeter.Login();
CurrentMeter.SetProcessState(status);
return true;
}
else
{
OnStoreDone?.Invoke(null, new StringPressureArgs($"Kann nicht {this.CurrentPcbID} in nummer konvertieren.", false));
return false;
}
}
catch (Exception ex)
{
@ -387,25 +409,11 @@ namespace CordonelAssemblyLine.Model
OnStoreDone?.Invoke(null, new StringPressureArgs($"Kann nicht gespeichert werden.Fehler: {ex.Message}",false));
}
// Wird von die Stichproben prüfung übernohmen
if (status == DisplayCodes.PressureTested)
{
if (isStored.Contains("0"))
{
OnStoreDone?.Invoke(null, new StringPressureArgs("Ergebnis gespeichert der Zähler weiterbearbeitet werden. Dieser Zähler muss NICHT zur Druckprüfung", false));
return false;
}
else
{
return true;
}
}
OnStoreDone?.Invoke(null, new StringPressureArgs("Bitte erneut testen oder Linienleitung und QS informieren.", true));
return false;
});
}
return false;
}

View File

@ -51,7 +51,7 @@
this.RuleText = $"{result.Rule}% von {result.Count} Stk.";
return result.ShouldBeTested;
return result.ShouldBePressureTested;
}
}
}

View File

@ -19,69 +19,72 @@
//Production process
//assembly line
//Picking
/// <summary>
/// Picking in progress
/// </summary>
PickingStarted = 0x7700,
/// <summary>
/// Picking succeeded, next step can be initiated
/// </summary>
PickingTested = 0x7777,
/// <summary>
/// Picking failed
/// </summary>
PickingFailed = 0xFF77,
//assembly line
//Picking
/// <summary>
/// Picking in progress
/// </summary>
PickingStarted = 0x7700,
/// <summary>
/// Picking succeeded, next step can be initiated
/// </summary>
PickingTested = 0x7777,
/// <summary>
/// Picking failed
/// </summary>
PickingFailed = 0xFF77,
//Pressure
/// <summary>
/// Pressure testing succeeded, next step can be initiated
/// </summary>
PressureTested = 0x1111,
/// <summary>
/// Pressure test failed
/// </summary>
PressureTestedFailed = 0xFF11,
//Pressure
/// <summary>
/// Pressure testing succeeded, next step can be initiated
/// </summary>
PressureTested = 0x1111,
/// <summary>
/// Pressure test failed
/// </summary>
PressureTestedFailed = 0xFF11,
/// <summary>
/// Pressure test failed
/// </summary>
PressureTestedPending = 0x0011,
//Marriage
/// <summary>
/// Connection between PCBID, Serial Number and Order number done
/// </summary>
Mounted = 0x2222,
//Marriage
/// <summary>
/// Connection between PCBID, Serial Number and Order number done
/// </summary>
Mounted = 0x2222,
//Test bench
/// <summary>
/// Zero flow test succeeded, next step can be initiated
/// </summary>
ZeroFlow = 0x3333,
/// <summary>
/// Zero flow test failed
/// </summary>
ZeroFlowFailed = 0xFF33,
/// <summary>
/// Flow calibration succeeded, next step can be initiated
/// </summary>
FlowCalibrated = 0x4444,
/// <summary>
/// Flow calibration failed
/// </summary>
FlowCalibrationOurOfRange = 0xFF44,
/// <summary>
/// Flow test succeeded, next step can be initiated
/// </summary>
FlowTested = 0x5555,
/// <summary>
/// Flow test failed
/// </summary>
FlowTestFailed = 0xFF55,
//Test bench
/// <summary>
/// Zero flow test succeeded, next step can be initiated
/// </summary>
ZeroFlow = 0x3333,
/// <summary>
/// Zero flow test failed
/// </summary>
ZeroFlowFailed = 0xFF33,
/// <summary>
/// Flow calibration succeeded, next step can be initiated
/// </summary>
FlowCalibrated = 0x4444,
/// <summary>
/// Flow calibration failed
/// </summary>
FlowCalibrationOurOfRange = 0xFF44,
/// <summary>
/// Flow test succeeded, next step can be initiated
/// </summary>
FlowTested = 0x5555,
/// <summary>
/// Flow test failed
/// </summary>
FlowTestFailed = 0xFF55,
//End of line / final test
/// <summary>
/// Final test failed, else the display will be switched to operational mode,
/// showing the actual accumulated volume
/// </summary>
FinalTestFailed = 0xFF66,
//End of line / final test
/// <summary>
/// Final test failed, else the display will be switched to operational mode,
/// showing the actual accumulated volume
/// </summary>
FinalTestFailed = 0xFF66,
//FWUpdate
/// <summary>

View File

@ -12,6 +12,6 @@
public bool IstStichprobe { get; set; }
public bool IstDicht { get; set; }
public bool? IstDicht { get; set; }
}
}

View File

@ -4,7 +4,7 @@
{
internal StichprobeResult(bool shouldBeTested, int number, int rule, int count)
{
this.ShouldBeTested = shouldBeTested;
this.ShouldBePressureTested = shouldBeTested;
this.Rule = rule;
this.Number = number;
this.Count = count;
@ -16,6 +16,6 @@
public int Number { get; }
public bool ShouldBeTested { get; }
public bool ShouldBePressureTested { get; }
}
}

View File

@ -8,20 +8,15 @@
public Stichproben(string assemblyLocation)
{
this.stichprobenRules = new StichprobenRules(assemblyLocation);
this.stichprobenDb = new StichprobenDbContext("Server=SLASQL01.emea.sensus.net; Database=Auftrag; User ID=sa; Password=sqlserver;"/*TODO: assemblyLocation*/);
this.stichprobenDb = new StichprobenDbContext("Server=SLASQL01.emea.sensus.net; Database=Auftrag; User ID=sa; Password=sqlserver;");
}
public StichprobeResult ShouldBePressureTested(int pcbId)
{
var isAnyUndicht = this.stichprobenDb.IsAnyUndicht();
var previousStichprobe = this.stichprobenDb.GetLastOrDefault();
bool? pressureTestPassed = true;
if (previousStichprobe != null)
{
pressureTestPassed = this.stichprobenDb.PressureTestPassed(pcbId);
this.stichprobenDb.SetPressureTestPassed(previousStichprobe.Id, pressureTestPassed ?? false);
}
else
if (previousStichprobe is null)
{
previousStichprobe = new Stichprobe();
}
@ -32,7 +27,7 @@
PcbId = pcbId
};
if (pressureTestPassed != false)
if (isAnyUndicht == false)
{
stichprobenRule = this.stichprobenRules.FindRuleOrMin(previousStichprobe.Prozentsatz);

View File

@ -3,19 +3,14 @@
using LaaPackages.SqlClient;
using System;
using System.Linq;
internal class StichprobenDbContext
{
private readonly SqlConnection sqlConnection;
public StichprobenDbContext(string connectionString/*string assemblyLocation*/)
public StichprobenDbContext(string connectionString)
{
//TODO: Get connection string from the config
//var connectionString = ConfigurationManager
// .OpenExeConfiguration(assemblyLocation)
// .ConnectionStrings
// .ConnectionStrings["auftrag"]
// .ConnectionString;
this.sqlConnection = SqlConnection.CreateSqlConnection(connectionString, error =>
{
Console.WriteLine(error);
@ -58,10 +53,10 @@
Nummer = x.GetValue<int>(2),
Prozentsatz = x.GetValue<int>(3),
IstStichprobe = x.GetValue<bool>(4),
IstDicht = x.GetValue<bool>(5),
IstDicht = x.GetValue<bool?>(5),
});
public void SetPressureTestPassed(int id, bool pressureTestPassed)
public void SetPressureTestPassed(int id, bool? pressureTestPassed)
=> this.sqlConnection
.CreateCommand($@"
UPDATE Stichproben
@ -71,14 +66,44 @@
.SetParameter(nameof(id), id)
.ExecuteNonQuery();
public bool? PressureTestPassed(int pcbId)
=> this.sqlConnection
.CreateCommand($@"
SELECT TOP 1 Dicht
FROM Druckpruefung
WHERE FabNr = @{nameof(pcbId)}
ORDER BY Pruefgang DESC")
.SetParameter(nameof(pcbId), pcbId)
.FirstOrDefault(x => x.GetValue<bool?>(0));
public bool IsAnyUndicht()
{
var missingResults = this.sqlConnection
.CreateCommand($@"
UPDATE Stichproben
SET IstDicht = d.Dicht
OUTPUT inserted.IstDicht
FROM Stichproben AS s
LEFT JOIN Druckpruefung AS d
ON s.PcbId = d.FabNr
WHERE s.IstDicht IS NULL")
.ExecuteReader(x => x.GetValue<bool?>(0));
return missingResults?.Any(x => x == false) ?? false;
}
//public bool? PressureTestPassed(int pcbId)
//{
// var missingResults = this.sqlConnection
// .CreateCommand($@"
// UPDATE Stichproben
// SET IstDicht = d.Dicht
// OUTPUT inserted.IstDicht
// FROM Stichproben AS s
// LEFT JOIN Druckpruefung AS d
// ON s.PcbId = d.FabNr
// WHERE s.IstDicht IS NULL")
// .SetParameter(nameof(pcbId), pcbId)
// .ExecuteReader(x => x.GetValue<bool?>(0));
// return this.sqlConnection
// .CreateCommand($@"
// SELECT TOP 1 Dicht
// FROM Druckpruefung
// WHERE FabNr = @{nameof(pcbId)}
// ORDER BY Pruefgang DESC")
// .SetParameter(nameof(pcbId), pcbId)
// .FirstOrDefault(x => x.GetValue<bool?>(0));
//}
}
}