Production tracing bug fix : Previous workstep result was not checked, mere existence of a record was sufficient for a WM to pass
This commit is contained in:
@@ -35,6 +35,7 @@ namespace TBF.Rig.Output.DB.ProductionTracing
|
|||||||
public override string ToString() { return string.Format("{0}({1})", ClassName, Cfg.ToString(-1)); }
|
public override string ToString() { return string.Format("{0}({1})", ClassName, Cfg.ToString(-1)); }
|
||||||
|
|
||||||
public const string WorkstepName = "Test_bench";
|
public const string WorkstepName = "Test_bench";
|
||||||
|
public const int WorkstepRsltOK = 0;
|
||||||
|
|
||||||
MonitoringCfg tracingCfg;
|
MonitoringCfg tracingCfg;
|
||||||
string workplace
|
string workplace
|
||||||
@@ -394,22 +395,24 @@ namespace TBF.Rig.Output.DB.ProductionTracing
|
|||||||
Workstep workstep = null;
|
Workstep workstep = null;
|
||||||
|
|
||||||
ProjectionList projections = Projections.ProjectionList();
|
ProjectionList projections = Projections.ProjectionList();
|
||||||
projections.Add(Projections.Property(() => refRecord.Id)); /// rslt[0] = reference record ID
|
projections.Add(Projections.Property(() => refRecord.Id)); /// rcrd[0] = reference record ID
|
||||||
projections.Add(Projections.Property(() => workstep.Id)); /// rslt[1] = workstep ID
|
projections.Add(Projections.Property(() => workstep.Id)); /// rcrd[1] = workstep ID
|
||||||
projections.Add(Projections.Property(() => refRecord.Process.Id)); /// rslt[2] = process ID
|
projections.Add(Projections.Property(() => refRecord.Process.Id)); /// rcrd[2] = process ID
|
||||||
projections.Add(Projections.Property(() => refRecord.TimeStamp)); /// rslt[3] = reference record time stamp
|
projections.Add(Projections.Property(() => refRecord.TimeStamp)); /// rcrd[3] = reference record time stamp
|
||||||
|
projections.Add(Projections.Property(() => refRecord.Result)); /// rcrd[4] = result: =0...OK, >0...error code
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Get all reference records with Code == SerialNr from all worksteps different from 'Test_bench'
|
/// Get all reference records with Code == SerialNr from all worksteps different from 'Test_bench'
|
||||||
///
|
///
|
||||||
IList<object[]> results = session.QueryOver<ReferenceRecord>(() => refRecord)
|
IList<object[]> records = session.QueryOver<ReferenceRecord>(() => refRecord)
|
||||||
.Where(rr => (rr.Code == wm.SerialNr))
|
.Where(rr => (rr.Code == wm.SerialNr))
|
||||||
|
.OrderBy(rr => rr.TimeStamp).Asc
|
||||||
.JoinQueryOver<Workstep>(rr => rr.Workstep, () => workstep)
|
.JoinQueryOver<Workstep>(rr => rr.Workstep, () => workstep)
|
||||||
.And(ws => (ws.Name != WorkstepName))
|
.And(ws => (ws.Name != WorkstepName))
|
||||||
.Select(projections)
|
.Select(projections)
|
||||||
.List<object[]>();
|
.List<object[]>();
|
||||||
|
|
||||||
if (results.Count == 0)
|
if (records.Count == 0)
|
||||||
{
|
{
|
||||||
/// No records found
|
/// No records found
|
||||||
wm.ProcessId = 0;
|
wm.ProcessId = 0;
|
||||||
@@ -422,27 +425,18 @@ namespace TBF.Rig.Output.DB.ProductionTracing
|
|||||||
///
|
///
|
||||||
/// Get processId of the last record
|
/// Get processId of the last record
|
||||||
///
|
///
|
||||||
int processId = 0;
|
int lastProcessId = (int)records[records.Count - 1][2];
|
||||||
DateTime lastTimeStamp = DateTime.MinValue;
|
DateTime lastTimeStamp = (DateTime)records[records.Count - 1][3];
|
||||||
foreach (var rslt in results)
|
if (lastProcessId == 0) return Retv.Error; /// This should never happen
|
||||||
{
|
|
||||||
if (DateTime.Compare((DateTime)rslt[3], lastTimeStamp) > 0)
|
|
||||||
{
|
|
||||||
lastTimeStamp = (DateTime)rslt[3];
|
|
||||||
processId = (int)rslt[2];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (processId == 0) return Retv.Error; /// This should never happen
|
|
||||||
|
|
||||||
|
|
||||||
if ((currentProcess == null) || (currentProcess.Id != processId))
|
if ((currentProcess == null) || (currentProcess.Id != lastProcessId))
|
||||||
{
|
{
|
||||||
///
|
///
|
||||||
/// Process changed ==> update currentProcess / currentWorkstep / verifiedWorkstep / verifiedPart / verifyReferencePart
|
/// Process changed ==> update currentProcess / currentWorkstep / verifiedWorkstep / verifiedPart / verifyReferencePart
|
||||||
///
|
///
|
||||||
var processes = session.QueryOver<Process>()
|
var processes = session.QueryOver<Process>()
|
||||||
.Where(p => (p.Id == processId))
|
.Where(p => (p.Id == lastProcessId))
|
||||||
.List();
|
.List();
|
||||||
|
|
||||||
if (processes.Count != 1) return Retv.Error;
|
if (processes.Count != 1) return Retv.Error;
|
||||||
@@ -472,13 +466,13 @@ namespace TBF.Rig.Output.DB.ProductionTracing
|
|||||||
wm.ProcessId = currentProcess.Id;
|
wm.ProcessId = currentProcess.Id;
|
||||||
wm.SessionId = sessionId;
|
wm.SessionId = sessionId;
|
||||||
wm.LastRecordIsNok = true; /// NOK (=default if no matching record found)
|
wm.LastRecordIsNok = true; /// NOK (=default if no matching record found)
|
||||||
foreach (var rslt in results)
|
foreach (var rcrd in records)
|
||||||
{
|
{
|
||||||
if ((verifiedWorkstep.Id == (int)rslt[1]) && (processId == (int)rslt[2]))
|
if ((verifiedWorkstep.Id == (int)rcrd[1]) && (lastProcessId == (int)rcrd[2]))
|
||||||
{
|
{
|
||||||
/// This record fits verification requirements
|
/// This record fits verification requirements.
|
||||||
wm.LastRecordIsNok = false; /// OK
|
/// As records are ordered by time, the result of the last one determines the verification result.
|
||||||
break;
|
wm.LastRecordIsNok = ((int)rcrd[4] != WorkstepRsltOK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user