TestMehods.GrabImage added, in construction, ver. 2.15.624

This commit is contained in:
Milan Hanajik
2017-07-24 22:14:27 +03:00
parent a6a87cccae
commit ec27a5843b
13 changed files with 508 additions and 9 deletions
+2 -2
View File
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.14.595.0")]
[assembly: AssemblyFileVersion("2.14.595.0")]
[assembly: AssemblyVersion("2.15.619.0")]
[assembly: AssemblyFileVersion("2.15.619.0")]
+2 -2
View File
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.14.619.0")]
[assembly: AssemblyFileVersion("2.14.619.0")]
[assembly: AssemblyVersion("2.15.619.0")]
[assembly: AssemblyFileVersion("2.15.619.0")]
@@ -54,7 +54,8 @@ namespace TBF.BenchControl
Factories.Add(new TestMethods.FlyingStartMassCollection.Single.Factory());
Factories.Add(new TestMethods.FlyingStartMassCollection.Compound.Factory());
Factories.Add(new TestMethods.FlyingStartMassCollection.HeatMeters.Factory());
Factories.Add(new TestMethods.LeakTest.TestMethodFactory());
Factories.Add(new TestMethods.GrabImage.Factory());
Factories.Add(new TestMethods.LeakTest.TestMethodFactory());
Factories.Add(new TestMethods.LiveStream.Factory());
Factories.Add(new TestMethods.OuterLoop.Start.Factory());
Factories.Add(new TestMethods.OuterLoop.End.Factory());
@@ -0,0 +1,43 @@
///
/// Copyright (c) 2017 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
using System.IO;
using System.Xml.Serialization;
using TBF.BenchControl.Generic;
using TBF.Resources;
namespace TBF.BenchControl.TestMethods.GrabImage
{
public class Cfg : ComponentCfgBase, Generic.IComponentCfg
{
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(Cfg) })[0];
protected override XmlSerializer GetSerializer() { return Serializer; }
public IComponentCfgCtrl GetControl() { return new CfgCtrl(); }
public bool BlackAndWhite;
public bool LowResolution;
/// Private parameterless constructor invoked by all other (public) constructors
Cfg() {}
public Cfg(IComponentFactory factory, string name)
: this()
{
this.Factory = factory;
Name = name;
ParentName = string.Empty;
BlackAndWhite = false;
LowResolution = false;
}
public string ToString(int i)
{
return string.Format("Name={0}, B&W={1}, LowRes={2}", Name, BlackAndWhite, LowResolution);
}
}
}
@@ -0,0 +1,82 @@
///
/// Copyright (c) 2017 Sensus Metering Systems
///
using System;
using System.Windows.Forms;
using log4net;
using TBF.BenchControl.Generic;
namespace TBF.BenchControl.TestMethods.GrabImage
{
public partial class CfgCtrl : UserControl, IComponentCfgCtrl
{
static readonly ILog log = LogManager.GetLogger(typeof(CfgCtrl));
public bool ShowMore { get { return false; } }
Cfg config;
public IComponentCfg Config
{
get { return config as IComponentCfg; }
set
{
config = value as Cfg;
Redraw();
}
}
public CfgCtrl()
{
InitializeComponent();
}
private void EntryFormCfgCtrl_Load(object sender, EventArgs e)
{
Redraw();
}
public void Closing()
{
}
void Redraw()
{
if (config == null) return; /// Control was not loaded, settings were not changed
classNameLabel.Text = config.Factory.ClassName;
nameTextBox.Text = config.Name;
hiResolutionCheckBox.Checked = config.LowResolution;
}
public void Unlock()
{
nameTextBox.Enabled = true;
hiResolutionCheckBox.Enabled = true;
}
public CfgUpdateFlags VerifyCfg(ref string message)
{
return CfgUpdateFlags.None;
}
public CfgUpdateFlags UpdateCfg()
{
CfgUpdateFlags flags = CfgUpdateFlags.None;
if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed
if (config.Name != nameTextBox.Text)
{
config.Name = nameTextBox.Text;
flags |= (CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
}
if (config.LowResolution != hiResolutionCheckBox.Checked)
{
config.LowResolution = hiResolutionCheckBox.Checked;
flags |= (CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
}
return flags;
}
}
}
@@ -0,0 +1,97 @@
///
/// Copyright (c) 2017 Sensus Metering Systems
///
namespace TBF.BenchControl.TestMethods.GrabImage
{
partial class CfgCtrl
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.nameTextBox = new System.Windows.Forms.TextBox();
this.nameLabel = new System.Windows.Forms.Label();
this.classNameLabel = new System.Windows.Forms.Label();
this.hiResolutionCheckBox = new System.Windows.Forms.CheckBox();
this.SuspendLayout();
//
// nameTextBox
//
this.nameTextBox.Enabled = false;
this.nameTextBox.Location = new System.Drawing.Point(134, 69);
this.nameTextBox.Name = "nameTextBox";
this.nameTextBox.Size = new System.Drawing.Size(130, 20);
this.nameTextBox.TabIndex = 7;
//
// nameLabel
//
this.nameLabel.AutoSize = true;
this.nameLabel.Location = new System.Drawing.Point(24, 72);
this.nameLabel.Name = "nameLabel";
this.nameLabel.Size = new System.Drawing.Size(35, 13);
this.nameLabel.TabIndex = 6;
this.nameLabel.Text = "Name";
//
// classNameLabel
//
this.classNameLabel.AutoSize = true;
this.classNameLabel.Location = new System.Drawing.Point(131, 43);
this.classNameLabel.Name = "classNameLabel";
this.classNameLabel.Size = new System.Drawing.Size(83, 13);
this.classNameLabel.TabIndex = 5;
this.classNameLabel.Text = "ComonentName";
//
// hiResolutionCheckBox
//
this.hiResolutionCheckBox.AutoSize = true;
this.hiResolutionCheckBox.Enabled = false;
this.hiResolutionCheckBox.Location = new System.Drawing.Point(134, 104);
this.hiResolutionCheckBox.Name = "hiResolutionCheckBox";
this.hiResolutionCheckBox.Size = new System.Drawing.Size(96, 17);
this.hiResolutionCheckBox.TabIndex = 8;
this.hiResolutionCheckBox.Text = "High resolution";
this.hiResolutionCheckBox.UseVisualStyleBackColor = true;
//
// CfgCtrl
//
this.Controls.Add(this.hiResolutionCheckBox);
this.Controls.Add(this.nameTextBox);
this.Controls.Add(this.nameLabel);
this.Controls.Add(this.classNameLabel);
this.Name = "CfgCtrl";
this.Size = new System.Drawing.Size(300, 240);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TextBox nameTextBox;
private System.Windows.Forms.Label nameLabel;
private System.Windows.Forms.Label classNameLabel;
private System.Windows.Forms.CheckBox hiResolutionCheckBox;
}
}
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
@@ -0,0 +1,39 @@
///
/// Copyright (c) 2017 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
using log4net;
using Config.Entities;
using TBF.BenchControl;
namespace TBF.BenchControl.TestMethods.GrabImage
{
public class Component : ComponentBase, GenericDevices.ITestMethod
{
private static readonly ILog log = LogManager.GetLogger(typeof(Component));
public override string ToString() { return string.Format("TestMethods.LiveStream({0})", Cfg.ToString(1)); }
public bool Evaluate(Test test) { return false; }
public bool Publish(Test test) { return false; }
public bool CanTest(MetersKind meters) { return true; }
Cfg cfg;
public Component()
{
}
public Component(Generic.IComponentCfg cfg)
: base(cfg)
{
log.Debug(this.ToString());
this.cfg = cfg as Cfg;
}
public IList<Event> Execute(Test test, bool bdummy, int idummy)
{
return (new GrabImageSeq()).Execute(test, cfg.LowResolution);
}
}
}
@@ -0,0 +1,26 @@
///
/// Copyright (c) 2017 Sensus Metering Systems
///
using System.Collections.Generic;
using TBF.BenchControl.Generic;
namespace TBF.BenchControl.TestMethods.GrabImage
{
public class Factory : IComponentFactory
{
public string ClassName { get { return this.GetType().Namespace.Substring(17); } }
public void ResetStaticProperties() { Component.ResetStaticProperties(); }
public IComponent DummyComponent() { return new Component(); }
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new Component(cfg); }
public IComponentCfg DefaultConfig() { return new Cfg(this, this.GetType().Namespace.Substring(29)); }
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
{
return ComponentCfgBase.CreateFromDbEntity(Cfg.Serializer, component, this);
}
}
}
@@ -0,0 +1,78 @@
///
/// Copyright (c) 2017 Sensus Metering Systems
///
using System.Collections.Generic;
using log4net;
using Config.Entities;
using TBF.UiBridge;
namespace TBF.BenchControl.TestMethods.GrabImage
{
public class GrabImageSeq : Sequences.SequenceBase
{
private static readonly ILog log = LogManager.GetLogger(typeof(GrabImageSeq));
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> grabImagesOp = new List<IOperation>();
TestProgressEventArgs.SetEstimatedTimes(new int[] { 60, 0, 0, 0, 0, 0, 60, 0 });
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, 1, Config.Entities.Progress.JustStarted));
//------------------------------------------------
Bridge.OnActivity(this, test.Method);
//------------------------------------------------
State state = State.Create(string.Format("{0}({1}) : Grabbing images", test.Method, test.Name))
.AddOperation(checkUiOp);
foreach (var rr in sensPath.RegisterReaders)
{
if (rr is GenericDevices.IRoi)
{
GenericDevices.ICamera camera = (rr as GenericDevices.IRoi).Camera;
if (!cameras.Contains(camera))
{
cameras.Add(camera);
grabImagesOp.Add(camera.LiveStreamOp(hiResolution));
}
}
}
state.AddOperations(grabImagesOp);
state.EnterState();
do
{
e = StateMachine.WaitRunDevsRunOps();
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, 1, Config.Entities.Progress.Test));
if (e.Contains(Event.Error))
{
break;
}
if (TestAndLogUiCmdStop(test,e))
{
break;
}
}
while (true);
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;
}
}
}
@@ -41,9 +41,9 @@ namespace TBF.BenchControl.TestMethods.LiveStream
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, 1, Config.Entities.Progress.JustStarted));
//------------------------------------------------
Bridge.OnActivity(this, "Live image");
Bridge.OnActivity(this, test.Method);
//------------------------------------------------
State.Create("LiveStreamSeq : Live image")
State.Create(string.Format("{0}({1}) : Live stream", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperations(liveStreamOps)
.EnterState();
@@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
// Build Number
// Revision
//
[assembly: AssemblyVersion("2.14.619.1")]
[assembly: AssemblyFileVersion("2.14.619.1")]
[assembly: AssemblyVersion("2.15.624.1")]
[assembly: AssemblyFileVersion("2.15.624.1")]
+13
View File
@@ -843,6 +843,16 @@
<Compile Include="BenchControl\TestMethods\FlyingStart\HeatMeters\TestParams.cs" />
<Compile Include="BenchControl\TestMethods\FlyingStart\Single\Component.cs" />
<Compile Include="BenchControl\TestMethods\FlyingStart\Single\Factory.cs" />
<Compile Include="BenchControl\TestMethods\GrabImage\Cfg.cs" />
<Compile Include="BenchControl\TestMethods\GrabImage\CfgCtrl.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="BenchControl\TestMethods\GrabImage\CfgCtrl.designer.cs">
<DependentUpon>CfgCtrl.cs</DependentUpon>
</Compile>
<Compile Include="BenchControl\TestMethods\GrabImage\Component.cs" />
<Compile Include="BenchControl\TestMethods\GrabImage\Factory.cs" />
<Compile Include="BenchControl\TestMethods\GrabImage\GrabImageSeq.cs" />
<Compile Include="BenchControl\TestMethods\iPerlCommunication\AllCompletedEventArgs.cs" />
<Compile Include="BenchControl\TestMethods\iPerlCommunication\CommCompletedEventArgs.cs" />
<Compile Include="BenchControl\TestMethods\iPerlCommunication\iPerlCommunicationParams.cs" />
@@ -2064,6 +2074,9 @@
<EmbeddedResource Include="BenchControl\TestMethods\Endurance\CycleDlg.ru.resx">
<DependentUpon>CycleDlg.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="BenchControl\TestMethods\GrabImage\CfgCtrl.resx">
<DependentUpon>CfgCtrl.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="BenchControl\TestMethods\iPerlCommunication\iPerlHead\IperlHeadCfgCtrl.resx">
<DependentUpon>IperlHeadCfgCtrl.cs</DependentUpon>
</EmbeddedResource>