2021-05-27 15:30:04 +00:00
|
|
|
|
///
|
|
|
|
|
|
/// Copyright (c) 2016-2021 Sensus Slovensko a.s.
|
|
|
|
|
|
///
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
|
using SharedDatabase.Entities;
|
|
|
|
|
|
|
|
|
|
|
|
namespace SharedDatabase
|
|
|
|
|
|
{
|
|
|
|
|
|
public static class Utils
|
|
|
|
|
|
{
|
|
|
|
|
|
public static string GetTestName(string name, int repeats, int repetitionNr)
|
|
|
|
|
|
{
|
2023-06-22 11:20:04 +00:00
|
|
|
|
return Common.Utils.GetTestName(name, repeats, repetitionNr);
|
2021-05-27 15:30:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static System.Drawing.Color GetSeverityColor(Common.Severity severity, bool foreColor = false)
|
|
|
|
|
|
{
|
|
|
|
|
|
switch (severity)
|
|
|
|
|
|
{
|
|
|
|
|
|
case Common.Severity.Notification: return foreColor ? Color.White : Color.SteelBlue;
|
|
|
|
|
|
case Common.Severity.Warning: return foreColor ? Color.Black : Color.Orange;
|
|
|
|
|
|
case Common.Severity.Error: return foreColor ? Color.White : Color.Red;
|
|
|
|
|
|
case Common.Severity.FatalError: return foreColor ? Color.White : Color.Purple;
|
|
|
|
|
|
default: return foreColor ? Color.Black : Color.White;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static int BenchIdOracle2Asc(int benchIdOracle)
|
|
|
|
|
|
{
|
|
|
|
|
|
switch (benchIdOracle)
|
|
|
|
|
|
{
|
|
|
|
|
|
case 4: return 35; /// WR9
|
|
|
|
|
|
case 5: return 33; /// WR10
|
|
|
|
|
|
case 6: return 34; /// WR11
|
|
|
|
|
|
case 7: return 29; /// PT7, special
|
|
|
|
|
|
case 8: return 36; /// WR13
|
|
|
|
|
|
case 9: return 37; /// WR15
|
|
|
|
|
|
case 10: return 38; /// WR14
|
|
|
|
|
|
case 11: return 39; /// WR18
|
|
|
|
|
|
case 12: return 40; /// WR19
|
2023-06-22 11:20:04 +00:00
|
|
|
|
case 13: return 41; /// WR20
|
|
|
|
|
|
case 14: return 42; /// WR21
|
2021-05-27 15:30:04 +00:00
|
|
|
|
default: return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static string BenchNameFromOracleBenchID(int id)
|
|
|
|
|
|
{
|
|
|
|
|
|
switch (id)
|
|
|
|
|
|
{
|
|
|
|
|
|
case 4: return "WR9";
|
|
|
|
|
|
case 5: return "WR10";
|
|
|
|
|
|
case 6: return "WR11";
|
|
|
|
|
|
case 7: return "PT7";
|
|
|
|
|
|
case 8: return "WR13";
|
|
|
|
|
|
case 9: return "WR15";
|
|
|
|
|
|
case 10: return "WR14";
|
|
|
|
|
|
case 11: return "WR18";
|
|
|
|
|
|
case 12: return "WR19";
|
2023-06-22 11:20:04 +00:00
|
|
|
|
case 13: return "WR20";
|
|
|
|
|
|
case 14: return "WR21";
|
2021-05-27 15:30:04 +00:00
|
|
|
|
default: return string.Empty;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 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(long errorFlags)
|
|
|
|
|
|
{
|
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
|
for (int i = 0; i < 63; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if ((errorFlags & (1L << i)) != 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
sb.Append("E");
|
|
|
|
|
|
sb.Append(i + 1);
|
|
|
|
|
|
sb.Append(" ");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return sb.ToString().TrimEnd();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static string PassedColorStr(bool passed, bool useRedGreenColor)
|
|
|
|
|
|
{
|
|
|
|
|
|
#if PUCHONG_200
|
|
|
|
|
|
return (useRedGreenColor) ? (passed ? "OK|Green" : "NG|Red") : (passed ? "OK|White" : "NG|White");
|
|
|
|
|
|
#elif BAHRAIN_50 || DUBAJ_50
|
|
|
|
|
|
return (useRedGreenColor) ? (passed ? "PASSED|Green" : "FAILED|Red") : (passed ? "PASSED|White" : "FAILED|White");
|
|
|
|
|
|
#elif LANG_PL
|
|
|
|
|
|
return (useRedGreenColor) ? (passed ? "+|Green" : "-|Red") : (passed ? "+|White" : "-|White");
|
|
|
|
|
|
#elif LANG_RU
|
|
|
|
|
|
return (useRedGreenColor) ? (passed ? "годен|Green" : "негоден|Red") : (passed ? "годен|White" : "негоден|White");
|
|
|
|
|
|
#else
|
|
|
|
|
|
return (useRedGreenColor) ? (passed ? "OK|Green" : "NOK|Red") : (passed ? "OK|White" : "NOK|White");
|
|
|
|
|
|
#endif
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static void GetCounterStates(SharedDatabase.Entities.TestRslt tstRslt, int[] counters)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (tstRslt != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
tstRslt.Counter1 = ((counters != null) && (counters.Length >= 1)) ? counters[0] : 0;
|
|
|
|
|
|
tstRslt.Counter2 = ((counters != null) && (counters.Length >= 2)) ? counters[1] : 0;
|
|
|
|
|
|
tstRslt.Counter3 = ((counters != null) && (counters.Length >= 3)) ? counters[2] : 0;
|
|
|
|
|
|
tstRslt.Counter4 = ((counters != null) && (counters.Length >= 4)) ? counters[3] : 0;
|
|
|
|
|
|
tstRslt.Counter5 = ((counters != null) && (counters.Length >= 5)) ? counters[4] : 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static void GetCounterStates(SharedDatabase.Entities.Batch batch, int[] counters)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (batch != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
batch.Counter6 = ((counters != null) && (counters.Length >= 6)) ? counters[5] : 0;
|
|
|
|
|
|
batch.Counter7 = ((counters != null) && (counters.Length >= 7)) ? counters[6] : 0;
|
|
|
|
|
|
batch.Counter8 = ((counters != null) && (counters.Length >= 8)) ? counters[7] : 0;
|
|
|
|
|
|
batch.Counter9 = ((counters != null) && (counters.Length >= 9)) ? counters[8] : 0;
|
|
|
|
|
|
batch.Counter10 = ((counters != null) && (counters.Length >= 10)) ? counters[9] : 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|