Compare commits

..
Author SHA1 Message Date
michal 783d51e71a Fix Diverter switching - in sequence, logs 2024-03-15 21:02:39 +01:00
michal a710ab7457 PL lang fix, camera test 2024-03-10 22:25:55 +01:00
michal 6a428e3c76 Keyence Camera 2024-03-10 22:24:03 +01:00
78 changed files with 2849 additions and 439 deletions
+1
View File
@@ -67,5 +67,6 @@ WorkflowConfigurator/obj/
Workplace/bin/
Workplace/obj/
.vs/
.idea/
*.suo
*.bak
+2 -2
View File
@@ -17,7 +17,7 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG;LANG_PL</DefineConstants>
<DefineConstants>TRACE;DEBUG</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
@@ -25,7 +25,7 @@
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE;LANG_PL</DefineConstants>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
+3
View File
@@ -21,6 +21,9 @@ namespace Config.Mappings
Map(x => x.PressMtrUp);
Map(x => x.PressMtrDown);
Map(x => x.PressMtrDelta);
//Map(x => x.ElectricMtrUp);
//Map(x => x.ElectricMtrDown);
//Map(x => x.ElectricMtrDelta);
Map(x => x.StopBFValve);
Map(x => x.ValvesOpen)
.CustomType("StringClob")
+2 -2
View File
@@ -19,7 +19,7 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG;LANG_PL</DefineConstants>
<DefineConstants>TRACE;DEBUG</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>AnyCPU</PlatformTarget>
@@ -29,7 +29,7 @@
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE;LANG_PL</DefineConstants>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
+16 -2
View File
@@ -80,10 +80,22 @@ namespace TBF.Rig.DataEntry.StandardCamera
public string WMCycleEndState(int wmNr) { return (wmNr >= 0 && wmNr < wmCycleEndState.Length) ? wmCycleEndState[wmNr] : string.Empty; }
double[] wmStartState;
public double WMStartState(int wmNr) { return (wmNr >= 0 && wmNr < wmStartState.Length) ? wmStartState[wmNr] : 0; }
public double WMStartState(int wmNr)
{
bool real = (wmNr >= 0 && wmNr < wmStartState.Length);
log.DebugFormat("WMEndState, wmNr:{0}, wmEndState real: {1}, wmEndState[wmNr]: {2} ",wmNr,real, real ? wmStartState[wmNr] : 0);
return real ? wmStartState[wmNr] : 0;
}
double[] wmEndState;
public double WMEndState(int wmNr) { return (wmNr >= 0 && wmNr < wmEndState.Length) ? wmEndState[wmNr] : 0; }
public double WMEndState(int wmNr)
{
bool real = (wmNr >= 0 && wmNr < wmEndState.Length);
log.DebugFormat("WMEndState, wmNr:{0}, wmEndState real: {1}, wmEndState[wmNr]: {2} ",wmNr,real, real ? wmEndState[wmNr] : 0);
return real ? wmEndState[wmNr] : 0;
}
string[] wmStartStateStr;
@@ -215,6 +227,7 @@ namespace TBF.Rig.DataEntry.StandardCamera
///
void OpenTestStartStatesDlg(EntryForm myRef)
{
log.Debug("-- OpenTestStartStatesDlg --");
string ocrMessage;
var ocr = GetOcr(myRef.OcrWorkspace, out ocrMessage);
myRef.modelessDlg = new TestStartEndForm(TBF.Data.WMsCount, myRef.regReaders, ocr, ocrMessage, myRef.OcrStream,
@@ -224,6 +237,7 @@ namespace TBF.Rig.DataEntry.StandardCamera
///
void OpenTestEndStatesDlg(EntryForm myRef)
{
log.Debug("-- OpenTestEndStatesDlg --");
string ocrMessage;
var ocr = GetOcr(myRef.OcrWorkspace, out ocrMessage);
myRef.modelessDlg = new TestStartEndForm(TBF.Data.WMsCount, myRef.regReaders, ocr, ocrMessage, myRef.OcrStream,
@@ -5,6 +5,7 @@ using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Threading;
using System.Windows.Forms;
using log4net;
@@ -547,6 +548,7 @@ namespace TBF.Rig.DataEntry.StandardCamera
{
try
{
log.DebugFormat("okButton_Click - TextBoxesCount: [{0}], phys2wm:[{1}]", TextBoxesCount, phys2wm.ToArray().ToString());
for (int i = 0; i < TextBoxesCount; i++)
{
int wmPos = phys2wm[i];
@@ -560,6 +562,7 @@ namespace TBF.Rig.DataEntry.StandardCamera
{
WMStartState[wmPos - 1] = Units.ConvertFrom(unit, val); /// Convert to liters
WMStartStateStr[wmPos - 1] = startTextBoxes[i].Text;
log.DebugFormat("startTextBoxes[{0}]= {1} - wmPos= {2} - WMStartState[{3}]= {4} ", i,startTextBoxes[i].Text, wmPos, wmPos - 1,WMStartState[wmPos - 1] );
}
}
@@ -569,6 +572,7 @@ namespace TBF.Rig.DataEntry.StandardCamera
if (Utils.TryParseUDouble(endTextBoxes[i].Text, out val))
{
WMEndState[wmPos - 1] = Units.ConvertFrom(unit, val); /// Convert to liters
log.DebugFormat("endTextBoxes[{0}]= {1} - wmPos= {2} - WMEndState[{3}]= {4} ", i,endTextBoxes[i].Text, wmPos, wmPos - 1,WMEndState[wmPos - 1] );
}
}
}
@@ -688,10 +692,14 @@ namespace TBF.Rig.DataEntry.StandardCamera
double err = 100.0 * (endVolumeL - startVolumeL - refVolume) / refVolume;
exclamations[uiCtrlPos].Visible = (err < warningLimLo) || (warningLimHi < err);
log.Debug(string.Format("DataEntry - Update unit:[{0}], startV: {1} -> {2}, endV: {3} -> {4} ",
unit, startV, startVolumeL, endV, endVolumeL));
}
catch
{
exclamations[uiCtrlPos].Visible = false;
log.Debug("DataEntry - Update unit - Error uiCtrlPos: " + uiCtrlPos);
}
}
}
+1 -1
View File
@@ -3,7 +3,7 @@ using TBF.Rig.Generic;
namespace TBF.Rig.GenericDevices
{
public interface IAdjustableMeter : IComponent
public interface IAdjustableMeter : IPressureMeter
{
/// <summary>
/// Events: PressureDone, Error
+7
View File
@@ -0,0 +1,7 @@
namespace TBF.Rig.GenericDevices
{
public interface IFTPAdapter : TBF.Rig.Generic.IComponent
{
string Path { get; }
}
}
@@ -22,5 +22,8 @@ namespace TBF.Rig.GenericDevices
bool blackAndWhite,
bool lowResolution,
Common.ImageRotation imageRotation);
//if has valve return it
IValve GetValve();
}
}
@@ -27,6 +27,10 @@ namespace TBF.Rig.Modbus.Meret.AdjustableScale
double receivedValue;
double receivedAmpers;
public IOperation ReadPressureOp(ref DoubleBox pressure) { return this.ReadAdjustableOp(ref pressure); }
public IOperation ReadPressureOp(ref DoubleBox pressure, Event pressureDone) { return this.ReadAdjustableOp(ref pressure, pressureDone); }
public bool MsrmntAvailable { get { return true; } }
public double MeasuredVal { get { return receivedValue; } }
public double MsrdValLimLo { get { return Units.ConvertFrom(MsrdUnit, _adjustableMtrCfg.MsrdValLimLo); } }
+25
View File
@@ -0,0 +1,25 @@
///
/// Copyright (c) 2017 Sensus Metering Systems
///
using System.Collections.Generic;
using TBF.Rig.Generic;
namespace TBF.Rig.Network.AdapterFTP
{
public class Factory : IComponentFactory
{
public string ClassName { get { return this.GetType().Namespace.Substring(8); } }
public override string ToString() { return ClassName; }
public IComponent DummyComponent() { return new NetFtpAdapter(); }
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new NetFtpAdapter(cfg); }
public IComponentCfg DefaultConfig() { return new NetFtpadapterCfg(this.GetType().Namespace.Substring(8), this); }
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
{
return ComponentCfgBase.CreateFromDbEntity(NetFtpadapterCfg.Serializer, component, this);
}
}
}
@@ -0,0 +1,35 @@
///
/// Copyright (c) 2017 Sensus Metering Systems
///
using System.Net;
using log4net;
using TBF.Rig.GenericDevices;
namespace TBF.Rig.Network.AdapterFTP
{
public class NetFtpAdapter : ComponentBase, GenericDevices.IFTPAdapter
{
private static readonly ILog log = LogManager.GetLogger(typeof(NetFtpAdapter));
public override string ToString() { return string.Format("{0}({1})", ClassName, Cfg.ToString(-1)); }
readonly NetFtpadapterCfg netFtpadapterCfg;
private string path;
public string Path { get => path; }
public NetFtpAdapter() { }
public NetFtpAdapter(Generic.IComponentCfg cfg)
: base(cfg)
{
netFtpadapterCfg = cfg as NetFtpadapterCfg;
log.Warn(this.ToString());
}
public override void Initialize()
{
path = netFtpadapterCfg.Path;
}
}
}
@@ -0,0 +1,44 @@
///
/// Copyright (c) 2017 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
using System.Xml.Serialization;
using Config.Entities;
using TBF.Rig.Generic;
using TBF.Rig.GenericDevices;
namespace TBF.Rig.Network.AdapterFTP
{
public class NetFtpadapterCfg : ComponentCfgBase, Generic.IComponentCfg
{
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(NetFtpadapterCfg) })[0];
public override XmlSerializer GetSerializer() { return Serializer; }
public IComponentCfgCtrl GetControl(IList<Config.Entities.Component> cmpntEntities) { return new NetadapterCfgCtrl(); }
public string Description; /// Description string of the selected network adapter
public string Path; // path to Ftp
public string Trigger;
/// Private parameterless constructor invoked by all other (public) constructors NetFtpadapterCfg() {}
public NetFtpadapterCfg(string name, IComponentFactory factory)
: this()
{
Name = name;
Factory = factory;
ParentName = string.Empty;
}
protected NetFtpadapterCfg()
{
}
public string ToString(int i)
{
return string.Format("Name={0}, Description={1}", Name, Description);
}
}
}
@@ -0,0 +1,126 @@
///
/// Copyright (c) 2017 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Windows.Forms;
using Common;
using Config.Entities;
using TBF.Rig.Generic;
namespace TBF.Rig.Network.AdapterFTP
{
public partial class NetadapterCfgCtrl : UserControl, IComponentCfgCtrl
{
public bool ShowMore { get { return false; } }
NetFtpadapterCfg config;
public IComponentCfg Config
{
get { return config as IComponentCfg; }
set
{
config = value as NetFtpadapterCfg;
Redraw();
}
}
public NetadapterCfgCtrl()
{
InitializeComponent();
nameTextBox.Enabled = false;
textBoxFtpDir.Enabled = false;
btnDirSelect.Enabled = false;
button1.Enabled = false;
}
private void EntryFormCfgCtrl_Load(object sender, EventArgs e)
{
if (ParentForm == null) return; /// Return is executed when tab page is open in Designer
if (config == null) return; /// Control was not loaded, settings were not changed
Localize();
Redraw();
}
void Redraw()
{
classNameLabel.Text = config.Factory.ClassName;
nameTextBox.Text = config.Name;
textBoxFtpDir.Text = config.Path;
}
void Localize()
{
}
public void Closing()
{
}
public void Unlock()
{
nameTextBox.Enabled = true;
textBoxFtpDir.Enabled = true;
btnDirSelect.Enabled = true;
button1.Enabled = true;
}
public CfgUpdateFlags VerifyCfg(ref string message)
{
CfgUpdateFlags flags = CfgUpdateFlags.None;
if (!Directory.Exists(textBoxFtpDir.Text))
{
flags = CfgUpdateFlags.Error;
message += Environment.NewLine + "Invalid 'Dir path'";
}
return flags;
}
public CfgUpdateFlags UpdateCfg()
{
CfgUpdateFlags flags = CfgUpdateFlags.RestartRqrd;
if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed
config.Name = nameTextBox.Text;
/// Network adapter
string strAdapter = textBoxFtpDir.Text;
int iDash = strAdapter.IndexOf(" - ");
config.Description = iDash < 0 ? "" : strAdapter.Substring(iDash + 3);
config.Path = textBoxFtpDir.Text;
return flags;
}
private void btnDirSelect_Click(object sender, EventArgs e)
{
// Create FolderBrowserDialog
FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog();
// Set initial directory
folderBrowserDialog.SelectedPath = textBoxFtpDir.Text; // Set your predefined path here
// Show the dialog and capture the result
DialogResult result = folderBrowserDialog.ShowDialog();
// Process the result
if (result == DialogResult.OK && !string.IsNullOrWhiteSpace(folderBrowserDialog.SelectedPath))
{
textBoxFtpDir.Text = folderBrowserDialog.SelectedPath;
}
}
private void button1_Click(object sender, EventArgs e)
{
textBoxFtpDir.Text = @"C:\TBF\camera";
}
}
}
+162
View File
@@ -0,0 +1,162 @@
///
/// Copyright (c) 2017 Sensus Metering Systems
///
namespace TBF.Rig.Network.AdapterFTP
{
partial class NetadapterCfgCtrl
{
/// <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.components = new System.ComponentModel.Container();
this.nameTextBox = new System.Windows.Forms.TextBox();
this.nameLabel = new System.Windows.Forms.Label();
this.classNameLabel = new System.Windows.Forms.Label();
this.adapterLabel = new System.Windows.Forms.Label();
this.errorProvider1 = new System.Windows.Forms.ErrorProvider(this.components);
this.textBoxFtpDir = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.btnDirSelect = new System.Windows.Forms.Button();
this.button1 = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.errorProvider1)).BeginInit();
this.SuspendLayout();
//
// nameTextBox
//
this.nameTextBox.Enabled = false;
this.nameTextBox.Location = new System.Drawing.Point(152, 77);
this.nameTextBox.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.nameTextBox.Name = "nameTextBox";
this.nameTextBox.Size = new System.Drawing.Size(169, 26);
this.nameTextBox.TabIndex = 5;
//
// nameLabel
//
this.nameLabel.AutoSize = true;
this.nameLabel.Location = new System.Drawing.Point(14, 82);
this.nameLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.nameLabel.Name = "nameLabel";
this.nameLabel.Size = new System.Drawing.Size(51, 20);
this.nameLabel.TabIndex = 4;
this.nameLabel.Text = "Name";
//
// classNameLabel
//
this.classNameLabel.AutoSize = true;
this.classNameLabel.Location = new System.Drawing.Point(147, 37);
this.classNameLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.classNameLabel.Name = "classNameLabel";
this.classNameLabel.Size = new System.Drawing.Size(125, 20);
this.classNameLabel.TabIndex = 3;
this.classNameLabel.Text = "ComonentName";
//
// adapterLabel
//
this.adapterLabel.AutoSize = true;
this.adapterLabel.Location = new System.Drawing.Point(14, 123);
this.adapterLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.adapterLabel.Name = "adapterLabel";
this.adapterLabel.Size = new System.Drawing.Size(66, 20);
this.adapterLabel.TabIndex = 6;
this.adapterLabel.Text = "Adapter";
//
// errorProvider1
//
this.errorProvider1.ContainerControl = this;
//
// textBoxFtpDir
//
this.textBoxFtpDir.Location = new System.Drawing.Point(151, 120);
this.textBoxFtpDir.Name = "textBoxFtpDir";
this.textBoxFtpDir.Size = new System.Drawing.Size(373, 26);
this.textBoxFtpDir.TabIndex = 7;
//
// label1
//
this.label1.Location = new System.Drawing.Point(151, 161);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(267, 36);
this.label1.TabIndex = 8;
this.label1.Text = "Standart FTP dir: C:\\TBF\\camera";
//
// btnDirSelect
//
this.btnDirSelect.Location = new System.Drawing.Point(546, 116);
this.btnDirSelect.Name = "btnDirSelect";
this.btnDirSelect.Size = new System.Drawing.Size(37, 34);
this.btnDirSelect.TabIndex = 9;
this.btnDirSelect.Text = "...";
this.btnDirSelect.UseVisualStyleBackColor = true;
this.btnDirSelect.Click += new System.EventHandler(this.btnDirSelect_Click);
//
// button1
//
this.button1.Location = new System.Drawing.Point(465, 152);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(118, 39);
this.button1.TabIndex = 10;
this.button1.Text = "Set Default";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// NetadapterCfgCtrl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.button1);
this.Controls.Add(this.btnDirSelect);
this.Controls.Add(this.label1);
this.Controls.Add(this.textBoxFtpDir);
this.Controls.Add(this.adapterLabel);
this.Controls.Add(this.nameTextBox);
this.Controls.Add(this.nameLabel);
this.Controls.Add(this.classNameLabel);
this.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.Name = "NetadapterCfgCtrl";
this.Size = new System.Drawing.Size(675, 462);
this.Load += new System.EventHandler(this.EntryFormCfgCtrl_Load);
((System.ComponentModel.ISupportInitialize)(this.errorProvider1)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button btnDirSelect;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.ErrorProvider errorProvider1;
private System.Windows.Forms.TextBox textBoxFtpDir;
#endregion
private System.Windows.Forms.TextBox nameTextBox;
private System.Windows.Forms.Label nameLabel;
private System.Windows.Forms.Label classNameLabel;
private System.Windows.Forms.Label adapterLabel;
}
}
@@ -0,0 +1,123 @@
<?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>
<metadata name="errorProvider1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>
-4
View File
@@ -2,9 +2,7 @@
/// Copyright (c) 2017-2022 Sensus Slovensko a.s.
///
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Net;
@@ -12,11 +10,9 @@ using System.Net.Sockets;
using System.Security.Cryptography;
using System.Text;
using System.Threading;
using System.Timers;
using log4net;
using Renci.SshNet;
using Common;
using Config.Entities;
using TBF.Rig.Network.Telnet;
using TBF.Resources;
@@ -0,0 +1,318 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Security.AccessControl;
using System.Text.RegularExpressions;
using System.Threading;
using Common;
using log4net;
using TBF.Resources;
namespace TBF.Rig.Network.Camera.KeyenceIV3G120
{
public class Camera : ComponentBase, GenericDevices.ICamera, Generic.IDevice, IOperation
{
private static readonly ILog log = LogManager.GetLogger(typeof(KeyenceIV3G120.Camera));
private static readonly string ftpCameraSource = "C:\\TBF\\camera\\";
private static readonly string prefixCameraFolder = "camera";
private static readonly string prefixCameraName = "cam";
private static readonly string imageExtension = "bmp";
public static string FtpCameraSource => ftpCameraSource;
public static string PrefixCameraFolder => prefixCameraFolder;
public static string PrefixCameraName => prefixCameraName;
public static string ImageExtension => imageExtension;
public override string ToString()
{
return string.Format("{0}: Name={1}, Addr={2}",
this.GetType().Namespace.Substring(8),
CameraCfg.Name,
CameraCfg.HardwareAddress);
}
///
/// Properties
///
public readonly CameraCfg CameraCfg;
public readonly GenericDevices.IFTPAdapter NetAdapter;
//internal parameters
Thread rtpListenerThread;
static bool stopRtpListenerFlag = false;
private string lastImageRtpListener = "";
private static bool newImagePuls = false;
public Camera()
{
}
public Camera(Generic.IComponentCfg cfg, IList<Generic.IComponent> components)
: base(cfg)
{
CameraCfg = cfg as KeyenceIV3G120.CameraCfg;
NetAdapter = TbfComponents.FindComponent(cfg.ParentName, components) as GenericDevices.IFTPAdapter;
if (NetAdapter == null) throw new ArgumentNullException("no network adapter");
}
public int CameraIdx
{
get { return cameraIdx; }
}
int cameraIdx;
///
static int nextCameraIdx = 0;
static int GetCameraIdx()
{
return nextCameraIdx++;
}
/// Used in Initialize()
#region Configuration Change Handling
public static void OnCfgChange(object sender, CfgChangeArgs args)
{
if (CfgChangeHandler == null) return;
try
{
CfgChangeHandler(sender, args);
}
catch (Exception e)
{
log.Error("CfgChangeHandler(...) failed", e);
}
}
public static event EventHandler<CfgChangeArgs> CfgChangeHandler;
public override void StartChangeHandler()
{
CfgChangeHandler += delegate(object sender, CfgChangeArgs args)
{
CameraCfg tmpcfg = args.Cfg as CameraCfg;
if (tmpcfg != null && tmpcfg.Name.Equals(Name))
{
if (args.Command == CfgChangeCmd.CfgChange)
{
}
}
};
}
#endregion Configuration Change Handling
public override void Initialize()
{
cameraIdx = GetCameraIdx();
roisAndResults = new RoisAndResults();
if (CameraCfg.DebugLevel == DebugMode.Simulate)
{
UiBridge.Bridge.OnCameraInfo(cameraIdx,
string.Format("{0} s/n {1} si simulated", Name, CameraCfg.HardwareAddress));
return;
}
/// Detect a camera
bool cameraDetected = true;
if (CameraCfg.DebugLevel == DebugMode.AutoDetect)
{
//TODO BUMI detect camera via send impuls must appere new pictures in FTP server - that must be implemented to FTP loading logic
CameraCfg.DebugLevel = cameraDetected ? DebugMode.DetectedOn : DebugMode.DetectedOff;
}
else if (!cameraDetected)
{
throw new Exception(string.Format("{0}={1}", Strings.Address, CameraCfg.HardwareAddress));
}
if (cameraDetected)
{
UiBridge.Bridge.OnCameraInfo(cameraIdx,
string.Format("{0} s/n {1}", Name, CameraCfg.HardwareAddress));
StartRtpListener();
}
}
///
/// ROI related parameters
///
RoisAndResults roisAndResults;
///
public void ClearRoiParams() { roisAndResults.ClearRoiParams(); }
public int RegisterRoi(string roiParams) { return roisAndResults.RegisterRoi(roiParams); }
public int GetResult(int roiHandle, out long timeMs) { return roisAndResults.GetResult(roiHandle, out timeMs); }
public bool Running { get { return running; } }
bool running;
public bool ShowOverlayRect { set { showOverlayRect = value; } }
bool showOverlayRect = false;
public Rectangle OverlayRect { set { overlayRect = value; } }
Rectangle overlayRect;
public int OverlayThickness { set { overlayThickness = value; } }
int overlayThickness;
public IOperation LiveStreamOp(bool hiRes)
{
throw new System.NotImplementedException();
}
public IOperation MeasurementOp()
{
return this;
}
public IOperation GrabImagesOp(string[] imgFileNames, bool blackAndWhite, bool lowResolution,
ImageRotation imageRotation)
{
return new GrabImagesOp(this, imgFileNames, null, new DateTime());
}
public void RunDeviceBefore()
{
if ((CameraCfg.DebugLevel != DebugMode.Simulate) && (CameraCfg.DebugLevel != DebugMode.DetectedOff))
{
}
}
public void RunDeviceAfter() { }
public void StopDevice()
{
if ((CameraCfg.DebugLevel != DebugMode.Simulate) && (CameraCfg.DebugLevel != DebugMode.DetectedOff))
{
running = false;
stopRtpListenerFlag = true;
}
}
public void StopDevice2()
{
if ((CameraCfg.DebugLevel != DebugMode.Simulate) && (CameraCfg.DebugLevel != DebugMode.DetectedOff))
{
if (rtpListenerThread != null) rtpListenerThread.Join(50);
}
}
public void Start()
{
throw new System.NotImplementedException();
}
public Event Run()
{
throw new System.NotImplementedException();
}
public void Stop()
{
if ((CameraCfg.DebugLevel != DebugMode.Simulate) && (CameraCfg.DebugLevel != DebugMode.DetectedOff))
{
running = false;
stopRtpListenerFlag = true;
}
}
private void StartRtpListener()
{
rtpListenerThread = new Thread(new ThreadStart(RtpListener));
rtpListenerThread.Start();
}
public void RtpListener()
{
log.Debug($"RtpListener - started, stopRtpListenerFlag: {stopRtpListenerFlag}");
int penWidth = 1;
Pen pen = new Pen(Color.Green, penWidth);
string pathDir = $"{ftpCameraSource}{prefixCameraFolder}{cameraIdx}\\";
string searchPattern = $"^.*{prefixCameraName}{cameraIdx}_[\\w]{{0,5}}[\\d]{{6}}_[\\d]{{6}}\\.(?i)bmp$";
while (!stopRtpListenerFlag)
{
try
{
//Try to find picture candidate, shout be on FTP
Image image = null;
string[] picCandidates = Directory.GetFiles(pathDir, "*.bmp", SearchOption.TopDirectoryOnly);
if (picCandidates.Length == 1 && picCandidates.Any(pic => pic == lastImageRtpListener))
{
continue;
}
picCandidates = picCandidates.Where(pic => Regex.IsMatch(pic, searchPattern)).ToArray();
if (picCandidates != null && picCandidates.Length > 0)
{
string newCandidate = CameraUtils.GetLastCreationTimeCandidate(picCandidates);
if (newCandidate == lastImageRtpListener)
{
continue;
}
log.Debug($"RtpListener - in Cycle, newCandidate: {newCandidate}");
try
{
CameraUtils.WaitForImageCompleteOnDisk(newCandidate);
using (Image originalImage = Image.FromFile(newCandidate))
{
// Create a new bitmap from the loaded image
using (Bitmap bitmapCopy = new Bitmap(originalImage))
{
// Create an Image object from the Bitmap object (bitmapCopy)
image = bitmapCopy.Clone() as Image;
}
}
}
catch (Exception ex)
{
log.Error("Error loading image: " + ex.Message);
}
if (showOverlayRect && overlayRect != null && overlayThickness > 0)
{
using (var grph = Graphics.FromImage(image))
{
if (penWidth != overlayThickness)
{
penWidth = overlayThickness;
pen = new Pen(Color.Green, penWidth);
}
grph.DrawRectangle(pen, overlayRect);
}
}
log.Debug($"Image success!, size: {image.Size.ToString()}");
UiBridge.Bridge.OnImage(this.cameraIdx, image);
lastImageRtpListener = newCandidate;
}
}
catch (Exception exc)
{
string msg = string.Format("Exception in MJpeg RTP listener thread: {0}", exc.Message);
log.Error(msg);
}
}
log.Debug($"RtpListener - finished, stopRtpListenerFlag: {stopRtpListenerFlag}");
return;
}
}
}
@@ -0,0 +1,48 @@
///
/// Copyright (c) 2017 Sensus Metering Systems
///
using System.Collections.Generic;
using System.Net;
using System.Net.Sockets;
using System.Xml.Serialization;
using Common;
using TBF.Rig.Generic;
using TBF.Resources;
namespace TBF.Rig.Network.Camera.KeyenceIV3G120
{
public class CameraCfg : ComponentCfgBase, IChildComponentCfg
{
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(CameraCfg) })[0];
public override XmlSerializer GetSerializer() { return Serializer; }
public IComponentCfgCtrl GetControl(IList<Config.Entities.Component> cmpntEntities) { return new CameraCfgCtrl(); }
///
/// Serialized parameters
///
public int HardwareAddress;
/// Private parameterless constructor invoked by all other (public) constructors
CameraCfg() { }
public CameraCfg(string name, IComponentFactory factory)
: this()
{
Name = name;
Factory = factory;
ParentName = "Network.AdapterFTP";
HardwareAddress = 1;
DebugLevel = DebugMode.AutoDetect;
}
public string ToString(int i)
{
return string.Format("Name={0}, s/n={1}, Parent={2}",
Name,
HardwareAddress,
ParentName);
}
}
}
@@ -0,0 +1,145 @@
///
/// Copyright (c) 2017 Sensus Metering Systems
///
using System;
using System.Windows.Forms;
using Common;
using Config.Entities;
using TBF.Rig.Generic;
using TBF.Resources;
using TBF.UI.Bench.Components;
namespace TBF.Rig.Network.Camera.KeyenceIV3G120
{
public partial class CameraCfgCtrl : UserControl, IComponentCfgCtrl
{
ComponentParametersDlg parent;
public bool ShowMore { get { return false; } }
CameraCfg config;
public IComponentCfg Config
{
get { return config as IComponentCfg; }
set
{
config = value as CameraCfg;
Redraw();
}
}
public CameraCfgCtrl()
{
InitializeComponent();
}
private void PumpCfgCtrl_Load(object sender, EventArgs e)
{
Localize();
parent = ParentForm as ComponentParametersDlg;
if (parent == null) return;
if (parent.CmpntEntities != null)
{
foreach (var cmpnt in parent.CmpntEntities)
{
if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is TBF.Rig.Network.AdapterFTP.Factory)
{
parentNameComboBox.Items.Add(cmpnt.Name);
}
}
}
Redraw();
}
void Localize()
{
nameLabel.Text = Strings.Name;
parentNameLabel.Text = Strings.Parent_name;
hwAddressLabel.Text = Strings.Serial_number;
}
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;
parentNameComboBox.Text = string.IsNullOrEmpty(config.ParentName) ? "---" : config.ParentName;
hwAddressTextBox.Text = config.HardwareAddress.ToString();
}
public void Unlock()
{
nameTextBox.Enabled = true;
parentNameComboBox.Enabled = true;
hwAddressTextBox.Enabled = true;
}
public CfgUpdateFlags VerifyCfg(ref string message)
{
CfgUpdateFlags flags = CfgUpdateFlags.None;
int dummy;
if (!parentNameComboBox.Items.Contains(parentNameComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + string.Format(Strings.Invalid_0, parentNameLabel.Text);
}
if (!int.TryParse(hwAddressTextBox.Text, out dummy) || dummy % 100 > 63)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + string.Format(Strings.Invalid_0, hwAddressLabel.Text);
}
return flags;
}
public CfgUpdateFlags UpdateCfg()
{
CfgUpdateFlags flags = CfgUpdateFlags.None;
if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed
string newParentName = parentNameComboBox.Text.Equals("---") ? string.Empty : parentNameComboBox.Text;
int newHWAddress = int.Parse(hwAddressTextBox.Text);
if (config.Name != nameTextBox.Text ||
config.ParentName != newParentName ||
config.HardwareAddress != newHWAddress )
{
config.Name = nameTextBox.Text;
config.ParentName = newParentName;
config.HardwareAddress = newHWAddress;
flags |= (CfgUpdateFlags.RestartRqrd | CfgUpdateFlags.AnyChange);
}
// if (config.TestImagesMode != newTestImagesMode ||
// config.TestImagesCount != newTestImagesCount)
// {
// config.TestImagesMode = newTestImagesMode;
// config.TestImagesCount = newTestImagesCount;
//
// flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.VolatileChange);
// }
if ((flags & CfgUpdateFlags.InvokeCfgChange) != 0)
{
Camera.OnCfgChange(this, new CfgChangeArgs(CfgChangeCmd.CfgChange, config));
}
return flags;
}
}
}
@@ -0,0 +1,140 @@
///
/// Copyright (c) 2017 Sensus Metering Systems
///
namespace TBF.Rig.Network.Camera.KeyenceIV3G120
{
partial class CameraCfgCtrl
{
/// <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.hwAddressTextBox = new System.Windows.Forms.TextBox();
this.hwAddressLabel = new System.Windows.Forms.Label();
this.parentNameLabel = new System.Windows.Forms.Label();
this.nameTextBox = new System.Windows.Forms.TextBox();
this.nameLabel = new System.Windows.Forms.Label();
this.classNameLabel = new System.Windows.Forms.Label();
this.parentNameComboBox = new System.Windows.Forms.ComboBox();
this.SuspendLayout();
//
// hwAddressTextBox
//
this.hwAddressTextBox.Enabled = false;
this.hwAddressTextBox.Location = new System.Drawing.Point(198, 142);
this.hwAddressTextBox.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.hwAddressTextBox.Name = "hwAddressTextBox";
this.hwAddressTextBox.Size = new System.Drawing.Size(193, 26);
this.hwAddressTextBox.TabIndex = 6;
//
// hwAddressLabel
//
this.hwAddressLabel.AutoSize = true;
this.hwAddressLabel.Location = new System.Drawing.Point(42, 146);
this.hwAddressLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.hwAddressLabel.Name = "hwAddressLabel";
this.hwAddressLabel.Size = new System.Drawing.Size(107, 20);
this.hwAddressLabel.TabIndex = 5;
this.hwAddressLabel.Text = "Serial number";
//
// parentNameLabel
//
this.parentNameLabel.AutoSize = true;
this.parentNameLabel.Location = new System.Drawing.Point(42, 106);
this.parentNameLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.parentNameLabel.Name = "parentNameLabel";
this.parentNameLabel.Size = new System.Drawing.Size(100, 20);
this.parentNameLabel.TabIndex = 3;
this.parentNameLabel.Text = "Parent name";
//
// nameTextBox
//
this.nameTextBox.Enabled = false;
this.nameTextBox.Location = new System.Drawing.Point(198, 63);
this.nameTextBox.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.nameTextBox.Name = "nameTextBox";
this.nameTextBox.Size = new System.Drawing.Size(193, 26);
this.nameTextBox.TabIndex = 2;
//
// nameLabel
//
this.nameLabel.AutoSize = true;
this.nameLabel.Location = new System.Drawing.Point(42, 68);
this.nameLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.nameLabel.Name = "nameLabel";
this.nameLabel.Size = new System.Drawing.Size(51, 20);
this.nameLabel.TabIndex = 1;
this.nameLabel.Text = "Name";
//
// classNameLabel
//
this.classNameLabel.AutoSize = true;
this.classNameLabel.Location = new System.Drawing.Point(194, 26);
this.classNameLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.classNameLabel.Name = "classNameLabel";
this.classNameLabel.Size = new System.Drawing.Size(125, 20);
this.classNameLabel.TabIndex = 0;
this.classNameLabel.Text = "ComonentName";
//
// parentNameComboBox
//
this.parentNameComboBox.Enabled = false;
this.parentNameComboBox.FormattingEnabled = true;
this.parentNameComboBox.Location = new System.Drawing.Point(198, 102);
this.parentNameComboBox.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.parentNameComboBox.Name = "parentNameComboBox";
this.parentNameComboBox.Size = new System.Drawing.Size(193, 28);
this.parentNameComboBox.TabIndex = 4;
//
// CameraCfgCtrl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.hwAddressTextBox);
this.Controls.Add(this.hwAddressLabel);
this.Controls.Add(this.parentNameComboBox);
this.Controls.Add(this.parentNameLabel);
this.Controls.Add(this.nameTextBox);
this.Controls.Add(this.nameLabel);
this.Controls.Add(this.classNameLabel);
this.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.Name = "CameraCfgCtrl";
this.Size = new System.Drawing.Size(603, 391);
this.Load += new System.EventHandler(this.PumpCfgCtrl_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TextBox hwAddressTextBox;
private System.Windows.Forms.Label hwAddressLabel;
private System.Windows.Forms.Label parentNameLabel;
private System.Windows.Forms.TextBox nameTextBox;
private System.Windows.Forms.Label nameLabel;
private System.Windows.Forms.Label classNameLabel;
private System.Windows.Forms.ComboBox parentNameComboBox;
}
}
@@ -0,0 +1,97 @@
using System;
using System.IO;
using System.Linq;
using System.Threading;
using log4net;
namespace TBF.Rig.Network.Camera.KeyenceIV3G120
{
public class CameraUtils
{
private static readonly ILog log = LogManager.GetLogger(typeof(KeyenceIV3G120.CameraUtils));
public static string GetLastCreationTimeCandidate(string[] picCandidates)
{
var creationTimes = picCandidates.Select(path => new FileInfo(path).CreationTime).ToArray();
// Find the index of the latest creation time
var latestIndex = Array.IndexOf(creationTimes, creationTimes.Max());
// Get the path of the file with the latest creation time
return picCandidates[latestIndex];
}
public static void WaitForImageCompleteOnDisk(string picturePath)
{
//TODO finish
//we start this part in moment we found some file in disk
//wait for finish write image on disk - FTP is slow
if (File.Exists(picturePath))
{
try
{
for (int iIteration = 0;iIteration < 10;iIteration++) // wait max 2 sec - otherwise there may be a problem
{
Thread.Sleep(200);
try
{
using (FileStream fs = File.Open(picturePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
break;
}
}
catch (IOException ex)
{
// Handle the case when the file is not ready or cannot be accessed
log.Debug("No accessing rihts! We will wait next iteration!");
}
}
}
catch (Exception e)
{
log.Error("Error to wait for writing file to disk. Detail: " + e.StackTrace);
}
}
}
public void CallTrigger()
{
//TODO call initialisation signal - valve open
}
public static void ClearDir(string path)
{
log.Debug($"ClearDir({path}) called!");
string[] filesToDelete = Directory.GetFiles(path, "*.*", SearchOption.TopDirectoryOnly);
ClearDir(filesToDelete);
}
public static void ClearDir(string[] files)
{
foreach (string file in files)
{
if (File.Exists(file))
{
try
{
// Check if user has write permission for the file
if ((File.GetAttributes(file) & FileAttributes.ReadOnly) == 0)
{
File.Delete(file);
log.Debug($"Deleted: {file}");
}
else
{
log.Debug($"Insufficient permissions to delete: {file}");
}
}
catch (Exception ex)
{
log.Debug($"Error deleting {file}: {ex.Message}");
}
}
}
}
}
}
@@ -0,0 +1,25 @@
///
/// Copyright (c) 2017 Sensus Metering Systems
///
using System.Collections.Generic;
using TBF.Rig.Generic;
namespace TBF.Rig.Network.Camera.KeyenceIV3G120
{
public class Factory : IComponentFactory
{
public string ClassName { get { return GetType().Namespace.Substring(8); } }
public override string ToString() { return ClassName; }
public IComponent DummyComponent() { return new Camera(); }
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new Camera(cfg, components); }
public IComponentCfg DefaultConfig() { return new CameraCfg(this.GetType().Namespace.Substring(8), this); }
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
{
return ComponentCfgBase.CreateFromDbEntity(CameraCfg.Serializer, component, this);
}
}
}
@@ -0,0 +1,115 @@
using System;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using Common;
using log4net;
namespace TBF.Rig.Network.Camera.KeyenceIV3G120
{
public class GrabImagesOp : IOperation
{
private static readonly ILog log = LogManager.GetLogger(typeof(GrabImagesOp));
public override string ToString() { return string.Format("GrabImageOp()"); }
private readonly Camera camera;
readonly string[] imgFileNames;
private readonly string path;
private readonly DateTime time;
bool grabImageDone;
bool grabPassed;
bool grabFailed;
public GrabImagesOp(Camera camera, string[] imgFileNames, string path, DateTime time)
{
this.camera = camera;
this.imgFileNames = imgFileNames;
this.path = path;
this.time = time;
}
public void Start()
{
grabImageDone = false;
if ((imgFileNames != null) && (imgFileNames.Length > 0) && File.Exists(imgFileNames[0]))
{
///
/// An image specified, (1) delete previous image, (2) check if this is a simulation
///
File.Delete(imgFileNames[0]);
if (camera.CameraCfg.DebugLevel == DebugMode.Simulate || camera.CameraCfg.DebugLevel == DebugMode.DetectedOff)
{
///
/// Camera is in simulation mode => create a simulated image
///
File.Copy(string.Format("{0}\\Pictures\\sample.jpg", Program.ExecutableDir), imgFileNames[0]);
}
}
}
public Event Run()
{
if ((imgFileNames == null) || (imgFileNames.Length < 1) || (imgFileNames[0] == null))
{
///
/// No images to be grabbed => Done
///
return Event.GrabPassed;
}
else if (camera.CameraCfg.DebugLevel == DebugMode.Simulate ||
camera.CameraCfg.DebugLevel == DebugMode.DetectedOff)
{
///
/// Camera is in simulation mode => create a simulated image and complete
///
return Event.GrabPassed;
}
else if (!grabImageDone)
{
string pathDir = $"{Camera.FtpCameraSource}{Camera.PrefixCameraFolder}{camera.CameraIdx}\\";
string searchPattern = $"^.*{Camera.PrefixCameraName}{camera.CameraIdx}_[\\w]{{0,5}}[\\d]{{6}}_[\\d]{{6}}\\.(?i)bmp$";
string[] picCandidates = Directory.GetFiles(pathDir, "*.bmp", SearchOption.TopDirectoryOnly);
picCandidates = picCandidates.Where(pic => Regex.IsMatch(pic, searchPattern)).ToArray();
if (picCandidates != null && picCandidates.Length > 0)
{
string newCandidate = CameraUtils.GetLastCreationTimeCandidate(picCandidates);
log.Debug($"GrabImageOP.Run() - in Cycle, newCandidate: {newCandidate}");
try
{
CameraUtils.WaitForImageCompleteOnDisk(newCandidate);
File.Move(newCandidate, imgFileNames[0]);
grabImageDone = true;
grabPassed = true;
CameraUtils.ClearDir(pathDir);
return Event.GrabPassed;
}
catch (Exception ex)
{
log.Error("Error loading image: " + ex.Message);
grabFailed = true;
return Event.Error;
}
}
return Event.CameraBusy;
}
return Event.CameraBusy;
}
public void Stop()
{
if (camera.CameraCfg.DebugLevel == DebugMode.Simulate) return;
if (grabImageDone)
{
string pathDir = $"{Camera.FtpCameraSource}{Camera.PrefixCameraFolder}{camera.CameraIdx}\\";
CameraUtils.ClearDir(pathDir);
}
}
}
}
@@ -0,0 +1,91 @@
///
/// Copyright (c) 2017 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
namespace TBF.Rig.Network.Camera.KeyenceIV3G120
{
public class RoisAndResults
{
public const int MaxRegisteredRois = 4; /// Max. count of registered (and measured) ROI-s
public long CameraTimeMs;
public int[] Angles;
private IList<string> roiParams;
public int RegisteredRoisCount { get { return roiParams.Count; } }
public RoisAndResults()
{
Angles = new int[MaxRegisteredRois];
roiParams = new List<string>();
}
public void ClearRoiParams()
{
lock (this)
{
roiParams.Clear();
}
}
public int RegisterRoi(string roiParam)
{
lock (this)
{
if (this.roiParams.Count >= MaxRegisteredRois) return 0;
this.roiParams.Add(roiParam);
return this.roiParams.Count; /// return a handle 1 .. MaxRegisteredRois
}
}
public string GetRoiParams(int roiHandle)
{
lock (this)
{
if (roiHandle > 0 && roiHandle <= roiParams.Count)
{
return roiParams[roiHandle - 1];
}
else
{
return string.Empty;
}
}
}
public void SetResults(long timeMs, int[] angles)
{
lock (this)
{
CameraTimeMs = timeMs;
for (int i = 0; i < Math.Min(angles.Length, Angles.Length); i++)
{
Angles[i] = angles[i];
}
}
}
public int GetResult(int roiHandle, out long timeMs)
{
lock (this)
{
if (roiHandle > 0 && roiHandle <= roiParams.Count)
{
timeMs = CameraTimeMs;
return Angles[roiHandle - 1];
}
else
{
timeMs = 0;
return 0;
}
}
}
}
}
+6
View File
@@ -8,6 +8,7 @@ using System.Text;
using log4net;
using Common;
using Config.Entities;
using TBF.Rig.GenericDevices;
namespace TBF.Rig.Network.Camera.Roi
{
@@ -197,6 +198,11 @@ namespace TBF.Rig.Network.Camera.Roi
return null;
}
public IValve GetValve()
{
return null;
}
public IOperation GrabImageOp(string imageFileName)
{
@@ -7,6 +7,7 @@ using System.Text;
using log4net;
using Common;
using Config.Entities;
using TBF.Rig.GenericDevices;
namespace TBF.Rig.Network.Camera.RoiForFixedStart
{
@@ -129,5 +130,10 @@ namespace TBF.Rig.Network.Camera.RoiForFixedStart
else
return null;
}
public IValve GetValve()
{
return null;
}
}
}
@@ -0,0 +1,25 @@
///
/// Copyright (c) 2017 Sensus Metering Systems
///
using System.Collections.Generic;
using TBF.Rig.Generic;
namespace TBF.Rig.Network.Camera.RoiForFixedStartKeyence
{
public class Factory : IComponentFactory
{
public string ClassName { get { return this.GetType().Namespace.Substring(8); } }
public override string ToString() { return ClassName; }
public IComponent DummyComponent() { return new Roi(); }
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new Roi(cfg, components); }
public IComponentCfg DefaultConfig() { return new RoiCfg(this.GetType().Namespace.Substring(8), this); }
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
{
return ComponentCfgBase.CreateFromDbEntity(RoiCfg.Serializer, component, this);
}
}
}
@@ -1,35 +1,30 @@
///
/// Copyright (c) 2021 Sensus Slovensko a.s.
/// Copyright (c) 2017 Sensus Metering Systems
///
using System;
using System.IO;
using System.Text;
using System.Xml.Serialization;
using Common;
using Config.Entities;
using TBF.Rig.Generic;
using TBF.Resources;
namespace TBF.Rig.RegisterReaders.FrequencyMeterFromUniCB
namespace TBF.Rig.Network.Camera.RoiForFixedStartKeyence
{
public class RRProcParams : ProcedureParamsBase, IParamsProvider, IProcedureParams
public class ProcedureParams : ProcedureParamsBase, IParamsProvider, IProcedureParams
{
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(RRProcParams) })[0];
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(ProcedureParams) })[0];
public override XmlSerializer GetSerializer() { return Serializer; }
public double PulsesPerLtr; /// [l^-1]
public int Filter;
public override void InitializeAll()
{
PulsesPerLtr = 1.0;
Filter = 0;
}
string[] paramNames = new string[]
{
Strings.PulsesPerLtr,
Strings.Filter,
};
public override string ParamName(int i) { return paramNames[i]; }
public override int ParamsCount() { return paramNames.Length; }
@@ -39,40 +34,32 @@ namespace TBF.Rig.RegisterReaders.FrequencyMeterFromUniCB
switch (i)
{
case 0: return PulsesPerLtr.ToString();
case 1: return Filter.ToString();
default: return string.Empty;
default: return string.Empty;
}
}
/// Retrieves parameters from UI controls
CfgUpdateFlags IParamsProvider.UpdateParam(int i, string strValue)
public CfgUpdateFlags UpdateParam(int i, string strValue)
{
switch (i)
{
case 0: PulsesPerLtr = Utils.ParseUDouble(strValue); return CfgUpdateFlags.None;
case 1: Filter = int.Parse(strValue); return CfgUpdateFlags.None;
default: return CfgUpdateFlags.None;
}
}
/// Verifies whether strings in UI controls represent valid parameters
bool IParamsProvider.ValidateParam(int i, string strValue, out string message)
public bool ValidateParam(int i, string strValue, out string message)
{
message = string.Empty;
double dummy;
int idummy;
switch (i)
{
case 0:
if (Utils.TryParseUDouble(strValue, out dummy)) return true;
break;
case 1:
if (int.TryParse(strValue, out idummy) && (idummy >= 0)) return true;
break;
default:
default:
message = "Invalid index";
return false;
}
@@ -81,15 +68,14 @@ namespace TBF.Rig.RegisterReaders.FrequencyMeterFromUniCB
return false;
}
void CopyContentTo(RRProcParams prms)
void CopyContentTo(ProcedureParams prms)
{
prms.PulsesPerLtr = this.PulsesPerLtr;
prms.Filter = this.Filter;
}
IParamsProvider IParamsProvider.Clone()
public IParamsProvider Clone()
{
RRProcParams pars = new RRProcParams();
ProcedureParams pars = new ProcedureParams();
CopyContentTo(pars);
return pars;
}
@@ -99,7 +85,7 @@ namespace TBF.Rig.RegisterReaders.FrequencyMeterFromUniCB
if (dbEntity == null) return;
try
{
RRProcParams tmp = Serializer.Deserialize(new StringReader(dbEntity.Parameters)) as RRProcParams;
ProcedureParams tmp = Serializer.Deserialize(new StringReader(dbEntity.Parameters)) as ProcedureParams;
procedureParamsEntity = dbEntity;
componentName = dbEntity.CmpntName;
@@ -111,18 +97,15 @@ namespace TBF.Rig.RegisterReaders.FrequencyMeterFromUniCB
{
}
}
public RRProcParams()
{
}
public ProcedureParams() { }
public RRProcParams(bool initialize)
public ProcedureParams(bool initialize)
{
if (initialize) InitializeAll();
}
public RRProcParams(ComponentProcedure procedureParamsEntity, string componentName, Procedure procedure)
public ProcedureParams(ComponentProcedure procedureParamsEntity, string componentName, Procedure procedure)
{
this.procedureParamsEntity = procedureParamsEntity;
this.componentName = componentName;
@@ -0,0 +1,170 @@
///
/// Copyright (c) 2017-2021 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
using System.Text;
using log4net;
using Common;
using Config.Entities;
using NHibernate.Util;
using TBF.Rig.Generic;
using TBF.Rig.GenericDevices;
namespace TBF.Rig.Network.Camera.RoiForFixedStartKeyence
{
public class Roi : ComponentBase, GenericDevices.IRegReaderStillCamera
{
/// TODO: Implement support for sharing one camera by multiple ROI-s
private static readonly ILog log = LogManager.GetLogger(typeof(Roi));
public override string ToString() { return string.Format("{0}({1})", ClassName, Cfg.ToString(-1)); }
readonly RoiCfg roiCfg;
///
/// Camera and ICamera
///
public readonly KeyenceIV3G120.Camera FtpCamera;
public GenericDevices.ICamera Camera { get { return FtpCamera as GenericDevices.ICamera; } }
public int Position
{
get
{
int firstDigitPos = Name.IndexOfAny(new char[] { '1', '2', '3', '4', '5', '6', '7', '8', '9', '0' });
int position;
return (firstDigitPos < 0) ? 0 : (int.TryParse(Name.Substring(firstDigitPos), out position) ? position : 0);
}
}
public RegisterReaderType RegisterReaderType { get { return RegisterReaderType.Manual; } }
public double PulsesPerLtr { get { return roiCfg.ProcParams.PulsesPerLtr; } }
public double LtrsPerPulse { get { return (PulsesPerLtr <= float.Epsilon) ? 1.0 : (1 / PulsesPerLtr); } }
double beginWMState;
public double BeginWMState
{
get { return beginWMState; }
set { beginWMState = value; }
}
double endWMState;
public double EndWMState
{
get { return endWMState; }
set { endWMState = value; }
}
public double WMVolume { get { return endWMState - beginWMState; } }
public int WMPulses { get { return (int)(WMVolume / LtrsPerPulse); } }
public int WMRefPulses { get { return StateMachine.ControlBoardMain.RefPulses; ; } }
public Roi() { }
public Roi(Generic.IComponentCfg cfg, IList<Generic.IComponent> components)
: base(cfg)
{
roiCfg = cfg as RoiCfg;
FtpCamera = TbfComponents.FindComponent(cfg.ParentName, components) as KeyenceIV3G120.Camera;
log.Warn(this.ToString());
}
public override void Initialize()
{
Clear();
}
#region Configuration Change Handling
public static void OnCfgChange(object sender, CfgChangeArgs args)
{
if (CfgChangeHandler == null) return;
try { CfgChangeHandler(sender, args); }
catch (Exception e) { log.Error("CfgChangeHandler(...) failed", e); }
}
public static event EventHandler<CfgChangeArgs> CfgChangeHandler;
public override void StartChangeHandler()
{
CfgChangeHandler += delegate(object sender, CfgChangeArgs args)
{
RoiCfg tmpcfg = args.Cfg as RoiCfg;
if (tmpcfg != null && tmpcfg.Name.Equals(Name))
{
if (args.Command == CfgChangeCmd.CfgChange)
{
roiCfg.TriggerName = tmpcfg.TriggerName;
}
}
};
}
#endregion Configuration Change Handling
public void Clear()
{
log.DebugFormat("{0}:Clear()", Name);
beginWMState = 0;
endWMState = 0;
}
public static IValve Valve(string name)
{
/// Load the list of components from the database
var session = TBF.DB.CreateSession(DBKind.Config);
var cmptnEntities = session.QueryOver<Component>().OrderBy(x => x.ItemNr).Asc.List();
IList<IComponent> TbfComponents = Rig.TbfComponents.LoadComponentsFromDB(cmptnEntities);
IList<IValve> valves = Rig.BuiltIn.ValveBase.AllValves(TbfComponents);
if (valves.Count == 0)
{
return null;
}
foreach (var valve in valves)
{
if (valve.Name == name)
{
return valve;
}
}
return valves[0];
}
public IOperation GrabImageOp(string imageFileName)
{
return GrabImageOp(imageFileName, true, true, ImageRotation.None);
}
public IOperation GrabImageOp(string imageFileName,
bool blackAndWhite, bool lowResolution, ImageRotation imageRotation)
{
if (FtpCamera != null)
{
/// TODO: Implement support for sharing one camera by multiple ROI-s
return FtpCamera.GrabImagesOp(new string[] { imageFileName }, blackAndWhite, lowResolution, imageRotation);
}
else
return null;
}
public IValve GetValve()
{
if (roiCfg?.TriggerName != null)
{
IValve valve = Valve(roiCfg.TriggerName);
if (valve != null)
{
return valve;
}
}
return null;
}
}
}
@@ -0,0 +1,54 @@
///
/// Copyright (c) 2017 Sensus Metering Systems
///
using System.Collections.Generic;
using System.Xml.Serialization;
using Common;
using Config.Entities;
using TBF.Rig.Generic;
namespace TBF.Rig.Network.Camera.RoiForFixedStartKeyence
{
public class RoiCfg : ComponentCfgBase, IChildComponentCfg
{
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(RoiCfg) })[0];
public override XmlSerializer GetSerializer() { return Serializer; }
public IComponentCfgCtrl GetControl(IList<Config.Entities.Component> cmpntEntities) { return new RoiCfgCtrl(); }
///
/// Serialized parameters
///
private string triggerName;
public string TriggerName { get => triggerName; set => triggerName = value; }
/// <summary> Procedure parameters </summary>
[XmlIgnore]
public ProcedureParams ProcParams;
public override IParamsProvider GetRuntimeProcParamsProvider() { return ProcParams; }
public override IParamsProvider CreateProcParamsProvider() { return new ProcedureParams(true); }
/// Private parameterless constructor invoked by all other (public) constructors
RoiCfg()
{
ProcParams = new ProcedureParams(true);
}
public RoiCfg(string name, IComponentFactory factory)
: this()
{
Name = name;
Factory = factory;
ParentName = "Camera";
triggerName = string.Empty;
DebugLevel = DebugMode.Inherit;
}
public string ToString(int i)
{
return string.Format("{0} Camera={1} Trigger{2}",
Name, ParentName, triggerName);
}
}
}
@@ -0,0 +1,189 @@
///
/// Copyright (c) 2017 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using log4net;
using Common;
using Config.Entities;
using TBF.Rig.Generic;
using TBF.Resources;
using TBF.Rig.GenericDevices;
using TBF.UI.Bench.Components;
namespace TBF.Rig.Network.Camera.RoiForFixedStartKeyence
{
public partial class RoiCfgCtrl : UserControl, IComponentCfgCtrl
{
static readonly ILog log = LogManager.GetLogger(typeof(RoiCfgCtrl));
ComponentParametersDlg parent;
private IList<IValve> allValves;
public bool ShowMore
{
get { return false; }
}
RoiCfg config;
public IComponentCfg Config
{
get { return config as IComponentCfg; }
set
{
config = value as RoiCfg;
Redraw();
}
}
public RoiCfgCtrl()
{
InitializeComponent();
}
private void PumpCfgCtrl_Load(object sender, EventArgs e)
{
parent = ParentForm as ComponentParametersDlg;
if (parent == null) return;
if (parent.CmpntEntities != null)
{
foreach (var cmpnt in parent.CmpntEntities)
{
if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is TBF.Rig.Network.Camera
.KeyenceIV3G120.Factory)
{
parentNameComboBox.Items.Add(cmpnt.Name);
}
}
}
allValves = InitAllValves();
foreach (var valve in allValves)
{
triggerValveComboBox.Items.Add(valve.Name);
}
Redraw();
}
private IList<IValve> InitAllValves()
{
/// Load the list of components from the database
var session = TBF.DB.CreateSession(DBKind.Config);
var cmptnEntities = session.QueryOver<Component>().OrderBy(x => x.ItemNr).Asc.List();
IList<IComponent> TbfComponents = Rig.TbfComponents.LoadComponentsFromDB(cmptnEntities);
/// Find all master valves
return Rig.BuiltIn.ValveBase.AllValves(TbfComponents);
}
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;
parentNameComboBox.Text = string.IsNullOrEmpty(config.ParentName) ? "---" : config.ParentName;
triggerValveComboBox.Text = config.TriggerName;
}
public void Unlock()
{
nameTextBox.Enabled = true;
parentNameComboBox.Enabled = true;
triggerValveComboBox.Enabled = true;
}
public CfgUpdateFlags VerifyCfg(ref string message)
{
CfgUpdateFlags flags = CfgUpdateFlags.None;
if (!parentNameComboBox.Items.Contains(parentNameComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + string.Format(Strings.Invalid_0, parentNameLabel.Text);
}
if (!triggerValveComboBox.Items.Contains(triggerValveComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + string.Format(Strings.Invalid_0, imageRotationLabel.Text);
}
return flags;
}
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.RestartRqrd | CfgUpdateFlags.AnyChange);
}
string newParentName = parentNameComboBox.Text.Equals("---") ? string.Empty : parentNameComboBox.Text;
if (config.ParentName != newParentName)
{
config.ParentName = newParentName;
flags |= (CfgUpdateFlags.RestartRqrd | CfgUpdateFlags.AnyChange);
}
if (allValves.Any( valve => valve.Name == triggerValveComboBox.Text ))
{
config.TriggerName = triggerValveComboBox.Text;
flags |= (CfgUpdateFlags.AnyChange | CfgUpdateFlags.InvokeCfgChange);
}
if ((flags & CfgUpdateFlags.InvokeCfgChange) != 0)
{
Roi.OnCfgChange(this, new CfgChangeArgs(CfgChangeCmd.CfgChange, config));
}
return flags;
}
#region Configuration Change Handling
public static void OnCmdResponse(object sender, CmdResponseArgs args)
{
if (CmdResponseHandler == null) return;
try
{
CmdResponseHandler(sender, args);
}
catch (Exception e)
{
log.Error("CmdResponseHandler(...) failed", e);
}
}
public static event EventHandler<CmdResponseArgs> CmdResponseHandler;
public void StartResponseHandler()
{
}
public void StopResponseHandler()
{
}
#endregion Configuration Change Handling
}
}
@@ -0,0 +1,166 @@
///
/// Copyright (c) 2017 Sensus Metering Systems
///
namespace TBF.Rig.Network.Camera.RoiForFixedStartKeyence
{
partial class RoiCfgCtrl
{
/// <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.parentNameLabel = new System.Windows.Forms.Label();
this.nameTextBox = new System.Windows.Forms.TextBox();
this.nameLabel = new System.Windows.Forms.Label();
this.classNameLabel = new System.Windows.Forms.Label();
this.parentNameComboBox = new System.Windows.Forms.ComboBox();
this.label1 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.triggerValveComboBox = new System.Windows.Forms.ComboBox();
this.imageRotationLabel = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// parentNameLabel
//
this.parentNameLabel.AutoSize = true;
this.parentNameLabel.Location = new System.Drawing.Point(30, 118);
this.parentNameLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.parentNameLabel.Name = "parentNameLabel";
this.parentNameLabel.Size = new System.Drawing.Size(65, 20);
this.parentNameLabel.TabIndex = 3;
this.parentNameLabel.Text = "Camera";
//
// nameTextBox
//
this.nameTextBox.Enabled = false;
this.nameTextBox.Location = new System.Drawing.Point(208, 75);
this.nameTextBox.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.nameTextBox.Name = "nameTextBox";
this.nameTextBox.Size = new System.Drawing.Size(340, 26);
this.nameTextBox.TabIndex = 2;
//
// nameLabel
//
this.nameLabel.AutoSize = true;
this.nameLabel.Location = new System.Drawing.Point(30, 80);
this.nameLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.nameLabel.Name = "nameLabel";
this.nameLabel.Size = new System.Drawing.Size(51, 20);
this.nameLabel.TabIndex = 1;
this.nameLabel.Text = "Name";
//
// classNameLabel
//
this.classNameLabel.AutoSize = true;
this.classNameLabel.Location = new System.Drawing.Point(204, 40);
this.classNameLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.classNameLabel.Name = "classNameLabel";
this.classNameLabel.Size = new System.Drawing.Size(173, 20);
this.classNameLabel.TabIndex = 0;
this.classNameLabel.Text = "ComponentClassName";
//
// parentNameComboBox
//
this.parentNameComboBox.Enabled = false;
this.parentNameComboBox.FormattingEnabled = true;
this.parentNameComboBox.Location = new System.Drawing.Point(208, 114);
this.parentNameComboBox.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.parentNameComboBox.Name = "parentNameComboBox";
this.parentNameComboBox.Size = new System.Drawing.Size(340, 28);
this.parentNameComboBox.TabIndex = 4;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(-316, -226);
this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(87, 20);
this.label1.TabIndex = 5;
this.label1.Text = "Arguments";
//
// textBox1
//
this.textBox1.Enabled = false;
this.textBox1.Location = new System.Drawing.Point(-188, -231);
this.textBox1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(556, 26);
this.textBox1.TabIndex = 6;
//
// triggerValveComboBox
//
this.triggerValveComboBox.Enabled = false;
this.triggerValveComboBox.FormattingEnabled = true;
this.triggerValveComboBox.Location = new System.Drawing.Point(208, 155);
this.triggerValveComboBox.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.triggerValveComboBox.Name = "triggerValveComboBox";
this.triggerValveComboBox.Size = new System.Drawing.Size(340, 28);
this.triggerValveComboBox.TabIndex = 8;
//
// imageRotationLabel
//
this.imageRotationLabel.AutoSize = true;
this.imageRotationLabel.Location = new System.Drawing.Point(30, 160);
this.imageRotationLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.imageRotationLabel.Name = "imageRotationLabel";
this.imageRotationLabel.Size = new System.Drawing.Size(97, 20);
this.imageRotationLabel.TabIndex = 7;
this.imageRotationLabel.Text = "Trigger valve";
//
// RoiCfgCtrl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.triggerValveComboBox);
this.Controls.Add(this.imageRotationLabel);
this.Controls.Add(this.parentNameComboBox);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.label1);
this.Controls.Add(this.parentNameLabel);
this.Controls.Add(this.nameTextBox);
this.Controls.Add(this.nameLabel);
this.Controls.Add(this.classNameLabel);
this.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.Name = "RoiCfgCtrl";
this.Size = new System.Drawing.Size(750, 462);
this.Load += new System.EventHandler(this.PumpCfgCtrl_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label parentNameLabel;
private System.Windows.Forms.TextBox nameTextBox;
private System.Windows.Forms.Label nameLabel;
private System.Windows.Forms.Label classNameLabel;
private System.Windows.Forms.ComboBox parentNameComboBox;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.ComboBox triggerValveComboBox;
private System.Windows.Forms.Label imageRotationLabel;
}
}
@@ -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>
+63
View File
@@ -0,0 +1,63 @@
using System.Collections.Generic;
using System.Net.NetworkInformation;
using TBF.Rig.GenericDevices;
namespace TBF.Rig.Network
{
public class FtpAdapterInfo
{
public string Description;
/// Description of the network adapter.
public string Path;
/// common path to Ftp
public IValve TriggerValve;
/// valve to open reach trigger
public FtpAdapterInfo(string description)
{
Description = description;
}
///------------------------------------------------------
/// Static members and functions
///------------------------------------------------------
/// <summary>
/// Private list of the available network adapters.
/// </summary>
static List<FtpAdapterInfo> netAdapters;
/// <summary>
/// Retrieves the list of network adapters.
/// Never returns 'null', calls RefreshNetAdaptersInfo() the first time it is used.
/// If you want to refresh the list of the network adapters later, explicitly call
/// the RefreshNetAdaptersInfo() method.
/// </summary>
public static List<FtpAdapterInfo> NetAdapters
{
get
{
if (netAdapters == null) RefreshNetAdaptersInfo();
return netAdapters;
}
}
/// <summary>
/// Refreshes the information about network adapters stored in the netAdapters list.
/// </summary>
public static void RefreshNetAdaptersInfo()
{
if (netAdapters == null) netAdapters = new List<AdapterInfo>();
else netAdapters.Clear();
NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
foreach (NetworkInterface adapter in nics)
{
FtpAdapterInfo info = new FtpAdapterInfo(adapter.Description);
netAdapters.Add(info);
}
}
}
}
@@ -1,24 +0,0 @@
using System.Collections.Generic;
using Config.Entities;
using TBF.Rig.Generic;
namespace TBF.Rig.RegisterReaders.FrequencyMeterFromUniCB
{
public class Factory : IComponentFactory
{
public string ClassName { get { return GetType().Namespace.Substring(8); } }
public override string ToString() { return ClassName; }
public IComponent DummyComponent() { return new FrequencyRegisterReader(); }
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new FrequencyRegisterReader(cfg, components); }
public IComponentCfg DefaultConfig() { return new RRCfg("Frequency", this); }
public IComponentCfg CmpntCfgFromCmpntEntity(Component component)
{
return ComponentCfgBase.CreateFromDbEntity(RRCfg.Serializer, component, this);
}
}
}
@@ -1,47 +0,0 @@
using System;
using System.Collections.Generic;
using Common;
using log4net;
using TBF.Rig.GenericDevices;
namespace TBF.Rig.RegisterReaders.FrequencyMeterFromUniCB
{
public class FrequencyRegisterReader : ComponentBase, GenericDevices.IRegReader
{
private static readonly ILog log = LogManager.GetLogger(typeof(FrequencyRegisterReader));
public override string ToString() { return string.Format("{0}({1})", ClassName, Cfg.ToString(-1)); }
readonly RRCfg rrCfg;
readonly TBF.Rig.ControlBoard.IControlBoard cb;
public int Position { get{ return rrCfg.Position; } }
public Common.RegisterReaderType RegisterReaderType { get { return Common.RegisterReaderType.Pulses; } }
public double PulsesPerLtr { get { return rrCfg.ProcParams.PulsesPerLtr; } }
public double LtrsPerPulse { get { return (PulsesPerLtr <= float.Epsilon) ? 1.0 : (1 / PulsesPerLtr); ; } }
public int Filter { get { return rrCfg.ProcParams.Filter; } }
public int WMPulses { get { return cb.PulsesWM(Position); } }
public int WMRefPulses { get { return cb.RefPulsesWM(Position); } }
public double WMVolume { get { return LtrsPerPulse * Convert.ToDouble(WMPulses); } }
public double BeginWMState { get { return 0; } } /// Always 0
public double EndWMState { get { return WMVolume; } } /// Derived from WMVolume
public FrequencyRegisterReader() { }
public FrequencyRegisterReader(Generic.IComponentCfg cfg, IList<Generic.IComponent> components)
: base(cfg)
{
rrCfg = cfg as RRCfg;
cb = TbfComponents.FindComponent(cfg.ParentName, components) as TBF.Rig.ControlBoard.IControlBoard;
if (cb == null) throw new Exception("Cannot find " + Name + " parent");
log.Warn(this.ToString());
}
public override void Initialize() { }
}
}
@@ -1,51 +0,0 @@
using System.Collections.Generic;
using System.Xml.Serialization;
using Common;
using Config.Entities;
using TBF.Rig.Generic;
namespace TBF.Rig.RegisterReaders.FrequencyMeterFromUniCB
{
public class RRCfg : ComponentCfgBase, Generic.IChildComponentCfg
{
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(RRCfg) })[0];
public override XmlSerializer GetSerializer() { return Serializer; }
IComponentCfgCtrl IComponentCfg.GetControl(IList<Component> cmpntEntities) { return new RRCfgCtrl(); }
///
/// Serialized parameters
///
public int Position; /// 1..nrWaterMeters
/// <summary> Procedure parameters </summary>
[XmlIgnore]
public RRProcParams ProcParams;
public override IParamsProvider GetRuntimeProcParamsProvider() { return ProcParams; }
public override IParamsProvider CreateProcParamsProvider() { return new RRProcParams(true); }
/// Private parameterless constructor invoked by all other (public) constructors
RRCfg()
{
ProcParams = new RRProcParams(true);
}
public RRCfg(string name, IComponentFactory factory)
: this()
{
Name = name;
Factory = factory;
ParentName = "UniCB";
Position = 1;
}
string IComponentCfg.ToString(int i)
{
return string.Format("Name={0}, Parent={1}, Position={2}",
Name,
(string.IsNullOrEmpty(ParentName) ? "-" : ParentName),
Position);
}
}
}
@@ -1,106 +0,0 @@
///
/// Copyright (c) 2021 Sensus Slovensko a.s.
///
using System;
using System.Windows.Forms;
using Common;
using TBF.Rig.Generic;
using TBF.UI.Bench.Components;
namespace TBF.Rig.RegisterReaders.FrequencyMeterFromUniCB
{
public partial class RRCfgCtrl : UserControl, IComponentCfgCtrl
{
ComponentParametersDlg parent;
bool IComponentCfgCtrl.ShowMore { get { return false; } }
RRCfg config;
IComponentCfg IComponentCfgCtrl.Config
{
get { return config as IComponentCfg; }
set
{
config = value as RRCfg;
Redraw();
}
}
public RRCfgCtrl()
{
InitializeComponent();
}
private void RegisterReaderCfgCtrl_Load(object sender, EventArgs e)
{
parent = ParentForm as ComponentParametersDlg;
if (parent == null) return;
if (parent.CmpntEntities != null)
{
foreach (var cmpnt in parent.CmpntEntities)
{
if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is ControlBoard.Uni.Factory)
{
parentNameComboBox.Items.Add(cmpnt.Name);
}
}
}
Redraw();
}
void IComponentCfgCtrl.Closing()
{
}
void Redraw()
{
if (config == null) return; /// Control was not loaded, settings were not changed
componentNameLabel.Text = config.Factory.ClassName;
nameTextBox.Text = config.Name;
parentNameComboBox.Text = string.IsNullOrEmpty(config.ParentName) ? "---" : config.ParentName;
positionTextBox.Text = config.Position.ToString();
}
void IComponentCfgCtrl.Unlock()
{
nameTextBox.Enabled = true;
parentNameComboBox.Enabled = true;
positionTextBox.Enabled = true;
}
CfgUpdateFlags IComponentCfgCtrl.VerifyCfg(ref string message)
{
CfgUpdateFlags flags = CfgUpdateFlags.None;
int dummy;
if (!parentNameComboBox.Items.Contains(parentNameComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Invalid 'Parent Name'";
}
if (!int.TryParse(positionTextBox.Text, out dummy) || (dummy < 1))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'Position' should be >= 1";
}
return flags;
}
CfgUpdateFlags IComponentCfgCtrl.UpdateCfg()
{
CfgUpdateFlags flags = CfgUpdateFlags.RestartRqrd;
if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed
config.Name = nameTextBox.Text;
config.ParentName = parentNameComboBox.Text.Equals("---") ? string.Empty : parentNameComboBox.Text;
config.Position = int.Parse(positionTextBox.Text);
return flags;
}
}
}
@@ -1,133 +0,0 @@
///
/// Copyright (c) 2021 Sensus Slovensko a.s.
///
namespace TBF.Rig.RegisterReaders.FrequencyMeterFromUniCB
{
partial class RRCfgCtrl
{
/// <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.positionTextBox = new System.Windows.Forms.TextBox();
this.positionLabel = new System.Windows.Forms.Label();
this.parentNameLabel = new System.Windows.Forms.Label();
this.nameTextBox = new System.Windows.Forms.TextBox();
this.nameLabel = new System.Windows.Forms.Label();
this.componentNameLabel = new System.Windows.Forms.Label();
this.parentNameComboBox = new System.Windows.Forms.ComboBox();
this.SuspendLayout();
//
// positionTextBox
//
this.positionTextBox.Enabled = false;
this.positionTextBox.Location = new System.Drawing.Point(136, 119);
this.positionTextBox.Name = "positionTextBox";
this.positionTextBox.Size = new System.Drawing.Size(46, 20);
this.positionTextBox.TabIndex = 6;
//
// positionLabel
//
this.positionLabel.AutoSize = true;
this.positionLabel.Location = new System.Drawing.Point(26, 122);
this.positionLabel.Name = "positionLabel";
this.positionLabel.Size = new System.Drawing.Size(44, 13);
this.positionLabel.TabIndex = 5;
this.positionLabel.Text = "Position";
//
// parentNameLabel
//
this.parentNameLabel.AutoSize = true;
this.parentNameLabel.Location = new System.Drawing.Point(26, 96);
this.parentNameLabel.Name = "parentNameLabel";
this.parentNameLabel.Size = new System.Drawing.Size(69, 13);
this.parentNameLabel.TabIndex = 3;
this.parentNameLabel.Text = "Parent Name";
//
// nameTextBox
//
this.nameTextBox.Enabled = false;
this.nameTextBox.Location = new System.Drawing.Point(136, 67);
this.nameTextBox.Name = "nameTextBox";
this.nameTextBox.Size = new System.Drawing.Size(130, 20);
this.nameTextBox.TabIndex = 2;
//
// nameLabel
//
this.nameLabel.AutoSize = true;
this.nameLabel.Location = new System.Drawing.Point(26, 70);
this.nameLabel.Name = "nameLabel";
this.nameLabel.Size = new System.Drawing.Size(35, 13);
this.nameLabel.TabIndex = 1;
this.nameLabel.Text = "Name";
//
// componentNameLabel
//
this.componentNameLabel.AutoSize = true;
this.componentNameLabel.Location = new System.Drawing.Point(133, 43);
this.componentNameLabel.Name = "componentNameLabel";
this.componentNameLabel.Size = new System.Drawing.Size(83, 13);
this.componentNameLabel.TabIndex = 0;
this.componentNameLabel.Text = "ComonentName";
//
// parentNameComboBox
//
this.parentNameComboBox.Enabled = false;
this.parentNameComboBox.FormattingEnabled = true;
this.parentNameComboBox.Location = new System.Drawing.Point(136, 93);
this.parentNameComboBox.Name = "parentNameComboBox";
this.parentNameComboBox.Size = new System.Drawing.Size(130, 21);
this.parentNameComboBox.TabIndex = 4;
//
// RegisterReaderCfgCtrl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.parentNameComboBox);
this.Controls.Add(this.positionTextBox);
this.Controls.Add(this.positionLabel);
this.Controls.Add(this.parentNameLabel);
this.Controls.Add(this.nameTextBox);
this.Controls.Add(this.nameLabel);
this.Controls.Add(this.componentNameLabel);
this.Name = "RegisterReaderCfgCtrl";
this.Size = new System.Drawing.Size(300, 200);
this.Load += new System.EventHandler(this.RegisterReaderCfgCtrl_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TextBox positionTextBox;
private System.Windows.Forms.Label positionLabel;
private System.Windows.Forms.Label parentNameLabel;
private System.Windows.Forms.TextBox nameTextBox;
private System.Windows.Forms.Label nameLabel;
private System.Windows.Forms.Label componentNameLabel;
private System.Windows.Forms.ComboBox parentNameComboBox;
}
}
+92
View File
@@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using log4net;
using Common;
using Config.Entities;
@@ -68,6 +69,94 @@ namespace TBF.Rig.Sequences
protected GenericDevices.IDataEntry lastDataEntryCmpnt;
///TODO open valve
///
protected void OpenValveGrabImage(ControlBoard.IControlBoard cBrd,IOperation additionalOperation, IValve triggerValve,IList<Event> e, string stateName)
{
//Test if diverter is open
IDiverter diverter = cBrd.Devices.Diverter;
if (diverter != null)
{
log.DebugFormat("Diverter state - start Grab Image: {0}, number: {1}",
diverter.State == true ? "-to tank-" : "bypass tank", diverter.DiverterNr);
}
if (additionalOperation != null)
{
log.Debug("Open Valve GrabImage - with additionalOperation");
State valveOpen = State.Create(stateName)
.AddOperation(checkUiOp)
.AddOperation(cBrd.SetValvesOp(triggerValve, null))
.AddOperation(additionalOperation)
.EnterState();
}
else
{
log.Debug("Open Valve GrabImage - NO additionalOperation");
State valveOpen = State.Create(stateName)
.AddOperation(checkUiOp)
.AddOperation(cBrd.SetValvesOp(triggerValve, null))
.EnterState();
}
do
{
e = StateMachine.WaitRunDevsRunOps();
if (e.Contains(Event.Error)) break;
} while (e.Contains(Event.ValvesBusy));
log.Debug("Trigger send, opened valve: "+ triggerValve?.Name );
Thread.Sleep(1000);
if (diverter != null)
{
log.DebugFormat("Diverter state - after: {0}, diverter number: {1}",
diverter.State == true ? "-to tank-" : "bypass tank", diverter.DiverterNr);
}
}
protected void CloseValveGrabImage(ControlBoard.IControlBoard cBrd, IOperation additionalOperation, IValve triggerValve,IList<Event> e, string stateName)
{
//Test if diverter is open
IDiverter diverter = cBrd.Devices.Diverter;
if (diverter != null)
{
log.DebugFormat("Diverter state before Grab Image: {0}, number: {1}",
diverter.State == true ? "-to tank-" : "bypass tank", diverter.DiverterNr);
}
Thread.Sleep(2000);
if (additionalOperation != null)
{
log.Debug("Close Valve GrabImage - with additionalOperation");
State valveOpen = State.Create(stateName)
.AddOperation(checkUiOp)
.AddOperation(cBrd.SetValvesOp(null, triggerValve))
.AddOperation(additionalOperation)
.EnterState();
}
else
{
log.Debug("Close Valve GrabImage - NO additionalOperation");
State valveOpen = State.Create(stateName)
.AddOperation(checkUiOp)
.AddOperation(cBrd.SetValvesOp(null, triggerValve))
.EnterState();
}
do
{
e = StateMachine.WaitRunDevsRunOps();
if (e.Contains(Event.Error)) break;
} while (e.Contains(Event.ValvesBusy));
log.Debug("Trigger send, closed valve: "+ triggerValve?.Name );
if (diverter != null)
{
log.DebugFormat("Diverter state - after: {0}, num: {1}",
diverter.State == true ? "-to tank-" : "bypass tank", diverter.DiverterNr);
}
}
/// <summary>
/// Used in tests in measurement loop to display remaining test time
/// </summary>
@@ -979,6 +1068,9 @@ namespace TBF.Rig.Sequences
.AddOperation(benchPath.PressMtrUp == null ? null : benchPath.PressMtrUp.ReadPressureOp(ref PressUp))
.AddOperation(benchPath.PressMtrDown == null ? null : benchPath.PressMtrDown.ReadPressureOp(ref PressDown))
.AddOperation(benchPath.PressMtrDelta == null ? null : benchPath.PressMtrDelta.ReadPressureOp(ref PressDelta))
.AddOperation(benchPath.ElectricMtrUp == null ? null : benchPath.ElectricMtrUp.ReadAdjustableOp(ref ElectricUp))
.AddOperation(benchPath.ElectricMtrDown == null ? null : benchPath.ElectricMtrDown.ReadAdjustableOp(ref ElectricDown))
.AddOperation(benchPath.ElectricMtrDelta == null ? null : benchPath.ElectricMtrDelta.ReadAdjustableOp(ref ElectricDelta))
.AddOperation(heatMetersPath == null ? null : heatMetersPath.TMeterRefWarm1.ReadTempOp(ref TempRefHi1))
.AddOperation(heatMetersPath == null ? null : heatMetersPath.TMeterRefWarm2.ReadTempOp(ref TempRefHi2))
.AddOperation(heatMetersPath == null ? null : heatMetersPath.TMeterRefCold1.ReadTempOp(ref TempRefLo1))
+3 -1
View File
@@ -73,10 +73,13 @@ namespace TBF.Rig
new Modbus.UltrasoundLevelMeter.Factory(),
new Modbus.WaterAnalyzer.Factory(),
new Network.Adapter.Factory(),
new Network.AdapterFTP.Factory(),
new Network.Camera.CLP1611.Factory(),
new Network.Camera.KeyenceIV3G120.Factory(),
new Network.Camera.Display.Factory(),
new Network.Camera.Roi.Factory(),
new Network.Camera.RoiForFixedStart.Factory(),
new Network.Camera.RoiForFixedStartKeyence.Factory(),
new Network.Comet.Ambient.Factory(),
new Output.DB.ProductionTracing.Factory(),
new Output.DB.SaveDiverterCorrections.Factory(),
@@ -118,7 +121,6 @@ namespace TBF.Rig
new BuiltIn.PumpTandem.PumpFactory(),
new RegisterReaders.DataStream.MefImport.Factory(), /// 'Interface for data stream stream via MEF'
new RegisterReaders.DataStream.Reader.Factory(), /// 'RegisterReader for data stream stream via MEF'
new RegisterReaders.FrequencyMeterFromUniCB.Factory(), ///
new RegisterReaders.PulsesFromUniCB.Factory(), /// 'RegisterReader'
new RegisterReaders.StandingStartStop.Factory(), /// 'RegisterReader for standing start/stop'
new TestMethods.iPerlCommunication.iPerlHead.Factory(), /// 'RegisterReader for iPerl'
@@ -136,6 +136,9 @@ namespace TBF.Rig.TestMethods.Adjustment
if (benchPath.PressMtrUp != null) readTempPressOps.Add(benchPath.PressMtrUp.ReadPressureOp(ref PressUp));
if (benchPath.PressMtrDown != null) readTempPressOps.Add(benchPath.PressMtrDown.ReadPressureOp(ref PressDown));
if (benchPath.PressMtrDelta != null) readTempPressOps.Add(benchPath.PressMtrDelta.ReadPressureOp(ref PressDelta));
if (benchPath.ElectricMtrUp != null) readTempPressOps.Add(benchPath.ElectricMtrUp.ReadPressureOp(ref ElectricUp));
if (benchPath.ElectricMtrDown != null) readTempPressOps.Add(benchPath.ElectricMtrDown.ReadPressureOp(ref ElectricDown));
if (benchPath.ElectricMtrDelta != null) readTempPressOps.Add(benchPath.ElectricMtrDelta.ReadPressureOp(ref ElectricDelta));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefWarm1.ReadTempOp(ref TempRefHi1));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefWarm2.ReadTempOp(ref TempRefHi2));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefCold1.ReadTempOp(ref TempRefLo1));
@@ -119,6 +119,9 @@ namespace TBF.Rig.TestMethods.CombinedWithDetection
if (benchPath.PressMtrUp != null) readTempPressOps.Add(benchPath.PressMtrUp.ReadPressureOp(ref PressUp));
if (benchPath.PressMtrDown != null) readTempPressOps.Add(benchPath.PressMtrDown.ReadPressureOp(ref PressDown));
if (benchPath.PressMtrDelta != null) readTempPressOps.Add(benchPath.PressMtrDelta.ReadPressureOp(ref PressDelta));
if (benchPath.ElectricMtrUp != null) readTempPressOps.Add(benchPath.ElectricMtrUp.ReadPressureOp(ref ElectricUp));
if (benchPath.ElectricMtrDown != null) readTempPressOps.Add(benchPath.ElectricMtrDown.ReadPressureOp(ref ElectricDown));
if (benchPath.ElectricMtrDelta != null) readTempPressOps.Add(benchPath.ElectricMtrDelta.ReadPressureOp(ref ElectricDelta));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefWarm1.ReadTempOp(ref TempRefHi1));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefWarm2.ReadTempOp(ref TempRefHi2));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefCold1.ReadTempOp(ref TempRefLo1));
@@ -126,6 +126,9 @@ namespace TBF.Rig.TestMethods.DiverterTest
if (benchPath.PressMtrUp != null) readTempPressOps.Add(benchPath.PressMtrUp.ReadPressureOp(ref PressUp));
if (benchPath.PressMtrDown != null) readTempPressOps.Add(benchPath.PressMtrDown.ReadPressureOp(ref PressDown));
if (benchPath.PressMtrDelta != null) readTempPressOps.Add(benchPath.PressMtrDelta.ReadPressureOp(ref PressDelta));
if (benchPath.ElectricMtrUp != null) readTempPressOps.Add(benchPath.ElectricMtrUp.ReadPressureOp(ref ElectricUp));
if (benchPath.ElectricMtrDown != null) readTempPressOps.Add(benchPath.ElectricMtrDown.ReadPressureOp(ref ElectricDown));
if (benchPath.ElectricMtrDelta != null) readTempPressOps.Add(benchPath.ElectricMtrDelta.ReadPressureOp(ref ElectricDelta));
int totalPulses = Convert.ToInt32(test.Volume / outPath.FlowMeter.LtrPerPulse);
+3 -3
View File
@@ -36,9 +36,9 @@ namespace TBF.Rig.TestMethods.Dummy
if (benchPath.PressMtrUp != null) readTempPressOps.Add(benchPath.PressMtrUp.ReadPressureOp(ref PressUp));
if (benchPath.PressMtrDown != null) readTempPressOps.Add(benchPath.PressMtrDown.ReadPressureOp(ref PressDown));
if (benchPath.PressMtrDelta != null) readTempPressOps.Add(benchPath.PressMtrDelta.ReadPressureOp(ref PressDelta));
if (benchPath.ElectricMtrUp != null) readTempPressOps.Add(benchPath.PressMtrUp.ReadPressureOp(ref ElectricUp));
if (benchPath.ElectricMtrDown != null) readTempPressOps.Add(benchPath.PressMtrDown.ReadPressureOp(ref ElectricDown));
if (benchPath.ElectricMtrDelta != null) readTempPressOps.Add(benchPath.PressMtrDelta.ReadPressureOp(ref ElectricDelta));
if (benchPath.ElectricMtrUp != null) readTempPressOps.Add(benchPath.ElectricMtrUp.ReadPressureOp(ref ElectricUp));
if (benchPath.ElectricMtrDown != null) readTempPressOps.Add(benchPath.ElectricMtrDown.ReadPressureOp(ref ElectricDown));
if (benchPath.ElectricMtrDelta != null) readTempPressOps.Add(benchPath.ElectricMtrDelta.ReadPressureOp(ref ElectricDelta));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefWarm1.ReadTempOp(ref TempRefHi1));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefWarm2.ReadTempOp(ref TempRefHi2));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefCold1.ReadTempOp(ref TempRefLo1));
@@ -104,6 +104,9 @@ namespace TBF.Rig.TestMethods.Endurance
if (benchPath.PressMtrUp != null) readTempPressOps.Add(benchPath.PressMtrUp.ReadPressureOp(ref PressUp));
if (benchPath.PressMtrDown != null) readTempPressOps.Add(benchPath.PressMtrDown.ReadPressureOp(ref PressDown));
if (benchPath.PressMtrDelta != null) readTempPressOps.Add(benchPath.PressMtrDelta.ReadPressureOp(ref PressDelta));
if (benchPath.ElectricMtrUp != null) readTempPressOps.Add(benchPath.ElectricMtrUp.ReadPressureOp(ref ElectricUp));
if (benchPath.ElectricMtrDown != null) readTempPressOps.Add(benchPath.ElectricMtrDown.ReadPressureOp(ref ElectricDown));
if (benchPath.ElectricMtrDelta != null) readTempPressOps.Add(benchPath.ElectricMtrDelta.ReadPressureOp(ref ElectricDelta));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefWarm1.ReadTempOp(ref TempRefHi1));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefWarm2.ReadTempOp(ref TempRefHi2));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefCold1.ReadTempOp(ref TempRefLo1));
@@ -100,6 +100,9 @@ namespace TBF.Rig.TestMethods.FixedStart
if (benchPath.PressMtrUp != null) readTempPressOps.Add(benchPath.PressMtrUp.ReadPressureOp(ref PressUp));
if (benchPath.PressMtrDown != null) readTempPressOps.Add(benchPath.PressMtrDown.ReadPressureOp(ref PressDown));
if (benchPath.PressMtrDelta != null) readTempPressOps.Add(benchPath.PressMtrDelta.ReadPressureOp(ref PressDelta));
if (benchPath.ElectricMtrUp != null) readTempPressOps.Add(benchPath.ElectricMtrUp.ReadPressureOp(ref ElectricUp));
if (benchPath.ElectricMtrDown != null) readTempPressOps.Add(benchPath.ElectricMtrDown.ReadPressureOp(ref ElectricDown));
if (benchPath.ElectricMtrDelta != null) readTempPressOps.Add(benchPath.ElectricMtrDelta.ReadPressureOp(ref ElectricDelta));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefWarm1.ReadTempOp(ref TempRefHi1));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefWarm2.ReadTempOp(ref TempRefHi2));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefCold1.ReadTempOp(ref TempRefLo1));
@@ -388,21 +391,37 @@ namespace TBF.Rig.TestMethods.FixedStart
{
string fileName = string.Format("{0}-start.bmp", test.Name);
IValve triggerValve = null;
bool triggerSend = false;
if (dataEntryCmpnt is GenericDevices.IDataEntryForCamera)
{
string[] startImages = new string[sensPath.RegisterReaders.Length];
log.Debug("Enter watermeter begin states - dataEntryCmpnt is GenericDevices.IDataEntryForCamera - startImages: " + startImages.Length);
State state2 = State.Create(string.Format("{0}({1}) : Grabbing images", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperations(readTempPressOps);
for (int i = 0; i < sensPath.RegisterReaders.Length; i++)
{
GenericDevices.IRegReaderStillCamera roi = sensPath.RegisterReaders[i] as GenericDevices.IRegReaderStillCamera;
if (roi != null)
{
///if exist valve trigger camera open
triggerValve = roi.GetValve();
if (triggerValve != null && !triggerSend)
{
OpenValveGrabImage(cBrd,null,triggerValve, e,
string.Format("{0}({1}) : Grabbing images - valve open", test.Method, test.Name));
triggerSend = true;
}
string directory = Path.Combine(Program.TempImagesDir, BatchRslts.Batch.BatchNr.ToString(), (i + 1).ToString());
Directory.CreateDirectory(directory);
log.Debug("Enter watermeter begin states - roi - created dir: " + directory);
startImages[i] = Path.Combine(directory, fileName);
log.Debug("Enter watermeter begin states - roi - st: " + fileName);
state2.AddOperation(roi.GrabImageOp(startImages[i]));
}
}
@@ -419,6 +438,12 @@ namespace TBF.Rig.TestMethods.FixedStart
(dataEntryCmpnt as GenericDevices.IDataEntryForCamera).StartImages = startImages;
}
///valve trigger camera close
if (triggerValve != null)
{
CloseValveGrabImage(cBrd, null,triggerValve, e,
string.Format("{0}({1}) : Grabbing images - valve close", test.Method, test.Name));
}
Bridge.OnActivity(this, Strings.Enter_water_meter_data);
State.Create(string.Format("{0}({1}) : Entering begin-state", test.Method, test.Name))
@@ -460,6 +485,8 @@ namespace TBF.Rig.TestMethods.FixedStart
if (rr is Rig.Network.Camera.RoiForFixedStart.Roi)
(rr as Rig.Network.Camera.RoiForFixedStart.Roi).BeginWMState = dataEntryCmpnt.WMStartState(i);
if (rr is Rig.Network.Camera.RoiForFixedStartKeyence.Roi)
(rr as Rig.Network.Camera.RoiForFixedStartKeyence.Roi).BeginWMState = dataEntryCmpnt.WMStartState(i);
}
}
@@ -647,9 +674,12 @@ namespace TBF.Rig.TestMethods.FixedStart
{
string fileName = string.Format("{0}-end.bmp", test.Name);
IValve triggerValve = null;
bool triggerSend = false;
if (dataEntryCmpnt is GenericDevices.IDataEntryForCamera)
{
string[] endImages = new string[sensPath.RegisterReaders.Length];
log.Debug("endImages:" + endImages);
State state2 = State.Create(string.Format("{0}({1}) : Grabbing images", test.Method, test.Name))
.AddOperation(checkUiOp)
@@ -660,9 +690,18 @@ namespace TBF.Rig.TestMethods.FixedStart
GenericDevices.IRegReaderStillCamera roi = sensPath.RegisterReaders[i] as GenericDevices.IRegReaderStillCamera;
if (roi != null)
{
///if exist valve trigger camera open
triggerValve = roi.GetValve();
if (triggerValve != null && !triggerSend)
{
OpenValveGrabImage(cBrd,null,triggerValve,e,string.Format("{0}({1}) : Grabbing images - valve open", test.Method, test.Name));
triggerSend = true;
}
string directory = Path.Combine(Program.TempImagesDir, BatchRslts.Batch.BatchNr.ToString(), (i + 1).ToString());
Directory.CreateDirectory(directory);
endImages[i] = Path.Combine(directory, fileName);
log.Debug("GrabImageOp: " + endImages[i]);
state2.AddOperation(roi.GrabImageOp(endImages[i]));
}
}
@@ -680,6 +719,12 @@ namespace TBF.Rig.TestMethods.FixedStart
(dataEntryCmpnt as GenericDevices.IDataEntryForCamera).EndImages = endImages;
}
///valve trigger camera close
if (triggerValve != null)
{
CloseValveGrabImage(cBrd,null, triggerValve,e,string.Format("{0}({1}) : Grabbing images - valve close", test.Method, test.Name));
}
Bridge.OnActivity(this, Strings.Enter_water_meter_data);
State state = State.Create(string.Format("{0}({1}) : Entering the end-state", test.Method, test.Name));
if (heatMetersTestParams != null && dataEntryCmpnt is GenericDevices.IHasHeatMtrStatesForm)
@@ -109,6 +109,9 @@ namespace TBF.Rig.TestMethods.FixedStartAdvanced
if (benchPath.PressMtrUp != null) readTempPressOps.Add(benchPath.PressMtrUp.ReadPressureOp(ref PressUp));
if (benchPath.PressMtrDown != null) readTempPressOps.Add(benchPath.PressMtrDown.ReadPressureOp(ref PressDown));
if (benchPath.PressMtrDelta != null) readTempPressOps.Add(benchPath.PressMtrDelta.ReadPressureOp(ref PressDelta));
if (benchPath.ElectricMtrUp != null) readTempPressOps.Add(benchPath.ElectricMtrUp.ReadAdjustableOp(ref ElectricUp));
if (benchPath.ElectricMtrDown != null) readTempPressOps.Add(benchPath.ElectricMtrDown.ReadAdjustableOp(ref ElectricDown));
if (benchPath.ElectricMtrDelta != null) readTempPressOps.Add(benchPath.ElectricMtrDelta.ReadAdjustableOp(ref ElectricDelta));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefWarm1.ReadTempOp(ref TempRefHi1));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefWarm2.ReadTempOp(ref TempRefHi2));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefCold1.ReadTempOp(ref TempRefLo1));
@@ -119,6 +119,9 @@ namespace TBF.Rig.TestMethods.FixedStartDeferredEval
if (benchPath.PressMtrUp != null) readTempPressOps.Add(benchPath.PressMtrUp.ReadPressureOp(ref PressUp));
if (benchPath.PressMtrDown != null) readTempPressOps.Add(benchPath.PressMtrDown.ReadPressureOp(ref PressDown));
if (benchPath.PressMtrDelta != null) readTempPressOps.Add(benchPath.PressMtrDelta.ReadPressureOp(ref PressDelta));
if (benchPath.ElectricMtrUp != null) readTempPressOps.Add(benchPath.ElectricMtrUp.ReadAdjustableOp(ref ElectricUp));
if (benchPath.ElectricMtrDown != null) readTempPressOps.Add(benchPath.ElectricMtrDown.ReadAdjustableOp(ref ElectricDown));
if (benchPath.ElectricMtrDelta != null) readTempPressOps.Add(benchPath.ElectricMtrDelta.ReadAdjustableOp(ref ElectricDelta));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefWarm1.ReadTempOp(ref TempRefHi1));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefWarm2.ReadTempOp(ref TempRefHi2));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefCold1.ReadTempOp(ref TempRefLo1));
@@ -127,6 +127,9 @@ namespace TBF.Rig.TestMethods.FixedStartMassCollAdvanced
if (benchPath.PressMtrUp != null) readTempPressOps.Add(benchPath.PressMtrUp.ReadPressureOp(ref PressUp));
if (benchPath.PressMtrDown != null) readTempPressOps.Add(benchPath.PressMtrDown.ReadPressureOp(ref PressDown));
if (benchPath.PressMtrDelta != null) readTempPressOps.Add(benchPath.PressMtrDelta.ReadPressureOp(ref PressDelta));
if (benchPath.ElectricMtrUp != null) readTempPressOps.Add(benchPath.ElectricMtrUp.ReadAdjustableOp(ref ElectricUp));
if (benchPath.ElectricMtrDown != null) readTempPressOps.Add(benchPath.ElectricMtrDown.ReadAdjustableOp(ref ElectricDown));
if (benchPath.ElectricMtrDelta != null) readTempPressOps.Add(benchPath.ElectricMtrDelta.ReadAdjustableOp(ref ElectricDelta));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefWarm1.ReadTempOp(ref TempRefHi1));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefWarm2.ReadTempOp(ref TempRefHi2));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefCold1.ReadTempOp(ref TempRefLo1));
@@ -340,6 +343,8 @@ namespace TBF.Rig.TestMethods.FixedStartMassCollAdvanced
if (rr is Rig.Network.Camera.RoiForFixedStart.Roi)
(rr as Rig.Network.Camera.RoiForFixedStart.Roi).BeginWMState = dataEntryCmpnt.WMStartState(i);
if (rr is Rig.Network.Camera.RoiForFixedStartKeyence.Roi)
(rr as Rig.Network.Camera.RoiForFixedStartKeyence.Roi).BeginWMState = dataEntryCmpnt.WMStartState(i);
}
}
@@ -144,6 +144,9 @@ namespace TBF.Rig.TestMethods.FixedStartMassCollDeferredEval
if (benchPath.PressMtrUp != null) readTempPressOps.Add(benchPath.PressMtrUp.ReadPressureOp(ref PressUp));
if (benchPath.PressMtrDown != null) readTempPressOps.Add(benchPath.PressMtrDown.ReadPressureOp(ref PressDown));
if (benchPath.PressMtrDelta != null) readTempPressOps.Add(benchPath.PressMtrDelta.ReadPressureOp(ref PressDelta));
if (benchPath.ElectricMtrUp != null) readTempPressOps.Add(benchPath.ElectricMtrUp.ReadPressureOp(ref ElectricUp));
if (benchPath.ElectricMtrDown != null) readTempPressOps.Add(benchPath.ElectricMtrDown.ReadPressureOp(ref ElectricDown));
if (benchPath.ElectricMtrDelta != null) readTempPressOps.Add(benchPath.ElectricMtrDelta.ReadPressureOp(ref ElectricDelta));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefWarm1.ReadTempOp(ref TempRefHi1));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefWarm2.ReadTempOp(ref TempRefHi2));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefCold1.ReadTempOp(ref TempRefLo1));
@@ -123,6 +123,9 @@ namespace TBF.Rig.TestMethods.FixedStartTankCollection
if (benchPath.PressMtrUp != null) readTempPressOps.Add(benchPath.PressMtrUp.ReadPressureOp(ref PressUp));
if (benchPath.PressMtrDown != null) readTempPressOps.Add(benchPath.PressMtrDown.ReadPressureOp(ref PressDown));
if (benchPath.PressMtrDelta != null) readTempPressOps.Add(benchPath.PressMtrDelta.ReadPressureOp(ref PressDelta));
if (benchPath.ElectricMtrUp != null) readTempPressOps.Add(benchPath.ElectricMtrUp.ReadPressureOp(ref ElectricUp));
if (benchPath.ElectricMtrDown != null) readTempPressOps.Add(benchPath.ElectricMtrDown.ReadPressureOp(ref ElectricDown));
if (benchPath.ElectricMtrDelta != null) readTempPressOps.Add(benchPath.ElectricMtrDelta.ReadPressureOp(ref ElectricDelta));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefWarm1.ReadTempOp(ref TempRefHi1));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefWarm2.ReadTempOp(ref TempRefHi2));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefCold1.ReadTempOp(ref TempRefLo1));
@@ -411,9 +414,10 @@ namespace TBF.Rig.TestMethods.FixedStartTankCollection
if (rr is Rig.RegisterReaders.StandingStartStop.RegisterReader)
(rr as Rig.RegisterReaders.StandingStartStop.RegisterReader).BeginWMState = dataEntryCmpnt.WMStartState(i);
if (rr is Rig.Network.Camera.RoiForFixedStart.Roi)
(rr as Rig.Network.Camera.RoiForFixedStart.Roi).BeginWMState = dataEntryCmpnt.WMStartState(i);
if (rr is Rig.Network.Camera.RoiForFixedStartKeyence.Roi)
(rr as Rig.Network.Camera.RoiForFixedStartKeyence.Roi).BeginWMState = dataEntryCmpnt.WMStartState(i);
}
if (dataEntryCmpnt is GenericDevices.IDataEntryForCamera && (dataEntryCmpnt as GenericDevices.IDataEntryForCamera).SaveImages)
@@ -659,11 +663,24 @@ namespace TBF.Rig.TestMethods.FixedStartTankCollection
GenericDevices.IRegReader rr = sensPath.RegisterReaders[i];
if (rr is Rig.RegisterReaders.StandingStartStop.RegisterReader)
(rr as Rig.RegisterReaders.StandingStartStop.RegisterReader).EndWMState = dataEntryCmpnt.WMEndState(i);
{
(rr as Rig.RegisterReaders.StandingStartStop.RegisterReader).EndWMState =
dataEntryCmpnt.WMEndState(i);
log.DebugFormat(" FixedStartTankCollectionSeq.cs - EndWMState [{0}] -> Rig.RegisterReaders.StandingStartStop.RegisterReader",dataEntryCmpnt.WMEndState(i));
}
if (rr is Rig.Network.Camera.RoiForFixedStart.Roi)
{
(rr as Rig.Network.Camera.RoiForFixedStart.Roi).EndWMState = dataEntryCmpnt.WMEndState(i);
}
log.DebugFormat(" FixedStartTankCollectionSeq.cs - EndWMState [{0}] -> Rig.Network.Camera.RoiForFixedStart.Roi",dataEntryCmpnt.WMEndState(i));
}
if (rr is Rig.Network.Camera.RoiForFixedStartKeyence.Roi)
{
(rr as Rig.Network.Camera.RoiForFixedStartKeyence.Roi).EndWMState = dataEntryCmpnt.WMEndState(i);
log.DebugFormat(" FixedStartTankCollectionSeq.cs - EndWMState [{0}] -> Rig.Network.Camera.RoiForFixedStartKeyence.Roi",dataEntryCmpnt.WMEndState(i));
}
}
if (dataEntryCmpnt is GenericDevices.IDataEntryForCamera && (dataEntryCmpnt as GenericDevices.IDataEntryForCamera).SaveImages)
{
@@ -106,6 +106,9 @@ namespace TBF.Rig.TestMethods.FlowAdjustment
if (benchPath.PressMtrUp != null) readTempPressOps.Add(benchPath.PressMtrUp.ReadPressureOp(ref PressUp));
if (benchPath.PressMtrDown != null) readTempPressOps.Add(benchPath.PressMtrDown.ReadPressureOp(ref PressDown));
if (benchPath.PressMtrDelta != null) readTempPressOps.Add(benchPath.PressMtrDelta.ReadPressureOp(ref PressDelta));
if (benchPath.ElectricMtrUp != null) readTempPressOps.Add(benchPath.ElectricMtrUp.ReadPressureOp(ref ElectricUp));
if (benchPath.ElectricMtrDown != null) readTempPressOps.Add(benchPath.ElectricMtrDown.ReadPressureOp(ref ElectricDown));
if (benchPath.ElectricMtrDelta != null) readTempPressOps.Add(benchPath.ElectricMtrDelta.ReadPressureOp(ref ElectricDelta));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefWarm1.ReadTempOp(ref TempRefHi1));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefWarm2.ReadTempOp(ref TempRefHi2));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefCold1.ReadTempOp(ref TempRefLo1));
@@ -107,6 +107,9 @@ namespace TBF.Rig.TestMethods.FlyingStart
if (benchPath.PressMtrUp != null) readTempPressOps.Add(benchPath.PressMtrUp.ReadPressureOp(ref PressUp));
if (benchPath.PressMtrDown != null) readTempPressOps.Add(benchPath.PressMtrDown.ReadPressureOp(ref PressDown));
if (benchPath.PressMtrDelta != null) readTempPressOps.Add(benchPath.PressMtrDelta.ReadPressureOp(ref PressDelta));
if (benchPath.ElectricMtrUp != null) readTempPressOps.Add(benchPath.ElectricMtrUp.ReadPressureOp(ref ElectricUp));
if (benchPath.ElectricMtrDown != null) readTempPressOps.Add(benchPath.ElectricMtrDown.ReadPressureOp(ref ElectricDown));
if (benchPath.ElectricMtrDelta != null) readTempPressOps.Add(benchPath.ElectricMtrDelta.ReadPressureOp(ref ElectricDelta));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefWarm1.ReadTempOp(ref TempRefHi1));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefWarm2.ReadTempOp(ref TempRefHi2));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefCold1.ReadTempOp(ref TempRefLo1));
@@ -140,6 +140,9 @@ namespace TBF.Rig.TestMethods.FlyingStartFirstRepetWithMassColl
if (benchPath.PressMtrUp != null) readTempPressOps.Add(benchPath.PressMtrUp.ReadPressureOp(ref PressUp));
if (benchPath.PressMtrDown != null) readTempPressOps.Add(benchPath.PressMtrDown.ReadPressureOp(ref PressDown));
if (benchPath.PressMtrDelta != null) readTempPressOps.Add(benchPath.PressMtrDelta.ReadPressureOp(ref PressDelta));
if (benchPath.ElectricMtrUp != null) readTempPressOps.Add(benchPath.ElectricMtrUp.ReadPressureOp(ref ElectricUp));
if (benchPath.ElectricMtrDown != null) readTempPressOps.Add(benchPath.ElectricMtrDown.ReadPressureOp(ref ElectricDown));
if (benchPath.ElectricMtrDelta != null) readTempPressOps.Add(benchPath.ElectricMtrDelta.ReadPressureOp(ref ElectricDelta));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefWarm1.ReadTempOp(ref TempRefHi1));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefWarm2.ReadTempOp(ref TempRefHi2));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefCold1.ReadTempOp(ref TempRefLo1));
@@ -161,6 +161,9 @@ namespace TBF.Rig.TestMethods.FlyingStartMassCollComparative
if (benchPath.PressMtrUp != null) readTempPressOps.Add(benchPath.PressMtrUp.ReadPressureOp(ref PressUp));
if (benchPath.PressMtrDown != null) readTempPressOps.Add(benchPath.PressMtrDown.ReadPressureOp(ref PressDown));
if (benchPath.PressMtrDelta != null) readTempPressOps.Add(benchPath.PressMtrDelta.ReadPressureOp(ref PressDelta));
if (benchPath.ElectricMtrUp != null) readTempPressOps.Add(benchPath.ElectricMtrUp.ReadPressureOp(ref ElectricUp));
if (benchPath.ElectricMtrDown != null) readTempPressOps.Add(benchPath.ElectricMtrDown.ReadPressureOp(ref ElectricDown));
if (benchPath.ElectricMtrDelta != null) readTempPressOps.Add(benchPath.ElectricMtrDelta.ReadPressureOp(ref ElectricDelta));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefWarm1.ReadTempOp(ref TempRefHi1));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefWarm2.ReadTempOp(ref TempRefHi2));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefCold1.ReadTempOp(ref TempRefLo1));
@@ -137,6 +137,9 @@ namespace TBF.Rig.TestMethods.FlyingStartMassCollProlonged
if (benchPath.PressMtrUp != null) readTempPressOps.Add(benchPath.PressMtrUp.ReadPressureOp(ref PressUp));
if (benchPath.PressMtrDown != null) readTempPressOps.Add(benchPath.PressMtrDown.ReadPressureOp(ref PressDown));
if (benchPath.PressMtrDelta != null) readTempPressOps.Add(benchPath.PressMtrDelta.ReadPressureOp(ref PressDelta));
if (benchPath.ElectricMtrUp != null) readTempPressOps.Add(benchPath.ElectricMtrUp.ReadPressureOp(ref ElectricUp));
if (benchPath.ElectricMtrDown != null) readTempPressOps.Add(benchPath.ElectricMtrDown.ReadPressureOp(ref ElectricDown));
if (benchPath.ElectricMtrDelta != null) readTempPressOps.Add(benchPath.ElectricMtrDelta.ReadPressureOp(ref ElectricDelta));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefWarm1.ReadTempOp(ref TempRefHi1));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefWarm2.ReadTempOp(ref TempRefHi2));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefCold1.ReadTempOp(ref TempRefLo1));
@@ -134,6 +134,9 @@ namespace TBF.Rig.TestMethods.FlyingStartMassCollection
if(benchPath.PressMtrUp != null) readTempPressOps.Add(benchPath.PressMtrUp.ReadPressureOp(ref PressUp));
if(benchPath.PressMtrDown != null) readTempPressOps.Add(benchPath.PressMtrDown.ReadPressureOp(ref PressDown));
if(benchPath.PressMtrDelta != null) readTempPressOps.Add(benchPath.PressMtrDelta.ReadPressureOp(ref PressDelta));
if(benchPath.ElectricMtrUp != null) readTempPressOps.Add(benchPath.ElectricMtrUp.ReadPressureOp(ref ElectricUp));
if(benchPath.ElectricMtrDown != null) readTempPressOps.Add(benchPath.ElectricMtrDown.ReadPressureOp(ref ElectricDown));
if(benchPath.ElectricMtrDelta != null) readTempPressOps.Add(benchPath.ElectricMtrDelta.ReadPressureOp(ref ElectricDelta));
if(heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefWarm1.ReadTempOp(ref TempRefHi1));
if(heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefWarm2.ReadTempOp(ref TempRefHi2));
if(heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefCold1.ReadTempOp(ref TempRefLo1));
@@ -143,6 +143,9 @@ namespace TBF.Rig.TestMethods.FlyingStartTankCollection
if (benchPath.PressMtrUp != null) readTempPressOps.Add(benchPath.PressMtrUp.ReadPressureOp(ref PressUp));
if (benchPath.PressMtrDown != null) readTempPressOps.Add(benchPath.PressMtrDown.ReadPressureOp(ref PressDown));
if (benchPath.PressMtrDelta != null) readTempPressOps.Add(benchPath.PressMtrDelta.ReadPressureOp(ref PressDelta));
if (benchPath.ElectricMtrUp != null) readTempPressOps.Add(benchPath.ElectricMtrUp.ReadPressureOp(ref ElectricUp));
if (benchPath.ElectricMtrDown != null) readTempPressOps.Add(benchPath.ElectricMtrDown.ReadPressureOp(ref ElectricDown));
if (benchPath.ElectricMtrDelta != null) readTempPressOps.Add(benchPath.ElectricMtrDelta.ReadPressureOp(ref ElectricDelta));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefWarm1.ReadTempOp(ref TempRefHi1));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefWarm2.ReadTempOp(ref TempRefHi2));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefCold1.ReadTempOp(ref TempRefLo1));
+26 -1
View File
@@ -7,6 +7,7 @@ using Common;
using Config.Entities;
using TBF.UiBridge;
using System.IO;
using TBF.Rig.GenericDevices;
namespace TBF.Rig.TestMethods.GrabImage
{
@@ -29,6 +30,8 @@ namespace TBF.Rig.TestMethods.GrabImage
{
IList<Event> e = new List<Event>(); /// Events from currently running operations
Event retVal = Event.Done;
ControlBoard.IControlBoard cBrd = StateMachine.ControlBoardMain;
/// Operations
checkUiOp = new Operations.CheckUIOp(true);
@@ -41,14 +44,28 @@ namespace TBF.Rig.TestMethods.GrabImage
//------------------------------------------------
State state = State.Create(string.Format("{0}({1}) : Grabbing images", test.Method, test.Name))
.AddOperation(checkUiOp);
IValve triggerValve = null;
bool triggerSend = false;
for (int i = 0; i < sensPath.RegisterReaders.Length; i++)
{
GenericDevices.IRegReaderStillCamera roi = sensPath.RegisterReaders[i] as GenericDevices.IRegReaderStillCamera;
if (roi != null)
{
///if exist valve trigger camera open
triggerValve = roi.GetValve();
if (triggerValve != null && !triggerSend)
{
OpenValveGrabImage(cBrd,null, triggerValve, e,
string.Format("{0}({1}) : Grabbing images - valve open", test.Method, test.Name));
triggerSend = true;
}
string imageName = Path.HasExtension(cfg.ImageFileName)?cfg.ImageFileName:cfg.ImageFileName+".bmp";
log.DebugFormat("GrabImage file name: {0} ", imageName);
string directory = Path.Combine(Program.ImagesDir, BatchRslts.Batch.BatchNr.ToString(), (i+1).ToString());
Directory.CreateDirectory(directory);
state.AddOperation(roi.GrabImageOp(Path.Combine(directory, cfg.ImageFileName),
state.AddOperation(roi.GrabImageOp(Path.Combine(directory, imageName),
cfg.BlackAndWhite,
cfg.LowResolution,
cfg.ImageRotation));
@@ -65,6 +82,14 @@ namespace TBF.Rig.TestMethods.GrabImage
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; break; }
}
while (e.Contains(Event.CameraBusy));
///valve trigger camera close
if (triggerValve != null)
{
CloseValveGrabImage(cBrd,null,triggerValve, e,
string.Format("{0}({1}) : Grabbing images - valve close", test.Method, test.Name));
}
///////
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, 1, Progress.Completed));
return new List<Event> { retVal };
@@ -76,6 +76,9 @@ namespace TBF.Rig.TestMethods.LeakTest
if (benchPath.PressMtrUp != null) readTempPressOps.Add(benchPath.PressMtrUp.ReadPressureOp(ref PressUp));
if (benchPath.PressMtrDown != null) readTempPressOps.Add(benchPath.PressMtrDown.ReadPressureOp(ref PressDown));
if (benchPath.PressMtrDelta != null) readTempPressOps.Add(benchPath.PressMtrDelta.ReadPressureOp(ref PressDelta));
if (benchPath.ElectricMtrUp != null) readTempPressOps.Add(benchPath.ElectricMtrUp.ReadPressureOp(ref ElectricUp));
if (benchPath.ElectricMtrDown != null) readTempPressOps.Add(benchPath.ElectricMtrDown.ReadPressureOp(ref ElectricDown));
if (benchPath.ElectricMtrDelta != null) readTempPressOps.Add(benchPath.ElectricMtrDelta.ReadPressureOp(ref ElectricDelta));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefWarm1.ReadTempOp(ref TempRefHi1));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefWarm2.ReadTempOp(ref TempRefHi2));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefCold1.ReadTempOp(ref TempRefLo1));
@@ -62,6 +62,9 @@ namespace TBF.Rig.TestMethods.PMaxTest
if (benchPath.PressMtrUp != null) readTempPressOps.Add(benchPath.PressMtrUp.ReadPressureOp(ref PressUp));
if (benchPath.PressMtrDown != null) readTempPressOps.Add(benchPath.PressMtrDown.ReadPressureOp(ref PressDown));
if (benchPath.PressMtrDelta != null) readTempPressOps.Add(benchPath.PressMtrDelta.ReadPressureOp(ref PressDelta));
if (benchPath.ElectricMtrUp != null) readTempPressOps.Add(benchPath.ElectricMtrUp.ReadPressureOp(ref ElectricUp));
if (benchPath.ElectricMtrDown != null) readTempPressOps.Add(benchPath.ElectricMtrDown.ReadPressureOp(ref ElectricDown));
if (benchPath.ElectricMtrDelta != null) readTempPressOps.Add(benchPath.ElectricMtrDelta.ReadPressureOp(ref ElectricDelta));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefWarm1.ReadTempOp(ref TempRefHi1));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefWarm2.ReadTempOp(ref TempRefHi2));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefCold1.ReadTempOp(ref TempRefLo1));
@@ -96,6 +96,9 @@ namespace TBF.Rig.TestMethods.PulsesTest
if (benchPath.PressMtrUp != null) readTempPressOps.Add(benchPath.PressMtrUp.ReadPressureOp(ref PressUp));
if (benchPath.PressMtrDown != null) readTempPressOps.Add(benchPath.PressMtrDown.ReadPressureOp(ref PressDown));
if (benchPath.PressMtrDelta != null) readTempPressOps.Add(benchPath.PressMtrDelta.ReadPressureOp(ref PressDelta));
if (benchPath.ElectricMtrUp != null) readTempPressOps.Add(benchPath.ElectricMtrUp.ReadPressureOp(ref ElectricUp));
if (benchPath.ElectricMtrDown != null) readTempPressOps.Add(benchPath.ElectricMtrDown.ReadPressureOp(ref ElectricDown));
if (benchPath.ElectricMtrDelta != null) readTempPressOps.Add(benchPath.ElectricMtrDelta.ReadPressureOp(ref ElectricDelta));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefWarm1.ReadTempOp(ref TempRefHi1));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefWarm2.ReadTempOp(ref TempRefHi2));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefCold1.ReadTempOp(ref TempRefLo1));
@@ -96,6 +96,9 @@ namespace TBF.Rig.TestMethods.PulsesTestManual
if (benchPath.PressMtrUp != null) readTempPressOps.Add(benchPath.PressMtrUp.ReadPressureOp(ref PressUp));
if (benchPath.PressMtrDown != null) readTempPressOps.Add(benchPath.PressMtrDown.ReadPressureOp(ref PressDown));
if (benchPath.PressMtrDelta != null) readTempPressOps.Add(benchPath.PressMtrDelta.ReadPressureOp(ref PressDelta));
if (benchPath.ElectricMtrUp != null) readTempPressOps.Add(benchPath.ElectricMtrUp.ReadPressureOp(ref ElectricUp));
if (benchPath.ElectricMtrDown != null) readTempPressOps.Add(benchPath.ElectricMtrDown.ReadPressureOp(ref ElectricDown));
if (benchPath.ElectricMtrDelta != null) readTempPressOps.Add(benchPath.ElectricMtrDelta.ReadPressureOp(ref ElectricDelta));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefWarm1.ReadTempOp(ref TempRefHi1));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefWarm2.ReadTempOp(ref TempRefHi2));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefCold1.ReadTempOp(ref TempRefLo1));
@@ -51,6 +51,9 @@ namespace TBF.Rig.TestMethods.RoiDetection
if (benchPath.PressMtrUp != null) readTempPressOps.Add(benchPath.PressMtrUp.ReadPressureOp(ref PressUp));
if (benchPath.PressMtrDown != null) readTempPressOps.Add(benchPath.PressMtrDown.ReadPressureOp(ref PressDown));
if (benchPath.PressMtrDelta != null) readTempPressOps.Add(benchPath.PressMtrDelta.ReadPressureOp(ref PressDelta));
if (benchPath.ElectricMtrUp != null) readTempPressOps.Add(benchPath.ElectricMtrUp.ReadPressureOp(ref ElectricUp));
if (benchPath.ElectricMtrDown != null) readTempPressOps.Add(benchPath.ElectricMtrDown.ReadPressureOp(ref ElectricDown));
if (benchPath.ElectricMtrDelta != null) readTempPressOps.Add(benchPath.ElectricMtrDelta.ReadPressureOp(ref ElectricDelta));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefWarm1.ReadTempOp(ref TempRefHi1));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefWarm2.ReadTempOp(ref TempRefHi2));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefCold1.ReadTempOp(ref TempRefLo1));
@@ -75,6 +75,9 @@ namespace TBF.Rig.TestMethods.SensitivityTest
if (benchPath.PressMtrUp != null) readTempPressOps.Add(benchPath.PressMtrUp.ReadPressureOp(ref PressUp));
if (benchPath.PressMtrDown != null) readTempPressOps.Add(benchPath.PressMtrDown.ReadPressureOp(ref PressDown));
if (benchPath.PressMtrDelta != null) readTempPressOps.Add(benchPath.PressMtrDelta.ReadPressureOp(ref PressDelta));
if (benchPath.ElectricMtrUp != null) readTempPressOps.Add(benchPath.ElectricMtrUp.ReadPressureOp(ref ElectricUp));
if (benchPath.ElectricMtrDown != null) readTempPressOps.Add(benchPath.ElectricMtrDown.ReadPressureOp(ref ElectricDown));
if (benchPath.ElectricMtrDelta != null) readTempPressOps.Add(benchPath.ElectricMtrDelta.ReadPressureOp(ref ElectricDelta));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefWarm1.ReadTempOp(ref TempRefHi1));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefWarm2.ReadTempOp(ref TempRefHi2));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefCold1.ReadTempOp(ref TempRefLo1));
@@ -107,6 +107,9 @@ namespace TBF.Rig.TestMethods.StandingStart
if (benchPath.PressMtrUp != null) readTempPressOps.Add(benchPath.PressMtrUp.ReadPressureOp(ref PressUp));
if (benchPath.PressMtrDown != null) readTempPressOps.Add(benchPath.PressMtrDown.ReadPressureOp(ref PressDown));
if (benchPath.PressMtrDelta != null) readTempPressOps.Add(benchPath.PressMtrDelta.ReadPressureOp(ref PressDelta));
if (benchPath.ElectricMtrUp != null) readTempPressOps.Add(benchPath.ElectricMtrUp.ReadPressureOp(ref ElectricUp));
if (benchPath.ElectricMtrDown != null) readTempPressOps.Add(benchPath.ElectricMtrDown.ReadPressureOp(ref ElectricDown));
if (benchPath.ElectricMtrDelta != null) readTempPressOps.Add(benchPath.ElectricMtrDelta.ReadPressureOp(ref ElectricDelta));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefWarm1.ReadTempOp(ref TempRefHi1));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefWarm2.ReadTempOp(ref TempRefHi2));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefCold1.ReadTempOp(ref TempRefLo1));
@@ -508,6 +511,8 @@ namespace TBF.Rig.TestMethods.StandingStart
if (rr is Rig.Network.Camera.RoiForFixedStart.Roi)
(rr as Rig.Network.Camera.RoiForFixedStart.Roi).BeginWMState = dataEntryCmpnt.WMStartState(i);
if (rr is Rig.Network.Camera.RoiForFixedStartKeyence.Roi)
(rr as Rig.Network.Camera.RoiForFixedStartKeyence.Roi).BeginWMState = dataEntryCmpnt.WMStartState(i);
}
}
@@ -124,6 +124,9 @@ namespace TBF.Rig.TestMethods.StandingStartMassCollWODiv
if (benchPath.PressMtrUp != null) readTempPressOps.Add(benchPath.PressMtrUp.ReadPressureOp(ref PressUp));
if (benchPath.PressMtrDown != null) readTempPressOps.Add(benchPath.PressMtrDown.ReadPressureOp(ref PressDown));
if (benchPath.PressMtrDelta != null) readTempPressOps.Add(benchPath.PressMtrDelta.ReadPressureOp(ref PressDelta));
if (benchPath.ElectricMtrUp != null) readTempPressOps.Add(benchPath.ElectricMtrUp.ReadAdjustableOp(ref ElectricUp));
if (benchPath.ElectricMtrDown != null) readTempPressOps.Add(benchPath.ElectricMtrDown.ReadAdjustableOp(ref ElectricDown));
if (benchPath.ElectricMtrDelta != null) readTempPressOps.Add(benchPath.ElectricMtrDelta.ReadAdjustableOp(ref ElectricDelta));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefWarm1.ReadTempOp(ref TempRefHi1));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefWarm2.ReadTempOp(ref TempRefHi2));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefCold1.ReadTempOp(ref TempRefLo1));
@@ -456,6 +459,8 @@ namespace TBF.Rig.TestMethods.StandingStartMassCollWODiv
if (rr is Rig.Network.Camera.RoiForFixedStart.Roi)
(rr as Rig.Network.Camera.RoiForFixedStart.Roi).BeginWMState = dataEntryCmpnt.WMStartState(i);
if (rr is Rig.Network.Camera.RoiForFixedStartKeyence.Roi)
(rr as Rig.Network.Camera.RoiForFixedStartKeyence.Roi).BeginWMState = dataEntryCmpnt.WMStartState(i);
}
if (dataEntryCmpnt is GenericDevices.IDataEntryForCamera && (dataEntryCmpnt as GenericDevices.IDataEntryForCamera).SaveImages)
@@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading;
using log4net;
using Common;
using Config.Entities;
@@ -133,6 +134,9 @@ namespace TBF.Rig.TestMethods.StandingStartMassCollection
if (benchPath.PressMtrUp != null) readTempPressOps.Add(benchPath.PressMtrUp.ReadPressureOp(ref PressUp));
if (benchPath.PressMtrDown != null) readTempPressOps.Add(benchPath.PressMtrDown.ReadPressureOp(ref PressDown));
if (benchPath.PressMtrDelta != null) readTempPressOps.Add(benchPath.PressMtrDelta.ReadPressureOp(ref PressDelta));
if (benchPath.ElectricMtrUp != null) readTempPressOps.Add(benchPath.ElectricMtrUp.ReadPressureOp(ref ElectricUp));
if (benchPath.ElectricMtrDown != null) readTempPressOps.Add(benchPath.ElectricMtrDown.ReadPressureOp(ref ElectricDown));
if (benchPath.ElectricMtrDelta != null) readTempPressOps.Add(benchPath.ElectricMtrDelta.ReadPressureOp(ref ElectricDelta));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefWarm1.ReadTempOp(ref TempRefHi1));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefWarm2.ReadTempOp(ref TempRefHi2));
if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefCold1.ReadTempOp(ref TempRefLo1));
@@ -159,6 +163,7 @@ namespace TBF.Rig.TestMethods.StandingStartMassCollection
/// Start the test, initialize test results
Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, heatMetersPath));
string testName = Results.Utils.GetTestName(test.Name, test.Repeats, repetitionNr);
log.DebugFormat("Start the test - testName: {0}, test -> name: {1} -> Repeats: {2} -> repetitionNr: {3}", testName, test.Name, test.Repeats, repetitionNr);
///
/// Optionally display prompt to emerge temperature meters to appropriate baths for heat meters test
@@ -485,8 +490,10 @@ namespace TBF.Rig.TestMethods.StandingStartMassCollection
if (dataEntryCmpnt != null)
{
string fileName = string.Format("{0}-start.bmp", test.Name);
string fileName = string.Format("{0}-{1}-start.bmp", test.Name, repetitionNr); //string.Format("{0}-start.bmp", test.Name);
IValve triggerValve = null;
bool triggerSend = false;
if (dataEntryCmpnt is GenericDevices.IDataEntryForCamera)
{
string[] startImages = new string[sensPath.RegisterReaders.Length];
@@ -503,6 +510,14 @@ namespace TBF.Rig.TestMethods.StandingStartMassCollection
GenericDevices.IRegReaderStillCamera roi = sensPath.RegisterReaders[i] as GenericDevices.IRegReaderStillCamera;
if (roi != null)
{
///if exist valve trigger camera open
triggerValve = roi.GetValve();
if (triggerValve != null && !triggerSend)
{
OpenValveGrabImage(cBrd,testInProgress, triggerValve, e,
string.Format("{0}({1}) : Grabbing images - valve open", test.Method, test.Name));
triggerSend = true;
}
string directory = Path.Combine(Program.TempImagesDir, BatchRslts.Batch.BatchNr.ToString(), (i + 1).ToString());
Directory.CreateDirectory(directory);
startImages[i] = Path.Combine(directory, fileName);
@@ -529,6 +544,15 @@ namespace TBF.Rig.TestMethods.StandingStartMassCollection
(dataEntryCmpnt as GenericDevices.IDataEntryForCamera).StartImages = startImages;
}
///valve trigger camera close
if (triggerValve != null)
{
CloseValveGrabImage(cBrd,testInProgress,triggerValve, e,
string.Format("{0}({1}) : Grabbing images - valve close", test.Method, test.Name));
}
///////
Bridge.OnActivity(this, Strings.Enter_water_meter_data);
State.Create(string.Format("{0}({1}) : Enter start states of water meters", test.Method, test.Name))
@@ -573,11 +597,18 @@ namespace TBF.Rig.TestMethods.StandingStartMassCollection
if (rr is Rig.Network.Camera.RoiForFixedStart.Roi)
(rr as Rig.Network.Camera.RoiForFixedStart.Roi).BeginWMState = dataEntryCmpnt.WMStartState(i);
if (rr is Rig.Network.Camera.RoiForFixedStartKeyence.Roi)
{
(rr as Rig.Network.Camera.RoiForFixedStartKeyence.Roi).BeginWMState =
dataEntryCmpnt.WMStartState(i);
log.DebugFormat(" StandingStartMassCollectionSeq.cs - BeginWMState [{0}] -> RoiForFixedStartKeyence.Roi",dataEntryCmpnt.WMStartState(i));
}
}
}
if (dataEntryCmpnt is IDataEntryForCamera && (dataEntryCmpnt as IDataEntryForCamera).SaveImages)
{
log.Debug("Save images WMStartState...");
/// SaveImages==true ... copy images to the directory that will be archived at the end of the cycle
for (int i = 0; i < sensPath.RegisterReaders.Length; i++)
{
@@ -594,6 +625,7 @@ namespace TBF.Rig.TestMethods.StandingStartMassCollection
string destFName = string.IsNullOrEmpty((dataEntryCmpnt as IDataEntryForCamera).TestStartImgName(i, testName))
? fileName : (dataEntryCmpnt as IDataEntryForCamera).TestStartImgName(i, testName);
File.Copy(Path.Combine(srcDir, fileName), Path.Combine(destDir, destFName), true);
log.DebugFormat("Save images sourceFile: {0}, destFile: {1} ",Path.Combine(srcDir, fileName), Path.Combine(destDir, destFName));
}
}
catch (Exception exc)
@@ -784,8 +816,10 @@ namespace TBF.Rig.TestMethods.StandingStartMassCollection
///
if (dataEntryCmpnt != null)
{
string fileName = string.Format("{0}-end.bmp", test.Name);
string fileName = string.Format("{0}-{1}-end.bmp", test.Name, repetitionNr); //string.Format("{0}-end.bmp", test.Name);
IValve triggerValve = null;
bool triggerSend = false;
if (dataEntryCmpnt is GenericDevices.IDataEntryForCamera)
{
string[] endImages = new string[sensPath.RegisterReaders.Length];
@@ -797,11 +831,20 @@ namespace TBF.Rig.TestMethods.StandingStartMassCollection
GenericDevices.IRegReaderStillCamera roi = sensPath.RegisterReaders[i] as GenericDevices.IRegReaderStillCamera;
if (roi != null)
{
///if exist valve trigger camera open
triggerValve = roi.GetValve();
if (triggerValve != null && !triggerSend)
{
OpenValveGrabImage(cBrd,testInProgress,triggerValve, e,
string.Format("{0}({1}) : Grabbing images - valve open", test.Method, test.Name));
triggerSend = true;
}
string directory = Path.Combine(Program.TempImagesDir, BatchRslts.Batch.BatchNr.ToString(), (i + 1).ToString());
Directory.CreateDirectory(directory);
endImages[i] = Path.Combine(directory, fileName);
state2.AddOperation(roi.GrabImageOp(endImages[i]));
}
state2.AddOperation(testInProgress);
}
else
{
/// Camera simulation
@@ -823,7 +866,15 @@ namespace TBF.Rig.TestMethods.StandingStartMassCollection
(dataEntryCmpnt as GenericDevices.IDataEntryForCamera).EndImages = endImages;
}
///valve trigger camera close
if (triggerValve != null)
{
CloseValveGrabImage(cBrd,testInProgress, triggerValve, e,
string.Format("{0}({1}) : Grabbing images - valve close", test.Method, test.Name));
}
///////
Bridge.OnActivity(this, Strings.Enter_water_meter_data);
State state = State.Create(string.Format("{0}({1}) : Entering the end-state", test.Method, test.Name));
if (heatMetersTestParams != null && dataEntryCmpnt is GenericDevices.IHasHeatMtrStatesForm)
@@ -840,6 +891,7 @@ namespace TBF.Rig.TestMethods.StandingStartMassCollection
}
state.AddOperation(checkUiOp)
.AddOperations(readTempPressOps)
.AddOperation(testInProgress)
.EnterState();
do {
e = StateMachine.WaitRunDevsRunOps();
@@ -876,11 +928,19 @@ namespace TBF.Rig.TestMethods.StandingStartMassCollection
if (rr is Rig.Network.Camera.RoiForFixedStart.Roi)
(rr as Rig.Network.Camera.RoiForFixedStart.Roi).EndWMState = dataEntryCmpnt.WMEndState(i);
}
if (rr is Rig.Network.Camera.RoiForFixedStartKeyence.Roi)
{
(rr as Rig.Network.Camera.RoiForFixedStartKeyence.Roi).EndWMState =
dataEntryCmpnt.WMEndState(i);
log.DebugFormat(" StandingStartMassCollectionSeq.cs - EndWMState [{0}] -> RoiForFixedStartKeyence.Roi",dataEntryCmpnt.WMEndState(i));
}
}
}
if (dataEntryCmpnt is IDataEntryForCamera && (dataEntryCmpnt as IDataEntryForCamera).SaveImages)
{
log.Debug("Save images EndWMState...");
/// SaveImages==true ... copy images to the directory that will be archived at the end of the cycle
for (int i = 0; i < sensPath.RegisterReaders.Length; i++)
{
@@ -897,6 +957,7 @@ namespace TBF.Rig.TestMethods.StandingStartMassCollection
string destFName = string.IsNullOrEmpty((dataEntryCmpnt as IDataEntryForCamera).TestEndImgName(i, testName))
? fileName : (dataEntryCmpnt as IDataEntryForCamera).TestEndImgName(i, testName);
File.Copy(Path.Combine(srcDir, fileName), Path.Combine(destDir, destFName), true);
log.DebugFormat("Save images sourceFile: {0}, destFile: {1} ",Path.Combine(srcDir, fileName), Path.Combine(destDir, destFName));
}
}
catch (Exception exc)
+41 -13
View File
@@ -592,6 +592,7 @@
<Compile Include="Rig\GenericDevices\IEvaporation.cs" />
<Compile Include="Rig\GenericDevices\IEventTrigger.cs" />
<Compile Include="Rig\GenericDevices\IFlowMeterSingle.cs" />
<Compile Include="Rig\GenericDevices\IFTPAdapter.cs" />
<Compile Include="Rig\GenericDevices\IHasCalendarEvents.cs" />
<Compile Include="Rig\GenericDevices\IParallelOutput.cs" />
<Compile Include="Rig\GenericDevices\IReceivesDataFromRadio.cs" />
@@ -760,6 +761,15 @@
<Compile Include="Rig\Modbus\WaterAnalyzer\AnalyzerCfg.cs" />
<Compile Include="Rig\Modbus\WaterAnalyzer\ReadConductivityOp.cs" />
<Compile Include="Rig\Modbus\WaterAnalyzer\ReadTempOp.cs" />
<Compile Include="Rig\Network\AdapterFTP\Factory.cs" />
<Compile Include="Rig\Network\AdapterFTP\NetFtpAdapter.cs" />
<Compile Include="Rig\Network\AdapterFTP\NetFtpadapterCfg.cs" />
<Compile Include="Rig\Network\AdapterFTP\NetadapterCfgCtrl.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Rig\Network\AdapterFTP\NetadapterCfgCtrl.designer.cs">
<DependentUpon>NetadapterCfgCtrl.cs</DependentUpon>
</Compile>
<Compile Include="Rig\Network\AdapterInfo.cs" />
<Compile Include="Rig\Network\Adapter\Netadapter.cs" />
<Compile Include="Rig\Network\Adapter\Factory.cs" />
@@ -806,6 +816,28 @@
<Compile Include="Rig\Network\Camera\Display\DisplayCfgCtrl.designer.cs">
<DependentUpon>DisplayCfgCtrl.cs</DependentUpon>
</Compile>
<Compile Include="Rig\Network\Camera\KeyenceIV3G120\Camera.cs" />
<Compile Include="Rig\Network\Camera\KeyenceIV3G120\CameraCfg.cs" />
<Compile Include="Rig\Network\Camera\KeyenceIV3G120\CameraCfgCtrl.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Rig\Network\Camera\KeyenceIV3G120\CameraCfgCtrl.designer.cs">
<DependentUpon>CameraCfgCtrl.cs</DependentUpon>
</Compile>
<Compile Include="Rig\Network\Camera\KeyenceIV3G120\CameraUtils.cs" />
<Compile Include="Rig\Network\Camera\KeyenceIV3G120\Factory.cs" />
<Compile Include="Rig\Network\Camera\KeyenceIV3G120\GrabImagesOp.cs" />
<Compile Include="Rig\Network\Camera\KeyenceIV3G120\RoisAndResults.cs" />
<Compile Include="Rig\Network\Camera\RoiForFixedStartKeyence\Factory.cs" />
<Compile Include="Rig\Network\Camera\RoiForFixedStartKeyence\ProcedureParams.cs" />
<Compile Include="Rig\Network\Camera\RoiForFixedStartKeyence\Roi.cs" />
<Compile Include="Rig\Network\Camera\RoiForFixedStartKeyence\RoiCfg.cs" />
<Compile Include="Rig\Network\Camera\RoiForFixedStartKeyence\RoiCfgCtrl.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Rig\Network\Camera\RoiForFixedStartKeyence\RoiCfgCtrl.designer.cs">
<DependentUpon>RoiCfgCtrl.cs</DependentUpon>
</Compile>
<Compile Include="Rig\Network\Camera\RoiForFixedStart\Factory.cs" />
<Compile Include="Rig\Network\Camera\RoiForFixedStart\ProcedureParams.cs" />
<Compile Include="Rig\Network\Camera\RoiForFixedStart\Roi.cs" />
@@ -1055,16 +1087,6 @@
<Compile Include="Rig\Output\FileWriters\Basic\WriterCfgCtrl.designer.cs">
<DependentUpon>WriterCfgCtrl.cs</DependentUpon>
</Compile>
<Compile Include="Rig\RegisterReaders\FrequencyMeterFromUniCB\FrequencyRegisterReader.cs" />
<Compile Include="Rig\RegisterReaders\FrequencyMeterFromUniCB\Factory.cs" />
<Compile Include="Rig\RegisterReaders\FrequencyMeterFromUniCB\RRCfg.cs" />
<Compile Include="Rig\RegisterReaders\FrequencyMeterFromUniCB\RRCfgCtrl.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Rig\RegisterReaders\FrequencyMeterFromUniCB\RRCfgCtrl.designer.cs">
<DependentUpon>RRCfgCtrl.cs</DependentUpon>
</Compile>
<Compile Include="Rig\RegisterReaders\FrequencyMeterFromUniCB\RRProcParams.cs" />
<Compile Include="Rig\RegisterReaders\DataStream\MefImport\Factory.cs" />
<Compile Include="Rig\RegisterReaders\DataStream\MefImport\MefImport.cs" />
<Compile Include="Rig\RegisterReaders\DataStream\MefImport\MefImportCfg.cs" />
@@ -2776,6 +2798,9 @@
<EmbeddedResource Include="Rig\Modbus\TankSelector\TankSelectorCfgCtrl.resx">
<DependentUpon>TankSelectorCfgCtrl.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Rig\Network\AdapterFTP\NetadapterCfgCtrl.resx">
<DependentUpon>NetadapterCfgCtrl.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Rig\Network\Adapter\NetadapterCfgCtrl.resx">
<DependentUpon>NetadapterCfgCtrl.cs</DependentUpon>
</EmbeddedResource>
@@ -2791,6 +2816,12 @@
<EmbeddedResource Include="Rig\Network\Camera\Display\DisplayCfgCtrl.resx">
<DependentUpon>DisplayCfgCtrl.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Rig\Network\Camera\KeyenceIV3G120\CameraCfgCtrl.resx">
<DependentUpon>CameraCfgCtrl.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Rig\Network\Camera\RoiForFixedStartKeyence\RoiCfgCtrl.resx">
<DependentUpon>RoiCfgCtrl.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Rig\Network\Camera\RoiForFixedStart\RoiCfgCtrl.resx">
<DependentUpon>RoiCfgCtrl.cs</DependentUpon>
</EmbeddedResource>
@@ -2866,9 +2897,6 @@
<EmbeddedResource Include="Rig\Output\FileWriters\Basic\WriterCfgCtrl.resx">
<DependentUpon>WriterCfgCtrl.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Rig\RegisterReaders\FrequencyMeterFromUniCB\RRCfgCtrl.resx">
<DependentUpon>RRCfgCtrl.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Rig\RegisterReaders\KPackE\DataEntryForRadio\CycleBeginningForm.resx">
<DependentUpon>CycleBeginningForm.cs</DependentUpon>
</EmbeddedResource>
+2 -7
View File
@@ -111,13 +111,8 @@ namespace TBF.UI.Bench.Paths
tUpCBox.Items.Add(cmpnt.Cfg.Name);
tDownCBox.Items.Add(cmpnt.Cfg.Name);
}
if (cmpnt is Rig.GenericDevices.IPressureMeter)
{
prUpCBox.Items.Add(cmpnt.Cfg.Name);
prDownCBox.Items.Add(cmpnt.Cfg.Name);
prDeltaCBox.Items.Add(cmpnt.Cfg.Name);
}
if (cmpnt is Rig.GenericDevices.IAdjustableMeter)
if ((cmpnt is Rig.GenericDevices.IPressureMeter) ||
(cmpnt is Rig.GenericDevices.IAdjustableMeter))
{
prUpCBox.Items.Add(cmpnt.Cfg.Name);
prDownCBox.Items.Add(cmpnt.Cfg.Name);
+1 -1
View File
@@ -187,7 +187,7 @@ namespace TBF.UI.Bench.Paths
private System.Windows.Forms.TabPage metersTabPage;
private TBF.UI.Shared.SharedButtons sharedButtons;
private PathsFeedingCtrl pathsFeedingCtrl;
private PathsBenchCtrl pathsBenchCtrl;
private PathsBenchCtrl pathsBenchCtrl;
private PathsOutputCtrl pathsOutputCtrl;
private PathsMetersCtrl pathsMetersCtrl;
}
@@ -0,0 +1,93 @@
using System.IO;
using System.Reflection;
using System.Threading;
using JetBrains.Annotations;
using log4net;
using log4net.Config;
using log4net.Repository;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using TBF.Rig.Generic;
using TBF.Rig.Network.Camera.KeyenceIV3G120;
using System.Xml;
namespace TBFTests.Rig.Network.Camera.KeyenceIV3G120
{
public class Log4NetSetup
{
public static void ConfigureLog4Net()
{
// Construct the log4net configuration as a string
string log4netConfig = @"
<log4net>
<appender name='ConsoleAppender' type='log4net.Appender.ConsoleAppender'>
<layout type='log4net.Layout.PatternLayout'>
<conversionPattern value='%date %-5level %logger - %message%newline' />
</layout>
</appender>
<root>
<level value='ALL' />
<appender-ref ref='ConsoleAppender' />
</root>
</log4net>";
// Load the log4net configuration from the string
XmlDocument doc = new XmlDocument();
doc.LoadXml(log4netConfig);
XmlElement element = doc.DocumentElement;
// Get the current assembly for the repository
Assembly assembly = Assembly.GetExecutingAssembly();
// Configure log4net using the parsed XmlElement
ILoggerRepository logRepository = LogManager.GetRepository(assembly);
XmlConfigurator.Configure(logRepository, element);
}
}
[TestClass]
[TestSubject(typeof(TBF.Rig.Network.Camera.KeyenceIV3G120.Camera))]
public class CameraTest
{
[TestInitialize]
public void Setup()
{
// Configure Log4Net programmatically
Log4NetSetup.ConfigureLog4Net();
}
[TestMethod]
public void Initialize()
{
Factory factory = new Factory();
IComponentCfg config = new CameraCfg("Camera0", factory);
TBF.Rig.Network.Camera.KeyenceIV3G120.Camera camera = new TBF.Rig.Network.Camera.KeyenceIV3G120.Camera(config, null);
camera.Initialize();
Thread.Sleep(10000);
camera.Stop();
Thread.Sleep(10000);
}
[TestMethod]
public void RtpListener()
{
Factory factory = new Factory();
IComponentCfg config = new CameraCfg("Camera0", factory);
TBF.Rig.Network.Camera.KeyenceIV3G120.Camera camera = new TBF.Rig.Network.Camera.KeyenceIV3G120.Camera(config, null);
camera.RtpListener();
camera.Stop();
}
}
}
@@ -0,0 +1,19 @@
using JetBrains.Annotations;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using TBF.Rig.Network.Camera.RoiForFixedStartKeyence;
namespace TBFTests.Rig.Network.Camera.RoiForFixedStartKeyence
{
[TestClass]
[TestSubject(typeof(Roi))]
public class RoiTest
{
[TestMethod]
public void Valve()
{
Roi roi = new Roi();
}
}
}
+6
View File
@@ -44,6 +44,9 @@
<Reference Include="JetBrains.Annotations, Version=4242.42.42.42, Culture=neutral, PublicKeyToken=1010a0d8d6380325, processorArchitecture=MSIL">
<HintPath>..\packages\JetBrains.Annotations.2023.3.0\lib\net20\JetBrains.Annotations.dll</HintPath>
</Reference>
<Reference Include="log4net, Version=2.0.15.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\packages\log4net.2.0.15\lib\net45\log4net.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Extensions.Configuration.Abstractions, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Extensions.Configuration.Abstractions.5.0.0\lib\net461\Microsoft.Extensions.Configuration.Abstractions.dll</HintPath>
</Reference>
@@ -81,6 +84,7 @@
<HintPath>..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll</HintPath>
</Reference>
<Reference Include="System.Web" />
<Reference Include="System.Xml" />
</ItemGroup>
<Choose>
<When Condition="('$(VisualStudioVersion)' == '10.0' or '$(VisualStudioVersion)' == '') and '$(TargetFrameworkVersion)' == 'v3.5'">
@@ -93,6 +97,8 @@
<ItemGroup>
<Compile Include="Entities\MeasurementCorrectionTest.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Rig\Network\Camera\KeyenceIV3G120\CameraTest.cs" />
<Compile Include="Rig\Network\Camera\RoiForFixedStartKeyence\RoiTest.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
+1
View File
@@ -13,4 +13,5 @@
<package id="System.Runtime.CompilerServices.Unsafe" version="5.0.0" targetFramework="net472" />
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net472" />
<package id="System.ValueTuple" version="4.5.0" targetFramework="net472" />
<package id="log4net" version="2.0.15" targetFramework="net472" />
</packages>