79 lines
1.5 KiB
C#
79 lines
1.5 KiB
C#
///
|
|
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
|
///
|
|
using System.Threading;
|
|
using log4net;
|
|
using NHibernate;
|
|
|
|
namespace TBF.BenchControl.Operations
|
|
{
|
|
public class LoadProcedureOp : IOperation
|
|
{
|
|
private static readonly ILog log = LogManager.GetLogger(typeof(LoadProcedureOp));
|
|
|
|
Thread loaderThread;
|
|
bool error;
|
|
bool completed;
|
|
|
|
/// <summary>
|
|
/// Events: Wait, ProcedureLoaded or Error
|
|
/// </summary>
|
|
public LoadProcedureOp()
|
|
{
|
|
error = false;
|
|
completed = false;
|
|
}
|
|
|
|
/// <summary>Start this operation</summary>
|
|
public void Start()
|
|
{
|
|
if (loaderThread != null)
|
|
{
|
|
error = true;
|
|
return;
|
|
}
|
|
|
|
loaderThread = new Thread(Loader);
|
|
loaderThread.Start();
|
|
}
|
|
|
|
void Loader()
|
|
{
|
|
StateMachine.LoadProcedure(false);
|
|
StateMachine.LoadProcedureParams(StateMachine.Procedure);
|
|
|
|
completed = true;
|
|
}
|
|
|
|
/// <summary>Run this operation</summary>
|
|
/// <returns>
|
|
/// Event.Error, Event.ProcedureLoaded or Event.Wait
|
|
/// </returns>
|
|
public Event Run()
|
|
{
|
|
if (error) return Event.Error;
|
|
if (!completed) return Event.Wait;
|
|
|
|
///
|
|
/// Check for incomplete configuration mistakes
|
|
///
|
|
if (StateMachine.Tests.Count == 0) return Event.ConfigurationError;
|
|
foreach (var test in StateMachine.Tests)
|
|
{
|
|
if (test.FeedingPath == null || test.BenchPath == null ||
|
|
test.OutputPath == null || test.MetersPath == null)
|
|
{
|
|
return Event.ConfigurationError;
|
|
}
|
|
}
|
|
|
|
return Event.ProcedureLoaded;
|
|
}
|
|
|
|
/// <summary>Stop this operation</summary>
|
|
public void Stop()
|
|
{
|
|
}
|
|
}
|
|
}
|