This commit is contained in:
Stoyan Zlatev
2025-04-10 14:58:48 +02:00
9 changed files with 92 additions and 45 deletions
+1 -1
View File
@@ -14,4 +14,4 @@ using System.Reflection;
//[assembly: AssemblyVersion("1.2.*.0")]
[assembly: AssemblyVersion("2.6.15.*")]
[assembly: AssemblyVersion("2.6.16.*")]
@@ -155,7 +155,7 @@
</site>
<site name="MeterProcessState" id="2">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\Users\drabesch_ro\Repo\lab\la_operations\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" />
@@ -1 +1 @@
89102b0142e574de38a9f47d370f3334e5e6c268
8cb55c312de586b683d72cf58c13e2801d10e14b767777d98338d3e1473a1213
@@ -74,7 +74,7 @@ namespace Xylem.Common.Production.ProductionUiCordonel
{
msg = $"{Properties.Resources.StrStartMessageSwLicenseExpired} {_version}";
_logger.Error(msg);
MessageBox.Show(msg, Properties.Resources.StrProcessStateError,
MessageBox.Show(msg, Properties.Resources.StrProcessStateError,
MessageBoxButton.OK, MessageBoxImage.Error);
Close();
return;
@@ -82,7 +82,7 @@ namespace Xylem.Common.Production.ProductionUiCordonel
}
catch (Exception e)
{
msg = Properties.Resources.StrErrorMsgMissingNetworkConnetction + " " + e.Message ;
msg = Properties.Resources.StrErrorMsgMissingNetworkConnetction + " " + e.Message;
_logger.Error(msg);
MessageBox.Show(msg,
Properties.Resources.StrProcessStateError,
@@ -377,6 +377,9 @@ namespace Xylem.Common.Production.ProductionUiCordonel
/// <remarks date="2024-Aug-30" author="Thomas Wiedebusch">
/// - Extended.
/// </remarks>
/// <remarks date="2025-Apr-10" author="Thomas Wiedebusch">
/// - Extended.
/// </remarks>
private void ProcessStateChange_Handler(Object sender, ProcessStateArgs e)
{
_logger.Debug($"Slot:{Slot} - Final test state: {e.State}");
@@ -426,7 +429,8 @@ namespace Xylem.Common.Production.ProductionUiCordonel
// Ready for shipping
if (e.State == ProcessState.ReadyForShipping)
{
StoreSuccessNote(out _);
// Create extended report including all steps and each register write, read and comparison
CreateFile(Properties.Resources.StrInfoSuccessPapers);
BtnStop_Click(this, null);
}
// Print return report
@@ -802,38 +806,30 @@ namespace Xylem.Common.Production.ProductionUiCordonel
private void PrintErrorNote()
{
var sb = new StringBuilder();
sb.AppendLine("========================================================================");
sb.AppendLine(Properties.Resources.StrInstructionReturnPapers);
sb.AppendLine("========================================================================");
CreateFile(sb, out var fileName);
Process.Start(fileName);
}
private void StoreSuccessNote(out String fileName)
{
var sb = new StringBuilder();
sb.AppendLine("========================================================================");
sb.AppendLine(Properties.Resources.StrInfoSuccessPapers);
sb.AppendLine("========================================================================");
CreateFile(sb, out fileName);
// Safe report to file
CreateFile(Properties.Resources.StrInstructionReturnPapers, true, true);
}
private void PrintSuccessNote()
{
StoreSuccessNote(out var fileName);
Process.Start(fileName);
// Safe report to file
CreateFile(Properties.Resources.StrInfoSuccessPapers, true, true);
}
private void CreateFile(StringBuilder sb, out String fileName)
/// <summary>
/// Logging a file with all process information, building a compressed report for printout.
/// </summary>
/// <remarks date="2025-Apr-10" author="Thomas Wiedebusch">
/// - Reduced printout.
/// </remarks>
private void CreateFile(String headerInfo, Boolean shortReport = false, Boolean printReport = false)
{
if (sb == null)
sb = new StringBuilder();
var sb = new StringBuilder();
var genesisMeter = _processCtrl.GetGenesisMeter();
var loggingPath = $"C:\\GenesisLog\\{DateTime.Now:yyyy-MM-dd}\\ProductionUiCordonel\\";
fileName = $"{loggingPath}{DateTime.Now.ToString("yyyyMMddHHmmss")}_Report_{genesisMeter.PcbId}.txt";
sb.AppendLine("========================================================================");
sb.AppendLine(headerInfo);
sb.AppendLine("========================================================================");
sb.AppendLine(_strSoftwareNameVersion);
sb.AppendLine("------------------------------------------------------------------------");
sb.AppendLine($"{Properties.Resources.StrDateTime}: {DateTime.Now}");
@@ -843,12 +839,50 @@ namespace Xylem.Common.Production.ProductionUiCordonel
sb.AppendLine($"{Properties.Resources.StrLblSerialNumberTxt}: {genesisMeter.CustomerSerialNumber}");
sb.AppendLine($"{Properties.Resources.StrLblOperatorNameText}: {Software.UserName}");
sb.AppendLine("------------------------------------------------------------------------");
//TODO THW take the log path from setup (done with GTB)
var loggingPath = $"C:\\GenesisLog\\{DateTime.Now:yyyy-MM-dd}\\ProductionUiCordonel\\";
var fileName = $"{loggingPath}{DateTime.Now.ToString("yyyyMMddHHmmss")}_ExtendedReport_{genesisMeter.PcbId}.txt";
// Copy the header to the compressed string builder
var compressedSb = new StringBuilder();
if (shortReport)
{
compressedSb.Append(sb);
}
var rtbText = new TextRange(
rtbLog.Document.ContentStart,
rtbLog.Document.ContentEnd
);
sb.Append($"{rtbText.Text}");
// Write the complete report to the file
File.WriteAllText(fileName, sb.ToString());
// Reduce sb content to compress it for printout
if (shortReport)
{
fileName = $"{loggingPath}{DateTime.Now.ToString("yyyyMMddHHmmss")}" +
$"_ShortReport_{genesisMeter.PcbId}.txt";
var sr = new StringReader(rtbText.Text);
var srLine = sr.ReadLine();
while (srLine != null)
{
if (srLine.Contains(Properties.Resources.StrProcessStateError) ||
srLine.Contains(Properties.Resources.StrProcessStateDone) ||
srLine.Contains(Properties.Resources.StrProcessStateWarning) ||
srLine.Contains(Properties.Resources.StrProcessStateSkipped) ||
srLine.Contains(Properties.Resources.StrWarningMsgSpecialRequirementActive))
compressedSb.AppendLine(srLine);
srLine = sr.ReadLine();
}
// Returns the compressed file for error report printout
File.WriteAllText(fileName, compressedSb.ToString());
if (printReport)
Process.Start(fileName);
}
}
/// <summary>
@@ -111,24 +111,25 @@ namespace Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses.EolPr
// Exit if meanwhile cancellation is required
if (CancellationToken.IsCancellationRequested)
return CancellationProcedure();
ActualProcessProgress++;
}
if (!eolTriggerReturn)
{
if (!string.IsNullOrEmpty(error))
Meter.WriteLog(error);
foreach (var feed in feedback)
{
ErrorMsgDispatcher(Resources.StrErrorMsgSentinelConcerns + " " +
feed.Key + ": " + feed.Value);
}
if (feedback != null)
foreach (var feed in feedback)
{
ErrorMsgDispatcher(Resources.StrErrorMsgSentinelConcerns + " " +
feed.Key + ": " + feed.Value);
}
ErrorMsgDispatcher(Resources.StrErrorMsgSentinelCheckEolProgress);
return StatusReturn.Failed;
}
SuccessMsgDispatcher(Resources.StrSuccessMsgSentinelCheckEolProgress);
ActualProcessProgress++;
@@ -154,7 +155,7 @@ namespace Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses.EolPr
ActualProcessProgress = MaxActualProgressSteps;
SetOverallProcessTo100Percent();
while (_waitOnUserFeedback && SingleProcessState != SingleProcessState.Idle)
{
}
@@ -164,7 +165,7 @@ namespace Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses.EolPr
}
catch (Exception e)
{
ErrorMsgDispatcher( e.Message);
ErrorMsgDispatcher(e.Message);
return StatusReturn.Failed;
}
}
@@ -363,10 +363,15 @@ namespace Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses
break;
case ProcessState.DetectCordonel:
// Reset the cancellation request
_cancellationTokenSource?.Dispose();
_cancellationTokenSource = new CancellationTokenSource();
_cancellationToken = _cancellationTokenSource.Token;
// Wait for cancellation
if (_cancellationToken.IsCancellationRequested)
{
Thread.Sleep(1000);
// Reset the cancellation request
_cancellationTokenSource?.Dispose();
_cancellationTokenSource = new CancellationTokenSource();
_cancellationToken = _cancellationTokenSource.Token;
}
// Set up the counter for maximum overall process progress bar in GUI
CalcAndPushMaxOverAllProcessSteps();
@@ -572,6 +577,7 @@ namespace Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses
/// Clears all collected data on new genesisMeter and reminds the detected for next
/// detection and run of this comparison.
/// </summary>
/// <returns>true for new meter</returns>
/// <remarks date="2023-Jun-28" author="Thomas Wiedebusch">
/// - Initial
/// </remarks>
@@ -582,7 +588,6 @@ namespace Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses
/// <remarks date="2024-Jul-15" author="Thomas Wiedebusch">
/// - Handle genesis meter is null as new meter.
/// </remarks>
/// <returns>true for new meter</returns>
private Boolean CheckForNewMeter()
{
if (_genesisMeter == null ||
@@ -857,10 +862,14 @@ namespace Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses
/// Check all processes for error or abort request
/// </summary>
/// <returns>true if abort required</returns>
/// <remarks date="2025-Apr-10" author="Thomas Wiedebusch">
/// - Cancellation token.
/// </remarks>
private Boolean AnyProcessRequiresAbortion()
{
return Processes.Any(pp => pp.SingleProcessState == SingleProcessState.Error ||
pp.SingleProcessState == SingleProcessState.Abort);
pp.SingleProcessState == SingleProcessState.Abort ||
_cancellationToken.IsCancellationRequested);
}
/// <summary>
/// Check process if in status waiting or running (incomplete)
@@ -944,6 +953,9 @@ namespace Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses
/// <remarks date="2025-Feb-13" author="Thomas Wiedebusch">
/// - Abort register access.
/// </remarks>
/// <remarks date="2025-Apr-07" author="Thomas Wiedebusch">
/// - Cancellation token source.
/// </remarks>
private void KillProcesses()
{
_cancellationTokenSource?.Cancel();