TestMethods.Message added.
This commit is contained in:
parent
aaa78d60db
commit
c315c8a42b
@ -100,6 +100,7 @@ namespace TBF.Rig
|
|||||||
Factories.Add(new TestMethods.LeakTest.Factory());
|
Factories.Add(new TestMethods.LeakTest.Factory());
|
||||||
Factories.Add(new TestMethods.LiveStream.Factory());
|
Factories.Add(new TestMethods.LiveStream.Factory());
|
||||||
Factories.Add(new TestMethods.ManualEntry.Factory());
|
Factories.Add(new TestMethods.ManualEntry.Factory());
|
||||||
|
Factories.Add(new TestMethods.Message.Factory());
|
||||||
Factories.Add(new TestMethods.OuterLoop.Start.Factory());
|
Factories.Add(new TestMethods.OuterLoop.Start.Factory());
|
||||||
Factories.Add(new TestMethods.OuterLoop.End.Factory());
|
Factories.Add(new TestMethods.OuterLoop.End.Factory());
|
||||||
Factories.Add(new TestMethods.PMaxTest.Factory());
|
Factories.Add(new TestMethods.PMaxTest.Factory());
|
||||||
|
|||||||
24
TBF/Rig/TestMethods/Message/Factory.cs
Normal file
24
TBF/Rig/TestMethods/Message/Factory.cs
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
///
|
||||||
|
/// Copyright (c) 2023 Sensus Slovensko a.s.
|
||||||
|
///
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using TBF.Rig.Generic;
|
||||||
|
|
||||||
|
namespace TBF.Rig.TestMethods.Message
|
||||||
|
{
|
||||||
|
public class Factory : IComponentFactory
|
||||||
|
{
|
||||||
|
public string ClassName { get { return GetType().Namespace.Substring(8); } }
|
||||||
|
|
||||||
|
public IComponent DummyComponent() { return new TestMethod(); }
|
||||||
|
|
||||||
|
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new TestMethod(cfg); }
|
||||||
|
|
||||||
|
public IComponentCfg DefaultConfig() { return new TestMethodCfg(GetType().Namespace.Substring(20), this); }
|
||||||
|
|
||||||
|
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
|
||||||
|
{
|
||||||
|
return ComponentCfgBase.CreateFromDbEntity(TestMethodCfg.Serializer, component, this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
65
TBF/Rig/TestMethods/Message/MessageSeq.cs
Normal file
65
TBF/Rig/TestMethods/Message/MessageSeq.cs
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
///
|
||||||
|
/// Copyright (c) 2023 Sensus Slovensko a.s.
|
||||||
|
///
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using log4net;
|
||||||
|
using Common;
|
||||||
|
using Config.Entities;
|
||||||
|
using TBF.UiBridge;
|
||||||
|
|
||||||
|
namespace TBF.Rig.TestMethods.Message
|
||||||
|
{
|
||||||
|
public class MessageSeq : Sequences.SequenceBase
|
||||||
|
{
|
||||||
|
private static readonly ILog log = LogManager.GetLogger(typeof(MessageSeq));
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Message method sequence
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="test">Test entity</param>
|
||||||
|
/// <returns>
|
||||||
|
/// Event.Done . . . . . . . OK
|
||||||
|
/// Event.UiCmdStop . . . . Stopped by the user using the on-screen button STOP
|
||||||
|
/// Event.OpArgumentError . Target flow is out of range
|
||||||
|
/// Event.Error . . . . . . Unspecified error
|
||||||
|
/// </returns>
|
||||||
|
public IList<Event> Execute(Test test, int repetitionNr, bool isLastRepetition, DebugMode mode, TestMethodCfg cfg)
|
||||||
|
{
|
||||||
|
IList<Event> e = new List<Event>(); /// Events from currently running operations
|
||||||
|
checkUiOp = new Operations.CheckUIOp(true); /// Runs in more then one state
|
||||||
|
|
||||||
|
/// Start the test, initialize test results
|
||||||
|
Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, heatMetersPath, 0));
|
||||||
|
string testName = Common.Utils.GetTestName(test.Name, test.Repeats, repetitionNr);
|
||||||
|
TestStartTime = DateTime.Now;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Show a dialog with OK button and an appropriate message
|
||||||
|
///
|
||||||
|
Bridge.OnAdjustmentInProgress(this, new AdjustmentInProgressEventArgs(testName));
|
||||||
|
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Progress.Test));
|
||||||
|
Bridge.OnActivity(this, test.Method);
|
||||||
|
State.Create(string.Format("{0}({1}) : Running Operations.MessageBoxOp", test.Method, test.Name))
|
||||||
|
.AddOperation(checkUiOp)
|
||||||
|
.AddOperation(StateMachine.BenchWaitingOp)
|
||||||
|
.AddOperation(new Operations.MessageBoxOp(cfg.MessageStr.Replace("~", Environment.NewLine)))
|
||||||
|
.EnterState();
|
||||||
|
do
|
||||||
|
{
|
||||||
|
e = StateMachine.WaitRunDevsRunOps();
|
||||||
|
|
||||||
|
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, 1, Progress.Test));
|
||||||
|
|
||||||
|
if (e.Contains(Event.Error)) goto stopTest;
|
||||||
|
if (TestAndLogUiCmdStop(test, e)) goto stopTest;
|
||||||
|
}
|
||||||
|
while (!e.Contains(Event.OK));
|
||||||
|
|
||||||
|
return new List<Event> { Event.Done };
|
||||||
|
|
||||||
|
stopTest:
|
||||||
|
return new List<Event> { Event.UiCmdStop };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
41
TBF/Rig/TestMethods/Message/TestMethod.cs
Normal file
41
TBF/Rig/TestMethods/Message/TestMethod.cs
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
///
|
||||||
|
/// Copyright (c) 2023 Sensus Slovensko a.s.
|
||||||
|
///
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using log4net;
|
||||||
|
using Common;
|
||||||
|
using Config.Entities;
|
||||||
|
using TBF.Rig;
|
||||||
|
|
||||||
|
namespace TBF.Rig.TestMethods.Message
|
||||||
|
{
|
||||||
|
public class TestMethod : ComponentBase, GenericDevices.ITestMethod
|
||||||
|
{
|
||||||
|
private static readonly ILog log = LogManager.GetLogger(typeof(TestMethod));
|
||||||
|
public override string ToString() { return string.Format("{0}({1})", ClassName, Cfg.ToString(-1)); }
|
||||||
|
|
||||||
|
public bool CanTest(MetersKind meters) { return true; }
|
||||||
|
public bool DoTransitions() { return false; }
|
||||||
|
|
||||||
|
TestMethodCfg messageCfg;
|
||||||
|
|
||||||
|
public TestMethod() { }
|
||||||
|
|
||||||
|
public TestMethod(Generic.IComponentCfg cfg)
|
||||||
|
: base(cfg)
|
||||||
|
{
|
||||||
|
messageCfg = cfg as TestMethodCfg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Initialize()
|
||||||
|
{
|
||||||
|
log.FatalFormat("{0} initialized: {1}", Name, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IList<Event> Execute(Test test, int repetNr, bool isLastRepetition)
|
||||||
|
{
|
||||||
|
return (new MessageSeq()).Execute(test, repetNr, isLastRepetition, DebugLevel, messageCfg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
123
TBF/Rig/TestMethods/Message/TestMethodCfg.cs
Normal file
123
TBF/Rig/TestMethods/Message/TestMethodCfg.cs
Normal file
@ -0,0 +1,123 @@
|
|||||||
|
///
|
||||||
|
/// Copyright (c) 2023 Sensus Slovensko a.s.
|
||||||
|
///
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Xml.Serialization;
|
||||||
|
using Common;
|
||||||
|
using Config.Entities;
|
||||||
|
using TBF.Resources;
|
||||||
|
using TBF.Rig.Generic;
|
||||||
|
|
||||||
|
namespace TBF.Rig.TestMethods.Message
|
||||||
|
{
|
||||||
|
public class TestMethodCfg : ComponentCfgBase, IChildComponentCfg, IParamsProvider
|
||||||
|
{
|
||||||
|
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(TestMethodCfg) })[0];
|
||||||
|
public override XmlSerializer GetSerializer() { return Serializer; }
|
||||||
|
|
||||||
|
public IComponentCfgCtrl GetControl(IList<Component> cmpntEntities)
|
||||||
|
{
|
||||||
|
return new Configs.ParamsProvider.ComponentCfgCtrl(this, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Serialized parameters
|
||||||
|
///
|
||||||
|
public string MessageStr { get; set; } /// 0
|
||||||
|
|
||||||
|
/// Private parameterless constructor invoked by all other (public) constructors
|
||||||
|
TestMethodCfg() { }
|
||||||
|
|
||||||
|
public TestMethodCfg(string name, IComponentFactory factory)
|
||||||
|
: this()
|
||||||
|
{
|
||||||
|
this.Name = name;
|
||||||
|
this.Factory = factory;
|
||||||
|
InitializeAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
public string ComponentName { get { return Name; } }
|
||||||
|
|
||||||
|
public void InitializeAll()
|
||||||
|
{
|
||||||
|
MessageStr = "Trať je zavodnená";
|
||||||
|
}
|
||||||
|
|
||||||
|
string[] paramNames = new string[]
|
||||||
|
{
|
||||||
|
"Message", /// 0
|
||||||
|
};
|
||||||
|
public string ParamName(int i) { return paramNames[i]; }
|
||||||
|
public int ParamsCount() { return paramNames.Length; }
|
||||||
|
|
||||||
|
public ICollection<string> ParamValues(int i)
|
||||||
|
{
|
||||||
|
switch (i)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public string ToString(int i)
|
||||||
|
{
|
||||||
|
switch (i)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
return MessageStr;
|
||||||
|
default:
|
||||||
|
return string.Format("{0} message = {1}", Name, MessageStr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public CfgUpdateFlags UpdateParam(int i, string str)
|
||||||
|
{
|
||||||
|
switch (i)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
MessageStr = str;
|
||||||
|
return CfgUpdateFlags.RestartRqrd;
|
||||||
|
default:
|
||||||
|
return CfgUpdateFlags.None;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool ValidateParam(int i, string str, out string message)
|
||||||
|
{
|
||||||
|
message = string.Empty;
|
||||||
|
|
||||||
|
switch (i)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
message = "Invalid index";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
message = ParamName(i) + " is invalid";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CopyContentTo(TestMethodCfg prms)
|
||||||
|
{
|
||||||
|
prms.MessageStr = MessageStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IParamsProvider Clone()
|
||||||
|
{
|
||||||
|
TestMethodCfg pars = new TestMethodCfg();
|
||||||
|
CopyContentTo(pars);
|
||||||
|
return pars;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool UpdateEmbeddedDbEntity()
|
||||||
|
{
|
||||||
|
return true; /// =OK, do nothing
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1653,6 +1653,10 @@
|
|||||||
<Compile Include="Rig\TestMethods\ManualEntry\ManualEntryCfgCtrl.designer.cs">
|
<Compile Include="Rig\TestMethods\ManualEntry\ManualEntryCfgCtrl.designer.cs">
|
||||||
<DependentUpon>ManualEntryCfgCtrl.cs</DependentUpon>
|
<DependentUpon>ManualEntryCfgCtrl.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="Rig\TestMethods\Message\MessageSeq.cs" />
|
||||||
|
<Compile Include="Rig\TestMethods\Message\Factory.cs" />
|
||||||
|
<Compile Include="Rig\TestMethods\Message\TestMethodCfg.cs" />
|
||||||
|
<Compile Include="Rig\TestMethods\Message\TestMethod.cs" />
|
||||||
<Compile Include="Rig\TestMethods\OuterLoop\End\Component.cs" />
|
<Compile Include="Rig\TestMethods\OuterLoop\End\Component.cs" />
|
||||||
<Compile Include="Rig\TestMethods\OuterLoop\End\Factory.cs" />
|
<Compile Include="Rig\TestMethods\OuterLoop\End\Factory.cs" />
|
||||||
<Compile Include="Rig\TestMethods\OuterLoop\Start\Component.cs" />
|
<Compile Include="Rig\TestMethods\OuterLoop\Start\Component.cs" />
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user