68 lines
2.1 KiB
C#
68 lines
2.1 KiB
C#
///
|
|
/// Copyright (c) 2017 Sensus Metering Systems
|
|
///
|
|
using System.Collections.Generic;
|
|
using log4net;
|
|
using Config.Entities;
|
|
using TBF.UiBridge;
|
|
|
|
namespace TBF.BenchControl.TestMethods.LiveStream
|
|
{
|
|
public class LiveStreamSeq : Sequences.SequenceBase
|
|
{
|
|
private static readonly ILog log = LogManager.GetLogger(typeof(LiveStreamSeq));
|
|
|
|
|
|
public IList<Event> Execute(Test test, bool hiResolution)
|
|
{
|
|
IList<Event> e = new List<Event>(); /// Events from currently running operations
|
|
Event retVal = Event.Done;
|
|
|
|
/// Operations
|
|
checkUiOp = new Operations.CheckUIOp(true);
|
|
|
|
IList<GenericDevices.ICamera> cameras = new List<GenericDevices.ICamera>();
|
|
IList<IOperation> liveStreamOps = new List<IOperation>();
|
|
|
|
foreach (var rr in sensPath.RegisterReaders)
|
|
{
|
|
if (rr is GenericDevices.IRoiForFixedStart)
|
|
{
|
|
GenericDevices.ICamera camera = (rr as GenericDevices.IRoiForFixedStart).Camera;
|
|
if (!cameras.Contains(camera))
|
|
{
|
|
cameras.Add(camera);
|
|
liveStreamOps.Add(camera.LiveStreamOp(hiResolution));
|
|
}
|
|
}
|
|
}
|
|
|
|
//------------------------------------------------
|
|
Bridge.OnActivity(this, test.Method);
|
|
//------------------------------------------------
|
|
State.Create(string.Format("{0}({1}) : Live stream", test.Method, test.Name))
|
|
.AddOperation(checkUiOp)
|
|
.AddOperation(new Operations.MessageBoxOp(TBF.Resources.Strings.Camera))
|
|
.AddOperations(liveStreamOps)
|
|
.EnterState();
|
|
do
|
|
{
|
|
e = StateMachine.WaitRunDevsRunOps();
|
|
|
|
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, 1, Config.Entities.Progress.Test));
|
|
|
|
if (e.Contains(Event.Error)) { retVal = Event.Error; break; }
|
|
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; break; }
|
|
}
|
|
while (!e.Contains(Event.OK));
|
|
|
|
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, 1, Config.Entities.Progress.Completed));
|
|
|
|
/// Create a list with one item 'retVal' (default is Event.Done) and return it
|
|
IList<Event> retList = new List<Event>(1);
|
|
retList.Add(retVal);
|
|
return retList;
|
|
}
|
|
}
|
|
}
|