Compare commits

..
Author SHA1 Message Date
Milan Hanajik 80697ed65f ver. 2.12.550 2017-04-24 14:22:51 +02:00
Milan Hanajik 43fd99cea6 output.FileWriter.Enhanced copes with WaterMeters.Count==0, etc. 2017-04-24 12:21:12 +02:00
Milan Hanajik eafcf016f3 Setting regulation valves before flow setting disabled, caused porbles all the time, ver. 2.12 549 2017-04-24 11:58:57 +02:00
Milan Hanajik 5a89a5d43f ver. 2.12.548 2017-04-24 11:02:12 +02:00
Milan Hanajik 33715395dc ReadMassOp fixed, was freezing when draining tanks, ver. 2.12.547 2017-04-24 10:49:28 +02:00
Milan Hanajik 05982cc2ff Endurance test method sequence modified. 2017-04-24 09:44:11 +02:00
Milan Hanajik 6706b296c0 ver. 2.12.546 2017-04-24 08:29:51 +02:00
Milan Hanajik e4be90b7bc ver. 2.12.545 2017-04-20 15:59:35 +02:00
Milan Hanajik 9cc9e4b4c9 MainSeq change to Restore a previously saved batch results, ver. 2.12.544 2017-04-20 15:53:11 +02:00
Milan Hanajik 45869401ad BatchNr of restored session fixed, ver. 2.12.544 2017-04-20 11:00:41 +02:00
Milan Hanajik 5a88e8909f Culture parameter added to all Output.FileWriters components, ver. 2.12.543 2017-04-18 15:29:28 +02:00
Milan Hanajik a4dc7435d0 PreviousResultsCtrl modification: Reload/Restore button was hidden. 2017-04-14 11:51:37 +02:00
Milan Hanajik df1689d458 MainSeq changes, CopyContentFrom() added to WaterMeter, TestRslt, MeterTestRslt, ver. 2.12.542 2017-04-13 14:34:58 +02:00
Milan Hanajik 76a54f41a7 Results.DBase added. 2017-04-12 21:43:57 +02:00
Milan Hanajik 89593b1dac 'Custom'/'Oprav DEWY' button added to BenchControlPanel, MainSeq changes 2017-04-12 17:59:48 +02:00
Milan Hanajik dbd6b7a9f7 SeqBase bug fixes. 2017-04-12 17:37:55 +02:00
Milan Hanajik e49fcdebfc ver. 2.12.539 2017-04-11 17:37:04 +02:00
Milan Hanajik 1ccdcf9bd2 Possibility to reload previous results, MainSeq modified - CreateNewBatchResults() and RestoreBatchResults(), ver. 2.12.538 2017-04-11 17:31:48 +02:00
Milan Hanajik 60f5359bd9 Culture invariant procedure import/export, ver. 2.12.537 2017-04-11 12:54:37 +02:00
Milan Hanajik 71cc77bee1 Keithley.Multimeter_2010_RS232.Multimeter shut-down bug fix, ver. 2.12.536 2017-04-10 15:06:56 +02:00
Milan Hanajik 460b40c9cd ver. 2.12.535 2017-04-10 12:04:04 +02:00
Milan Hanajik c2e32c774e RoiDetecion wizard forms added to TestWizard, ver. 2.12.534 2017-04-10 11:53:41 +02:00
Milan Hanajik 796d9fa554 Camera.Display.DisplayForm modifications 2017-04-09 14:10:49 +02:00
Milan Hanajik 8a8c6c9997 Camera measurement speed optimized, ver. 2.12.533 2017-04-09 13:30:30 +02:00
Milan Hanajik 6e420250b4 Possibility to switch off Telnet VirtualTerminal completely, IVirtualTerminal, DummyVT. 2017-04-07 16:04:43 +02:00
Milan Hanajik 4564f0424c Camera ; UDP listener implemented (but disabled) again, ver. 2.12.532 2017-04-07 15:49:14 +02:00
Milan Hanajik 099d635d3e RoiParams, DetectionImagesCount, P1, P2 are procedure parameters, ver. 2.12.531 2017-04-07 12:22:01 +02:00
Milan Hanajik d372a38e7d Camera time read with each sample, calculation : VolumeStart, VolumeEnd, TimestampStart, TimestampEnd used, ver. 2.12.530 2017-04-07 11:29:35 +02:00
Milan Hanajik fc26b95bdb RoiCfg.SaveImages introduced, Program.ImagesDir introduced - directory cleaned or created on program startup. 2017-04-06 23:49:51 +02:00
Milan Hanajik 44735260ce CLP1611 Measurement done only on successfully detected ROI-s, ver. 2.12.530 2017-04-06 23:47:24 +02:00
Milan Hanajik 6aa3cd96a6 RoiDetection : Changes while testing, ver. 2.12.528 2017-04-06 18:00:33 +02:00
Milan Hanajik e1eb582804 RoiDetection : Images/cameras for retry of ROI Detection can be selected, ver. 2.12.527 2017-04-06 16:54:27 +02:00
Milan Hanajik 0ad4847972 Network.Camera.Display and ICameraDisplay added, ver. 2.12.526 2017-04-06 15:17:56 +02:00
Milan Hanajik 323f2ede25 RoiDetectionOp modified : File transfer correctly initiated. 2017-04-06 10:27:21 +02:00
Milan Hanajik a64c547395 Output.FileWriters.Xml modifications, ver. 2.12.525 2017-04-06 08:29:03 +02:00
Milan Hanajik 40f5079846 MeasurementOp.cs deleted, MeasurementOp in Network/Camera/CLP1611/Camera.cs 2017-04-05 22:22:41 +02:00
Milan Hanajik 464dfc6dd1 FlyingStartMassCollection : 'Next' button can be used to stop the test. 2017-04-05 22:01:21 +02:00
Milan Hanajik c1b3cdde6d Camera bug fix 2017-04-05 22:00:01 +02:00
Milan Hanajik e688c4ba25 Speisung -> Wasserzulauf 2017-04-05 20:32:39 +02:00
Milan Hanajik 592823aa10 Program shutdown cleaned-up : StopOperations(), StopDevice() called appropriately. 2017-04-05 19:45:21 +02:00
Milan Hanajik 5ad871a7e0 Procedure 'Export' / 'Import' implemented, ver. 2.12.524 2017-04-03 14:24:35 +02:00
Milan Hanajik 049bbc8655 DEWA Q2 correction modified, Results.Entities.WaterMeter columns added (iPerl only). 2017-03-31 14:17:18 +02:00
Milan Hanajik dcf6df293f Changes agreed with Mr. Kolesnik in BWB, ver. 2.12.521 2017-03-30 12:38:50 +02:00
Milan Hanajik 0dd2245fe6 Berlin component upgraded 2017-03-29 12:45:14 +02:00
Milan Hanajik cd750cca2f Bug in DataEntry.Standard6.CycleEndForm fixed (end states, Berlin), ver. 2.12.520 2017-03-29 11:54:07 +02:00
Milan Hanajik 5f2da63339 Drain valve removed from Output path, outPath.Scale.DrainValve used instead of outPath.DrainValve, wait for Event. BalanceDone before 2nd mass measurement in FlyingStartMassCollection, ver. 2.12.519 2017-03-29 09:22:39 +02:00
Milan Hanajik d420128b4b Draining modified, in BERLIN done always before flow setting, ver. 2.12.518 2017-03-28 23:54:52 +02:00
144 changed files with 7245 additions and 3186 deletions
+25 -3
View File
@@ -1,6 +1,9 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
/// Copyright (c) 2013-2017 Sensus Metering Systems
///
using System;
using System.IO;
namespace Config.Entities
{
public class ComponentProcedure
@@ -10,13 +13,32 @@ namespace Config.Entities
public virtual string Parameters { get; set; }
public virtual Procedure Procedure { get; set; }
public virtual ComponentProcedure Clone()
public virtual ComponentProcedure Clone(Procedure newProcedure)
{
ComponentProcedure result = new ComponentProcedure();
result.CmpntName = CmpntName;
result.Parameters = Parameters;
result.Procedure = Procedure;
result.Procedure = newProcedure;
return result;
}
public virtual void Export(StreamWriter output)
{
output.WriteLine(CmpntName);
output.WriteLine(Parameters.Replace(Environment.NewLine, "~"));
}
public static ComponentProcedure Import(StreamReader input, Procedure newProcedure)
{
string firstLine = input.ReadLine();
if (string.IsNullOrEmpty(firstLine)) return null;
ComponentProcedure result = new ComponentProcedure();
result.CmpntName = firstLine;
result.Parameters = input.ReadLine().Replace("~", Environment.NewLine);
result.Procedure = newProcedure;
return result;
}
}
}
+24 -2
View File
@@ -1,6 +1,9 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
/// Copyright (c) 2013-2017 Sensus Metering Systems
///
using System;
using System.IO;
namespace Config.Entities
{
public class ComponentTest
@@ -18,5 +21,24 @@ namespace Config.Entities
result.Test = Test;
return result;
}
}
public virtual void Export(StreamWriter output)
{
output.WriteLine(CmpntName);
output.WriteLine(Parameters.Replace(Environment.NewLine, "~"));
}
public static ComponentTest Import(StreamReader input, Test newTest)
{
string firstLine = input.ReadLine();
if (string.IsNullOrEmpty(firstLine)) return null;
ComponentTest result = new ComponentTest();
result.CmpntName = firstLine;
result.Parameters = input.ReadLine().Replace("~", Environment.NewLine);
result.Test = newTest;
return result;
}
}
}
+6 -6
View File
@@ -11,16 +11,16 @@ namespace Config.Entities
public virtual int Id { get; protected set; }
public virtual int ItemNr { get; set; }
public virtual string Name { get; set; }
public virtual float Qfrom { get; set; } /// Water flow in [m3/h]
public virtual float Qto { get; set; } /// Water flow in [m3/h]
public virtual float Qfrom { get; set; } /// Water flow in [m3/h]
public virtual float Qto { get; set; } /// Water flow in [m3/h]
public virtual string RegulValve { get; set; }
public virtual string FlowMeter { get; set; }
public virtual float PidCoef { get; set; } /// PID coefficient for the regulation path
public virtual float PidCoef { get; set; } /// PID coefficient for the regulation path
public virtual string StartValve { get; set; }
public virtual string Diverter { get; set; }
public virtual string TempDiv { get; set; }
public virtual string Balance { get; set; }
public virtual string EmptyTankValve { get; set; }
public virtual string Scale { get; set; }
public virtual string EmptyTankValve { get; set; } /// Not used anywhere
/// Valves
public virtual string ValvesOpen { get; set; }
@@ -54,7 +54,7 @@ namespace Config.Entities
result.StartValve = StartValve;
result.Diverter = Diverter;
result.TempDiv = TempDiv;
result.Balance = Balance;
result.Scale = Scale;
result.EmptyTankValve = EmptyTankValve;
result.ValvesOpen = ValvesOpen;
result.ValvesClose = ValvesClose;
+71 -6
View File
@@ -3,6 +3,8 @@
///
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
namespace Config.Entities
{
@@ -40,9 +42,6 @@ namespace Config.Entities
public virtual IList<ComponentProcedure> MoreParams { get; set; }
public virtual IList<Test> Tests { get; set; }
////public virtual string MetrologicalClass { get; set; }
////public virtual IList<WMType> WMTypes { get; set; }
/// ------------- Additional stuff not mapped into the database -------------
public Procedure()
@@ -96,11 +95,77 @@ namespace Config.Entities
result.TransitionStart = TransitionStart;
result.TransitionEnd = TransitionEnd;
foreach (var prms in MoreParams) { result.MoreParams.Add(prms.Clone()); }
foreach (var prms in MoreParams) { result.MoreParams.Add(prms.Clone(result)); }
foreach (var test in Tests) { result.Tests.Add(test.Clone()); }
//result.MetrologicalClass = MetrologicalClass;
//result.WMType = WMType.Clone();
return result;
}
public virtual void Export(StreamWriter output)
{
output.WriteLine(ItemNr.ToString(CultureInfo.InvariantCulture));
output.WriteLine(Name);
output.WriteLine(Description);
output.WriteLine(CreationUser);
output.WriteLine(CreationTime.ToString(CultureInfo.InvariantCulture));
output.WriteLine(LastChgUser);
output.WriteLine(LastChgTime.ToString(CultureInfo.InvariantCulture));
output.WriteLine(MetersKind.ToString());
output.WriteLine(Watermeters);
output.WriteLine(ProtocolTitle);
output.WriteLine(DataEntry);
output.WriteLine(ResultsPrinter);
output.WriteLine(ResultsWriter);
output.WriteLine(TransitionStart);
output.WriteLine(TransitionEnd);
foreach (var prms in MoreParams) { prms.Export(output); }
output.WriteLine();
foreach (var test in Tests) { test.Export(output); }
output.WriteLine();
output.Close();
}
public static Procedure Import(StreamReader input)
{
Procedure result = new Procedure();
result.ItemNr = int.Parse(input.ReadLine(), CultureInfo.InvariantCulture);
result.Name = input.ReadLine();
result.Description = input.ReadLine();
result.CreationUser = input.ReadLine();
result.CreationTime = DateTime.Parse(input.ReadLine(), CultureInfo.InvariantCulture);
result.LastChgUser = input.ReadLine();
result.LastChgTime = DateTime.Parse(input.ReadLine(), CultureInfo.InvariantCulture);
string line = input.ReadLine();
result.MetersKind = line.Equals(MetersKind.Single.ToString()) ? MetersKind.Single : (line.Equals(MetersKind.Combined.ToString()) ? MetersKind.Combined : MetersKind.HeatMeter);
result.Watermeters = input.ReadLine();
result.ProtocolTitle = input.ReadLine();
result.DataEntry = input.ReadLine();
result.ResultsPrinter = input.ReadLine();
result.ResultsWriter = input.ReadLine();
result.TransitionStart = input.ReadLine();
result.TransitionEnd = input.ReadLine();
while(true)
{
ComponentProcedure prms = ComponentProcedure.Import(input, result);
if (prms == null)
break;
else
result.MoreParams.Add(prms);
}
while (true)
{
Test tst = Test.Import(input, result);
if (tst == null)
break;
else
result.Tests.Add(tst);
}
return result;
}
+97 -6
View File
@@ -1,9 +1,10 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
/// Author: Milan Hanajik
/// Copyright (c) 2013-2017 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
namespace Config.Entities
{
@@ -22,13 +23,13 @@ namespace Config.Entities
public virtual float Qfrom { get; set; } /// Water flow low limit in [m3/h]
public virtual float Qto { get; set; } /// Water flow high limit in [m3/h]
public virtual float Volume { get; set; } /// Test volume (target) in [l]
public virtual float TstTime { get; set; } /// Test time (estimate) in [s]
public virtual float TstTime { get; set; } /// Test time (estimate) in [s]
public virtual string Method { get; set; }
public virtual float ErrLimLo { get; set; } /// in [%] (usually < 0)
public virtual float ErrLimHi { get; set; } /// in [%] (usually > 0)
public virtual float Uncertainty { get; set; } /// int [%] makes error limits tighter: 0 <= Uncertainty <= abs(ErrLimXx)
public virtual int Repeats { get; set; }
public virtual bool Emptying { get; set; }
public virtual bool Draining { get; set; }
public virtual bool Zeroing { get; set; }
public virtual float PumpPower { get; set; } /// Power of the pump in [%] in the range 0 .. 100.0f, use values 0% and 100% for non-FM pumps
public virtual int MassRepeats { get; set; } /// Number of mass. measurements at the beginning/end of test, 0 = default (=5)
@@ -68,7 +69,7 @@ namespace Config.Entities
Publish = (sbyte)Config.Entities.Publish.Always;
Evaluate = true;
Repeats = 1;
Emptying = false;
Draining = false;
Zeroing = false;
ErrLimLo = -2.0f; /// [%] lower error limit
ErrLimHi = 2.0f; /// [%] upper error limit
@@ -109,7 +110,7 @@ namespace Config.Entities
result.Volume = Volume;
result.TstTime = TstTime;
result.Repeats = Repeats;
result.Emptying = Emptying;
result.Draining = Draining;
result.Zeroing = Zeroing;
result.PumpPower = PumpPower;
result.MassRepeats = MassRepeats;
@@ -141,6 +142,96 @@ namespace Config.Entities
return result;
}
public virtual void Export(StreamWriter output)
{
output.WriteLine(Name);
output.WriteLine(Part.ToString(CultureInfo.InvariantCulture));
output.WriteLine(Publish.ToString(CultureInfo.InvariantCulture));
output.WriteLine(Evaluate.ToString());
output.WriteLine(Qfrom.ToString(CultureInfo.InvariantCulture));
output.WriteLine(Qto.ToString(CultureInfo.InvariantCulture));
output.WriteLine(Volume.ToString(CultureInfo.InvariantCulture));
output.WriteLine(TstTime.ToString(CultureInfo.InvariantCulture));
output.WriteLine(Method);
output.WriteLine(ErrLimLo.ToString(CultureInfo.InvariantCulture));
output.WriteLine(ErrLimHi.ToString(CultureInfo.InvariantCulture));
output.WriteLine(Uncertainty.ToString(CultureInfo.InvariantCulture));
output.WriteLine(Repeats.ToString(CultureInfo.InvariantCulture));
output.WriteLine(Draining.ToString());
output.WriteLine(Zeroing.ToString());
output.WriteLine(PumpPower.ToString(CultureInfo.InvariantCulture));
output.WriteLine(MassRepeats.ToString(CultureInfo.InvariantCulture));
output.WriteLine(MassSpread.ToString(CultureInfo.InvariantCulture));
output.WriteLine(((byte)MassMethod).ToString(CultureInfo.InvariantCulture));
output.WriteLine(TimeBeforeFlow.ToString(CultureInfo.InvariantCulture));
output.WriteLine(TimeFlow2Mass.ToString(CultureInfo.InvariantCulture));
output.WriteLine(TimePump2StartV.ToString(CultureInfo.InvariantCulture));
output.WriteLine(TimeStop2Mass.ToString(CultureInfo.InvariantCulture));
output.WriteLine(FeedingPath);
output.WriteLine(BenchPath);
output.WriteLine(OutputPath);
output.WriteLine(MetersPath);
output.WriteLine(RelTransBefore);
output.WriteLine(RelTransBetween);
output.WriteLine(RelTransAfter);
output.WriteLine(TransitionAfter);
foreach (var prms in MoreParams) { prms.Export(output); }
output.WriteLine();
}
public static Test Import(StreamReader input, Procedure newProcedure)
{
string firstLine = input.ReadLine();
if (string.IsNullOrEmpty(firstLine)) return null;
Test tst = new Test();
tst.Name = firstLine;
tst.Part = int.Parse(input.ReadLine(), CultureInfo.InvariantCulture);
tst.Publish = sbyte.Parse(input.ReadLine(), CultureInfo.InvariantCulture);
tst.Evaluate = bool.Parse(input.ReadLine());
tst.Qfrom = float.Parse(input.ReadLine(), CultureInfo.InvariantCulture);
tst.Qto = float.Parse(input.ReadLine(), CultureInfo.InvariantCulture);
tst.Volume = float.Parse(input.ReadLine(), CultureInfo.InvariantCulture);
tst.TstTime = float.Parse(input.ReadLine(), CultureInfo.InvariantCulture);
tst.Method = input.ReadLine();
tst.ErrLimLo = float.Parse(input.ReadLine(), CultureInfo.InvariantCulture);
tst.ErrLimHi = float.Parse(input.ReadLine(), CultureInfo.InvariantCulture);
tst.Uncertainty = float.Parse(input.ReadLine(), CultureInfo.InvariantCulture);
tst.Repeats = int.Parse(input.ReadLine(), CultureInfo.InvariantCulture);
tst.Draining = bool.Parse(input.ReadLine());
tst.Zeroing = bool.Parse(input.ReadLine());
tst.PumpPower = float.Parse(input.ReadLine(), CultureInfo.InvariantCulture);
tst.MassRepeats = int.Parse(input.ReadLine(), CultureInfo.InvariantCulture);
tst.MassSpread = float.Parse(input.ReadLine(), CultureInfo.InvariantCulture);
tst.MassMethod = (MassMethod)byte.Parse(input.ReadLine(), CultureInfo.InvariantCulture);
tst.TimeBeforeFlow = int.Parse(input.ReadLine(), CultureInfo.InvariantCulture);
tst.TimeFlow2Mass = int.Parse(input.ReadLine(), CultureInfo.InvariantCulture);
tst.TimePump2StartV = int.Parse(input.ReadLine(), CultureInfo.InvariantCulture);
tst.TimeStop2Mass = int.Parse(input.ReadLine(), CultureInfo.InvariantCulture);
tst.FeedingPath = input.ReadLine();
tst.BenchPath = input.ReadLine();
tst.OutputPath = input.ReadLine();
tst.MetersPath = input.ReadLine();
tst.RelTransBefore = input.ReadLine();
tst.RelTransBetween = input.ReadLine();
tst.RelTransAfter = input.ReadLine();
tst.TransitionAfter = input.ReadLine();
while (true)
{
ComponentTest prms = ComponentTest.Import(input, tst);
if (prms == null)
break;
else
tst.MoreParams.Add(prms);
}
tst.Procedure = newProcedure;
return tst;
}
public override string ToString()
{
string partStr = (Part > 0) ? string.Format(", part {0}", Part) : string.Empty;
+1 -1
View File
@@ -153,7 +153,7 @@ namespace Config.Entities
Volume = test.Volume;
TstTime = test.TstTime;
Repeats = test.Repeats;
Emptying = test.Emptying;
Emptying = test.Draining;
Zeroing = test.Zeroing;
PumpPower = PumpPower;
Time2MassMsrmt = test.TimeStop2Mass;
+2 -1
View File
@@ -21,7 +21,8 @@ namespace Config.Mappings
Map(x => x.StartValve);
Map(x => x.Diverter);
Map(x => x.TempDiv);
Map(x => x.Balance);
Map(x => x.Scale)
.Column("Balance");
Map(x => x.EmptyTankValve);
Map(x => x.ValvesOpen)
.CustomType("StringClob")
+2 -1
View File
@@ -22,7 +22,8 @@ namespace Config.Mappings
Map(x => x.Volume);
Map(x => x.TstTime);
Map(x => x.Repeats);
Map(x => x.Emptying);
Map(x => x.Draining)
.Column("Emptying");
Map(x => x.Zeroing);
Map(x => x.PumpPower);
Map(x => x.MassRepeats);
+2 -2
View File
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.12.499.0")]
[assembly: AssemblyFileVersion("2.12.499.0")]
[assembly: AssemblyVersion("2.12.537.0")]
[assembly: AssemblyFileVersion("2.12.537.0")]
+35
View File
@@ -270,5 +270,40 @@ namespace Results
return true;
}
public static Batch LoadBatch(int batchNr)
{
IList<Batch> batches;
ISession session = DB.CreateSession();
if (session == null) return null;
TestDataList = session.QueryOver<TestData>().List();
ComponentsList = session.QueryOver<Components>().List();
WaterMeterDataList = session.QueryOver<WaterMeterData>().List();
try
{
batches = session.QueryOver<Batch>()
.Where(x => (x.BatchNr == batchNr))
.List();
foreach (var batch in batches)
{
batch.TestRslts = session.QueryOver<TestRslt>()
.Where(x => (x.Batch.Id == batch.Id))
.List();
batch.WaterMeters = session.QueryOver<WaterMeter>()
.Where(x => (x.Batch.Id == batch.Id))
.List();
}
}
catch (Exception exc)
{
log.FatalFormat("Cannot load batch #{0}: {1}", batchNr, exc.Message);
return null;
}
return (batches.Count > 0) ? batches[0] : null;
}
}
}
+63
View File
@@ -0,0 +1,63 @@
///
/// Copyright (c) 2017 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
using FluentNHibernate.Cfg;
using FluentNHibernate.Cfg.Db;
using log4net;
using NHibernate;
using NHibernate.Cfg;
using NHibernate.Tool.hbm2ddl;
using Results.Entities;
namespace Results
{
public class DBase
{
static readonly ILog log = LogManager.GetLogger(typeof(DBase));
/// <summary> Session factory for all regular sessions, not for CreateEmptyResultsDB(). </summary>
public static IList<DBase> Databases;
public static int Count { get { return Databases.Count; } }
static DBase()
{
Databases = new List<DBase>();
}
public readonly string Name;
public readonly string ConnectionString;
ISessionFactory sessionFactory;
public DBase(string connectionString, string name)
{
this.ConnectionString = connectionString;
this.Name = name;
sessionFactory = Fluently.Configure()
.Database(MySQLConfiguration.Standard.ConnectionString(connectionString))
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<Entities.WaterMeterData>())
.ExposeConfiguration(BuildSchema)
.BuildSessionFactory();
}
public DBase(string connectionString)
: this(connectionString, string.Empty)
{
}
private void BuildSchema(Configuration config)
{
/// This NHibernate tool takes a configuration with mapping info and exports a database schema
new SchemaExport(config).SetOutputFile("db_schema");
}
public ISession OpenSession()
{
return sessionFactory.OpenSession();
}
}
}
+19
View File
@@ -89,5 +89,24 @@ namespace Results.Entities
TestRslt = testRslt;
CompoundMeterId = (byte)compoundMeterId;
}
public virtual void CopyContentFrom(MeterTestRslt src)
{
if (src == null) return;
PulsesMeter = src.PulsesMeter;
PulsesMaster = src.PulsesMaster;
PulsesPerLiter = src.PulsesPerLiter;
VolumeStart = src.VolumeStart;
VolumeEnd = src.VolumeEnd;
VolumeMeter = src.VolumeMeter;
VolumeRef = src.VolumeRef;
TimestampStart = src.TimestampStart;
TimestampEnd = src.TimestampEnd;
TestTime = src.TestTime;
Error = src.Error;
TestDone = src.TestDone;
Passed = src.Passed;
}
}
}
+91 -3
View File
@@ -14,12 +14,12 @@ namespace Results.Entities
public virtual TestData TestData { get; set; }
public virtual Components Components { get; set; }
public virtual int Part { get; set; }
public virtual int RepetitionNr { get; set; } /// Repetition number from the set of repeated tests (1...)
public virtual int RepetitionNr { get; set; } /// Repetition number from the set of repeated tests (1...)
/// Main results
public virtual DateTime StartTime { get; set; } /// Date and time of the test start
public virtual DateTime EndTime { get; set; } /// Date and time of the test end
public virtual int FlowSetTime { get; set; } /// [s] Measurement time in seconds
public virtual int FlowSetTime { get; set; } /// [s] Measurement time in seconds
public virtual double TestTime { get; set; } /// [s] Measurement time in seconds
public virtual double PulsesMaster { get; set; }
public virtual double ConstMaster { get; set; } /// [pls/l] Pulses per liter master flow meter
@@ -104,7 +104,7 @@ namespace Results.Entities
/// Wrappers
public virtual string Name() { return Utils.GetTestName(TestData.Name, TestData.Repeats, RepetitionNr); }
public virtual int Repeats() { return TestData.Repeats; }
public virtual int Repeats() { return TestData.Repeats; }
public virtual double Qfrom() { return TestData.Qfrom; }
public virtual double Qto() { return TestData.Qto; }
public virtual double TargetVolume() { return TestData.TargetVolume; }
@@ -130,6 +130,94 @@ namespace Results.Entities
RepetitionNr = repetitionNr;
}
public virtual void CopyContentFrom(TestRslt src)
{
if (src == null) return;
Components = src.Components; /// ???
Part = src.Part;
RepetitionNr = src.RepetitionNr;
StartTime = src.StartTime;
EndTime = src.EndTime;
FlowSetTime = src.FlowSetTime;
TestTime = src.TestTime;
PulsesMaster = src.PulsesMaster;
ConstMaster = src.ConstMaster;
MassStartRaw = src.MassStartRaw;
MassStart = src.MassStart;
MassEndRaw = src.MassEndRaw;
MassEnd = src.MassEnd;
DensityIn = src.DensityIn;
DensityOut = src.DensityOut;
DensityDiv = src.DensityDiv;
Buoyancy = src.Buoyancy;
FlowMass = src.FlowMass;
FlowVolume = src.FlowVolume;
VolumeCTV = src.VolumeCTV;
VolumeMaster = src.VolumeMaster;
ErrorMaster = src.ErrorMaster;
RefEnergy = src.RefEnergy;
AmbTempMean = src.AmbTempMean;
AmbTempStart = src.AmbTempStart;
AmbTempEnd = src.AmbTempEnd;
AmbTempMin = src.AmbTempMin;
AmbTempMax = src.AmbTempMax;
AmbPressMean = src.AmbPressMean;
AmbPressStart = src.AmbPressStart;
AmbPressEnd = src.AmbPressEnd;
AmbPressMin = src.AmbPressMin;
AmbPressMax = src.AmbPressMax;
AmbHumiMean = src.AmbHumiMean;
AmbHumiStart = src.AmbHumiStart;
AmbHumiEnd = src.AmbHumiEnd;
AmbHumiMin = src.AmbHumiMin;
AmbHumiMax = src.AmbHumiMax;
PressUpMean = src.PressUpMean;
PressUpStart = src.PressUpStart;
PressUpEnd = src.PressUpEnd;
PressUpMin = src.PressUpMin;
PressUpMax = src.PressUpMax;
PressDownMean = src.PressDownMean;
PressDownStart = src.PressDownStart;
PressDownEnd = src.PressDownEnd;
PressDownMin = src.PressDownMin;
PressDownMax = src.PressDownMax;
PressDeltaMean = src.PressDeltaMean;
PressDeltaStart = src.PressDeltaStart;
PressDeltaEnd = src.PressDeltaEnd;
PressDeltaMin = src.PressDeltaMin;
PressDeltaMax = src.PressDeltaMax;
TempUpMean = src.TempUpMean;
TempUpStart = src.TempUpStart;
TempUpEnd = src.TempUpEnd;
TempUpMin = src.TempUpMin;
TempUpMax = src.TempUpMax;
TempDownMean = src.TempDownMean;
TempDownStart = src.TempDownStart;
TempDownEnd = src.TempDownEnd;
TempDownMin = src.TempDownMin;
TempDownMax = src.TempDownMax;
TempDivMean = src.TempDivMean;
TempDivStart = src.TempDivStart;
TempDivEnd = src.TempDivEnd;
TempDivMin = src.TempDivMin;
TempDivMax = src.TempDivMax;
FlowStart = src.FlowStart;
FlowEnd = src.FlowEnd;
FlowMin = src.FlowMin;
FlowMax = src.FlowMax;
Custom1 = src.Custom1;
Custom2 = src.Custom2;
Custom3 = src.Custom3;
Custom4 = src.Custom4;
Custom5 = src.Custom5;
Custom6 = src.Custom6;
Custom7 = src.Custom7;
Custom8 = src.Custom8;
Custom9 = src.Custom9;
Custom10 = src.Custom10;
}
public override string ToString()
{
return string.Format("batch={0}, procedure={1}, test={2}, {3} {4}", Batch.BatchNr, Batch.ProcedureName, Name(), StartTime.ToShortDateString(), StartTime.ToShortTimeString());
+48 -3
View File
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Config.Entities;
@@ -27,8 +26,10 @@ namespace Results.Entities
public virtual double CalibFactor { get; set; } /// iPerl calibration factor used during the test
public virtual double Q2ErrWOCorrection { get; set; }
public virtual bool Q2CorrectionDone { get; set; } /// true = iPerl Q2 correction was done
public virtual double Q2Correction { get; set; } /// iPerl Q2 correction used during the test
public virtual int Q2CorrFlowRight { get; set; } /// 1 = right to left
public virtual double Q2Correction { get; set; } /// !!! obsolete
public virtual int Q2CorrRFlow { get; set; } /// iPerl Q2 correction for the R-flow written to iPerl
public virtual int Q2CorrLFlow { get; set; } /// iPerl Q2 correction for the L-flow written to iPerl
public virtual int Q2CorrFlowRight { get; set; } /// 1 = right to left
public virtual double Diff2Hz8Hz { get; set; }
public virtual bool Hz2CorrectionDone { get; set; } /// true = iPerl Q2 correction was done
public virtual int Hz2Correction { get; set; } /// iPerl Q2 correction used during the test
@@ -142,6 +143,50 @@ namespace Results.Entities
}
public virtual void CopyContentFrom(WaterMeter src)
{
if (src == null) return;
SerialNr = src.SerialNr;
SerialNrAux = src.SerialNrAux;
PurchaseOrder = src.PurchaseOrder;
YearOfProduction = src.YearOfProduction;
// WMPosition skipped
EndState = src.EndState;
EndStateAux = src.EndStateAux;
QRise = src.QRise;
QFall = src.QFall;
Passed = src.Passed;
ResultCode = src.ResultCode;
#if IPERL
SerialNrEx = src.SerialNrEx;
OrigCalibFactor = src.OrigCalibFactor;
CalibFactor = src.CalibFactor;
Q2ErrWOCorrection = src.Q2ErrWOCorrection;
Q2CorrectionDone = src.Q2CorrectionDone;
Q2Correction = src.Q2Correction;
Q2CorrRFlow = src.Q2CorrRFlow;
Q2CorrLFlow = src.Q2CorrLFlow;
Q2CorrFlowRight = src.Q2CorrFlowRight;
Diff2Hz8Hz = src.Diff2Hz8Hz;
Hz2CorrectionDone = src.Hz2CorrectionDone;
Hz2Correction = src.Hz2Correction;
#endif
#if ORACLE_DB
Pruefindex = src.Pruefindex;
HydrPruefung = src.HydrPruefung;
#endif
foreach (var mtr in MeterTestRslts)
{
MeterTestRslt srcMtr = src.GetMeterTestRslt(mtr.Name(), (Config.Entities.CompoundMeterId)mtr.CompoundMeterId);
if (srcMtr != null)
{
mtr.CopyContentFrom(srcMtr);
mtr.TestRslt.CopyContentFrom(srcMtr.TestRslt);
}
}
}
public override string ToString()
{
StringBuilder sb = new StringBuilder(80);
+3 -1
View File
@@ -30,7 +30,9 @@ namespace Results.Mappings
Map(x => x.Q2ErrWOCorrection);
Map(x => x.Q2CorrectionDone);
Map(x => x.Q2Correction);
Map(x => x.Q2CorrFlowRight);
Map(x => x.Q2CorrRFlow);
Map(x => x.Q2CorrLFlow);
Map(x => x.Q2CorrFlowRight);
Map(x => x.Diff2Hz8Hz);
Map(x => x.Hz2CorrectionDone);
Map(x => x.Hz2Correction);
+2 -2
View File
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.12.486.0")]
[assembly: AssemblyFileVersion("2.12.486.0")]
[assembly: AssemblyVersion("2.12.544.0")]
[assembly: AssemblyFileVersion("2.12.544.0")]
+1
View File
@@ -59,6 +59,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="BatchResults.cs" />
<Compile Include="DBase.cs" />
<Compile Include="Entities\Batch.cs" />
<Compile Include="Entities\Components.cs" />
<Compile Include="Entities\MeterTestRslt.cs" />
+2 -2
View File
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.12.514.0")]
[assembly: AssemblyFileVersion("2.12.514.0")]
[assembly: AssemblyVersion("2.12.542.0")]
[assembly: AssemblyFileVersion("2.12.542.0")]
@@ -533,8 +533,8 @@ namespace TBF.BenchControl.DB.SensusOracle
logger.WriteLine(string.Format("JustierWert=0,2")); /// 0,2
logger.WriteLine(string.Format("Corrected2Hz={0}", wMtr.Hz2CorrectionDone ? 1 : 0));
logger.WriteLine(string.Format("Q2Corrected={0}", wMtr.Q2CorrectionDone ? 1 : 0));
logger.WriteLine(string.Format("Q2CorrectionRight={0}", (int)Math.Round(wMtr.Q2Correction / 2)));
logger.WriteLine(string.Format("Q2CorrectionLeft={0}", (int)Math.Round(wMtr.Q2Correction)));
logger.WriteLine(string.Format("Q2CorrectionRight={0}", wMtr.Q2CorrRFlow));
logger.WriteLine(string.Format("Q2CorrectionLeft={0}", wMtr.Q2CorrLFlow));
logger.WriteLine(string.Format("Q2CorrectionFlowRight={0}", wMtr.Q2CorrFlowRight));
logger.WriteLine(string.Format("FlowDirectionRight={0}", wMtr.Q2CorrFlowRight));
logger.WriteLine(string.Format("Position={0}", wMtr.WMPosition));
@@ -1102,8 +1102,8 @@ namespace TBF.BenchControl.DB.SensusOracle
parm = new OracleParameter("WITHQ2CORRECTION", OracleDbType.Int32); parm.Value = wm.Q2CorrectionDone ? 1 : 0; cmd.Parameters.Add(parm); ///:7
parm = new OracleParameter("ERRQ2", OracleDbType.Double); parm.Value = q2ErrWOCorrection; cmd.Parameters.Add(parm); ///:8
parm = new OracleParameter("Q2CORRECTIONFLOWRIGHT", OracleDbType.Int32);parm.Value = wm.Q2CorrFlowRight;/*1=right to left*/ cmd.Parameters.Add(parm); ///:9
parm = new OracleParameter("Q2CORRECTIONLEFT", OracleDbType.Int32); parm.Value = (int)Math.Round(wm.Q2Correction); cmd.Parameters.Add(parm); ///:10
parm = new OracleParameter("Q2CORRECTIONRIGHT", OracleDbType.Int32); parm.Value = (int)Math.Round(wm.Q2Correction / 2); cmd.Parameters.Add(parm); ///:11
parm = new OracleParameter("Q2CORRECTIONLEFT", OracleDbType.Int32); parm.Value = wm.Q2CorrLFlow; cmd.Parameters.Add(parm); ///:10
parm = new OracleParameter("Q2CORRECTIONRIGHT", OracleDbType.Int32); parm.Value = wm.Q2CorrRFlow; cmd.Parameters.Add(parm); ///:11
int rowsUpdated = cmd.ExecuteNonQuery();
log.InfoFormat("VT_IP_ZAEHLER_PINDEX_PD inserted, PcbNr={0}, pruefix={1}", wm.SerialNr, max_Pruefindex);
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
/// Copyright (c) 2013-2017 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
@@ -40,6 +40,8 @@ namespace TBF.BenchControl.DataEntry.Standard6
completed = false;
enabledComboBoxes = new List<ComboBox>();
Height = 147 + WaterMetersCount * 90;
StartForceCloseHandler();
}
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
/// Copyright (c) 2013-2017 Sensus Metering Systems
///
using System;
using System.Windows.Forms;
@@ -76,10 +76,10 @@ namespace TBF.BenchControl.DataEntry.Standard6
private void okButton_Click(object sender, EventArgs e)
{
if (WaterMetersCount >= 1) EndStateText[0] = textBox1.Text;
if (WaterMetersCount >= 2) EndStateText[1] = textBox3.Text;
if (WaterMetersCount >= 3) EndStateText[2] = textBox4.Text;
if (WaterMetersCount >= 4) EndStateText[3] = textBox5.Text;
if (WaterMetersCount >= 5) EndStateText[4] = textBox6.Text;
if (WaterMetersCount >= 2) EndStateText[1] = textBox2.Text;
if (WaterMetersCount >= 3) EndStateText[2] = textBox3.Text;
if (WaterMetersCount >= 4) EndStateText[3] = textBox4.Text;
if (WaterMetersCount >= 5) EndStateText[4] = textBox5.Text;
if (WaterMetersCount >= 6) EndStateText[5] = textBox6.Text;
completed = true;
@@ -124,25 +124,25 @@ namespace TBF.BenchControl.DataEntry.Standard6
///
void OpenBeginningDlg(EntryFormNoStartEnd myRef)
{
myRef.modelessDlg = new CycleBeginningForm(Config.Data.WMsCount);
myRef.modelessDlg = new CycleBeginningForm(myRef.waterMeters.Length);
modelessDlg.Show();
}
///
void OpenEndDlg(EntryFormNoStartEnd myRef)
{
myRef.modelessDlg = new CycleEndForm(Config.Data.WMsCount);
myRef.modelessDlg = new CycleEndForm(myRef.waterMeters.Length);
modelessDlg.Show();
}
///
void OpenTestStartStatesDlg(EntryFormNoStartEnd myRef)
{
myRef.modelessDlg = new TestStartEndForm(Config.Data.WMsCount, disabled);
myRef.modelessDlg = new TestStartEndForm(myRef.waterMeters.Length, disabled);
modelessDlg.Show();
}
///
void OpenTestEndStatesDlg(EntryFormNoStartEnd myRef)
{
myRef.modelessDlg = new TestStartEndForm(Config.Data.WMsCount, wmStartStateStr, disabled, refVolume, errLimLo, errLimHi);
myRef.modelessDlg = new TestStartEndForm(myRef.waterMeters.Length, wmStartStateStr, disabled, refVolume, errLimLo, errLimHi);
modelessDlg.Show();
}
@@ -242,8 +242,10 @@ namespace TBF.BenchControl.DataEntry.iPerl
wm.CalibFactor = iPerl.CalibrationFactor;
wm.Q2ErrWOCorrection = iPerl.Q2ErrorWOCorrection;
wm.Q2CorrectionDone = iPerl.Q2CorrectionDone;
wm.Q2Correction = iPerl.Q2CorrectionFactor;
wm.Diff2Hz8Hz = iPerl.Diff2Hz8Hz;
wm.Q2Correction = iPerl.Q2Correction;
wm.Q2CorrRFlow = iPerl.Q2CorrRFlow;
wm.Q2CorrLFlow = iPerl.Q2CorrLFlow;
wm.Diff2Hz8Hz = iPerl.Diff2Hz8Hz;
wm.Hz2CorrectionDone = iPerl.Hz2CorrectionDone;
wm.Hz2Correction = iPerl.Hz2CorrectionFactor;
@@ -8,7 +8,7 @@ using Config.Entities;
namespace TBF.BenchControl.Dummy.Balance
{
public class Component : ComponentBase, GenericDevices.IBalance, IOperation
public class Component : ComponentBase, GenericDevices.IScale, IOperation
{
private static readonly ILog log = LogManager.GetLogger(typeof(Component));
public override string ToString()
@@ -26,7 +26,7 @@ namespace TBF.BenchControl.Dummy.Balance
log.Debug(this.ToString());
}
public int BalanceNr { get { return 0; } }
public int ScaleNr { get { return 0; } }
public double Capacity { get { return 10000.0; } }
public GenericDevices.IValve DrainValve { get { return null; } }
public bool IsEmpty(double mass) { return true; }
+8 -4
View File
@@ -115,6 +115,7 @@ namespace TBF.BenchControl
TurnPumpOnOffDone,
/// CheckUi events
UiCmdReloadBatch,
UiCmdStartTest,
UiCmdStartQ1,
UiCmdStartQ2,
@@ -123,16 +124,17 @@ namespace TBF.BenchControl
UiCmdStop,
UiCmdPurgeBegin,
UiCmdPurgeEnd,
UiCmdEmptyTank1,
UiCmdEmptyTank2,
UiCmdEmptyTank3,
UiCmdDrainTank1,
UiCmdDrainTank2,
UiCmdDrainTank3,
UiCmdBreak,
UiCmdResetResults,
UiCmdAcceptResults,
UiCmdCalibration,
UiCmdCameraTest,
UiCmdSensitivityTest,
UiCmdB1,
UiCmdCustom,
UiCmdB1,
UiCmdB2,
UiCmdB3,
@@ -169,6 +171,8 @@ namespace TBF.BenchControl
No,
Next, /// To move to the next state when debugging
OK,
Retry,
Abort,
TimerBusy,
SetOutputsDone,
@@ -7,11 +7,11 @@ namespace TBF.BenchControl.GenericDevices
{
public interface ICamera : Generic.IComponent
{
void ClearRois();
void ClearRoiParams();
int RegisterRoi(string roiParams); /// returns 0=NOK or handle (=index)
int GetResult(int roiHandle); /// returns result for a registered ROI
int GetResult(int roiHandle, out long timeMs); /// returns result for a registered ROI and camera time in ms
/// <summary>
/// Display live image.
@@ -0,0 +1,24 @@
///
/// Copyright (c) 2017 Sensus Metering Systems
///
namespace TBF.BenchControl.GenericDevices
{
public interface ICameraDisplay : Generic.IComponent
{
/// <summary>
/// Display static images.
/// </summary>
/// <returns>Reference to operation object instance</returns>
IOperation ShowStaticImageOp(string[] imageFileNames, string title);
/// <summary>
/// Display static images.
/// </summary>
/// <returns>Reference to operation object instance</returns>
IOperation ShowLiveStreamOp(string[] imageFileNames, string title);
bool[] SelectedImages { get; }
}
}
@@ -8,11 +8,18 @@ namespace TBF.BenchControl.GenericDevices
public interface IRoi : IComponent, IRegisterReader
{
GenericDevices.ICamera Camera { get; }
bool Detected { get; }
string DetectedImageName { get; }
bool Detected { get; set; }
void ClearRoi();
void RegisterRoiToCamera();
double VolumeStart { get; } /// in l
double VolumeEnd { get; } /// in l
double TimestampStart { get; } /// in s
double TimestampEnd { get; } /// in s
/// <summary>
/// Watermeter wheel/arrow detection process.
/// </summary>
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
/// Copyright (c) 2013-2017 Sensus Metering Systems
///
using System.Collections.Generic;
using TBF.BenchControl.Generic;
@@ -10,12 +10,12 @@ namespace TBF.BenchControl.GenericDevices
/// <summary>
/// Basic balance functions
/// </summary>
public interface IBalance : IComponent
public interface IScale : IComponent
{
/// <summary>
/// Balance number: 0-based index required for communication with the Elde component
/// </summary>
int BalanceNr { get; }
int ScaleNr { get; }
/// <summary>
/// Balance water tank capacity in kg or ltr
@@ -5,7 +5,7 @@ using TBF.BenchControl.Generic;
namespace TBF.BenchControl.GenericDevices
{
public interface IBalance2 : IBalance, IComponent
public interface IScale2 : IScale, IComponent
{
/// <summary>
/// Events: Done, Error
@@ -1,12 +1,12 @@
///
/// Copyright (c) 2013-2016 Sensus Metering Systems
/// Copyright (c) 2013-2017 Sensus Metering Systems
///
using System;
using TBF.BenchControl.Generic;
namespace TBF.BenchControl.GenericDevices
{
public interface IBalanceCfg : IComponentCfg
public interface IScaleCfg : IComponentCfg
{
///
/// Parameters displayed in Metrology tab page
@@ -200,7 +200,7 @@ namespace TBF.BenchControl.Keithley.Multimeter_2010_RS232
/// <summary>Run this device</summary>
public void RunDeviceBefore()
{
if (multimeterCfg.DebugLevel == DebugMode.Simulate) return;
if (serialPort == null) return;
receivedData.Append(serialPort.ReadExisting());
@@ -244,7 +244,7 @@ namespace TBF.BenchControl.Keithley.Multimeter_2010_RS232
/// <summary>Run this device</summary>
public void RunDeviceAfter()
{
if (multimeterCfg.DebugLevel == DebugMode.Simulate) return;
if (serialPort == null) return;
switch (scanState)
{
@@ -297,7 +297,11 @@ namespace TBF.BenchControl.Keithley.Multimeter_2010_RS232
{
if (multimeterCfg.DebugLevel == DebugMode.Simulate) return;
serialPort.Close();
if (serialPort != null)
{
serialPort.Close();
serialPort = null;
}
}
}
}
@@ -10,7 +10,7 @@ using TBF.BenchControl.Generic;
namespace TBF.BenchControl.MettlerToledo.Multi
{
public class BalanceCfg : ComponentCfgBase, GenericDevices.IBalanceCfg, GenericDevices.ICalibInfoCfg
public class BalanceCfg : ComponentCfgBase, GenericDevices.IScaleCfg, GenericDevices.ICalibInfoCfg
{
public IComponentCfgCtrl GetControl() { return new BalanceCfgCtrl(); }
@@ -19,7 +19,7 @@ namespace TBF.BenchControl.MettlerToledo.Multi
/// <note>
/// Implemented and tested on 15.10.2013 by Milan Hanajik
/// </note>
public class BalanceDev : TankDraining, IDevice, GenericDevices.IBalance
public class BalanceDev : TankDraining, IDevice, GenericDevices.IScale
{
/// <summary>
/// Info: StartMassMeasurement() and "Balnce response = .., Mass = ..."
@@ -48,7 +48,7 @@ namespace TBF.BenchControl.MettlerToledo.Multi
protected static SerialPort serialPort;
protected static StringBuilder stringBuilder;
public int BalanceNr { get { return balanceNr; } }
public int ScaleNr { get { return balanceNr; } }
public int IdNr { get { return balanceCfg.IdNr; } }
public double Capacity { get { return balanceCfg.Capacity; } }
public double Resolution { get { return balanceCfg.Resolution; } }
@@ -276,7 +276,7 @@ namespace TBF.BenchControl.MettlerToledo.Multi
/// <summary>Stop this device</summary>
public void StopDevice()
{
if (balanceCfg.IdNr == 1 && serialPort != null)
if ((balanceCfg.DebugLevel != DebugMode.Simulate) && (balanceCfg.IdNr == 1) && (serialPort != null))
{
serialPort.Close();
serialPort = null;
@@ -16,19 +16,19 @@ namespace TBF.BenchControl.MettlerToledo.Multi
bool done;
/// Set by the constructor
BalanceDev balanceDev;
BalanceDev scale;
DoubleBox result;
/// <summary>
/// Events: BalanceDone, Error
/// </summary>
/// <param name="balanceDev">Balance device instance</param>
/// <param name="scale">Balance device instance</param>
/// <param name="requiredReadingsCount">Required mass readings count (>= 3)</param>
/// <param name="result">Reference to the measured mass in kg</param>
public ReadMassOp(BalanceDev balanceDev, ref DoubleBox result)
public ReadMassOp(BalanceDev scale, ref DoubleBox result)
{
if (balanceDev == null) throw new ArgumentNullException("balanceDev");
this.balanceDev = balanceDev;
if (scale == null) throw new ArgumentNullException("scale");
this.scale = scale;
this.result = result;
@@ -39,7 +39,7 @@ namespace TBF.BenchControl.MettlerToledo.Multi
public void Start()
{
done = false;
started = BalanceDev.GetImmediateMassMeasurement(balanceDev.IdNr, balanceDev.Name);
started = BalanceDev.GetImmediateMassMeasurement(scale.IdNr, scale.Name);
}
/// <summary>Run this operation</summary>
@@ -52,22 +52,21 @@ namespace TBF.BenchControl.MettlerToledo.Multi
{
if (!started)
{
started = BalanceDev.GetImmediateMassMeasurement(balanceDev.IdNr, balanceDev.Name);
if (!done) return Event.Busy;
else return Event.BalanceDone;
started = BalanceDev.GetImmediateMassMeasurement(scale.IdNr, scale.Name);
if (!done)
return Event.Busy;
else
return Event.BalanceDone;
}
else if (started && balanceDev.MsrmntState == MsrmntState.Valid)
else if (started && scale.MsrmntState != MsrmntState.Busy)
{
result.Val = balanceDev.Mass;
log.InfoFormat("ReadMassOp.Run() ... mass={0} ... returning Event.BalanceDone", balanceDev.Mass);
if (scale.MsrmntState == MsrmntState.Valid) result.Val = scale.Mass;
log.InfoFormat("ReadMassOp.Run() ... state={0}, mass={1} ... returning Event.BalanceDone",
scale.MsrmntState, scale.Mass);
done = true;
started = false;
return Event.BalanceDone; /// Mass read OK
}
else if (done)
{
return Event.BalanceDone; /// Mass has already been read (at least once)
}
else
{
return Event.Busy;
@@ -10,7 +10,7 @@ using TBF.BenchControl.Generic;
namespace TBF.BenchControl.MettlerToledo.Standard
{
public class BalanceCfg : ComponentCfgBase, GenericDevices.IBalanceCfg, GenericDevices.ICalibInfoCfg, GenericDevices.ITankDrainingCfg
public class BalanceCfg : ComponentCfgBase, GenericDevices.IScaleCfg, GenericDevices.ICalibInfoCfg, GenericDevices.ITankDrainingCfg
{
public IComponentCfgCtrl GetControl() { return new BalanceCfgCtrl(); }
@@ -19,7 +19,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
/// <note>
/// Implemented and tested on 15.10.2013 by Milan Hanajik
/// </note>
public class BalanceDev : TankDraining, IDevice, GenericDevices.IBalance
public class BalanceDev : TankDraining, IDevice, GenericDevices.IScale
{
/// <summary>
/// Info: StartMassMeasurement() and "Balnce response = .., Mass = ..."
@@ -47,7 +47,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
protected SerialPort serialPort;
protected StringBuilder stringBuilder;
public int BalanceNr { get { return balanceNr; } }
public int ScaleNr { get { return balanceNr; } }
public double Capacity { get { return balanceCfg.Capacity; } }
public int EmptyTimeSec { get { return balanceCfg.DrainTimeSec; } }
@@ -452,14 +452,11 @@ namespace TBF.BenchControl.MettlerToledo.Standard
/// <summary>Stop this device</summary>
public void StopDevice()
{
try
if ((balanceCfg.DebugLevel != DebugMode.Simulate) && (serialPort != null))
{
serialPort.Close();
serialPort = null;
}
catch
{
}
}
/// <summary>
@@ -19,7 +19,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
/// <note>
/// Implemented and tested on 15.10.2013 by Milan Hanajik
/// </note>
public class BalanceNewDev : BalanceDev, IDevice, GenericDevices.IBalance2
public class BalanceNewDev : BalanceDev, IDevice, GenericDevices.IScale2
{
/// <summary>
/// Info: StartMassMeasurement() and "Balnce response = .., Mass = ..."
@@ -18,7 +18,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
/// <note>
/// Implemented and tested on 15.10.2013 by Milan Hanajik
/// </note>
public class BalanceOld : BalanceDev, IDevice, GenericDevices.IBalance
public class BalanceOld : BalanceDev, IDevice, GenericDevices.IScale
{
/// <summary>
/// Info: StartMassMeasurement() and "Balnce response = .., Mass = ..."
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2016 Sensus Metering Systems
/// Copyright (c) 2013-2017 Sensus Metering Systems
///
using System;
using log4net;
@@ -12,22 +12,23 @@ namespace TBF.BenchControl.MettlerToledo.Standard
private static readonly ILog log = LogManager.GetLogger(typeof(ReadMassOp));
public override string ToString() { return string.Format("ReadMassOp(.,.)"); }
bool started;
bool done;
/// Set by the constructor
BalanceDev balanceDev;
BalanceDev scale;
DoubleBox result;
/// <summary>
/// Events: BalanceDone, Error
/// </summary>
/// <param name="balanceDev">Balance device instance</param>
/// <param name="scale">Balance device instance</param>
/// <param name="requiredReadingsCount">Required mass readings count (>= 3)</param>
/// <param name="result">Reference to the measured mass in kg</param>
public ReadMassOp(BalanceDev balanceDev, ref DoubleBox result)
public ReadMassOp(BalanceDev scale, ref DoubleBox result)
{
if (balanceDev == null) throw new ArgumentNullException("balanceDev");
this.balanceDev = balanceDev;
if (scale == null) throw new ArgumentNullException("balanceDev");
this.scale = scale;
this.result = result;
@@ -37,8 +38,9 @@ namespace TBF.BenchControl.MettlerToledo.Standard
/// <summary>Start this operation</summary>
public void Start()
{
scale.GetImmediateMassMeasurement();
started = true;
done = false;
balanceDev.GetImmediateMassMeasurement();
}
/// <summary>Run this operation</summary>
@@ -49,22 +51,26 @@ namespace TBF.BenchControl.MettlerToledo.Standard
/// </returns>
public Event Run()
{
if (balanceDev.MsrmntState == MsrmntState.Valid)
{
result.Val = balanceDev.Mass;
done = true;
log.InfoFormat("ReadMassOp.Run() ... mass={0} ... returning Event.BalanceDone", balanceDev.Mass);
balanceDev.GetImmediateMassMeasurement(); /// Start another measurement
return Event.BalanceDone; /// Mass read OK
}
else if (done)
{
return Event.BalanceDone; /// Mass has already been read (at least once)
}
else
{
return Event.None;
}
if (!started)
{
scale.GetImmediateMassMeasurement();
started = true;
done = false;
return Event.Busy;
}
else if (started && scale.MsrmntState != MsrmntState.Busy)
{
if (scale.MsrmntState == MsrmntState.Valid) result.Val = scale.Mass;
log.InfoFormat("ReadMassOp.Run() ... state={0}, mass={1} ... returning Event.BalanceDone",
scale.MsrmntState, scale.Mass);
done = true;
started = false;
return Event.BalanceDone; /// Mass read OK
}
else
{
return Event.Busy;
}
}
/// <summary>Stop this operation</summary>
@@ -77,7 +77,8 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
Session wscpSession;
bool wscpOpened;
bool closeWscpThread;
string wscpFileName;
string wscpSrcFileName;
string wscpDstFileName;
enum WscpCommand
{
None,
@@ -90,9 +91,10 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
/// ROI related parameters
///
IList<string> roiParams;
long cameraTimeMs;
int[] result;
///
public void ClearRois() { roiParams.Clear(); }
public void ClearRoiParams() { roiParams.Clear(); }
public int RegisterRoi(string rParams)
{
this.roiParams.Add(rParams);
@@ -101,8 +103,10 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
return newHandle;
}
///
public int GetResult(int roiHandle)
public int GetResult(int roiHandle, out long timeMs)
{
timeMs = cameraTimeMs;
if (roiHandle > 0 && roiHandle <= roiParams.Count)
{
return result[roiHandle - 1];
@@ -113,6 +117,18 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
///
/// UDP Port number for 'MeasurementOp'
///
const int UdpPortRangeStart = 13800;
const int UdpPortRangeEnd = 13850;
static int nextUdpPortNr = UdpPortRangeStart;
public static int GetNextUdpPortNr() { return nextUdpPortNr++; }
///
readonly int measurementUdpPortNr;
UdpClient measurementListener;
public Camera() {}
public Camera(Generic.IComponentCfg cfg, IList<Generic.IComponent> components)
@@ -125,6 +141,8 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
Telnet = null;
terminalDlg = null;
measurementUdpPortNr = GetNextUdpPortNr();
roiParams = new List<string>();
running = false;
@@ -156,7 +174,7 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
if (cameraDetected)
{
/// Open telnet clint and start the log-in process
Telnet = new Telnet.TelnetClient(this, CameraCfg.Name, ClpUserName, ClpPassword, TelnetPrompt, TelnetSkipFirstLine);
Telnet = new Telnet.TelnetClient(this, CameraCfg.Name, ClpUserName, ClpPassword, TelnetPrompt, TelnetSkipFirstLine, CameraCfg.DisplayTerminal);
if (CameraCfg.DisplayTerminal)
{
@@ -179,6 +197,10 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
Telnet.Enqueue(new Telnet.Command(Network.Telnet.CmdAction.CONNECT, ipAddress.ToString(), 10, 30));
//measurementListener = new UdpClient(measurementUdpPortNr);
//new Thread(new ThreadStart(MeasurementUdpListener)).Start();
wscpThread = new Thread(new ThreadStart(WscpWorker));
wscpThread.Start();
@@ -213,10 +235,10 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
public void RunDeviceAfter()
{
if (running)
{
Console.WriteLine("Time={0} IP={1} scp={2}", StateMachine.Time, IPAddress, wscpOpened ? "Opened" : "Closed");
}
// if (running)
// {
// Console.WriteLine("Time={0} IP={1} scp={2}", StateMachine.Time, IPAddress, wscpOpened ? "Opened" : "Closed");
// }
}
@@ -346,6 +368,11 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
wscpSession = new WinSCP.Session();
wscpSession.Open(wscpSessionOptions);
TransferOptions transferOptions = new TransferOptions();
transferOptions.TransferMode = TransferMode.Binary;
TransferOperationResult transferResult;
wscpOpened = wscpSession.Opened;
if (wscpOpened)
@@ -356,7 +383,8 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
{
case WscpCommand.Get:
wscpCommand = WscpCommand.None;
wscpSession.GetFiles(wscpFileName, string.Format("c:\\TBF\\TftpRoot\\{0}-{1}", Name, wscpFileName));
transferResult = wscpSession.GetFiles(wscpSrcFileName, wscpDstFileName, false, transferOptions);
///transferResult.Check();
break;
default:
break;
@@ -372,15 +400,16 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
/// <summary>
/// Transfer a file via SCP
/// </summary>
/// <param name="fileName"></param>
/// <param name="srcFileName"></param>
/// <returns>0 (success), -1 (busy), -2 (no session)</returns>
public int WscpTransferFile(string fileName)
public int WscpTransferFile(string srcFileName, string dstFileName)
{
if (!wscpOpened) return -2;
if (wscpCommand != WscpCommand.None) return -1;
wscpFileName = fileName;
wscpSrcFileName = srcFileName;
wscpDstFileName = dstFileName;
wscpCommand = WscpCommand.Get;
return 0;
}
@@ -422,8 +451,9 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
/// Prepare the telent command
StringBuilder sb = new StringBuilder();
foreach (var s in roiParams) sb.AppendFormat(" {0}", s);
command = string.Format("clp/Measurement -udp {0} {1}{2}{3} 1 1 0 0 0",
ipAddress, 6378,
command = string.Format("clp/Measurement -udp {0} {1}{2}{3} 1 7 0 0 0",
NetAdapter.IPAddress,
measurementUdpPortNr,
CameraCfg.UseTestImages ? (" -l " + CameraCfg.TestImagesCount.ToString()) : string.Empty,
sb);
@@ -469,14 +499,69 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
{
string[] pulsesArr = msrmtData.MeasuredData.Split(new char[] { ';' });
if (result != null && result.Length + 1 == pulsesArr.Length)
uint uiVal;
if (result != null && result.Length + 1 == pulsesArr.Length && uint.TryParse(pulsesArr[0], out uiVal))
{
cameraTimeMs = (long)uiVal;
for (int i = 0; i < result.Length; i++)
{
int val;
if (int.TryParse(pulsesArr[i + 1], out val)) result[i] = Math.Abs(val);
if (int.TryParse(pulsesArr[i + 1], out val))
{
result[i] = Math.Abs(val);
}
}
}
}
void MeasurementUdpListener()
{
StringBuilder toBeProcessed = new StringBuilder();
IPEndPoint ipEndPoint = new IPEndPoint(IPAddress.Any, measurementUdpPortNr);
try
{
while (true)
{
byte[] byteArray = measurementListener.Receive(ref ipEndPoint);
toBeProcessed.Append(Encoding.ASCII.GetString(byteArray, 0, byteArray.Length));
log.DebugFormat("MeasurementUdpListener() ... toBeProcessed = {0}", toBeProcessed);
while (true)
{
int from = toBeProcessed.ToString().IndexOf('[');
if (from < 0) break;
int len = toBeProcessed.ToString(from + 1, toBeProcessed.Length - from - 1).IndexOf(']');
if (len < 0) break;
string[] pulsesArr = toBeProcessed.ToString(from + 1, len).Split(new char[] { ';' });
uint uiVal;
if (result != null && result.Length + 1 == pulsesArr.Length && uint.TryParse(pulsesArr[0], out uiVal))
{
// cameraTimeMs = (long)uiVal;
for (int i = 0; i < result.Length; i++)
{
int val;
if (int.TryParse(pulsesArr[i + 1], out val))
{
// result[i] = Math.Abs(val);
}
}
}
toBeProcessed.Remove(0, from + len + 2);
}
}
}
catch
{
log.FatalFormat("Camera : MeasurementUdpListener() thread failed");
}
}
}
}
@@ -1,81 +0,0 @@
///
/// Copyright (c) 2017 Sensus Metering Systems
///
using System.Collections.Generic;
using System.Text;
using TBF.BenchControl.Network.Telnet;
namespace TBF.BenchControl.Network.Camera.CLP1611
{
public class MeasurementOp : IOperation
{
readonly CLP1611.Camera camera;
readonly CLP1611.CameraCfg cameraCfg;
readonly Telnet.TelnetClient telnet;
readonly string ipAddress;
readonly int portNr;
readonly IList<string> roiParams;
string command;
bool measurementCommandSent;
/// <summary>
/// Events: Event.None or Event.Error
/// </summary>
/// <param name="camera">CLP1611.Camera reference</param>
public MeasurementOp(Camera camera, string ipAddress, int portNr, IList<string> roiParams)
{
this.camera = camera;
this.cameraCfg = camera.CameraCfg;
this.telnet = camera.Telnet;
this.ipAddress = ipAddress;
this.portNr = portNr;
this.roiParams = roiParams;
measurementCommandSent = false;
}
public void Start()
{
measurementCommandSent = false;
}
public Event Run()
{
if (!measurementCommandSent)
{
if (telnet.State == TelnetClient.TelnetState.Inactive)
{
//
// Prepare and send (=enqueue) command
//
StringBuilder sb = new StringBuilder();
foreach (var s in roiParams)
{
sb.Append(" ");
sb.Append(s);
}
command = string.Format("clp/Measurement -udp {0} {1}{2}{3} 1 1 0 0 0",
ipAddress,
portNr,
cameraCfg.UseTestImages ? (" -l " + cameraCfg.TestImagesCount.ToString()) : string.Empty,
sb);
telnet.Enqueue(new Telnet.Command(Telnet.CmdAction.SEND_STRING, command));
measurementCommandSent = true;
}
}
return Event.None;
}
public void Stop()
{
if (measurementCommandSent)
{
telnet.Enqueue(new Telnet.Command(Telnet.CmdAction.SEND_COMMAND, Telnet.TelnetClient.CtrlCCommand));
}
}
}
}
@@ -0,0 +1,153 @@
///
/// Copyright (c) 2017 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
using System.Text;
using log4net;
using Config.Entities;
using TBF.BenchControl.GenericDevices;
using System.Windows.Forms;
namespace TBF.BenchControl.Network.Camera.Display
{
public class Display : ComponentBase, IOperation, ICameraDisplay
{
private static readonly ILog log = LogManager.GetLogger(typeof(Display));
public override string ToString()
{
return string.Format("{0}({1})", this.GetType().Namespace.Substring(17), Cfg.ToString(1));
}
public readonly DisplayCfg DisplayCfg;
///
public Display()
{
}
///
public Display(Generic.IComponentCfg cfg, IList<Generic.IComponent> components)
: base(cfg)
{
DisplayCfg = cfg as DisplayCfg;
log.Debug(this.ToString());
}
public bool[] SelectedImages { get { return selectedImages; } }
bool[] selectedImages;
public enum CurrentOp
{
None,
StaticImage,
LiveStream,
}
CurrentOp currentOp;
DialogResult result;
string title;
string[] imageFileNames;
System.Windows.Forms.Form modelessDlg;
///
delegate void DisplayFormDlgt(Display myRef);
///
void OpenStaticImageDisplay(Display myRef)
{
myRef.modelessDlg = new DisplayForm(imageFileNames, title);
modelessDlg.Show();
}
///
void OpenLiveStreamDisplay(Display myRef)
{
myRef.modelessDlg = new DisplayForm(imageFileNames, title);
modelessDlg.Show();
}
/// <returns>Reference to the operation</returns>
public IOperation ShowStaticImageOp(string[] imageFileNames, string title)
{
if (currentOp != CurrentOp.None) throw new Exception("Sequence error");
this.imageFileNames = imageFileNames;
this.title = title;
currentOp = CurrentOp.StaticImage;
return this;
}
/// <returns>Reference to the operation</returns>
public IOperation ShowLiveStreamOp(string[] imageFileNames, string title)
{
if (currentOp != CurrentOp.None) throw new Exception("Sequence error");
this.imageFileNames = imageFileNames;
this.title = title;
currentOp = CurrentOp.LiveStream;
return this;
}
/// <summary>Start this operation</summary>
public void Start()
{
result = DialogResult.None;
switch (currentOp)
{
case CurrentOp.StaticImage:
Program.MainWnd.Invoke(new DisplayFormDlgt(OpenStaticImageDisplay), this);
break;
case CurrentOp.LiveStream:
Program.MainWnd.Invoke(new DisplayFormDlgt(OpenLiveStreamDisplay), this);
break;
}
}
/// <summary>Run this operation</summary>
/// <returns>Event.None</returns>
public Event Run()
{
if ((modelessDlg is IHasCompleted) && !(modelessDlg as IHasCompleted).Completed)
{
return Event.ModelessFormIsOpen;
}
if ((result == DialogResult.None) && modelessDlg is DisplayForm)
{
/// Save the result (once)
selectedImages = (modelessDlg as DisplayForm).SelectedImages;
result = (modelessDlg as DisplayForm).Result;
modelessDlg = null;
}
if (result == DialogResult.OK) return Event.OK;
else if (result == DialogResult.Retry) return Event.Retry;
else if (result == DialogResult.Abort) return Event.Abort;
else return Event.None; /// Should never happen
}
/// <summary>Stop this operation</summary>
public void Stop()
{
if (modelessDlg is IHasCompleted)
{
UiBridge.Bridge.OnCloseModelessForm(this, null);
modelessDlg = null;
}
currentOp = CurrentOp.None;
}
}
}
@@ -0,0 +1,34 @@
///
/// Copyright (c) 2017 Sensus Metering Systems
///
using System.Xml.Serialization;
using Config.Entities;
using TBF.BenchControl.Generic;
namespace TBF.BenchControl.Network.Camera.Display
{
public class DisplayCfg : ComponentCfgBase, IComponentCfg
{
public IComponentCfgCtrl GetControl() { return new DisplayCfgCtrl(); }
///
/// Serialized parameters
///
/// Private parameterless constructor invoked by all other (public) constructors
DisplayCfg() {}
public DisplayCfg(string name, IComponentFactory factory)
: this()
{
Name = name;
Factory = factory;
}
public string ToString(int i)
{
return string.Format("Name={0}", Name);
}
}
}
@@ -0,0 +1,82 @@
///
/// Copyright (c) 2017 Sensus Metering Systems
///
using System;
using System.Windows.Forms;
using log4net;
using TBF.BenchControl.Generic;
namespace TBF.BenchControl.Network.Camera.Display
{
public partial class DisplayCfgCtrl : UserControl, IComponentCfgCtrl
{
static readonly ILog log = LogManager.GetLogger(typeof(DisplayCfgCtrl));
ComponentParametersDlg parent;
public bool ShowMore { get { return false; } }
DisplayCfg config;
public IComponentCfg Config
{
get { return config as IComponentCfg; }
set
{
config = value as DisplayCfg;
Redraw();
}
}
public DisplayCfgCtrl()
{
InitializeComponent();
}
private void PumpCfgCtrl_Load(object sender, EventArgs e)
{
parent = ParentForm as ComponentParametersDlg;
if (parent == null) return;
Redraw();
}
public void Closing()
{
}
void Redraw()
{
if (config == null) return; /// Control was not loaded, settings were not changed
classNameLabel.Text = config.Factory.ClassName;
nameTextBox.Text = config.Name;
}
public void Unlock()
{
nameTextBox.Enabled = true;
}
public CfgUpdateFlags VerifyCfg(ref string message)
{
CfgUpdateFlags flags = CfgUpdateFlags.None;
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);
}
return flags;
}
}
}
@@ -0,0 +1,109 @@
///
/// Copyright (c) 2017 Sensus Metering Systems
///
namespace TBF.BenchControl.Network.Camera.Display
{
partial class DisplayCfgCtrl
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.nameTextBox = new System.Windows.Forms.TextBox();
this.nameLabel = new System.Windows.Forms.Label();
this.classNameLabel = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// nameTextBox
//
this.nameTextBox.Enabled = false;
this.nameTextBox.Location = new System.Drawing.Point(99, 34);
this.nameTextBox.Name = "nameTextBox";
this.nameTextBox.Size = new System.Drawing.Size(174, 20);
this.nameTextBox.TabIndex = 1;
//
// nameLabel
//
this.nameLabel.AutoSize = true;
this.nameLabel.Location = new System.Drawing.Point(13, 37);
this.nameLabel.Name = "nameLabel";
this.nameLabel.Size = new System.Drawing.Size(35, 13);
this.nameLabel.TabIndex = 0;
this.nameLabel.Text = "Name";
//
// classNameLabel
//
this.classNameLabel.AutoSize = true;
this.classNameLabel.Location = new System.Drawing.Point(96, 11);
this.classNameLabel.Name = "classNameLabel";
this.classNameLabel.Size = new System.Drawing.Size(114, 13);
this.classNameLabel.TabIndex = 0;
this.classNameLabel.Text = "ComponentClassName";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(-211, -147);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(57, 13);
this.label1.TabIndex = 5;
this.label1.Text = "Arguments";
//
// textBox1
//
this.textBox1.Enabled = false;
this.textBox1.Location = new System.Drawing.Point(-125, -150);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(372, 20);
this.textBox1.TabIndex = 6;
//
// DisplayCfgCtrl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.textBox1);
this.Controls.Add(this.label1);
this.Controls.Add(this.nameTextBox);
this.Controls.Add(this.nameLabel);
this.Controls.Add(this.classNameLabel);
this.Name = "DisplayCfgCtrl";
this.Size = new System.Drawing.Size(500, 300);
this.Load += new System.EventHandler(this.PumpCfgCtrl_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TextBox nameTextBox;
private System.Windows.Forms.Label nameLabel;
private System.Windows.Forms.Label classNameLabel;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox textBox1;
}
}
@@ -0,0 +1,171 @@
///
/// Copyright (c) 2017 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using log4net;
using TBF.Resources;
using System.Drawing;
namespace TBF.BenchControl.Network.Camera.Display
{
public partial class DisplayForm : Form, GenericDevices.IHasCompleted
{
private static readonly ILog log = LogManager.GetLogger(typeof(DisplayForm));
/// <summary> Number of text boxes for serial numbers </summary>
readonly string[] imageFileNames;
readonly int imagesCount;
readonly GroupBox[] groupBoxes;
readonly PictureBox[] pictureBoxes;
readonly CheckBox[] checkBoxes;
readonly int boxesCount;
Timer myTimer;
public bool[] SelectedImages;
public DialogResult Result; /// DialogResult.None OK Retry or Cancel
/// Set to 'true' when the form closes
public bool Completed { get { return completed; } }
bool completed;
/// <summary>
/// Constructor
/// </summary>
/// <param name="waterMetersCount">Number of text boxes for serial numbers</param>
public DisplayForm(string[] imageFileNames, string title)
{
InitializeComponent();
this.imageFileNames = imageFileNames;
this.imagesCount = (imageFileNames == null) ? 0 : imageFileNames.Length;
groupBoxes = new GroupBox[] { groupBox1, groupBox2, groupBox3, groupBox4, groupBox5, groupBox6 };
pictureBoxes = new PictureBox[] { pictureBox1, pictureBox2, pictureBox3, pictureBox4, pictureBox5, pictureBox6 };
checkBoxes = new CheckBox[] { checkBox1, checkBox2, checkBox3, checkBox4, checkBox5, checkBox6 };
boxesCount = pictureBoxes.Length;
Text = title;
int lastVisibleGroupBoxIx = 0;
for (int i = 0; i < boxesCount; i++)
{
if (i < imagesCount && !string.IsNullOrEmpty(imageFileNames[i]))
{
groupBoxes[i].Text = string.Format("{0} {1}", Strings.Water_Meter, i + 1);
checkBoxes[i].Checked = true;
checkBoxes[i].Text = Strings.Retry;
lastVisibleGroupBoxIx = i;
}
else
{
groupBoxes[i].Visible = false;
checkBoxes[i].Checked = false;
}
}
SelectedImages = new bool[imagesCount];
if (lastVisibleGroupBoxIx < 3) Height = 338;
Result = DialogResult.None;
completed = false;
StartForceCloseHandler();
}
/// <summary> Parameterless constructor for all watermeters </summary>
public DisplayForm()
: this(null, string.Empty)
{
}
private void CycleBeginningForm_Load(object sender, EventArgs e)
{
okButton.Text = Strings.OkBtnText;
retryButton.Text = Strings.Retry;
abortButton.Text = Strings.Abort;
myTimer = new Timer();
myTimer.Interval = (500); // 45 mins
myTimer.Tick += new EventHandler(MyTimer_Tick);
myTimer.Start();
}
private void MyTimer_Tick(object sender, EventArgs e)
{
for (int i = 0; i < Math.Min(imagesCount, boxesCount); i++)
{
if (imageFileNames[i] != null &&
System.IO.File.Exists(imageFileNames[i]) &&
pictureBoxes[i] != null &&
pictureBoxes[i].Image == null)
{
pictureBoxes[i].Image = Image.FromFile(imageFileNames[i]); ;
checkBoxes[i].Checked = false;
}
}
}
void UpdateData()
{
for (int i = 0; i < Math.Min(imagesCount, boxesCount); i++)
{
SelectedImages[i] = checkBoxes[i].Checked;
}
}
private void okButton_Click(object sender, EventArgs e)
{
if (myTimer != null) myTimer.Stop();
UpdateData();
Result = DialogResult.OK;
completed = true;
Close();
}
private void abortButton_Click(object sender, EventArgs e)
{
if (myTimer != null) myTimer.Stop();
UpdateData();
Result = DialogResult.Abort;
completed = true;
Close();
}
private void retryButton_Click(object sender, EventArgs e)
{
if (myTimer != null) myTimer.Stop();
UpdateData();
Result = DialogResult.Retry;
completed = true;
Close();
}
#region Forced close handling
public void StartForceCloseHandler()
{
UiBridge.Bridge.CloseModelessFormHandler += delegate(object sender, EventArgs args)
{
if (InvokeRequired) { Invoke(new EventHandler<EventArgs>(OnForceClose), sender, args); }
else OnForceClose(sender, args);
};
}
private void OnForceClose(object sender, EventArgs args)
{
DialogResult = DialogResult.Cancel;
Close();
}
#endregion
}
}
@@ -0,0 +1,285 @@
///
/// Copyright (c) 2017 Sensus Metering Systems
///
namespace TBF.BenchControl.Network.Camera.Display
{
partial class DisplayForm
{
/// <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 Windows Form 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()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(DisplayForm));
this.okButton = new System.Windows.Forms.Button();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.checkBox1 = new System.Windows.Forms.CheckBox();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.checkBox2 = new System.Windows.Forms.CheckBox();
this.pictureBox2 = new System.Windows.Forms.PictureBox();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.checkBox3 = new System.Windows.Forms.CheckBox();
this.pictureBox3 = new System.Windows.Forms.PictureBox();
this.groupBox4 = new System.Windows.Forms.GroupBox();
this.checkBox4 = new System.Windows.Forms.CheckBox();
this.pictureBox4 = new System.Windows.Forms.PictureBox();
this.retryButton = new System.Windows.Forms.Button();
this.abortButton = new System.Windows.Forms.Button();
this.groupBox5 = new System.Windows.Forms.GroupBox();
this.checkBox5 = new System.Windows.Forms.CheckBox();
this.pictureBox5 = new System.Windows.Forms.PictureBox();
this.groupBox6 = new System.Windows.Forms.GroupBox();
this.checkBox6 = new System.Windows.Forms.CheckBox();
this.pictureBox6 = new System.Windows.Forms.PictureBox();
this.groupBox1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.groupBox2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit();
this.groupBox3.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox3)).BeginInit();
this.groupBox4.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox4)).BeginInit();
this.groupBox5.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox5)).BeginInit();
this.groupBox6.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox6)).BeginInit();
this.SuspendLayout();
//
// okButton
//
resources.ApplyResources(this.okButton, "okButton");
this.okButton.ForeColor = System.Drawing.Color.Black;
this.okButton.Name = "okButton";
this.okButton.UseVisualStyleBackColor = true;
this.okButton.Click += new System.EventHandler(this.okButton_Click);
//
// groupBox1
//
this.groupBox1.Controls.Add(this.checkBox1);
this.groupBox1.Controls.Add(this.pictureBox1);
resources.ApplyResources(this.groupBox1, "groupBox1");
this.groupBox1.ForeColor = System.Drawing.Color.Black;
this.groupBox1.Name = "groupBox1";
this.groupBox1.TabStop = false;
//
// checkBox1
//
resources.ApplyResources(this.checkBox1, "checkBox1");
this.checkBox1.Name = "checkBox1";
this.checkBox1.UseVisualStyleBackColor = true;
//
// pictureBox1
//
resources.ApplyResources(this.pictureBox1, "pictureBox1");
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.TabStop = false;
//
// groupBox2
//
this.groupBox2.Controls.Add(this.checkBox2);
this.groupBox2.Controls.Add(this.pictureBox2);
resources.ApplyResources(this.groupBox2, "groupBox2");
this.groupBox2.ForeColor = System.Drawing.Color.Black;
this.groupBox2.Name = "groupBox2";
this.groupBox2.TabStop = false;
//
// checkBox2
//
resources.ApplyResources(this.checkBox2, "checkBox2");
this.checkBox2.Name = "checkBox2";
this.checkBox2.UseVisualStyleBackColor = true;
//
// pictureBox2
//
resources.ApplyResources(this.pictureBox2, "pictureBox2");
this.pictureBox2.Name = "pictureBox2";
this.pictureBox2.TabStop = false;
//
// groupBox3
//
this.groupBox3.Controls.Add(this.checkBox3);
this.groupBox3.Controls.Add(this.pictureBox3);
resources.ApplyResources(this.groupBox3, "groupBox3");
this.groupBox3.ForeColor = System.Drawing.Color.Black;
this.groupBox3.Name = "groupBox3";
this.groupBox3.TabStop = false;
//
// checkBox3
//
resources.ApplyResources(this.checkBox3, "checkBox3");
this.checkBox3.Name = "checkBox3";
this.checkBox3.UseVisualStyleBackColor = true;
//
// pictureBox3
//
resources.ApplyResources(this.pictureBox3, "pictureBox3");
this.pictureBox3.Name = "pictureBox3";
this.pictureBox3.TabStop = false;
//
// groupBox4
//
this.groupBox4.Controls.Add(this.checkBox4);
this.groupBox4.Controls.Add(this.pictureBox4);
resources.ApplyResources(this.groupBox4, "groupBox4");
this.groupBox4.ForeColor = System.Drawing.Color.Black;
this.groupBox4.Name = "groupBox4";
this.groupBox4.TabStop = false;
//
// checkBox4
//
resources.ApplyResources(this.checkBox4, "checkBox4");
this.checkBox4.Name = "checkBox4";
this.checkBox4.UseVisualStyleBackColor = true;
//
// pictureBox4
//
resources.ApplyResources(this.pictureBox4, "pictureBox4");
this.pictureBox4.Name = "pictureBox4";
this.pictureBox4.TabStop = false;
//
// retryButton
//
resources.ApplyResources(this.retryButton, "retryButton");
this.retryButton.ForeColor = System.Drawing.Color.Black;
this.retryButton.Name = "retryButton";
this.retryButton.UseVisualStyleBackColor = true;
this.retryButton.Click += new System.EventHandler(this.retryButton_Click);
//
// abortButton
//
resources.ApplyResources(this.abortButton, "abortButton");
this.abortButton.ForeColor = System.Drawing.Color.Black;
this.abortButton.Name = "abortButton";
this.abortButton.UseVisualStyleBackColor = true;
this.abortButton.Click += new System.EventHandler(this.abortButton_Click);
//
// groupBox5
//
this.groupBox5.Controls.Add(this.checkBox5);
this.groupBox5.Controls.Add(this.pictureBox5);
resources.ApplyResources(this.groupBox5, "groupBox5");
this.groupBox5.ForeColor = System.Drawing.Color.Black;
this.groupBox5.Name = "groupBox5";
this.groupBox5.TabStop = false;
//
// checkBox5
//
resources.ApplyResources(this.checkBox5, "checkBox5");
this.checkBox5.Name = "checkBox5";
this.checkBox5.UseVisualStyleBackColor = true;
//
// pictureBox5
//
resources.ApplyResources(this.pictureBox5, "pictureBox5");
this.pictureBox5.Name = "pictureBox5";
this.pictureBox5.TabStop = false;
//
// groupBox6
//
this.groupBox6.Controls.Add(this.checkBox6);
this.groupBox6.Controls.Add(this.pictureBox6);
resources.ApplyResources(this.groupBox6, "groupBox6");
this.groupBox6.ForeColor = System.Drawing.Color.Black;
this.groupBox6.Name = "groupBox6";
this.groupBox6.TabStop = false;
//
// checkBox6
//
resources.ApplyResources(this.checkBox6, "checkBox6");
this.checkBox6.Name = "checkBox6";
this.checkBox6.UseVisualStyleBackColor = true;
//
// pictureBox6
//
resources.ApplyResources(this.pictureBox6, "pictureBox6");
this.pictureBox6.Name = "pictureBox6";
this.pictureBox6.TabStop = false;
//
// DisplayForm
//
resources.ApplyResources(this, "$this");
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.DarkGray;
this.Controls.Add(this.groupBox6);
this.Controls.Add(this.groupBox5);
this.Controls.Add(this.abortButton);
this.Controls.Add(this.retryButton);
this.Controls.Add(this.groupBox4);
this.Controls.Add(this.groupBox3);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.okButton);
this.ForeColor = System.Drawing.Color.Black;
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.Name = "DisplayForm";
this.TopMost = true;
this.Load += new System.EventHandler(this.CycleBeginningForm_Load);
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit();
this.groupBox3.ResumeLayout(false);
this.groupBox3.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox3)).EndInit();
this.groupBox4.ResumeLayout(false);
this.groupBox4.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox4)).EndInit();
this.groupBox5.ResumeLayout(false);
this.groupBox5.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox5)).EndInit();
this.groupBox6.ResumeLayout(false);
this.groupBox6.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox6)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Button okButton;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.GroupBox groupBox3;
private System.Windows.Forms.GroupBox groupBox4;
private System.Windows.Forms.Button retryButton;
private System.Windows.Forms.Button abortButton;
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.PictureBox pictureBox2;
private System.Windows.Forms.PictureBox pictureBox3;
private System.Windows.Forms.PictureBox pictureBox4;
private System.Windows.Forms.GroupBox groupBox5;
private System.Windows.Forms.PictureBox pictureBox5;
private System.Windows.Forms.GroupBox groupBox6;
private System.Windows.Forms.PictureBox pictureBox6;
private System.Windows.Forms.CheckBox checkBox1;
private System.Windows.Forms.CheckBox checkBox2;
private System.Windows.Forms.CheckBox checkBox3;
private System.Windows.Forms.CheckBox checkBox4;
private System.Windows.Forms.CheckBox checkBox5;
private System.Windows.Forms.CheckBox checkBox6;
}
}
@@ -0,0 +1,807 @@
<?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>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="okButton.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Right</value>
</data>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="okButton.Font" type="System.Drawing.Font, System.Drawing">
<value>Verdana, 14.25pt</value>
</data>
<data name="okButton.Location" type="System.Drawing.Point, System.Drawing">
<value>1072, 19</value>
</data>
<data name="okButton.Size" type="System.Drawing.Size, System.Drawing">
<value>146, 58</value>
</data>
<assembly alias="mscorlib" name="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="okButton.TabIndex" type="System.Int32, mscorlib">
<value>7</value>
</data>
<data name="okButton.Text" xml:space="preserve">
<value>OK</value>
</data>
<data name="&gt;&gt;okButton.Name" xml:space="preserve">
<value>okButton</value>
</data>
<data name="&gt;&gt;okButton.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;okButton.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;okButton.ZOrder" xml:space="preserve">
<value>8</value>
</data>
<data name="checkBox1.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Right</value>
</data>
<data name="checkBox1.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="checkBox1.CheckAlign" type="System.Drawing.ContentAlignment, System.Drawing">
<value>MiddleRight</value>
</data>
<data name="checkBox1.Font" type="System.Drawing.Font, System.Drawing">
<value>Verdana, 12pt</value>
</data>
<data name="checkBox1.Location" type="System.Drawing.Point, System.Drawing">
<value>257, 19</value>
</data>
<data name="checkBox1.Size" type="System.Drawing.Size, System.Drawing">
<value>70, 22</value>
</data>
<data name="checkBox1.TabIndex" type="System.Int32, mscorlib">
<value>1</value>
</data>
<data name="checkBox1.Text" xml:space="preserve">
<value>Retry</value>
</data>
<data name="checkBox1.TextAlign" type="System.Drawing.ContentAlignment, System.Drawing">
<value>MiddleRight</value>
</data>
<data name="&gt;&gt;checkBox1.Name" xml:space="preserve">
<value>checkBox1</value>
</data>
<data name="&gt;&gt;checkBox1.Type" xml:space="preserve">
<value>System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;checkBox1.Parent" xml:space="preserve">
<value>groupBox1</value>
</data>
<data name="&gt;&gt;checkBox1.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<data name="pictureBox1.Location" type="System.Drawing.Point, System.Drawing">
<value>7, 45</value>
</data>
<data name="pictureBox1.Size" type="System.Drawing.Size, System.Drawing">
<value>320, 240</value>
</data>
<data name="pictureBox1.SizeMode" type="System.Windows.Forms.PictureBoxSizeMode, System.Windows.Forms">
<value>StretchImage</value>
</data>
<data name="pictureBox1.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
</data>
<data name="&gt;&gt;pictureBox1.Name" xml:space="preserve">
<value>pictureBox1</value>
</data>
<data name="&gt;&gt;pictureBox1.Type" xml:space="preserve">
<value>System.Windows.Forms.PictureBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;pictureBox1.Parent" xml:space="preserve">
<value>groupBox1</value>
</data>
<data name="&gt;&gt;pictureBox1.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<data name="groupBox1.Font" type="System.Drawing.Font, System.Drawing">
<value>Verdana, 14.25pt</value>
</data>
<data name="groupBox1.Location" type="System.Drawing.Point, System.Drawing">
<value>15, 8</value>
</data>
<data name="groupBox1.Size" type="System.Drawing.Size, System.Drawing">
<value>335, 293</value>
</data>
<data name="groupBox1.TabIndex" type="System.Int32, mscorlib">
<value>1</value>
</data>
<data name="groupBox1.Text" xml:space="preserve">
<value>Watermeter 1</value>
</data>
<data name="&gt;&gt;groupBox1.Name" xml:space="preserve">
<value>groupBox1</value>
</data>
<data name="&gt;&gt;groupBox1.Type" xml:space="preserve">
<value>System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;groupBox1.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;groupBox1.ZOrder" xml:space="preserve">
<value>7</value>
</data>
<data name="checkBox2.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Right</value>
</data>
<data name="checkBox2.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="checkBox2.CheckAlign" type="System.Drawing.ContentAlignment, System.Drawing">
<value>MiddleRight</value>
</data>
<data name="checkBox2.Font" type="System.Drawing.Font, System.Drawing">
<value>Verdana, 12pt</value>
</data>
<data name="checkBox2.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="checkBox2.Location" type="System.Drawing.Point, System.Drawing">
<value>257, 19</value>
</data>
<data name="checkBox2.Size" type="System.Drawing.Size, System.Drawing">
<value>70, 22</value>
</data>
<data name="checkBox2.TabIndex" type="System.Int32, mscorlib">
<value>2</value>
</data>
<data name="checkBox2.Text" xml:space="preserve">
<value>Retry</value>
</data>
<data name="checkBox2.TextAlign" type="System.Drawing.ContentAlignment, System.Drawing">
<value>MiddleRight</value>
</data>
<data name="&gt;&gt;checkBox2.Name" xml:space="preserve">
<value>checkBox2</value>
</data>
<data name="&gt;&gt;checkBox2.Type" xml:space="preserve">
<value>System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;checkBox2.Parent" xml:space="preserve">
<value>groupBox2</value>
</data>
<data name="&gt;&gt;checkBox2.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<data name="pictureBox2.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="pictureBox2.Location" type="System.Drawing.Point, System.Drawing">
<value>7, 45</value>
</data>
<data name="pictureBox2.Size" type="System.Drawing.Size, System.Drawing">
<value>320, 240</value>
</data>
<data name="pictureBox2.SizeMode" type="System.Windows.Forms.PictureBoxSizeMode, System.Windows.Forms">
<value>StretchImage</value>
</data>
<data name="pictureBox2.TabIndex" type="System.Int32, mscorlib">
<value>1</value>
</data>
<data name="&gt;&gt;pictureBox2.Name" xml:space="preserve">
<value>pictureBox2</value>
</data>
<data name="&gt;&gt;pictureBox2.Type" xml:space="preserve">
<value>System.Windows.Forms.PictureBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;pictureBox2.Parent" xml:space="preserve">
<value>groupBox2</value>
</data>
<data name="&gt;&gt;pictureBox2.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<data name="groupBox2.Font" type="System.Drawing.Font, System.Drawing">
<value>Verdana, 14.25pt</value>
</data>
<data name="groupBox2.Location" type="System.Drawing.Point, System.Drawing">
<value>365, 8</value>
</data>
<data name="groupBox2.Size" type="System.Drawing.Size, System.Drawing">
<value>335, 293</value>
</data>
<data name="groupBox2.TabIndex" type="System.Int32, mscorlib">
<value>2</value>
</data>
<data name="groupBox2.Text" xml:space="preserve">
<value>Watermeter 2</value>
</data>
<data name="&gt;&gt;groupBox2.Name" xml:space="preserve">
<value>groupBox2</value>
</data>
<data name="&gt;&gt;groupBox2.Type" xml:space="preserve">
<value>System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;groupBox2.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;groupBox2.ZOrder" xml:space="preserve">
<value>6</value>
</data>
<data name="checkBox3.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Right</value>
</data>
<data name="checkBox3.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="checkBox3.CheckAlign" type="System.Drawing.ContentAlignment, System.Drawing">
<value>MiddleRight</value>
</data>
<data name="checkBox3.Font" type="System.Drawing.Font, System.Drawing">
<value>Verdana, 12pt</value>
</data>
<data name="checkBox3.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="checkBox3.Location" type="System.Drawing.Point, System.Drawing">
<value>257, 19</value>
</data>
<data name="checkBox3.Size" type="System.Drawing.Size, System.Drawing">
<value>70, 22</value>
</data>
<data name="checkBox3.TabIndex" type="System.Int32, mscorlib">
<value>4</value>
</data>
<data name="checkBox3.Text" xml:space="preserve">
<value>Retry</value>
</data>
<data name="checkBox3.TextAlign" type="System.Drawing.ContentAlignment, System.Drawing">
<value>MiddleRight</value>
</data>
<data name="&gt;&gt;checkBox3.Name" xml:space="preserve">
<value>checkBox3</value>
</data>
<data name="&gt;&gt;checkBox3.Type" xml:space="preserve">
<value>System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;checkBox3.Parent" xml:space="preserve">
<value>groupBox3</value>
</data>
<data name="&gt;&gt;checkBox3.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<data name="pictureBox3.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="pictureBox3.Location" type="System.Drawing.Point, System.Drawing">
<value>7, 45</value>
</data>
<data name="pictureBox3.Size" type="System.Drawing.Size, System.Drawing">
<value>320, 240</value>
</data>
<data name="pictureBox3.SizeMode" type="System.Windows.Forms.PictureBoxSizeMode, System.Windows.Forms">
<value>StretchImage</value>
</data>
<data name="pictureBox3.TabIndex" type="System.Int32, mscorlib">
<value>3</value>
</data>
<data name="&gt;&gt;pictureBox3.Name" xml:space="preserve">
<value>pictureBox3</value>
</data>
<data name="&gt;&gt;pictureBox3.Type" xml:space="preserve">
<value>System.Windows.Forms.PictureBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;pictureBox3.Parent" xml:space="preserve">
<value>groupBox3</value>
</data>
<data name="&gt;&gt;pictureBox3.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<data name="groupBox3.Font" type="System.Drawing.Font, System.Drawing">
<value>Verdana, 14.25pt</value>
</data>
<data name="groupBox3.Location" type="System.Drawing.Point, System.Drawing">
<value>717, 8</value>
</data>
<data name="groupBox3.Size" type="System.Drawing.Size, System.Drawing">
<value>335, 293</value>
</data>
<data name="groupBox3.TabIndex" type="System.Int32, mscorlib">
<value>3</value>
</data>
<data name="groupBox3.Text" xml:space="preserve">
<value>Watermeter 3</value>
</data>
<data name="&gt;&gt;groupBox3.Name" xml:space="preserve">
<value>groupBox3</value>
</data>
<data name="&gt;&gt;groupBox3.Type" xml:space="preserve">
<value>System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;groupBox3.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;groupBox3.ZOrder" xml:space="preserve">
<value>5</value>
</data>
<data name="checkBox4.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Right</value>
</data>
<data name="checkBox4.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="checkBox4.CheckAlign" type="System.Drawing.ContentAlignment, System.Drawing">
<value>MiddleRight</value>
</data>
<data name="checkBox4.Font" type="System.Drawing.Font, System.Drawing">
<value>Verdana, 12pt</value>
</data>
<data name="checkBox4.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="checkBox4.Location" type="System.Drawing.Point, System.Drawing">
<value>257, 19</value>
</data>
<data name="checkBox4.Size" type="System.Drawing.Size, System.Drawing">
<value>70, 22</value>
</data>
<data name="checkBox4.TabIndex" type="System.Int32, mscorlib">
<value>3</value>
</data>
<data name="checkBox4.Text" xml:space="preserve">
<value>Retry</value>
</data>
<data name="checkBox4.TextAlign" type="System.Drawing.ContentAlignment, System.Drawing">
<value>MiddleRight</value>
</data>
<data name="&gt;&gt;checkBox4.Name" xml:space="preserve">
<value>checkBox4</value>
</data>
<data name="&gt;&gt;checkBox4.Type" xml:space="preserve">
<value>System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;checkBox4.Parent" xml:space="preserve">
<value>groupBox4</value>
</data>
<data name="&gt;&gt;checkBox4.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<data name="pictureBox4.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="pictureBox4.Location" type="System.Drawing.Point, System.Drawing">
<value>7, 45</value>
</data>
<data name="pictureBox4.Size" type="System.Drawing.Size, System.Drawing">
<value>320, 240</value>
</data>
<data name="pictureBox4.SizeMode" type="System.Windows.Forms.PictureBoxSizeMode, System.Windows.Forms">
<value>StretchImage</value>
</data>
<data name="pictureBox4.TabIndex" type="System.Int32, mscorlib">
<value>1</value>
</data>
<data name="&gt;&gt;pictureBox4.Name" xml:space="preserve">
<value>pictureBox4</value>
</data>
<data name="&gt;&gt;pictureBox4.Type" xml:space="preserve">
<value>System.Windows.Forms.PictureBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;pictureBox4.Parent" xml:space="preserve">
<value>groupBox4</value>
</data>
<data name="&gt;&gt;pictureBox4.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<data name="groupBox4.Font" type="System.Drawing.Font, System.Drawing">
<value>Verdana, 14.25pt</value>
</data>
<data name="groupBox4.Location" type="System.Drawing.Point, System.Drawing">
<value>15, 306</value>
</data>
<data name="groupBox4.Size" type="System.Drawing.Size, System.Drawing">
<value>335, 293</value>
</data>
<data name="groupBox4.TabIndex" type="System.Int32, mscorlib">
<value>4</value>
</data>
<data name="groupBox4.Text" xml:space="preserve">
<value>Watermeter 4</value>
</data>
<data name="&gt;&gt;groupBox4.Name" xml:space="preserve">
<value>groupBox4</value>
</data>
<data name="&gt;&gt;groupBox4.Type" xml:space="preserve">
<value>System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;groupBox4.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;groupBox4.ZOrder" xml:space="preserve">
<value>4</value>
</data>
<data name="retryButton.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Right</value>
</data>
<data name="retryButton.Font" type="System.Drawing.Font, System.Drawing">
<value>Verdana, 14.25pt</value>
</data>
<data name="retryButton.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="retryButton.Location" type="System.Drawing.Point, System.Drawing">
<value>1072, 96</value>
</data>
<data name="retryButton.Size" type="System.Drawing.Size, System.Drawing">
<value>146, 58</value>
</data>
<data name="retryButton.TabIndex" type="System.Int32, mscorlib">
<value>8</value>
</data>
<data name="retryButton.Text" xml:space="preserve">
<value>Retry</value>
</data>
<data name="&gt;&gt;retryButton.Name" xml:space="preserve">
<value>retryButton</value>
</data>
<data name="&gt;&gt;retryButton.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;retryButton.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;retryButton.ZOrder" xml:space="preserve">
<value>3</value>
</data>
<data name="abortButton.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Right</value>
</data>
<data name="abortButton.Font" type="System.Drawing.Font, System.Drawing">
<value>Verdana, 14.25pt</value>
</data>
<data name="abortButton.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="abortButton.Location" type="System.Drawing.Point, System.Drawing">
<value>1072, 173</value>
</data>
<data name="abortButton.Size" type="System.Drawing.Size, System.Drawing">
<value>146, 58</value>
</data>
<data name="abortButton.TabIndex" type="System.Int32, mscorlib">
<value>9</value>
</data>
<data name="abortButton.Text" xml:space="preserve">
<value>Abort</value>
</data>
<data name="&gt;&gt;abortButton.Name" xml:space="preserve">
<value>abortButton</value>
</data>
<data name="&gt;&gt;abortButton.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;abortButton.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;abortButton.ZOrder" xml:space="preserve">
<value>2</value>
</data>
<data name="checkBox5.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Right</value>
</data>
<data name="checkBox5.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="checkBox5.CheckAlign" type="System.Drawing.ContentAlignment, System.Drawing">
<value>MiddleRight</value>
</data>
<data name="checkBox5.Font" type="System.Drawing.Font, System.Drawing">
<value>Verdana, 12pt</value>
</data>
<data name="checkBox5.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="checkBox5.Location" type="System.Drawing.Point, System.Drawing">
<value>257, 19</value>
</data>
<data name="checkBox5.Size" type="System.Drawing.Size, System.Drawing">
<value>70, 22</value>
</data>
<data name="checkBox5.TabIndex" type="System.Int32, mscorlib">
<value>3</value>
</data>
<data name="checkBox5.Text" xml:space="preserve">
<value>Retry</value>
</data>
<data name="checkBox5.TextAlign" type="System.Drawing.ContentAlignment, System.Drawing">
<value>MiddleRight</value>
</data>
<data name="&gt;&gt;checkBox5.Name" xml:space="preserve">
<value>checkBox5</value>
</data>
<data name="&gt;&gt;checkBox5.Type" xml:space="preserve">
<value>System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;checkBox5.Parent" xml:space="preserve">
<value>groupBox5</value>
</data>
<data name="&gt;&gt;checkBox5.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<data name="pictureBox5.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="pictureBox5.Location" type="System.Drawing.Point, System.Drawing">
<value>7, 45</value>
</data>
<data name="pictureBox5.Size" type="System.Drawing.Size, System.Drawing">
<value>320, 240</value>
</data>
<data name="pictureBox5.SizeMode" type="System.Windows.Forms.PictureBoxSizeMode, System.Windows.Forms">
<value>StretchImage</value>
</data>
<data name="pictureBox5.TabIndex" type="System.Int32, mscorlib">
<value>1</value>
</data>
<data name="&gt;&gt;pictureBox5.Name" xml:space="preserve">
<value>pictureBox5</value>
</data>
<data name="&gt;&gt;pictureBox5.Type" xml:space="preserve">
<value>System.Windows.Forms.PictureBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;pictureBox5.Parent" xml:space="preserve">
<value>groupBox5</value>
</data>
<data name="&gt;&gt;pictureBox5.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<data name="groupBox5.Font" type="System.Drawing.Font, System.Drawing">
<value>Verdana, 14.25pt</value>
</data>
<data name="groupBox5.Location" type="System.Drawing.Point, System.Drawing">
<value>365, 306</value>
</data>
<data name="groupBox5.Size" type="System.Drawing.Size, System.Drawing">
<value>335, 293</value>
</data>
<data name="groupBox5.TabIndex" type="System.Int32, mscorlib">
<value>10</value>
</data>
<data name="groupBox5.Text" xml:space="preserve">
<value>Watermeter 5</value>
</data>
<data name="&gt;&gt;groupBox5.Name" xml:space="preserve">
<value>groupBox5</value>
</data>
<data name="&gt;&gt;groupBox5.Type" xml:space="preserve">
<value>System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;groupBox5.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;groupBox5.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<data name="checkBox6.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Right</value>
</data>
<data name="checkBox6.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="checkBox6.CheckAlign" type="System.Drawing.ContentAlignment, System.Drawing">
<value>MiddleRight</value>
</data>
<data name="checkBox6.Font" type="System.Drawing.Font, System.Drawing">
<value>Verdana, 12pt</value>
</data>
<data name="checkBox6.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="checkBox6.Location" type="System.Drawing.Point, System.Drawing">
<value>257, 19</value>
</data>
<data name="checkBox6.Size" type="System.Drawing.Size, System.Drawing">
<value>70, 22</value>
</data>
<data name="checkBox6.TabIndex" type="System.Int32, mscorlib">
<value>3</value>
</data>
<data name="checkBox6.Text" xml:space="preserve">
<value>Retry</value>
</data>
<data name="checkBox6.TextAlign" type="System.Drawing.ContentAlignment, System.Drawing">
<value>MiddleRight</value>
</data>
<data name="&gt;&gt;checkBox6.Name" xml:space="preserve">
<value>checkBox6</value>
</data>
<data name="&gt;&gt;checkBox6.Type" xml:space="preserve">
<value>System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;checkBox6.Parent" xml:space="preserve">
<value>groupBox6</value>
</data>
<data name="&gt;&gt;checkBox6.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<data name="pictureBox6.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="pictureBox6.Location" type="System.Drawing.Point, System.Drawing">
<value>7, 45</value>
</data>
<data name="pictureBox6.Size" type="System.Drawing.Size, System.Drawing">
<value>320, 240</value>
</data>
<data name="pictureBox6.SizeMode" type="System.Windows.Forms.PictureBoxSizeMode, System.Windows.Forms">
<value>StretchImage</value>
</data>
<data name="pictureBox6.TabIndex" type="System.Int32, mscorlib">
<value>1</value>
</data>
<data name="&gt;&gt;pictureBox6.Name" xml:space="preserve">
<value>pictureBox6</value>
</data>
<data name="&gt;&gt;pictureBox6.Type" xml:space="preserve">
<value>System.Windows.Forms.PictureBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;pictureBox6.Parent" xml:space="preserve">
<value>groupBox6</value>
</data>
<data name="&gt;&gt;pictureBox6.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<data name="groupBox6.Font" type="System.Drawing.Font, System.Drawing">
<value>Verdana, 14.25pt</value>
</data>
<data name="groupBox6.Location" type="System.Drawing.Point, System.Drawing">
<value>717, 306</value>
</data>
<data name="groupBox6.Size" type="System.Drawing.Size, System.Drawing">
<value>335, 293</value>
</data>
<data name="groupBox6.TabIndex" type="System.Int32, mscorlib">
<value>11</value>
</data>
<data name="groupBox6.Text" xml:space="preserve">
<value>Watermeter 6</value>
</data>
<data name="&gt;&gt;groupBox6.Name" xml:space="preserve">
<value>groupBox6</value>
</data>
<data name="&gt;&gt;groupBox6.Type" xml:space="preserve">
<value>System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;groupBox6.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;groupBox6.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<data name="$this.AutoScaleDimensions" type="System.Drawing.SizeF, System.Drawing">
<value>6, 13</value>
</data>
<data name="$this.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="$this.ClientSize" type="System.Drawing.Size, System.Drawing">
<value>1237, 613</value>
</data>
<data name="&gt;&gt;$this.Name" xml:space="preserve">
<value>DisplayForm</value>
</data>
<data name="&gt;&gt;$this.Type" xml:space="preserve">
<value>System.Windows.Forms.Form, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
</root>
@@ -0,0 +1,26 @@
///
/// Copyright (c) 2017 Sensus Metering Systems
///
using System.Collections.Generic;
using TBF.BenchControl.Generic;
namespace TBF.BenchControl.Network.Camera.Display
{
public class Factory : IComponentFactory
{
public string ClassName { get { return this.GetType().Namespace.Substring(17); } }
public void ResetStaticProperties() { Display.ResetStaticProperties(); }
public IComponent DummyComponent() { return new Display(); }
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new Display(cfg, components); }
public IComponentCfg DefaultConfig() { return new DisplayCfg(this.GetType().Namespace.Substring(17), this); }
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
{
return ComponentCfgBase.CreateFromDbEntity(typeof(DisplayCfg), component, this);
}
}
}
@@ -14,15 +14,27 @@ namespace TBF.BenchControl.Network.Camera.Roi
public class ProcedureParams : ProcedureParamsBase, IParamsProvider, IProcedureParams
{
public float PulsesPerLtr; /// [l^-1]
public int DetectionImagesCount;
public int DetectionPeriod1;
public int DetectionPeriod2;
public string RoiParams;
public override void InitializeAll()
{
PulsesPerLtr = 1.0f;
DetectionImagesCount = 10;
DetectionPeriod1 = 1;
DetectionPeriod2 = 19;
RoiParams = "160 160 79 79 20 79 0 0 360 360 1 50 0 0 50 0";
}
string[] paramNames = new string[]
{
Strings.PulsesPerLtr,
"Images count",
"Period1",
"Period2",
"Parameters"
};
public override string ParamName(int i) { return paramNames[i]; }
public override int ParamsCount() { return paramNames.Length; }
@@ -32,6 +44,10 @@ namespace TBF.BenchControl.Network.Camera.Roi
switch (i)
{
case 0: return PulsesPerLtr.ToString();
case 1: return DetectionImagesCount.ToString();
case 2: return DetectionPeriod1.ToString();
case 3: return DetectionPeriod2.ToString();
case 4: return RoiParams;
default: return string.Empty;
}
}
@@ -42,6 +58,10 @@ namespace TBF.BenchControl.Network.Camera.Roi
switch (i)
{
case 0: PulsesPerLtr = Utils.ParseUFloat(strValue); return;
case 1: DetectionImagesCount = int.Parse(strValue); return;
case 2: DetectionPeriod1 = int.Parse(strValue); return;
case 3: DetectionPeriod2 = int.Parse(strValue); return;
case 4: RoiParams = strValue; return;
default: return;
}
}
@@ -52,11 +72,19 @@ namespace TBF.BenchControl.Network.Camera.Roi
message = string.Empty;
float dummy;
int idummy;
switch (i)
{
case 0:
if (Utils.TryParseUFloat(strValue, out dummy)) return true;
break;
case 1:
case 2:
case 3:
if (int.TryParse(strValue, out idummy) && idummy >= 1 && idummy <= 50) return true;
break;
case 4:
return true;
default:
message = "Invalid index";
return false;
@@ -69,6 +97,10 @@ namespace TBF.BenchControl.Network.Camera.Roi
void CopyContentTo(ProcedureParams prms)
{
prms.PulsesPerLtr = this.PulsesPerLtr;
prms.DetectionImagesCount = this.DetectionImagesCount;
prms.DetectionPeriod1 = this.DetectionPeriod1;
prms.DetectionPeriod2 = this.DetectionPeriod2;
prms.RoiParams = this.RoiParams;
}
public IParamsProvider Clone()
@@ -35,25 +35,39 @@ namespace TBF.BenchControl.Network.Camera.Roi
public double PulsesPerLtr { get { return (double)RoiCfg.ProcParams.PulsesPerLtr; } }
public double LtrsPerPulse { get { return (PulsesPerLtr <= float.Epsilon) ? 1.0 : (1 / PulsesPerLtr); ; } }
int wmPulses;
public int WMPulses { get { return wmPulses; } }
int cameraPulses;
int pulsesDelta; /// = (WMPulses - cameraPulses) ... WMPulses = cameraPulses + pulsesDelta, Clear() calculates pulsesDelta
public int WMPulses { get { return cameraPulses + pulsesDelta; } }
long cameraTime;
long timeDelta; /// = (WMTestTime - cameraTime) ... WMTestTime = cameraTime + timeDelta, Clear() calculates timeDelta
public double WMTestTime { get { return (cameraTime + timeDelta) / 1000.0; } }
int wmRefPulses;
public int WMRefPulses { get { return wmRefPulses; } }
public double WMVolume { get { return LtrsPerPulse * (double)wmPulses; } }
public double WMVolume { get { return LtrsPerPulse * (double)WMPulses; } }
public double BeginWMState { get { return 0; } } /// Always 0
public double EndWMState { get { return WMVolume; } } /// Derived from WMVolume
public double BeginWMState { get { return 0; } } /// Always 0
public double EndWMState { get { return WMVolume; } } /// Derived from WMVolume
double volumeStart;
public double VolumeStart { get { return volumeStart; } } /// in l
double volumeEnd;
public double VolumeEnd { get { return volumeEnd; } } /// in l
double timestampStart;
public double TimestampStart { get { return timestampStart; } } /// in s
double timestampEnd;
public double TimestampEnd { get { return timestampEnd; } } /// in s
///
/// Roi specific
///
public bool Detected
{
get { return detected; }
set { detected = value; }
}
public bool Detected { get { return detected; } }
bool detected;
///
public Boxes.IntBox RoiX;
@@ -61,6 +75,23 @@ namespace TBF.BenchControl.Network.Camera.Roi
public Boxes.IntBox RoiWid;
public Boxes.IntBox RoiHgh;
///
public void ClearRoi()
{
detected = false;
}
///
public void SetRoi(int x, int y, int wid, int hgh)
{
RoiX.Val = x;
RoiY.Val = y;
RoiWid.Val = wid;
RoiHgh.Val = hgh;
detected = true;
}
///
public string DetectedImageName { get { return detectedImageName; } }
string detectedImageName;
///
private int roiHandle;
///
public void RegisterRoiToCamera()
@@ -115,11 +146,8 @@ namespace TBF.BenchControl.Network.Camera.Roi
{
if (args.Command == CfgChangeCmd.CfgChange)
{
RoiCfg.RoiParams = tmpcfg.RoiParams;
RoiCfg.UseTestImages = tmpcfg.UseTestImages;
RoiCfg.DetectionImagesCount = tmpcfg.DetectionImagesCount;
RoiCfg.DetectionPeriod1 = tmpcfg.DetectionPeriod1;
RoiCfg.DetectionPeriod2 = tmpcfg.DetectionPeriod2;
RoiCfg.LoadImages = tmpcfg.LoadImages;
RoiCfg.SaveImages = tmpcfg.SaveImages;
}
}
};
@@ -129,7 +157,8 @@ namespace TBF.BenchControl.Network.Camera.Roi
public void Clear()
{
wmPulses = 0;
pulsesDelta = -cameraPulses;
timeDelta = -cameraTime;
wmRefPulses = 0;
}
@@ -140,8 +169,9 @@ namespace TBF.BenchControl.Network.Camera.Roi
{
if (NetCamera != null && NetCamera.Telnet != null)
{
Telnet = NetCamera.Telnet;
return new RoiDetectionOp(this, RoiX, RoiY, RoiWid, RoiHgh);
Telnet = NetCamera.Telnet;
detectedImageName = string.Format("{0}{1}-det-{2}.jpg", Program.ImagesDir, RoiCfg.Name, StateMachine.Time);
return new RoiDetectionOp(this, RoiX, RoiY, RoiWid, RoiHgh);
}
else
{
@@ -157,7 +187,7 @@ namespace TBF.BenchControl.Network.Camera.Roi
{
if (detected && roiHandle != 0)
{
wmPulses = NetCamera.GetResult(roiHandle);
cameraPulses = NetCamera.GetResult(roiHandle, out cameraTime);
}
}
@@ -173,6 +203,9 @@ namespace TBF.BenchControl.Network.Camera.Roi
public void Start()
{
UdatePulses();
Clear();
volumeStart = WMVolume;
timestampStart = WMTestTime;
}
/// <summary>Run this operation</summary>
@@ -180,6 +213,8 @@ namespace TBF.BenchControl.Network.Camera.Roi
public Event Run()
{
UdatePulses();
volumeEnd = WMVolume;
timestampEnd = WMTestTime;
return Event.ReadRegisterDone;
}
@@ -15,11 +15,8 @@ namespace TBF.BenchControl.Network.Camera.Roi
/// Serialized parameters
///
public string PreviousRoi;
public string RoiParams;
public int DetectionImagesCount;
public int DetectionPeriod1;
public int DetectionPeriod2;
public bool UseTestImages;
public bool LoadImages;
public bool SaveImages;
/// <summary> Procedure parameters </summary>
[XmlIgnore]
@@ -32,6 +29,12 @@ namespace TBF.BenchControl.Network.Camera.Roi
return procParams;
}
public int DetectionImagesCount { get { return ProcParams.DetectionImagesCount; } }
public int DetectionPeriod1 { get { return ProcParams.DetectionPeriod1; } }
public int DetectionPeriod2 { get { return ProcParams.DetectionPeriod2; } }
public string RoiParams { get { return ProcParams.RoiParams; } }
/// Private parameterless constructor invoked by all other (public) constructors
RoiCfg()
{
@@ -44,15 +47,11 @@ namespace TBF.BenchControl.Network.Camera.Roi
Name = name;
Factory = factory;
ParentName = "Camera";
RoiParams = string.Empty;
DetectionImagesCount = 15;
DetectionPeriod1 = 1;
DetectionPeriod2 = 1;
}
public string ToString(int i)
{
return string.Format("Name={0}, Parent={1}, Params={2}", Name, ParentName, RoiParams);
return string.Format("{0} ({1}) {2}", Name, ParentName, (LoadImages ? " load images" : (SaveImages ? " save images" : "")));
}
}
}
@@ -68,11 +68,8 @@ namespace TBF.BenchControl.Network.Camera.Roi
nameTextBox.Text = config.Name;
parentNameComboBox.Text = string.IsNullOrEmpty(config.ParentName) ? "---" : config.ParentName;
previousRoiComboBox.Text = string.IsNullOrEmpty(config.PreviousRoi) ? "---" : config.PreviousRoi;
argsTextBox.Text = config.RoiParams;
useTestImagesCheckBox.Checked = config.UseTestImages;
imagesCountTextBox.Text = config.DetectionImagesCount.ToString();
period1TextBox.Text = config.DetectionPeriod1.ToString();
period2TextBox.Text = config.DetectionPeriod2.ToString();
loadImagesCheckBox.Checked = config.LoadImages;
saveImagesCheckBox.Checked = config.SaveImages;
}
public void Unlock()
@@ -80,75 +77,8 @@ namespace TBF.BenchControl.Network.Camera.Roi
nameTextBox.Enabled = true;
parentNameComboBox.Enabled = true;
previousRoiComboBox.Enabled = true;
argsTextBox.Enabled = true;
useTestImagesCheckBox.Enabled = true;
imagesCountTextBox.Enabled = true;
period1TextBox.Enabled = true;
period2TextBox.Enabled = true;
}
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);
}
string newPreviousRoi = previousRoiComboBox.Text.Equals("---") ? string.Empty : previousRoiComboBox.Text;
if (config.PreviousRoi != newPreviousRoi)
{
config.PreviousRoi = newPreviousRoi;
flags |= (CfgUpdateFlags.RestartRqrd | CfgUpdateFlags.AnyChange);
}
if (config.RoiParams != argsTextBox.Text)
{
config.RoiParams = argsTextBox.Text;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
if (config.UseTestImages != useTestImagesCheckBox.Checked)
{
config.UseTestImages = useTestImagesCheckBox.Checked;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
if (config.DetectionImagesCount != int.Parse(imagesCountTextBox.Text))
{
config.DetectionImagesCount = int.Parse(imagesCountTextBox.Text);
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
if (config.DetectionPeriod1 != int.Parse(period1TextBox.Text))
{
config.DetectionPeriod1 = int.Parse(period1TextBox.Text);
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
if (config.DetectionPeriod2 != int.Parse(period2TextBox.Text))
{
config.DetectionPeriod2 = int.Parse(period2TextBox.Text);
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
if ((flags & CfgUpdateFlags.InvokeCfgChange) != 0)
{
Roi.OnCfgChange(this, new CfgChangeArgs(CfgChangeCmd.CfgChange, config));
}
return flags;
loadImagesCheckBox.Enabled = true;
saveImagesCheckBox.Enabled = true;
}
public CfgUpdateFlags VerifyCfg(ref string message)
@@ -167,31 +97,56 @@ namespace TBF.BenchControl.Network.Camera.Roi
message += Environment.NewLine + "Invalid 'Previous RoI'";
}
int cnt, p1, p2;
if (!int.TryParse(imagesCountTextBox.Text, out cnt) || cnt < 1 || cnt > 50)
if (loadImagesCheckBox.Checked && saveImagesCheckBox.Checked)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'Images count' should be between 1 and 50";
message += Environment.NewLine + "Images cannot be Loaded and Saved at the same time";
}
if (!int.TryParse(period1TextBox.Text, out p1) || p1 < 1 || p1 > 50)
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)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'Period 1' should be between 1 and 50";
config.Name = nameTextBox.Text;
flags |= (CfgUpdateFlags.RestartRqrd | CfgUpdateFlags.AnyChange);
}
if (!int.TryParse(period2TextBox.Text, out p2) || p2 < 1 || p2 > 50)
string newParentName = parentNameComboBox.Text.Equals("---") ? string.Empty : parentNameComboBox.Text;
if (config.ParentName != newParentName)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'Period 2' should be between 1 and 50";
config.ParentName = newParentName;
flags |= (CfgUpdateFlags.RestartRqrd | CfgUpdateFlags.AnyChange);
}
if (p2 < p1)
string newPreviousRoi = previousRoiComboBox.Text.Equals("---") ? string.Empty : previousRoiComboBox.Text;
if (config.PreviousRoi != newPreviousRoi)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Period2 should >= Period1";
config.PreviousRoi = newPreviousRoi;
flags |= (CfgUpdateFlags.RestartRqrd | CfgUpdateFlags.AnyChange);
}
if (p2 > p1 && (cnt % 2) != 0)
if (config.LoadImages != loadImagesCheckBox.Checked)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "When Period2 > Period1, 'Images count' should be even";
config.LoadImages = loadImagesCheckBox.Checked;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
if (config.SaveImages != saveImagesCheckBox.Checked)
{
config.SaveImages = saveImagesCheckBox.Checked;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
if ((flags & CfgUpdateFlags.InvokeCfgChange) != 0)
{
Roi.OnCfgChange(this, new CfgChangeArgs(CfgChangeCmd.CfgChange, config));
}
return flags;
@@ -31,8 +31,6 @@ namespace TBF.BenchControl.Network.Camera.Roi
/// </summary>
private void InitializeComponent()
{
this.argsTextBox = new System.Windows.Forms.TextBox();
this.argsLabel = 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();
@@ -44,41 +42,17 @@ namespace TBF.BenchControl.Network.Camera.Roi
this.previousRoiLabel = new System.Windows.Forms.Label();
this.helpLabel1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.imagesCountTextBox = new System.Windows.Forms.TextBox();
this.imagesCountLabel = new System.Windows.Forms.Label();
this.useTestImagesCheckBox = new System.Windows.Forms.CheckBox();
this.period1TextBox = new System.Windows.Forms.TextBox();
this.period1Label = new System.Windows.Forms.Label();
this.period2TextBox = new System.Windows.Forms.TextBox();
this.period2Label = new System.Windows.Forms.Label();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.groupBox1.SuspendLayout();
this.loadImagesCheckBox = new System.Windows.Forms.CheckBox();
this.saveImagesCheckBox = new System.Windows.Forms.CheckBox();
this.SuspendLayout();
//
// argsTextBox
//
this.argsTextBox.Enabled = false;
this.argsTextBox.Location = new System.Drawing.Point(92, 19);
this.argsTextBox.Name = "argsTextBox";
this.argsTextBox.Size = new System.Drawing.Size(361, 20);
this.argsTextBox.TabIndex = 7;
//
// argsLabel
//
this.argsLabel.AutoSize = true;
this.argsLabel.Location = new System.Drawing.Point(6, 22);
this.argsLabel.Name = "argsLabel";
this.argsLabel.Size = new System.Drawing.Size(57, 13);
this.argsLabel.TabIndex = 6;
this.argsLabel.Text = "Arguments";
//
// parentNameLabel
//
this.parentNameLabel.AutoSize = true;
this.parentNameLabel.Location = new System.Drawing.Point(13, 60);
this.parentNameLabel.Name = "parentNameLabel";
this.parentNameLabel.Size = new System.Drawing.Size(69, 13);
this.parentNameLabel.TabIndex = 2;
this.parentNameLabel.TabIndex = 3;
this.parentNameLabel.Text = "Parent Name";
//
// nameTextBox
@@ -87,7 +61,7 @@ namespace TBF.BenchControl.Network.Camera.Roi
this.nameTextBox.Location = new System.Drawing.Point(99, 34);
this.nameTextBox.Name = "nameTextBox";
this.nameTextBox.Size = new System.Drawing.Size(174, 20);
this.nameTextBox.TabIndex = 1;
this.nameTextBox.TabIndex = 2;
//
// nameLabel
//
@@ -95,7 +69,7 @@ namespace TBF.BenchControl.Network.Camera.Roi
this.nameLabel.Location = new System.Drawing.Point(13, 37);
this.nameLabel.Name = "nameLabel";
this.nameLabel.Size = new System.Drawing.Size(35, 13);
this.nameLabel.TabIndex = 0;
this.nameLabel.TabIndex = 1;
this.nameLabel.Text = "Name";
//
// classNameLabel
@@ -114,7 +88,7 @@ namespace TBF.BenchControl.Network.Camera.Roi
this.parentNameComboBox.Location = new System.Drawing.Point(99, 57);
this.parentNameComboBox.Name = "parentNameComboBox";
this.parentNameComboBox.Size = new System.Drawing.Size(174, 21);
this.parentNameComboBox.TabIndex = 3;
this.parentNameComboBox.TabIndex = 4;
//
// label1
//
@@ -140,7 +114,7 @@ namespace TBF.BenchControl.Network.Camera.Roi
this.previousRoiComboBox.Location = new System.Drawing.Point(99, 81);
this.previousRoiComboBox.Name = "previousRoiComboBox";
this.previousRoiComboBox.Size = new System.Drawing.Size(174, 21);
this.previousRoiComboBox.TabIndex = 5;
this.previousRoiComboBox.TabIndex = 6;
//
// previousRoiLabel
//
@@ -148,117 +122,60 @@ namespace TBF.BenchControl.Network.Camera.Roi
this.previousRoiLabel.Location = new System.Drawing.Point(13, 84);
this.previousRoiLabel.Name = "previousRoiLabel";
this.previousRoiLabel.Size = new System.Drawing.Size(68, 13);
this.previousRoiLabel.TabIndex = 4;
this.previousRoiLabel.TabIndex = 5;
this.previousRoiLabel.Text = "Previous RoI";
//
// helpLabel1
//
this.helpLabel1.AutoSize = true;
this.helpLabel1.Location = new System.Drawing.Point(91, 44);
this.helpLabel1.Location = new System.Drawing.Point(38, 186);
this.helpLabel1.Name = "helpLabel1";
this.helpLabel1.Size = new System.Drawing.Size(379, 13);
this.helpLabel1.TabIndex = 8;
this.helpLabel1.TabIndex = 2;
this.helpLabel1.Text = "roiWid roiHgh cx cy innerR outerR R3 ang1 ang2 fullAngle teethCount ..." +
"";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(90, 62);
this.label2.Location = new System.Drawing.Point(68, 204);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(350, 13);
this.label2.TabIndex = 9;
this.label2.TabIndex = 3;
this.label2.Text = "... angSpeed( - ccw +cw) initSpeed minMvmt maxFwdMvmt bkgndCorr";
//
// imagesCountTextBox
// loadImagesCheckBox
//
this.imagesCountTextBox.Enabled = false;
this.imagesCountTextBox.Location = new System.Drawing.Point(92, 84);
this.imagesCountTextBox.Name = "imagesCountTextBox";
this.imagesCountTextBox.Size = new System.Drawing.Size(46, 20);
this.imagesCountTextBox.TabIndex = 19;
this.loadImagesCheckBox.AutoSize = true;
this.loadImagesCheckBox.Enabled = false;
this.loadImagesCheckBox.Location = new System.Drawing.Point(99, 117);
this.loadImagesCheckBox.Name = "loadImagesCheckBox";
this.loadImagesCheckBox.Size = new System.Drawing.Size(112, 17);
this.loadImagesCheckBox.TabIndex = 6;
this.loadImagesCheckBox.Text = "Load images (test)";
this.loadImagesCheckBox.UseVisualStyleBackColor = true;
//
// imagesCountLabel
// saveImagesCheckBox
//
this.imagesCountLabel.AutoSize = true;
this.imagesCountLabel.Location = new System.Drawing.Point(6, 87);
this.imagesCountLabel.Name = "imagesCountLabel";
this.imagesCountLabel.Size = new System.Drawing.Size(71, 13);
this.imagesCountLabel.TabIndex = 18;
this.imagesCountLabel.Text = "Images count";
//
// useTestImagesCheckBox
//
this.useTestImagesCheckBox.AutoSize = true;
this.useTestImagesCheckBox.Enabled = false;
this.useTestImagesCheckBox.Location = new System.Drawing.Point(183, 87);
this.useTestImagesCheckBox.Name = "useTestImagesCheckBox";
this.useTestImagesCheckBox.Size = new System.Drawing.Size(101, 17);
this.useTestImagesCheckBox.TabIndex = 17;
this.useTestImagesCheckBox.Text = "Use test images";
this.useTestImagesCheckBox.UseVisualStyleBackColor = true;
//
// period1TextBox
//
this.period1TextBox.Enabled = false;
this.period1TextBox.Location = new System.Drawing.Point(92, 107);
this.period1TextBox.Name = "period1TextBox";
this.period1TextBox.Size = new System.Drawing.Size(46, 20);
this.period1TextBox.TabIndex = 21;
//
// period1Label
//
this.period1Label.AutoSize = true;
this.period1Label.Location = new System.Drawing.Point(6, 110);
this.period1Label.Name = "period1Label";
this.period1Label.Size = new System.Drawing.Size(46, 13);
this.period1Label.TabIndex = 20;
this.period1Label.Text = "Period 1";
//
// period2TextBox
//
this.period2TextBox.Enabled = false;
this.period2TextBox.Location = new System.Drawing.Point(92, 130);
this.period2TextBox.Name = "period2TextBox";
this.period2TextBox.Size = new System.Drawing.Size(46, 20);
this.period2TextBox.TabIndex = 23;
//
// period2Label
//
this.period2Label.AutoSize = true;
this.period2Label.Location = new System.Drawing.Point(6, 133);
this.period2Label.Name = "period2Label";
this.period2Label.Size = new System.Drawing.Size(46, 13);
this.period2Label.TabIndex = 22;
this.period2Label.Text = "Period 2";
//
// groupBox1
//
this.groupBox1.Controls.Add(this.argsTextBox);
this.groupBox1.Controls.Add(this.period2TextBox);
this.groupBox1.Controls.Add(this.argsLabel);
this.groupBox1.Controls.Add(this.period2Label);
this.groupBox1.Controls.Add(this.helpLabel1);
this.groupBox1.Controls.Add(this.period1TextBox);
this.groupBox1.Controls.Add(this.label2);
this.groupBox1.Controls.Add(this.period1Label);
this.groupBox1.Controls.Add(this.useTestImagesCheckBox);
this.groupBox1.Controls.Add(this.imagesCountTextBox);
this.groupBox1.Controls.Add(this.imagesCountLabel);
this.groupBox1.Location = new System.Drawing.Point(7, 110);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(477, 169);
this.groupBox1.TabIndex = 24;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "ROI Detection";
this.saveImagesCheckBox.AutoSize = true;
this.saveImagesCheckBox.Enabled = false;
this.saveImagesCheckBox.Location = new System.Drawing.Point(99, 140);
this.saveImagesCheckBox.Name = "saveImagesCheckBox";
this.saveImagesCheckBox.Size = new System.Drawing.Size(132, 17);
this.saveImagesCheckBox.TabIndex = 7;
this.saveImagesCheckBox.Text = "Save images (analyze)";
this.saveImagesCheckBox.UseVisualStyleBackColor = true;
//
// RoiCfgCtrl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.helpLabel1);
this.Controls.Add(this.saveImagesCheckBox);
this.Controls.Add(this.label2);
this.Controls.Add(this.previousRoiComboBox);
this.Controls.Add(this.previousRoiLabel);
this.Controls.Add(this.loadImagesCheckBox);
this.Controls.Add(this.parentNameComboBox);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.label1);
@@ -269,8 +186,6 @@ namespace TBF.BenchControl.Network.Camera.Roi
this.Name = "RoiCfgCtrl";
this.Size = new System.Drawing.Size(500, 300);
this.Load += new System.EventHandler(this.PumpCfgCtrl_Load);
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
@@ -278,8 +193,6 @@ namespace TBF.BenchControl.Network.Camera.Roi
#endregion
private System.Windows.Forms.TextBox argsTextBox;
private System.Windows.Forms.Label argsLabel;
private System.Windows.Forms.Label parentNameLabel;
private System.Windows.Forms.TextBox nameTextBox;
private System.Windows.Forms.Label nameLabel;
@@ -291,13 +204,7 @@ namespace TBF.BenchControl.Network.Camera.Roi
private System.Windows.Forms.Label previousRoiLabel;
private System.Windows.Forms.Label helpLabel1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox imagesCountTextBox;
private System.Windows.Forms.Label imagesCountLabel;
private System.Windows.Forms.CheckBox useTestImagesCheckBox;
private System.Windows.Forms.TextBox period1TextBox;
private System.Windows.Forms.Label period1Label;
private System.Windows.Forms.TextBox period2TextBox;
private System.Windows.Forms.Label period2Label;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.CheckBox loadImagesCheckBox;
private System.Windows.Forms.CheckBox saveImagesCheckBox;
}
}
@@ -1,9 +1,18 @@
using TBF.BenchControl.Network.Telnet;
///
/// Copyright (c) 2017 Sensus Metering Systems
///
using System;
using log4net;
using TBF.BenchControl.Network.Telnet;
namespace TBF.BenchControl.Network.Camera.Roi
{
public class RoiDetectionOp : IOperation
{
private static readonly ILog log = LogManager.GetLogger(typeof(RoiDetectionOp));
public override string ToString() { return string.Format("RoiDetectionOp()"); }
readonly Roi roi;
readonly RoiCfg roiCfg;
readonly CLP1611.Camera camera;
@@ -93,9 +102,10 @@ namespace TBF.BenchControl.Network.Camera.Roi
previous.RoiWid.Val, previous.RoiHgh.Val);
previous = previous.PreviousRoi;
}
command = string.Format("clp/RoiDetection{0}{1}{2}{3} {4}",
command = string.Format("clp/RoiDetection{0}{1}{2}{3}{4} {5}",
masks,
string.Format(roiCfg.UseTestImages ? " -l {0}" : " -n {0}", roiCfg.DetectionImagesCount),
string.Format(roiCfg.LoadImages ? " -l {0}" : " -n {0}", roiCfg.DetectionImagesCount),
roiCfg.SaveImages ? " -s" : "",
string.Format(" -p1 {0}", roiCfg.DetectionPeriod1),
string.Format(" -p2 {0}", roiCfg.DetectionPeriod2),
roiCfg.RoiParams);
@@ -109,13 +119,41 @@ namespace TBF.BenchControl.Network.Camera.Roi
}
return Event.CameraBusy;
}
else if (passed)
{
if (transferringDetectedImage)
{
/// ROI detection passed and image transfer is in progress
return Event.RoiDetectionPassed;
}
else if (0 == camera.WscpTransferFile("detected.jpg", roi.DetectedImageName))
{
/// Start the file transfer
transferringDetectedImage = true;
return Event.RoiDetectionPassed;
}
else
{
/// Wait until the previous image transfer completes
return Event.CameraBusy;
}
}
else if (failed)
{
/// ROI detection failed, there in no image to transfer
return Event.RoiDetectionFailed;
}
else if (previousFailed)
{
return Event.RoiDetectionPreviousFailed;
}
else if (response != null)
{
int from = response.IndexOf('[');
int to = response.IndexOf(']');
if (!response.Contains("RESULT=0\r\n") || from < 0 || to < 0 || to < from)
{
roi.Detected = false;
roi.ClearRoi();
failed = true;
return Event.RoiDetectionFailed;
}
@@ -127,47 +165,30 @@ namespace TBF.BenchControl.Network.Camera.Roi
if (terms.Length != 5 || !int.TryParse(terms[0], out x) || !int.TryParse(terms[1], out y)
|| !int.TryParse(terms[2], out w) || !int.TryParse(terms[3], out h))
{
roi.Detected = false;
roi.ClearRoi();
failed = true;
return Event.RoiDetectionFailed;
}
else
{
roiX.Val = x;
roiY.Val = y;
roiWid.Val = w;
roiHgh.Val = h;
roi.Detected = true;
roi.SetRoi(x, y, w, h);
passed = true;
return Event.RoiDetectionPassed;
///
/// Start the file transfer
///
if (0 == camera.WscpTransferFile("detected.jpg", roi.DetectedImageName))
{
transferringDetectedImage = true;
return Event.RoiDetectionPassed;
}
else
{
return Event.CameraBusy; /// File transfer not started
}
}
}
}
else if (passed)
{
if (transferringDetectedImage)
{
return Event.RoiDetectionPassed;
}
else if (0 == camera.WscpTransferFile("detected.jpg"))
{
transferringDetectedImage = true;
return Event.RoiDetectionPassed;
}
else
{
return Event.CameraBusy;
}
}
else if (failed)
{
return Event.RoiDetectionFailed;
}
else if (previousFailed)
{
return Event.RoiDetectionPreviousFailed;
}
else
{
return Event.CameraBusy;
@@ -0,0 +1,15 @@
///
/// Copyright (c) 2017 Sensus Metering Systems
///
namespace TBF.BenchControl.Network.Telnet
{
public class DummyVT : IVirtualTerminal
{
public DummyVT() { }
public void ClearScreen() { }
public void WriteVt(char c) { }
public void WriteVt(string txt) { }
public string Text { get { return string.Empty; } }
}
}
@@ -0,0 +1,13 @@
///
/// Copyright (c) 2017 Sensus Metering Systems
///
namespace TBF.BenchControl.Network.Telnet
{
public interface IVirtualTerminal
{
void ClearScreen();
void WriteVt(char c);
void WriteVt(string txt);
string Text { get; }
}
}
@@ -146,7 +146,7 @@ namespace TBF.BenchControl.Network.Telnet
/// Private fields
///
object objRef; /// Reference to object to be included in info sent by event handlers
VirtualTerminal vt; /// Virtual terminal
IVirtualTerminal vt; /// Virtual terminal
string hostname; /// Telnet server host name or IP address.
int portNr = DefaultTelnetPortNumber; /// Telnet server port number.
TcpClient tcp = null; /// Reference to TcpClient
@@ -223,7 +223,7 @@ namespace TBF.BenchControl.Network.Telnet
/// Hostname (IP address) and the port number is passed to worker thread
/// in a Command with CmdAction.CONNECT and str=hostname.
/// </summary>
public TelnetClient(object objRef, string threadId, string userName, string password, string defaultPrompt, bool skipFirstLine)
public TelnetClient(object objRef, string threadId, string userName, string password, string defaultPrompt, bool skipFirstLine, bool useVT)
{
this.objRef = objRef;
this.telnetUserName = userName;
@@ -232,7 +232,17 @@ namespace TBF.BenchControl.Network.Telnet
this.skipFirstLine = skipFirstLine;
state = TelnetState.Inactive; /// Device's icon is being updated by HNIP
vt = new VirtualTerminal(); /// TODO: pass a VirtualTerminal reference
///
if (useVT)
{
vt = new VirtualTerminal();
}
else
{
vt = new DummyVT();
}
/// TODO: pass a VirtualTerminal reference
this.portNr = DefaultTelnetPortNumber;
queueEvent = new AutoResetEvent(false);
disconnectDone = new AutoResetEvent(false);
@@ -986,7 +996,7 @@ namespace TBF.BenchControl.Network.Telnet
///
/// Public properties (read only)
///
public VirtualTerminal Vt { get { return vt; } }
public IVirtualTerminal Vt { get { return vt; } }
public string Hostname { get { return hostname; } }
public string NotificationText { get { return notificationText; } }
public string ErrorText { get { return fatalErrorText; } }
@@ -12,7 +12,7 @@ namespace TBF.BenchControl.Network.Telnet
/// - ClearScreen() and WriteVt() methods called from one thread only
/// - properties Text, etc. can be safely read from an arbitrary thread
/// </summary>
public class VirtualTerminal
public class VirtualTerminal : IVirtualTerminal
{
const uint DefaultVtRowsCount = 80; /// Default VT height (number of rows)
const uint DefaultVtColumnsCount = 132; /// Default VT width (number of columns)
@@ -77,7 +77,8 @@ namespace TBF.BenchControl.Operations
switch (cmd)
{
/// Bench Control Panel buttons
case UI2BenchCmd.StartTest: return Event.UiCmdStartTest;
case UI2BenchCmd.ReloadBatch: return Event.UiCmdReloadBatch;
case UI2BenchCmd.StartTest: return Event.UiCmdStartTest;
case UI2BenchCmd.StartQ1: return Event.UiCmdStartQ1;
case UI2BenchCmd.StartQ2: return Event.UiCmdStartQ2;
case UI2BenchCmd.StartQ3: return Event.UiCmdStartQ3;
@@ -85,15 +86,16 @@ namespace TBF.BenchControl.Operations
case UI2BenchCmd.Stop: return Event.UiCmdStop;
case UI2BenchCmd.PurgeBegin: return Event.UiCmdPurgeBegin;
case UI2BenchCmd.PurgeEnd: return Event.UiCmdPurgeEnd;
case UI2BenchCmd.EmptyTank1: return Event.UiCmdEmptyTank1;
case UI2BenchCmd.EmptyTank2: return Event.UiCmdEmptyTank2;
case UI2BenchCmd.EmptyTank3: return Event.UiCmdEmptyTank3;
case UI2BenchCmd.DrainTank1: return Event.UiCmdDrainTank1;
case UI2BenchCmd.DrainTank2: return Event.UiCmdDrainTank2;
case UI2BenchCmd.DrainTank3: return Event.UiCmdDrainTank3;
case UI2BenchCmd.Break: return Event.UiCmdBreak;
case UI2BenchCmd.ResetResults: return Event.UiCmdResetResults;
case UI2BenchCmd.AcceptResults: return Event.UiCmdAcceptResults;
case UI2BenchCmd.Calibration: return Event.UiCmdCalibration;
case UI2BenchCmd.CameraTest: return Event.UiCmdCameraTest;
case UI2BenchCmd.SensitivityTest: return Event.UiCmdSensitivityTest;
case UI2BenchCmd.Custom: return Event.UiCmdCustom;
case UI2BenchCmd.Next: return Event.Next;
@@ -3,6 +3,7 @@
///
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Threading;
using log4net;
@@ -153,6 +154,12 @@ namespace TBF.BenchControl.Output.FileWriters.Basic
completed2 = true;
});
if (writerCfg.Culture > Culture.system && writerCfg.Culture < Culture.Count)
{
thread1.CurrentCulture = new CultureInfo(writerCfg.Culture.ToString());
thread2.CurrentCulture = new CultureInfo(writerCfg.Culture.ToString());
}
return this;
}
@@ -19,7 +19,8 @@ namespace TBF.BenchControl.Output.FileWriters.Basic
public MonthFolders MonthFolders;
public DayFolders DayFolders;
public string FileNameFormat;
public Separator Separator;
public Culture Culture;
public Separator Separator;
public bool SaveGoodOnly;
public string[] SelectedItems;
@@ -38,15 +38,11 @@ namespace TBF.BenchControl.Output.FileWriters.Basic
private void WriterCfgCtrl_Load(object sender, EventArgs e)
{
for (Separator s = 0; s < Separator.Count; s++) separatorComboBox.Items.Add(s.ToString());
for (YearFolders s = 0; s < YearFolders.Count; s++) yearFoldersComboBox.Items.Add(s.ToString());
for (MonthFolders s = 0; s < MonthFolders.Count; s++) monthFoldersComboBox.Items.Add(s.ToString());
for (DayFolders s = 0; s < DayFolders.Count; s++) dayFoldersComboBox.Items.Add(s.ToString());
for (int i = 0; i < (int)Separator.Count; i++)
{
separatorComboBox.Items.Add(((Separator)i).ToString());
}
for (Culture s = 0; s < Culture.Count; s++) cultureComboBox.Items.Add(s.ToString());
for (Separator s = 0; s < Separator.Count; s++) separatorComboBox.Items.Add(s.ToString());
selectedItems = config.SelectedItems;
@@ -68,7 +64,8 @@ namespace TBF.BenchControl.Output.FileWriters.Basic
monthFoldersComboBox.Text = config.MonthFolders.ToString();
dayFoldersComboBox.Text = config.DayFolders.ToString();
fileNameFmtTextBox.Text = config.FileNameFormat;
separatorComboBox.Text = config.Separator.ToString();
cultureComboBox.Text = config.Culture.ToString();
separatorComboBox.Text = config.Separator.ToString();
goodOnlyCheckBox.Checked = config.SaveGoodOnly;
}
@@ -83,7 +80,8 @@ namespace TBF.BenchControl.Output.FileWriters.Basic
monthFoldersComboBox.Enabled = true;
dayFoldersComboBox.Enabled = true;
fileNameFmtTextBox.Enabled = true;
separatorComboBox.Enabled = true;
cultureComboBox.Enabled = true;
separatorComboBox.Enabled = true;
goodOnlyCheckBox.Enabled = true;
selectItemsButton.Enabled = true;
}
@@ -110,6 +108,12 @@ namespace TBF.BenchControl.Output.FileWriters.Basic
message += Environment.NewLine + "Invalid day folder selection";
}
if (!cultureComboBox.Items.Contains(cultureComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Invalid culture";
}
if (!separatorComboBox.Items.Contains(separatorComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
@@ -176,6 +180,16 @@ namespace TBF.BenchControl.Output.FileWriters.Basic
flags = CfgUpdateFlags.RestartRqrd;
}
for (Culture i = 0; i < Culture.Count; i++)
{
if (i.ToString().Equals(cultureComboBox.Text) && (config.Culture != i))
{
config.Culture = i;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
break;
}
}
for (Separator i = 0; i < Separator.Count; i++)
{
if (i.ToString().Equals(separatorComboBox.Text) && (config.Separator != i))
@@ -52,6 +52,8 @@ namespace TBF.BenchControl.Output.FileWriters.Basic
this.fileNameFmtTextBox = new System.Windows.Forms.TextBox();
this.fileNameFmtLabel = new System.Windows.Forms.Label();
this.goodOnlyCheckBox = new System.Windows.Forms.CheckBox();
this.cultureComboBox = new System.Windows.Forms.ComboBox();
this.cultureLabel = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// nameTextBox
@@ -111,25 +113,25 @@ namespace TBF.BenchControl.Output.FileWriters.Basic
// separatorLabel
//
this.separatorLabel.AutoSize = true;
this.separatorLabel.Location = new System.Drawing.Point(17, 184);
this.separatorLabel.Location = new System.Drawing.Point(17, 206);
this.separatorLabel.Name = "separatorLabel";
this.separatorLabel.Size = new System.Drawing.Size(53, 13);
this.separatorLabel.TabIndex = 15;
this.separatorLabel.TabIndex = 17;
this.separatorLabel.Text = "Separator";
//
// separatorComboBox
//
this.separatorComboBox.Enabled = false;
this.separatorComboBox.FormattingEnabled = true;
this.separatorComboBox.Location = new System.Drawing.Point(108, 181);
this.separatorComboBox.Location = new System.Drawing.Point(108, 203);
this.separatorComboBox.Name = "separatorComboBox";
this.separatorComboBox.Size = new System.Drawing.Size(146, 21);
this.separatorComboBox.TabIndex = 16;
this.separatorComboBox.TabIndex = 18;
//
// selectItemsButton
//
this.selectItemsButton.Enabled = false;
this.selectItemsButton.Location = new System.Drawing.Point(108, 203);
this.selectItemsButton.Location = new System.Drawing.Point(108, 225);
this.selectItemsButton.Name = "selectItemsButton";
this.selectItemsButton.Size = new System.Drawing.Size(145, 23);
this.selectItemsButton.TabIndex = 20;
@@ -238,17 +240,37 @@ namespace TBF.BenchControl.Output.FileWriters.Basic
// goodOnlyCheckBox
//
this.goodOnlyCheckBox.AutoSize = true;
this.goodOnlyCheckBox.Location = new System.Drawing.Point(20, 207);
this.goodOnlyCheckBox.Location = new System.Drawing.Point(20, 229);
this.goodOnlyCheckBox.Name = "goodOnlyCheckBox";
this.goodOnlyCheckBox.Size = new System.Drawing.Size(74, 17);
this.goodOnlyCheckBox.TabIndex = 17;
this.goodOnlyCheckBox.TabIndex = 19;
this.goodOnlyCheckBox.Text = "Good only";
this.goodOnlyCheckBox.UseVisualStyleBackColor = true;
//
// cultureComboBox
//
this.cultureComboBox.Enabled = false;
this.cultureComboBox.FormattingEnabled = true;
this.cultureComboBox.Location = new System.Drawing.Point(108, 181);
this.cultureComboBox.Name = "cultureComboBox";
this.cultureComboBox.Size = new System.Drawing.Size(146, 21);
this.cultureComboBox.TabIndex = 16;
//
// cultureLabel
//
this.cultureLabel.AutoSize = true;
this.cultureLabel.Location = new System.Drawing.Point(17, 184);
this.cultureLabel.Name = "cultureLabel";
this.cultureLabel.Size = new System.Drawing.Size(42, 13);
this.cultureLabel.TabIndex = 15;
this.cultureLabel.Text = "Cullture";
//
// WriterCfgCtrl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.cultureComboBox);
this.Controls.Add(this.cultureLabel);
this.Controls.Add(this.goodOnlyCheckBox);
this.Controls.Add(this.fileNameFmtTextBox);
this.Controls.Add(this.fileNameFmtLabel);
@@ -271,7 +293,7 @@ namespace TBF.BenchControl.Output.FileWriters.Basic
this.Controls.Add(this.nameLabel);
this.Controls.Add(this.classNameLabel);
this.Name = "WriterCfgCtrl";
this.Size = new System.Drawing.Size(300, 230);
this.Size = new System.Drawing.Size(300, 282);
this.Load += new System.EventHandler(this.WriterCfgCtrl_Load);
this.ResumeLayout(false);
this.PerformLayout();
@@ -301,5 +323,7 @@ namespace TBF.BenchControl.Output.FileWriters.Basic
private System.Windows.Forms.TextBox fileNameFmtTextBox;
private System.Windows.Forms.Label fileNameFmtLabel;
private System.Windows.Forms.CheckBox goodOnlyCheckBox;
private System.Windows.Forms.ComboBox cultureComboBox;
private System.Windows.Forms.Label cultureLabel;
}
}
@@ -3,6 +3,7 @@
///
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Threading;
using log4net;
@@ -93,8 +94,9 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
writerCfg.MonthFolders = newCfg.MonthFolders;
writerCfg.DayFolders = newCfg.DayFolders;
writerCfg.FileNameFormat = newCfg.FileNameFormat;
writerCfg.Separator = newCfg.Separator;
writerCfg.EliminateSpaces = newCfg.EliminateSpaces;
writerCfg.Culture = newCfg.Culture;
writerCfg.Separator = newCfg.Separator;
writerCfg.EliminateSpaces = newCfg.EliminateSpaces;
writerCfg.CommonItems = newCfg.CommonItems;
writerCfg.SelectedItems = newCfg.SelectedItems;
writerCfg.Header = newCfg.Header;
@@ -221,6 +223,12 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
completed2 = true;
});
if (writerCfg.Culture > Culture.system && writerCfg.Culture < Culture.Count)
{
thread1.CurrentCulture = new CultureInfo(writerCfg.Culture.ToString());
thread2.CurrentCulture = new CultureInfo(writerCfg.Culture.ToString());
}
return this;
}
@@ -286,7 +294,7 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
foreach (var v in commonItems)
{
leftColumn[cnt] = v.Caption;
rightColumn[cnt] = v.Print(batch.WaterMeters[0]);
rightColumn[cnt] = (batch.WaterMeters.Count > 0) ? v.Print(batch.WaterMeters[0]) : string.Empty;
cnt++;
}
@@ -19,6 +19,7 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
public MonthFolders MonthFolders;
public DayFolders DayFolders;
public string FileNameFormat;
public Culture Culture;
public Separator Separator;
public bool EliminateSpaces;
public string[] CommonItems;
@@ -42,15 +42,11 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
private void WriterCfgCtrl_Load(object sender, EventArgs e)
{
for (Separator s = 0; s < Separator.Count; s++) separatorComboBox.Items.Add(s.ToString());
for (YearFolders s = 0; s < YearFolders.Count; s++) yearFoldersComboBox.Items.Add(s.ToString());
for (MonthFolders s = 0; s < MonthFolders.Count; s++) monthFoldersComboBox.Items.Add(s.ToString());
for (DayFolders s = 0; s < DayFolders.Count; s++) dayFoldersComboBox.Items.Add(s.ToString());
for (int i = 0; i < (int)Separator.Count; i++)
{
separatorComboBox.Items.Add(((Separator)i).ToString());
}
for (Culture s = 0; s < Culture.Count; s++) cultureComboBox.Items.Add(s.ToString());
for (Separator s = 0; s < Separator.Count; s++) separatorComboBox.Items.Add(s.ToString());
header = config.Header;
commonItems = config.CommonItems;
@@ -69,6 +65,7 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
monthFoldersLabel.Text = "Month folders";
dayFoldersLabel.Text = "Day folders";
fileNameFmtLabel.Text = "File name format";
cultureLabel.Text = "Culture";
separatorLabel.Text = "Separator";
eliminateSpacesCheckBox.Text = "No spaces";
headerButton.Text = Strings.Header;
@@ -93,7 +90,8 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
monthFoldersComboBox.Text = config.MonthFolders.ToString();
dayFoldersComboBox.Text = config.DayFolders.ToString();
fileNameFmtTextBox.Text = config.FileNameFormat;
separatorComboBox.Text = config.Separator.ToString();
cultureComboBox.Text = config.Culture.ToString();
separatorComboBox.Text = config.Separator.ToString();
eliminateSpacesCheckBox.Checked = config.EliminateSpaces;
}
@@ -108,7 +106,8 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
monthFoldersComboBox.Enabled = true;
dayFoldersComboBox.Enabled = true;
fileNameFmtTextBox.Enabled = true;
separatorComboBox.Enabled = true;
cultureComboBox.Enabled = true;
separatorComboBox.Enabled = true;
eliminateSpacesCheckBox.Enabled = true;
headerButton.Enabled = true;
commonItemsButton.Enabled = true;
@@ -138,6 +137,12 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
message += Environment.NewLine + "Invalid day folder selection";
}
if (!cultureComboBox.Items.Contains(cultureComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Invalid culture";
}
if (!separatorComboBox.Items.Contains(separatorComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
@@ -208,6 +213,15 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
for (Culture i = 0; i < Culture.Count; i++)
{
if (i.ToString().Equals(cultureComboBox.Text) && (config.Culture != i))
{
config.Culture = i;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
break;
}
}
for (Separator i = 0; i < Separator.Count; i++)
{
@@ -56,12 +56,14 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
this.footerButton = new System.Windows.Forms.Button();
this.commonItemsButton = new System.Windows.Forms.Button();
this.upgradeWizardButton = new System.Windows.Forms.Button();
this.cultureComboBox = new System.Windows.Forms.ComboBox();
this.cultureLabel = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// nameTextBox
//
this.nameTextBox.Enabled = false;
this.nameTextBox.Location = new System.Drawing.Point(108, 31);
this.nameTextBox.Location = new System.Drawing.Point(108, 28);
this.nameTextBox.Name = "nameTextBox";
this.nameTextBox.Size = new System.Drawing.Size(146, 20);
this.nameTextBox.TabIndex = 2;
@@ -69,7 +71,7 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
// nameLabel
//
this.nameLabel.AutoSize = true;
this.nameLabel.Location = new System.Drawing.Point(17, 34);
this.nameLabel.Location = new System.Drawing.Point(17, 31);
this.nameLabel.Name = "nameLabel";
this.nameLabel.Size = new System.Drawing.Size(35, 13);
this.nameLabel.TabIndex = 1;
@@ -78,7 +80,7 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
// classNameLabel
//
this.classNameLabel.AutoSize = true;
this.classNameLabel.Location = new System.Drawing.Point(105, 9);
this.classNameLabel.Location = new System.Drawing.Point(105, 6);
this.classNameLabel.Name = "classNameLabel";
this.classNameLabel.Size = new System.Drawing.Size(83, 13);
this.classNameLabel.TabIndex = 0;
@@ -87,7 +89,7 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
// destinationTextBox
//
this.destinationTextBox.Enabled = false;
this.destinationTextBox.Location = new System.Drawing.Point(108, 52);
this.destinationTextBox.Location = new System.Drawing.Point(108, 49);
this.destinationTextBox.Name = "destinationTextBox";
this.destinationTextBox.Size = new System.Drawing.Size(146, 20);
this.destinationTextBox.TabIndex = 4;
@@ -95,7 +97,7 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
// destinationLabel
//
this.destinationLabel.AutoSize = true;
this.destinationLabel.Location = new System.Drawing.Point(17, 55);
this.destinationLabel.Location = new System.Drawing.Point(17, 52);
this.destinationLabel.Name = "destinationLabel";
this.destinationLabel.Size = new System.Drawing.Size(60, 13);
this.destinationLabel.TabIndex = 3;
@@ -104,7 +106,7 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
// destinationButton
//
this.destinationButton.Enabled = false;
this.destinationButton.Location = new System.Drawing.Point(269, 52);
this.destinationButton.Location = new System.Drawing.Point(269, 49);
this.destinationButton.Name = "destinationButton";
this.destinationButton.Size = new System.Drawing.Size(30, 20);
this.destinationButton.TabIndex = 5;
@@ -115,28 +117,28 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
// separatorLabel
//
this.separatorLabel.AutoSize = true;
this.separatorLabel.Location = new System.Drawing.Point(17, 184);
this.separatorLabel.Location = new System.Drawing.Point(17, 203);
this.separatorLabel.Name = "separatorLabel";
this.separatorLabel.Size = new System.Drawing.Size(53, 13);
this.separatorLabel.TabIndex = 17;
this.separatorLabel.TabIndex = 19;
this.separatorLabel.Text = "Separator";
//
// separatorComboBox
//
this.separatorComboBox.Enabled = false;
this.separatorComboBox.FormattingEnabled = true;
this.separatorComboBox.Location = new System.Drawing.Point(108, 181);
this.separatorComboBox.Location = new System.Drawing.Point(108, 200);
this.separatorComboBox.Name = "separatorComboBox";
this.separatorComboBox.Size = new System.Drawing.Size(146, 21);
this.separatorComboBox.TabIndex = 18;
this.separatorComboBox.TabIndex = 20;
//
// testItemsButton
//
this.testItemsButton.Enabled = false;
this.testItemsButton.Location = new System.Drawing.Point(108, 278);
this.testItemsButton.Location = new System.Drawing.Point(108, 297);
this.testItemsButton.Name = "testItemsButton";
this.testItemsButton.Size = new System.Drawing.Size(146, 23);
this.testItemsButton.TabIndex = 22;
this.testItemsButton.TabIndex = 24;
this.testItemsButton.Text = "Test items";
this.testItemsButton.UseVisualStyleBackColor = true;
this.testItemsButton.Click += new System.EventHandler(this.testItemsButton_Click);
@@ -144,7 +146,7 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
// yearFoldersLabel
//
this.yearFoldersLabel.AutoSize = true;
this.yearFoldersLabel.Location = new System.Drawing.Point(17, 97);
this.yearFoldersLabel.Location = new System.Drawing.Point(17, 94);
this.yearFoldersLabel.Name = "yearFoldersLabel";
this.yearFoldersLabel.Size = new System.Drawing.Size(63, 13);
this.yearFoldersLabel.TabIndex = 9;
@@ -153,7 +155,7 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
// monthFoldersLabel
//
this.monthFoldersLabel.AutoSize = true;
this.monthFoldersLabel.Location = new System.Drawing.Point(17, 119);
this.monthFoldersLabel.Location = new System.Drawing.Point(17, 116);
this.monthFoldersLabel.Name = "monthFoldersLabel";
this.monthFoldersLabel.Size = new System.Drawing.Size(71, 13);
this.monthFoldersLabel.TabIndex = 11;
@@ -162,7 +164,7 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
// dayFoldersLabel
//
this.dayFoldersLabel.AutoSize = true;
this.dayFoldersLabel.Location = new System.Drawing.Point(17, 141);
this.dayFoldersLabel.Location = new System.Drawing.Point(17, 138);
this.dayFoldersLabel.Name = "dayFoldersLabel";
this.dayFoldersLabel.Size = new System.Drawing.Size(60, 13);
this.dayFoldersLabel.TabIndex = 13;
@@ -172,7 +174,7 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
//
this.yearFoldersComboBox.Enabled = false;
this.yearFoldersComboBox.FormattingEnabled = true;
this.yearFoldersComboBox.Location = new System.Drawing.Point(108, 94);
this.yearFoldersComboBox.Location = new System.Drawing.Point(108, 91);
this.yearFoldersComboBox.Name = "yearFoldersComboBox";
this.yearFoldersComboBox.Size = new System.Drawing.Size(146, 21);
this.yearFoldersComboBox.TabIndex = 10;
@@ -181,7 +183,7 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
//
this.monthFoldersComboBox.Enabled = false;
this.monthFoldersComboBox.FormattingEnabled = true;
this.monthFoldersComboBox.Location = new System.Drawing.Point(108, 116);
this.monthFoldersComboBox.Location = new System.Drawing.Point(108, 113);
this.monthFoldersComboBox.Name = "monthFoldersComboBox";
this.monthFoldersComboBox.Size = new System.Drawing.Size(146, 21);
this.monthFoldersComboBox.TabIndex = 12;
@@ -190,7 +192,7 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
//
this.dayFoldersComboBox.Enabled = false;
this.dayFoldersComboBox.FormattingEnabled = true;
this.dayFoldersComboBox.Location = new System.Drawing.Point(108, 138);
this.dayFoldersComboBox.Location = new System.Drawing.Point(108, 135);
this.dayFoldersComboBox.Name = "dayFoldersComboBox";
this.dayFoldersComboBox.Size = new System.Drawing.Size(146, 21);
this.dayFoldersComboBox.TabIndex = 14;
@@ -198,7 +200,7 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
// destination2Button
//
this.destination2Button.Enabled = false;
this.destination2Button.Location = new System.Drawing.Point(269, 73);
this.destination2Button.Location = new System.Drawing.Point(269, 70);
this.destination2Button.Name = "destination2Button";
this.destination2Button.Size = new System.Drawing.Size(30, 20);
this.destination2Button.TabIndex = 8;
@@ -208,7 +210,7 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
// destination2TextBox
//
this.destination2TextBox.Enabled = false;
this.destination2TextBox.Location = new System.Drawing.Point(108, 73);
this.destination2TextBox.Location = new System.Drawing.Point(108, 70);
this.destination2TextBox.Name = "destination2TextBox";
this.destination2TextBox.Size = new System.Drawing.Size(146, 20);
this.destination2TextBox.TabIndex = 7;
@@ -216,7 +218,7 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
// destination2Label
//
this.destination2Label.AutoSize = true;
this.destination2Label.Location = new System.Drawing.Point(17, 76);
this.destination2Label.Location = new System.Drawing.Point(17, 73);
this.destination2Label.Name = "destination2Label";
this.destination2Label.Size = new System.Drawing.Size(69, 13);
this.destination2Label.TabIndex = 6;
@@ -225,7 +227,7 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
// fileNameFmtTextBox
//
this.fileNameFmtTextBox.Enabled = false;
this.fileNameFmtTextBox.Location = new System.Drawing.Point(108, 160);
this.fileNameFmtTextBox.Location = new System.Drawing.Point(108, 157);
this.fileNameFmtTextBox.Name = "fileNameFmtTextBox";
this.fileNameFmtTextBox.Size = new System.Drawing.Size(146, 20);
this.fileNameFmtTextBox.TabIndex = 16;
@@ -233,7 +235,7 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
// fileNameFmtLabel
//
this.fileNameFmtLabel.AutoSize = true;
this.fileNameFmtLabel.Location = new System.Drawing.Point(17, 163);
this.fileNameFmtLabel.Location = new System.Drawing.Point(17, 160);
this.fileNameFmtLabel.Name = "fileNameFmtLabel";
this.fileNameFmtLabel.Size = new System.Drawing.Size(84, 13);
this.fileNameFmtLabel.TabIndex = 15;
@@ -242,20 +244,20 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
// eliminateSpacesCheckBox
//
this.eliminateSpacesCheckBox.AutoSize = true;
this.eliminateSpacesCheckBox.Location = new System.Drawing.Point(108, 208);
this.eliminateSpacesCheckBox.Location = new System.Drawing.Point(108, 227);
this.eliminateSpacesCheckBox.Name = "eliminateSpacesCheckBox";
this.eliminateSpacesCheckBox.Size = new System.Drawing.Size(77, 17);
this.eliminateSpacesCheckBox.TabIndex = 19;
this.eliminateSpacesCheckBox.TabIndex = 21;
this.eliminateSpacesCheckBox.Text = "No spaces";
this.eliminateSpacesCheckBox.UseVisualStyleBackColor = true;
//
// headerButton
//
this.headerButton.Enabled = false;
this.headerButton.Location = new System.Drawing.Point(108, 228);
this.headerButton.Location = new System.Drawing.Point(108, 247);
this.headerButton.Name = "headerButton";
this.headerButton.Size = new System.Drawing.Size(146, 23);
this.headerButton.TabIndex = 20;
this.headerButton.TabIndex = 22;
this.headerButton.Text = "Header";
this.headerButton.UseVisualStyleBackColor = true;
this.headerButton.Click += new System.EventHandler(this.headerButton_Click);
@@ -263,10 +265,10 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
// footerButton
//
this.footerButton.Enabled = false;
this.footerButton.Location = new System.Drawing.Point(108, 303);
this.footerButton.Location = new System.Drawing.Point(108, 322);
this.footerButton.Name = "footerButton";
this.footerButton.Size = new System.Drawing.Size(146, 23);
this.footerButton.TabIndex = 23;
this.footerButton.TabIndex = 25;
this.footerButton.Text = "Footer";
this.footerButton.UseVisualStyleBackColor = true;
this.footerButton.Click += new System.EventHandler(this.footerButton_Click);
@@ -274,28 +276,48 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
// commonItemsButton
//
this.commonItemsButton.Enabled = false;
this.commonItemsButton.Location = new System.Drawing.Point(108, 253);
this.commonItemsButton.Location = new System.Drawing.Point(108, 272);
this.commonItemsButton.Name = "commonItemsButton";
this.commonItemsButton.Size = new System.Drawing.Size(146, 23);
this.commonItemsButton.TabIndex = 21;
this.commonItemsButton.TabIndex = 23;
this.commonItemsButton.Text = "Common items";
this.commonItemsButton.UseVisualStyleBackColor = true;
this.commonItemsButton.Click += new System.EventHandler(this.commonItemsButton_Click);
//
// upgradeWizardButton
//
this.upgradeWizardButton.Location = new System.Drawing.Point(269, 253);
this.upgradeWizardButton.Location = new System.Drawing.Point(269, 272);
this.upgradeWizardButton.Name = "upgradeWizardButton";
this.upgradeWizardButton.Size = new System.Drawing.Size(80, 48);
this.upgradeWizardButton.TabIndex = 24;
this.upgradeWizardButton.TabIndex = 26;
this.upgradeWizardButton.Text = "Upgrade wizard";
this.upgradeWizardButton.UseVisualStyleBackColor = true;
this.upgradeWizardButton.Click += new System.EventHandler(this.upgradeWizardButton_Click);
//
// cultureComboBox
//
this.cultureComboBox.Enabled = false;
this.cultureComboBox.FormattingEnabled = true;
this.cultureComboBox.Location = new System.Drawing.Point(108, 178);
this.cultureComboBox.Name = "cultureComboBox";
this.cultureComboBox.Size = new System.Drawing.Size(146, 21);
this.cultureComboBox.TabIndex = 18;
//
// cultureLabel
//
this.cultureLabel.AutoSize = true;
this.cultureLabel.Location = new System.Drawing.Point(17, 181);
this.cultureLabel.Name = "cultureLabel";
this.cultureLabel.Size = new System.Drawing.Size(42, 13);
this.cultureLabel.TabIndex = 17;
this.cultureLabel.Text = "Cullture";
//
// WriterCfgCtrl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.cultureComboBox);
this.Controls.Add(this.cultureLabel);
this.Controls.Add(this.upgradeWizardButton);
this.Controls.Add(this.commonItemsButton);
this.Controls.Add(this.footerButton);
@@ -356,5 +378,7 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
private System.Windows.Forms.Button footerButton;
private System.Windows.Forms.Button commonItemsButton;
private System.Windows.Forms.Button upgradeWizardButton;
private System.Windows.Forms.ComboBox cultureComboBox;
private System.Windows.Forms.Label cultureLabel;
}
}
@@ -37,4 +37,13 @@ namespace TBF.BenchControl.Output.FileWriters
Semicolon,
Count
}
public enum Culture
{
system,
EN,
DE,
SK,
Count
}
}
@@ -3,6 +3,7 @@
///
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Threading;
using log4net;
@@ -25,10 +26,10 @@ namespace TBF.BenchControl.Output.FileWriters.Xml
/// Items to print
///
string header;
IList<Results.WMeterRsltItemSpec> commonItems1;
string rootTag;
string testTag;
IList<Results.WMeterRsltItemSpec> commonItems;
IList<Results.WMeterRsltItemSpec> testItems;
IList<Results.WMeterRsltItemSpec> commonItems2;
string footer;
Thread thread1; /// Thread where one file is saved
@@ -51,21 +52,12 @@ namespace TBF.BenchControl.Output.FileWriters.Xml
void ApplyConfig()
{
switch (writerCfg.Separator)
{
default:
case Separator.None: separatorStr = string.Empty; break;
case Separator.Space: separatorStr = " "; break;
case Separator.Tabulator: separatorStr = "\t"; break;
case Separator.Comma: separatorStr = ","; break;
case Separator.Semicolon: separatorStr = ";"; break;
}
/// TODO: Apply culture info
rootTag = writerCfg.RootTag;
testTag = writerCfg.RootTag;
header = string.IsNullOrEmpty(writerCfg.Header) ? string.Empty : writerCfg.Header.Replace("~", Environment.NewLine);
commonItems1 = Results.WMeterRsltItemSpec.FromStrArray(writerCfg.CommonItems1);
testItems = Results.WMeterRsltItemSpec.FromStrArray(writerCfg.SelectedItems); /// TestID info will be overwritten later on
commonItems2 = Results.WMeterRsltItemSpec.FromStrArray(writerCfg.CommonItems2);
footer = string.IsNullOrEmpty(writerCfg.Footer) ? string.Empty : writerCfg.Footer.Replace("~", Environment.NewLine);
commonItems = Results.WMeterRsltItemSpec.FromStrArray(writerCfg.CommonItems);
testItems = Results.WMeterRsltItemSpec.FromStrArray(writerCfg.TestItems); /// TestID info will be overwritten later on
}
@@ -95,12 +87,12 @@ namespace TBF.BenchControl.Output.FileWriters.Xml
writerCfg.MonthFolders = newCfg.MonthFolders;
writerCfg.DayFolders = newCfg.DayFolders;
writerCfg.FileNameFormat = newCfg.FileNameFormat;
writerCfg.Separator = newCfg.Separator;
writerCfg.CommonItems1 = newCfg.CommonItems1;
writerCfg.SelectedItems = newCfg.SelectedItems;
writerCfg.CommonItems2 = newCfg.CommonItems2;
writerCfg.Culture = newCfg.Culture;
writerCfg.Header = newCfg.Header;
writerCfg.Footer = newCfg.Footer;
writerCfg.RootTag = newCfg.RootTag;
writerCfg.TestTag = newCfg.TestTag;
writerCfg.CommonItems = newCfg.CommonItems;
writerCfg.TestItems = newCfg.TestItems;
ApplyConfig();
}
@@ -207,7 +199,13 @@ namespace TBF.BenchControl.Output.FileWriters.Xml
WriteRslts(batch, writerCfg.DestinationPath2);
completed2 = true;
});
if (writerCfg.Culture > Culture.system && writerCfg.Culture < Culture.Count)
{
thread1.CurrentCulture = new CultureInfo(writerCfg.Culture.ToString());
thread2.CurrentCulture = new CultureInfo(writerCfg.Culture.ToString());
}
return this;
}
@@ -264,9 +262,10 @@ namespace TBF.BenchControl.Output.FileWriters.Xml
{
/// Header
if (!string.IsNullOrEmpty(writerCfg.Header)) wr.Write(header);
wr.WriteLine(string.Format("<{0}>", rootTag));
/// Common items 1
foreach (var v in commonItems1)
foreach (var v in commonItems)
{
if (abort) return;
@@ -285,7 +284,7 @@ namespace TBF.BenchControl.Output.FileWriters.Xml
if ((mtr != null) && (mtr.Publish() == Config.Entities.Publish.Always))
{
wr.WriteLine(" <prueflauf>");
wr.WriteLine(string.Format(" <{0}>", testTag));
for (int i = 0; i < testItems.Count; i++)
{
/// Fetch the item and strip color information
@@ -296,26 +295,12 @@ namespace TBF.BenchControl.Output.FileWriters.Xml
/// Print the item
wr.WriteLine(" <{0}>{1}</{0}>", testItems[i].Caption, itemText);
}
wr.WriteLine(" </prueflauf>");
wr.WriteLine(string.Format(" </{0}>", testTag));
}
}
/// Common items 2
foreach (var v in commonItems2)
{
if (abort) return;
/// Fetch the item and strip color information
string itemText = v.Print(wm);
string[] texts = itemText.Split(new char[] { '|' });
if (texts.Length == 2) { itemText = texts[0]; }
wr.WriteLine(" <{0}>{1}</{0}>", v.Caption, itemText);
}
/// Footer
if (abort) return;
if (!string.IsNullOrEmpty(writerCfg.Footer)) wr.Write(footer);
wr.WriteLine(string.Format("</{0}>", rootTag));
}
}
}
@@ -20,12 +20,12 @@ namespace TBF.BenchControl.Output.FileWriters.Xml
public MonthFolders MonthFolders;
public DayFolders DayFolders;
public string FileNameFormat;
public Separator Separator;
public Culture Culture;
public string Header;
public string[] CommonItems1;
public string[] SelectedItems;
public string[] CommonItems2;
public string Footer;
public string RootTag;
public string TestTag;
public string[] CommonItems;
public string[] TestItems;
[XmlIgnore]
public Config.Entities.MetersKind MetersKind;
@@ -47,23 +47,24 @@ namespace TBF.BenchControl.Output.FileWriters.Xml
DestinationPath2 = string.Empty;
YearFolders = YearFolders.FourDigit;
MonthFolders = MonthFolders.Digit;
DayFolders = DayFolders.Digit;
DayFolders = DayFolders.Digit;
FileNameFormat = "{0:yyMMdd-HHmm}-{2:D2}.xml";
Separator = Separator.None;
Header = string.Empty;
Footer = string.Empty;
Culture = Culture.EN;
Header = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>";
RootTag = "gwzPruefung";
TestTag = "prueflauf";
}
public string ToString(int i)
{
return string.Format("Name={0}, Path={1}, Y={2}, M={3}, D={4}, FNameFmt={5}, Separator={6}",
return string.Format("Name={0}, Path={1}, Y={2}, M={3}, D={4}, FNameFmt={5}, Culture={6}",
Name,
DestinationPath,
YearFolders,
MonthFolders,
DayFolders,
FileNameFormat,
Separator);
Culture);
}
}
}
@@ -30,10 +30,8 @@ namespace TBF.BenchControl.Output.FileWriters.Xml
}
string header;
string[] commonItems1;
string[] commonItems;
string[] testItems;
string[] commonItems2;
string footer;
public WriterCfgCtrl()
{
@@ -43,21 +41,14 @@ namespace TBF.BenchControl.Output.FileWriters.Xml
private void WriterCfgCtrl_Load(object sender, EventArgs e)
{
for (Separator s = 0; s < Separator.Count; s++) separatorComboBox.Items.Add(s.ToString());
for (YearFolders s = 0; s < YearFolders.Count; s++) yearFoldersComboBox.Items.Add(s.ToString());
for (MonthFolders s = 0; s < MonthFolders.Count; s++) monthFoldersComboBox.Items.Add(s.ToString());
for (DayFolders s = 0; s < DayFolders.Count; s++) dayFoldersComboBox.Items.Add(s.ToString());
for (int i = 0; i < (int)Separator.Count; i++)
{
separatorComboBox.Items.Add(((Separator)i).ToString());
}
for (Culture s = 0; s < Culture.Count; s++) cultureComboBox.Items.Add(s.ToString());
header = config.Header;
commonItems1 = config.CommonItems1;
testItems = config.SelectedItems;
commonItems2 = config.CommonItems2;
footer = config.Footer;
commonItems = config.CommonItems;
testItems = config.TestItems;
Redraw();
}
@@ -71,12 +62,12 @@ namespace TBF.BenchControl.Output.FileWriters.Xml
monthFoldersLabel.Text = "Month folders";
dayFoldersLabel.Text = "Day folders";
fileNameFmtLabel.Text = "File name format";
separatorLabel.Text = "Separator";
cultureLabel.Text = "Culture";
headerButton.Text = Strings.Header;
commonItemsButton1.Text = "Common items 1";
testItemsButton.Text = "Test items";
commonItemsButton2.Text = "Common items 2";
footerButton.Text = Strings.Footer;
rootTagLabel.Text = "Root tag";
commonItemsButton.Text = "Common items";
testTagLabel.Text = "Test tag";
testItemsButton.Text = "Test items";
}
public void Closing()
@@ -94,7 +85,9 @@ namespace TBF.BenchControl.Output.FileWriters.Xml
monthFoldersComboBox.Text = config.MonthFolders.ToString();
dayFoldersComboBox.Text = config.DayFolders.ToString();
fileNameFmtTextBox.Text = config.FileNameFormat;
separatorComboBox.Text = config.Separator.ToString();
cultureComboBox.Text = config.Culture.ToString();
rootTagTextBox.Text = config.RootTag;
testTagTextBox.Text = config.TestTag;
}
public void Unlock()
@@ -108,12 +101,12 @@ namespace TBF.BenchControl.Output.FileWriters.Xml
monthFoldersComboBox.Enabled = true;
dayFoldersComboBox.Enabled = true;
fileNameFmtTextBox.Enabled = true;
separatorComboBox.Enabled = true;
cultureComboBox.Enabled = true;
headerButton.Enabled = true;
commonItemsButton1.Enabled = true;
testItemsButton.Enabled = true;
commonItemsButton2.Enabled = true;
footerButton.Enabled = true;
rootTagTextBox.Enabled = true;
commonItemsButton.Enabled = true;
testTagTextBox.Enabled = true;
testItemsButton.Enabled = true;
}
public CfgUpdateFlags VerifyCfg(ref string message)
@@ -138,11 +131,24 @@ namespace TBF.BenchControl.Output.FileWriters.Xml
message += Environment.NewLine + "Invalid day folder selection";
}
if (!separatorComboBox.Items.Contains(separatorComboBox.Text))
if (!cultureComboBox.Items.Contains(cultureComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Invalid separator";
message += Environment.NewLine + "Invalid culture";
}
if (string.IsNullOrEmpty(rootTagTextBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Root tag field is empty";
}
if (string.IsNullOrEmpty(testTagTextBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Test tag field is empty";
}
return flags;
}
@@ -208,48 +214,47 @@ namespace TBF.BenchControl.Output.FileWriters.Xml
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
for (Separator i = 0; i < Separator.Count; i++)
for (Culture i = 0; i < Culture.Count; i++)
{
if (i.ToString().Equals(separatorComboBox.Text) && (config.Separator != i))
if (i.ToString().Equals(cultureComboBox.Text) && (config.Culture != i))
{
config.Separator = i;
config.Culture = i;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
break;
}
}
if (config.Header != header)
{
config.Header = header;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
if (config.CommonItems1 != commonItems1)
{
config.CommonItems1 = commonItems1;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
if (config.SelectedItems != testItems)
{
config.SelectedItems = testItems;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
if (config.CommonItems2 != commonItems2)
if (config.RootTag != rootTagTextBox.Text)
{
config.CommonItems2 = commonItems2;
config.RootTag = rootTagTextBox.Text;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
if (config.CommonItems != commonItems)
{
config.CommonItems = commonItems;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
if (config.Footer != footer)
{
config.Footer = footer;
if (config.TestTag != testTagTextBox.Text)
{
config.TestTag = testTagTextBox.Text;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
if (config.TestItems != testItems)
{
config.TestItems = testItems;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
if ((flags & CfgUpdateFlags.InvokeCfgChange) != 0)
{
@@ -273,12 +278,12 @@ namespace TBF.BenchControl.Output.FileWriters.Xml
}
}
private void commonItemsButton1_Click(object sender, EventArgs e)
private void commonItemsButton_Click(object sender, EventArgs e)
{
Results.Forms.ResultsConfigDlg dlg = new Results.Forms.ResultsConfigDlg()
{
MetersKind = config.MetersKind,
SelectedItems = Results.WMeterRsltItemSpec.FromStrArray(commonItems1),
SelectedItems = Results.WMeterRsltItemSpec.FromStrArray(commonItems),
AvailableItems = new List<Results.WMeterRsltItemSpec>()
};
@@ -286,27 +291,10 @@ namespace TBF.BenchControl.Output.FileWriters.Xml
if (dlg.ShowDialog() == DialogResult.OK)
{
commonItems1 = Results.WMeterRsltItemSpec.ToStrArray(dlg.SelectedItems);
commonItems = Results.WMeterRsltItemSpec.ToStrArray(dlg.SelectedItems);
}
}
private void commonItemsButton2_Click(object sender, EventArgs e)
{
Results.Forms.ResultsConfigDlg dlg = new Results.Forms.ResultsConfigDlg()
{
MetersKind = config.MetersKind,
SelectedItems = Results.WMeterRsltItemSpec.FromStrArray(commonItems2),
AvailableItems = new List<Results.WMeterRsltItemSpec>()
};
foreach (var v in Results.WMeterRsltItemSpec.AllItems) dlg.AvailableItems.Add(v);
if (dlg.ShowDialog() == DialogResult.OK)
{
commonItems2 = Results.WMeterRsltItemSpec.ToStrArray(dlg.SelectedItems);
}
}
private void testItemsButton_Click(object sender, EventArgs e)
{
Results.Forms.ResultsConfigDlg dlg = new Results.Forms.ResultsConfigDlg(true)
@@ -324,15 +312,6 @@ namespace TBF.BenchControl.Output.FileWriters.Xml
}
}
private void footerButton_Click(object sender, EventArgs e)
{
HeaderFooterDlg dlg = new HeaderFooterDlg(false, string.IsNullOrEmpty(footer) ? string.Empty : footer.Replace("~", Environment.NewLine));
if (dlg.ShowDialog() == DialogResult.OK)
{
footer = dlg.EditedText.Replace(Environment.NewLine, "~");
}
}
#region Configuration Change Handling
public static void OnCmdResponse(object sender, CmdResponseArgs args)
@@ -37,8 +37,8 @@ namespace TBF.BenchControl.Output.FileWriters.Xml
this.destinationTextBox = new System.Windows.Forms.TextBox();
this.destinationLabel = new System.Windows.Forms.Label();
this.destinationButton = new System.Windows.Forms.Button();
this.separatorLabel = new System.Windows.Forms.Label();
this.separatorComboBox = new System.Windows.Forms.ComboBox();
this.cultureLabel = new System.Windows.Forms.Label();
this.cultureComboBox = new System.Windows.Forms.ComboBox();
this.testItemsButton = new System.Windows.Forms.Button();
this.yearFoldersLabel = new System.Windows.Forms.Label();
this.monthFoldersLabel = new System.Windows.Forms.Label();
@@ -52,9 +52,11 @@ namespace TBF.BenchControl.Output.FileWriters.Xml
this.fileNameFmtTextBox = new System.Windows.Forms.TextBox();
this.fileNameFmtLabel = new System.Windows.Forms.Label();
this.headerButton = new System.Windows.Forms.Button();
this.footerButton = new System.Windows.Forms.Button();
this.commonItemsButton1 = new System.Windows.Forms.Button();
this.commonItemsButton2 = new System.Windows.Forms.Button();
this.commonItemsButton = new System.Windows.Forms.Button();
this.rootTagTextBox = new System.Windows.Forms.TextBox();
this.rootTagLabel = new System.Windows.Forms.Label();
this.testTagLabel = new System.Windows.Forms.Label();
this.testTagTextBox = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// nameTextBox
@@ -111,31 +113,31 @@ namespace TBF.BenchControl.Output.FileWriters.Xml
this.destinationButton.UseVisualStyleBackColor = true;
this.destinationButton.Click += new System.EventHandler(this.destinationButton_Click);
//
// separatorLabel
// cultureLabel
//
this.separatorLabel.AutoSize = true;
this.separatorLabel.Location = new System.Drawing.Point(17, 184);
this.separatorLabel.Name = "separatorLabel";
this.separatorLabel.Size = new System.Drawing.Size(53, 13);
this.separatorLabel.TabIndex = 17;
this.separatorLabel.Text = "Separator";
this.cultureLabel.AutoSize = true;
this.cultureLabel.Location = new System.Drawing.Point(17, 184);
this.cultureLabel.Name = "cultureLabel";
this.cultureLabel.Size = new System.Drawing.Size(42, 13);
this.cultureLabel.TabIndex = 17;
this.cultureLabel.Text = "Cullture";
//
// separatorComboBox
// cultureComboBox
//
this.separatorComboBox.Enabled = false;
this.separatorComboBox.FormattingEnabled = true;
this.separatorComboBox.Location = new System.Drawing.Point(108, 181);
this.separatorComboBox.Name = "separatorComboBox";
this.separatorComboBox.Size = new System.Drawing.Size(146, 21);
this.separatorComboBox.TabIndex = 18;
this.cultureComboBox.Enabled = false;
this.cultureComboBox.FormattingEnabled = true;
this.cultureComboBox.Location = new System.Drawing.Point(108, 181);
this.cultureComboBox.Name = "cultureComboBox";
this.cultureComboBox.Size = new System.Drawing.Size(146, 21);
this.cultureComboBox.TabIndex = 18;
//
// testItemsButton
//
this.testItemsButton.Enabled = false;
this.testItemsButton.Location = new System.Drawing.Point(108, 255);
this.testItemsButton.Location = new System.Drawing.Point(108, 294);
this.testItemsButton.Name = "testItemsButton";
this.testItemsButton.Size = new System.Drawing.Size(146, 23);
this.testItemsButton.TabIndex = 21;
this.testItemsButton.TabIndex = 25;
this.testItemsButton.Text = "Test items";
this.testItemsButton.UseVisualStyleBackColor = true;
this.testItemsButton.Click += new System.EventHandler(this.testItemsButton_Click);
@@ -241,7 +243,7 @@ namespace TBF.BenchControl.Output.FileWriters.Xml
// headerButton
//
this.headerButton.Enabled = false;
this.headerButton.Location = new System.Drawing.Point(108, 205);
this.headerButton.Location = new System.Drawing.Point(108, 204);
this.headerButton.Name = "headerButton";
this.headerButton.Size = new System.Drawing.Size(146, 23);
this.headerButton.TabIndex = 19;
@@ -249,46 +251,60 @@ namespace TBF.BenchControl.Output.FileWriters.Xml
this.headerButton.UseVisualStyleBackColor = true;
this.headerButton.Click += new System.EventHandler(this.headerButton_Click);
//
// footerButton
// commonItemsButton
//
this.footerButton.Enabled = false;
this.footerButton.Location = new System.Drawing.Point(108, 305);
this.footerButton.Name = "footerButton";
this.footerButton.Size = new System.Drawing.Size(146, 23);
this.footerButton.TabIndex = 23;
this.footerButton.Text = "Footer";
this.footerButton.UseVisualStyleBackColor = true;
this.footerButton.Click += new System.EventHandler(this.footerButton_Click);
this.commonItemsButton.Enabled = false;
this.commonItemsButton.Location = new System.Drawing.Point(108, 249);
this.commonItemsButton.Name = "commonItemsButton";
this.commonItemsButton.Size = new System.Drawing.Size(146, 23);
this.commonItemsButton.TabIndex = 22;
this.commonItemsButton.Text = "Common items";
this.commonItemsButton.UseVisualStyleBackColor = true;
this.commonItemsButton.Click += new System.EventHandler(this.commonItemsButton_Click);
//
// commonItemsButton1
// rootTagTextBox
//
this.commonItemsButton1.Enabled = false;
this.commonItemsButton1.Location = new System.Drawing.Point(108, 230);
this.commonItemsButton1.Name = "commonItemsButton1";
this.commonItemsButton1.Size = new System.Drawing.Size(146, 23);
this.commonItemsButton1.TabIndex = 20;
this.commonItemsButton1.Text = "Common items 1";
this.commonItemsButton1.UseVisualStyleBackColor = true;
this.commonItemsButton1.Click += new System.EventHandler(this.commonItemsButton1_Click);
this.rootTagTextBox.Enabled = false;
this.rootTagTextBox.Location = new System.Drawing.Point(108, 228);
this.rootTagTextBox.Name = "rootTagTextBox";
this.rootTagTextBox.Size = new System.Drawing.Size(146, 20);
this.rootTagTextBox.TabIndex = 21;
//
// commonItemsButton2
// rootTagLabel
//
this.commonItemsButton2.Enabled = false;
this.commonItemsButton2.Location = new System.Drawing.Point(108, 280);
this.commonItemsButton2.Name = "commonItemsButton2";
this.commonItemsButton2.Size = new System.Drawing.Size(146, 23);
this.commonItemsButton2.TabIndex = 22;
this.commonItemsButton2.Text = "Common items 2";
this.commonItemsButton2.UseVisualStyleBackColor = true;
this.commonItemsButton2.Click += new System.EventHandler(this.commonItemsButton2_Click);
this.rootTagLabel.AutoSize = true;
this.rootTagLabel.Location = new System.Drawing.Point(17, 231);
this.rootTagLabel.Name = "rootTagLabel";
this.rootTagLabel.Size = new System.Drawing.Size(48, 13);
this.rootTagLabel.TabIndex = 20;
this.rootTagLabel.Text = "Root tag";
//
// testTagLabel
//
this.testTagLabel.AutoSize = true;
this.testTagLabel.Location = new System.Drawing.Point(17, 276);
this.testTagLabel.Name = "testTagLabel";
this.testTagLabel.Size = new System.Drawing.Size(46, 13);
this.testTagLabel.TabIndex = 23;
this.testTagLabel.Text = "Test tag";
//
// testTagTextBox
//
this.testTagTextBox.Enabled = false;
this.testTagTextBox.Location = new System.Drawing.Point(108, 273);
this.testTagTextBox.Name = "testTagTextBox";
this.testTagTextBox.Size = new System.Drawing.Size(146, 20);
this.testTagTextBox.TabIndex = 24;
//
// WriterCfgCtrl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.commonItemsButton2);
this.Controls.Add(this.commonItemsButton1);
this.Controls.Add(this.footerButton);
this.Controls.Add(this.testTagLabel);
this.Controls.Add(this.testTagTextBox);
this.Controls.Add(this.rootTagLabel);
this.Controls.Add(this.rootTagTextBox);
this.Controls.Add(this.commonItemsButton);
this.Controls.Add(this.headerButton);
this.Controls.Add(this.fileNameFmtTextBox);
this.Controls.Add(this.fileNameFmtLabel);
@@ -302,8 +318,8 @@ namespace TBF.BenchControl.Output.FileWriters.Xml
this.Controls.Add(this.monthFoldersLabel);
this.Controls.Add(this.yearFoldersLabel);
this.Controls.Add(this.testItemsButton);
this.Controls.Add(this.separatorComboBox);
this.Controls.Add(this.separatorLabel);
this.Controls.Add(this.cultureComboBox);
this.Controls.Add(this.cultureLabel);
this.Controls.Add(this.destinationButton);
this.Controls.Add(this.destinationTextBox);
this.Controls.Add(this.destinationLabel);
@@ -326,8 +342,8 @@ namespace TBF.BenchControl.Output.FileWriters.Xml
private System.Windows.Forms.TextBox destinationTextBox;
private System.Windows.Forms.Label destinationLabel;
private System.Windows.Forms.Button destinationButton;
private System.Windows.Forms.Label separatorLabel;
private System.Windows.Forms.ComboBox separatorComboBox;
private System.Windows.Forms.Label cultureLabel;
private System.Windows.Forms.ComboBox cultureComboBox;
private System.Windows.Forms.Button testItemsButton;
private System.Windows.Forms.Label yearFoldersLabel;
private System.Windows.Forms.Label monthFoldersLabel;
@@ -340,9 +356,11 @@ namespace TBF.BenchControl.Output.FileWriters.Xml
private System.Windows.Forms.Label destination2Label;
private System.Windows.Forms.TextBox fileNameFmtTextBox;
private System.Windows.Forms.Label fileNameFmtLabel;
private System.Windows.Forms.Button headerButton;
private System.Windows.Forms.Button footerButton;
private System.Windows.Forms.Button commonItemsButton1;
private System.Windows.Forms.Button commonItemsButton2;
private System.Windows.Forms.Button headerButton;
private System.Windows.Forms.Button commonItemsButton;
private System.Windows.Forms.TextBox rootTagTextBox;
private System.Windows.Forms.Label rootTagLabel;
private System.Windows.Forms.Label testTagLabel;
private System.Windows.Forms.TextBox testTagTextBox;
}
}
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
/// Copyright (c) 2013-2017 Sensus Metering Systems
///
using System.Collections.Generic;
using TBF.BenchControl.GenericDevices;
@@ -18,8 +18,7 @@ namespace TBF.BenchControl
public IValve StartValve;
public IDiverter Diverter;
public ITempMeter TempDiv;
public IBalance Balance;
public IValve EmptyTankValve;
public IScale Scale;
public IList<IValve> ValvesOpen;
public IList<IValve> ValvesClose;
@@ -44,8 +43,7 @@ namespace TBF.BenchControl
StartValve = (IValve)TbfComponents.FindComponent(entity.StartValve, components);
Diverter = (IDiverter)TbfComponents.FindComponent(entity.Diverter, components);
TempDiv = (ITempMeter)TbfComponents.FindComponent(entity.TempDiv, components);
Balance = (IBalance)TbfComponents.FindComponent(entity.Balance, components);
EmptyTankValve = (IValve)TbfComponents.FindComponent(entity.EmptyTankValve, components);
Scale = (IScale)TbfComponents.FindComponent(entity.Scale, components);
string[] vOpen = entity.ValvesOpen.Split(new char[] { ';' });
ValvesOpen = new List<IValve>();
@@ -63,7 +61,7 @@ namespace TBF.BenchControl
(RegulValve != null) ? RegulValve.Name : "---",
(FlowMeter != null) ? FlowMeter.Name : "---",
(Diverter != null) ? Diverter.Name : "---",
(Balance != null) ? Balance.Name : "---");
(Scale != null) ? Scale.Name : "---");
}
}
}
@@ -78,7 +78,7 @@ namespace TBF.BenchControl.ResultsPrinters.Basic
HdrTop = TitleY + 60;
BodyTop = HdrTop + 160;
if (batch.WaterMeters[0].Compound())
if (batch.WaterMeters.Count > 0 && batch.WaterMeters[0].Compound())
{
rsltItems = Results.ItemSpec.FromStrArray(Program.LocalSettings.RsltItems_Printer_CombinedWM);
}
@@ -100,12 +100,15 @@ namespace TBF.BenchControl.ResultsPrinters.Basic
}
int testsCount = 0;
foreach (var mtr in batch.WaterMeters[0].MeterTestRslts)
if (batch.WaterMeters.Count > 0)
{
if (mtr.Publish() == Config.Entities.Publish.Always) testsCount++;
foreach (var mtr in batch.WaterMeters[0].MeterTestRslts)
{
if (mtr.Publish() == Config.Entities.Publish.Always) testsCount++;
}
}
if (batch.WaterMeters[0].Compound()) testsCount /= 3;
if (batch.WaterMeters.Count > 0 && batch.WaterMeters[0].Compound()) testsCount /= 3;
int wmSectionHeight = (testsCount + 4) * SpacingOne;
@@ -58,7 +58,7 @@ namespace TBF.BenchControl.ResultsPrinters.LabelPrinter
DefaultPageSettings.Landscape = (pageOrientation == PageOrientation.Landscape);
if (batch.WaterMeters[0].Compound())
if (batch.WaterMeters.Count > 0 && batch.WaterMeters[0].Compound())
{
rsltItems = Results.ItemSpec.FromStrArray(Program.LocalSettings.RsltItems_Printer_CombinedWM);
}
@@ -5,6 +5,7 @@ using System;
using System.Collections.Generic;
using log4net;
using Config.Entities;
using Results.Entities;
using TBF.UiBridge;
using TBF.BenchControl;
using TBF.BenchControl.Operations;
@@ -32,6 +33,7 @@ namespace TBF.BenchControl.Sequences
IList<Generic.ITestParams> simultWithEvacuationParams;
System.Windows.Forms.Form modelessDlg;
///
delegate void iPerlCommFormDlgt(MainSeq myRef, Generic.IComponentCfg cfg, IList<Test> tests, IList<Generic.ITestParams> multiTestParams);
@@ -64,7 +66,7 @@ namespace TBF.BenchControl.Sequences
log.Fatal("--------------------------------------");
}
}
///
void CloseIPerlCommForm()
{
UiBridge.Bridge.OnCloseModelessForm(this, null);
@@ -126,29 +128,29 @@ namespace TBF.BenchControl.Sequences
IntBox remainingTime = new IntBox();
State startNew = State.Create("MainSeq : Emptying tanks")
.AddOperation(checkUiOp);
IList<IValve> allEmptyingValves = new List<IValve>();
if (StateMachine.DrainValve1 != null) allEmptyingValves.Add(StateMachine.DrainValve1);
if (StateMachine.DrainValve2 != null) allEmptyingValves.Add(StateMachine.DrainValve2);
if (StateMachine.DrainValve3 != null) allEmptyingValves.Add(StateMachine.DrainValve3);
IList<IValve> allDrainValves = new List<IValve>();
if (StateMachine.DrainValve1 != null) allDrainValves.Add(StateMachine.DrainValve1);
if (StateMachine.DrainValve2 != null) allDrainValves.Add(StateMachine.DrainValve2);
if (StateMachine.DrainValve3 != null) allDrainValves.Add(StateMachine.DrainValve3);
// Determine the tank emptying time (the maximum for all balances)
int balanceEmptyTime = 0;
if (StateMachine.Balance1 != null && StateMachine.Balance1.EmptyTimeSec > balanceEmptyTime)
int scaleDrainTime = 0;
if (StateMachine.Scale1 != null && StateMachine.Scale1.EmptyTimeSec > scaleDrainTime)
{
balanceEmptyTime = StateMachine.Balance1.EmptyTimeSec;
scaleDrainTime = StateMachine.Scale1.EmptyTimeSec;
}
if (StateMachine.Balance2 != null && StateMachine.Balance2.EmptyTimeSec > balanceEmptyTime)
if (StateMachine.Scale2 != null && StateMachine.Scale2.EmptyTimeSec > scaleDrainTime)
{
balanceEmptyTime = StateMachine.Balance2.EmptyTimeSec;
scaleDrainTime = StateMachine.Scale2.EmptyTimeSec;
}
if (StateMachine.Balance3 != null && StateMachine.Balance3.EmptyTimeSec > balanceEmptyTime)
if (StateMachine.Scale3 != null && StateMachine.Scale3.EmptyTimeSec > scaleDrainTime)
{
balanceEmptyTime = StateMachine.Balance3.EmptyTimeSec;
scaleDrainTime = StateMachine.Scale3.EmptyTimeSec;
}
if (balanceEmptyTime > 0)
if (scaleDrainTime > 0)
{
startNew.AddOperation(new TimerOp(balanceEmptyTime, remainingTime))
.AddOperation(StateMachine.ControlBoard.SetValvesOp(allEmptyingValves, null));
startNew.AddOperation(new TimerOp(scaleDrainTime, remainingTime))
.AddOperation(StateMachine.ControlBoard.SetValvesOp(allDrainValves, null));
}
startNew.EnterState();
@@ -177,7 +179,7 @@ namespace TBF.BenchControl.Sequences
//--------------------------------------------------------------------------------------------
State stopEmptying = State.Create("MainSeq : Stop emptying of water tanks")
.AddOperation(checkUiOp)
.AddOperation(StateMachine.ControlBoard.SetValvesOp(null, allEmptyingValves))
.AddOperation(StateMachine.ControlBoard.SetValvesOp(null, allDrainValves))
.EnterState();
do
{
@@ -190,9 +192,9 @@ namespace TBF.BenchControl.Sequences
//--------------------------------------------------------------------------------------------
State taraAll = State.Create("MainSeq : Reset all balances").AddOperation(checkUiOp);
DoubleBox tara = new DoubleBox(0);
if (StateMachine.Balance1 != null) taraAll.AddOperation(StateMachine.Balance1.TaringOp(ref tara));
if (StateMachine.Balance2 != null) taraAll.AddOperation(StateMachine.Balance2.TaringOp(ref tara));
if (StateMachine.Balance3 != null) taraAll.AddOperation(StateMachine.Balance3.TaringOp(ref tara));
if (StateMachine.Scale1 != null) taraAll.AddOperation(StateMachine.Scale1.TaringOp(ref tara));
if (StateMachine.Scale2 != null) taraAll.AddOperation(StateMachine.Scale2.TaringOp(ref tara));
if (StateMachine.Scale3 != null) taraAll.AddOperation(StateMachine.Scale3.TaringOp(ref tara));
taraAll.EnterState();
do
{
@@ -219,106 +221,67 @@ namespace TBF.BenchControl.Sequences
//--------------------------------------------------------------------------------------------
select_procedure:
/// Make sure the CycleBeginForm is closed (after an abnormal procedure/test end, etc.)
CloseBeginForm();
selection = MakeSelection(MKSelContext.ProcedureNotSelected);
//--------------------------------
Bridge.Bench2UI(ButtonsEtc.StopBtnEn);
StateMachine.LoadProcedure(false);
if (StateMachine.Procedure == null) goto select_procedure;
CloseBeginForm(); /// Make sure the CycleBeginForm is closed (after an abnormal end, etc.)
do
{
selection = MakeSelection(MKSelContext.ProcedureNotSelected);
StateMachine.LoadProcedure(false);
}
while (StateMachine.Procedure == null); /// Make sure a valid procedure is selected
///
/// Procedure selected at this point, a new batch was started
///
StateMachine.LoadProcedureParams(StateMachine.Procedure);
StateMachine.LoadProcedureParams(StateMachine.Procedure);
Bridge.Bench2UI(ButtonsEtc.StopBtnEn); /// Enable STOP button
int newBatchNr = Program.LocalSettings.BatchNr;
log.FatalFormat("New measurement session started: batch = {0}, procedure = {1}", newBatchNr, StateMachine.Procedure.Name);
///
/// Prepare new water meters
///
foreach (var wm in WaterMeters) wm.ClearData(); /// Clean water meter data
bool compound = (StateMachine.Procedure.MetersKind == MetersKind.Combined);
bool heatMeters = (StateMachine.Procedure.MetersKind == MetersKind.HeatMeter);
int waterMetersCount = Math.Min(WaterMeters.Count, heatMeters ? Config.Data.HeatMetersCount : (compound ? Config.Data.CompoundWMsCount : Config.Data.WMsCount));
///
Results.Entities.WaterMeterData[] waterMeterData = new Results.Entities.WaterMeterData[waterMetersCount];
///
int[] waterMeterParts = new int[waterMetersCount];
for (int wmNr = 0; wmNr < waterMetersCount; wmNr++)
if (selection == Selection.RestoreBatch)
{
int ix = compound ? (2 * wmNr) : wmNr;
waterMeterParts[wmNr] = Utils.PartNr(wmNr + 1, compound);
waterMeterData[wmNr] = new Results.Entities.WaterMeterData()
{
ProductName = WaterMeters[ix].ProductName,
Producer = WaterMeters[ix].Producer,
L = WaterMeters[ix].L,
DN = WaterMeters[ix].DN,
Mounting = WaterMeters[ix].Mounting,
Q4_Qmax = WaterMeters[ix].Q4_Qmax,
Q3_Qn = WaterMeters[ix].Q3_Qn,
Q2_Qt = WaterMeters[ix].Q2_Qt,
Q1_Qmin = WaterMeters[ix].Q1_Qmin,
MetrologicalClass = WaterMeters[ix].MetrologicalClass,
TemperatureClass = WaterMeters[ix].TemperatureClass,
PressureLossClass = WaterMeters[ix].PressureLossClass,
MaxAdmissiblePressure = WaterMeters[ix].MaxAdmissiblePressure,
FlowProfileSensitivityClass = WaterMeters[ix].FlowProfileSensitivityClass,
ApprovalInfo = WaterMeters[ix].ApprovalInfo,
Certificate = WaterMeters[ix].Certificate,
PulsesPerLtr = WaterMeters[ix].PulsesPerLtr,
Text1 = WaterMeters[ix].Text1,
Text2 = WaterMeters[ix].Text2,
Text3 = WaterMeters[ix].Text3,
Text4 = WaterMeters[ix].Text4,
Text5 = WaterMeters[ix].Text5,
Compound = compound,
HeatMeter = heatMeters,
};
if (compound)
BatchRslts = CreateNewBatchResults(newBatchNr, StateMachine.Procedure);
RestoreBatchResults(TBF.UiBridge.Bridge.BatchNr, ref BatchRslts); /// pass the original batch number of the batch to be restored
}
else if (selection == Selection.Custom)
{
for (int i = StateMachine.Procedure.Tests.Count - 1; i >= 0; i--)
{
int auxIx = 2 * wmNr + 1;
waterMeterData[wmNr].ProducerAux = WaterMeters[auxIx].Producer;
waterMeterData[wmNr].Q3_Qn_Aux = WaterMeters[auxIx].Q3_Qn;
waterMeterData[wmNr].MetrologicalClassAux = WaterMeters[auxIx].MetrologicalClass;
waterMeterData[wmNr].ApprovalInfoAux = WaterMeters[auxIx].ApprovalInfo;
if (StateMachine.Procedure.Tests[i].Name.ToLower().Contains("write") ||
StateMachine.Procedure.Tests[i].Name.ToLower().Contains("reset"))
{
StateMachine.Procedure.Tests.RemoveAt(i);
}
}
#if ORACLE_DB
BenchControl.WaterMeters.iPerl.WaterMeter iPerl = WaterMeters[wmNr] as BenchControl.WaterMeters.iPerl.WaterMeter;
if (iPerl != null)
BatchRslts = CreateNewBatchResults(newBatchNr, StateMachine.Procedure);
for (int i = StateMachine.Procedure.Tests.Count - 1; i >= 0; i--)
{
waterMeterData[wmNr].WMTypeId = iPerl.WMType_ID;
waterMeterData[wmNr].WMTypeRev = iPerl.WMType_Rev;
if (StateMachine.Procedure.Tests[i].Name.ToLower().Contains("adj"))
{
StateMachine.Procedure.Tests.RemoveAt(i);
}
}
#endif
}
else
{
BatchRslts = CreateNewBatchResults(newBatchNr, StateMachine.Procedure);
}
///
/// Prepare empty results
///
BatchRslts = Results.BatchResults.NewFromProcedure(Program.LocalSettings.BatchNr,
(BenchInfo != null) ? BenchInfo.TestBenchId : 1,
Users.GlobalData.CurrentUser.UserName, Users.GlobalData.CurrentUser.Number, Program.Version,
StateMachine.Procedure, waterMeterData, waterMeterParts);
StateMachine.CycleStartTimeStamp = BatchRslts.Batch.StartTime;
Bridge.OnProcedureSelected(this, new ProcedureSelectedEventArgs(StateMachine.Procedure));
/// Display 'Cycle Begin Form'
if (OpenCycleBeginForm()) goto stop;
///
/// Display 'Cycle Begin Form' in case of a normal batch (not a restored batch)
///
if (selection != Selection.RestoreBatch && selection != Selection.Custom)
{
if (OpenCycleBeginForm()) goto stop;
}
/// Find purge suquences
TransitionSequence purgeBegin = null;
@@ -335,9 +298,11 @@ namespace TBF.BenchControl.Sequences
{
goto assume_bench_filled;
}
else if (selection == Selection.Cycle && benchFilled)
else if ((selection == Selection.Cycle && benchFilled) || (selection == Selection.RestoreBatch))
{
//--------------------------------
///
/// Always ask a question in case of a restored batch
///
State.Create("MainSeq : Answer a question")
.AddOperation(new Operations.AskYesNoOp(Strings.Fill_with_water))
.AddOperation(checkUiOp)
@@ -409,6 +374,35 @@ namespace TBF.BenchControl.Sequences
}
modelessDlg = null;
if (selection == Selection.Custom)
{
/// Load existing data from databases
Results.DBase.Databases.Clear();
try { Results.DBase.Databases.Add(new Results.DBase("SERVER=10.42.128.197; DATABASE=st-wr10-r; UID=vysledky; PASSWORD=GAqx76QUB6NbnpZP; CHARSET=utf8;", "WR10")); }
catch (Exception exc) { log.ErrorFormat("Cannot open WR10 result database: {0}", exc.Message); }
try { Results.DBase.Databases.Add(new Results.DBase("SERVER=10.42.128.98; DATABASE=st-wr11-r; UID=vysledky; PASSWORD=GAqx76QUB6NbnpZP; CHARSET=utf8;", "WR11")); }
catch (Exception exc) { log.ErrorFormat("Cannot open WR11 result database: {0}", exc.Message); }
try { Results.DBase.Databases.Add(new Results.DBase("SERVER=10.42.128.152; DATABASE=st-wr13-r; UID=vysledky; PASSWORD=GAqx76QUB6NbnpZP; CHARSET=utf8;", "WR13")); }
catch (Exception exc) { log.ErrorFormat("Cannot open WR13 result database: {0}", exc.Message); }
try { Results.DBase.Databases.Add(new Results.DBase("SERVER=10.42.128.63; DATABASE=st-wr15-r; UID=vysledky; PASSWORD=GAqx76QUB6NbnpZP; CHARSET=utf8;", "WR15")); }
catch (Exception exc) { log.ErrorFormat("Cannot open WR15 result database: {0}", exc.Message); }
for (int i = 0; i < BatchRslts.WaterMeters.Length; i++)
{
WaterMeter newWM = BatchRslts.WaterMeters[i];
for (int j = 0; j < Results.DBase.Count; j++)
{
NHibernate.ISession session = Results.DBase.Databases[j].OpenSession();
IList<WaterMeter> watermeters = session.QueryOver<WaterMeter>().Where(x => (x.SerialNr == newWM.SerialNr)).List();
if (watermeters.Count > 0)
{
BatchRslts.WaterMeters[i].CopyContentFrom(watermeters[watermeters.Count - 1]); /// Copy results from the last occurance of the watermeter
}
}
}
}
}
@@ -417,7 +411,7 @@ namespace TBF.BenchControl.Sequences
benchFilled = true;
Bridge.Bench2UI(ButtonsEtc.ShowBenchFilled);
if (selection != Selection.PurgeBegin)
if (selection != Selection.PurgeBegin && selection != Selection.RestoreBatch && selection != Selection.Custom)
{
goto cycle_or_test_selected;
}
@@ -516,9 +510,9 @@ namespace TBF.BenchControl.Sequences
}
/// Update format for the water mass
Mass.Format = outPath.Balance.Format;
StartMass.Format = outPath.Balance.Format;
EndMass.Format = outPath.Balance.Format;
Mass.Format = outPath.Scale.Format;
StartMass.Format = outPath.Scale.Format;
EndMass.Format = outPath.Scale.Format;
//--------------------------------------------------------------
ITestMethod testMethodSequence = TbfComponents.FindComponent(test.Method) as ITestMethod;
@@ -658,9 +652,9 @@ namespace TBF.BenchControl.Sequences
}
/// Update format for the water mass
Mass.Format = outPath.Balance.Format;
StartMass.Format = outPath.Balance.Format;
EndMass.Format = outPath.Balance.Format;
Mass.Format = outPath.Scale.Format;
StartMass.Format = outPath.Scale.Format;
EndMass.Format = outPath.Scale.Format;
//--------------------------------------------------------------
ITestMethod testMethodSequence = TbfComponents.FindComponent(test.Method) as ITestMethod;
@@ -754,9 +748,9 @@ namespace TBF.BenchControl.Sequences
}
/// Update format for the water mass
Mass.Format = outPath.Balance.Format;
StartMass.Format = outPath.Balance.Format;
EndMass.Format = outPath.Balance.Format;
Mass.Format = outPath.Scale.Format;
StartMass.Format = outPath.Scale.Format;
EndMass.Format = outPath.Scale.Format;
ITestMethod testMethodSequence = TbfComponents.FindComponent(test.Method) as ITestMethod;
if (testMethodSequence != null && testMethodSequence.CanTest(StateMachine.Procedure.MetersKind))
@@ -903,11 +897,13 @@ namespace TBF.BenchControl.Sequences
summaryResults.Info(TestResult2CsvLine(tr));
}
Program.LocalSettings.BatchNr++;
Program.LocalSettings.Save();
log.FatalFormat("BatchNr = {0} (incremented)", Program.LocalSettings.BatchNr);
log.FatalFormat("Measurement session saved: batch = {0}, procedure = {1}, next batch nr. = {2}",
ProcessData.BatchRslts.Batch.BatchNr,
ProcessData.BatchRslts.Batch.ProcedureName,
Program.LocalSettings.BatchNr);
if (simultWithEvacuationCount > 0)
{
@@ -1040,33 +1036,24 @@ namespace TBF.BenchControl.Sequences
}
/// <summary>
/// Selection done in MakeSelection()
/// Return values of MakeSelection()
/// </summary>
public enum Selection
{
/// Handled inside MakeSelection()
None,
EmptyTank1,
EmptyTank2,
EmptyTank3,
CloseTank1,
CloseTank2,
CloseTank3,
CameraTest,
/// Used as return values
Cycle,
RestOfCycle,
Test,
Q1,
Q2,
Q3,
Stop,
PurgeBegin,
PurgeEnd,
public enum Selection
{
PurgeBegin,
PurgeEnd,
Break,
SaveResults,
}
Cycle,
RestOfCycle,
Test,
Q1,
Q2,
Q3,
SaveResults,
RestoreBatch,
Custom,
}
/// <summary>
/// Idle loop to make a procedure or test selection.
@@ -1074,21 +1061,22 @@ namespace TBF.BenchControl.Sequences
/// </summary>
/// <param name="context">Context where MakeSelection() is called</param>
/// <returns>
/// Selection.Cycle
/// Selection.PurgeBegin
/// Selection.PurgeEnd
/// Selection.Break
/// Selection.Cycle
/// Selection.Test
/// Selection.Q1
/// Selection.Q2
/// Selection.Q3
/// Selection.Stop
/// Selection.PurgeBegin
/// Selection.PurgeEnd
/// Selection.SaveResults
/// </returns>
private Selection MakeSelection(MKSelContext context)
{
/// Tank emptying valves states
bool emptying1 = false;
bool emptying2 = false;
bool emptying3 = false;
bool draining1 = false;
bool draining2 = false;
bool draining3 = false;
/// Measured masses to control emptying
DoubleBox mass1 = new DoubleBox();
@@ -1096,12 +1084,11 @@ namespace TBF.BenchControl.Sequences
DoubleBox mass3 = new DoubleBox();
IList<Event> e;
Selection selection;
while (true)
{
/// Display an appropriate activity message
if (emptying1 || emptying2 || emptying3)
if (draining1 || draining2 || draining3)
{
Bridge.OnActivity(this, Strings.Emptying_tank);
}
@@ -1118,7 +1105,7 @@ namespace TBF.BenchControl.Sequences
Bridge.Bench2UI(((context == MKSelContext.ProcedureNotSelected) ? ButtonsEtc.ProcedureCmbBoxEn : 0) |
ButtonsEtc.TestCmbBoxEn |
ButtonsEtc.StopBtnEn |
((emptying1 || emptying2 || emptying3) ? 0 :
((draining1 || draining2 || draining3) ? 0 :
(ButtonsEtc.StartCycleBtnEn |
ButtonsEtc.StartTestBtnsEn |
ButtonsEtc.PurgeBeginBtnEn |
@@ -1126,233 +1113,287 @@ namespace TBF.BenchControl.Sequences
ButtonsEtc.SensitivityTestBtnEn |
((Cameras.Count > 0) ? ButtonsEtc.CalibrationBtnEn : 0) |
ButtonsEtc.Break)) |
(((StateMachine.Balance1 != null) && (StateMachine.DrainValve1 != null) && !emptying1) ? ButtonsEtc.EmptyTankBtn1En : 0) |
(((StateMachine.Balance2 != null) && (StateMachine.DrainValve2 != null) && !emptying2) ? ButtonsEtc.EmptyTankBtn2En : 0) |
(((StateMachine.Balance3 != null) && (StateMachine.DrainValve3 != null) && !emptying3) ? ButtonsEtc.EmptyTankBtn3En : 0));
(((StateMachine.Scale1 != null) && (StateMachine.DrainValve1 != null) && !draining1) ? ButtonsEtc.DrainTankBtn1En : 0) |
(((StateMachine.Scale2 != null) && (StateMachine.DrainValve2 != null) && !draining2) ? ButtonsEtc.DrainTankBtn2En : 0) |
(((StateMachine.Scale3 != null) && (StateMachine.DrainValve3 != null) && !draining3) ? ButtonsEtc.DrainTankBtn3En : 0));
selection = Selection.None;
State.Create("MainSeq : Select an activity")
.AddOperation(checkUiOp)
.AddOperation((StateMachine.Balance1 != null) ? StateMachine.Balance1.ReadMassOp(ref mass1) : null)
.AddOperation((StateMachine.Balance2 != null) ? StateMachine.Balance2.ReadMassOp(ref mass2) : null)
.AddOperation((StateMachine.Balance3 != null) ? StateMachine.Balance3.ReadMassOp(ref mass3) : null)
.AddOperation((StateMachine.Scale1 != null) ? StateMachine.Scale1.ReadMassOp(ref mass1) : null)
.AddOperation((StateMachine.Scale2 != null) ? StateMachine.Scale2.ReadMassOp(ref mass2) : null)
.AddOperation((StateMachine.Scale3 != null) ? StateMachine.Scale3.ReadMassOp(ref mass3) : null)
.AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp())
.EnterState();
do
{
e = StateMachine.WaitRunDevsRunOps();
if (e.Contains(Event.Error)) goto error;
else if (e.Contains(Event.UiCmdStop)) selection = Selection.Stop;
else if (e.Contains(Event.UiCmdCameraTest)) selection = Selection.CameraTest;
else if (e.Contains(Event.UiCmdEmptyTank1)) selection = Selection.EmptyTank1;
else if (e.Contains(Event.UiCmdEmptyTank2)) selection = Selection.EmptyTank2;
else if (e.Contains(Event.UiCmdEmptyTank3)) selection = Selection.EmptyTank3;
else if (emptying1 && StateMachine.Balance1.IsEmpty(mass1.Val)) selection = Selection.CloseTank1;
else if (emptying2 && StateMachine.Balance2.IsEmpty(mass2.Val)) selection = Selection.CloseTank2;
else if (emptying3 && StateMachine.Balance3.IsEmpty(mass3.Val)) selection = Selection.CloseTank3;
else if (e.Contains(Event.UiCmdPurgeBegin)) return Selection.PurgeBegin; /// Value used to branch the code later on
else if (e.Contains(Event.UiCmdPurgeEnd)) return Selection.PurgeEnd;
else if (e.Contains(Event.UiCmdBreak) && context == MKSelContext.InsideProcedure) return Selection.Break;
else if (e.Contains(Event.UiCmdStartTest)) return Selection.Test;
else if (e.Contains(Event.UiCmdStartQ1)) return Selection.Q1;
else if (e.Contains(Event.UiCmdStartQ2)) return Selection.Q2;
else if (e.Contains(Event.UiCmdStartQ3)) return Selection.Q3;
else if (e.Contains(Event.UiCmdStartCycle)) return Selection.Cycle;
else if (e.Contains(Event.UiCmdAcceptResults)) return Selection.SaveResults;
}
while (selection == Selection.None);
/// Handled inside MakeSelection() inside the selection loop
if (e.Contains(Event.Error)) break;
if (e.Contains(Event.UiCmdStop)) break;
if (e.Contains(Event.UiCmdDrainTank1)) break;
if (e.Contains(Event.UiCmdDrainTank2)) break;
if (e.Contains(Event.UiCmdDrainTank3)) break;
if (draining1 && StateMachine.Scale1.IsEmpty(mass1.Val)) break;
if (draining2 && StateMachine.Scale2.IsEmpty(mass2.Val)) break;
if (draining3 && StateMachine.Scale3.IsEmpty(mass3.Val)) break;
if (selection == Selection.CameraTest)
{
CameraTest();
/// Quit the selection loop and leave MakeSelection()
if (e.Contains(Event.UiCmdBreak) && context == MKSelContext.InsideProcedure) return Selection.Break;
if (e.Contains(Event.UiCmdPurgeBegin)) return Selection.PurgeBegin;
if (e.Contains(Event.UiCmdPurgeEnd)) return Selection.PurgeEnd;
if (e.Contains(Event.UiCmdStartCycle)) return Selection.Cycle;
if (e.Contains(Event.UiCmdStartTest)) return Selection.Test;
if (e.Contains(Event.UiCmdStartQ1)) return Selection.Q1;
if (e.Contains(Event.UiCmdStartQ2)) return Selection.Q2;
if (e.Contains(Event.UiCmdStartQ3)) return Selection.Q3;
if (e.Contains(Event.UiCmdAcceptResults)) return Selection.SaveResults;
if (e.Contains(Event.UiCmdReloadBatch)) return Selection.RestoreBatch;
if (e.Contains(Event.UiCmdCustom)) return Selection.Custom;
}
else if (selection == Selection.Stop)
while (true);
if (e.Contains(Event.Error))
{
if (emptying1 || emptying2 || emptying3)
///------------------------------------
Bridge.OnActivity(this, Strings.Error);
///------------------------------------
State.Create("MainSeq : ERROR state")
.EnterState();
while (true) StateMachine.WaitRunDevsRunOps(); /// Endless loop
}
else if (e.Contains(Event.UiCmdStop))
{
if (draining1 || draining2 || draining3)
{
IList<IValve> valvesClose = new List<IValve>();
if (emptying1) valvesClose.Add(StateMachine.DrainValve1);
if (emptying2) valvesClose.Add(StateMachine.DrainValve2);
if (emptying3) valvesClose.Add(StateMachine.DrainValve3);
if (draining1) valvesClose.Add(StateMachine.DrainValve1);
if (draining2) valvesClose.Add(StateMachine.DrainValve2);
if (draining3) valvesClose.Add(StateMachine.DrainValve3);
State.Create("MainSeq : Close emptying valve(s)")
.AddOperation(StateMachine.ControlBoard.SetValvesOp(null, valvesClose))
.EnterState();
do { e = StateMachine.WaitRunDevsRunOps(); }
while (!e.Contains(Event.ValvesSet));
emptying1 = emptying2 = emptying3 = false;
draining1 = draining2 = draining3 = false;
}
selection = Selection.None;
}
else if ((selection == Selection.EmptyTank1) && !emptying1)
else if (e.Contains(Event.UiCmdDrainTank1) && !draining1)
{
emptying1 = true;
draining1 = true;
///--------------------------------------------
Bridge.OnActivity(this, Strings.Emptying_tank);
///--------------------------------------------
Bridge.Bench2UI(((context == MKSelContext.ProcedureNotSelected) ? ButtonsEtc.ProcedureCmbBoxEn : 0) |
ButtonsEtc.TestCmbBoxEn | ButtonsEtc.StopBtnEn |
(emptying2 ? 0 : ButtonsEtc.EmptyTankBtn2En) |
(emptying3 ? 0 : ButtonsEtc.EmptyTankBtn3En));
(draining2 ? 0 : ButtonsEtc.DrainTankBtn2En) |
(draining3 ? 0 : ButtonsEtc.DrainTankBtn3En));
State.Create("MainSeq : Open tank 1")
.AddOperation(StateMachine.ControlBoard.SetValvesOp(StateMachine.DrainValve1, null))
.EnterState();
do { e = StateMachine.WaitRunDevsRunOps(); }
while (!e.Contains(Event.ValvesSet));
}
else if ((selection == Selection.EmptyTank2) && !emptying2)
else if (e.Contains(Event.UiCmdDrainTank2) && !draining2)
{
emptying2 = true;
draining2 = true;
///--------------------------------------------
Bridge.OnActivity(this, Strings.Emptying_tank);
///--------------------------------------------
Bridge.Bench2UI(((context == MKSelContext.ProcedureNotSelected) ? ButtonsEtc.ProcedureCmbBoxEn : 0) |
ButtonsEtc.TestCmbBoxEn | ButtonsEtc.StopBtnEn |
(emptying1 ? 0 : ButtonsEtc.EmptyTankBtn1En) |
(emptying3 ? 0 : ButtonsEtc.EmptyTankBtn3En));
(draining1 ? 0 : ButtonsEtc.DrainTankBtn1En) |
(draining3 ? 0 : ButtonsEtc.DrainTankBtn3En));
State.Create("MainSeq : Open tank 2")
.AddOperation(StateMachine.ControlBoard.SetValvesOp(StateMachine.DrainValve2, null))
.EnterState();
do { e = StateMachine.WaitRunDevsRunOps(); }
while (!e.Contains(Event.ValvesSet));
}
else if ((selection == Selection.EmptyTank3) && !emptying3)
else if (e.Contains(Event.UiCmdDrainTank3) && !draining3)
{
emptying3 = true;
draining3 = true;
///--------------------------------------------
Bridge.OnActivity(this, Strings.Emptying_tank);
///--------------------------------------------
Bridge.Bench2UI(((context == MKSelContext.ProcedureNotSelected) ? ButtonsEtc.ProcedureCmbBoxEn : 0) |
ButtonsEtc.TestCmbBoxEn | ButtonsEtc.StopBtnEn |
(emptying1 ? 0 : ButtonsEtc.EmptyTankBtn1En) |
(emptying2 ? 0 : ButtonsEtc.EmptyTankBtn2En));
(draining1 ? 0 : ButtonsEtc.DrainTankBtn1En) |
(draining2 ? 0 : ButtonsEtc.DrainTankBtn2En));
State.Create("MainSeq : Open tank 3")
.AddOperation(StateMachine.ControlBoard.SetValvesOp(StateMachine.DrainValve3, null))
.EnterState();
do { e = StateMachine.WaitRunDevsRunOps(); }
while (!e.Contains(Event.ValvesSet));
}
else if (selection == Selection.CloseTank1)
else if (draining1 && StateMachine.Scale1.IsEmpty(mass1.Val))
{
State.Create("MainSeq : Close tank 1")
.AddOperation(StateMachine.ControlBoard.SetValvesOp(null, StateMachine.DrainValve1))
.EnterState();
do { e = StateMachine.WaitRunDevsRunOps(); }
while (!e.Contains(Event.ValvesSet));
emptying1 = false;
draining1 = false;
}
else if (selection == Selection.CloseTank2)
else if (draining2 && StateMachine.Scale2.IsEmpty(mass2.Val))
{
State.Create("MainSeq : Close tank 2")
.AddOperation(StateMachine.ControlBoard.SetValvesOp(null, StateMachine.DrainValve2))
.EnterState();
do { e = StateMachine.WaitRunDevsRunOps(); }
while (!e.Contains(Event.ValvesSet));
emptying2 = false;
draining2 = false;
}
else if (selection == Selection.CloseTank3)
else if (draining3 && StateMachine.Scale3.IsEmpty(mass3.Val))
{
State.Create("MainSeq : Close tank 3")
.AddOperation(StateMachine.ControlBoard.SetValvesOp(null, StateMachine.DrainValve3))
.EnterState();
do { e = StateMachine.WaitRunDevsRunOps(); }
while (!e.Contains(Event.ValvesSet));
emptying3 = false;
draining3 = false;
}
}
error:
Bridge.OnActivity(this, Strings.Error);
State.Create("MainSeq : ERROR state")
.EnterState();
while (true) StateMachine.WaitRunDevsRunOps();
}
/// <summary>
/// Perform a camera test
/// </summary>
void CameraTest()
{
IList<Event> e;
camera_test:
Bridge.OnActivity(this, "Camera test");
//---------------------------------------------------------
Bridge.Bench2UI(ButtonsEtc.StartTestBtnsEn | ButtonsEtc.StopBtnEn);
State.Create("MainSeq : 1 = Grab, 2 = Live, 3 = Focus, Stop = Quit camera test")
.AddOperation(checkUiOp)
.EnterState();
do
{
e = StateMachine.WaitRunDevsRunOps();
if (e.Contains(Event.Error)) goto error;
if (e.Contains(Event.UiCmdStop)) return;
if (e.Contains(Event.UiCmdStartQ1)) goto grab;
if (e.Contains(Event.UiCmdStartQ2)) goto live;
if (e.Contains(Event.UiCmdStartQ3)) goto focus;
}
while (true);
grab:
Bridge.Bench2UI(ButtonsEtc.StopBtnEn);
State.Create("MainSeq : Press 'Stop' to continue")
.AddOperation(checkUiOp)
.AddOperation((Cameras.Count > 0 && Cameras[0] != null && (Cameras[0].Cfg.DebugLevel != DebugMode.DetectedOff)) ? Cameras[0].GrabImageOp() : null)
.AddOperation((Cameras.Count > 1 && Cameras[1] != null && (Cameras[1].Cfg.DebugLevel != DebugMode.DetectedOff)) ? Cameras[1].GrabImageOp() : null)
.AddOperation((Cameras.Count > 2 && Cameras[2] != null && (Cameras[2].Cfg.DebugLevel != DebugMode.DetectedOff)) ? Cameras[2].GrabImageOp() : null)
.AddOperation((Cameras.Count > 3 && Cameras[3] != null && (Cameras[3].Cfg.DebugLevel != DebugMode.DetectedOff)) ? Cameras[3].GrabImageOp() : null)
.AddOperation((Cameras.Count > 4 && Cameras[4] != null && (Cameras[4].Cfg.DebugLevel != DebugMode.DetectedOff)) ? Cameras[4].GrabImageOp() : null)
.AddOperation((Cameras.Count > 5 && Cameras[5] != null && (Cameras[5].Cfg.DebugLevel != DebugMode.DetectedOff)) ? Cameras[5].GrabImageOp() : null)
.EnterState();
do
{
e = StateMachine.WaitRunDevsRunOps();
if (e.Contains(Event.Error)) goto error;
if (e.Contains(Event.UiCmdStop)) goto camera_test;
}
while (true);
live:
Bridge.Bench2UI(ButtonsEtc.StopBtnEn);
State.Create("MainSeq : Press 'Stop' to stop.")
.AddOperation(checkUiOp)
.AddOperation((Cameras.Count > 0 && Cameras[0] != null && (Cameras[0].Cfg.DebugLevel != DebugMode.DetectedOff)) ? Cameras[0].LiveStreamOp(false) : null)
.AddOperation((Cameras.Count > 1 && Cameras[1] != null && (Cameras[1].Cfg.DebugLevel != DebugMode.DetectedOff)) ? Cameras[1].LiveStreamOp(false) : null)
.AddOperation((Cameras.Count > 2 && Cameras[2] != null && (Cameras[2].Cfg.DebugLevel != DebugMode.DetectedOff)) ? Cameras[2].LiveStreamOp(false) : null)
.AddOperation((Cameras.Count > 3 && Cameras[3] != null && (Cameras[3].Cfg.DebugLevel != DebugMode.DetectedOff)) ? Cameras[3].LiveStreamOp(false) : null)
.AddOperation((Cameras.Count > 4 && Cameras[4] != null && (Cameras[4].Cfg.DebugLevel != DebugMode.DetectedOff)) ? Cameras[4].LiveStreamOp(false) : null)
.AddOperation((Cameras.Count > 5 && Cameras[5] != null && (Cameras[5].Cfg.DebugLevel != DebugMode.DetectedOff)) ? Cameras[5].LiveStreamOp(false) : null)
.EnterState();
do
{
e = StateMachine.WaitRunDevsRunOps();
if (e.Contains(Event.Error)) goto error;
if (e.Contains(Event.UiCmdStop)) goto camera_test;
}
while (true);
focus:
Bridge.Bench2UI(ButtonsEtc.StopBtnEn);
State.Create("MainSeq : Press 'Stop' to stop.")
.AddOperation(checkUiOp)
.AddOperation((Cameras.Count > 0 && Cameras[0] != null && (Cameras[0].Cfg.DebugLevel != DebugMode.DetectedOff)) ? Cameras[0].LiveStreamOp(true) : null)
.AddOperation((Cameras.Count > 1 && Cameras[1] != null && (Cameras[1].Cfg.DebugLevel != DebugMode.DetectedOff)) ? Cameras[1].LiveStreamOp(true) : null)
.AddOperation((Cameras.Count > 2 && Cameras[2] != null && (Cameras[2].Cfg.DebugLevel != DebugMode.DetectedOff)) ? Cameras[2].LiveStreamOp(true) : null)
.AddOperation((Cameras.Count > 3 && Cameras[3] != null && (Cameras[3].Cfg.DebugLevel != DebugMode.DetectedOff)) ? Cameras[3].LiveStreamOp(true) : null)
.AddOperation((Cameras.Count > 4 && Cameras[4] != null && (Cameras[4].Cfg.DebugLevel != DebugMode.DetectedOff)) ? Cameras[4].LiveStreamOp(true) : null)
.AddOperation((Cameras.Count > 5 && Cameras[5] != null && (Cameras[5].Cfg.DebugLevel != DebugMode.DetectedOff)) ? Cameras[5].LiveStreamOp(true) : null)
.EnterState();
do
{
e = StateMachine.WaitRunDevsRunOps();
if (e.Contains(Event.Error)) goto error;
if (e.Contains(Event.UiCmdStop)) goto camera_test;
}
while (true);
error:
Bridge.OnActivity(this, Strings.Error);
State.Create("MainSeq : ERROR state")
.EnterState();
while (true) StateMachine.WaitRunDevsRunOps();
}
void CollectSimultSteps()
/// <summary>
/// Create a new empty batch results from the procedure
/// </summary>
/// <param name="newBatchNr">New batch number</param>
/// <param name="procedure">Selected procedure</param>
/// <returns>Created BatchResults</returns>
Results.BatchResults CreateNewBatchResults(int newBatchNr, Procedure procedure)
{
///
/// Prepare new water meters
///
foreach (var wm in WaterMeters) wm.ClearData(); /// Clean water meter data
bool compound = (StateMachine.Procedure.MetersKind == MetersKind.Combined);
bool heatMeters = (StateMachine.Procedure.MetersKind == MetersKind.HeatMeter);
int waterMetersCount = Math.Min(WaterMeters.Count, heatMeters ? Config.Data.HeatMetersCount : (compound ? Config.Data.CompoundWMsCount : Config.Data.WMsCount));
///
Results.Entities.WaterMeterData[] waterMeterData = new Results.Entities.WaterMeterData[waterMetersCount];
///
int[] waterMeterParts = new int[waterMetersCount];
for (int wmNr = 0; wmNr < waterMetersCount; wmNr++)
{
int ix = compound ? (2 * wmNr) : wmNr;
waterMeterParts[wmNr] = Utils.PartNr(wmNr + 1, compound);
waterMeterData[wmNr] = new Results.Entities.WaterMeterData()
{
ProductName = WaterMeters[ix].ProductName,
Producer = WaterMeters[ix].Producer,
L = WaterMeters[ix].L,
DN = WaterMeters[ix].DN,
Mounting = WaterMeters[ix].Mounting,
Q4_Qmax = WaterMeters[ix].Q4_Qmax,
Q3_Qn = WaterMeters[ix].Q3_Qn,
Q2_Qt = WaterMeters[ix].Q2_Qt,
Q1_Qmin = WaterMeters[ix].Q1_Qmin,
MetrologicalClass = WaterMeters[ix].MetrologicalClass,
TemperatureClass = WaterMeters[ix].TemperatureClass,
PressureLossClass = WaterMeters[ix].PressureLossClass,
MaxAdmissiblePressure = WaterMeters[ix].MaxAdmissiblePressure,
FlowProfileSensitivityClass = WaterMeters[ix].FlowProfileSensitivityClass,
ApprovalInfo = WaterMeters[ix].ApprovalInfo,
Certificate = WaterMeters[ix].Certificate,
PulsesPerLtr = WaterMeters[ix].PulsesPerLtr,
Text1 = WaterMeters[ix].Text1,
Text2 = WaterMeters[ix].Text2,
Text3 = WaterMeters[ix].Text3,
Text4 = WaterMeters[ix].Text4,
Text5 = WaterMeters[ix].Text5,
Compound = compound,
HeatMeter = heatMeters,
};
if (compound)
{
int auxIx = 2 * wmNr + 1;
waterMeterData[wmNr].ProducerAux = WaterMeters[auxIx].Producer;
waterMeterData[wmNr].Q3_Qn_Aux = WaterMeters[auxIx].Q3_Qn;
waterMeterData[wmNr].MetrologicalClassAux = WaterMeters[auxIx].MetrologicalClass;
waterMeterData[wmNr].ApprovalInfoAux = WaterMeters[auxIx].ApprovalInfo;
}
#if ORACLE_DB
BenchControl.WaterMeters.iPerl.WaterMeter iPerl = WaterMeters[wmNr] as BenchControl.WaterMeters.iPerl.WaterMeter;
if (iPerl != null)
{
waterMeterData[wmNr].WMTypeId = iPerl.WMType_ID;
waterMeterData[wmNr].WMTypeRev = iPerl.WMType_Rev;
}
#endif
}
/// Prepare empty results
return Results.BatchResults.NewFromProcedure(newBatchNr,
(BenchInfo != null) ? BenchInfo.TestBenchId : 1,
Users.GlobalData.CurrentUser.UserName,
Users.GlobalData.CurrentUser.Number,
Program.Version,
StateMachine.Procedure,
waterMeterData,
waterMeterParts);
}
/// <summary>
/// Reload batch results from Results database given the batch number
/// </summary>
/// <param name="oriBatchNr">Original batch number</param>
/// <param name="newBatchNr">New unique batch number</param>
/// <param name="procedure">Reloaded procedure</param>
/// <returns></returns>
void RestoreBatchResults(int oriBatchNr, ref Results.BatchResults batchResults)
{
Batch oriBatch = Results.DB.LoadBatch(oriBatchNr);
batchResults.Batch.StartTime = oriBatch.StartTime;
foreach (var testRslt in batchResults.Batch.TestRslts)
{
foreach (var oriTstRslt in oriBatch.TestRslts)
{
if (testRslt.Name() == oriTstRslt.Name() &&
testRslt.Part == oriTstRslt.Part &&
testRslt.RepetitionNr == oriTstRslt.RepetitionNr)
{
testRslt.CopyContentFrom(oriTstRslt);
break;
}
}
}
for (int i = 0; i < batchResults.WaterMeters.Length; i++)
{
WaterMeter wm = batchResults.WaterMeters[i];
foreach (var wm2 in oriBatch.WaterMeters)
{
if (wm.WMPosition == wm2.WMPosition)
{
wm.CopyContentFrom(wm2);
break;
}
}
}
}
void CollectSimultSteps()
{
///
/// Collect steps (e.g. iPerl communication) to be done simultaneously with purging
@@ -171,39 +171,39 @@ namespace TBF.BenchControl.Sequences
}
protected Event EmptyTheTank(IValve emptyTankValve, IBalance balance)
protected Event DrainTheTank(IValve drainValve, IScale scale)
{
return EmptyTheTank(emptyTankValve, balance, new List<IOperation>());
return DrainTheTank(drainValve, scale, new List<IOperation>());
}
protected Event EmptyTheTank(IValve emptyTankValve, IBalance balance, IOperation extraOperation)
protected Event DrainTheTank(IValve drainValve, IScale scale, IOperation extraOperation)
{
IList<IOperation> extraOperations = new List<IOperation>();
extraOperations.Add(extraOperation);
return EmptyTheTank(emptyTankValve, balance, extraOperations);
return DrainTheTank(drainValve, scale, extraOperations);
}
/// <summary>
/// Empties the tank: opens the emptying valve and measures the weight.
/// </summary>
/// <param name="emptyTankValve">Valve to empty the tank</param>
/// <param name="balance">Balance underneath the tank</param>
/// <param name="drainValve">Valve to empty the tank</param>
/// <param name="scale">Scale underneath the tank</param>
/// <returns>Event.Done or Event.Error</returns>
protected Event EmptyTheTank(IValve emptyTankValve, IBalance balance, IList<IOperation> extraOperations)
protected Event DrainTheTank(IValve drainValve, IScale scale, IList<IOperation> extraOperations)
{
bool stopped = false;
//------------------------------------------------
//------------------------------------------------------------
Bridge.OnActivity(this, TBF.Resources.Strings.Emptying_tank);
//------------------------------------------------
//------------------------------------------------------------
IList<Event> e;
Bridge.Bench2UI(ButtonsEtc.StopBtnEn);
State.Create("SequenceBase : Opening the emptying valve")
State.Create("SequenceBase : Drain valve opened")
.AddOperation(checkUiOp)
.AddOperation(StateMachine.ControlBoard.SetValvesOp(emptyTankValve, null))
.AddOperation(StateMachine.ControlBoard.SetValvesOp(drainValve, null))
.AddOperations(extraOperations)
.EnterState();
do
@@ -214,9 +214,9 @@ namespace TBF.BenchControl.Sequences
do
{
State.Create("SequenceBase : Emptying the tank")
State.Create("SequenceBase : Draining the tank")
.AddOperation(checkUiOp)
.AddOperation(balance.ReadMassOp(ref Mass))
.AddOperation(scale.ReadMassOp(ref Mass))
.AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp())
.AddOperations(extraOperations)
.EnterState();
@@ -236,30 +236,30 @@ namespace TBF.BenchControl.Sequences
if (stopped) break;
}
while (!balance.IsEmpty(Mass.Val));
while (!scale.IsEmpty(Mass.Val));
//
// Quit emptying
//
State.Create("SequenceBase : Closing the emptying valve")
State.Create("SequenceBase : Closing the drain valve")
.AddOperation(checkUiOp)
.AddOperation(balance.ReadMassOp(ref Mass))
.AddOperation(scale.ReadMassOp(ref Mass))
.AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp())
.AddOperation(StateMachine.ControlBoard.SetValvesOp(null, emptyTankValve))
.AddOperation(StateMachine.ControlBoard.SetValvesOp(null, drainValve))
.AddOperations(extraOperations)
.EnterState();
do
{
e = StateMachine.WaitRunDevsRunOps();
if (e.Contains(Event.Error))
return Event.Error;
if (e.Contains(Event.Error)) return Event.Error;
if (TestAndLogUiCmdStop(e)) return Event.UiCmdStop;
}
while (!e.Contains(Event.ValvesSet) || !e.Contains(Event.BalanceDone));
State.Create("SequenceBase : Updating the weight")
State.Create("SequenceBase : Updating the mass")
.AddOperation(checkUiOp)
.AddOperation(balance.ReadMassOp(ref Mass))
.AddOperation(scale.ReadMassOp(ref Mass))
.AddOperation(new Operations.TimerOp(5))
.AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp())
.AddOperations(extraOperations)
@@ -267,9 +267,9 @@ namespace TBF.BenchControl.Sequences
do
{
e = StateMachine.WaitRunDevsRunOps();
if (e.Contains(Event.Error))
return Event.Error;
}
if (e.Contains(Event.Error)) return Event.Error;
if (TestAndLogUiCmdStop(e)) return Event.UiCmdStop;
}
while (!e.Contains(Event.BalanceDone) || !e.Contains(Event.TimerExpired));
@@ -485,18 +485,18 @@ namespace TBF.BenchControl.Sequences
switch (step.EndCondition)
{
case StepCondition.Scale1Empty:
endContitionFulfilled = (StateMachine.Balance1 == null) || StateMachine.Balance1.IsEmpty();
endContitionFulfilled = (StateMachine.Scale1 == null) || StateMachine.Scale1.IsEmpty();
break;
case StepCondition.Scale2Empty:
endContitionFulfilled = (StateMachine.Balance2 == null) || StateMachine.Balance2.IsEmpty();
endContitionFulfilled = (StateMachine.Scale2 == null) || StateMachine.Scale2.IsEmpty();
break;
case StepCondition.Scale3Empty:
endContitionFulfilled = (StateMachine.Balance3 == null) || StateMachine.Balance3.IsEmpty();
endContitionFulfilled = (StateMachine.Scale3 == null) || StateMachine.Scale3.IsEmpty();
break;
case StepCondition.AllScalesEmpty:
endContitionFulfilled = ((StateMachine.Balance1 == null) || StateMachine.Balance1.IsEmpty()) &&
((StateMachine.Balance2 == null) || StateMachine.Balance2.IsEmpty()) &&
((StateMachine.Balance3 == null) || StateMachine.Balance3.IsEmpty());
endContitionFulfilled = ((StateMachine.Scale1 == null) || StateMachine.Scale1.IsEmpty()) &&
((StateMachine.Scale2 == null) || StateMachine.Scale2.IsEmpty()) &&
((StateMachine.Scale3 == null) || StateMachine.Scale3.IsEmpty());
break;
}
*/
@@ -720,7 +720,7 @@ namespace TBF.BenchControl.Sequences
.AddOperation(heatMetersPath == null ? null : heatMetersPath.TMeterRefWarm2.ReadTempOp(ref TempRefHi2))
.AddOperation(heatMetersPath == null ? null : heatMetersPath.TMeterRefCold1.ReadTempOp(ref TempRefLo1))
.AddOperation(heatMetersPath == null ? null : heatMetersPath.TMeterRefCold2.ReadTempOp(ref TempRefLo2))
.AddOperation(realTest ? outPath.Balance.ReadMassOp(ref Mass) : null)
.AddOperation(realTest ? outPath.Scale.ReadMassOp(ref Mass) : null)
.AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp())
.AddOperation((StateMachine.Ambient != null)
? StateMachine.Ambient.ReadAmbientOp(AmbTemp, AmbPress, AmbHumi)
@@ -772,9 +772,9 @@ namespace TBF.BenchControl.Sequences
sb.Append(";"); sb.Append("60");
sb.Append(";"); sb.Append("0");
sb.Append(";"); sb.Append("0");
sb.Append(";"); sb.Append(outPath.FlowMeter.Idx1);
sb.Append(";"); sb.Append((outPath != null && outPath.FlowMeter != null) ? outPath.FlowMeter.Idx1 : 0);
sb.Append(";"); sb.Append(" ");
sb.Append(";"); if (outPath.Balance != null) sb.Append(outPath.Balance.Name);
sb.Append(";"); sb.Append((outPath != null && outPath.Scale != null) ? outPath.Scale.Name : string.Empty);
sb.Append(";"); sb.Append(tstRslt.AmbTempMean);
sb.Append(";"); sb.Append(Units.ConvertTo(Unit.mbar, tstRslt.AmbPressMean).ToString("F0")); /// [mbar]
sb.Append(";"); sb.Append(tstRslt.AmbHumiMean); /// [%]
@@ -823,10 +823,8 @@ namespace TBF.BenchControl.Sequences
sb.Append(";"); sb.Append(tstRslt.TestTime); /// t
sb.Append(";"); sb.Append(tstRslt.ErrorMaster); /// Eelm . . . chyba etalonu voci komercne pravej hodnote
sb.Append(";"); sb.Append(" "); /// Emass . . . chyba druheho etalonu voci komercne pravej hodnote (teraz vynechavame)
sb.Append(";"); if (outPath.FlowMeter != null && outPath.FlowMeter.LtrPerPulse != 0)
{
sb.Append(1.0f / outPath.FlowMeter.LtrPerPulse); /// Const.MID . konstanta eatlonu
}
sb.Append(";"); sb.Append((outPath != null && outPath.FlowMeter != null && outPath.FlowMeter.LtrPerPulse != 0) ? (1.0f / outPath.FlowMeter.LtrPerPulse) : 0);
/// Const.MID . konstanta eatlonu
sb.Append(";"); sb.Append(" "); /// Const.MA . . konstanta druheho etalonu
sb.Append(";"); sb.Append("0"); /// Time Div Start celkovy cas v [ms]
sb.Append(";"); sb.Append("0"); /// Time Div Start1
@@ -1084,7 +1082,7 @@ namespace TBF.BenchControl.Sequences
(BenchInfo != null) ? BenchInfo.TestBenchName : "testbench",
inPath.Pump != null ? inPath.Pump.Name : string.Empty,
outPath.FlowMeter != null ? outPath.FlowMeter.Name : string.Empty,
outPath.Balance != null ? outPath.Balance.Name : string.Empty,
outPath.Scale != null ? outPath.Scale.Name : string.Empty,
outPath.RegulValve != null ? outPath.RegulValve.Name : string.Empty,
outPath.Diverter != null ? outPath.Diverter.Name : string.Empty));
}
@@ -1208,7 +1206,7 @@ namespace TBF.BenchControl.Sequences
(BenchInfo != null) ? BenchInfo.TestBenchName : "testbench",
inPath.Pump != null ? inPath.Pump.Name : string.Empty,
outPath.FlowMeter != null ? outPath.FlowMeter.Name : string.Empty,
outPath.Balance != null ? outPath.Balance.Name : string.Empty,
outPath.Scale != null ? outPath.Scale.Name : string.Empty,
outPath.RegulValve != null ? outPath.RegulValve.Name : string.Empty,
outPath.Diverter != null ? outPath.Diverter.Name : string.Empty));
}
@@ -1335,7 +1333,7 @@ namespace TBF.BenchControl.Sequences
(BenchInfo != null) ? BenchInfo.TestBenchName : "testbench",
inPath.Pump != null ? inPath.Pump.Name : string.Empty,
outPath.FlowMeter != null ? outPath.FlowMeter.Name : string.Empty,
outPath.Balance != null ? outPath.Balance.Name : string.Empty,
outPath.Scale != null ? outPath.Scale.Name : string.Empty,
outPath.RegulValve != null ? outPath.RegulValve.Name : string.Empty,
outPath.Diverter != null ? outPath.Diverter.Name : string.Empty));
}
+44 -32
View File
@@ -45,9 +45,9 @@ namespace TBF.BenchControl
/// Public components
public static Elde.ControlBoardDev ControlBoard;
public static GenericDevices.IAmbient Ambient;
public static GenericDevices.IBalance Balance1;
public static GenericDevices.IBalance Balance2;
public static GenericDevices.IBalance Balance3;
public static GenericDevices.IScale Scale1;
public static GenericDevices.IScale Scale2;
public static GenericDevices.IScale Scale3;
public static GenericDevices.IValve DrainValve1;
public static GenericDevices.IValve DrainValve2;
public static GenericDevices.IValve DrainValve3;
@@ -85,8 +85,8 @@ namespace TBF.BenchControl
{
return GenericDevices.ValveBase.Merge(
Utils.ValvesOpen((feedingPaths != null && feedingPaths.Count > 0) ? feedingPaths[0] : null),
Utils.ValvesOpen((benchPaths != null && benchPaths.Count > 0) ? benchPaths[0] : null),
Utils.ValvesOpen((outputPaths != null && outputPaths.Count > 0) ? outputPaths[0] : null)
Utils.ValvesOpen((benchPaths != null && benchPaths.Count > 0) ? benchPaths[0] : null),
Utils.ValvesOpen((outputPaths != null && outputPaths.Count > 0) ? outputPaths[0] : null)
);
}
}
@@ -97,8 +97,8 @@ namespace TBF.BenchControl
{
return GenericDevices.ValveBase.Merge(
Utils.ValvesClose((feedingPaths != null && feedingPaths.Count > 0) ? feedingPaths[0] : null),
Utils.ValvesClose((benchPaths != null && benchPaths.Count > 0) ? benchPaths[0] : null),
Utils.ValvesClose((outputPaths != null && outputPaths.Count > 0) ? outputPaths[0] : null)
Utils.ValvesClose((benchPaths != null && benchPaths.Count > 0) ? benchPaths[0] : null),
Utils.ValvesClose((outputPaths != null && outputPaths.Count > 0) ? outputPaths[0] : null)
);
}
}
@@ -210,7 +210,7 @@ namespace TBF.BenchControl
/// Find all balances (to initialize tank capacities in the control board)
/// Find the control board
IList<IBalance> balances = new List<IBalance>();
IList<IScale> balances = new List<IScale>();
SequenceBase.FlowMeters = new List<IFlowMeter>();
SequenceBase.RegulValves = new List<IRegulValve>();
SequenceBase.PumpsWithFM = new List<IPumpFM>();
@@ -230,14 +230,14 @@ namespace TBF.BenchControl
if (cmpnt is IWaterMeter) SequenceBase.WaterMeters.Add(cmpnt as IWaterMeter);
if (cmpnt is ICamera) SequenceBase.Cameras.Add(cmpnt as ICamera);
if (cmpnt is GenericDevices.IAmbient) Ambient = cmpnt as GenericDevices.IAmbient;
if (cmpnt is IBalance)
if (cmpnt is IScale)
{
IBalance balance = cmpnt as IBalance;
balances.Add(balance);
IScale scale = cmpnt as IScale;
balances.Add(scale);
if (balance.BalanceNr == 0) Balance1 = balance;
else if (balance.BalanceNr == 1) Balance2 = balance;
else if (balance.BalanceNr == 2) Balance3 = balance;
if (scale.ScaleNr == 0) Scale1 = scale;
else if (scale.ScaleNr == 1) Scale2 = scale;
else if (scale.ScaleNr == 2) Scale3 = scale;
}
Elde.Valve.Valve eldeValve = (cmpnt as Elde.Valve.Valve);
@@ -306,23 +306,23 @@ namespace TBF.BenchControl
}
}
if (cmpnt is IBalance)
if (cmpnt is IScale)
{
IBalance balance = cmpnt as IBalance;
IScale balance = cmpnt as IScale;
if (balance.BalanceNr == 0)
if (balance.ScaleNr == 0)
{
DrainValve1 = balance.DrainValve;
log.WarnFormat("InitializeBoardEtc() ... Scale1={0} Draining valve1={1}",
balance.Name, (DrainValve1 != null) ? DrainValve1.Name : "---");
}
else if (balance.BalanceNr == 1)
else if (balance.ScaleNr == 1)
{
DrainValve2 = balance.DrainValve;
log.WarnFormat("InitializeBoardEtc() ... Scale2={0} Draining valve2={1}",
balance.Name, (DrainValve2 != null) ? DrainValve2.Name : "---");
}
else if (balance.BalanceNr == 2)
else if (balance.ScaleNr == 2)
{
DrainValve3 = balance.DrainValve;
log.WarnFormat("InitializeBoardEtc() ... Scale3={0} Draining valve3={1}",
@@ -505,7 +505,7 @@ namespace TBF.BenchControl
if (tr.Name == test.TransitionAfter) transitionAfter = tr;
}
if (pout.Balance == null)
if (pout.Scale == null)
{
errorMsg = string.Format("No balance specified in path {0}", test.OutputPath);
return false;
@@ -618,11 +618,6 @@ namespace TBF.BenchControl
}
catch (QuitStateMachineException)
{
State.StopOperations();
foreach (var device in devices) device.StopDevice();
quitStateMachine = false;
stateMachineRunning = false;
}
}
@@ -630,15 +625,31 @@ namespace TBF.BenchControl
/// <summary>
/// Do stuff that is repeated in the state execution loops most often
/// </summary>
/// <returns>List of Event-s returned from the state operations</returns>
/// <returns>List of Event-s returned from the state operations, null == quit</returns>
public static IList<Event> WaitRunDevsRunOps()
{
foreach (var device in devices) device.RunDeviceAfter();
WaitNextTick();
if (WaitNextTick())
{
///
/// Executed when the state machine is stopped
///
foreach (var device in devices) device.RunDeviceBefore();
State.StopOperations();
foreach (var device in devices) device.StopDevice();
stateMachineRunning = false;
throw new QuitStateMachineException();
}
foreach (var device in devices) device.RunDeviceBefore();
IList<Event> events = State.RunOperations();
return events;
///
/// This is followed by a state change in the sequence
///
}
@@ -646,7 +657,7 @@ namespace TBF.BenchControl
/// Wait time period - synchronize
/// </summary>
/// <returns>true when interrupted by 'quitStateMachine', otherwise false</returns>
public static void WaitNextTick()
public static bool WaitNextTick()
{
currentTimeSec += Period;
@@ -654,16 +665,17 @@ namespace TBF.BenchControl
DateTime nextLoopDateTime = startDateTime + timeFromStart;
while (DateTime.Now < nextLoopDateTime)
{
if (quitStateMachine)
Thread.Sleep(100);
if (quitStateMachine)
{
quitStateMachine = false;
wlog.Info("quitStateMachine == true ... going to stop the StateMachine()");
throw new QuitStateMachineException();
return true;
}
Thread.Sleep(100);
}
wlog.DebugFormat(" currentTime = {0}s", currentTimeSec);
return false;
}
}
}
@@ -81,6 +81,7 @@ namespace TBF.BenchControl
Factories.Add(new Modbus.TankSelector.Factory()); /// Modbus.TankSelector
Factories.Add(new Network.Adapter.Factory());
Factories.Add(new Network.Camera.CLP1611.Factory());
Factories.Add(new Network.Camera.Display.Factory());
Factories.Add(new Network.Camera.Roi.Factory());
Factories.Add(new Output.FileWriters.Basic.FactorySingle());
Factories.Add(new Output.FileWriters.Basic.FactoryCompound());
@@ -102,7 +102,7 @@ namespace TBF.BenchControl.TestMethods.Adjustment
State.Create("Adjustment : Starting the pump")
.AddOperation(checkUiOp)
.AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp())
.AddOperation(new Operations.SetAllRegulValvesOp(inPath.RegulValves, inPath.RegulValvesPct, 60))
// .AddOperation(new Operations.SetAllRegulValvesOp(inPath.RegulValves, inPath.RegulValvesPct, 60))
.AddOperation(inPath.Pump != null ? cBrd.SetValvesOp(inPath.Pump, null) : null)
.EnterState();
do
@@ -115,7 +115,7 @@ namespace TBF.BenchControl.TestMethods.Adjustment
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
}
while (e.Contains(Event.ValvesBusy) || !e.Contains(Event.AllPositionsReached));
while (e.Contains(Event.ValvesBusy) /* || !e.Contains(Event.AllPositionsReached)*/);
if (test.TimeBeforeFlow > 0)
@@ -180,7 +180,11 @@ namespace TBF.BenchControl.TestMethods.Adjustment
IList<GenericDevices.IRoi> rois = new List<GenericDevices.IRoi>();
foreach (var rr in sensPath.RegisterReaders)
{
if (rr is GenericDevices.IRoi) rois.Add(rr as GenericDevices.IRoi);
GenericDevices.IRoi roi = rr as GenericDevices.IRoi;
if (roi != null && roi.Detected)
{
rois.Add(roi);
}
}
/// Find cameras
@@ -189,7 +193,7 @@ namespace TBF.BenchControl.TestMethods.Adjustment
{
if (roi.Camera != null && !cameras.Contains(roi.Camera))
{
roi.Camera.ClearRois();
roi.Camera.ClearRoiParams();
cameras.Add(roi.Camera);
}
}
@@ -383,7 +387,7 @@ namespace TBF.BenchControl.TestMethods.Adjustment
(BenchInfo != null) ? BenchInfo.TestBenchName : "testbench",
inPath.Pump != null ? inPath.Pump.Name : string.Empty,
outPath.FlowMeter != null ? outPath.FlowMeter.Name : string.Empty,
outPath.Balance != null ? outPath.Balance.Name : string.Empty,
outPath.Scale != null ? outPath.Scale.Name : string.Empty,
outPath.RegulValve != null ? outPath.RegulValve.Name : string.Empty,
outPath.Diverter != null ? outPath.Diverter.Name : string.Empty));
@@ -141,12 +141,12 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
Qrise = 0;
Qfall = 0;
if (!test.Emptying) /// Do not skip emptying if test.Emptying==true
if (!test.Draining) /// Do not skip emptying if test.Emptying==true
{
//--------------------------------
State.Create("CombinedWithDetection : Get the mass of water in the tank")
State.Create("CombinedWithDetection : Mesuring mass of water in the tank")
.AddOperation(checkUiOp)
.AddOperation(outPath.Balance.ReadMassOp(ref Mass))
.AddOperation(outPath.Scale.ReadMassOp(ref Mass))
.EnterState();
do
{
@@ -157,14 +157,14 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
while (!e.Contains(Event.BalanceDone));
double estimatedEndMass = Mass.Val + test.Volume;
if (estimatedEndMass < outPath.Balance.Capacity * Constants.TankFullFactor)
if (estimatedEndMass < outPath.Scale.Capacity * Constants.TankFullFactor)
{
goto switching_flow_detection; /// Enough room in the tank -> skip emptying
}
}
// Empty the water tank
switch (EmptyTheTank(outPath.EmptyTankValve, outPath.Balance))
switch (DrainTheTank(outPath.Scale.DrainValve, outPath.Scale))
{
case Event.Error: goto error;
case Event.UiCmdStop: goto stopTest;
@@ -185,7 +185,11 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
IList<GenericDevices.IRoi> rois = new List<GenericDevices.IRoi>();
foreach (var rr in sensPath.RegisterReaders)
{
if (rr is GenericDevices.IRoi) rois.Add(rr as GenericDevices.IRoi);
GenericDevices.IRoi roi = rr as GenericDevices.IRoi;
if (roi != null && roi.Detected)
{
rois.Add(roi);
}
}
/// Find cameras
@@ -194,7 +198,7 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
{
if (roi.Camera != null && !cameras.Contains(roi.Camera))
{
roi.Camera.ClearRois();
roi.Camera.ClearRoiParams();
cameras.Add(roi.Camera);
}
}
@@ -463,7 +467,7 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
State.Create(Strings.Measure_the_mass)
.AddOperation(checkUiOp)
.AddOperations(measureOperations)
.AddOperation(outPath.Balance.ReadStableMassOp(ref StartMass, test.MassRepeats, test.MassSpread, test.MassMethod))
.AddOperation(outPath.Scale.ReadStableMassOp(ref StartMass, test.MassRepeats, test.MassSpread, test.MassMethod))
.EnterState();
do
{
@@ -548,7 +552,7 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
//------------------------------------------------
State.Create(Strings.Measure_the_mass)
.AddOperation(checkUiOp)
.AddOperation(outPath.Balance.ReadStableMassOp(ref EndMass, test.MassRepeats, test.MassSpread, test.MassMethod))
.AddOperation(outPath.Scale.ReadStableMassOp(ref EndMass, test.MassRepeats, test.MassSpread, test.MassMethod))
.EnterState();
do
{
@@ -656,9 +660,9 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
tstRslt.TestTime = cBrd.TTime; /// [s] measurement time
tstRslt.PulsesMaster = Convert.ToDouble(cBrd.EtPulses(0)); /// Pulses of the master flow meter (test total)
tstRslt.MassStartRaw = StartMass.Val;
tstRslt.MassStart = Formulas.CorrectedValue(tstRslt.MassStartRaw, outPath.Balance.Corrections);
tstRslt.MassStart = Formulas.CorrectedValue(tstRslt.MassStartRaw, outPath.Scale.Corrections);
tstRslt.MassEndRaw = EndMass.Val;
tstRslt.MassEnd = Formulas.CorrectedValue(tstRslt.MassEndRaw, outPath.Balance.Corrections);
tstRslt.MassEnd = Formulas.CorrectedValue(tstRslt.MassEndRaw, outPath.Scale.Corrections);
tstRslt.FlowMass = 3600.0 * (tstRslt.MassEnd - tstRslt.MassStart) / tstRslt.TestTime; /// [kg/h]
tstRslt.FlowVolume = 3.6 * LtrPerRefPulse * cBrd.EtPulses(0) / tstRslt.TestTime; /// [m3/h]
tstRslt.VolumeCTV = 1001.03 * (tstRslt.MassEnd - tstRslt.MassStart) / tstRslt.DensityOut; /// [l] 1000.0f is because density is in [kg/m3]
@@ -729,7 +733,7 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
(BenchInfo != null) ? BenchInfo.TestBenchName : "testbench",
inPath.Pump != null ? inPath.Pump.Name : string.Empty,
outPath.FlowMeter != null ? outPath.FlowMeter.Name : string.Empty,
outPath.Balance != null ? outPath.Balance.Name : string.Empty,
outPath.Scale != null ? outPath.Scale.Name : string.Empty,
outPath.RegulValve != null ? outPath.RegulValve.Name : string.Empty,
outPath.Diverter != null ? outPath.Diverter.Name : string.Empty));
@@ -90,10 +90,10 @@ namespace TBF.BenchControl.TestMethods.Endurance
//------------------------------------------------
if (inPath.Pump is GenericDevices.IPumpFM) (inPath.Pump as GenericDevices.IPumpFM).TurnOn(test.PumpPower);
///
State.Create("Endurance : Starting the pump")
State.Create(string.Format("{0}({1}) : Starting the pump", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp())
.AddOperation(new Operations.SetAllRegulValvesOp(inPath.RegulValves, inPath.RegulValvesPct, 60))
// .AddOperation(new Operations.SetAllRegulValvesOp(inPath.RegulValves, inPath.RegulValvesPct, 60))
.AddOperation(inPath.Pump != null ? cBrd.SetValvesOp(inPath.Pump, null) : null)
.EnterState();
do
@@ -106,13 +106,13 @@ namespace TBF.BenchControl.TestMethods.Endurance
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
}
while (e.Contains(Event.ValvesBusy) || !e.Contains(Event.AllPositionsReached));
while (e.Contains(Event.ValvesBusy) /* || !e.Contains(Event.AllPositionsReached)*/);
//------------------------------------------------
Bridge.OnActivity(this, Strings.Setting_the_flow);
//------------------------------------------------
int flowSetTime0 = StateMachine.Time;
State.Create("Endurance : Setting the flow")
State.Create(string.Format("{0}({1}) : Setting the flow", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperation(outPath.RegulValve.SetFlowOp(outPath.FlowMeter, test.Qfrom, test.Qto, outPath.PidCoef, RefFlow, 990)) /// timeout = 16.5 min.
.EnterState();
@@ -158,7 +158,11 @@ namespace TBF.BenchControl.TestMethods.Endurance
IList<GenericDevices.IRoi> rois = new List<GenericDevices.IRoi>();
foreach (var rr in sensPath.RegisterReaders)
{
if (rr is GenericDevices.IRoi) rois.Add(rr as GenericDevices.IRoi);
GenericDevices.IRoi roi = rr as GenericDevices.IRoi;
if (roi != null && roi.Detected)
{
rois.Add(roi);
}
}
/// Find cameras
@@ -167,7 +171,7 @@ namespace TBF.BenchControl.TestMethods.Endurance
{
if (roi.Camera != null && !cameras.Contains(roi.Camera))
{
roi.Camera.ClearRois();
roi.Camera.ClearRoiParams();
cameras.Add(roi.Camera);
}
}
@@ -184,7 +188,7 @@ namespace TBF.BenchControl.TestMethods.Endurance
//------------------------------------------------
Bridge.OnActivity(this, Strings.Test_in_progress);
//------------------------------------------------
State.Create("Endurance : Starting the test")
State.Create(string.Format("{0}({1}) : Starting the test", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperations(measureOperations)
.AddOperation(benchPath.TempMtrUp == null ? null : benchPath.TempMtrUp.ReadTempOp(ref TempUp))
@@ -227,7 +231,7 @@ namespace TBF.BenchControl.TestMethods.Endurance
ClearAllStatistics();
/// Measurement loop - begin
State.Create("Read water meters")
State.Create(string.Format("{0}({1}) : Reading watermeters", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperations(measureOperations)
.AddOperation(readRegistersOp)
@@ -424,7 +428,7 @@ namespace TBF.BenchControl.TestMethods.Endurance
(BenchInfo != null) ? BenchInfo.TestBenchName : "testbench",
inPath.Pump != null ? inPath.Pump.Name : string.Empty,
outPath.FlowMeter != null ? outPath.FlowMeter.Name : string.Empty,
outPath.Balance != null ? outPath.Balance.Name : string.Empty,
outPath.Scale != null ? outPath.Scale.Name : string.Empty,
outPath.RegulValve != null ? outPath.RegulValve.Name : string.Empty,
outPath.Diverter != null ? outPath.Diverter.Name : string.Empty));
@@ -448,9 +452,21 @@ namespace TBF.BenchControl.TestMethods.Endurance
Bridge.OnActivity(this, Strings.Endurance_cycle_execution);
//------------------------------------------------
State.Create(string.Format("{0}({1}) : Stopping diverter, gate, etc.", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperation(cBrd.StopPreviousOp())
.EnterState();
do
{
e = StateMachine.WaitRunDevsRunOps();
if (TestAndLogUiCmdStop(test, e)) { if (retVal == Event.Done) retVal = Event.UiCmdStop; break; }
}
while (!e.Contains(Event.PreviousStopped));
int estimtdEndTime = StateMachine.Time + (int)test.TstTime;
ClearAllStatistics();
///
/// Update CyclePar[] array
///
@@ -476,7 +492,7 @@ namespace TBF.BenchControl.TestMethods.Endurance
///
cBrd.CyclePar = cyclePar;
///
State.Create("Endurance : Cycle parameters upload")
State.Create(string.Format("{0}({1}) : Uploading cycle parameters", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperation(benchPath.TempMtrUp.ReadTempOp(ref TempUp))
.AddOperation(benchPath.TempMtrDown.ReadTempOp(ref TempDown))
@@ -505,7 +521,7 @@ namespace TBF.BenchControl.TestMethods.Endurance
bool stopInProgress = false;
///
State.Create("Endurance : Cycle execution")
State.Create(string.Format("{0}({1}) : Executing the cycle", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperation(new Operations.TimerOp((int)test.TstTime, Event.TimerExpired))
.AddOperation(benchPath.TempMtrUp.ReadTempOp(ref TempUp))
@@ -555,7 +571,7 @@ namespace TBF.BenchControl.TestMethods.Endurance
//------------------------------------------------
Bridge.OnActivity(this, Strings.Last_cycle_wait_please);
//------------------------------------------------
State.Create("Endurance : Extra delay to be sure the last endurance cycle completed")
State.Create(string.Format("{0}({1}) : Delay to make sure the last endu.cycle completed", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperation(new Operations.TimerOp((int)(duration / 1000) + 1, Event.TimerExpired))
.AddOperation(benchPath.TempMtrUp.ReadTempOp(ref TempUp))
@@ -608,7 +624,7 @@ namespace TBF.BenchControl.TestMethods.Endurance
/// Quit this sequence ///
///----------------------///
State.Create("Endurance : Stopping diverter, gate, etc.")
State.Create(string.Format("{0}({1}) : Stopping diverter, gate, etc.", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperation(cBrd.StopPreviousOp())
.EnterState();
@@ -30,33 +30,33 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced
{
Elde.ControlBoardDev cBrd = StateMachine.ControlBoard;
IList<Event> e = new List<Event>(); /// Events from currently running operations
Event retVal = Event.Done;
checkUiOp = new Operations.CheckUIOp(true); /// Runs in more then one state
IList<Event> e = new List<Event>(); /// Events from currently running operations
Event retVal = Event.Done;
checkUiOp = new Operations.CheckUIOp(true); /// Runs in more then one state
LtrPerRefPulse = outPath.FlowMeter.LtrPerPulse; /// [ltr/pulse], nominal flow in [m3/h]
LtrPerRefPulse = outPath.FlowMeter.LtrPerPulse; /// [ltr/pulse], nominal flow in [m3/h]
/// Notes:
/// float timeHr = volumeLtr / (1000.0f * targetFlow);
/// float timeSec = 3600.0f * timeHr;
/// int refPulses = (int)(timeSec * (2000.0f * targetFlow / pOut.FlowMeter.NominalFlow));
int totalPulses = (int)(test.Volume / LtrPerRefPulse + 0.5f);
/// Notes:
/// float timeHr = volumeLtr / (1000.0f * targetFlow);
/// float timeSec = 3600.0f * timeHr;
/// int refPulses = (int)(timeSec * (2000.0f * targetFlow / pOut.FlowMeter.NominalFlow));
int totalPulses = (int)(test.Volume / LtrPerRefPulse + 0.5f);
processDataLoggingOp = new TBF.BenchControl.Operations.ProcessDataLoggingOp(processDataLogger, this, false);
processDataLoggingOp = new TBF.BenchControl.Operations.ProcessDataLoggingOp(processDataLogger, this, false);
int repetitionNr = outerLoopMode ? outerLoopCounter : 1; /// First test: repetitionNr=1
int repetitionNr = outerLoopMode ? outerLoopCounter : 1; /// First test: repetitionNr=1
//====================================
// Transition or SetRoute - Start
//====================================
switch (Transition(transitionBefore, TransitionContext.BeforeTest))
{
case Event.Error: { retVal = Event.Error; goto stopTest; }
case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; }
case Event.Error: { retVal = Event.Error; goto stopTest; }
case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; }
}
//====================================
loop:
loop:
/// Start the test, initialize test results
Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, totalPulses));
string testName = Results.Utils.GetTestName(test.Name, test.Repeats, repetitionNr);
@@ -65,12 +65,49 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.JustStarted));
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting));
int flowSetTime0 = StateMachine.Time;
if (!test.Draining)
{
///
/// Measure the weight in case there is no unconditional draining
///
State.Create("FixedStartAdvanced : Measuring mass of water in the tank")
.AddOperation(checkUiOp)
.AddOperation(outPath.Scale.ReadMassOp(ref Mass))
.EnterState();
do
{
e = StateMachine.WaitRunDevsRunOps();
Bridge.OnProcessData(this, new ProcessDataEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting));
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting));
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
}
while (!e.Contains(Event.BalanceDone));
}
///
/// Skip draining in case there is enough room in the tank
///
if (test.Draining || (Mass.Val + test.Volume >= outPath.Scale.Capacity * Constants.TankFullFactor))
{
///
/// Drain the water tank
///
switch (DrainTheTank(outPath.Scale.DrainValve, outPath.Scale))
{
case Event.Error: { retVal = Event.Error; goto stopTest; }
case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; }
}
}
//------------------------------------------------
Bridge.OnActivity(this, Strings.Setting_the_flow);
//------------------------------------------------
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting));
int flowSetTime0 = StateMachine.Time;
if (inPath.Pump is GenericDevices.IPumpFM) (inPath.Pump as GenericDevices.IPumpFM).TurnOn(test.PumpPower);
State.Create("FixedStartAdvanced : Waiting 5 sec")
@@ -83,7 +120,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced
Bridge.OnProcessData(this, new ProcessDataEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting));
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting));
if (TestAndLogUiCmdStop(test,e)) { retVal = Event.UiCmdStop; goto stopTest; }
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
}
while (!e.Contains(Event.TimerExpired));
@@ -98,68 +135,32 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced
Bridge.OnProcessData(this, new ProcessDataEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting));
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting));
if (TestAndLogUiCmdStop(test,e)) { retVal = Event.UiCmdStop; goto stopTest; }
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
}
while (!e.Contains(Event.ValvesSet));
if (!test.Emptying) /// If condition met => skip measuring and force emptying
{
///
/// Measure the weight and skip emptying if there is enough room in the tank
///
State.Create("FixedStartAdvanced : Measuring the mass of water in the tank")
.AddOperation(checkUiOp)
.AddOperation(outPath.Balance.ReadMassOp(ref Mass))
.EnterState();
do
{
e = StateMachine.WaitRunDevsRunOps();
Bridge.OnProcessData(this, new ProcessDataEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting));
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting));
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
if (TestAndLogUiCmdStop(test,e)) { retVal = Event.UiCmdStop; goto stopTest; }
}
while (!e.Contains(Event.BalanceDone));
set_flow:
double estimatedEndMass = Mass.Val + test.Volume;
if (estimatedEndMass < outPath.Balance.Capacity * Constants.TankFullFactor)
{
goto set_flow; /// Enough room in the tank -> skip emptying
}
}
///
/// Empty the water tank
///
switch (EmptyTheTank(outPath.EmptyTankValve, outPath.Balance))
{
case Event.Error: { retVal = Event.Error; goto stopTest; }
case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; }
}
set_flow:
//------------------------------------------------
Bridge.OnActivity(this, Strings.Setting_the_flow);
//------------------------------------------------
//------------------------------------------------
Bridge.OnActivity(this, Strings.Setting_the_flow);
//------------------------------------------------
if (inPath.Pump is GenericDevices.IPumpFM) (inPath.Pump as GenericDevices.IPumpFM).TurnOn(test.PumpPower);
State.Create("FixedStartAdvanced : Starting the pump")
.AddOperation(checkUiOp)
.AddOperation(checkUiOp)
.AddOperation(cBrd.SetValvesOp(inPath.Pump, null))
.EnterState();
do
{
e = StateMachine.WaitRunDevsRunOps();
.EnterState();
do
{
e = StateMachine.WaitRunDevsRunOps();
Bridge.OnProcessData(this, new ProcessDataEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting));
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting));
if (TestAndLogUiCmdStop(test,e)) { retVal = Event.UiCmdStop; goto stopTest; }
}
while (!e.Contains(Event.ValvesSet));
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
}
while (!e.Contains(Event.ValvesSet));
//--------------------------------
//--------------------------------
State.Create("FixedStartAdvanced : Setting the flow")
.AddOperation(checkUiOp)
.AddOperation(outPath.RegulValve.SetFlowOp(outPath.FlowMeter, test.Qfrom, test.Qto, outPath.PidCoef, RefFlow, 600)) /// timeout = 10 min.
@@ -170,8 +171,8 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced
Bridge.OnProcessData(this, new ProcessDataEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting));
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting));
if (e.Contains(Event.OpArgumentError)) { retVal = Event.OpArgumentError; goto stopTest; }
if (TestAndLogUiCmdStop(test,e)) { retVal = Event.UiCmdStop; goto stopTest; }
if (e.Contains(Event.OpArgumentError)) { retVal = Event.OpArgumentError; goto stopTest; }
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
if (e.Contains(Event.RegulValveTimeOut))
{
Bridge.OnError(this, Strings.Timeout);
@@ -182,27 +183,27 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced
}
while (!e.Contains(Event.FlowReached));
flow_set:
flow_set:
int flowSetTime = StateMachine.Time - flowSetTime0;
//------------------------------------------------
Bridge.OnActivity(this, Strings.Stopping_flow_for_the_fixed_start);
//------------------------------------------------
State.Create("FixedStartAdvanced : Closing the start/stop valve before the fixed start test")
.AddOperation(checkUiOp)
//------------------------------------------------
Bridge.OnActivity(this, Strings.Stopping_flow_for_the_fixed_start);
//------------------------------------------------
State.Create("FixedStartAdvanced : Closing the start/stop valve before the fixed start test")
.AddOperation(checkUiOp)
.AddOperation(StateMachine.ControlBoard.SetValvesOp(null, outPath.StartValve))
.AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp())
.EnterState();
do
{
e = StateMachine.WaitRunDevsRunOps();
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
}
while (!e.Contains(Event.ValvesSet));
int time = StateMachine.Time;
double currentFlow = RefFlow.Val;
int time = StateMachine.Time;
double currentFlow = RefFlow.Val;
///
@@ -213,7 +214,11 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced
IList<GenericDevices.IRoi> rois = new List<GenericDevices.IRoi>();
foreach (var rr in sensPath.RegisterReaders)
{
if (rr is GenericDevices.IRoi) rois.Add(rr as GenericDevices.IRoi);
GenericDevices.IRoi roi = rr as GenericDevices.IRoi;
if (roi != null && roi.Detected)
{
rois.Add(roi);
}
}
/// Find cameras
@@ -222,7 +227,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced
{
if (roi.Camera != null && !cameras.Contains(roi.Camera))
{
roi.Camera.ClearRois();
roi.Camera.ClearRoiParams();
cameras.Add(roi.Camera);
}
}
@@ -236,120 +241,120 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced
///
/// Enter watermeter begin states here
///
///
/// Enter watermeter begin states here
///
GenericDevices.IHasWMStatesForm dataEntryCmpnt =
TbfComponents.FindComponent(StateMachine.Procedure.DataEntry) as GenericDevices.IHasWMStatesForm;
if (dataEntryCmpnt != null)
{
if (dataEntryCmpnt != null)
{
Bridge.OnActivity(this, Strings.Enter_water_meter_data);
State.Create("FixedStartAdvanced : Enter begin-state")
.AddOperation((dataEntryCmpnt as GenericDevices.IHasWMStatesForm).ShowTestStartFormOp())
.AddOperation(checkUiOp)
.EnterState();
do
{
e = StateMachine.WaitRunDevsRunOps();
if (TestAndLogUiCmdStop(test,e)) { retVal = Event.UiCmdStop; goto stopTest; }
}
while (!e.Contains(Event.ModelessFormClosed));
State.Create("FixedStartAdvanced : Enter begin-state")
.AddOperation((dataEntryCmpnt as GenericDevices.IHasWMStatesForm).ShowTestStartFormOp())
.AddOperation(checkUiOp)
.EnterState();
do
{
e = StateMachine.WaitRunDevsRunOps();
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
}
while (!e.Contains(Event.ModelessFormClosed));
for (int i = 0; i < Config.Data.WMsCount; i++)
{
for (int i = 0; i < Config.Data.WMsCount; i++)
{
BenchControl.Elde.FixedStartRegisterReader.RegisterReader registerReader =
sensPath.RegisterReaders[i] as BenchControl.Elde.FixedStartRegisterReader.RegisterReader;
sensPath.RegisterReaders[i] as BenchControl.Elde.FixedStartRegisterReader.RegisterReader;
if (registerReader != null) registerReader.BeginWMState = dataEntryCmpnt.WMStartState(i);
}
}
}
}
//------------------------------------------------
Bridge.OnActivity(this, Strings.Measuring_the_weight);
//------------------------------------------------
//------------------------------------------------
Bridge.OnActivity(this, Strings.Measuring_the_weight);
//------------------------------------------------
State.Create("FixedStartAdvanced : Measuring the start mass")
.AddOperation(checkUiOp)
.AddOperations(measureOperations)
.AddOperation(benchPath.TempMtrUp.ReadTempOp(ref TempUp))
.AddOperation(benchPath.TempMtrDown.ReadTempOp(ref TempDown))
.AddOperation(outPath.TempDiv.ReadTempOp(ref TempDiv))
.AddOperation(benchPath.PressMtrUp.ReadPressureOp(ref PressUp))
.AddOperation(benchPath.PressMtrDown.ReadPressureOp(ref PressDown))
.AddOperation(benchPath.TempMtrDown.ReadTempOp(ref TempDown))
.AddOperation(outPath.TempDiv.ReadTempOp(ref TempDiv))
.AddOperation(benchPath.PressMtrUp.ReadPressureOp(ref PressUp))
.AddOperation(benchPath.PressMtrDown.ReadPressureOp(ref PressDown))
.AddOperation(benchPath.PressMtrDelta == null ? null : benchPath.PressMtrDelta.ReadPressureOp(ref PressDelta))
.AddOperation((StateMachine.Ambient != null)
? StateMachine.Ambient.ReadAmbientOp(AmbTemp, AmbPress, AmbHumi) : null)
.AddOperation(outPath.Balance.ReadStableMassOp(ref StartMass, test.MassRepeats, test.MassSpread, test.MassMethod))
.AddOperation(cBrd.UpdateTankWeightOp())
.AddOperation(processDataLoggingOp)
.EnterState();
? StateMachine.Ambient.ReadAmbientOp(AmbTemp, AmbPress, AmbHumi) : null)
.AddOperation(outPath.Scale.ReadStableMassOp(ref StartMass, test.MassRepeats, test.MassSpread, test.MassMethod))
.AddOperation(cBrd.UpdateTankWeightOp())
.AddOperation(processDataLoggingOp)
.EnterState();
do
{
e = StateMachine.WaitRunDevsRunOps();
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
if (TestAndLogUiCmdStop(test,e)) { retVal = Event.UiCmdStop; goto stopTest; }
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
}
while (!e.Contains(Event.BalanceDone));
TestStartTime = DateTime.Now;
Mass.Val = StartMass.Val;
TestStartTime = DateTime.Now;
Mass.Val = StartMass.Val;
//------------------------------------------------
Bridge.OnActivity(this, Strings.Test_in_progress);
//------------------------------------------------
//------------------------------------------------
Bridge.OnActivity(this, Strings.Test_in_progress);
//------------------------------------------------
State.Create("FixedStartAdvanced : Starting the test")
.AddOperation(checkUiOp)
.AddOperations(measureOperations)
.AddOperation(cBrd.StartMeasurementOp(outPath, Elde.TestMethods.Diverter | Elde.TestMethods.Synchro,
.AddOperations(measureOperations)
.AddOperation(cBrd.StartMeasurementOp(outPath, Elde.TestMethods.Diverter | Elde.TestMethods.Synchro,
test.Qfrom, test.Qto, 2 * totalPulses, (float)test.TolerRed))
.EnterState();
do
{
e = StateMachine.WaitRunDevsRunOps();
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
if (TestAndLogUiCmdStop(test,e)) { retVal = Event.UiCmdStop; goto stopTest; }
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
}
while (!e.Contains(Event.MeasurementStarted));
State.Create("FixedStartAdvanced : Opening the start/stop valve at the beginning of the fixed start test")
.AddOperation(checkUiOp)
.AddOperation(StateMachine.ControlBoard.SetValvesOp(outPath.StartValve, null))
.AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp())
.EnterState();
do
{
e = StateMachine.WaitRunDevsRunOps();
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
}
while (!e.Contains(Event.ValvesSet));
State.Create("FixedStartAdvanced : Opening the start/stop valve at the beginning of the fixed start test")
.AddOperation(checkUiOp)
.AddOperation(StateMachine.ControlBoard.SetValvesOp(outPath.StartValve, null))
.AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp())
.EnterState();
do
{
e = StateMachine.WaitRunDevsRunOps();
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
}
while (!e.Contains(Event.ValvesSet));
/// Measurement loop - preparation
readRegistersOp = new Operations.ReadMoreRegistersOp(sensPath.RegisterReaders);
queryEnd1 = cBrd.QueryMeasurementEndOp();
readRegistersOp = new Operations.ReadMoreRegistersOp(sensPath.RegisterReaders);
queryEnd1 = cBrd.QueryMeasurementEndOp();
queryEnd2 = cBrd.QueryMeasurementEndOp();
ClearAllStatistics();
ClearAllStatistics();
int estimtdEndTime = StateMachine.Time + (int)test.TstTime;
/// Measurement loop - begin
do
{
//--------------------------------
switch (ReadRegistersTempPressAmbient(measureOperations, true))
{
case Event.Error:
retVal = Event.Error;
goto stopTest;
/// Measurement loop - begin
do
{
//--------------------------------
switch (ReadRegistersTempPressAmbient(measureOperations, true))
{
case Event.Error:
retVal = Event.Error;
goto stopTest;
case Event.UiCmdStop:
retVal = Event.UiCmdStop;
goto stopTest;
case Event.UiCmdStop:
retVal = Event.UiCmdStop;
goto stopTest;
case Event.MeasurementCompleted:
goto test_completed;
}
case Event.MeasurementCompleted:
goto test_completed;
}
int remainingTime = Math.Max(estimtdEndTime - StateMachine.Time, 0);
if (remainingTime > 60)
@@ -362,28 +367,28 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced
}
RefFreq.Val = cBrd.ReferenceFreq;
RefFlow.Val = cBrd.ReferenceFlow;
RefFlow.Val = cBrd.ReferenceFlow;
UpdateAllStatistics();
Bridge.OnProcessData(this, new ProcessDataEventArgs(test, repetitionNr, Config.Entities.Progress.Test));
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.Test));
}
while (cBrd.EtPulses(0) < totalPulses);
/// Measurement loop - end
while (cBrd.EtPulses(0) < totalPulses);
/// Measurement loop - end
test_completed:
test_completed:
State.Create("FixedStartAdvanced : Closing the start/stop valve at the end of the fixed start test")
.AddOperation(checkUiOp)
.AddOperation(StateMachine.ControlBoard.SetValvesOp(null, outPath.StartValve))
.AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp())
.EnterState();
do
{
e = StateMachine.WaitRunDevsRunOps();
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
}
while (e.Contains(Event.ValvesBusy));
State.Create("FixedStartAdvanced : Closing the start/stop valve at the end of the fixed start test")
.AddOperation(checkUiOp)
.AddOperation(StateMachine.ControlBoard.SetValvesOp(null, outPath.StartValve))
.AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp())
.EnterState();
do
{
e = StateMachine.WaitRunDevsRunOps();
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
}
while (e.Contains(Event.ValvesBusy));
State.Create("FixedStartAdvanced : Waiting before 2nd mass measurement")
@@ -396,7 +401,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced
.AddOperation(benchPath.PressMtrDelta == null ? null : benchPath.PressMtrDelta.ReadPressureOp(ref PressDelta))
.AddOperation((StateMachine.Ambient != null)
? StateMachine.Ambient.ReadAmbientOp(AmbTemp, AmbPress, AmbHumi) : null)
.AddOperation(outPath.Balance.ReadMassOp(ref Mass))
.AddOperation(outPath.Scale.ReadMassOp(ref Mass))
.AddOperation(cBrd.UpdateTankWeightOp())
.AddOperation(processDataLoggingOp)
.AddOperation(new Operations.TimerOp(test.TimeStop2Mass))
@@ -405,7 +410,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced
{
e = StateMachine.WaitRunDevsRunOps();
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
if (TestAndLogUiCmdStop(test,e)) { retVal = Event.UiCmdStop; goto stopTest; }
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
}
while (!e.Contains(Event.TimerExpired));
@@ -423,7 +428,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced
.AddOperation(benchPath.PressMtrDelta == null ? null : benchPath.PressMtrDelta.ReadPressureOp(ref PressDelta))
.AddOperation((StateMachine.Ambient != null)
? StateMachine.Ambient.ReadAmbientOp(AmbTemp, AmbPress, AmbHumi) : null)
.AddOperation(outPath.Balance.ReadStableMassOp(ref EndMass, test.MassRepeats, test.MassSpread, test.MassMethod))
.AddOperation(outPath.Scale.ReadStableMassOp(ref EndMass, test.MassRepeats, test.MassSpread, test.MassMethod))
.AddOperation(cBrd.UpdateTankWeightOp())
.AddOperation(processDataLoggingOp)
.EnterState();
@@ -431,7 +436,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced
{
e = StateMachine.WaitRunDevsRunOps();
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
if (TestAndLogUiCmdStop(test,e)) { retVal = Event.UiCmdStop; goto stopTest; }
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
}
while (!e.Contains(Event.BalanceDone));
///
@@ -439,56 +444,56 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced
State.Create("FixedStartAdvanced : Stopping diverter, gate, etc.")
.AddOperation(checkUiOp)
.AddOperation(cBrd.StopPreviousOp())
.EnterState();
do
{
e = StateMachine.WaitRunDevsRunOps();
if (TestAndLogUiCmdStop(test,e)) { retVal = Event.UiCmdStop; goto stopTest; }
}
while (!e.Contains(Event.PreviousStopped));
.AddOperation(checkUiOp)
.AddOperation(cBrd.StopPreviousOp())
.EnterState();
do
{
e = StateMachine.WaitRunDevsRunOps();
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
}
while (!e.Contains(Event.PreviousStopped));
double massStart = Formulas.CorrectedValue(StartMass.Val, outPath.Balance.Corrections);
double massEnd = Formulas.CorrectedValue(EndMass.Val, outPath.Balance.Corrections);
double massStart = Formulas.CorrectedValue(StartMass.Val, outPath.Scale.Corrections);
double massEnd = Formulas.CorrectedValue(EndMass.Val, outPath.Scale.Corrections);
double densityOut = Formulas.WaterDensityFromTemp(TempDownStat.Average);
double volumeCTV = 1.00103f * 1000.0f * (massEnd - massStart) / densityOut;
///
/// Enter watermeter end states here
///
if (dataEntryCmpnt != null)
{
///
/// Enter watermeter end states here
///
if (dataEntryCmpnt != null)
{
Bridge.OnActivity(this, Strings.Enter_water_meter_data);
State.Create("FixedStartAdvanced : Enter end-state")
State.Create("FixedStartAdvanced : Enter end-state")
.AddOperation(dataEntryCmpnt.ShowTestEndFormOp(volumeCTV, test.ErrLimLo + test.Uncertainty,
test.ErrLimHi - test.Uncertainty))
.AddOperation(checkUiOp)
.EnterState();
do
{
e = StateMachine.WaitRunDevsRunOps();
if (TestAndLogUiCmdStop(test,e)) { retVal = Event.UiCmdStop; goto stopTest; }
}
while (!e.Contains(Event.ModelessFormClosed));
.AddOperation(checkUiOp)
.EnterState();
do
{
e = StateMachine.WaitRunDevsRunOps();
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
}
while (!e.Contains(Event.ModelessFormClosed));
for (int i = 0; i < Config.Data.WMsCount; i++)
{
for (int i = 0; i < Config.Data.WMsCount; i++)
{
BenchControl.Elde.FixedStartRegisterReader.RegisterReader registerReader =
sensPath.RegisterReaders[i] as BenchControl.Elde.FixedStartRegisterReader.RegisterReader;
sensPath.RegisterReaders[i] as BenchControl.Elde.FixedStartRegisterReader.RegisterReader;
if (registerReader != null) registerReader.EndWMState = dataEntryCmpnt.WMEndState(i);
}
}
}
}
//------------------------------------------------
Bridge.OnActivity(this, Strings.Test_completed);
//------------------------------------------------
/// Make sure the CycleBeginForm is closed so that water meter data (s/n) can be copied into results
/// Make sure the CycleBeginForm is closed so that water meter data (s/n) can be copied into results
if (UIFlowControl.Stop == WaitBeginFormClosed()) goto stopTest;
///
@@ -544,48 +549,48 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced
tstRslt.TempDivEnd = (float)TempDivStat.Last;
tstRslt.TempDivMin = (float)TempDivStat.Min;
tstRslt.TempDivMax = (float)TempDivStat.Max;
tstRslt.DensityIn = Formulas.WaterDensityFromTemp(tstRslt.TempUpMean); /// [kg/m3]
tstRslt.DensityIn = Formulas.WaterDensityFromTemp(tstRslt.TempUpMean); /// [kg/m3]
tstRslt.DensityOut = Formulas.WaterDensityFromTemp(tstRslt.TempDownMean); /// [kg/m3]
tstRslt.DensityDiv = Formulas.WaterDensityFromTemp(tstRslt.TempDivMean); /// [kg/m3]
/// Main results
tstRslt.StartTime = TestStartTime;
tstRslt.EndTime = TestEndTime;
tstRslt.FlowSetTime = flowSetTime;
tstRslt.TestTime = cBrd.TTime; /// [s] measurement time
tstRslt.StartTime = TestStartTime;
tstRslt.EndTime = TestEndTime;
tstRslt.FlowSetTime = flowSetTime;
tstRslt.TestTime = cBrd.TTime; /// [s] measurement time
tstRslt.PulsesMaster = Convert.ToDouble(cBrd.EtPulses(0)); /// Pulses of the master flow meter (test total)
tstRslt.MassStartRaw = StartMass.Val;
tstRslt.MassStart = massStart; /// [kg] calculated before displaying 'End state' dialog
tstRslt.MassEndRaw = EndMass.Val;
tstRslt.MassEnd = massEnd; /// [kg] calculated before displaying 'End state' dialog
tstRslt.FlowMass = 3600.0 * (tstRslt.MassEnd - tstRslt.MassStart) / tstRslt.TestTime; /// [kg/h]
tstRslt.FlowVolume = 3.6 * LtrPerRefPulse * tstRslt.PulsesMaster / tstRslt.TestTime;
tstRslt.VolumeCTV = volumeCTV; /// [kg] calculated before displaying 'End state' dialog
tstRslt.MassStart = massStart; /// [kg] calculated before displaying 'End state' dialog
tstRslt.MassEndRaw = EndMass.Val;
tstRslt.MassEnd = massEnd; /// [kg] calculated before displaying 'End state' dialog
tstRslt.FlowMass = 3600.0 * (tstRslt.MassEnd - tstRslt.MassStart) / tstRslt.TestTime; /// [kg/h]
tstRslt.FlowVolume = 3.6 * LtrPerRefPulse * tstRslt.PulsesMaster / tstRslt.TestTime;
tstRslt.VolumeCTV = volumeCTV; /// [kg] calculated before displaying 'End state' dialog
tstRslt.VolumeMaster = LtrPerRefPulse * tstRslt.PulsesMaster; /// [l] volume from the master flow meter
tstRslt.ConstMaster = LtrPerRefPulse * tstRslt.VolumeCTV / tstRslt.VolumeMaster; /// Corrected master pulses per liter
tstRslt.ErrorMaster = Formulas.ErrorFromVolumes(tstRslt.VolumeMaster, tstRslt.VolumeCTV);
tstRslt.ConstMaster = LtrPerRefPulse * tstRslt.VolumeCTV / tstRslt.VolumeMaster; /// Corrected master pulses per liter
tstRslt.ErrorMaster = Formulas.ErrorFromVolumes(tstRslt.VolumeMaster, tstRslt.VolumeCTV);
tstRslt.FlowMin = (float)((tstRslt.VolumeMaster != 0) ? (RefFlowStat.Min * tstRslt.VolumeCTV / tstRslt.VolumeMaster) : RefFlowStat.Min);
tstRslt.FlowMax = (float)((tstRslt.VolumeMaster != 0) ? (RefFlowStat.Max * tstRslt.VolumeCTV / tstRslt.VolumeMaster) : RefFlowStat.Max);
for (int i = 0; i < BatchRslts.WMPositionsCount; i++)
{
if (test.Part != 0 && test.Part != Utils.PartNr(i + 1, BatchRslts.Batch.Compound)) continue;
for (int i = 0; i < BatchRslts.WMPositionsCount; i++)
{
if (test.Part != 0 && test.Part != Utils.PartNr(i + 1, BatchRslts.Batch.Compound)) continue;
Results.Entities.MeterTestRslt meterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.Single);
Results.Entities.MeterTestRslt meterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.Single);
GenericDevices.IRegisterReader regReader = sensPath.RegisterReaders[i];
if (meterRslt != null && regReader != null)
{
meterRslt.PulsesPerLiter = 1.0f;
meterRslt.VolumeStart = regReader.BeginWMState;
meterRslt.VolumeEnd = regReader.EndWMState;
meterRslt.VolumeMeter = meterRslt.VolumeEnd - meterRslt.VolumeStart;
meterRslt.VolumeRef = tstRslt.VolumeCTV; /// liter
meterRslt.PulsesMeter = meterRslt.VolumeMeter;
meterRslt.VolumeStart = regReader.BeginWMState;
meterRslt.VolumeEnd = regReader.EndWMState;
meterRslt.VolumeMeter = meterRslt.VolumeEnd - meterRslt.VolumeStart;
meterRslt.VolumeRef = tstRslt.VolumeCTV; /// liter
meterRslt.PulsesMeter = meterRslt.VolumeMeter;
meterRslt.PulsesMaster = tstRslt.PulsesMaster;
meterRslt.TestTime = tstRslt.TestTime;
meterRslt.Error = Formulas.ErrorFromVolumes(meterRslt.VolumeMeter, meterRslt.VolumeRef);
meterRslt.TestTime = tstRslt.TestTime;
meterRslt.Error = Formulas.ErrorFromVolumes(meterRslt.VolumeMeter, meterRslt.VolumeRef);
meterRslt.Passed = (meterRslt.Error >= test.ErrLimLo + test.Uncertainty)
&& (meterRslt.Error <= test.ErrLimHi - test.Uncertainty);
meterRslt.TestDone = true;
@@ -598,7 +603,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced
(BenchInfo != null) ? BenchInfo.TestBenchName : "testbench",
inPath.Pump != null ? inPath.Pump.Name : string.Empty,
outPath.FlowMeter != null ? outPath.FlowMeter.Name : string.Empty,
outPath.Balance != null ? outPath.Balance.Name : string.Empty,
outPath.Scale != null ? outPath.Scale.Name : string.Empty,
outPath.RegulValve != null ? outPath.RegulValve.Name : string.Empty,
outPath.Diverter != null ? outPath.Diverter.Name : string.Empty));
@@ -631,7 +636,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced
do
{
e = StateMachine.WaitRunDevsRunOps();
if (TestAndLogUiCmdStop(test,e)) { retVal = Event.UiCmdStop; goto stopTest; }
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
}
while (!e.Contains(Event.PreviousStopped));
@@ -639,7 +644,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced
/// Prevent overwriting 'retVal' in case it was set to non-default value earlier
switch (Transition(transitionAfter, (retVal == Event.Done) ? TransitionContext.AfterTest : TransitionContext.Stop))
{
case Event.Error: { if (retVal == Event.Done) retVal = Event.Error; break; }
case Event.Error: { if (retVal == Event.Done) retVal = Event.Error; break; }
case Event.UiCmdStop: { if (retVal == Event.Done) retVal = Event.UiCmdStop; break; }
}
@@ -49,6 +49,15 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection
int repetitionNr = outerLoopMode ? outerLoopCounter : 1; /// First test: repetitionNr=1
if (test.Volume >= outPath.Scale.Capacity * Constants.TankFullFactor)
{
Bridge.OnError(this, Strings.Test_volume_exceeds_the_scale_capacity);
retVal = Event.UiCmdStop;
goto stopTestWOTransitionAfter;
}
//====================================
// Transition or SetRoute - Start
//====================================
@@ -68,50 +77,89 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.JustStarted));
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting));
int flowSetTime0 = StateMachine.Time;
if (test.Volume >= outPath.Balance.Capacity * Constants.TankFullFactor)
{
Bridge.OnError(this, Strings.Test_volume_exceeds_the_scale_capacity);
retVal = Event.Error;
goto stopTest;
}
///
/// Optionally display prompt to emerge temperature meters to appropriate baths for heat meters test
///
IOperation heatMetersPromptOp = null;
if (heatMetersTestParams != null && !string.IsNullOrEmpty(heatMetersTestParams.Prompt))
{
heatMetersPromptOp = new Operations.MessageBoxOp(heatMetersTestParams.Prompt);
/// Make sure the CycleBeginForm is closed
if (UIFlowControl.Stop == WaitBeginFormClosed()) goto stopTest;
heatMetersPromptOp = new Operations.MessageBoxOp(heatMetersTestParams.Prompt);
}
if (!test.Draining)
{
///
/// Measure the weight in case there is no unconditional draining
///
State.Create(string.Format("{0}({1}) : Measuring mass of water in the tank", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperation(outPath.Scale.ReadMassOp(ref Mass))
.AddOperation(heatMetersPromptOp)
.EnterState();
do
{
e = StateMachine.WaitRunDevsRunOps();
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.JustStarted));
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
}
while (!e.Contains(Event.BalanceDone));
}
///
/// Skip draining in case there is enough room in the tank
///
if (test.Draining || (Mass.Val + test.Volume >= outPath.Scale.Capacity * Constants.TankFullFactor))
{
///
/// Drain the water tank
///
switch (DrainTheTank(outPath.Scale.DrainValve, outPath.Scale, heatMetersPromptOp))
{
case Event.Error: { retVal = Event.Error; goto stopTest; }
case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; }
}
}
///
/// Make sure the drain valve is closed
///
State.Create(string.Format("{0}({1}) : Make sure the drain valve is closed", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperation(outPath.Scale.ReadMassOp(ref Mass))
.AddOperation(heatMetersPromptOp)
.AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp())
.AddOperation(StateMachine.ControlBoard.SetValvesOp(null, outPath.Scale.DrainValve))
.EnterState();
do
{
e = StateMachine.WaitRunDevsRunOps();
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.JustStarted));
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
}
while (!e.Contains(Event.ValvesSet) || !e.Contains(Event.BalanceDone));
//------------------------------------------------
Bridge.OnActivity(this, Strings.Starting_the_pump);
//------------------------------------------------
if (inPath.Pump is GenericDevices.IPumpFM) (inPath.Pump as GenericDevices.IPumpFM).TurnOn(test.PumpPower);
State.Create("FixedStartMassCollection : Waiting before starting the pump")
.AddOperation(checkUiOp)
.AddOperation(new Operations.TimerOp(5))
.EnterState();
do
{
e = StateMachine.WaitRunDevsRunOps();
Bridge.OnProcessData(this, new ProcessDataEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting));
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting));
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting));
int flowSetTime0 = StateMachine.Time;
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
}
while (!e.Contains(Event.TimerExpired));
if (inPath.Pump is GenericDevices.IPumpFM) (inPath.Pump as GenericDevices.IPumpFM).TurnOn(test.PumpPower);
///
State.Create("FixedStartMassCollection : Starting the pump")
State.Create(string.Format("{0}({1}) : Starting the pump", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp())
.AddOperation(new Operations.SetAllRegulValvesOp(inPath.RegulValves, inPath.RegulValvesPct, 60))
// .AddOperation(new Operations.SetAllRegulValvesOp(inPath.RegulValves, inPath.RegulValvesPct, 60))
.AddOperation(heatMetersPromptOp)
.AddOperation(inPath.Pump != null ? cBrd.SetValvesOp(inPath.Pump, null) : null)
.EnterState();
@@ -125,47 +173,9 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
}
while (e.Contains(Event.ValvesBusy) || !e.Contains(Event.AllPositionsReached));
while (e.Contains(Event.ValvesBusy) /* || !e.Contains(Event.AllPositionsReached)*/);
if (!test.Emptying) /// If condition met => skip measuring and force emptying
{
///
/// Measure the weight and skip emptying if there is enough room in the tank
///
State.Create("FixedStartMassCollection : Measuring the mass of water in the tank")
.AddOperation(checkUiOp)
.AddOperation(outPath.Balance.ReadMassOp(ref Mass))
.AddOperation(heatMetersPromptOp)
.EnterState();
do
{
e = StateMachine.WaitRunDevsRunOps();
Bridge.OnProcessData(this, new ProcessDataEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting));
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting));
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
}
while (!e.Contains(Event.BalanceDone));
double estimatedEndMass = Mass.Val + test.Volume;
if (estimatedEndMass < outPath.Balance.Capacity * Constants.TankFullFactor)
{
goto set_flow; /// Enough room in the tank -> skip emptying
}
}
///
/// Empty the water tank
///
switch (EmptyTheTank(outPath.EmptyTankValve, outPath.Balance, heatMetersPromptOp))
{
case Event.Error: { retVal = Event.Error; goto stopTest; }
case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; }
}
set_flow:
if (debugLevel == Config.Entities.DebugMode.Simulate) goto flow_set;
@@ -181,7 +191,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection
valvesOpen.Add(inPath.Pump);
valvesOpen.Add(outPath.StartValve);
///
State.Create("FixedStartMassCollection : Starting the pump")
State.Create(string.Format("{0}({1}) : Turning pump on", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperation(StateMachine.ControlBoard.SetValvesOp(valvesOpen, null))
.AddOperation(heatMetersPromptOp)
@@ -198,7 +208,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection
//--------------------------------
State.Create("FixedStartMassCollection : Setting the flow")
State.Create(string.Format("{0}({1}) : Setting the flow", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperation(outPath.RegulValve.SetFlowOp(outPath.FlowMeter, test.Qfrom, test.Qto, outPath.PidCoef, RefFlow, 600)) /// timeout = 10 min.
.AddOperation(heatMetersPromptOp)
@@ -235,7 +245,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection
double Tw_last = 0;
double Tc_last = 0;
State.Create("FixedStartMassCollection : Check temperature stabilized.")
State.Create(string.Format("{0}({1}) : Checking if the temperature is stable", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperation(heatMetersPath.TMeterRefWarm1.ReadTempOp(ref TempRefHi1))
.AddOperation(heatMetersPath.TMeterRefWarm2.ReadTempOp(ref TempRefHi2))
@@ -279,7 +289,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection
//------------------------------------------------
Bridge.OnActivity(this, Strings.Stopping_flow_for_the_fixed_start);
//------------------------------------------------
State.Create("FixedStartMassCollection : Closing the start/stop valve before the fixed start test")
State.Create(string.Format("{0}({1}) : Closing the start/stop valve before the fixed start test", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperation(StateMachine.ControlBoard.SetValvesOp(null, outPath.StartValve))
.AddOperation(heatMetersPath == null ? null : heatMetersPath.TMeterRefWarm1.ReadTempOp(ref TempRefHi1))
@@ -308,7 +318,11 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection
IList<GenericDevices.IRoi> rois = new List<GenericDevices.IRoi>();
foreach (var rr in sensPath.RegisterReaders)
{
if (rr is GenericDevices.IRoi) rois.Add(rr as GenericDevices.IRoi);
GenericDevices.IRoi roi = rr as GenericDevices.IRoi;
if (roi != null && roi.Detected)
{
rois.Add(roi);
}
}
/// Find cameras
@@ -317,7 +331,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection
{
if (roi.Camera != null && !cameras.Contains(roi.Camera))
{
roi.Camera.ClearRois();
roi.Camera.ClearRoiParams();
cameras.Add(roi.Camera);
}
}
@@ -339,7 +353,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection
if (dataEntryCmpnt != null)
{
Bridge.OnActivity(this, Strings.Enter_water_meter_data);
State.Create("FixedStartMassCollection : Enter begin-state")
State.Create(string.Format("{0}({1}) : Entering begin-state", test.Method, test.Name))
.AddOperation((dataEntryCmpnt as GenericDevices.IHasWMStatesForm).ShowTestStartFormOp())
.AddOperation(heatMetersPath == null ? null : heatMetersPath.TMeterRefWarm1.ReadTempOp(ref TempRefHi1))
.AddOperation(heatMetersPath == null ? null : heatMetersPath.TMeterRefWarm2.ReadTempOp(ref TempRefHi2))
@@ -387,7 +401,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection
//------------------------------------------------
Bridge.OnActivity(this, Strings.Measuring_the_weight);
//------------------------------------------------
State.Create("FixedStartMassCollection : Measuring the start mass")
State.Create(string.Format("{0}({1}) : Measuring the start mass", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperations(measureOperations)
.AddOperation(benchPath.TempMtrUp == null ? null : benchPath.TempMtrUp.ReadTempOp(ref TempUp))
@@ -402,7 +416,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection
.AddOperation(heatMetersPath == null ? null : heatMetersPath.TMeterRefCold2.ReadTempOp(ref TempRefLo2))
.AddOperation((StateMachine.Ambient != null)
? StateMachine.Ambient.ReadAmbientOp(AmbTemp, AmbPress, AmbHumi) : null)
.AddOperation(outPath.Balance.ReadStableMassOp(ref StartMass, test.MassRepeats, test.MassSpread, test.MassMethod))
.AddOperation(outPath.Scale.ReadStableMassOp(ref StartMass, test.MassRepeats, test.MassSpread, test.MassMethod))
.AddOperation(cBrd.UpdateTankWeightOp())
.AddOperation(processDataLoggingOp)
.EnterState();
@@ -419,7 +433,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection
//------------------------------------------------
Bridge.OnActivity(this, Strings.Test_in_progress);
//------------------------------------------------
State.Create("FixedStartMassCollection : Starting the test")
State.Create(string.Format("{0}({1}) : Starting the test", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperations(measureOperations)
.AddOperation(benchPath.TempMtrUp == null ? null : benchPath.TempMtrUp.ReadTempOp(ref TempUp))
@@ -444,7 +458,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection
while (!e.Contains(Event.MeasurementStarted));
State.Create("FixedStartMassCollection : Opening the start/stop valve at the beginning of the fixed start test")
State.Create(string.Format("{0}({1}) : Opening the start/stop valve at the beginning of the fixed start test", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperation(benchPath.TempMtrUp == null ? null : benchPath.TempMtrUp.ReadTempOp(ref TempUp))
.AddOperation(benchPath.TempMtrDown == null ? null : benchPath.TempMtrDown.ReadTempOp(ref TempDown))
@@ -550,7 +564,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection
test_completed:
State.Create("FixedStartMassCollection : Closing the start/stop valve at the end of the fixed start test")
State.Create(string.Format("{0}({1}) : Closing the start/stop valve at the end of the fixed start test", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperation(benchPath.TempMtrUp == null ? null : benchPath.TempMtrUp.ReadTempOp(ref TempUp))
.AddOperation(benchPath.TempMtrDown == null ? null : benchPath.TempMtrDown.ReadTempOp(ref TempDown))
@@ -573,7 +587,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection
while (e.Contains(Event.ValvesBusy));
State.Create("FixedStartMassCollection : Waiting before 2nd mass measurement")
State.Create(string.Format("{0}({1}) : Waiting before 2nd mass measurement", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperation(benchPath.TempMtrUp == null ? null : benchPath.TempMtrUp.ReadTempOp(ref TempUp))
.AddOperation(benchPath.TempMtrDown == null ? null : benchPath.TempMtrDown.ReadTempOp(ref TempDown))
@@ -587,7 +601,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection
.AddOperation(heatMetersPath == null ? null : heatMetersPath.TMeterRefCold2.ReadTempOp(ref TempRefLo2))
.AddOperation((StateMachine.Ambient != null)
? StateMachine.Ambient.ReadAmbientOp(AmbTemp, AmbPress, AmbHumi) : null)
.AddOperation(outPath.Balance.ReadMassOp(ref Mass))
.AddOperation(outPath.Scale.ReadMassOp(ref Mass))
.AddOperation(cBrd.UpdateTankWeightOp())
.AddOperation(processDataLoggingOp)
.AddOperation(new Operations.TimerOp(test.TimeStop2Mass))
@@ -604,7 +618,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection
//------------------------------------------------
Bridge.OnActivity(this, Strings.Measuring_the_weight);
//------------------------------------------------
State.Create("FixedStartMassCollection : Measuring the end mass")
State.Create(string.Format("{0}({1}) : Measuring the end mass", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperation(benchPath.TempMtrUp == null ? null : benchPath.TempMtrUp.ReadTempOp(ref TempUp))
.AddOperation(benchPath.TempMtrDown == null ? null : benchPath.TempMtrDown.ReadTempOp(ref TempDown))
@@ -618,7 +632,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection
.AddOperation(heatMetersPath == null ? null : heatMetersPath.TMeterRefCold2.ReadTempOp(ref TempRefLo2))
.AddOperation((StateMachine.Ambient != null)
? StateMachine.Ambient.ReadAmbientOp(AmbTemp, AmbPress, AmbHumi) : null)
.AddOperation(outPath.Balance.ReadStableMassOp(ref EndMass, test.MassRepeats, test.MassSpread, test.MassMethod))
.AddOperation(outPath.Scale.ReadStableMassOp(ref EndMass, test.MassRepeats, test.MassSpread, test.MassMethod))
.AddOperation(cBrd.UpdateTankWeightOp())
.AddOperation(processDataLoggingOp)
.EnterState();
@@ -633,7 +647,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection
TestEndTime = DateTime.Now;
State.Create("FixedStartMassCollection : Stopping diverter, gate, etc.")
State.Create(string.Format("{0}({1}) : Stopping diverter, gate, etc.", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperation(cBrd.StopPreviousOp())
.EnterState();
@@ -645,8 +659,8 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection
while (!e.Contains(Event.PreviousStopped));
double massStart = Formulas.CorrectedValue(StartMass.Val, outPath.Balance.Corrections);
double massEnd = Formulas.CorrectedValue(EndMass.Val, outPath.Balance.Corrections);
double massStart = Formulas.CorrectedValue(StartMass.Val, outPath.Scale.Corrections);
double massEnd = Formulas.CorrectedValue(EndMass.Val, outPath.Scale.Corrections);
double densityOut = Formulas.WaterDensityFromTemp(TempDownStat.Average); /// [kg/m3]
double volumeCTV = 1001.03 * (massEnd - massStart) / densityOut;
double refEnergy = Energy.Sum * volumeCTV / VolumeForEnergy.Sum; /// [J]=[J]*[l]/[l]
@@ -657,7 +671,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection
if (dataEntryCmpnt != null)
{
Bridge.OnActivity(this, Strings.Enter_water_meter_data);
State state = State.Create("FixedStartMassCollection : Enter end-state");
State state = State.Create(string.Format("{0}({1}) : Entering the end-state", test.Method, test.Name));
if (heatMetersTestParams != null && dataEntryCmpnt is GenericDevices.IHasHeatMtrStatesForm)
{
state.AddOperation((dataEntryCmpnt as GenericDevices.IHasHeatMtrStatesForm).
@@ -942,7 +956,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection
(BenchInfo != null) ? BenchInfo.TestBenchName : "testbench",
inPath.Pump != null ? inPath.Pump.Name : string.Empty,
outPath.FlowMeter != null ? outPath.FlowMeter.Name : string.Empty,
outPath.Balance != null ? outPath.Balance.Name : string.Empty,
outPath.Scale != null ? outPath.Scale.Name : string.Empty,
outPath.RegulValve != null ? outPath.RegulValve.Name : string.Empty,
outPath.Diverter != null ? outPath.Diverter.Name : string.Empty));
@@ -967,7 +981,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection
/// Quit this sequence ///
///----------------------///
State.Create("FixedStartMassCollection : Stopping diverter, gate, etc.")
State.Create(string.Format("{0}({1}) : Stopping diverter, gate, etc.", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperation(cBrd.StopPreviousOp())
.EnterState();
@@ -982,10 +996,12 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection
/// Prevent overwriting 'retVal' in case it was set to non-default value earlier
switch (Transition(transitionAfter, (retVal == Event.Done) ? TransitionContext.AfterTest : TransitionContext.Stop))
{
case Event.Error: { if (retVal == Event.Done) retVal = Event.Error; break; }
case Event.Error: { if (retVal == Event.Done) retVal = Event.Error; break; }
case Event.UiCmdStop: { if (retVal == Event.Done) retVal = Event.UiCmdStop; break; }
}
stopTestWOTransitionAfter:
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.Completed));
/// Create a list with one item 'retVal' (default is Event.Done) and return it
@@ -75,11 +75,11 @@ namespace TBF.BenchControl.TestMethods.FlyingStart
}
}
//------------------------------------------------
Bridge.OnActivity(this, string.Format("Simulating {0}", test.Name));
//------------------------------------------------
//------------------------------------------------------------------
Bridge.OnActivity(this, string.Format("{0} simulation", test.Name));
//------------------------------------------------------------------
State.Create(string.Format("FlyingStart : Simulating {0}", test.Name))
State.Create(string.Format("{0}({1}) : Simulating {0}", test.Method, test.Name))
.AddOperation(checkUiOp)
.EnterState();
e = StateMachine.WaitRunDevsRunOps();
@@ -142,10 +142,10 @@ namespace TBF.BenchControl.TestMethods.FlyingStart
//------------------------------------------------
if (inPath.Pump is GenericDevices.IPumpFM) (inPath.Pump as GenericDevices.IPumpFM).TurnOn(test.PumpPower);
///
State.Create("FlyingStart : Starting the pump")
State.Create(string.Format("{0}({1}) : Starting the pump", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp())
.AddOperation(new Operations.SetAllRegulValvesOp(inPath.RegulValves, inPath.RegulValvesPct, 60))
// .AddOperation(new Operations.SetAllRegulValvesOp(inPath.RegulValves, inPath.RegulValvesPct, 60))
.AddOperation(heatMetersPromptOp)
.AddOperation(inPath.Pump != null ? cBrd.SetValvesOp(inPath.Pump, null) : null)
.EnterState();
@@ -158,13 +158,13 @@ namespace TBF.BenchControl.TestMethods.FlyingStart
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
}
while (e.Contains(Event.ValvesBusy) || !e.Contains(Event.AllPositionsReached));
while (e.Contains(Event.ValvesBusy) /* || !e.Contains(Event.AllPositionsReached)*/);
//------------------------------------------------
Bridge.OnActivity(this, Strings.Setting_the_flow);
//------------------------------------------------
int flowSetTime0 = StateMachine.Time;
State.Create("FlyingStart : Setting the flow")
State.Create(string.Format("{0}({1}) : Setting the flow", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperation(outPath.RegulValve.SetFlowOp(outPath.FlowMeter, test.Qfrom, test.Qto, outPath.PidCoef, RefFlow, 990)) /// timeout = 16.5 min.
.AddOperation(heatMetersPromptOp)
@@ -202,7 +202,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStart
double Tw_last = 0;
double Tc_last = 0;
State.Create("FlyingStart : Check temperature stabilized.")
State.Create(string.Format("{0}({1}) : Checking if the temperature is stable", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperation(heatMetersPath.TMeterRefWarm1.ReadTempOp(ref TempRefHi1))
.AddOperation(heatMetersPath.TMeterRefWarm2.ReadTempOp(ref TempRefHi2))
@@ -252,7 +252,11 @@ namespace TBF.BenchControl.TestMethods.FlyingStart
IList<GenericDevices.IRoi> rois = new List<GenericDevices.IRoi>();
foreach (var rr in sensPath.RegisterReaders)
{
if (rr is GenericDevices.IRoi) rois.Add(rr as GenericDevices.IRoi);
GenericDevices.IRoi roi = rr as GenericDevices.IRoi;
if (roi != null && roi.Detected)
{
rois.Add(roi);
}
}
/// Find cameras
@@ -261,7 +265,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStart
{
if (roi.Camera != null && !cameras.Contains(roi.Camera))
{
roi.Camera.ClearRois();
roi.Camera.ClearRoiParams();
cameras.Add(roi.Camera);
}
}
@@ -278,7 +282,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStart
//------------------------------------------------
Bridge.OnActivity(this, Strings.Test_in_progress);
//------------------------------------------------
State.Create("FlyingStart : Starting the test")
State.Create(string.Format("{0}({1}) : Starting the test", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperations(measureOperations)
.AddOperation(benchPath.TempMtrUp == null ? null : benchPath.TempMtrUp.ReadTempOp(ref TempUp))
@@ -566,6 +570,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStart
Results.Entities.MeterTestRslt meterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.Single);
GenericDevices.IRegisterReader regReader = sensPath.RegisterReaders[i];
WaterMeters.iPerl.WaterMeter iPerl = regReader as WaterMeters.iPerl.WaterMeter;
GenericDevices.IRoi cameraRoi = regReader as GenericDevices.IRoi;
if (meterRslt != null && regReader != null)
{
@@ -585,12 +590,26 @@ namespace TBF.BenchControl.TestMethods.FlyingStart
iPerl.VolumeLtrRef = meterRslt.VolumeRef;
#if IPERL
meterRslt.WaterMeter.CalibFactor = (iPerl.CalibrationStruct != null) ? iPerl.CalibrationStruct.Calibration : 0;
meterRslt.WaterMeter.Q2Correction = iPerl.Q2CorrectionFactor;
meterRslt.WaterMeter.Q2Correction = iPerl.Q2Correction;
meterRslt.WaterMeter.Q2CorrRFlow = iPerl.Q2CorrRFlow;
meterRslt.WaterMeter.Q2CorrLFlow = iPerl.Q2CorrLFlow;
#endif
iPerl.LastTestResult2 = iPerl.LastTestResult; /// Save shift previous test result
iPerl.LastTestResult = meterRslt; /// Save this test result
iPerl.NominalTestFlow = 500.0 * (test.Qfrom + test.Qto); /// Ave. + convert to liter/hour
}
else if (cameraRoi != null)
{
meterRslt.TimestampStart = cameraRoi.TimestampStart; /// second
meterRslt.TimestampEnd = cameraRoi.TimestampEnd; /// second
meterRslt.TestTime = cameraRoi.TimestampEnd - cameraRoi.TimestampStart; /// second
meterRslt.VolumeStart = cameraRoi.VolumeStart; /// liter
meterRslt.VolumeEnd = cameraRoi.VolumeEnd; /// liter
meterRslt.VolumeMeter = cameraRoi.VolumeEnd - cameraRoi.VolumeStart; /// liter
meterRslt.VolumeRef = tstRslt.VolumeCTV * meterRslt.TestTime / tstRslt.TestTime;
}
else
{
meterRslt.TestTime = tstRslt.TestTime; /// TODO: Malo by sa citat z dosky
@@ -614,7 +633,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStart
(BenchInfo != null) ? BenchInfo.TestBenchName : "testbench",
inPath.Pump != null ? inPath.Pump.Name : string.Empty,
outPath.FlowMeter != null ? outPath.FlowMeter.Name : string.Empty,
outPath.Balance != null ? outPath.Balance.Name : string.Empty,
outPath.Scale != null ? outPath.Scale.Name : string.Empty,
outPath.RegulValve != null ? outPath.RegulValve.Name : string.Empty,
outPath.Diverter != null ? outPath.Diverter.Name : string.Empty));
@@ -639,7 +658,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStart
/// Quit this sequence ///
///----------------------///
State.Create("FlyingStart : Stopping diverter, gate, etc.")
State.Create(string.Format("{0}({1}) : Stopping diverter, gate, etc.", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperation(cBrd.StopPreviousOp())
.EnterState();
@@ -76,10 +76,10 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection
}
//------------------------------------------------
Bridge.OnActivity(this, string.Format("Simulating {0}", test.Name));
Bridge.OnActivity(this, string.Format("{0} Simulation", test.Name));
//------------------------------------------------
State.Create(string.Format("FlyingStartMassCollection : Simulating {0}", test.Name))
State.Create(string.Format("{0}({1}) : Simulation", test.Method, test.Name))
.AddOperation(checkUiOp)
.EnterState();
e = StateMachine.WaitRunDevsRunOps();
@@ -102,7 +102,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection
int repetitionNr = outerLoopMode ? outerLoopCounter : 1; /// First test: repetitionNr = 1
if (test.Volume >= outPath.Balance.Capacity * Constants.TankFullFactor)
if (test.Volume >= outPath.Scale.Capacity * Constants.TankFullFactor)
{
Bridge.OnError(this, Strings.Test_volume_exceeds_the_scale_capacity);
retVal = Event.UiCmdStop;
@@ -127,22 +127,21 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection
TestStartTime = DateTime.Now;
TestProgressEventArgs.SetEstimatedTimes(new int[] { 1, 1, 1, 30, Convert.ToInt32(test.TstTime) + 15, 0, 0 });
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.JustStarted));
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting));
int flowSetTime0 = StateMachine.Time;
//------------------------------------------------
Bridge.OnActivity(this, Strings.Checking_tank_capacity);
//------------------------------------------------
bool emptyTheTank = test.Emptying;
bool drainTheTank = test.Draining;
if (!emptyTheTank) /// If condition met => skip measuring and force emptying
if (!drainTheTank) /// If condition met => skip measuring and force emptying
{
///
/// Measure the weight and skip emptying if there is enough room in the tank
///
State.Create("FlyingStartMassCollection : Checking available tank capacity")
State.Create(string.Format("{0}({1}) : Checking available tank capacity", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperation(outPath.Balance.ReadMassOp(ref Mass))
.AddOperation(outPath.Scale.ReadMassOp(ref Mass))
.EnterState();
do
{
@@ -153,27 +152,38 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection
while (!e.Contains(Event.BalanceDone));
double estimatedEndMass = Mass.Val + test.Volume;
if (estimatedEndMass >= outPath.Balance.Capacity * Constants.TankFullFactor)
if (estimatedEndMass >= outPath.Scale.Capacity * Constants.TankFullFactor)
{
emptyTheTank = true;
drainTheTank = true;
}
}
///
if (emptyTheTank)
if (drainTheTank)
{
State.Create("FlyingStartMassCollection : Opening the emptying valve")
#if BERLIN
switch (DrainTheTank(outPath.Scale.DrainValve, outPath.Scale))
{
case Event.Error: { retVal = Event.Error; goto stopTest; }
case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; }
}
drainTheTank = false;
#else
State.Create(string.Format("{0}({1}) : Opening the emptying valve", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperation(StateMachine.ControlBoard.SetValvesOp(outPath.EmptyTankValve, null))
.AddOperation(StateMachine.ControlBoard.SetValvesOp(outPath.Scale.DrainValve, null))
.EnterState();
do
{
e = StateMachine.WaitRunDevsRunOps();
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
}
while (!e.Contains(Event.ValvesSet));
#endif
}
///
/// Optionally display prompt to emerge temperature meters to appropriate baths for heat meters test
///
@@ -186,15 +196,20 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection
heatMetersPromptOp = new Operations.MessageBoxOp(heatMetersTestParams.Prompt);
}
//------------------------------------------------
Bridge.OnActivity(this, Strings.Starting_the_pump);
//------------------------------------------------
if (inPath.Pump is GenericDevices.IPumpFM) (inPath.Pump as GenericDevices.IPumpFM).TurnOn(test.PumpPower);
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting));
int flowSetTime0 = StateMachine.Time;
if (inPath.Pump is GenericDevices.IPumpFM) (inPath.Pump as GenericDevices.IPumpFM).TurnOn(test.PumpPower);
///
State.Create("FlyingStartMassCollection : Starting the pump")
State.Create(string.Format("{0}({1}) : Starting the pump", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp())
.AddOperation(new Operations.SetAllRegulValvesOp(inPath.RegulValves, inPath.RegulValvesPct, 60))
// .AddOperation(new Operations.SetAllRegulValvesOp(inPath.RegulValves, inPath.RegulValvesPct, 60))
.AddOperation(heatMetersPromptOp)
.AddOperation(inPath.Pump != null ? cBrd.SetValvesOp(inPath.Pump, null) : null)
.EnterState();
@@ -207,12 +222,12 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
}
while (e.Contains(Event.ValvesBusy) || !e.Contains(Event.AllPositionsReached));
while (e.Contains(Event.ValvesBusy) /* || !e.Contains(Event.AllPositionsReached)*/);
if (test.TimePump2StartV > 0)
{
State.Create("FlyingStartMassCollection : Waiting after the pump started")
State.Create(string.Format("{0}({1}) : Waiting after the pump started", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperation(new Operations.TimerOp(test.TimePump2StartV))
.AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp())
@@ -232,7 +247,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection
if (benchPath.StopBFValve != null)
{
State.Create("FlyingStartMassCollection : Opening the stop backflow valve")
State.Create(string.Format("{0}({1}) : Opening the stop backflow valve", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperation(StateMachine.ControlBoard.SetValvesOp(benchPath.StopBFValve, null))
.AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp())
@@ -250,7 +265,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection
if (test.TimeBeforeFlow > 0)
{
State.Create("FlyingStartMassCollection : Waiting before flow setting process starts")
State.Create(string.Format("{0}({1}) : Waiting before flow setting process starts", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperation(new Operations.TimerOp(test.TimeBeforeFlow))
.AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp())
@@ -273,7 +288,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection
//------------------------------------------------
Bridge.OnActivity(this, Strings.Setting_the_flow);
//------------------------------------------------
State.Create("FlyingStartMassCollection : Setting the flow")
State.Create(string.Format("{0}({1}) : Setting the flow", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp())
.AddOperation(outPath.RegulValve.SetFlowOp(outPath.FlowMeter, test.Qfrom, test.Qto, outPath.PidCoef, RefFlow, 990)) /// timeout = 16.5 min.
@@ -312,7 +327,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection
double Tw_last = 0;
double Tc_last = 0;
State.Create("FlyingStartMassCollection : Check temperature stabilized.")
State.Create(string.Format("{0}({1}) : Check temperature stabilized.", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperation(heatMetersPath.TMeterRefWarm1.ReadTempOp(ref TempRefHi1))
.AddOperation(heatMetersPath.TMeterRefWarm2.ReadTempOp(ref TempRefHi2))
@@ -358,11 +373,15 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection
/// Prepare cameras, ROI-s and measurementOperations
///
/// Find ROI-s
/// Find successfully detected ROI-s
IList<GenericDevices.IRoi> rois = new List<GenericDevices.IRoi>();
foreach (var rr in sensPath.RegisterReaders)
{
if (rr is GenericDevices.IRoi) rois.Add(rr as GenericDevices.IRoi);
GenericDevices.IRoi roi = rr as GenericDevices.IRoi;
if (roi != null && roi.Detected)
{
rois.Add(roi);
}
}
/// Find cameras
@@ -371,8 +390,8 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection
{
if (roi.Camera != null && !cameras.Contains(roi.Camera))
{
roi.Camera.ClearRois();
cameras.Add(roi.Camera);
roi.Camera.ClearRoiParams();
}
}
@@ -384,8 +403,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection
foreach (var camera in cameras) measureOperations.Add(camera.MeasurementOp());
if (emptyTheTank)
if (drainTheTank)
{
//------------------------------------------------
Bridge.OnActivity(this, Strings.Closing_the_tank);
@@ -402,18 +420,19 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection
extraOps.Add(heatMetersPath.TMeterRefCold1.ReadTempOp(ref TempRefLo1));
extraOps.Add(heatMetersPath.TMeterRefCold2.ReadTempOp(ref TempRefLo2));
}
switch (EmptyTheTank(outPath.EmptyTankValve, outPath.Balance, extraOps))
switch (DrainTheTank(outPath.Scale.DrainValve, outPath.Scale, extraOps))
{
case Event.Error: { retVal = Event.Error; goto stopTest; }
case Event.Error: { retVal = Event.Error; goto stopTest; }
case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; }
}
emptyTheTank = false;
drainTheTank = false;
}
if (test.TimeFlow2Mass > 0)
{
State.Create("FlyingStartMassCollection : Waiting before 1st mass measurement")
State.Create(string.Format("{0}({1}) : Waiting before 1st mass measurement", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperation(heatMetersPath == null ? null : heatMetersPath.TMeterRefWarm1.ReadTempOp(ref TempRefHi1))
.AddOperation(heatMetersPath == null ? null : heatMetersPath.TMeterRefWarm2.ReadTempOp(ref TempRefHi2))
@@ -441,7 +460,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection
else
LogProcessHeaderHeatMeters(processDataLogger, "Start mass");
State.Create("FlyingStartMassCollection : Measuring the start mass")
State.Create(string.Format("{0}({1}) : Measuring the start mass", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperations(measureOperations)
.AddOperation(benchPath.TempMtrUp == null ? null : benchPath.TempMtrUp.ReadTempOp(ref TempUp))
@@ -456,7 +475,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection
.AddOperation(heatMetersPath == null ? null : heatMetersPath.TMeterRefCold2.ReadTempOp(ref TempRefLo2))
.AddOperation((StateMachine.Ambient != null)
? StateMachine.Ambient.ReadAmbientOp(AmbTemp, AmbPress, AmbHumi) : null)
.AddOperation(outPath.Balance.ReadStableMassOp(ref StartMass, test.MassRepeats, test.MassSpread, test.MassMethod))
.AddOperation(outPath.Scale.ReadStableMassOp(ref StartMass, test.MassRepeats, test.MassSpread, test.MassMethod))
.AddOperation(cBrd.UpdateTankWeightOp())
.AddOperation(processDataLoggingOp)
.EnterState();
@@ -479,7 +498,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection
//------------------------------------------------
Bridge.OnActivity(this, Strings.Test_in_progress);
//------------------------------------------------
State.Create("FlyingStartMassCollection : Starting the test")
State.Create(string.Format("{0}({1}) : Starting the test", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperations(measureOperations)
.AddOperation(benchPath.TempMtrUp == null ? null : benchPath.TempMtrUp.ReadTempOp(ref TempUp))
@@ -521,7 +540,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection
ClearAllStatistics();
/// Measurement loop - begin
State.Create("Read water meters")
State.Create(string.Format("{0}({1}) : Reading watermeters", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperations(measureOperations)
.AddOperation(readRegistersOp)
@@ -535,7 +554,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection
.AddOperation(heatMetersPath == null ? null : heatMetersPath.TMeterRefWarm2.ReadTempOp(ref TempRefHi2))
.AddOperation(heatMetersPath == null ? null : heatMetersPath.TMeterRefCold1.ReadTempOp(ref TempRefLo1))
.AddOperation(heatMetersPath == null ? null : heatMetersPath.TMeterRefCold2.ReadTempOp(ref TempRefLo2))
.AddOperation(outPath.Balance.ReadMassOp(ref Mass))
.AddOperation(outPath.Scale.ReadMassOp(ref Mass))
.AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp())
.AddOperation((StateMachine.Ambient != null)
? StateMachine.Ambient.ReadAmbientOp(AmbTemp, AmbPress, AmbHumi)
@@ -589,7 +608,8 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection
Bridge.OnProcessData(this, new ProcessDataEventArgs(test, repetitionNr, Config.Entities.Progress.Test));
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.Test));
}
while (true);
while (!e.Contains(Event.Next)); /// 'Next' button can be used in Debug version
/// Measurement loop - end
test_completed:
@@ -611,7 +631,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection
//------------------------------------------------
Bridge.OnActivity(this, Strings.Measuring_the_weight);
//------------------------------------------------
State.Create("FlyingStartMassCollection : Waiting before the 2nd mass measurement")
State.Create(string.Format("{0}({1}) : Waiting before the 2nd mass measurement", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperation(benchPath.TempMtrUp == null ? null : benchPath.TempMtrUp.ReadTempOp(ref TempUp))
.AddOperation(benchPath.TempMtrDown == null ? null : benchPath.TempMtrDown.ReadTempOp(ref TempDown))
@@ -625,7 +645,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection
.AddOperation(heatMetersPath == null ? null : heatMetersPath.TMeterRefCold2.ReadTempOp(ref TempRefLo2))
.AddOperation((StateMachine.Ambient != null)
? StateMachine.Ambient.ReadAmbientOp(AmbTemp, AmbPress, AmbHumi) : null)
.AddOperation(outPath.Balance.ReadMassOp(ref Mass))
.AddOperation(outPath.Scale.ReadMassOp(ref Mass))
.AddOperation(cBrd.UpdateTankWeightOp())
.AddOperation(processDataLoggingOp)
.AddOperation(new Operations.TimerOp(test.TimeStop2Mass))
@@ -636,14 +656,14 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
if (TestAndLogUiCmdStop(test,e)) { retVal = Event.UiCmdStop; goto stopTest; }
}
while (!e.Contains(Event.TimerExpired));
while (!e.Contains(Event.TimerExpired) || !e.Contains(Event.BalanceDone));
if (heatMetersPath == null)
LogProcessHeader(processDataLogger, "End mass");
else
LogProcessHeaderHeatMeters(processDataLogger, "End mass");
State.Create("FlyingStartMassCollection : Measuring the end mass")
State.Create(string.Format("{0}({1}) : Measuring the end mass", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperation(benchPath.TempMtrUp == null ? null : benchPath.TempMtrUp.ReadTempOp(ref TempUp))
.AddOperation(benchPath.TempMtrDown == null ? null : benchPath.TempMtrDown.ReadTempOp(ref TempDown))
@@ -657,7 +677,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection
.AddOperation(heatMetersPath == null ? null : heatMetersPath.TMeterRefCold2.ReadTempOp(ref TempRefLo2))
.AddOperation((StateMachine.Ambient != null)
? StateMachine.Ambient.ReadAmbientOp(AmbTemp, AmbPress, AmbHumi) : null)
.AddOperation(outPath.Balance.ReadStableMassOp(ref EndMass, test.MassRepeats, test.MassSpread, test.MassMethod))
.AddOperation(outPath.Scale.ReadStableMassOp(ref EndMass, test.MassRepeats, test.MassSpread, test.MassMethod))
.AddOperation(cBrd.UpdateTankWeightOp())
.AddOperation(processDataLoggingOp)
.EnterState();
@@ -746,9 +766,9 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection
tstRslt.TestTime = cBrd.TTime; /// [s] measurement time
tstRslt.PulsesMaster = Convert.ToDouble(cBrd.EtPulses(0)); /// Pulses of the master flow meter (test total)
tstRslt.MassStartRaw = StartMass.Val;
tstRslt.MassStart = Formulas.CorrectedValue(tstRslt.MassStartRaw, outPath.Balance.Corrections);
tstRslt.MassStart = Formulas.CorrectedValue(tstRslt.MassStartRaw, outPath.Scale.Corrections);
tstRslt.MassEndRaw = EndMass.Val;
tstRslt.MassEnd = Formulas.CorrectedValue(tstRslt.MassEndRaw, outPath.Balance.Corrections);
tstRslt.MassEnd = Formulas.CorrectedValue(tstRslt.MassEndRaw, outPath.Scale.Corrections);
tstRslt.FlowMass = 3600.0 * (tstRslt.MassEnd - tstRslt.MassStart) / tstRslt.TestTime; /// [kg/h]
tstRslt.FlowVolume = 3.6 * LtrPerRefPulse * tstRslt.PulsesMaster / tstRslt.TestTime; /// [m3/h]
tstRslt.VolumeCTV = 1001.03 * (tstRslt.MassEnd - tstRslt.MassStart) / tstRslt.DensityOut; /// [l] 1000.0f is because density is in [kg/m3]
@@ -895,6 +915,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection
Results.Entities.MeterTestRslt meterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.Single);
GenericDevices.IRegisterReader regReader = sensPath.RegisterReaders[i];
WaterMeters.iPerl.WaterMeter iPerl = regReader as WaterMeters.iPerl.WaterMeter;
GenericDevices.IRoi cameraRoi = regReader as GenericDevices.IRoi;
if (meterRslt != null && regReader != null)
{
@@ -914,15 +935,29 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection
iPerl.VolumeLtrRef = meterRslt.VolumeRef;
#if IPERL
meterRslt.WaterMeter.CalibFactor = (iPerl.CalibrationStruct != null) ? iPerl.CalibrationStruct.Calibration : 0;
meterRslt.WaterMeter.Q2Correction = iPerl.Q2CorrectionFactor;
meterRslt.WaterMeter.Q2Correction = iPerl.Q2Correction;
meterRslt.WaterMeter.Q2CorrRFlow = iPerl.Q2CorrRFlow;
meterRslt.WaterMeter.Q2CorrLFlow = iPerl.Q2CorrLFlow;
#endif
iPerl.LastTestResult2 = iPerl.LastTestResult; /// Save shift previous test result
iPerl.LastTestResult = meterRslt; /// Save this test result
iPerl.NominalTestFlow = 500.0 * (test.Qfrom + test.Qto); /// Ave. + convert to liter/hour
}
else if (cameraRoi != null)
{
meterRslt.TimestampStart = cameraRoi.TimestampStart; /// second
meterRslt.TimestampEnd = cameraRoi.TimestampEnd; /// second
meterRslt.TestTime = cameraRoi.TimestampEnd - cameraRoi.TimestampStart; /// second
meterRslt.VolumeStart = cameraRoi.VolumeStart; /// liter
meterRslt.VolumeEnd = cameraRoi.VolumeEnd; /// liter
meterRslt.VolumeMeter = cameraRoi.VolumeEnd - cameraRoi.VolumeStart; /// liter
meterRslt.VolumeRef = tstRslt.VolumeCTV * meterRslt.TestTime / tstRslt.TestTime;
}
else
{
meterRslt.TestTime = tstRslt.TestTime; /// TODO: Malo by sa citat z dosky
meterRslt.TestTime = tstRslt.TestTime; /// TODO: Malo by sa citat z dosky
meterRslt.VolumeStart = 0; /// liter
meterRslt.VolumeEnd = 0; /// liter
meterRslt.VolumeMeter = meterRslt.PulsesMeter * regReader.LtrsPerPulse; /// liter
@@ -942,7 +977,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection
(BenchInfo != null) ? BenchInfo.TestBenchName : "testbench",
inPath.Pump != null ? inPath.Pump.Name : string.Empty,
outPath.FlowMeter != null ? outPath.FlowMeter.Name : string.Empty,
outPath.Balance != null ? outPath.Balance.Name : string.Empty,
outPath.Scale != null ? outPath.Scale.Name : string.Empty,
outPath.RegulValve != null ? outPath.RegulValve.Name : string.Empty,
outPath.Diverter != null ? outPath.Diverter.Name : string.Empty));
@@ -966,7 +1001,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection
/// Quit this sequence ///
///----------------------///
State.Create("FlyingStartMassCollection : Stopping diverter, gate, etc.")
State.Create(string.Format("{0}({1}) : Stopping diverter, gate, etc.", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperation(cBrd.StopPreviousOp())
.EnterState();
@@ -58,14 +58,14 @@ namespace TBF.BenchControl.TestMethods.LeakTest
//------------------------------------------------
if (inPath.Pump is GenericDevices.IPumpFM) (inPath.Pump as GenericDevices.IPumpFM).TurnOn(test.PumpPower);
State.Create("LeakTest : Starting the pump")
State.Create(string.Format("{0}({1}) : Starting the pump", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperation(benchPath.TempMtrUp.ReadTempOp(ref TempUp))
.AddOperation(benchPath.TempMtrDown.ReadTempOp(ref TempDown))
.AddOperation(benchPath.PressMtrUp.ReadPressureOp(ref PressUp))
.AddOperation(benchPath.PressMtrDown.ReadPressureOp(ref PressDown))
.AddOperation(benchPath.PressMtrDelta == null ? null : benchPath.PressMtrDelta.ReadPressureOp(ref PressDelta))
.AddOperation(new Operations.SetAllRegulValvesOp(inPath.RegulValves, inPath.RegulValvesPct, 60))
// .AddOperation(new Operations.SetAllRegulValvesOp(inPath.RegulValves, inPath.RegulValvesPct, 60))
.AddOperation(inPath.Pump != null ? cBrd.SetValvesOp(inPath.Pump, null) : null)
.EnterState();
do
@@ -74,7 +74,7 @@ namespace TBF.BenchControl.TestMethods.LeakTest
if (TestAndLogUiCmdStop(test,e)) { retVal = Event.UiCmdStop; goto stopTest; }
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
}
while (e.Contains(Event.ValvesBusy) || !e.Contains(Event.AllPositionsReached));
while (e.Contains(Event.ValvesBusy) /* || !e.Contains(Event.AllPositionsReached)*/);
//------------------------------------------------
@@ -89,7 +89,7 @@ namespace TBF.BenchControl.TestMethods.LeakTest
{
if (inPath.Pump is GenericDevices.IPumpFM) (inPath.Pump as GenericDevices.IPumpFM).TurnOn(pumpPower);
State.Create("LeakTest : Setting the water pressure")
State.Create(string.Format("{0}({1}) : Setting the water pressure", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperation(benchPath.TempMtrUp.ReadTempOp(ref TempUp))
.AddOperation(benchPath.TempMtrDown.ReadTempOp(ref TempDown))
@@ -143,7 +143,7 @@ namespace TBF.BenchControl.TestMethods.LeakTest
Bridge.OnActivity(this, Strings.Test_in_progress);
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, 1, Config.Entities.Progress.Test));
//------------------------------------------------
State.Create("LeakTest : Maximum water pressure set")
State.Create(string.Format("{0}({1}) : Maximum water pressure set", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperation(benchPath.TempMtrUp.ReadTempOp(ref TempUp))
.AddOperation(benchPath.TempMtrDown.ReadTempOp(ref TempDown))
@@ -178,7 +178,7 @@ namespace TBF.BenchControl.TestMethods.LeakTest
//------------------------------------------------
Bridge.OnActivity(this, Strings.Closing_valve_Pump_off);
//------------------------------------------------
State.Create("LeakTest : Closing the valve")
State.Create(string.Format("{0}({1}) : Closing the valve", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperation(cBrd.SetValvesOp(null, outPath.StartValve))
.AddOperation(benchPath.TempMtrUp.ReadTempOp(ref TempUp))
@@ -202,7 +202,7 @@ namespace TBF.BenchControl.TestMethods.LeakTest
if (inPath.Pump is GenericDevices.IPumpFM) (inPath.Pump as GenericDevices.IPumpFM).TurnOff();
State.Create("LeakTest : Closing the valve")
State.Create(string.Format("{0}({1}) : Closing the valve", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperation(cBrd.SetValvesOp(null, inPath.Pump))
.AddOperation(benchPath.TempMtrUp.ReadTempOp(ref TempUp))
@@ -233,7 +233,7 @@ namespace TBF.BenchControl.TestMethods.LeakTest
//------------------------------------------------
Bridge.OnActivity(this, Strings.Test_in_progress);
//------------------------------------------------
State.Create("LeakTest : Starting the test")
State.Create(string.Format("{0}({1}) : Starting the test", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperation(benchPath.TempMtrUp.ReadTempOp(ref TempUp))
.AddOperation(benchPath.TempMtrDown.ReadTempOp(ref TempDown))
@@ -401,7 +401,7 @@ namespace TBF.BenchControl.TestMethods.LeakTest
(BenchInfo != null) ? BenchInfo.TestBenchName : "testbench",
inPath.Pump != null ? inPath.Pump.Name : string.Empty,
outPath.FlowMeter != null ? outPath.FlowMeter.Name : string.Empty,
outPath.Balance != null ? outPath.Balance.Name : string.Empty,
outPath.Scale != null ? outPath.Scale.Name : string.Empty,
outPath.RegulValve != null ? outPath.RegulValve.Name : string.Empty,
outPath.Diverter != null ? outPath.Diverter.Name : string.Empty));
@@ -422,7 +422,7 @@ namespace TBF.BenchControl.TestMethods.LeakTest
///
/// Quit this sequence
///
State.Create("LeakTest : Stopping diverter, gate, etc.")
State.Create(string.Format("{0}({1}) : Stopping diverter, gate, etc.", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperation(cBrd.StopPreviousOp())
.EnterState();
@@ -59,14 +59,14 @@ namespace TBF.BenchControl.TestMethods.PMaxTest
//------------------------------------------------
if (inPath.Pump is GenericDevices.IPumpFM) (inPath.Pump as GenericDevices.IPumpFM).TurnOn(test.PumpPower);
State.Create("PMaxTest : Starting the pump")
State.Create(string.Format("{0}({1}) : Starting the pump", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperation(benchPath.TempMtrUp.ReadTempOp(ref TempUp))
.AddOperation(benchPath.TempMtrDown.ReadTempOp(ref TempDown))
.AddOperation(benchPath.PressMtrUp.ReadPressureOp(ref PressUp))
.AddOperation(benchPath.PressMtrDown.ReadPressureOp(ref PressDown))
.AddOperation(benchPath.PressMtrDelta == null ? null : benchPath.PressMtrDelta.ReadPressureOp(ref PressDelta))
.AddOperation(new Operations.SetAllRegulValvesOp(inPath.RegulValves, inPath.RegulValvesPct, 60))
// .AddOperation(new Operations.SetAllRegulValvesOp(inPath.RegulValves, inPath.RegulValvesPct, 60))
.AddOperation(inPath.Pump != null ? cBrd.SetValvesOp(inPath.Pump, null) : null)
.EnterState();
do
@@ -75,7 +75,7 @@ namespace TBF.BenchControl.TestMethods.PMaxTest
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
}
while (e.Contains(Event.ValvesBusy) || !e.Contains(Event.AllPositionsReached));
while (e.Contains(Event.ValvesBusy) /* || !e.Contains(Event.AllPositionsReached)*/);
//------------------------------------------------
@@ -90,7 +90,7 @@ namespace TBF.BenchControl.TestMethods.PMaxTest
{
if (inPath.Pump is GenericDevices.IPumpFM) (inPath.Pump as GenericDevices.IPumpFM).TurnOn(pumpPower);
State.Create("PMaxTest : Setting the water pressure")
State.Create(string.Format("{0}({1}) : Setting the water pressure", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperation(benchPath.TempMtrUp.ReadTempOp(ref TempUp))
.AddOperation(benchPath.TempMtrDown.ReadTempOp(ref TempDown))
@@ -144,7 +144,7 @@ namespace TBF.BenchControl.TestMethods.PMaxTest
Bridge.OnActivity(this, Strings.Test_in_progress);
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, 1, Config.Entities.Progress.Test));
//------------------------------------------------
State.Create("PMaxTest : Starting the test")
State.Create(string.Format("{0}({1}) : Starting the test", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperation(benchPath.TempMtrUp.ReadTempOp(ref TempUp))
.AddOperation(benchPath.TempMtrDown.ReadTempOp(ref TempDown))
@@ -312,7 +312,7 @@ namespace TBF.BenchControl.TestMethods.PMaxTest
(BenchInfo != null) ? BenchInfo.TestBenchName : "testbench",
inPath.Pump != null ? inPath.Pump.Name : string.Empty,
outPath.FlowMeter != null ? outPath.FlowMeter.Name : string.Empty,
outPath.Balance != null ? outPath.Balance.Name : string.Empty,
outPath.Scale != null ? outPath.Scale.Name : string.Empty,
outPath.RegulValve != null ? outPath.RegulValve.Name : string.Empty,
outPath.Diverter != null ? outPath.Diverter.Name : string.Empty));
@@ -333,7 +333,7 @@ namespace TBF.BenchControl.TestMethods.PMaxTest
///
/// Quit this sequence
///
State.Create("PMaxTest : Stopping diverter, gate, etc.")
State.Create(string.Format("{0}({1}) : Stopping diverter, gate, etc.", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperation(cBrd.StopPreviousOp())
.EnterState();
@@ -103,14 +103,14 @@ namespace TBF.BenchControl.TestMethods.ReferenceFlowmeterCalibration
while (!e.Contains(Event.ValvesSet));
if (!test.Emptying) /// If condition met => skip measuring and force emptying
if (!test.Draining) /// If condition met => skip measuring and force emptying
{
///
/// Measure the weight and skip emptying if there is enough room in the tank
///
State.Create("ReferenceFlowmeterCalibration : Measuring the mass of water in the tank")
State.Create("ReferenceFlowmeterCalibration : Measuring mass of water in the tank")
.AddOperation(checkUiOp)
.AddOperation(outPath.Balance.ReadMassOp(ref Mass))
.AddOperation(outPath.Scale.ReadMassOp(ref Mass))
.EnterState();
do
{
@@ -124,7 +124,7 @@ namespace TBF.BenchControl.TestMethods.ReferenceFlowmeterCalibration
while (!e.Contains(Event.BalanceDone));
double estimatedEndMass = Mass.Val + test.Volume;
if (estimatedEndMass < outPath.Balance.Capacity * Constants.TankFullFactor)
if (estimatedEndMass < outPath.Scale.Capacity * Constants.TankFullFactor)
{
goto set_flow; /// Enough room in the tank -> skip emptying
}
@@ -133,7 +133,7 @@ namespace TBF.BenchControl.TestMethods.ReferenceFlowmeterCalibration
///
/// Empty the water tank
///
switch (EmptyTheTank(outPath.EmptyTankValve, outPath.Balance))
switch (DrainTheTank(outPath.Scale.DrainValve, outPath.Scale))
{
case Event.Error: { retVal = Event.Error; goto stopTest; }
case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; }
@@ -182,7 +182,7 @@ namespace TBF.BenchControl.TestMethods.ReferenceFlowmeterCalibration
.AddOperation(benchPath.PressMtrDelta == null ? null : benchPath.PressMtrDelta.ReadPressureOp(ref PressDelta))
.AddOperation((StateMachine.Ambient != null)
? StateMachine.Ambient.ReadAmbientOp(AmbTemp, AmbPress, AmbHumi) : null)
.AddOperation(outPath.Balance.ReadStableMassOp(ref StartMass, test.MassRepeats, test.MassSpread, test.MassMethod))
.AddOperation(outPath.Scale.ReadStableMassOp(ref StartMass, test.MassRepeats, test.MassSpread, test.MassMethod))
.AddOperation(cBrd.UpdateTankWeightOp())
.AddOperation(processDataLoggingOp)
.EnterState();
@@ -251,7 +251,7 @@ namespace TBF.BenchControl.TestMethods.ReferenceFlowmeterCalibration
.AddOperation(readRegistersOp)
.AddOperation((StateMachine.Ambient != null)
? StateMachine.Ambient.ReadAmbientOp(AmbTemp, AmbPress, AmbHumi) : null)
.AddOperation(outPath.Balance.ReadMassOp(ref Mass))
.AddOperation(outPath.Scale.ReadMassOp(ref Mass))
.AddOperation(cBrd.UpdateTankWeightOp())
.AddOperation(processDataLoggingOp)
.AddOperation(new Operations.TimerOp(test.TimeStop2Mass))
@@ -277,7 +277,7 @@ namespace TBF.BenchControl.TestMethods.ReferenceFlowmeterCalibration
.AddOperation(benchPath.PressMtrDelta == null ? null : benchPath.PressMtrDelta.ReadPressureOp(ref PressDelta))
.AddOperation((StateMachine.Ambient != null)
? StateMachine.Ambient.ReadAmbientOp(AmbTemp, AmbPress, AmbHumi) : null)
.AddOperation(outPath.Balance.ReadStableMassOp(ref EndMass, test.MassRepeats, test.MassSpread, test.MassMethod))
.AddOperation(outPath.Scale.ReadStableMassOp(ref EndMass, test.MassRepeats, test.MassSpread, test.MassMethod))
.AddOperation(cBrd.UpdateTankWeightOp())
.AddOperation(processDataLoggingOp)
.EnterState();
@@ -362,9 +362,9 @@ namespace TBF.BenchControl.TestMethods.ReferenceFlowmeterCalibration
tstRslt.TestTime = cBrd.TTime; /// [s] measurement time
tstRslt.PulsesMaster = Convert.ToDouble(cBrd.EtPulses(0)); /// Pulses of the master flow meter (test total)
tstRslt.MassStartRaw = StartMass.Val;
tstRslt.MassStart = Formulas.CorrectedValue(tstRslt.MassStartRaw, outPath.Balance.Corrections);
tstRslt.MassStart = Formulas.CorrectedValue(tstRslt.MassStartRaw, outPath.Scale.Corrections);
tstRslt.MassEndRaw = EndMass.Val;
tstRslt.MassEnd = Formulas.CorrectedValue(tstRslt.MassEndRaw, outPath.Balance.Corrections);
tstRslt.MassEnd = Formulas.CorrectedValue(tstRslt.MassEndRaw, outPath.Scale.Corrections);
tstRslt.FlowMass = 3600.0 * (tstRslt.MassEnd - tstRslt.MassStart) / tstRslt.TestTime; /// [kg/h]
tstRslt.FlowVolume = 3.6 * LtrPerRefPulse * tstRslt.PulsesMaster / tstRslt.TestTime; /// [m3/h]
tstRslt.VolumeCTV = 1001.03 * (tstRslt.MassEnd - tstRslt.MassStart) / tstRslt.DensityOut; /// [l] 1000.0f is because density is in [kg/m3]
@@ -388,7 +388,7 @@ namespace TBF.BenchControl.TestMethods.ReferenceFlowmeterCalibration
(BenchInfo != null) ? BenchInfo.TestBenchName : "testbench",
inPath.Pump != null ? inPath.Pump.Name : string.Empty,
outPath.FlowMeter != null ? outPath.FlowMeter.Name : string.Empty,
outPath.Balance != null ? outPath.Balance.Name : string.Empty,
outPath.Scale != null ? outPath.Scale.Name : string.Empty,
outPath.RegulValve != null ? outPath.RegulValve.Name : string.Empty,
outPath.Diverter != null ? outPath.Diverter.Name : string.Empty));
@@ -18,6 +18,7 @@ namespace TBF.BenchControl.TestMethods.RoiDetection
public bool Publish(Test test) { return false; }
public bool CanTest(MetersKind meters) { return true; }
public RoiDetection()
{
}
@@ -28,9 +29,21 @@ namespace TBF.BenchControl.TestMethods.RoiDetection
log.Debug(this.ToString());
}
public IList<Event> Execute(Test test, bool outerLoopMode, int outerLoopCounter)
{
return (new RoiDetectionSeq()).Execute(test, outerLoopMode, outerLoopCounter);
GenericDevices.ICameraDisplay display = null;
foreach (var cmpnt in StateMachine.Components)
{
if (cmpnt is GenericDevices.ICameraDisplay)
{
display = (cmpnt as GenericDevices.ICameraDisplay);
break;
}
}
return (new RoiDetectionSeq()).Execute(test, display, outerLoopMode, outerLoopCounter);
}
}
}
@@ -8,6 +8,7 @@ using log4net;
using Config.Entities;
using TBF.Resources;
using TBF.UiBridge;
using System.IO;
namespace TBF.BenchControl.TestMethods.RoiDetection
{
@@ -16,7 +17,7 @@ namespace TBF.BenchControl.TestMethods.RoiDetection
private static readonly ILog log = LogManager.GetLogger(typeof(RoiDetectionSeq));
public IList<Event> Execute(Test test, bool outerLoopMode, int outerLoopCounter)
public IList<Event> Execute(Test test, GenericDevices.ICameraDisplay display, bool outerLoopMode, int outerLoopCounter)
{
Elde.ControlBoardDev cBrd = StateMachine.ControlBoard;
@@ -58,9 +59,9 @@ namespace TBF.BenchControl.TestMethods.RoiDetection
TestProgressEventArgs.SetEstimatedTimes(new int[] { 1, 1, 1, 30, Convert.ToInt32(test.TstTime) + 15, 0, 0 });
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.JustStarted));
//------------------------------------------------
//-------------------------------------------------
Bridge.OnActivity(this, Strings.Starting_the_pump);
//------------------------------------------------
//-------------------------------------------------
///
if (inPath.Pump is GenericDevices.IPumpFM) (inPath.Pump as GenericDevices.IPumpFM).TurnOn(test.PumpPower);
State.Create("RoiDetection : Starting the pump")
@@ -107,23 +108,36 @@ namespace TBF.BenchControl.TestMethods.RoiDetection
int time = StateMachine.Time;
double currentFlow = RefFlow.Val;
foreach (var rr in sensPath.RegisterReaders)
string[] imageNames = new string[sensPath.RegisterReaders.Length];
for (int i = 0; i < sensPath.RegisterReaders.Length; i++)
{
if (rr is GenericDevices.IRoi) (rr as GenericDevices.IRoi).Detected = false;
GenericDevices.IRoi roi = sensPath.RegisterReaders[i] as GenericDevices.IRoi;
if (roi != null)
{
roi.ClearRoi();
}
else
{
imageNames[i] = null;
}
}
detection_loop:
//------------------------------------------------
//---------------------------------------------------------
Bridge.OnActivity(this, Strings.ROI_Detection_in_Progress);
//------------------------------------------------
//---------------------------------------------------------
State detection = State.Create("RoiDetection : Detection of ROI-s")
.AddOperation(checkUiOp);
foreach (var rr in sensPath.RegisterReaders)
for (int i = 0; i < sensPath.RegisterReaders.Length; i++)
{
if (rr is GenericDevices.IRoi && !(rr as GenericDevices.IRoi).Detected)
GenericDevices.IRoi roi = sensPath.RegisterReaders[i] as GenericDevices.IRoi;
if (roi != null && !roi.Detected)
{
detection.AddOperation((rr as GenericDevices.IRoi).RoiDetectionOp());
detection.AddOperation(roi.RoiDetectionOp());
imageNames[i] = roi.DetectedImageName;
}
}
detection.EnterState();
@@ -138,37 +152,59 @@ namespace TBF.BenchControl.TestMethods.RoiDetection
retVal = Event.Error;
goto stopTest;
}
if (TestAndLogUiCmdStop(test,e)) { retVal = Event.UiCmdStop; goto stopTest; }
if (TestAndLogUiCmdStop(test,e))
{
retVal = Event.UiCmdStop;
goto stopTest;
}
}
while (e.Contains(Event.CameraBusy));
//-----------------------------------------------------------------------------------------------------
if (e.Contains(Event.RoiDetectionPreviousFailed)) Bridge.OnActivity(this, Strings.Camera_error);
else if (e.Contains(Event.RoiDetectionFailed)) Bridge.OnActivity(this, Strings.Detection_failed);
else Bridge.OnActivity(this, Strings.Detection_completed);
//-----------------------------------------------------------------------------------------------------
if (e.Contains(Event.RoiDetectionPreviousFailed))
{
retVal = Event.Error;
Bridge.OnActivity(this, Strings.Camera_error);
}
else if (e.Contains(Event.RoiDetectionFailed))
{
retVal = Event.Error;
Bridge.OnActivity(this, Strings.Detection_failed);
State.Create("RoiDetection : Do you want to retry RoI detection?")
.AddOperation(checkUiOp)
.AddOperation(new Operations.AskYesNoOp(Strings.Do_you_want_to_retry_RoI_detection))
.EnterState();
do
string title = Strings.Select_images_and_press_Retry_to_retry_RoI_detection;
State.Create("RoiDetection : Select images and press Retry to retry RoI detection")
.AddOperation(checkUiOp)
.AddOperation((display == null) ? null : display.ShowStaticImageOp(imageNames, title))
.EnterState();
do
{
e = StateMachine.WaitRunDevsRunOps();
if (TestAndLogUiCmdStop(test, e))
{
e = StateMachine.WaitRunDevsRunOps();
while (!e.Contains(Event.Yes)) goto detection_loop;
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
retVal = Event.UiCmdStop;
goto stopTest;
}
while (!e.Contains(Event.No));
}
while (e.Contains(Event.ModelessFormIsOpen));
if (e.Contains(Event.Retry))
{
for (int i = 0; i < display.SelectedImages.Length; i++)
{
GenericDevices.IRoi roi = sensPath.RegisterReaders[i] as GenericDevices.IRoi;
if (roi != null && display.SelectedImages[i])
{
roi.ClearRoi();
}
}
goto detection_loop;
}
else if (e.Contains(Event.Abort))
{
retVal = Event.UiCmdStop;
goto stopTest;
}
//------------------------------------------------
//---------------------------------------------------
Bridge.OnActivity(this, Strings.Detection_completed);
//------------------------------------------------
//---------------------------------------------------
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.TransitionAfter));
@@ -675,8 +675,8 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
else if (activity.ToLower().Contains(WriteCalibrationFactorStr.ToLower())) error = WriteCalibrationFactor(wm, ref resultStr);
else if (activity.ToLower().Equals(NormalizeCalibrationFactorStr.ToLower())) error = NormalizeCalibrationFactor(wm, ref resultStr);
else if (activity.ToLower().Equals(ResetQ2CorrectionStr.ToLower())) error = ResetQ2Correction(wm, ref resultStr);
else if (activity.ToLower().Equals(WriteQ2CorrectionStr.ToLower())) error = WriteQ2Correction(wm, ref resultStr);
else if (activity.ToLower().Equals(WriteQ2CorrectionAltStr.ToLower())) error = WriteQ2CorrectionAlt(wm, ref resultStr);
else if (activity.ToLower().Equals(WriteQ2CorrectionStr.ToLower())) error = WriteQ2Correction(wm, ref resultStr, false); /// standard iPerl
else if (activity.ToLower().Equals(WriteQ2CorrectionAltStr.ToLower())) error = WriteQ2Correction(wm, ref resultStr, true); /// DEWA iPerl
else if (activity.ToLower().Equals(Reset2HzCorrectionStr.ToLower())) error = Reset2HzCorrection(wm, ref resultStr);
else if (activity.ToLower().Equals(Write2HzCorrectionStr.ToLower())) error = Write2HzCorrection(wm, ref resultStr);
else
@@ -1190,7 +1190,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
if (error == CommErr.None)
{
resultStr = "Q2 corrections reset to 0";
wm.Q2CorrectionFactor = 0;
wm.Q2CorrRFlow = 0;
}
#endif
@@ -1270,28 +1270,70 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
/// <param name="wm">Water meter object</param>
/// <param name="resultStr">String passed to caller</param>
/// <returns>true on success</returns>
static CommErr WriteQ2Correction(WaterMeters.iPerl.WaterMeter wm, ref string resultStr)
static CommErr WriteQ2Correction(WaterMeters.iPerl.WaterMeter wm, ref string resultStr, bool DEWA)
{
if (wm.CommFailed) return CommErr.CommFailed;
if (wm.CommFailed) return CommErr.CommFailed;
if (wm.LastTestResult == null) return CommErr.CommFailed; /// This should never happen
wm.Q2ErrorWOCorrection = wm.LastTestResult.Error;
wm.Q2CorrectionDone = false;
wm.Q2CorrRFlow = 0;
double q2CorrectionFactor;
bool wmOK = wm.CalculateQ2CorrectionFactor(wm.LastTestResult, out q2CorrectionFactor);
double q2Correction = 0;
Byte q2CorrRFlow = 0;
Byte q2CorrLFlow = 0;
if (q2CorrectionFactor == 0)
{
resultStr = string.Format("Q2 correction = 0 (writing bypassed)");
return CommErr.None;
}
if (DEWA == false)
{
///
/// Standard process
///
if (Math.Abs(wm.LastTestResult.Error) <= 0.5)
{
resultStr = string.Format("Q2 correction = 0 (writing bypassed)");
return CommErr.None;
}
if (!wm.CalculateQ2CorrectionFactor(wm.LastTestResult, out q2Correction))
{
return CommErr.None; /// Q2 error is too large, water meter failed anyhow
}
q2CorrRFlow = (byte)((int)Math.Round(0.5 * q2Correction) & 0x000000FF);
q2CorrLFlow = (byte)((int)Math.Round(q2Correction) & 0x000000FF);
}
else
{
///
/// DEWA process
///
if (wm.LastTestResult.Error >= 0 && wm.LastTestResult.Error <= 1.0)
{
resultStr = string.Format("Q2 correction = 0 (writing bypassed)");
return CommErr.None;
}
if (!wm.CalculateQ2CorrectionFactor(wm.LastTestResult, out q2Correction))
{
return CommErr.None; /// Q2 error is too large, water meter failed anyhow
}
if (wm.LastTestResult.Error < 0)
{
q2CorrRFlow = (byte)((int)Math.Round(1.1 * q2Correction) & 0x000000FF);
q2CorrLFlow = (byte)((int)Math.Round(1.1 * q2Correction) & 0x000000FF);
}
else /// if (wm.LastTestResult.Error > 1.0)
{
q2CorrRFlow = (byte)((int)Math.Round(0.5 * q2Correction) & 0x000000FF);
q2CorrLFlow = (byte)((int)Math.Round(0.5 * q2Correction) & 0x000000FF);
}
}
if (OpenPort(wm) != 0) return CommErr.OpenPort; /// Open RFID port
CommErr error = CommErr.Write;
Byte q2CorrRFlow = (byte)((int)Math.Round(q2CorrectionFactor / 2) & 0x000000FF);
Byte q2CorrLFlow = (byte)((int)Math.Round(q2CorrectionFactor) & 0x000000FF);
byte[] wrData = new byte[2] { q2CorrRFlow, q2CorrLFlow };
///
for (int j = 0; j < cfg.MaxCommRetries; j++)
@@ -1333,8 +1375,10 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
resultStr = string.Format("Q2 correction: R-flow={0}, L-flow={1}", (SByte)q2CorrRFlow, (SByte)q2CorrLFlow);
rfidDataLogger.Warn(wm.Name + ": " + resultStr);
wm.Q2CorrectionDone = true;
wm.Q2CorrectionFactor = q2CorrectionFactor;
}
wm.Q2Correction = q2Correction;
wm.Q2CorrRFlow = (int)q2CorrRFlow;
wm.Q2CorrLFlow = (int)q2CorrLFlow;
}
#endif
ClosePort(wm); /// Close RFID port
@@ -1343,86 +1387,6 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
}
/// <summary>
/// Write the calculated Q2 correction factors to the memory.
/// Read them back to verify factors were written correctly.
/// </summary>
/// <param name="wm">Water meter object</param>
/// <param name="resultStr">String passed to caller</param>
/// <returns>true on success</returns>
static CommErr WriteQ2CorrectionAlt(WaterMeters.iPerl.WaterMeter wm, ref string resultStr)
{
if (wm.CommFailed) return CommErr.CommFailed;
wm.Q2ErrorWOCorrection = wm.LastTestResult.Error;
wm.Q2CorrectionDone = false;
double q2CorrectionFactor;
bool wmOK = wm.CalculateQ2CorrectionFactor(wm.LastTestResult, out q2CorrectionFactor);
if (q2CorrectionFactor == 0)
{
resultStr = string.Format("Q2 correction = 0 (writing bypassed)");
return CommErr.None;
}
if (OpenPort(wm) != 0) return CommErr.OpenPort; /// Open RFID port
CommErr error = CommErr.Write;
Byte q2CorrRFlow = (byte)((int)Math.Round(q2CorrectionFactor) & 0x000000FF);
Byte q2CorrLFlow = (byte)((int)Math.Round(q2CorrectionFactor) & 0x000000FF);
byte[] wrData = new byte[2] { q2CorrRFlow, q2CorrLFlow };
///
for (int j = 0; j < cfg.MaxCommRetries; j++)
{
if (0 == WriteRequestPort(wm, MessageID.MetrologyMemory, Q2CorrFactorsAddr, wrData.Length, wrData, cfg.CommTimeout))
{
error = CommErr.None;
break;
}
}
///
/// Verification disabled on 16.02.2016
///
#if false
if (error == CommErr.None)
{
error = CommErr.Verify;
/// Read calibration
byte[] rdData = null;
for (int j = 0; j < cfg.MaxCommRetries; j++)
{
if ((0 == ReadRequestPort(wm, MessageID.MetrologyMemory, Q2CorrFactorsAddr, 2, out rdData, cfg.CommTimeout)) &&
(rdData != null) && (rdData.Length == 2) && (rdData[0] == q2CorrRFlow) && (rdData[1] == q2CorrLFlow))
{
error = CommErr.None;
resultStr = string.Format("Q2 factors: R-flow={0}, L-flow={1}", (SByte)q2CorrRFlow, (SByte)q2CorrLFlow);
rfidDataLogger.Warn(wm.Name + ": " + resultStr);
wm.Q2CorrectionDone = true;
wm.Q2CorrectionFactor = q2CorrectionFactor;
break;
}
}
}
#else
if (error == CommErr.None)
{
resultStr = string.Format("Q2 correction: R-flow={0}, L-flow={1}", (SByte)q2CorrRFlow, (SByte)q2CorrLFlow);
rfidDataLogger.Warn(wm.Name + ": " + resultStr);
wm.Q2CorrectionDone = true;
wm.Q2CorrectionFactor = q2CorrectionFactor;
}
#endif
ClosePort(wm); /// Close RFID port
return error;
}
/// <summary>
/// Write the calculated 2Hz correction factor to the memory.
/// </summary>
@@ -148,7 +148,9 @@ namespace TBF.BenchControl.WaterMeters.iPerl
public double Q2ErrorWOCorrection;
public bool Q2CorrectionDone;
public double Q2CorrectionFactor;
public double Q2Correction;
public int Q2CorrRFlow;
public int Q2CorrLFlow;
public double Diff2Hz8Hz;
public bool Hz2CorrectionDone;
@@ -226,14 +228,14 @@ namespace TBF.BenchControl.WaterMeters.iPerl
{
q2CorrectionFactor = 0;
if (q2TestResult == null)
{
return false; /// Q2 test result is missing ==> water meter failed
}
if (q2TestResult == null) return false; /// Q2 test result is missing ==> water meter failed
if (Math.Abs(q2TestResult.Error) <= 0.5)
double errLimitLo = q2TestResult.ErrLimLo() + q2TestResult.Uncertainty();
double errLimitHi = q2TestResult.ErrLimHi() - q2TestResult.Uncertainty();
if ((q2TestResult.Error < errLimitLo) || (q2TestResult.Error > errLimitHi))
{
return true; /// error < +/-0.5 % ==> no Q2 correction
return false; /// Q2 error too large ==> water meter failed
}
double A = 16.0 / ScalingFactor(); /// Raw units per ml: DN15=16, DN20=8, DN25=4, DN32=2, DN40=1
@@ -243,20 +245,6 @@ namespace TBF.BenchControl.WaterMeters.iPerl
double F = D / (NominalTestFlow * 10.0); /// Error corrected with 8 Raw Units per minute [%]
double G = F / B; /// Error corrected with 1 Raw Unit per minute [%]
double errLimitLo = q2TestResult.ErrLimLo() + q2TestResult.Uncertainty();
double errLimitHi = q2TestResult.ErrLimHi() - q2TestResult.Uncertainty();
if ((q2TestResult.Error < errLimitLo) || (q2TestResult.Error > errLimitHi))
{
return false; /// Q2 error too large ==> water meter failed
}
double volumeMeterErrLimLo = q2TestResult.VolumeRef * (100.0 + errLimitLo) / 100.0;
double volumeMeterErrLimHi = q2TestResult.VolumeRef * (100.0 + errLimitHi) / 100.0;
double corrFactorHi = (-1) * (errLimitLo / G) * (q2TestResult.VolumeRef / volumeMeterErrLimLo); /// > 0
double corrFactorLo = (-1) * (errLimitHi / G) * (q2TestResult.VolumeRef / volumeMeterErrLimHi); /// < 0
q2CorrectionFactor = (-1) * (q2TestResult.Error / G) * (q2TestResult.VolumeRef / q2TestResult.VolumeMeter);
log.WarnFormat("Q2 correction: Pos={0}, PCB#={1}, corrFactor={2}, error={3}% [Lo={4}%, Hi={5}%]",
@@ -420,7 +408,7 @@ namespace TBF.BenchControl.WaterMeters.iPerl
OriginalCalibFactor = 0;
Q2ErrorWOCorrection = 0;
Q2CorrectionDone = false;
Q2CorrectionFactor = 0;
Q2CorrRFlow = 0;
optoDataCount = 0;
}
+124 -124
View File
@@ -28,135 +28,135 @@
/// </summary>
private void InitializeComponent()
{
this.sendButton = new System.Windows.Forms.Button();
this.sentCheckBox = new System.Windows.Forms.CheckBox();
this.failedCountLabel = new System.Windows.Forms.Label();
this.passedCountLabel = new System.Windows.Forms.Label();
this.purchaseOrderLabel = new System.Windows.Forms.Label();
this.procedureLabel = new System.Windows.Forms.Label();
this.endTimeLabel = new System.Windows.Forms.Label();
this.startTimeLabel = new System.Windows.Forms.Label();
this.batchNrLabel = new System.Windows.Forms.Label();
this.showButton = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// sendButton
//
this.sendButton.Location = new System.Drawing.Point(832, 2);
this.sendButton.Name = "sendButton";
this.sendButton.Size = new System.Drawing.Size(104, 23);
this.sendButton.TabIndex = 15;
this.sendButton.Text = "Again";
this.sendButton.UseVisualStyleBackColor = true;
this.sendButton.Click += new System.EventHandler(this.sendButton_Click);
//
// sentCheckBox
//
this.sentCheckBox.AutoSize = true;
this.sentCheckBox.Location = new System.Drawing.Point(748, 6);
this.sentCheckBox.Name = "sentCheckBox";
this.sentCheckBox.Size = new System.Drawing.Size(48, 17);
this.sentCheckBox.TabIndex = 14;
this.sentCheckBox.Text = "Sent";
this.sentCheckBox.UseVisualStyleBackColor = true;
//
// failedCountLabel
//
this.failedCountLabel.AutoSize = true;
this.failedCountLabel.Location = new System.Drawing.Point(681, 7);
this.failedCountLabel.Name = "failedCountLabel";
this.failedCountLabel.Size = new System.Drawing.Size(48, 13);
this.failedCountLabel.TabIndex = 13;
this.failedCountLabel.Text = "failedCnt";
//
// passedCountLabel
//
this.passedCountLabel.AutoSize = true;
this.passedCountLabel.Location = new System.Drawing.Point(590, 7);
this.passedCountLabel.Name = "passedCountLabel";
this.passedCountLabel.Size = new System.Drawing.Size(57, 13);
this.passedCountLabel.TabIndex = 12;
this.passedCountLabel.Text = "passedCnt";
//
// purchaseOrderLabel
//
this.purchaseOrderLabel.AutoSize = true;
this.purchaseOrderLabel.Location = new System.Drawing.Point(481, 7);
this.purchaseOrderLabel.Name = "purchaseOrderLabel";
this.purchaseOrderLabel.Size = new System.Drawing.Size(77, 13);
this.purchaseOrderLabel.TabIndex = 11;
this.purchaseOrderLabel.Text = "purchaseOrder";
//
// procedureLabel
//
this.procedureLabel.AutoSize = true;
this.procedureLabel.Location = new System.Drawing.Point(328, 7);
this.procedureLabel.Name = "procedureLabel";
this.procedureLabel.Size = new System.Drawing.Size(55, 13);
this.procedureLabel.TabIndex = 10;
this.procedureLabel.Text = "procedure";
//
// endTimeLabel
//
this.endTimeLabel.AutoSize = true;
this.endTimeLabel.Location = new System.Drawing.Point(185, 7);
this.endTimeLabel.Name = "endTimeLabel";
this.endTimeLabel.Size = new System.Drawing.Size(48, 13);
this.endTimeLabel.TabIndex = 9;
this.endTimeLabel.Text = "endTime";
//
// startTimeLabel
//
this.startTimeLabel.AutoSize = true;
this.startTimeLabel.Location = new System.Drawing.Point(54, 7);
this.startTimeLabel.Name = "startTimeLabel";
this.startTimeLabel.Size = new System.Drawing.Size(50, 13);
this.startTimeLabel.TabIndex = 8;
this.startTimeLabel.Text = "startTime";
//
// batchNrLabel
//
this.batchNrLabel.AutoSize = true;
this.batchNrLabel.Location = new System.Drawing.Point(3, 7);
this.batchNrLabel.Name = "batchNrLabel";
this.batchNrLabel.Size = new System.Drawing.Size(24, 13);
this.batchNrLabel.TabIndex = 16;
this.batchNrLabel.Text = "bNr";
//
// showButton
//
this.showButton.Location = new System.Drawing.Point(939, 2);
this.showButton.Name = "showButton";
this.showButton.Size = new System.Drawing.Size(104, 23);
this.showButton.TabIndex = 17;
this.showButton.Text = "Show";
this.showButton.UseVisualStyleBackColor = true;
this.showButton.Click += new System.EventHandler(this.showButton_Click);
//
// PreviousResultCtrl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.showButton);
this.Controls.Add(this.batchNrLabel);
this.Controls.Add(this.sendButton);
this.Controls.Add(this.sentCheckBox);
this.Controls.Add(this.failedCountLabel);
this.Controls.Add(this.passedCountLabel);
this.Controls.Add(this.purchaseOrderLabel);
this.Controls.Add(this.procedureLabel);
this.Controls.Add(this.endTimeLabel);
this.Controls.Add(this.startTimeLabel);
this.Name = "PreviousResultCtrl";
this.Size = new System.Drawing.Size(1048, 26);
this.ResumeLayout(false);
this.PerformLayout();
this.sendReloadButton = new System.Windows.Forms.Button();
this.sentCheckBox = new System.Windows.Forms.CheckBox();
this.failedCountLabel = new System.Windows.Forms.Label();
this.passedCountLabel = new System.Windows.Forms.Label();
this.purchaseOrderLabel = new System.Windows.Forms.Label();
this.procedureLabel = new System.Windows.Forms.Label();
this.endTimeLabel = new System.Windows.Forms.Label();
this.startTimeLabel = new System.Windows.Forms.Label();
this.batchNrLabel = new System.Windows.Forms.Label();
this.showButton = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// sendReloadButton
//
this.sendReloadButton.Location = new System.Drawing.Point(832, 2);
this.sendReloadButton.Name = "sendReloadButton";
this.sendReloadButton.Size = new System.Drawing.Size(104, 23);
this.sendReloadButton.TabIndex = 15;
this.sendReloadButton.Text = "Again";
this.sendReloadButton.UseVisualStyleBackColor = true;
this.sendReloadButton.Click += new System.EventHandler(this.sendReloadButton_Click);
//
// sentCheckBox
//
this.sentCheckBox.AutoSize = true;
this.sentCheckBox.Location = new System.Drawing.Point(748, 6);
this.sentCheckBox.Name = "sentCheckBox";
this.sentCheckBox.Size = new System.Drawing.Size(48, 17);
this.sentCheckBox.TabIndex = 14;
this.sentCheckBox.Text = "Sent";
this.sentCheckBox.UseVisualStyleBackColor = true;
//
// failedCountLabel
//
this.failedCountLabel.AutoSize = true;
this.failedCountLabel.Location = new System.Drawing.Point(681, 7);
this.failedCountLabel.Name = "failedCountLabel";
this.failedCountLabel.Size = new System.Drawing.Size(48, 13);
this.failedCountLabel.TabIndex = 13;
this.failedCountLabel.Text = "failedCnt";
//
// passedCountLabel
//
this.passedCountLabel.AutoSize = true;
this.passedCountLabel.Location = new System.Drawing.Point(590, 7);
this.passedCountLabel.Name = "passedCountLabel";
this.passedCountLabel.Size = new System.Drawing.Size(57, 13);
this.passedCountLabel.TabIndex = 12;
this.passedCountLabel.Text = "passedCnt";
//
// purchaseOrderLabel
//
this.purchaseOrderLabel.AutoSize = true;
this.purchaseOrderLabel.Location = new System.Drawing.Point(481, 7);
this.purchaseOrderLabel.Name = "purchaseOrderLabel";
this.purchaseOrderLabel.Size = new System.Drawing.Size(77, 13);
this.purchaseOrderLabel.TabIndex = 11;
this.purchaseOrderLabel.Text = "purchaseOrder";
//
// procedureLabel
//
this.procedureLabel.AutoSize = true;
this.procedureLabel.Location = new System.Drawing.Point(328, 7);
this.procedureLabel.Name = "procedureLabel";
this.procedureLabel.Size = new System.Drawing.Size(55, 13);
this.procedureLabel.TabIndex = 10;
this.procedureLabel.Text = "procedure";
//
// endTimeLabel
//
this.endTimeLabel.AutoSize = true;
this.endTimeLabel.Location = new System.Drawing.Point(185, 7);
this.endTimeLabel.Name = "endTimeLabel";
this.endTimeLabel.Size = new System.Drawing.Size(48, 13);
this.endTimeLabel.TabIndex = 9;
this.endTimeLabel.Text = "endTime";
//
// startTimeLabel
//
this.startTimeLabel.AutoSize = true;
this.startTimeLabel.Location = new System.Drawing.Point(54, 7);
this.startTimeLabel.Name = "startTimeLabel";
this.startTimeLabel.Size = new System.Drawing.Size(50, 13);
this.startTimeLabel.TabIndex = 8;
this.startTimeLabel.Text = "startTime";
//
// batchNrLabel
//
this.batchNrLabel.AutoSize = true;
this.batchNrLabel.Location = new System.Drawing.Point(3, 7);
this.batchNrLabel.Name = "batchNrLabel";
this.batchNrLabel.Size = new System.Drawing.Size(24, 13);
this.batchNrLabel.TabIndex = 16;
this.batchNrLabel.Text = "bNr";
//
// showButton
//
this.showButton.Location = new System.Drawing.Point(939, 2);
this.showButton.Name = "showButton";
this.showButton.Size = new System.Drawing.Size(104, 23);
this.showButton.TabIndex = 17;
this.showButton.Text = "Show";
this.showButton.UseVisualStyleBackColor = true;
this.showButton.Click += new System.EventHandler(this.showButton_Click);
//
// PreviousResultCtrl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.showButton);
this.Controls.Add(this.batchNrLabel);
this.Controls.Add(this.sendReloadButton);
this.Controls.Add(this.sentCheckBox);
this.Controls.Add(this.failedCountLabel);
this.Controls.Add(this.passedCountLabel);
this.Controls.Add(this.purchaseOrderLabel);
this.Controls.Add(this.procedureLabel);
this.Controls.Add(this.endTimeLabel);
this.Controls.Add(this.startTimeLabel);
this.Name = "PreviousResultCtrl";
this.Size = new System.Drawing.Size(1048, 26);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Button sendButton;
private System.Windows.Forms.Button sendReloadButton;
private System.Windows.Forms.CheckBox sentCheckBox;
private System.Windows.Forms.Label failedCountLabel;
private System.Windows.Forms.Label passedCountLabel;
+23 -19
View File
@@ -1,10 +1,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
///
/// Copyright (c) 2016-2017 Sensus Metering Systems
///
using System;
using System.Windows.Forms;
using TBF.Resources;
@@ -12,7 +9,8 @@ namespace TBF.Forms
{
public partial class PreviousResultCtrl : UserControl
{
PreviousResultsDlg parent;
readonly PreviousResultsDlg parent;
readonly bool reloadEn;
public int BatchNr;
public DateTime StarTime;
@@ -28,10 +26,12 @@ namespace TBF.Forms
InitializeComponent();
}
public PreviousResultCtrl(PreviousResultsDlg parent, int bnr, DateTime s, DateTime e, string proc, string pOrd, int passCnt, int failCnt, bool sent)
public PreviousResultCtrl(PreviousResultsDlg parent, int bnr, DateTime s, DateTime e, string proc, string pOrd, int passCnt, int failCnt, bool sent, bool reloadEn)
: this()
{
this.parent = parent;
this.reloadEn = reloadEn;
BatchNr = bnr;
StarTime = s;
EndTime = e;
@@ -52,17 +52,18 @@ namespace TBF.Forms
#if MUNICH
sentCheckBox.Text = Strings.Printed;
sentCheckBox.Checked = Sent;
sendButton.Enabled = true; /// 'Print again' function always available
sendButton.Text = Strings.Print_again;
sendReloadButton.Enabled = true; /// 'Print again' function always available
sendReloadButton.Text = reloadEn ? Strings.Restore : Strings.Print_again;
#elif ORACLE_DB
sentCheckBox.Text = Strings.Sent;
sentCheckBox.Checked = Sent;
sendButton.Enabled = !Sent;
sendButton.Text = Strings.Again;
sendReloadButton.Enabled = reloadEn || !Sent;
sendReloadButton.Text = reloadEn ? Strings.Restore : Strings.Save_again;
#else
sentCheckBox.Visible = false;
sendButton.Enabled = false;
sendButton.Visible = false;
sendReloadButton.Enabled = reloadEn;
sendReloadButton.Visible = reloadEn;
sendReloadButton.Text = Strings.Restore;
#endif
showButton.Text = Strings.Show;
}
@@ -72,16 +73,19 @@ namespace TBF.Forms
this.Sent = sent;
#if MUNICH
sentCheckBox.Checked = sent;
sendButton.Enabled = true;
sendReloadButton.Enabled = true;
#elif ORACLE_DB
sentCheckBox.Checked = sent;
sendButton.Enabled = !sent;
sendReloadButton.Enabled = !sent;
#endif
}
private void sendButton_Click(object sender, EventArgs e)
private void sendReloadButton_Click(object sender, EventArgs e)
{
parent.OnSendAgain(this, new PreviousResultIdEventArgs(BatchNr));
if (reloadEn)
parent.OnReload(this, new PreviousResultIdEventArgs(BatchNr));
else
parent.OnSendAgain(this, new PreviousResultIdEventArgs(BatchNr));
}
private void showButton_Click(object sender, EventArgs e)
+51 -22
View File
@@ -1,17 +1,12 @@
using System;
///
/// Copyright (c) 2016-2017 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Results.Entities;
using NHibernate;
using log4net;
using Oracle.DataAccess.Client; // ODP.NET Oracle managed provider
using Oracle.DataAccess.Types;
using TBF.BenchControl.DB.SensusOracle;
using TBF.Resources;
namespace TBF.Forms
@@ -23,11 +18,13 @@ namespace TBF.Forms
ISession session;
int currentBatchNr;
IList<Batch> batches;
bool reloadEn;
public PreviousResultsDlg()
public PreviousResultsDlg(bool reloadEn)
{
InitializeComponent();
this.reloadEn = reloadEn;
currentBatchNr = Program.LocalSettings.BatchNr;
SendAgainHandler += delegate(object sndr, PreviousResultIdEventArgs args)
@@ -43,6 +40,12 @@ namespace TBF.Forms
};
}
public PreviousResultsDlg()
: this(false)
{
}
private void PreviousResultsDlg_Load(object sender, EventArgs e)
{
Localize();
@@ -66,6 +69,26 @@ namespace TBF.Forms
}
public void OnReload(object sender, PreviousResultIdEventArgs data)
{
foreach (var batch in batches)
{
if (batch.BatchNr == data.BatchNr)
{
TBF.UiBridge.Bridge.BatchNr = batch.BatchNr;
Program.MainWnd.UpdateProcedure(batch.ProcedureName);
TBF.UiBridge.Bridge.Ui2Bench(TBF.UiBridge.UI2BenchCmd.ReloadBatch);
break;
}
}
DialogResult = DialogResult.Cancel;
Close();
}
public event EventHandler<PreviousResultIdEventArgs> SendAgainHandler;
/// <summary>
@@ -74,8 +97,14 @@ namespace TBF.Forms
public void OnSendAgain(object sender, PreviousResultIdEventArgs data)
{
if (SendAgainHandler == null) return;
try { SendAgainHandler(sender, data); }
catch (Exception e) { log.Error("SendAgainHandler(...) failed", e); }
try
{
SendAgainHandler(sender, data);
}
catch (Exception e)
{
log.Error("SendAgainHandler(...) failed", e);
}
}
public void DoSendAgain(object sender, PreviousResultIdEventArgs data)
@@ -148,7 +177,6 @@ namespace TBF.Forms
public void DoShowResults(object sender, PreviousResultIdEventArgs data)
{
Results.Forms.BatchResultsDlg dlg = new Results.Forms.BatchResultsDlg();
dlg.PopupResultsLeft = Program.LocalSettings.PopupResultsLeft;
dlg.PopupResultsTop = Program.LocalSettings.PopupResultsTop;
@@ -208,15 +236,16 @@ namespace TBF.Forms
if (passedCount + failedCount == 0) continue;
flowLayoutPanel1.Controls.Add(new PreviousResultCtrl( this,
b.BatchNr,
b.StartTime,
b.EndTime,
b.ProcedureName,
b.WaterMeters[0].PurchaseOrder,
passedCount,
failedCount,
b.RsltsSent));
flowLayoutPanel1.Controls.Add(new PreviousResultCtrl(this,
b.BatchNr,
b.StartTime,
b.EndTime,
b.ProcedureName,
b.WaterMeters[0].PurchaseOrder,
passedCount,
failedCount,
b.RsltsSent,
reloadEn));
}
ResumeLayout();
+16 -10
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
/// Copyright (c) 2013-2017 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
@@ -443,21 +443,27 @@ namespace TBF
private void procedureComboBox_SelectedIndexChanged(object sender, EventArgs e)
{
ProcedureName = procedureComboBox.Text;
UpdateProcedure(procedureComboBox.Text);
}
public void UpdateProcedure(string procedureName)
{
procedureComboBox.Text = procedureName;
ProcedureName = procedureName;
BenchControlPanel.ReloadTests();
if (CurrentProcedure != null && CurrentProcedure.Description != null)
{
descriptionLabel.Text = CurrentProcedure.Description;
}
if (CurrentProcedure != null && CurrentProcedure.Description != null)
{
descriptionLabel.Text = CurrentProcedure.Description;
}
if (CurrentProcedure != null && testProgressControls != null)
{
testProgressControls.ProcedureSelectedInUI(this, new UiBridge.ProcedureSelectedEventArgs(CurrentProcedure));
}
if (!string.IsNullOrEmpty(ProcedureName))
{
Program.LocalSettings.LastProcedureName = ProcedureName;
Program.LocalSettings.Save();
}
{
Program.LocalSettings.LastProcedureName = ProcedureName;
Program.LocalSettings.Save();
}
}
private void MainWnd_FormClosing(object sender, FormClosingEventArgs e)

Some files were not shown because too many files have changed in this diff Show More