Changes for Xylem Nanjing, ver. 3.1.1676

This commit is contained in:
Milan Hanajik
2021-06-18 15:35:46 +02:00
parent f1ef16e1a3
commit 827a9f7c58
837 changed files with 46518 additions and 5851 deletions
+109 -49
View File
@@ -6,6 +6,7 @@ using System.Collections.Generic;
using System.Diagnostics;
using log4net;
using NHibernate;
using Common;
using Config.Entities;
using Results.Entities;
using TBF.Rig.Operations;
@@ -27,19 +28,21 @@ namespace TBF.Rig.Sequences
int simultWithPurgingCount;
Generic.IComponentCfg simultWithPurgingCfg;
IList<Config.Entities.Test> simultWithPurgingTests;
IList<Generic.ITestParams> simultWithPurgingParams;
Generic.IProcedureParams simultWithPurgingProcParams;
IList<Config.Entities.Test> simultWithPurgingTests;
IList<Generic.ITestParams> simultWithPurgingTestParams;
int simultWithEvacuationCount;
Generic.IComponentCfg simultWithEvacuationCfg;
IList<Config.Entities.Test> simultWithEvacuationTests;
IList<Generic.ITestParams> simultWithEvacuationParams;
Generic.IProcedureParams simultWithEvacuationProcParams;
IList<Config.Entities.Test> simultWithEvacuationTests;
IList<Generic.ITestParams> simultWithEvacuationTestParams;
System.Windows.Forms.Form modelessDlg;
///
delegate void iPerlCommFormDlgt(MainSeq myRef, Generic.IComponentCfg cfg, IList<Test> tests, IList<Generic.ITestParams> multiTestParams);
///
void OpenIPerlCommForm(MainSeq myRef, Generic.IComponentCfg cfg, IList<Test> tests, IList<Generic.ITestParams> multiTestParams)
///
delegate void CommunicationFormDlgt(MainSeq myRef, Generic.IComponentCfg cfg, Generic.IProcedureParams procParams, IList<Test> tests, IList<Generic.ITestParams> multiTestParams);
///
void OpenIPerlCommForm(MainSeq myRef, Generic.IComponentCfg cfg, Generic.IProcedureParams procParams, IList<Test> tests, IList<Generic.ITestParams> multiTestParams)
{
try
{
@@ -67,12 +70,58 @@ namespace TBF.Rig.Sequences
log.Fatal("--------------------------------------");
}
}
///
void CloseIPerlCommForm()
{
UiBridge.Bridge.OnCloseModelessForm(this, null);
modelessDlg = null;
}
///
void OpenS640CommForm(MainSeq myRef, Generic.IComponentCfg cfg, Generic.IProcedureParams procParams, IList<Test> tests, IList<Generic.ITestParams> multiTestParams)
{
try
{
TestMethods.S640Communication.S640Activity activity; /// 1st argument
TBF.Rig.TestMethods.S640Communication.I640Cfg config; /// 2nd argument
if (cfg is TestMethods.S640Communication.S640StartCfg)
{
activity = TestMethods.S640Communication.S640Activity.Start;
config = (cfg as TestMethods.S640Communication.S640StartCfg);
}
else if (cfg is TestMethods.S640Communication.S640EndCfg)
{
activity = TestMethods.S640Communication.S640Activity.End;
config = (cfg as TestMethods.S640Communication.S640EndCfg);
}
else
{
return;
}
/// 1st argument
IList<TestMethods.S640Communication.S640Activity> activities = new List<TestMethods.S640Communication.S640Activity>();
foreach (var t in tests)
{
activities.Add(activity);
}
/// 2nd argument: as is
/// 3rd argument: as is
myRef.modelessDlg = new TestMethods.S640Communication.S640CommForm(activities, config, procParams, tests);
myRef.modelessDlg.Show();
}
catch (Exception e)
{
log.FatalFormat("---------------( MainSeq : OpenIperlCommForm crashed !!! )---------------");
log.FatalFormat("Message : {0}", e.Message);
if (e.InnerException != null)
{
log.FatalFormat("InnerMessage : {0}", e.InnerException.Message);
}
log.FatalFormat("StackTrace : {0}{1}", Environment.NewLine, e.StackTrace);
log.Fatal("--------------------------------------");
}
}
///
void CloseCommunicationForm()
{
UiBridge.Bridge.OnCloseModelessForm(this, null);
modelessDlg = null;
}
@@ -85,13 +134,15 @@ namespace TBF.Rig.Sequences
simultWithPurgingCount = 0;
simultWithPurgingCfg = null;
simultWithPurgingProcParams = null;
simultWithPurgingTests = new List<Config.Entities.Test>();
simultWithPurgingParams = new List<Generic.ITestParams>();
simultWithPurgingTestParams = new List<Generic.ITestParams>();
simultWithEvacuationCount = 0;
simultWithEvacuationCfg = null;
simultWithEvacuationProcParams = null;
simultWithEvacuationTests = new List<Config.Entities.Test>();
simultWithEvacuationParams = new List<Generic.ITestParams>();
simultWithEvacuationTestParams = new List<Generic.ITestParams>();
checkUiOp = new CheckUIOp(true); /// Running in almost all states
}
@@ -210,7 +261,7 @@ namespace TBF.Rig.Sequences
try
{
using (ISession localSession = Config.FluentCommon.CreateSession(Users.Entities.DBKind.Config))
using (ISession localSession = Config.FluentCommon.CreateSession(DBKind.Config))
{
StateMachine.LoadPathsAndTransitions(localSession);
}
@@ -222,10 +273,10 @@ namespace TBF.Rig.Sequences
{
/// User has chosen to restore an interrupted session and necessary conditions are met
/// TODO: Repeate twice for Users.Entities.DBKind.Config and Users.Entities.DBKind.RemoteConfig
/// TODO: Repeate twice for DBKind.Config and DBKind.RemoteConfig
using (ISession remoteOrLocalSession = Config.FluentCommon.CreateSession(isRemoteIntProc ?
Users.Entities.DBKind.RemoteConfig :
Users.Entities.DBKind.Config))
DBKind.RemoteConfig :
DBKind.Config))
{
StateMachine.LoadProcedure(remoteOrLocalSession, interruptedProcedureName, isRemoteIntProc);
StateMachine.LoadProcedureParams(StateMachine.Procedure);
@@ -235,7 +286,9 @@ namespace TBF.Rig.Sequences
foreach (var test in StateMachine.Procedure.Tests) a += test.MoreParams.Count;
}
}
else if ((Bridge.SelectedProcedure != null) && !string.IsNullOrEmpty(Bridge.SelectedProcedure.Name))
else if (Bridge.SelectedProcedure != null &&
Bridge.SelectedProcedure.ResolvedSource != ProcedureSelection.None &&
!string.IsNullOrEmpty(Bridge.SelectedProcedure.ResolvedName))
{
if (selection == Selection.Cycle)
{
@@ -252,12 +305,15 @@ namespace TBF.Rig.Sequences
}
}
/// TODO: Repeate twice for Users.Entities.DBKind.Config and Users.Entities.DBKind.RemoteConfig
using (ISession remoteOrLocalSession = Config.FluentCommon.CreateSession(Bridge.SelectedProcedure.IsRemote ?
Users.Entities.DBKind.RemoteConfig :
Users.Entities.DBKind.Config))
/// TODO: Repeate twice for DBKind.Config and DBKind.RemoteConfig
using (ISession remoteOrLocalSession = Config.FluentCommon.CreateSession((Bridge.SelectedProcedure.ResolvedSource == ProcedureSelection.FromSharedDB) ?
DBKind.RemoteConfig :
DBKind.Config))
{
StateMachine.LoadProcedure(remoteOrLocalSession, Bridge.SelectedProcedure.Name, Bridge.SelectedProcedure.IsRemote, testsInside);
StateMachine.LoadProcedure(remoteOrLocalSession,
Bridge.SelectedProcedure.ResolvedName,
(Bridge.SelectedProcedure.ResolvedSource == ProcedureSelection.FromSharedDB),
testsInside);
StateMachine.LoadProcedureParams(StateMachine.Procedure);
/// This is to load Procedure.Tests and test.MoreParams for each test
@@ -321,7 +377,7 @@ namespace TBF.Rig.Sequences
if (selection == Selection.RestoreBatch)
{
BatchRslts = CreateNewBatchResults(newBatchNr, StateMachine.Procedure);
BatchRslts = CreateNewBatchResults(newBatchNr, StateMachine.Procedure, string.Empty);
RestoreBatchResults(TBF.UiBridge.Bridge.BatchNr, ref BatchRslts); /// pass the original batch number of the batch to be restored
}
else if (selection == Selection.RestoreAndFixBatch)
@@ -329,7 +385,7 @@ namespace TBF.Rig.Sequences
///
/// Restore and fix a batch - part 1 (fix "Previous workstep is missing" error)
///
BatchRslts = CreateNewBatchResults(newBatchNr, StateMachine.Procedure);
BatchRslts = CreateNewBatchResults(newBatchNr, StateMachine.Procedure, string.Empty);
RestoreBatchResults(TBF.UiBridge.Bridge.BatchNr, ref BatchRslts); /// pass the original batch number of the batch to be restored
for (int i = 0; i < BatchRslts.Batch.WaterMeters.Count; i++)
@@ -347,10 +403,10 @@ namespace TBF.Rig.Sequences
/// Water meter failed but the failure is not an assembly error
wm.Disabled = true;
}
else if (!wm.Disabled && (Users.GlobalData.GetCurrentUserName() == "milan" ||
Users.GlobalData.GetCurrentUserName() == "augustin" ||
Users.GlobalData.GetCurrentUserName() == "michal" ||
Users.GlobalData.GetCurrentUserName() == "michal2"))
else if (!wm.Disabled && (GlobalData.GetCurrentUserName() == "milan" ||
GlobalData.GetCurrentUserName() == "augustin" ||
GlobalData.GetCurrentUserName() == "michal" ||
GlobalData.GetCurrentUserName() == "michal2"))
{
/// Water meter failed, is not disabled, there is an assembly error and user is one of above
/// ... => reset flag E28
@@ -370,7 +426,7 @@ namespace TBF.Rig.Sequences
else if (selection != Selection.RestoreInterruptedSession)
{
/// This is a regular session => initialize BatchRslts
BatchRslts = CreateNewBatchResults(newBatchNr, StateMachine.Procedure);
BatchRslts = CreateNewBatchResults(newBatchNr, StateMachine.Procedure, Bridge.SelectedProcedure.Variant);
}
@@ -462,7 +518,11 @@ namespace TBF.Rig.Sequences
/// Open iPerlCommunicationForm
ProcessData.RegisterReaders = StateMachine.GetMetersPath(simultWithPurgingTests[0]).RegisterReaders;
Program.MainWnd.Invoke(new iPerlCommFormDlgt(OpenIPerlCommForm), new object[] { this, simultWithPurgingCfg, simultWithPurgingTests, simultWithPurgingParams });
#if IPERL
Program.MainWnd.Invoke(new CommunicationFormDlgt(OpenIPerlCommForm), new object[] { this, simultWithPurgingCfg, simultWithPurgingProcParams, simultWithPurgingTests, simultWithPurgingTestParams });
#else
Program.MainWnd.Invoke(new CommunicationFormDlgt(OpenS640CommForm), new object[] { this, simultWithPurgingCfg, simultWithPurgingProcParams, simultWithPurgingTests, simultWithPurgingTestParams });
#endif
}
///
@@ -472,10 +532,10 @@ namespace TBF.Rig.Sequences
switch (evt)
{
case Event.Error:
if (simultWithPurgingCount > 0) CloseIPerlCommForm();
if (simultWithPurgingCount > 0) CloseCommunicationForm();
goto error;
case Event.UiCmdStop:
if (simultWithPurgingCount > 0) CloseIPerlCommForm();
if (simultWithPurgingCount > 0) CloseCommunicationForm();
goto stop;
default:
break;
@@ -500,7 +560,7 @@ namespace TBF.Rig.Sequences
e = StateMachine.WaitRunDevsRunOps();
if (e.Contains(Event.UiCmdStop))
{
CloseIPerlCommForm();
CloseCommunicationForm();
goto stop;
}
@@ -542,7 +602,7 @@ namespace TBF.Rig.Sequences
log.ErrorFormat("StartInfoReader failed to read data from the database");
/// TODO: Message for an operator? Error?
}
else if ((selection == Selection.RestoreAndFixBatch) && (Users.GlobalData.GetCurrentUserName() != "milan"))
else if ((selection == Selection.RestoreAndFixBatch) && (GlobalData.GetCurrentUserName() != "milan"))
{
/// Restore and fix a batch - part 2
for (int i = 0; i < BatchRslts.Batch.WaterMeters.Count; i++)
@@ -560,15 +620,15 @@ namespace TBF.Rig.Sequences
if (wm.LastRecordIsNok)
{
/// There is still a production tracing error, last record is missing
wm.ErrorFlags |= (int)Config.Entities.ErrorFlagMask.E28; /// Set E28
wm.ErrorFlags |= (int)ErrorFlagMask.E28; /// Set E28
}
else
{
/// No production tracing error, last record is OK
wm.ErrorFlags &= ~(int)Config.Entities.ErrorFlagMask.E28; /// Clear E28
wm.ErrorFlags &= ~(int)ErrorFlagMask.E28; /// Clear E28
}
if ((wm.ErrorFlags & (int)Config.Entities.ErrorFlagMask.E28) != 0)
if ((wm.ErrorFlags & (int)ErrorFlagMask.E28) != 0)
{
/// Previous workstep missing or NOK (production tracing error)
mtr.ErrorIndicators |= (int)ErrorFlagMask.E28;
@@ -864,7 +924,7 @@ namespace TBF.Rig.Sequences
int timeEstTransAfter = testMethod.DoTransitions() ? GetTransitionTimeEst(transitionAfter) : 1;
TestProgressEventArgs.SetEstimatedTimes(new int[] { 1, timeEstTransBefore, 1, 30, 0, Convert.ToInt32(testInst.Test.TestTime) + 15, timeEstTransAfter, 0 });
Bridge.OnTestProgress(this, new TestProgressEventArgs(testInst.Test, testInst.Repetition, Config.Entities.Progress.JustStarted));
Bridge.OnTestProgress(this, new TestProgressEventArgs(testInst.Test, testInst.Repetition, Progress.JustStarted));
bool currentTestFinished = true;
bool doOneMoreRepetition = false;
@@ -893,8 +953,8 @@ namespace TBF.Rig.Sequences
&& !e.Contains(Event.OpArgumentError)
&& !e.Contains(Event.UiCmdStop));
Bridge.OnTestProgress(this, new TestProgressEventArgs(testInst.Test, testInst.Repetition, currentTestFinished ? Config.Entities.Progress.Completed
: Config.Entities.Progress.Aborted));
Bridge.OnTestProgress(this, new TestProgressEventArgs(testInst.Test, testInst.Repetition, currentTestFinished ? Progress.Completed
: Progress.Aborted));
if (testMethod.DoTransitions() && !e.Contains(Event.RecoverableError))
{
@@ -1073,7 +1133,7 @@ namespace TBF.Rig.Sequences
TestProgressEventArgs.SetEstimatedTimes(new int[] { 1, timeEstTransBefore, 1, 30, 0, Convert.ToInt32(test.TestTime) + 15, timeEstTransAfter, 0 });
/// start, transition, flow detection, flow setting, aborted, test, transition, end
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetNr, Config.Entities.Progress.JustStarted));
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetNr, Progress.JustStarted));
if (testMethod.DoTransitions())
{
@@ -1096,8 +1156,8 @@ namespace TBF.Rig.Sequences
&& !e.Contains(Event.OpArgumentError)
&& !e.Contains(Event.UiCmdStop));
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetNr, testFinished ? Config.Entities.Progress.Completed
: Config.Entities.Progress.Aborted));
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetNr, testFinished ? Progress.Completed
: Progress.Aborted));
if (testMethod.DoTransitions())
{
@@ -1105,8 +1165,8 @@ namespace TBF.Rig.Sequences
rsltTransAfter = Transition(transitionAfter, endContext); /// Transition or SetRoute - end of test
}
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetNr, testFinished ? Config.Entities.Progress.Completed
: Config.Entities.Progress.Aborted));
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetNr, testFinished ? Progress.Completed
: Progress.Aborted));
}
if (rsltTransBefore == Event.Error || e.Contains(Event.Error)) goto error;