Bug fixes.

Oracle DB: In the vt_zaehler_pindex_pd.korrimprate should be new CalibFactor, not OrigCalibFactor (Joern Goegge)
This commit is contained in:
Jan Augustin 2024-03-28 08:53:39 +01:00
parent 60f30d65fd
commit c77fd822a6
6 changed files with 48 additions and 25 deletions

View File

@ -14,6 +14,7 @@ using Users;
using TBF.Resources;
using TBF.Rig.Sequences;
using TBF.UI.Shared;
using System.Threading;
namespace TBF
{
@ -69,7 +70,9 @@ namespace TBF
[STAThread]
static void Main()
{
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(MyHandler);
Application.ThreadException += new ThreadExceptionEventHandler(Form1_UIThreadException);
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(MyHandler);
/// Program version string
System.Reflection.Assembly thisAssembly = System.Reflection.Assembly.GetExecutingAssembly();
@ -536,7 +539,12 @@ namespace TBF
log.Info("Exiting application.");
}
static void MyHandler(object sender, UnhandledExceptionEventArgs args)
private static void Form1_UIThreadException(object sender, ThreadExceptionEventArgs e)
{
LogException(log, "Unhandled thread exception", (Exception)e.Exception);
}
static void MyHandler(object sender, UnhandledExceptionEventArgs args)
{
LogException(log, "Unhandled exception", (Exception)args.ExceptionObject);
}

View File

@ -1066,7 +1066,7 @@ namespace TBF.Rig.Output.DB.SensusOracle
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Int32, Value = dbCfg.TestBenchGroupId + 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.Double, Value = wm.CalibFactor }); // korrimprate - should be new calib.factor, not wm.OrigCalibFactor
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Int32, Value = 0 }); /// TODO: pressure test
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Int32, Value = wm.WMPosition });
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Int32, Value = wm.Passed ? 1 : 0 });
@ -1299,7 +1299,7 @@ namespace TBF.Rig.Output.DB.SensusOracle
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Int32, Value = dbCfg.TestBenchGroupId + 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.Double, Value = wm.CalibFactor });
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 });

View File

@ -2064,8 +2064,8 @@ namespace TBF.Rig.Sequences
log.FatalFormat(" Feeding path: {0}", (inPath != null) ? inPath.ToString() : "none");
log.FatalFormat(" Bench path: {0}", (benchPath != null) ? benchPath.ToString() : "none");
log.FatalFormat(" Output path: {0}", (outPath != null) ? outPath.ToString() : "none");
if (inPath.Pump is IPump) log.FatalFormat(" Pump power: {0}%", (inPath.Pump as IPump).Power);
else if (inPath.Pump is IValve) log.FatalFormat(" Feeding valve: {0}", (inPath.Pump as IValve).State ? "open" : "close");
if (inPath != null && inPath.Pump is IPump) log.FatalFormat(" Pump power: {0}%", (inPath.Pump as IPump).Power);
else if (inPath != null && inPath.Pump is IValve) log.FatalFormat(" Feeding valve: {0}", (inPath.Pump as IValve).State ? "open" : "close");
if (outPath.RegulValve is IRegValve) log.FatalFormat(" Regulation valve position: {0}%", outPath.RegulValve.Position);
log.FatalFormat(" Flow: {0}", RefFlow);
log.FatalFormat(" Mass: {0}", Mass);

View File

@ -17,8 +17,6 @@ using Config.Entities;
using TBF.Resources;
using TBF.Rig.Sequences;
using TBF.Rig.TestMethods.iPerlCommunication.iPerlHead;
using Sensus.iPerl.RfidCom;
using Sensus.iPerl.RfidCom.Helper;
using Results.Entities;
using static Sensus.iPerl.NfcHandler.MCI_Protocol;

View File

@ -17,6 +17,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
{
for (int i = 0; i < cfg.MaxCommRetries; i++)
{
rfidDataLogger.Error($"{iperlHead.CommInterface} Start {i} reading: COM{iperlHead.RfidComPortNr}: ReadRequestPort ({messageID},{offset}, {length}... timeout {cfg.CommTimeout})");
using (RfidLogic writer = new RfidLogic($"COM{iperlHead.RfidComPortNr}"))
{
try
@ -86,6 +87,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
for (var i = 0; i < cfg.MaxCommRetries; i++)
{
rfidDataLogger.Error($"{iperlHead.CommInterface} Start {i} writting: COM{iperlHead.RfidComPortNr}: WriteRequest ({messageID},{offset}, {length}, {payload}... timeout {cfg.CommTimeout})");
try
{
if (writer.ClosePort()) writer.OpenPort();

View File

@ -1,4 +1,7 @@
namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
using System;
using System.Linq;
namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
{
internal class SimulationServices
{
@ -6,25 +9,18 @@
internal static int ReadRequest(TestMethodCfg cfg, IperlHead iperlHead, MessageID messageID, int offset, int length, out byte[] buffer)
{
if ((messageID == MessageID.Configuration) && (offset == 0) && (length == ConfigStruct.Length))
byte[] configurationBuffer = new byte[ConfigStruct.Length] { 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 160, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
byte[] calibrationBuffer = new byte[CalibrationStructV4.Length] { 3, 0, 150, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 0, 0, 150, 10 };
buffer = new byte[length];
if (messageID == MessageID.Configuration)
{
buffer = new byte[ConfigStruct.Length] { 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 160, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
Array.Copy(GetPCB(iperlHead), 0, configurationBuffer, 16, 5); // set PCB Number according to iPerlHead configuration
Array.Copy(configurationBuffer,offset,buffer,0,length);
}
else if ((messageID == MessageID.Calibration) && (offset == 0) && (length == CalibrationStruct.Length))
else if (messageID == MessageID.Calibration)
{
buffer = new byte[CalibrationStruct.Length] { 3, 0, 150, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 0, 0 };
}
else if ((messageID == MessageID.Calibration) && (offset == 0) && (length == CalibrationStructV4.Length))
{
buffer = new byte[CalibrationStructV4.Length] { 3, 0, 150, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 0, 0, 150, 10 };
}
else if ((messageID == MessageID.Calibration) && (offset == 2) && (length == 2))
{
buffer = new byte[2] { 150, 10 };
}
else if ((messageID == MessageID.Calibration) && (offset == 34) && (length == 2))
{
buffer = new byte[2] { 150, 10 };
Array.Copy(calibrationBuffer, offset, buffer, 0, length);
}
else if ((messageID == MessageID.MetrologyMemory) && (offset == Q2CorrFactorsAddr) && (length == 2))
{
@ -42,5 +38,24 @@
{
return 0;
}
private static Array GetPCB(IperlHead iperlHead)
{
string pcbStr = iperlHead.RfidComPortNr.ToString().PadRight(10,'0') + iperlHead.Position.ToString("D2");
long decVal = Convert.ToInt64(pcbStr);
string nHexStr = decVal.ToString("X4");
string hexStr = "";
for (int a = nHexStr.Length; a >= 1; a = a - 2)
{
hexStr = hexStr + nHexStr.Substring(a - 2, 2);
}
return Enumerable.Range(0, hexStr.Length)
.Where(x => x % 2 == 0)
.Select(x => Convert.ToByte(hexStr.Substring(x, 2), 16))
.ToArray();
}
}
}