Use of remote database for procedures/tests, part 2.
This commit is contained in:
parent
6020d6e4eb
commit
76053d466b
@ -19,10 +19,11 @@ namespace TBF.BenchControl.BenchInfo.Extended
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(Component));
|
||||
public override string ToString() { return string.Format("BenchInfoEx({0})", Cfg.ToString(1)); }
|
||||
|
||||
public readonly ComponentCfg BenchInfoCfg;
|
||||
readonly ComponentCfg myCfg;
|
||||
|
||||
public string TestBenchName { get { return BenchInfoCfg.TestBenchName; } }
|
||||
public int TestBenchId { get { return BenchInfoCfg.TestBenchId; } }
|
||||
public string TestBenchName { get { return myCfg.TestBenchName; } }
|
||||
public int TestBenchId { get { return myCfg.TestBenchId; } }
|
||||
public RemoteDBUse RemoteDBUse { get { return myCfg.RemoteDBUse; } }
|
||||
|
||||
public Component()
|
||||
{
|
||||
@ -31,7 +32,7 @@ namespace TBF.BenchControl.BenchInfo.Extended
|
||||
public Component(Generic.IComponentCfg cfg)
|
||||
: base(cfg)
|
||||
{
|
||||
BenchInfoCfg = cfg as ComponentCfg;
|
||||
myCfg = cfg as ComponentCfg;
|
||||
log.Debug(this.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
/// Author: Milan Hanajík
|
||||
/// Copyright (c) 2013-2018 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -24,6 +23,7 @@ namespace TBF.BenchControl.BenchInfo.Munich
|
||||
|
||||
public string TestBenchName { get { return benchInfoCfg.TestBenchName; } }
|
||||
public int TestBenchId { get { return benchInfoCfg.TestBenchId; } }
|
||||
public RemoteDBUse RemoteDBUse { get { return RemoteDBUse.LocalDBOnly; } }
|
||||
|
||||
public Component()
|
||||
{
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
/// Copyright (c) 2015 Sensus Metering Systems
|
||||
/// Author: Milan Hanajík
|
||||
///
|
||||
using Config.Entities;
|
||||
using TBF.BenchControl.Generic;
|
||||
|
||||
namespace TBF.BenchControl.GenericDevices
|
||||
@ -13,5 +14,6 @@ namespace TBF.BenchControl.GenericDevices
|
||||
{
|
||||
string TestBenchName { get; }
|
||||
int TestBenchId { get; }
|
||||
RemoteDBUse RemoteDBUse { get; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -36,8 +36,6 @@ namespace TBF.BenchControl.Sequences
|
||||
IList<Config.Entities.Test> simultWithEvacuationTests;
|
||||
IList<Generic.ITestParams> simultWithEvacuationParams;
|
||||
|
||||
IList<ComponentTest> testParamsForCurrentProcedure;
|
||||
|
||||
System.Windows.Forms.Form modelessDlg;
|
||||
///
|
||||
delegate void iPerlCommFormDlgt(MainSeq myRef, Generic.IComponentCfg cfg, IList<Test> tests, IList<Generic.ITestParams> multiTestParams);
|
||||
@ -323,54 +321,55 @@ namespace TBF.BenchControl.Sequences
|
||||
}
|
||||
catch (Exception) { continue; }
|
||||
|
||||
#if (TURA_IPERL || TURA_SPECIAL)
|
||||
///
|
||||
/// Try to load all parameters for this procedure from a remote DB
|
||||
///
|
||||
try
|
||||
{
|
||||
using (ISession remoteOrLocalSession = Config.FluentCommon.CreateSession(Users.Entities.DBKind.RemoteConfig))
|
||||
{
|
||||
StateMachine.LoadProcedure(remoteOrLocalSession);
|
||||
StateMachine.LoadProcedureParams(StateMachine.Procedure);
|
||||
|
||||
/// This is to load Procedure.Tests and tets.MoreParams for each test
|
||||
int a = 0;
|
||||
foreach (var test in StateMachine.Procedure.Tests) a += test.MoreParams.Count;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
Users.Entities.DBKind[] configDBs;
|
||||
///
|
||||
if (BenchInfo == null || BenchInfo.RemoteDBUse == RemoteDBUse.LocalDBOnly)
|
||||
{
|
||||
StateMachine.Procedure = null;
|
||||
configDBs = new Users.Entities.DBKind[] { Users.Entities.DBKind.Config };
|
||||
}
|
||||
else if (BenchInfo.RemoteDBUse == RemoteDBUse.RemoteDBOnly)
|
||||
{
|
||||
configDBs = new Users.Entities.DBKind[] { Users.Entities.DBKind.RemoteConfig };
|
||||
}
|
||||
else if (BenchInfo.RemoteDBUse == RemoteDBUse.BothDBsLocalFirst)
|
||||
{
|
||||
configDBs = new Users.Entities.DBKind[] { Users.Entities.DBKind.Config, Users.Entities.DBKind.RemoteConfig };
|
||||
}
|
||||
else if (BenchInfo.RemoteDBUse == RemoteDBUse.BothDBsRemoteFirst)
|
||||
{
|
||||
configDBs = new Users.Entities.DBKind[] { Users.Entities.DBKind.RemoteConfig, Users.Entities.DBKind.Config };
|
||||
}
|
||||
else
|
||||
{
|
||||
configDBs = new Users.Entities.DBKind[] { Users.Entities.DBKind.Config };
|
||||
}
|
||||
|
||||
if (StateMachine.Procedure != null) break;
|
||||
#endif
|
||||
///
|
||||
/// Try to load all parameters for this procedure from the local DB
|
||||
/// Try to load all parameters for the selected procedure from databases as specifie in BenchInfo
|
||||
///
|
||||
try
|
||||
foreach (var cfgDb in configDBs)
|
||||
{
|
||||
using (ISession localSession = Config.FluentCommon.CreateSession(Users.Entities.DBKind.Config))
|
||||
try
|
||||
{
|
||||
StateMachine.LoadPathsAndTransitions(localSession);
|
||||
}
|
||||
/// TODO: Repeate twice for Users.Entities.DBKind.Config and Users.Entities.DBKind.RemoteConfig
|
||||
using (ISession remoteOrLocalSession = Config.FluentCommon.CreateSession(Users.Entities.DBKind.Config))
|
||||
{
|
||||
StateMachine.LoadProcedure(remoteOrLocalSession);
|
||||
StateMachine.LoadProcedureParams(StateMachine.Procedure);
|
||||
|
||||
/// TODO: Repeate twice for Users.Entities.DBKind.Config and Users.Entities.DBKind.RemoteConfig
|
||||
using (ISession remoteOrLocalSession = Config.FluentCommon.CreateSession(Users.Entities.DBKind.Config))
|
||||
/// This is to load Procedure.Tests and tets.MoreParams for each test
|
||||
int a = 0;
|
||||
foreach (var test in StateMachine.Procedure.Tests) a += test.MoreParams.Count;
|
||||
}
|
||||
|
||||
if (StateMachine.Procedure != null) break;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
StateMachine.LoadProcedure(remoteOrLocalSession);
|
||||
StateMachine.LoadProcedureParams(StateMachine.Procedure);
|
||||
|
||||
/// This is to load Procedure.Tests and tets.MoreParams for each test
|
||||
int a = 0;
|
||||
foreach (var test in StateMachine.Procedure.Tests) a += test.MoreParams.Count;
|
||||
StateMachine.Procedure = null;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
StateMachine.Procedure = null;
|
||||
}
|
||||
}
|
||||
while (StateMachine.Procedure == null); /// Make sure a valid procedure is selected
|
||||
|
||||
@ -737,7 +736,7 @@ namespace TBF.BenchControl.Sequences
|
||||
ITestMethod testMethod = testMethodComp as ITestMethod;
|
||||
if (testMethod != null && testMethod.CanTest(StateMachine.Procedure.MetersKind))
|
||||
{
|
||||
StateMachine.LoadTestParams(test, testParamsForCurrentProcedure);
|
||||
StateMachine.LoadTestParams(test);
|
||||
ProcessData.RegisterReaders = sensPath.RegisterReaders;
|
||||
if (isOuterLoopMode && outerLoopRepeats != test.Repeats && !(testMethod is TestMethods.OuterLoop.End.Component))
|
||||
{
|
||||
@ -883,7 +882,7 @@ namespace TBF.BenchControl.Sequences
|
||||
|
||||
if (testMethod != null && testMethod.CanTest(StateMachine.Procedure.MetersKind))
|
||||
{
|
||||
StateMachine.LoadTestParams(dfrrdData.Test, testParamsForCurrentProcedure);
|
||||
StateMachine.LoadTestParams(dfrrdData.Test);
|
||||
ProcessData.RegisterReaders = sensPath.RegisterReaders;
|
||||
|
||||
foreach (var rr in sensPath.RegisterReaders)
|
||||
@ -938,7 +937,7 @@ namespace TBF.BenchControl.Sequences
|
||||
ITestMethod testMethod = TbfComponents.FindComponent(test.Method) as ITestMethod;
|
||||
if (testMethod != null && testMethod.CanTest(StateMachine.Procedure.MetersKind))
|
||||
{
|
||||
StateMachine.LoadTestParams(test, testParamsForCurrentProcedure);
|
||||
StateMachine.LoadTestParams(test);
|
||||
ProcessData.RegisterReaders = sensPath.RegisterReaders;
|
||||
|
||||
foreach (var rr in sensPath.RegisterReaders)
|
||||
|
||||
@ -427,7 +427,7 @@ namespace TBF.BenchControl
|
||||
}
|
||||
}
|
||||
|
||||
public static void LoadTestParams(Test test, IList<ComponentTest> bufferedTestParams)
|
||||
public static void LoadTestParams(Test test)
|
||||
{
|
||||
foreach (var cmpnt in components)
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user