DB.SensusOracle.Database : (1) Procedure params., (2) S620 support, (3) SensusTestInfo for 620.
This commit is contained in:
parent
c28828fcdd
commit
3bfb34a6ea
@ -23,6 +23,7 @@ namespace Results.Output
|
||||
Suez_EMP_DN32, /// EMP: 12 flow rates
|
||||
Suez_EMP_DN40, /// EMP: 12 flow rates
|
||||
Greece, /// Q3, Q2adj, Q2, Q1
|
||||
S620, /// Q3, Q100, Q2, Q1
|
||||
Count,
|
||||
None,
|
||||
}
|
||||
@ -414,6 +415,16 @@ namespace Results.Output
|
||||
new SensusTestInfo("Q2", 2, "Q2", 2, "02", 2, "Q2", Range.R100_110),
|
||||
new SensusTestInfo("Q1", 1, "Q1", 1, "01", 1, "Q1", Range.R100_110),
|
||||
};
|
||||
|
||||
case LogType.S620:
|
||||
return new SensusTestInfo[]
|
||||
{
|
||||
/// TBF Oracle DB Opto RAW LU logfiles
|
||||
new SensusTestInfo("Q3", 5, "Q3", 5, "04", 5, "Q3", Range.R90_100),
|
||||
new SensusTestInfo("Q100", 4, "Q100l", 4, "03", 4,"Q100l", Range.R100_110),
|
||||
new SensusTestInfo("Q2", 2, "Q2", 2, "02", 2, "Q2", Range.R100_110),
|
||||
new SensusTestInfo("Q1", 1, "Q1", 1, "01", 1, "Q1", Range.R100_110),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,9 +1,8 @@
|
||||
///
|
||||
/// Copyright (c) 2015-2019 Sensus Slovensko a.s.
|
||||
/// Copyright (c) 2015-2020 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using log4net;
|
||||
using Oracle.DataAccess.Client; // ODP.NET Oracle managed provider
|
||||
@ -21,6 +20,23 @@ namespace TBF.BenchControl.Output.DB.SensusOracle
|
||||
Error,
|
||||
}
|
||||
|
||||
public enum DBUsed
|
||||
{
|
||||
None,
|
||||
Production,
|
||||
Test,
|
||||
Quality,
|
||||
Count
|
||||
}
|
||||
|
||||
public enum WMKind
|
||||
{
|
||||
Iperl,
|
||||
S620,
|
||||
Count
|
||||
}
|
||||
|
||||
|
||||
public class Database : ComponentBase, IOperation, GenericDevices.IResultsWriter, GenericDevices.IStartInfoReader, Generic.IDevice
|
||||
{
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(Database));
|
||||
@ -28,7 +44,15 @@ namespace TBF.BenchControl.Output.DB.SensusOracle
|
||||
|
||||
const int Anbid_StaraTura = 4;
|
||||
|
||||
public DatabaseCfg dbCfg;
|
||||
DatabaseCfg dbCfg;
|
||||
|
||||
public DBUsed DBUsed { get { return (dbCfg == null || dbCfg.ProcParams == null) ? DBUsed.None : dbCfg.ProcParams.DBUsed; } }
|
||||
public WMKind WMKind { get { return (dbCfg == null || dbCfg.ProcParams == null) ? WMKind.Iperl : dbCfg.ProcParams.WMKind; } }
|
||||
public int WMTypeId { get { return (dbCfg == null || dbCfg.ProcParams == null) ? 0 : dbCfg.ProcParams.WMTypeId; } }
|
||||
public int YearOfManufacture { get { return (dbCfg == null || dbCfg.ProcParams == null) ? DateTime.Now.Year : dbCfg.ProcParams.YearOfManufacture; } }
|
||||
public bool SaveResults { get { return (dbCfg == null || dbCfg.ProcParams == null) ? false : dbCfg.ProcParams.SaveResults; } }
|
||||
public bool ReadStartInfo { get { return (dbCfg == null || dbCfg.ProcParams == null) ? true : dbCfg.ProcParams.ReadStartInfo; } }
|
||||
public bool StartInfoIsRequired { get { return (dbCfg == null || dbCfg.ProcParams == null) ? false : dbCfg.ProcParams.StartInfoIsRequired; } }
|
||||
|
||||
|
||||
enum OpState
|
||||
@ -39,16 +63,12 @@ namespace TBF.BenchControl.Output.DB.SensusOracle
|
||||
WriteResultsScheduled,
|
||||
WriteResultsRunning,
|
||||
}
|
||||
|
||||
OpState currentOpState;
|
||||
bool opCompleted;
|
||||
bool anyError;
|
||||
|
||||
|
||||
///
|
||||
/// iPerls to verify
|
||||
///
|
||||
GenericDevices.IRegReader[] iperlHeads;
|
||||
|
||||
/// <summary>
|
||||
/// Start info is read into WaterMeter objects referenced by this array
|
||||
/// </summary>
|
||||
@ -59,7 +79,29 @@ namespace TBF.BenchControl.Output.DB.SensusOracle
|
||||
/// </summary>
|
||||
Results.Entities.Batch batch;
|
||||
|
||||
OracleConnection connection; /// Oracle database connection
|
||||
OracleConnection productionDB; /// Production Oracle DB connection
|
||||
OracleConnection qualityDB; /// Quality Oracle DB connection
|
||||
OracleConnection testDB; /// Test Oracle DB connection
|
||||
|
||||
OracleConnection selectedDB
|
||||
{
|
||||
get
|
||||
{
|
||||
if (dbCfg == null || dbCfg.ProcParams == null) return null;
|
||||
|
||||
switch (dbCfg.ProcParams.DBUsed)
|
||||
{
|
||||
case DBUsed.Production: return productionDB;
|
||||
case DBUsed.Quality: return qualityDB;
|
||||
case DBUsed.Test: return testDB;
|
||||
|
||||
default:
|
||||
case DBUsed.None:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// The following 3 variables are always updated together
|
||||
@ -86,38 +128,26 @@ namespace TBF.BenchControl.Output.DB.SensusOracle
|
||||
///
|
||||
public void Initialize()
|
||||
{
|
||||
switch (dbCfg.DBUsed)
|
||||
{
|
||||
case DBUsed.Production:
|
||||
connection = new OracleConnection("Data Source=STARA01.WORLD;User Id=deltachef;Password=deltachef;");
|
||||
break;
|
||||
case DBUsed.Quality:
|
||||
connection = new OracleConnection("Data Source=STARA01.WORLD;User Id=deltaqual;Password=test;");
|
||||
break;
|
||||
case DBUsed.Test:
|
||||
connection = new OracleConnection("Data Source=STARA_TEST.WORLD;User Id=deltachef;Password=deltachef;");
|
||||
break;
|
||||
default:
|
||||
connection = null;
|
||||
break;
|
||||
}
|
||||
productionDB = new OracleConnection("Data Source=STARA01.WORLD;User Id=deltachef;Password=deltachef;");
|
||||
qualityDB = new OracleConnection("Data Source=STARA01.WORLD;User Id=deltaqual;Password=test;");
|
||||
testDB = new OracleConnection("Data Source=STARA_TEST.WORLD;User Id=deltachef;Password=deltachef;");
|
||||
|
||||
if (dbCfg.DebugLevel == DebugMode.Simulate) return;
|
||||
|
||||
///
|
||||
/// Do something with the database to see if the connection works well
|
||||
///
|
||||
if (connection != null)
|
||||
if (productionDB != null)
|
||||
{
|
||||
connection.Open();
|
||||
productionDB.Open();
|
||||
|
||||
string rslt = "none";
|
||||
OracleCommand cmd = new OracleCommand("select Standort from ANBIETER_SD where ANBID = 4", connection);
|
||||
OracleCommand cmd = new OracleCommand("select Standort from ANBIETER_SD where ANBID = 4", productionDB);
|
||||
OracleDataReader dr = cmd.ExecuteReader();
|
||||
if (dr.Read()) rslt = dr.GetString(0);
|
||||
dr.Close();
|
||||
|
||||
connection.Close();
|
||||
productionDB.Close();
|
||||
}
|
||||
}
|
||||
///
|
||||
@ -126,9 +156,11 @@ namespace TBF.BenchControl.Output.DB.SensusOracle
|
||||
///
|
||||
public void StopDevice()
|
||||
{
|
||||
if (connection != null) connection.Dispose();
|
||||
if (testDB != null) testDB.Dispose();
|
||||
if (qualityDB != null) qualityDB.Dispose();
|
||||
if (productionDB != null) productionDB.Dispose();
|
||||
}
|
||||
public void StopDevice2() { }
|
||||
public void StopDevice2() {}
|
||||
|
||||
|
||||
/// <summary>
|
||||
@ -221,7 +253,7 @@ namespace TBF.BenchControl.Output.DB.SensusOracle
|
||||
/// <returns>Reference to the operation</returns>
|
||||
public IOperation ReadStartInfoOp(IList<Results.Entities.WaterMeter> waterMeters)
|
||||
{
|
||||
if (!dbCfg.ReadStartInfo)
|
||||
if (!ReadStartInfo)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@ -244,7 +276,7 @@ namespace TBF.BenchControl.Output.DB.SensusOracle
|
||||
/// <returns>Reference to the operation</returns>
|
||||
public IOperation ProcessResultsOp(Results.Entities.Batch batch)
|
||||
{
|
||||
if (!dbCfg.SaveResults)
|
||||
if (!SaveResults)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@ -287,11 +319,11 @@ namespace TBF.BenchControl.Output.DB.SensusOracle
|
||||
{
|
||||
if (waterMeters.Count == 0) return Event.ResultsWritten;
|
||||
|
||||
if ((dbCfg.DebugLevel == DebugMode.Normal) && (connection != null))
|
||||
if ((dbCfg.DebugLevel == DebugMode.Normal) && (selectedDB != null))
|
||||
{
|
||||
log.WarnFormat("{0} : Run() : currentOp = {1}", Name, currentOpState);
|
||||
#if ORACLE_DB
|
||||
if (ReadStartInfoFromDB(connection) == Retv.Error) anyError = true;
|
||||
if (ReadStartInfoFromDB(selectedDB) == Retv.Error) anyError = true;
|
||||
#endif
|
||||
}
|
||||
opCompleted = true;
|
||||
@ -305,11 +337,11 @@ namespace TBF.BenchControl.Output.DB.SensusOracle
|
||||
{
|
||||
if (batch.WaterMeters.Count == 0) return Event.ResultsWritten;
|
||||
|
||||
if ((dbCfg.DebugLevel == DebugMode.Normal) && (connection != null))
|
||||
if ((dbCfg.DebugLevel == DebugMode.Normal) && (selectedDB != null))
|
||||
{
|
||||
log.WarnFormat("{0} : Run() : currentOp = {1}", Name, currentOpState);
|
||||
#if ORACLE_DB
|
||||
if (WriteResultsToDB(connection, batch, false) == Retv.Error) anyError = true;
|
||||
if (WriteResultsToDB(selectedDB, batch, false) == Retv.Error) anyError = true;
|
||||
#endif
|
||||
}
|
||||
opCompleted = true;
|
||||
@ -495,7 +527,7 @@ namespace TBF.BenchControl.Output.DB.SensusOracle
|
||||
///
|
||||
log.ErrorFormat("Water meter {0} was not found in ORACLE database.", wm.SerialNr);
|
||||
dr.Close();
|
||||
return dbCfg.StartInfoIsRequired ? Retv.Error : Retv.OK;
|
||||
return StartInfoIsRequired ? Retv.Error : Retv.OK;
|
||||
}
|
||||
dr.Close();
|
||||
|
||||
@ -651,10 +683,17 @@ namespace TBF.BenchControl.Output.DB.SensusOracle
|
||||
SaveBatchData(conn, batch);
|
||||
foreach (var wMtr in batch.WaterMeters)
|
||||
{
|
||||
if ((wMtr.ErrorFlags & ((int)ErrorFlagMask.E26 | (int)ErrorFlagMask.E27 | (int)ErrorFlagMask.E28)) == 0)
|
||||
if (WMKind == WMKind.Iperl)
|
||||
{
|
||||
/// No production error => write the result of testing to Oracle DB
|
||||
SaveSingleWM2DB(conn, wMtr, safeMode);
|
||||
if ((wMtr.ErrorFlags & ((int)ErrorFlagMask.E26 | (int)ErrorFlagMask.E27 | (int)ErrorFlagMask.E28)) == 0)
|
||||
{
|
||||
/// No production error => write the result of testing to Oracle DB
|
||||
SaveOneIperlToDB(conn, wMtr, safeMode);
|
||||
}
|
||||
}
|
||||
else if (WMKind == WMKind.S620)
|
||||
{
|
||||
SaveOneS620ToDB(conn, wMtr, safeMode);
|
||||
}
|
||||
}
|
||||
|
||||
@ -672,43 +711,6 @@ namespace TBF.BenchControl.Output.DB.SensusOracle
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write one meter results into the database
|
||||
/// </summary>
|
||||
/// <param name="wmNr">0-based water meter number</param>
|
||||
/// <param name="results">Sorted list of results to save</param>
|
||||
void SaveSingleWM2DB(OracleConnection conn, Results.Entities.WaterMeter wm, bool safeMode)
|
||||
{
|
||||
if (safeMode && !wm.Passed) return;
|
||||
|
||||
if (string.IsNullOrEmpty(wm.SerialNr)) return; /// No database activity possible w/o PCB number
|
||||
|
||||
int maxpruefindexLowPart = ReadMaxPruefindex(conn, wm);
|
||||
|
||||
TBF.BenchControl.GenericDevices.IBenchInfo benchInfo = TBF.BenchControl.Sequences.ProcessData.BenchInfo;
|
||||
int testBenchID = (benchInfo != null) ? benchInfo.TestBenchId : 1;
|
||||
int MAX_Pruefindex = 100 * testBenchID + maxpruefindexLowPart + 1;
|
||||
|
||||
int Hydr_Pruefung;
|
||||
if (wm.Passed)
|
||||
{
|
||||
/// Passed
|
||||
if (maxpruefindexLowPart == 0)
|
||||
Hydr_Pruefung = 96;
|
||||
else
|
||||
Hydr_Pruefung = 224;
|
||||
}
|
||||
else
|
||||
{
|
||||
/// Failed
|
||||
Hydr_Pruefung = 97; /// Hydr. test failed, Pressure test passed
|
||||
}
|
||||
|
||||
wm.Pruefindex = MAX_Pruefindex;
|
||||
wm.HydrPruefung = Hydr_Pruefung;
|
||||
SaveOrUpdateWM(conn, wm, MAX_Pruefindex, Hydr_Pruefung);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
@ -894,13 +896,13 @@ namespace TBF.BenchControl.Output.DB.SensusOracle
|
||||
cmd2.ExecuteNonQuery(); /// Returns nr. of updated rows
|
||||
#else
|
||||
OracleCommand cmd2 = new OracleCommand("INSERT INTO VT_PRUEFDURCHFLUSS_PD(" +
|
||||
"ANBID, ID_Pruefstand, ID_WzPruefreihe, PruefungsNr, " +
|
||||
"PVOL, PMasse, MinDurchfluss, MaxDurchfluss, " +
|
||||
"Q_ist, KFaktor, Q_VZ, F_VZ, RegelEinstellZeit, Drehzahl, " +
|
||||
"BeginnDruck_Vorne, BeginnDruck_Hinten, EndDruck_Vorne, EndDruck_Hinten, " +
|
||||
"TVWZ, IVWZ, Verwendeter_VZ, BeginnGewicht, EndGewicht)" +
|
||||
" VALUES (:1, :2, :3, :4, :5, :6, :7, :8, :9, :10, :11, :12, :13, :14, :15, " +
|
||||
":16, :17, :18, :19, :20, :21, :22, :23)", conn);
|
||||
"ANBID, ID_Pruefstand, ID_WzPruefreihe, PruefungsNr, " +
|
||||
"PVOL, PMasse, MinDurchfluss, MaxDurchfluss, " +
|
||||
"Q_ist, KFaktor, Q_VZ, F_VZ, RegelEinstellZeit, Drehzahl, " +
|
||||
"BeginnDruck_Vorne, BeginnDruck_Hinten, EndDruck_Vorne, EndDruck_Hinten, " +
|
||||
"TVWZ, IVWZ, Verwendeter_VZ, BeginnGewicht, EndGewicht)" +
|
||||
" VALUES (:1, :2, :3, :4, :5, :6, :7, :8, :9, :10, :11, :12, :13, :14, :15, " +
|
||||
":16, :17, :18, :19, :20, :21, :22, :23)", conn);
|
||||
OracleParameter parm;
|
||||
parm = new OracleParameter("ANBID", OracleDbType.Int32); parm.Value = Anbid_StaraTura; cmd2.Parameters.Add(parm); ///:1
|
||||
parm = new OracleParameter("ID_Pruefstand", OracleDbType.Int32); parm.Value = 18000 + b.TestBenchId; cmd2.Parameters.Add(parm); ///:2
|
||||
@ -945,7 +947,44 @@ namespace TBF.BenchControl.Output.DB.SensusOracle
|
||||
}
|
||||
|
||||
|
||||
void SaveOrUpdateWM(OracleConnection conn, Results.Entities.WaterMeter wm, int max_Pruefindex, int hydr_Pruefung)
|
||||
/// <summary>
|
||||
/// Write one meter results into the database
|
||||
/// </summary>
|
||||
/// <param name="wmNr">0-based water meter number</param>
|
||||
/// <param name="results">Sorted list of results to save</param>
|
||||
void SaveOneIperlToDB(OracleConnection conn, Results.Entities.WaterMeter wm, bool safeMode)
|
||||
{
|
||||
if (safeMode && !wm.Passed) return;
|
||||
|
||||
if (string.IsNullOrEmpty(wm.SerialNr)) return; /// No database activity possible w/o PCB number
|
||||
|
||||
int maxpruefindexLowPart = ReadMaxPruefindex(conn, wm);
|
||||
|
||||
TBF.BenchControl.GenericDevices.IBenchInfo benchInfo = TBF.BenchControl.Sequences.ProcessData.BenchInfo;
|
||||
int testBenchID = (benchInfo != null) ? benchInfo.TestBenchId : 1;
|
||||
int MAX_Pruefindex = 100 * testBenchID + maxpruefindexLowPart + 1;
|
||||
|
||||
int Hydr_Pruefung;
|
||||
if (wm.Passed)
|
||||
{
|
||||
/// Passed
|
||||
if (maxpruefindexLowPart == 0)
|
||||
Hydr_Pruefung = 96;
|
||||
else
|
||||
Hydr_Pruefung = 224;
|
||||
}
|
||||
else
|
||||
{
|
||||
/// Failed
|
||||
Hydr_Pruefung = 97; /// Hydr. test failed, Pressure test passed
|
||||
}
|
||||
|
||||
wm.Pruefindex = MAX_Pruefindex;
|
||||
wm.HydrPruefung = Hydr_Pruefung;
|
||||
SaveOrUpdateIperl(conn, wm, MAX_Pruefindex, Hydr_Pruefung);
|
||||
}
|
||||
|
||||
void SaveOrUpdateIperl(OracleConnection conn, Results.Entities.WaterMeter wm, int max_Pruefindex, int hydr_Pruefung)
|
||||
{
|
||||
int sekundaere_Adr = wm.Passed ? 1 : 0;
|
||||
int idBenutzer = 6; // = wm.Batch.UserNumber;
|
||||
@ -967,7 +1006,7 @@ namespace TBF.BenchControl.Output.DB.SensusOracle
|
||||
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Int32, Value = hydr_Pruefung });
|
||||
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Int32, Value = idBenutzer });
|
||||
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Int32, Value = Anbid_StaraTura });
|
||||
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Int32, Value = dbCfg.Baujahr });
|
||||
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Int32, Value = YearOfManufacture });
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
log.InfoFormat("VT_ZAEHLER_PD inserted, PcbNr={0}, pos={1}, maxPruefix={2}", wm.SerialNr, wm.WMPosition, max_Pruefindex);
|
||||
@ -988,7 +1027,7 @@ namespace TBF.BenchControl.Output.DB.SensusOracle
|
||||
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Int32, Value = max_Pruefindex });
|
||||
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Int32, Value = hydr_Pruefung });
|
||||
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Int32, Value = idBenutzer });
|
||||
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Int32, Value = dbCfg.Baujahr });
|
||||
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Int32, Value = YearOfManufacture });
|
||||
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Varchar2, Value = wm.SerialNr });
|
||||
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Int32, Value = Anbid_StaraTura });
|
||||
|
||||
@ -1105,6 +1144,173 @@ namespace TBF.BenchControl.Output.DB.SensusOracle
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Write one meter results into the database
|
||||
/// </summary>
|
||||
/// <param name="wmNr">0-based water meter number</param>
|
||||
/// <param name="results">Sorted list of results to save</param>
|
||||
void SaveOneS620ToDB(OracleConnection conn, Results.Entities.WaterMeter wm, bool safeMode)
|
||||
{
|
||||
if (safeMode && !wm.Passed) return;
|
||||
|
||||
if (string.IsNullOrEmpty(wm.SerialNr)) return; /// No database activity possible w/o PCB number
|
||||
|
||||
int maxpruefindexLowPart = ReadMaxPruefindex(conn, wm);
|
||||
|
||||
TBF.BenchControl.GenericDevices.IBenchInfo benchInfo = TBF.BenchControl.Sequences.ProcessData.BenchInfo;
|
||||
int testBenchID = (benchInfo != null) ? benchInfo.TestBenchId : 1;
|
||||
int MAX_Pruefindex = 100 * testBenchID + maxpruefindexLowPart + 1;
|
||||
|
||||
int Hydr_Pruefung;
|
||||
if (wm.Passed)
|
||||
{
|
||||
/// Passed
|
||||
if (maxpruefindexLowPart == 0)
|
||||
Hydr_Pruefung = 96;
|
||||
else
|
||||
Hydr_Pruefung = 224;
|
||||
}
|
||||
else
|
||||
{
|
||||
/// Failed
|
||||
Hydr_Pruefung = 97; /// Hydr. test failed, Pressure test passed
|
||||
}
|
||||
|
||||
wm.Pruefindex = MAX_Pruefindex;
|
||||
wm.HydrPruefung = Hydr_Pruefung;
|
||||
SaveOrUpdateS620(conn, wm, MAX_Pruefindex, Hydr_Pruefung);
|
||||
}
|
||||
|
||||
void SaveOrUpdateS620(OracleConnection conn, Results.Entities.WaterMeter wm, int max_Pruefindex, int hydr_Pruefung)
|
||||
{
|
||||
int sekundaere_Adr = wm.Passed ? 1 : 0;
|
||||
int idBenutzer = 6; // = wm.Batch.UserNumber;
|
||||
|
||||
if (max_Pruefindex % 100 == 1)
|
||||
{
|
||||
if (!dbCfg.TestMode)
|
||||
{
|
||||
OracleCommand cmd = new OracleCommand("INSERT INTO VT_ZAEHLER_PD(Auftragsnummer, VT_Identnummer, VT_Fernum, Max_Pruefindex," +
|
||||
" Zaehlernummer, Sekundaere_Adr, Hydr_Pruefung, ID_Benutzer, ANBID, Baujahr)" +
|
||||
" VALUES (:1, :2, :3, :4, :5, :6, :7, :8, :9, :10)", conn);
|
||||
|
||||
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Varchar2, Value = wm.PurchaseOrder });
|
||||
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Varchar2, Value = "IPBATMXX" });
|
||||
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Varchar2, Value = wm.SerialNr });
|
||||
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Int32, Value = max_Pruefindex });
|
||||
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Int32, Value = -1 });
|
||||
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Int32, Value = sekundaere_Adr });
|
||||
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Int32, Value = hydr_Pruefung });
|
||||
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Int32, Value = idBenutzer });
|
||||
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Int32, Value = Anbid_StaraTura });
|
||||
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Int32, Value = YearOfManufacture });
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
log.InfoFormat("VT_ZAEHLER_PD inserted, PcbNr={0}, pos={1}, maxPruefix={2}", wm.SerialNr, wm.WMPosition, max_Pruefindex);
|
||||
}
|
||||
else
|
||||
{
|
||||
log.WarnFormat("SIM: VT_ZAEHLER_PD inserted, PcbNr={0}, pos={1}, maxPruefix={2}", wm.SerialNr, wm.WMPosition, max_Pruefindex);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!dbCfg.TestMode)
|
||||
{
|
||||
OracleCommand cmd = new OracleCommand("UPDATE VT_ZAEHLER_PD SET Auftragsnummer = :1, VT_Identnummer = :2, Max_Pruefindex = :3, Hydr_Pruefung= :4, ID_Benutzer= :5, Baujahr= :6 WHERE VT_Fernum = :7 and ANBID = :8", conn);
|
||||
|
||||
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Varchar2, Value = wm.PurchaseOrder });
|
||||
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Varchar2, Value = "IPBATMXX" });
|
||||
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Int32, Value = max_Pruefindex });
|
||||
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Int32, Value = hydr_Pruefung });
|
||||
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Int32, Value = idBenutzer });
|
||||
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Int32, Value = YearOfManufacture });
|
||||
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Varchar2, Value = wm.SerialNr });
|
||||
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Int32, Value = Anbid_StaraTura });
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
log.InfoFormat("VT_ZAEHLER_PD updated, PcbNr={0}, pos={1}, maxPruefix={2}", wm.SerialNr, wm.WMPosition, max_Pruefindex);
|
||||
}
|
||||
else
|
||||
{
|
||||
log.WarnFormat("SIM: VT_ZAEHLER_PD updated, PcbNr={0}, pos={1}, maxPruefix={2}", wm.SerialNr, wm.WMPosition, max_Pruefindex);
|
||||
}
|
||||
}
|
||||
|
||||
if (!dbCfg.TestMode)
|
||||
{
|
||||
OracleCommand cmd = new OracleCommand("INSERT INTO VT_ZAEHLER_PINDEX_PD(" +
|
||||
"VT_Fernum, Pruefindex, ANBID, ID_Pruefstand, ID_WzPruefreihe, Hydr_Pruefung, " +
|
||||
"ReedKontakt, ReedKontaktOK, ReedKontaktZeit, KorrImprate, FestWertWZ, PtestOK, " +
|
||||
"Zaehlerstand, WT_Platz_NR, WZgut, ID_Benutzer, AnzahlPruefungen)" +
|
||||
" VALUES (:1, :2, :3, :4, :5, :6, 0, 0, 0, :7, 0, :8, 0, :9, :10, :11, :12)", conn); /// ReedKontakt = ReedKontaktOK = ReedKontaktZeit = FestWertWZ = Zaehlerstand = 0
|
||||
|
||||
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Varchar2, Value = wm.SerialNr });
|
||||
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Int32, Value = max_Pruefindex });
|
||||
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Int32, Value = Anbid_StaraTura });
|
||||
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Int32, Value = 18000 + wm.Batch.TestBenchId });
|
||||
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Int32, Value = wm.Batch.BatchNr });
|
||||
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Int32, Value = hydr_Pruefung });
|
||||
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Double, Value = wm.OrigCalibFactor });
|
||||
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Int32, Value = 0 }); /// TODO
|
||||
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Int32, Value = wm.WMPosition });
|
||||
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Int32, Value = wm.Passed ? 1 : 0 });
|
||||
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Int32, Value = idBenutzer });
|
||||
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Int32, Value = 3 });
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
log.InfoFormat("VT_ZAEHLER_PINDEX_PD inserted, PcbNr={0}, pos={1}, pruefix={2}", wm.SerialNr, wm.WMPosition, max_Pruefindex % 100);
|
||||
}
|
||||
else
|
||||
{
|
||||
log.WarnFormat("SIM: VT_ZAEHLER_PINDEX_PD inserted, PcbNr={0}, pos={1}, pruefix={2}", wm.SerialNr, wm.WMPosition, max_Pruefindex % 100);
|
||||
}
|
||||
|
||||
|
||||
foreach (var testInfo in completeTestInfo)
|
||||
{
|
||||
if ((testInfo.PruefungsNrDB != 0) && (-20 <= testInfo.PruefungsNrDB) && (testInfo.PruefungsNrDB <= 20)) /// LU PruefungsNr-s are nonzero and between -20 and 20
|
||||
{
|
||||
Results.Entities.TestData tData = wm.GetTestData(testInfo.TestName);
|
||||
Results.Entities.MeterTestRslt mtr;
|
||||
if (tData == null)
|
||||
{
|
||||
throw new Exception(string.Format("'{0}' test results missing, watermeter {1}", testInfo.TestName, wm.WMPosition));
|
||||
}
|
||||
else if (tData.Repeats == 1)
|
||||
{
|
||||
mtr = wm.GetMeterTestRslt(testInfo.TestName);
|
||||
if (mtr == null) throw new Exception(string.Format("'{0}' test results missing, watermeter {1}", testInfo.TestName, wm.WMPosition));
|
||||
}
|
||||
else
|
||||
{
|
||||
Results.Entities.MeterTestRslt firstMtr = wm.GetMeterTestRslt(Utils.TestTitle(tData, 1));
|
||||
if (firstMtr == null) throw new Exception(string.Format("'{0}' test results missing, watermeter {1}", Utils.TestTitle(tData, 1), wm.WMPosition));
|
||||
|
||||
mtr = new Results.Entities.MeterTestRslt();
|
||||
mtr.CopyContentFrom(firstMtr);
|
||||
mtr.TestRslt = firstMtr.TestRslt;
|
||||
mtr.WaterMeter = firstMtr.WaterMeter;
|
||||
for (int i = 2; i <= tData.Repeats; i++)
|
||||
{
|
||||
Results.Entities.MeterTestRslt nextMtr = wm.GetMeterTestRslt(Utils.TestTitle(tData, i));
|
||||
if (nextMtr == null) throw new Exception(string.Format("'{0}' test results missing, watermeter {1}", Utils.TestTitle(tData, i), wm.WMPosition));
|
||||
|
||||
mtr.TestTime += nextMtr.TestTime;
|
||||
mtr.VolumeMeter += nextMtr.VolumeMeter;
|
||||
mtr.VolumeRef += nextMtr.VolumeRef;
|
||||
mtr.VolumeEnd = nextMtr.VolumeEnd;
|
||||
mtr.Passed = (mtr.Passed && nextMtr.Passed);
|
||||
}
|
||||
mtr.Error = Formulas.ErrorFromVolumes(mtr.VolumeMeter, mtr.VolumeRef);
|
||||
}
|
||||
|
||||
SaveMeterTestResult(conn, mtr, testInfo.PruefungsNrDB, max_Pruefindex, wmTypeRevision);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Saves a water meter result of a single test
|
||||
/// </summary>
|
||||
@ -1112,7 +1318,7 @@ namespace TBF.BenchControl.Output.DB.SensusOracle
|
||||
/// <returns>Nr. of rows updated</returns>
|
||||
int SaveMeterTestResult(OracleConnection conn, Results.Entities.MeterTestRslt mtr, int pruefungsNr, int max_Pruefindex, int wmTypeRevision)
|
||||
{
|
||||
double Q_wm = 3600.0 * mtr.VolumeMeter / mtr.TestTime; /// in [l/hour]
|
||||
double Q_wm = (mtr.TestTime != 0) ? (3600.0 * mtr.VolumeMeter / mtr.TestTime) : 0; /// in [l/hour]
|
||||
double Q_wm_with_upper_bound = Math.Min(2 * 1000 * mtr.TestRslt.FlowVolume, Math.Max(0.0, Q_wm));
|
||||
int retv = 0;
|
||||
|
||||
|
||||
@ -3,29 +3,11 @@
|
||||
///
|
||||
using System;
|
||||
using System.Xml.Serialization;
|
||||
using Config.Entities;
|
||||
using TBF.BenchControl.Generic;
|
||||
|
||||
namespace TBF.BenchControl.Output.DB.SensusOracle
|
||||
{
|
||||
public enum DBUsed
|
||||
{
|
||||
None,
|
||||
Production,
|
||||
Test,
|
||||
Quality,
|
||||
Count
|
||||
}
|
||||
|
||||
public enum Separator
|
||||
{
|
||||
None,
|
||||
Space,
|
||||
Tabulator,
|
||||
Comma,
|
||||
Semicolon,
|
||||
Count
|
||||
}
|
||||
|
||||
public class DatabaseCfg : ComponentCfgBase, Generic.IComponentCfg
|
||||
{
|
||||
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(DatabaseCfg) })[0];
|
||||
@ -33,44 +15,33 @@ namespace TBF.BenchControl.Output.DB.SensusOracle
|
||||
|
||||
public IComponentCfgCtrl GetControl() { return new DatabaseCfgCtrl(); }
|
||||
|
||||
|
||||
public DBUsed DBUsed;
|
||||
public int Baujahr; /// Written to the database
|
||||
public bool ReadStartInfo;
|
||||
public bool StartInfoIsRequired;
|
||||
public bool SaveResults;
|
||||
/// <summary> Serialized parameters </summary>
|
||||
public bool TestMode;
|
||||
|
||||
/// <summary> Procedure parameters </summary>
|
||||
[XmlIgnore]
|
||||
public ProcedureParams ProcParams;
|
||||
public override IParamsProvider GetRuntimeProcParamsProvider() { return ProcParams; }
|
||||
public override IParamsProvider CreateProcParamsProvider() { return new ProcedureParams(true); }
|
||||
|
||||
/// Private parameterless constructor invoked by all other (public) constructors
|
||||
DatabaseCfg()
|
||||
{
|
||||
Name = "Sensus-Oracle-DB";
|
||||
ParentName = string.Empty;
|
||||
DBUsed = DBUsed.Test;
|
||||
Baujahr = 2015;
|
||||
ReadStartInfo = true;
|
||||
SaveResults = true;
|
||||
StartInfoIsRequired = false;
|
||||
TestMode = false;
|
||||
}
|
||||
{
|
||||
ProcParams = new ProcedureParams(true);
|
||||
}
|
||||
|
||||
public DatabaseCfg(IComponentFactory factory)
|
||||
public DatabaseCfg(string name, IComponentFactory factory)
|
||||
: this()
|
||||
{
|
||||
this.Factory = factory;
|
||||
Name = name;
|
||||
Factory = factory;
|
||||
ParentName = string.Empty;
|
||||
TestMode = false;
|
||||
}
|
||||
|
||||
public string ToString(int i)
|
||||
{
|
||||
return string.Format("Name={0}, DB={1}, Bjahr={2}, RdStartInfo={3}, SaveRslts={4}, StartInfoRqrd={5}, TestMode={6}",
|
||||
Name,
|
||||
DBUsed,
|
||||
Baujahr,
|
||||
ReadStartInfo,
|
||||
SaveResults,
|
||||
StartInfoIsRequired,
|
||||
TestMode);
|
||||
return string.Format("Name={0} TestMode={1}", Name, TestMode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
///
|
||||
/// Copyright (c) 2015-2018 Sensus Slovensko a.s.
|
||||
/// Copyright (c) 2015-2020 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
@ -30,12 +30,7 @@ namespace TBF.BenchControl.Output.DB.SensusOracle
|
||||
|
||||
private void WriterCfgCtrl_Load(object sender, EventArgs e)
|
||||
{
|
||||
for (int i = 0; i < (int)DBUsed.Count; i++)
|
||||
{
|
||||
dbUsedComboBox.Items.Add(((DBUsed)i).ToString());
|
||||
}
|
||||
|
||||
Redraw();
|
||||
Redraw();
|
||||
}
|
||||
|
||||
public void Closing()
|
||||
@ -47,49 +42,25 @@ namespace TBF.BenchControl.Output.DB.SensusOracle
|
||||
if (config == null) return; /// Control was not loaded, settings were not changed
|
||||
classNameLabel.Text = config.Factory.ClassName;
|
||||
nameTextBox.Text = config.Name;
|
||||
dbUsedComboBox.Text = config.DBUsed.ToString();
|
||||
baujahrTextBox.Text = config.Baujahr.ToString();
|
||||
readStartInfoCheckBox.Checked = config.ReadStartInfo;
|
||||
startInfoIsRequiredCheckBox.Checked = config.StartInfoIsRequired;
|
||||
saveResultsCheckBox.Checked = config.SaveResults;
|
||||
testModeCheckBox.Checked = config.TestMode;
|
||||
}
|
||||
|
||||
public void Unlock()
|
||||
{
|
||||
nameTextBox.Enabled = true;
|
||||
dbUsedComboBox.Enabled = true;
|
||||
baujahrTextBox.Enabled = true;
|
||||
readStartInfoCheckBox.Enabled = true;
|
||||
startInfoIsRequiredCheckBox.Enabled = true;
|
||||
saveResultsCheckBox.Enabled = true;
|
||||
testModeCheckBox.Enabled = true;
|
||||
}
|
||||
|
||||
public CfgUpdateFlags VerifyCfg(ref string message)
|
||||
{
|
||||
CfgUpdateFlags flags = CfgUpdateFlags.None;
|
||||
|
||||
int tmp;
|
||||
if (!int.TryParse(baujahrTextBox.Text, out tmp) || tmp < 2015 || tmp > 2099)
|
||||
{
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "Invalid 'Bujahr'";
|
||||
}
|
||||
|
||||
if (!dbUsedComboBox.Items.Contains(dbUsedComboBox.Text))
|
||||
{
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "Invalid 'Database used' item";
|
||||
}
|
||||
return flags;
|
||||
return CfgUpdateFlags.None;
|
||||
}
|
||||
|
||||
public CfgUpdateFlags UpdateCfg()
|
||||
{
|
||||
CfgUpdateFlags flags = CfgUpdateFlags.None; /// <------------------- !!!
|
||||
if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed
|
||||
|
||||
if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed
|
||||
CfgUpdateFlags flags = CfgUpdateFlags.None;
|
||||
|
||||
if (config.Name != nameTextBox.Text)
|
||||
{
|
||||
@ -97,34 +68,9 @@ namespace TBF.BenchControl.Output.DB.SensusOracle
|
||||
flags |= CfgUpdateFlags.RestartRqrd;
|
||||
}
|
||||
|
||||
int baujahr = int.Parse(baujahrTextBox.Text);
|
||||
if (config.Baujahr != baujahr)
|
||||
{
|
||||
config.Baujahr = baujahr;
|
||||
flags |= CfgUpdateFlags.RestartRqrd;
|
||||
}
|
||||
|
||||
for (int i = 0; i < (int)DBUsed.Count; i++)
|
||||
{
|
||||
if (((DBUsed)i).ToString().Equals(dbUsedComboBox.Text) && (config.DBUsed != (DBUsed)i))
|
||||
{
|
||||
config.DBUsed = (DBUsed)i;
|
||||
flags |= CfgUpdateFlags.RestartRqrd;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
flags |= UpdateDifferent(ref config.ReadStartInfo, readStartInfoCheckBox.Checked, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
|
||||
flags |= UpdateDifferent(ref config.StartInfoIsRequired, startInfoIsRequiredCheckBox.Checked, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
|
||||
flags |= UpdateDifferent(ref config.SaveResults, saveResultsCheckBox.Checked, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
|
||||
flags |= UpdateDifferent(ref config.TestMode, testModeCheckBox.Checked, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
private void logsFolderButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -34,20 +34,13 @@ namespace TBF.BenchControl.Output.DB.SensusOracle
|
||||
this.nameTextBox = new System.Windows.Forms.TextBox();
|
||||
this.nameLabel = new System.Windows.Forms.Label();
|
||||
this.classNameLabel = new System.Windows.Forms.Label();
|
||||
this.readStartInfoCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.saveResultsCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.dbUsedComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.dbUsedLabel = new System.Windows.Forms.Label();
|
||||
this.baujahrTextBox = new System.Windows.Forms.TextBox();
|
||||
this.baujahrLabel = new System.Windows.Forms.Label();
|
||||
this.startInfoIsRequiredCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.testModeCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// nameTextBox
|
||||
//
|
||||
this.nameTextBox.Enabled = false;
|
||||
this.nameTextBox.Location = new System.Drawing.Point(110, 55);
|
||||
this.nameTextBox.Location = new System.Drawing.Point(123, 59);
|
||||
this.nameTextBox.Name = "nameTextBox";
|
||||
this.nameTextBox.Size = new System.Drawing.Size(146, 20);
|
||||
this.nameTextBox.TabIndex = 2;
|
||||
@ -55,7 +48,7 @@ namespace TBF.BenchControl.Output.DB.SensusOracle
|
||||
// nameLabel
|
||||
//
|
||||
this.nameLabel.AutoSize = true;
|
||||
this.nameLabel.Location = new System.Drawing.Point(19, 58);
|
||||
this.nameLabel.Location = new System.Drawing.Point(19, 62);
|
||||
this.nameLabel.Name = "nameLabel";
|
||||
this.nameLabel.Size = new System.Drawing.Size(35, 13);
|
||||
this.nameLabel.TabIndex = 1;
|
||||
@ -64,85 +57,17 @@ namespace TBF.BenchControl.Output.DB.SensusOracle
|
||||
// classNameLabel
|
||||
//
|
||||
this.classNameLabel.AutoSize = true;
|
||||
this.classNameLabel.Location = new System.Drawing.Point(107, 27);
|
||||
this.classNameLabel.Location = new System.Drawing.Point(120, 31);
|
||||
this.classNameLabel.Name = "classNameLabel";
|
||||
this.classNameLabel.Size = new System.Drawing.Size(83, 13);
|
||||
this.classNameLabel.TabIndex = 0;
|
||||
this.classNameLabel.Text = "ComonentName";
|
||||
//
|
||||
// readStartInfoCheckBox
|
||||
//
|
||||
this.readStartInfoCheckBox.AutoSize = true;
|
||||
this.readStartInfoCheckBox.Enabled = false;
|
||||
this.readStartInfoCheckBox.Location = new System.Drawing.Point(111, 145);
|
||||
this.readStartInfoCheckBox.Name = "readStartInfoCheckBox";
|
||||
this.readStartInfoCheckBox.Size = new System.Drawing.Size(95, 17);
|
||||
this.readStartInfoCheckBox.TabIndex = 9;
|
||||
this.readStartInfoCheckBox.Text = "Read start info";
|
||||
this.readStartInfoCheckBox.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// saveResultsCheckBox
|
||||
//
|
||||
this.saveResultsCheckBox.AutoSize = true;
|
||||
this.saveResultsCheckBox.Enabled = false;
|
||||
this.saveResultsCheckBox.Location = new System.Drawing.Point(111, 200);
|
||||
this.saveResultsCheckBox.Name = "saveResultsCheckBox";
|
||||
this.saveResultsCheckBox.Size = new System.Drawing.Size(84, 17);
|
||||
this.saveResultsCheckBox.TabIndex = 11;
|
||||
this.saveResultsCheckBox.Text = "Save results";
|
||||
this.saveResultsCheckBox.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// dbUsedComboBox
|
||||
//
|
||||
this.dbUsedComboBox.Enabled = false;
|
||||
this.dbUsedComboBox.FormattingEnabled = true;
|
||||
this.dbUsedComboBox.Location = new System.Drawing.Point(110, 79);
|
||||
this.dbUsedComboBox.Name = "dbUsedComboBox";
|
||||
this.dbUsedComboBox.Size = new System.Drawing.Size(145, 21);
|
||||
this.dbUsedComboBox.TabIndex = 6;
|
||||
//
|
||||
// dbUsedLabel
|
||||
//
|
||||
this.dbUsedLabel.AutoSize = true;
|
||||
this.dbUsedLabel.Location = new System.Drawing.Point(19, 81);
|
||||
this.dbUsedLabel.Name = "dbUsedLabel";
|
||||
this.dbUsedLabel.Size = new System.Drawing.Size(79, 13);
|
||||
this.dbUsedLabel.TabIndex = 5;
|
||||
this.dbUsedLabel.Text = "Database used";
|
||||
//
|
||||
// baujahrTextBox
|
||||
//
|
||||
this.baujahrTextBox.Enabled = false;
|
||||
this.baujahrTextBox.Location = new System.Drawing.Point(110, 104);
|
||||
this.baujahrTextBox.Name = "baujahrTextBox";
|
||||
this.baujahrTextBox.Size = new System.Drawing.Size(57, 20);
|
||||
this.baujahrTextBox.TabIndex = 8;
|
||||
//
|
||||
// baujahrLabel
|
||||
//
|
||||
this.baujahrLabel.AutoSize = true;
|
||||
this.baujahrLabel.Location = new System.Drawing.Point(19, 107);
|
||||
this.baujahrLabel.Name = "baujahrLabel";
|
||||
this.baujahrLabel.Size = new System.Drawing.Size(43, 13);
|
||||
this.baujahrLabel.TabIndex = 7;
|
||||
this.baujahrLabel.Text = "Baujahr";
|
||||
//
|
||||
// startInfoIsRequiredCheckBox
|
||||
//
|
||||
this.startInfoIsRequiredCheckBox.AutoSize = true;
|
||||
this.startInfoIsRequiredCheckBox.Enabled = false;
|
||||
this.startInfoIsRequiredCheckBox.Location = new System.Drawing.Point(130, 168);
|
||||
this.startInfoIsRequiredCheckBox.Name = "startInfoIsRequiredCheckBox";
|
||||
this.startInfoIsRequiredCheckBox.Size = new System.Drawing.Size(119, 17);
|
||||
this.startInfoIsRequiredCheckBox.TabIndex = 10;
|
||||
this.startInfoIsRequiredCheckBox.Text = "Start info is required";
|
||||
this.startInfoIsRequiredCheckBox.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// testModeCheckBox
|
||||
//
|
||||
this.testModeCheckBox.AutoSize = true;
|
||||
this.testModeCheckBox.Enabled = false;
|
||||
this.testModeCheckBox.Location = new System.Drawing.Point(130, 223);
|
||||
this.testModeCheckBox.Location = new System.Drawing.Point(123, 113);
|
||||
this.testModeCheckBox.Name = "testModeCheckBox";
|
||||
this.testModeCheckBox.Size = new System.Drawing.Size(155, 17);
|
||||
this.testModeCheckBox.TabIndex = 12;
|
||||
@ -154,13 +79,6 @@ namespace TBF.BenchControl.Output.DB.SensusOracle
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.testModeCheckBox);
|
||||
this.Controls.Add(this.startInfoIsRequiredCheckBox);
|
||||
this.Controls.Add(this.baujahrTextBox);
|
||||
this.Controls.Add(this.baujahrLabel);
|
||||
this.Controls.Add(this.dbUsedComboBox);
|
||||
this.Controls.Add(this.dbUsedLabel);
|
||||
this.Controls.Add(this.saveResultsCheckBox);
|
||||
this.Controls.Add(this.readStartInfoCheckBox);
|
||||
this.Controls.Add(this.nameTextBox);
|
||||
this.Controls.Add(this.nameLabel);
|
||||
this.Controls.Add(this.classNameLabel);
|
||||
@ -177,13 +95,6 @@ namespace TBF.BenchControl.Output.DB.SensusOracle
|
||||
private System.Windows.Forms.TextBox nameTextBox;
|
||||
private System.Windows.Forms.Label nameLabel;
|
||||
private System.Windows.Forms.Label classNameLabel;
|
||||
private System.Windows.Forms.CheckBox readStartInfoCheckBox;
|
||||
private System.Windows.Forms.CheckBox saveResultsCheckBox;
|
||||
private System.Windows.Forms.ComboBox dbUsedComboBox;
|
||||
private System.Windows.Forms.Label dbUsedLabel;
|
||||
private System.Windows.Forms.TextBox baujahrTextBox;
|
||||
private System.Windows.Forms.Label baujahrLabel;
|
||||
private System.Windows.Forms.CheckBox startInfoIsRequiredCheckBox;
|
||||
private System.Windows.Forms.CheckBox testModeCheckBox;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
///
|
||||
/// Copyright (c) 2015-2018 Sensus Slovensko a.s.
|
||||
/// Copyright (c) 2015-2020 Sensus Slovensko a.s.
|
||||
///
|
||||
using System.Collections.Generic;
|
||||
using TBF.BenchControl.Generic;
|
||||
@ -17,7 +17,7 @@ namespace TBF.BenchControl.Output.DB.SensusOracle
|
||||
|
||||
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new Database(cfg); }
|
||||
|
||||
public IComponentCfg DefaultConfig() { return new DatabaseCfg(this); }
|
||||
public IComponentCfg DefaultConfig() { return new DatabaseCfg("Sensus-Oracle-DB", this); }
|
||||
|
||||
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
|
||||
{
|
||||
|
||||
245
TBF/BenchControl/Output/DB/SensusOracle/ProcedureParams.cs
Normal file
245
TBF/BenchControl/Output/DB/SensusOracle/ProcedureParams.cs
Normal file
@ -0,0 +1,245 @@
|
||||
///
|
||||
/// Copyright (c) 2020 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Xml.Serialization;
|
||||
using Config.Entities;
|
||||
using TBF.BenchControl.Generic;
|
||||
using TBF.Resources;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace TBF.BenchControl.Output.DB.SensusOracle
|
||||
{
|
||||
public class ProcedureParams : ProcedureParamsBase, IParamsProvider, IProcedureParams
|
||||
{
|
||||
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(ProcedureParams) })[0];
|
||||
public override XmlSerializer GetSerializer() { return Serializer; }
|
||||
|
||||
public DBUsed DBUsed; /// 0
|
||||
public WMKind WMKind; /// 1
|
||||
public int WMTypeId; /// 2
|
||||
public int YearOfManufacture; /// 3
|
||||
public bool SaveResults; /// 4
|
||||
public bool ReadStartInfo; /// 5
|
||||
public bool StartInfoIsRequired; /// 6
|
||||
|
||||
public override void InitializeAll()
|
||||
{
|
||||
DBUsed = DBUsed.Production; /// 0
|
||||
WMKind = WMKind.Iperl; /// 1
|
||||
WMTypeId = 2; /// 2
|
||||
YearOfManufacture = DateTime.Now.Year; /// 3
|
||||
#if TURA_SPECIAL
|
||||
SaveResults = false; /// 4
|
||||
#else
|
||||
SaveResults = true; /// 4
|
||||
#endif
|
||||
ReadStartInfo = true; /// 5
|
||||
StartInfoIsRequired = false; /// 6
|
||||
}
|
||||
|
||||
string[] paramNames = new string[]
|
||||
{
|
||||
"Database", /// 0
|
||||
"Kind of WMs", /// 1
|
||||
"WM type ID", /// 2
|
||||
"Year of manufacture", /// 3
|
||||
"Save results", /// 4
|
||||
"Read start info", /// 5
|
||||
"Start info is required", /// 6
|
||||
};
|
||||
public override string ParamName(int i) { return paramNames[i]; }
|
||||
public override int ParamsCount() { return paramNames.Length; }
|
||||
|
||||
public override IList<string> ParamValues(int i)
|
||||
{
|
||||
if (i == 0)
|
||||
{
|
||||
IList<string> retVal = new List<string>();
|
||||
for (DBUsed db = 0; db < DBUsed.Count; db++) retVal.Add(db.ToString());
|
||||
return retVal;
|
||||
}
|
||||
|
||||
if (i == 1)
|
||||
{
|
||||
IList<string> retVal = new List<string>();
|
||||
for (WMKind wm = 0; wm < WMKind.Count; wm++) retVal.Add(wm.ToString());
|
||||
return retVal;
|
||||
}
|
||||
|
||||
if (i == 3)
|
||||
{
|
||||
IList<string> retVal = new List<string>();
|
||||
int year = DateTime.Now.Year;
|
||||
retVal.Add(year.ToString());
|
||||
retVal.Add((year + 1).ToString());
|
||||
return retVal;
|
||||
}
|
||||
|
||||
if (i == 4 || i == 5 || i == 6)
|
||||
{
|
||||
IList<string> retVal = new List<string>();
|
||||
retVal.Add(Strings.yes);
|
||||
retVal.Add(Strings.no);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public override string ToString(int i)
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
case 0: return DBUsed.ToString();
|
||||
case 1: return WMKind.ToString();
|
||||
case 2: return WMTypeId.ToString();
|
||||
case 3: return YearOfManufacture.ToString();
|
||||
case 4: return SaveResults ? Strings.yes : Strings.no;
|
||||
case 5: return ReadStartInfo ? Strings.yes : Strings.no;
|
||||
case 6: return StartInfoIsRequired ? Strings.yes : Strings.no;
|
||||
default: return string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
/// Retrieves parameters from UI controls
|
||||
public CfgUpdateFlags UpdateParam(int i, string strValue)
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
case 0:
|
||||
for (DBUsed db = 0; db < DBUsed.Count; db++)
|
||||
{
|
||||
if (db.ToString() == strValue)
|
||||
{
|
||||
DBUsed = db;
|
||||
return CfgUpdateFlags.None;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
for (WMKind wm = 0; wm < WMKind.Count; wm++)
|
||||
{
|
||||
if (wm.ToString() == strValue)
|
||||
{
|
||||
WMKind = wm;
|
||||
return CfgUpdateFlags.None;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 2: WMTypeId = int.Parse(strValue); break;
|
||||
case 3: YearOfManufacture = int.Parse(strValue); break;
|
||||
case 4: SaveResults = (strValue == Strings.yes); break;
|
||||
case 5: ReadStartInfo = (strValue == Strings.yes); break;
|
||||
case 6: StartInfoIsRequired = (strValue == Strings.yes); break;
|
||||
}
|
||||
|
||||
return CfgUpdateFlags.None;
|
||||
}
|
||||
|
||||
/// Verifies whether strings in UI controls represent valid parameters
|
||||
public bool ValidateParam(int i, string strValue, out string message)
|
||||
{
|
||||
message = string.Empty;
|
||||
|
||||
int idummy;
|
||||
switch (i)
|
||||
{
|
||||
case 0:
|
||||
for (DBUsed db = 0; db < DBUsed.Count; db++)
|
||||
{
|
||||
if (db.ToString() == strValue) return true;
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
for (WMKind wm = 0; wm < WMKind.Count; wm++)
|
||||
{
|
||||
if (wm.ToString() == strValue) return true;
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
if (int.TryParse(strValue, out idummy) && idummy >= 0)
|
||||
return true;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
if (int.TryParse(strValue, out idummy) && idummy >= DateTime.Now.Year && idummy <= DateTime.Now.Year + 1)
|
||||
return true;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
if (strValue == Strings.yes || strValue == Strings.no)
|
||||
return true;
|
||||
break;
|
||||
|
||||
default:
|
||||
message = "Invalid index";
|
||||
return false;
|
||||
}
|
||||
|
||||
message = ParamName(i) + " is invalid";
|
||||
return false;
|
||||
}
|
||||
|
||||
void CopyContentTo(ProcedureParams prms)
|
||||
{
|
||||
prms.DBUsed = this.DBUsed;
|
||||
prms.WMKind = this.WMKind;
|
||||
prms.WMTypeId = this.WMTypeId;
|
||||
prms.YearOfManufacture = this.YearOfManufacture;
|
||||
prms.SaveResults = this.SaveResults;
|
||||
prms.ReadStartInfo = this.ReadStartInfo;
|
||||
prms.StartInfoIsRequired = this.StartInfoIsRequired;
|
||||
}
|
||||
|
||||
public IParamsProvider Clone()
|
||||
{
|
||||
ProcedureParams pars = new ProcedureParams();
|
||||
CopyContentTo(pars);
|
||||
return pars;
|
||||
}
|
||||
|
||||
public override void UpdateFromDbEntity(ComponentProcedure dbEntity)
|
||||
{
|
||||
if (dbEntity == null) return;
|
||||
try
|
||||
{
|
||||
ProcedureParams tmp = Serializer.Deserialize(new StringReader(dbEntity.Parameters)) as ProcedureParams;
|
||||
|
||||
procedureParamsEntity = dbEntity;
|
||||
componentName = dbEntity.CmpntName;
|
||||
procedure = dbEntity.Procedure;
|
||||
|
||||
if (tmp != null) tmp.CopyContentTo(this);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public ProcedureParams()
|
||||
{
|
||||
}
|
||||
|
||||
public ProcedureParams(bool initialize)
|
||||
{
|
||||
if (initialize) InitializeAll();
|
||||
}
|
||||
|
||||
public ProcedureParams(ComponentProcedure procedureParamsEntity, string componentName, Procedure procedure)
|
||||
{
|
||||
this.procedureParamsEntity = procedureParamsEntity;
|
||||
this.componentName = componentName;
|
||||
this.procedure = procedure;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -567,10 +567,6 @@ namespace TBF.BenchControl.Sequences
|
||||
int[] waterMeterParts = new int[waterMetersCount];
|
||||
for (int wmNr = 0; wmNr < waterMetersCount; wmNr++)
|
||||
{
|
||||
/// WR10 .. WR15 configuration specific code (iPerl head component name)
|
||||
TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead.IperlHead iHead =
|
||||
TbfComponents.FindComponent(string.Format("iPerl{0}", wmNr + 1)) as TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead.IperlHead;
|
||||
|
||||
int ix = compound ? (2 * wmNr) : wmNr;
|
||||
if (WaterMeters.Count > ix)
|
||||
{
|
||||
@ -610,7 +606,7 @@ namespace TBF.BenchControl.Sequences
|
||||
Compound = compound,
|
||||
HeatMeter = heatMeters,
|
||||
#if ORACLE_DB
|
||||
WMTypeId = (iHead != null) ? iHead.WMType_ID : 0,
|
||||
WMTypeId = (ProcessData.OracleDB != null) ? ProcessData.OracleDB.WMTypeId : 0,
|
||||
#endif
|
||||
};
|
||||
}
|
||||
|
||||
@ -984,6 +984,7 @@
|
||||
<DependentUpon>DatabaseCfgCtrl.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="BenchControl\Output\DB\SensusOracle\Factory.cs" />
|
||||
<Compile Include="BenchControl\Output\DB\SensusOracle\ProcedureParams.cs" />
|
||||
<Compile Include="BenchControl\Output\Enums.cs" />
|
||||
<Compile Include="BenchControl\Output\EventTriggers\Iperl\Factory.cs" />
|
||||
<Compile Include="BenchControl\Output\EventTriggers\Iperl\Trigger.cs" />
|
||||
|
||||
@ -318,15 +318,16 @@ namespace TBF.UI.Procedures
|
||||
IList<IComponent> other = new List<IComponent>();
|
||||
foreach (var cmpnt in TbfComponents)
|
||||
{
|
||||
if (cmpnt is TBF.BenchControl.Modbus.Easytherm.Easytherm) other.Add(cmpnt);
|
||||
}
|
||||
if (cmpnt is TBF.BenchControl.Output.DB.SensusOracle.Database) other.Add(cmpnt);
|
||||
if (cmpnt is TBF.BenchControl.Modbus.Easytherm.Easytherm) other.Add(cmpnt);
|
||||
}
|
||||
|
||||
if (other.Count > 0)
|
||||
{
|
||||
ProcedureParamsCtrl newCtrl = new ProcedureParamsCtrl(this, other, false);
|
||||
procedureParamsCtrls.Add(newCtrl);
|
||||
|
||||
TabPage newTab = new TabPage(Strings.Temperature);
|
||||
TabPage newTab = new TabPage("More...");
|
||||
newTab.Controls.Add(newCtrl);
|
||||
newTab.Tag = newCtrl;
|
||||
tabControl.TabPages.Add(newTab);
|
||||
|
||||
@ -172,13 +172,14 @@ namespace TBF.UI.ResultsMI
|
||||
TBF.BenchControl.Output.DB.SensusOracle.DatabaseCfg cfg = TBF.BenchControl.ComponentCfgBase.CreateFromDbEntity(DatabaseCfg.Serializer, cmpntEntities[0], null)
|
||||
as TBF.BenchControl.Output.DB.SensusOracle.DatabaseCfg;
|
||||
|
||||
MessageBox.Show(string.Format("Výsledky budú zapísané do '{0}' databázy", cfg.DBUsed),
|
||||
/// TODO: Implement database selection
|
||||
MessageBox.Show(string.Format("Výsledky budú zapísané do produkčnej databázy"),
|
||||
Strings.Information,
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Information);
|
||||
|
||||
OracleConnection conn;
|
||||
switch (cfg.DBUsed)
|
||||
switch (DBUsed.Production)
|
||||
{
|
||||
default:
|
||||
case DBUsed.Production:
|
||||
@ -192,6 +193,7 @@ namespace TBF.UI.ResultsMI
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if ((TBF.BenchControl.Sequences.ProcessData.OracleDB != null) &&
|
||||
(TBF.BenchControl.Sequences.ProcessData.OracleDB.WriteResultsToDB(conn, b, true) == Retv.OK))
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user