(1) TBF.Screens.ResultsTabPageCtrl fixes, (2) Results.Forms.BatchResultsDlg fixes : Show previous results displays colors, ver. 2.18.1167

This commit is contained in:
Milan Hanajik 2019-03-14 08:16:44 +01:00
parent 26d49eb4b7
commit e7164b98ff
9 changed files with 282 additions and 103 deletions

View File

@ -16,6 +16,16 @@ namespace Results.Forms
{
static readonly ILog log = LogManager.GetLogger(typeof(BatchResultsDlg));
static readonly Color NotCompletedColor = Color.White;
static readonly Color OkColor = Color.LightGreen;
static readonly Color NokColor = Color.LightPink;
static readonly Color RejectColor = Color.Magenta;
static readonly Color ProductionTracing = Color.RoyalBlue;
static readonly Color WrongDirection = Color.Gold;
static readonly Color WrongQ2FactorsColor = Color.Red;
DateTime lastRedraw;
DateTime lastSizeChange;
bool loaded;
@ -178,14 +188,16 @@ namespace Results.Forms
this.ResumeLayout(false);
}
/// <summary>
/// Get an empty ListView control with appropriate parameters.
/// </summary>
/// <returns>ListView control</returns>
OneWMResultsCtrl GetListView()
OneWMResultsCtrl GetListView(Color backColor)
{
return new OneWMResultsCtrl(Color.White, lvWidth, lvHeight);
return new OneWMResultsCtrl(backColor, lvWidth, lvHeight);
}
OneWMResultsCtrl GetListView() { return GetListView(Color.White); }
/// <summary>
@ -199,8 +211,10 @@ namespace Results.Forms
foreach (var mtr in wMtr.MeterTestRslts)
{
if (mtr.IsPilotRslt() && mtr.TestDone && (mtr.Publish() != Config.Entities.Publish.Never)
&& (mtr.Publish() != Config.Entities.Publish.Internal))
if ((mtr.CompoundMeterId == (byte)CompoundMeterId.Single || mtr.CompoundMeterId == (byte)CompoundMeterId.Compound || mtr.CompoundMeterId == (byte)CompoundMeterId.HeatMeterEnergy)
&& mtr.TestDone
&& (mtr.Publish() != Config.Entities.Publish.Never)
&& (mtr.Publish() != Config.Entities.Publish.Internal))
{
testNames.Add(mtr.Name());
}
@ -209,6 +223,57 @@ namespace Results.Forms
return testNames;
}
/// <summary>
/// Get color for highlighting results and an apporpriate text message.
/// </summary>
/// <param name="wMtr">Water meter results entity</param>
/// <param name="message">Appropriate message</param>
/// <returns>Color for results</returns>
Color GetColorOfResults(Results.Entities.WaterMeter wMtr, out string message)
{
bool wmtrCompleted = wMtr.CompletedFromTests();
bool wmtrPassed = wMtr.PassedFromTests();
if ((wMtr.ErrorFlags & (int)ErrorFlagMask.E28) != 0)
{
message = Strings.Previous_step_is_missing_or_NOK;
return ProductionTracing;
}
else if ((wMtr.ErrorFlags & (int)ErrorFlagMask.E27) != 0)
{
message = Strings.Wrong_iPerl_counting_direction;
return WrongDirection;
}
else if ((wMtr.ErrorFlags & (int)ErrorFlagMask.E26) != 0)
{
message = Strings.Invalid_Q2_correction_factors;
return WrongQ2FactorsColor;
}
else if ((wMtr.ErrorFlags & (int)ErrorFlagMask.E25) != 0)
{
message = Strings.Test_repetition_count_exceeded_upper_limit;
return RejectColor;
}
else if (wmtrPassed)
{
/// Water meter passed (therefore is was also completed)
message = Strings.Passed;
return OkColor;
}
else if (wmtrCompleted)
{
/// Water meter was completed but did not pass => Failed
message = Strings.Failed;
return NokColor;
}
else
{
/// Water meter was not completed yet => did not pass, did not fail
message = Strings.Test_in_progress;
return NotCompletedColor;
}
}
/// <summary>
/// Get a ListView control filled with results of the meter 'mtr'
@ -219,9 +284,11 @@ namespace Results.Forms
{
metersKind = wMtr.Compound() ? MetersKind.Combined : (wMtr.HeatMeter() ? MetersKind.HeatMeter : MetersKind.Single);
OneWMResultsCtrl lview = GetListView();
string message = string.Empty;
Color commonBackColor = GetColorOfResults(wMtr, out message);
OneWMResultsCtrl lview = GetListView(commonBackColor);
#if ORACLE_DB
lview.Caption = string.Format("PCB {0} {1} {2}", (string.IsNullOrEmpty(wMtr.SerialNr) ? string.Empty : wMtr.SerialNr), Strings.repetition, (wMtr.Pruefindex % 100));
lview.Caption = string.Format("{0} ({1}) {2}", (string.IsNullOrEmpty(wMtr.SerialNr) ? string.Empty : wMtr.SerialNr), (wMtr.Pruefindex % 100), message);
#else
lview.Caption = string.Format("s/n = {0}", string.IsNullOrEmpty(wMtr.SerialNr) ? string.Empty : wMtr.SerialNr);
#endif
@ -289,9 +356,11 @@ namespace Results.Forms
{
metersKind = wMtr.Compound() ? MetersKind.Combined : (wMtr.HeatMeter() ? MetersKind.HeatMeter : MetersKind.Single);
OneWMResultsCtrl lview = GetListView();
string message;
Color commonBackColor = GetColorOfResults(wMtr, out message);
OneWMResultsCtrl lview = GetListView(commonBackColor);
#if ORACLE_DB
lview.Caption = string.Format("PCB {0} {1} {2}", (string.IsNullOrEmpty(wMtr.SerialNr) ? string.Empty : wMtr.SerialNr), Strings.repetition, (wMtr.Pruefindex % 100));
lview.Caption = string.Format("{0} ({1}) {2}", (string.IsNullOrEmpty(wMtr.SerialNr) ? string.Empty : wMtr.SerialNr), (wMtr.Pruefindex % 100), message);
#else
lview.Caption = string.Format("s/n = {0}", string.IsNullOrEmpty(wMtr.SerialNr) ? string.Empty : wMtr.SerialNr);
#endif

View File

@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// 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("2.18.1162.0")]
[assembly: AssemblyFileVersion("2.18.1162.0")]
[assembly: AssemblyVersion("2.18.1166.0")]
[assembly: AssemblyFileVersion("2.18.1166.0")]

View File

@ -384,6 +384,15 @@ namespace Results.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to NOK.
/// </summary>
internal static string Failed {
get {
return ResourceManager.GetString("Failed", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Failed meters count.
/// </summary>
@ -447,6 +456,15 @@ namespace Results.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Invalid Q2 correction factors.
/// </summary>
internal static string Invalid_Q2_correction_factors {
get {
return ResourceManager.GetString("Invalid_Q2_correction_factors", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Item.
/// </summary>
@ -627,6 +645,15 @@ namespace Results.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to OK.
/// </summary>
internal static string Passed {
get {
return ResourceManager.GetString("Passed", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Passed meters count.
/// </summary>
@ -663,6 +690,15 @@ namespace Results.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Previous step is missing or NOK.
/// </summary>
internal static string Previous_step_is_missing_or_NOK {
get {
return ResourceManager.GetString("Previous_step_is_missing_or_NOK", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Procedure.
/// </summary>
@ -1032,6 +1068,15 @@ namespace Results.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Test in progress.
/// </summary>
internal static string Test_in_progress {
get {
return ResourceManager.GetString("Test_in_progress", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Test method.
/// </summary>
@ -1050,6 +1095,15 @@ namespace Results.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Test repetition count exceeded upper limit.
/// </summary>
internal static string Test_repetition_count_exceeded_upper_limit {
get {
return ResourceManager.GetString("Test_repetition_count_exceeded_upper_limit", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Test vol..
/// </summary>
@ -1923,6 +1977,15 @@ namespace Results.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Wrong iPerl counting direction.
/// </summary>
internal static string Wrong_iPerl_counting_direction {
get {
return ResourceManager.GetString("Wrong_iPerl_counting_direction", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Year.
/// </summary>

View File

@ -258,4 +258,25 @@
<data name="repetition" xml:space="preserve">
<value>opakování</value>
</data>
<data name="Invalid_Q2_correction_factors" xml:space="preserve">
<value>Nesprávne Q2 korekčné faktory</value>
</data>
<data name="Previous_step_is_missing_or_NOK" xml:space="preserve">
<value>Predchádzajúci krok chýba alebo neprešiel</value>
</data>
<data name="Test_repetition_count_exceeded_upper_limit" xml:space="preserve">
<value>Počet opakovaní testu prekročil dovolené maximum</value>
</data>
<data name="Wrong_iPerl_counting_direction" xml:space="preserve">
<value>Nesprávny smer počítania iPerlu</value>
</data>
<data name="Failed" xml:space="preserve">
<value>NOK</value>
</data>
<data name="Passed" xml:space="preserve">
<value>OK</value>
</data>
<data name="Test_in_progress" xml:space="preserve">
<value>Probíhá test</value>
</data>
</root>

View File

@ -744,4 +744,25 @@
<data name="repetition" xml:space="preserve">
<value>repetition</value>
</data>
<data name="Invalid_Q2_correction_factors" xml:space="preserve">
<value>Invalid Q2 correction factors</value>
</data>
<data name="Previous_step_is_missing_or_NOK" xml:space="preserve">
<value>Previous step is missing or NOK</value>
</data>
<data name="Test_repetition_count_exceeded_upper_limit" xml:space="preserve">
<value>Test repetition count exceeded upper limit</value>
</data>
<data name="Wrong_iPerl_counting_direction" xml:space="preserve">
<value>Wrong iPerl counting direction</value>
</data>
<data name="Failed" xml:space="preserve">
<value>NOK</value>
</data>
<data name="Passed" xml:space="preserve">
<value>OK</value>
</data>
<data name="Test_in_progress" xml:space="preserve">
<value>Test in progress</value>
</data>
</root>

View File

@ -48,14 +48,14 @@ namespace Results
/// <summary>
/// Converts ErrorFlags integer to string. Supports up to 31 flags (E1..E31).
/// Converts ErrorFlags integer to string. Supports up to 31 flags (E1..E31, i.e. bit0..bit30).
/// </summary>
/// <param name="errorFlags">Input</param>
/// <returns>Output string</returns>
public static string ErrorFlagsStr(int errorFlags)
{
StringBuilder sb = new StringBuilder();
for (int i = 0; i < 30; i++)
for (int i = 0; i < 31; i++)
{
if ((errorFlags & (1 << i)) != 0)
{

View File

@ -49,8 +49,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
/// </returns>
public IList<Event> Execute(Config.Entities.Test test, int repetitionNr, TestMethodCfg cfg, iPerlCommunicationParams testParams)
{
IList<Event> e = new List<Event>(); /// Events from currently running operations
Event retVal = Event.Done;
IList<Event> e; /// Events from currently running operations
checkUiOp = new Operations.CheckUIOp(true); /// Runs in more then one state
modelessDlg = null;
@ -74,10 +73,8 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
Bridge.OnTestCompleted(this, new TestCompletedEventArgs(test.Name, ProcessData.BatchRslts.GetTestRslt(test.Name, 0)));
allResults.Info(TestResult2CsvLine(test.Name, 0)); /// Append the results to the CSV-file
IList<Event> rList = new List<Event>(1);
rList.Add(Event.Done);
return rList;
}
return new List<Event> { Event.Done };
}
else if (testParams.Activity.ToLower().Contains(Q2correctionCheckCmd))
{
TestProgressEventArgs.SetEstimatedTimes(new int[] { 0, 0, 0, 30, 0, 30, 0, 0 });
@ -95,9 +92,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
Bridge.OnTestCompleted(this, new TestCompletedEventArgs(test.Name, ProcessData.BatchRslts.GetTestRslt(test.Name, 0)));
allResults.Info(TestResult2CsvLine(test.Name, 0)); /// Append the results to the CSV-file
IList<Event> rList = new List<Event>(1);
rList.Add(Event.Done);
return rList;
return new List<Event> { Event.Done };
}
else if (testParams.Activity.ToLower().Contains(IperlCheckCmd))
{
@ -113,108 +108,116 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
Results.Entities.TestRslt tstRslt = ProcessData.BatchRslts.GetTestRslt(test.Name, 0);
int wrongMetersCount = 0;
string message = string.Empty;
for (int i = 0; i < BatchRslts.WMPositionsCount; i++)
if (tstRslt != null)
{
Results.Entities.WaterMeter wm = BatchRslts.WaterMeters[i];
Results.Entities.MeterTestRslt mtr = ProcessData.BatchRslts.GetMeterTestRslt(test.Name, i, CompoundMeterId.Single);
tstRslt.StartTime = DateTime.Now;
if ((wm != null) && (mtr != null))
int wrongMetersCount = 0;
string message = string.Empty;
for (int i = 0; i < BatchRslts.WMPositionsCount; i++)
{
int errorIndicators = 0;
bool anyErrorOfThisMeter = false;
foreach (var arg in args)
Results.Entities.WaterMeter wm = BatchRslts.WaterMeters[i];
Results.Entities.MeterTestRslt mtr = ProcessData.BatchRslts.GetMeterTestRslt(test.Name, i, CompoundMeterId.Single);
///// Reference to iPerl water meter or null:
//TestMethods.iPerlCommunication.iPerlHead.IperlHead iPerlHead = ((sensPath.RegisterReaders != null) && (i < sensPath.RegisterReaders.Length))
// ? (sensPath.RegisterReaders[i] as TestMethods.iPerlCommunication.iPerlHead.IperlHead)
// : null;
if ((wm != null) && (mtr != null))
{
#if ORACLE_DB
if (arg.ToLower() == "pruefindex")
int errorIndicators = 0;
bool anyErrorOfThisMeter = false;
foreach (var arg in args)
{
if (wm.Pruefindex > maxTestIndex)
#if ORACLE_DB
if (arg.ToLower() == "pruefindex")
{
anyErrorOfThisMeter = true;
message += string.Format("iPerl{0} : Príliš veľa opakovaní testu vodomera{1}", wm.WMPosition, Environment.NewLine);
errorIndicators |= (int)ErrorFlagMask.E25; /// Max pruefindex exceeded
if (wm.Pruefindex > maxTestIndex)
{
anyErrorOfThisMeter = true;
message += string.Format("iPerl{0} : Príliš veľa opakovaní testu vodomera{1}", wm.WMPosition, Environment.NewLine);
errorIndicators |= (int)ErrorFlagMask.E25; /// Max pruefindex exceeded
}
}
}
#endif
#if TURA_SPECIAL
if (arg.ToLower() == "q2factors")
{
if ((wm.ProdQ2CorrRL != wm.Q2CorrRL) || (wm.ProdQ2CorrLR != wm.Q2CorrLR))
{
anyMeterError = true;
anyErrorOfThisMeter = true;
message += string.Format("Q2 korekčné faktory vodomera {0} nesedia{1}", wm.WMPosition, Environment.NewLine);
errorIndicators |= (int)ErrorFlagMask.E26; /// Q2 correction factors not valid
}
}
#endif
if (arg.ToLower() == "direction")
{
//if (wm.Pruefindex > maxTestIndex)
//{
// anyErrorOfThisMeter = true;
// message += string.Format("Príliš veľa opakovaní testu vodomera {0}{1}", wm.WMPosition, Environment.NewLine);
// errorIndicators |= (int)ErrorFlagMask.E27; /// Wrong direction (positive/negative counting)
//}
}
if (arg.ToLower() == "prevworkstep")
{
if (!wm.IsLastRecordOk)
if (arg.ToLower() == "direction")
{
anyErrorOfThisMeter = true;
message += string.Format("iPerl{0} : Predchádzajúci krok nebol zaznamenaný{1}", wm.WMPosition, Environment.NewLine);
errorIndicators |= (int)ErrorFlagMask.E28; /// Previous workstep missing or NOK (production tracing)
//if (wm.Pruefindex > maxTestIndex)
//{
// anyErrorOfThisMeter = true;
// message += string.Format("Príliš veľa opakovaní testu vodomera {0}{1}", wm.WMPosition, Environment.NewLine);
// errorIndicators |= (int)ErrorFlagMask.E27; /// Wrong direction (positive/negative counting)
//}
}
if (arg.ToLower() == "prevworkstep")
{
if (!wm.IsLastRecordOk)
{
anyErrorOfThisMeter = true;
message += string.Format("iPerl{0} : Predchádzajúci krok nebol zaznamenaný{1}", wm.WMPosition, Environment.NewLine);
errorIndicators |= (int)ErrorFlagMask.E28; /// Previous workstep missing or NOK (production tracing)
}
}
}
}
mtr.TestDone = true;
mtr.ErrorIndicators = errorIndicators;
///
if (anyErrorOfThisMeter)
{
/// This iPerl check did not pass
mtr.Passed = false;
wm.Disabled = true;
wrongMetersCount++;
mtr.TestDone = true;
mtr.ErrorIndicators = errorIndicators;
///
if (anyErrorOfThisMeter)
{
/// This iPerl check did not pass
mtr.Passed = false;
wrongMetersCount++;
}
else
{
/// Check passed OK
mtr.Passed = true;
}
}
else
}
tstRslt.EndTime = DateTime.Now;
tstRslt.TestDone = true;
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, Config.Entities.Progress.Completed));
Bridge.OnTestCompleted(this, new TestCompletedEventArgs(test.Name, tstRslt));
allResults.Info(TestResult2CsvLine(test.Name, 0)); /// Append the results to the CSV-file
if (wrongMetersCount >= cfg.IperlCheckErrorsToStop)
{
State.Create("iPerlCommunicationSeq : Show check result")
.AddOperation(new Operations.LargeMessageBoxOp(message))
.EnterState();
do
{
/// Check passed OK
mtr.Passed = true;
e = StateMachine.WaitRunDevsRunOps();
}
while (!e.Contains(Event.Continue) && !e.Contains(Event.Abort));
if (e.Contains(Event.Abort))
{
Bridge.OnError(this, string.Format("Niečo nie je v poriadku !"));
return new List<Event> { Event.UiCmdStop };
}
}
}
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, Config.Entities.Progress.Completed));
Bridge.OnTestCompleted(this, new TestCompletedEventArgs(test.Name, ProcessData.BatchRslts.GetTestRslt(test.Name, 0)));
allResults.Info(TestResult2CsvLine(test.Name, 0)); /// Append the results to the CSV-file
IList<Event> rList = new List<Event>(1);
if (wrongMetersCount >= cfg.IperlCheckErrorsToStop)
{
State.Create("iPerlCommunicationSeq : Show check result")
.AddOperation(new Operations.LargeMessageBoxOp(message))
.EnterState();
do
{
e = StateMachine.WaitRunDevsRunOps();
}
while (!e.Contains(Event.Continue) && !e.Contains(Event.Abort));
if (e.Contains(Event.Abort))
{
Bridge.OnError(this, string.Format("Niečo nie je v poriadku !"));
rList.Add(Event.UiCmdStop);
return rList;
}
}
rList.Add(Event.Done);
return rList;
return new List<Event> { Event.Done };
}
else if (testParams.Activity.ToLower().Contains("simulate "))
{
@ -243,7 +246,10 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
.EnterState();
e = StateMachine.WaitRunDevsRunOps();
if (TestAndLogUiCmdStop(test,e)) retVal = Event.UiCmdStop;
if (TestAndLogUiCmdStop(test, e))
{
return new List<Event> { Event.UiCmdStop };
}
}
else
{
@ -274,7 +280,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
if (stopPressed)
{
CloseIPerlCommForm();
retVal = Event.UiCmdStop;
return new List<Event> { Event.UiCmdStop };
}
else
{
@ -286,9 +292,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
}
/// Create a list with one item 'retVal' (default is Event.Done) and return it
IList<Event> retList = new List<Event>(1);
retList.Add(retVal);
return retList;
return new List<Event> { Event.Done };
}

View File

@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
// Build Number
// Revision
//
[assembly: AssemblyVersion("2.18.1165.0")]
[assembly: AssemblyFileVersion("2.18.1165.0")]
[assembly: AssemblyVersion("2.18.1167.0")]
[assembly: AssemblyFileVersion("2.18.1167.0")]

View File

@ -309,6 +309,7 @@ namespace TBF.Screens
{
return new OneWMResultsCtrl(backColor, lvWidth, lvHeight);
}
OneWMResultsCtrl GetListView() { return GetListView(Color.White); }
/// <summary>
@ -376,7 +377,7 @@ namespace TBF.Screens
/// Water meter was completed but did not pass => Failed
#if ORACLE_DB
if ((TBF.BenchControl.Sequences.ProcessData.BenchInfo is TBF.BenchControl.BenchInfo.iPerl.Component) &&
wMtr.Pruefindex >= (TBF.BenchControl.Sequences.ProcessData.BenchInfo as TBF.BenchControl.BenchInfo.iPerl.Component).MaxTestIndex)
(wMtr.Pruefindex % 100) >= (TBF.BenchControl.Sequences.ProcessData.BenchInfo as TBF.BenchControl.BenchInfo.iPerl.Component).MaxTestIndex)
{
/// Proefindex reached the limit => Proefindex would be above this limit next time => Reject
message = Strings.Test_repetition_count_exceeded_upper_limit;