Preparation for remote sharing of procedures, ver. 2.18.920
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
using System.Threading;
|
||||
using log4net;
|
||||
using NHibernate;
|
||||
@@ -39,11 +40,20 @@ namespace TBF.BenchControl.Operations
|
||||
|
||||
void Loader()
|
||||
{
|
||||
StateMachine.LoadProcedure(false);
|
||||
try
|
||||
{
|
||||
ISession session = Config.FluentCommon.CreateSession(Users.Entities.DBKind.Config);
|
||||
StateMachine.LoadPathsAndTransitions(session);
|
||||
StateMachine.LoadProcedure(session);
|
||||
StateMachine.LoadProcedureParams(StateMachine.Procedure);
|
||||
|
||||
completed = true;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
error = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Run this operation</summary>
|
||||
/// <returns>
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using log4net;
|
||||
using NHibernate;
|
||||
using Config;
|
||||
using Config.Entities;
|
||||
using Results.Entities;
|
||||
@@ -34,7 +35,7 @@ namespace TBF.BenchControl.Sequences
|
||||
IList<Config.Entities.Test> simultWithEvacuationTests;
|
||||
IList<Generic.ITestParams> simultWithEvacuationParams;
|
||||
|
||||
|
||||
IList<ComponentTest> testParamsForCurrentProcedure;
|
||||
|
||||
System.Windows.Forms.Form modelessDlg;
|
||||
///
|
||||
@@ -108,7 +109,8 @@ namespace TBF.BenchControl.Sequences
|
||||
Selection selection;
|
||||
string selectedTestName;
|
||||
|
||||
StateMachine.LoadProcedure(true); // TODO: Implement as an operation so that the worker thread is not blocked
|
||||
ISession session = Config.FluentCommon.CreateSession(Users.Entities.DBKind.Config);
|
||||
StateMachine.LoadPathsAndTransitions(session); // TODO: Implement as an operation so that the worker thread is not blocked
|
||||
|
||||
Bridge.OnActivity(this, Strings.Starting_system);
|
||||
State.Create("MainSeq : Press OK to start the system")
|
||||
@@ -311,15 +313,38 @@ namespace TBF.BenchControl.Sequences
|
||||
default: selectedTestName = Bridge.SelectedTestName; break;
|
||||
}
|
||||
|
||||
UiBridge.Bridge.OnError(this, string.Empty); /// Clear an error message (if any)
|
||||
StateMachine.LoadProcedure(false);
|
||||
///
|
||||
/// Load all parameters for this procedure from DB
|
||||
///
|
||||
try
|
||||
{
|
||||
ISession sesn = Config.FluentCommon.CreateSession(Users.Entities.DBKind.Config);
|
||||
|
||||
StateMachine.LoadPathsAndTransitions(sesn);
|
||||
StateMachine.LoadProcedure(sesn);
|
||||
StateMachine.LoadProcedureParams(StateMachine.Procedure);
|
||||
|
||||
testParamsForCurrentProcedure = new List<ComponentTest>();
|
||||
foreach (var test in StateMachine.Tests)
|
||||
{
|
||||
IList<ComponentTest> testParams = sesn.QueryOver<ComponentTest>()
|
||||
.Where(x => (x.Test == test))
|
||||
.List();
|
||||
foreach (var tp in testParams) testParamsForCurrentProcedure.Add(tp);
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
StateMachine.Procedure = null;
|
||||
}
|
||||
}
|
||||
while (StateMachine.Procedure == null); /// Make sure a valid procedure is selected
|
||||
|
||||
UiBridge.Bridge.OnError(this, string.Empty); /// Clear an error message (if any)
|
||||
|
||||
///
|
||||
/// Procedure selected at this point, a new batch was started
|
||||
///
|
||||
StateMachine.LoadProcedureParams(StateMachine.Procedure);
|
||||
StateMachine.ControlBoard.ManualUIAllowed = !StateMachine.Procedure.ManualCtrlDisabled;
|
||||
|
||||
Bridge.Bench2UI(ButtonsEtc.StopBtnEn); /// Enable STOP button
|
||||
@@ -493,9 +518,9 @@ namespace TBF.BenchControl.Sequences
|
||||
WaterMeter newWM = BatchRslts.WaterMeters[i];
|
||||
for (int j = 0; j < Results.DBase.Count; j++)
|
||||
{
|
||||
NHibernate.ISession session = Results.DBase.Databases[j].OpenSession();
|
||||
NHibernate.ISession sesn = Results.DBase.Databases[j].OpenSession();
|
||||
|
||||
IList<WaterMeter> watermeters = session.QueryOver<WaterMeter>().Where(x => (x.SerialNr == newWM.SerialNr)).List();
|
||||
IList<WaterMeter> watermeters = sesn.QueryOver<WaterMeter>().Where(x => (x.SerialNr == newWM.SerialNr)).List();
|
||||
if (watermeters.Count > 0)
|
||||
{
|
||||
BatchRslts.WaterMeters[i].CopyContentFrom(watermeters[watermeters.Count - 1]); /// Copy results from the last occurance of the watermeter
|
||||
@@ -670,7 +695,7 @@ namespace TBF.BenchControl.Sequences
|
||||
ITestMethod testMethod = testMethodComp as ITestMethod;
|
||||
if (testMethod != null && testMethod.CanTest(StateMachine.Procedure.MetersKind))
|
||||
{
|
||||
StateMachine.LoadTestParams(test);
|
||||
StateMachine.LoadTestParams(test, testParamsForCurrentProcedure);
|
||||
ProcessData.RegisterReaders = sensPath.RegisterReaders;
|
||||
if (isOuterLoopMode && outerLoopRepeats != test.Repeats && !(testMethod is TestMethods.OuterLoop.End.Component))
|
||||
{
|
||||
@@ -816,7 +841,7 @@ namespace TBF.BenchControl.Sequences
|
||||
|
||||
if (testMethod != null && testMethod.CanTest(StateMachine.Procedure.MetersKind))
|
||||
{
|
||||
StateMachine.LoadTestParams(dfrrdData.Test);
|
||||
StateMachine.LoadTestParams(dfrrdData.Test, testParamsForCurrentProcedure);
|
||||
ProcessData.RegisterReaders = sensPath.RegisterReaders;
|
||||
|
||||
foreach (var rr in sensPath.RegisterReaders)
|
||||
@@ -871,7 +896,7 @@ namespace TBF.BenchControl.Sequences
|
||||
ITestMethod testMethod = TbfComponents.FindComponent(test.Method) as ITestMethod;
|
||||
if (testMethod != null && testMethod.CanTest(StateMachine.Procedure.MetersKind))
|
||||
{
|
||||
StateMachine.LoadTestParams(test);
|
||||
StateMachine.LoadTestParams(test, testParamsForCurrentProcedure);
|
||||
ProcessData.RegisterReaders = sensPath.RegisterReaders;
|
||||
|
||||
foreach (var rr in sensPath.RegisterReaders)
|
||||
|
||||
@@ -384,9 +384,12 @@ namespace TBF.BenchControl
|
||||
stateMachineRunning = true;
|
||||
}
|
||||
|
||||
public static void LoadProcedure(bool loadPathsOnly)
|
||||
/// <summary>
|
||||
/// Loads all paths and transitions from the DB.
|
||||
/// Updates StatMachine.feedingPaths ... StatMachine.meterPaths, StatMachine.TransitionSequences
|
||||
/// </summary>
|
||||
public static void LoadPathsAndTransitions(ISession session)
|
||||
{
|
||||
ISession session = Config.FluentCommon.CreateSession(Users.Entities.DBKind.Config);
|
||||
WtSession = session;
|
||||
|
||||
feedingPaths = session.QueryOver<Config.Entities.FeedingPath>().OrderBy(x => x.ItemNr).Asc.List();
|
||||
@@ -397,18 +400,27 @@ namespace TBF.BenchControl
|
||||
#if HEAT_METERS
|
||||
heatMetersPaths = session.QueryOver<Config.Entities.HeatMetersPath>().OrderBy(x => x.ItemNr).Asc.List();
|
||||
#endif
|
||||
}
|
||||
|
||||
if (loadPathsOnly) return;
|
||||
/// <summary>
|
||||
/// Loads selected procedure from the DB.
|
||||
/// Updates StateMachine.Procedure and StateMachine.Tests
|
||||
/// </summary>
|
||||
public static bool LoadProcedure(ISession session)
|
||||
{
|
||||
WtSession = session;
|
||||
|
||||
IList<Procedure> selectedProcs = session.QueryOver<Procedure>()
|
||||
.Where(x => (x.ProcedureState == ProcedureState.Active))
|
||||
.And(x => (x.Name == TBF.UiBridge.Bridge.SelectedProcedureName))
|
||||
.List();
|
||||
|
||||
if (selectedProcs.Count != 1) return;
|
||||
if (selectedProcs.Count != 1) return false;
|
||||
|
||||
Procedure = selectedProcs[0];
|
||||
Tests = selectedProcs[0].Tests;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void LoadProcedureParams(Procedure procedure)
|
||||
@@ -419,7 +431,7 @@ namespace TBF.BenchControl
|
||||
}
|
||||
}
|
||||
|
||||
public static void LoadTestParams(Test test)
|
||||
public static void LoadTestParams(Test test, IList<ComponentTest> bufferedTestParams)
|
||||
{
|
||||
foreach (var cmpnt in components)
|
||||
{
|
||||
|
||||
@@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
[assembly: AssemblyVersion("2.18.918.0")]
|
||||
[assembly: AssemblyFileVersion("2.18.918.0")]
|
||||
[assembly: AssemblyVersion("2.18.920.0")]
|
||||
[assembly: AssemblyFileVersion("2.18.920.0")]
|
||||
|
||||
Reference in New Issue
Block a user