Compare commits

..
Author SHA1 Message Date
Milan Hanajik cdd74cc36f Reconfigured for PUCHONG_200 2019-06-26 16:25:41 +02:00
149 changed files with 3090 additions and 8327 deletions
-5
View File
@@ -1,13 +1,9 @@
Config/bin/
Config/obj/
Decrypt/bin/
Decrypt/obj/
DeviceTest/bin/
DeviceTest/obj/
Dirichlet.Numerics/bin
Dirichlet.Numerics/obj
Encrypt/bin/
Encrypt/obj/
GemCard/bin
GemCard/obj
GraphLib/bin
@@ -29,6 +25,5 @@ Users/obj/
UserManagement/bin/
UserManagement/obj/
Doc/
.vs/
*.suo
*.bak
+2 -2
View File
@@ -18,7 +18,7 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG;TURA_IPERL;IPERL;ORACLE_DB;LANG_SK</DefineConstants>
<DefineConstants>TRACE;DEBUG;PUCHONG_200</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
@@ -28,7 +28,7 @@
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE;TURA_IPERL;IPERL;ORACLE_DB;LANG_SK</DefineConstants>
<DefineConstants>TRACE;PUCHONG_200</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
+5 -11
View File
@@ -10,8 +10,8 @@ namespace Config
#if MUNICH
public const int WMsCount = 3;
public const int LineSize = 3;
public const int CompoundWMsCount = 3;
public const int LineSize = 1;
public const int CompoundWMsCount = 1;
public const int HeatMetersCount = 0;
public const int MaxPartNr = 3;
#elif DN100 || BADGER_STREDNA_TRAT || BADGER_VELKA_TRAT || CEVAK_200
@@ -20,18 +20,12 @@ namespace Config
public const int CompoundWMsCount = 1;
public const int HeatMetersCount = 0;
public const int MaxPartNr = WMsCount / LineSize;
#elif FUZHOU_300 || FUZHOU_150 || IZRAEL_200 || GENESIS || SLM_150 || PETERSBURG_200
#elif FUZHOU_300 || FUZHOU_150 || IZRAEL_200 || PUCHONG_200 || GENESIS || SLM_150 || PETERSBURG_200
public const int WMsCount = 6;
public const int LineSize = 6;
public const int CompoundWMsCount = 1;
public const int HeatMetersCount = 0;
public const int MaxPartNr = 3;
#elif PUCHONG_200
public const int WMsCount = 6;
public const int LineSize = 6;
public const int CompoundWMsCount = 3;
public const int HeatMetersCount = 0;
public const int MaxPartNr = 3;
#elif DEWA_300
public const int WMsCount = 10;
public const int LineSize = 10;
@@ -62,7 +56,7 @@ namespace Config
public const int CompoundWMsCount = 1;
public const int HeatMetersCount = 0;
public const int MaxPartNr = 1;
#elif TORUN_50 || CEVAK_40 || MURES_40 || FUZHOU_50 || PETERSBURG_50 || KEMPNO_50 || BAHRAIN_50 || KRAKOW_50 || JUZNA_AFRIKA_50 || IZRAEL_25 || ZAMBIA || ZODINO || FEWA_50 || FILIPINY_50
#elif TORUN_50 || CEVAK_40 || MURES_40 || FUZHOU_50 || PETERSBURG_50 || KEMPNO_50 || BAHRAIN_50 || KRAKOW_50 || JUZNA_AFRIKA_50 || IZRAEL_25 || ZAMBIA || ZODINO || FEWA_50
public const int WMsCount = 20;
public const int LineSize = 10;
public const int CompoundWMsCount = 1;
@@ -74,7 +68,7 @@ namespace Config
public const int CompoundWMsCount = 1;
public const int HeatMetersCount = 0;
public const int MaxPartNr = WMsCount / LineSize;
#elif TURA_IPERL || TURA_IPERL_NEW
#elif TURA_IPERL
public const int WMsCount = 40;
public const int LineSize = 20;
public const int CompoundWMsCount = 1;
-3
View File
@@ -56,9 +56,6 @@ namespace Config.Entities
public virtual string RelTransAfter { get; set; }
public virtual string TransitionAfter { get; set; }
public virtual bool IsOuterLoopStart { get; set; } /// Not mapped to database
public virtual bool IsOuterLoopEnd { get; set; } /// Not mapped to database
public virtual IList<ComponentTest> MoreParams { get; set; }
public virtual Procedure Procedure { get; set; }
+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.18.1273.0")]
[assembly: AssemblyFileVersion("2.18.1273.0")]
[assembly: AssemblyVersion("2.18.1227.0")]
[assembly: AssemblyFileVersion("2.18.1227.0")]
-48
View File
@@ -82,53 +82,5 @@ namespace Config
else return "F5";
}
}
/// <summary>
/// Extract and return a database name from a MySQL connection string.
/// </summary>
public static string GetDBName(string connectionString)
{
return GetFromConnectionString(connectionString, new string[] { "DATABASE=" });
}
/// <summary>
/// Extract and return a username from a MySQL connection string
/// </summary>
public static string GetDBUser(string connectionString)
{
return GetFromConnectionString(connectionString, new string[] { "USER=", "UID=" });
}
/// <summary>
/// Extract and return a password from a MySQL connection string
/// </summary>
public static string GetDBPassword(string connectionString)
{
return GetFromConnectionString(connectionString, new string[] { "PASSWORD=" });
}
/// <summary>
/// Extract and return an element of a MySQL connection string
/// (a host, a database, a user name or a password).
/// Return an empty string on any error.
/// </summary>
public static string GetFromConnectionString(string connectionString, string[] patterns)
{
foreach (var pattern in patterns)
{
int startIx = connectionString.IndexOf(pattern);
if (startIx >= 0)
{
/// pattern found, extract the subsequent element
startIx += pattern.Length;
int endIx = connectionString.IndexOf(';', startIx);
return (endIx > 0) ? connectionString.Substring(startIx, endIx - startIx) : string.Empty;
}
}
/// pattern NOT found
return string.Empty;
}
}
}
-64
View File
@@ -1,64 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{D476ABBE-A455-4476-8A8D-3F6151217B51}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Decrypt</RootNamespace>
<AssemblyName>Decrypt</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<StartupObject>Decrypt.Program</StartupObject>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
-9
View File
@@ -1,9 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<StartArguments>config.xml</StartArguments>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<StartArguments>config.xml</StartArguments>
</PropertyGroup>
</Project>
-96
View File
@@ -1,96 +0,0 @@
using System;
using System.IO;
using System.Security.Cryptography;
using System.Text;
namespace Decrypt
{
/// <summary>
/// See also:
/// https://www.fluxbytes.com/csharp/encrypt-and-decrypt-files-in-c/
/// </summary>
class Program
{
static byte[] key = new byte[] { 83, 254, 105, 64, 184, 201, 195, 127, 52, 99, 77, 45, 252, 132, 163, 156 };
static byte[] IV = new byte[] { 189, 23, 137, 56, 204, 241, 242, 118, 28, 89, 9, 198, 224, 111, 186, 125 };
static void Main(string[] args)
{
if ((args.Length < 1) || !File.Exists(args[0]))
{
Console.WriteLine("Usage: Decode <file>");
Console.ReadKey();
return;
}
string fileName = args[0];
string intermediateFile = fileName + ".plain"; /// Intermediate file, output of cryptography decoding
string backupFile = fileName + ".bak";
try
{
using (StreamReader reader = new StreamReader(fileName))
{
if (reader.ReadLine().StartsWith("<?xml version="))
{
Console.WriteLine(string.Format("File {0} is not encrypted.", fileName));
Console.ReadKey();
return;
}
}
bool successful = false;
using (RijndaelManaged aes = new RijndaelManaged { Padding = PaddingMode.Zeros })
{
using (FileStream fsCrypt = new FileStream(fileName, FileMode.Open))
{
using (FileStream fsOut = new FileStream(intermediateFile, FileMode.Create))
{
using (ICryptoTransform decryptor = aes.CreateDecryptor(key, IV))
{
using (CryptoStream cs = new CryptoStream(fsCrypt, decryptor, CryptoStreamMode.Read))
{
int data;
while ((data = cs.ReadByte()) != -1)
{
if (data != 0) fsOut.WriteByte((byte)data);
}
successful = true;
}
}
}
}
}
if (successful)
{
/// File decryption successfuly completed => rotate files
if (File.Exists(backupFile)) File.Delete(backupFile);
File.Move(fileName, backupFile);
File.Move(intermediateFile, fileName);
return;
}
else
{
Failed(fileName, intermediateFile, "");
return;
}
}
catch (Exception e)
{
Failed(fileName, intermediateFile, e.Message);
return;
}
}
static void Failed(string fileName, string toBeDeleted, string message)
{
if (File.Exists(toBeDeleted))
{
File.Delete(toBeDeleted);
}
Console.WriteLine(string.Format("Decryption of file {0} failed: {1}", fileName, message));
Console.ReadKey();
}
}
}
-36
View File
@@ -1,36 +0,0 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Decrypt")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Decrypt")]
[assembly: AssemblyCopyright("Copyright © 2019")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("c17ec788-0e12-4f9c-aadf-ea4e83a9f373")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// 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("1.0.1.0")]
[assembly: AssemblyFileVersion("1.0.1.0")]
-3
View File
@@ -1,3 +0,0 @@
<?xml version="1.0"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
-64
View File
@@ -1,64 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{DA9B09F3-A99D-4883-A954-537560453674}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Encrypt</RootNamespace>
<AssemblyName>Encrypt</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<StartupObject>Encrypt.Program</StartupObject>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
-93
View File
@@ -1,93 +0,0 @@
using System;
using System.IO;
using System.Security.Cryptography;
using System.Text;
namespace Encrypt
{
/// <summary>
/// See also:
/// https://www.fluxbytes.com/csharp/encrypt-and-decrypt-files-in-c/
/// </summary>
class Program
{
static byte[] key = new byte[] { 83, 254, 105, 64, 184, 201, 195, 127, 52, 99, 77, 45, 252, 132, 163, 156 };
static byte[] IV = new byte[] { 189, 23, 137, 56, 204, 241, 242, 118, 28, 89, 9, 198, 224, 111, 186, 125 };
static void Main(string[] args)
{
if ((args.Length < 1) || !File.Exists(args[0]))
{
Console.WriteLine("Usage: Encode <file>");
Console.ReadKey();
return;
}
string fileName = args[0];
string intermediateFile = fileName + ".encrypted"; /// Intermediate file, output of cryptography encoding
string backupFile = fileName + ".bak";
try
{
using (StreamReader reader = new StreamReader(fileName))
{
if (!reader.ReadLine().StartsWith("<?xml version="))
{
Console.WriteLine(string.Format("File {0} is already encrypted.", fileName));
Console.ReadKey();
return;
}
}
bool successful = false;
using (RijndaelManaged aes = new RijndaelManaged { Padding = PaddingMode.Zeros })
{
using (FileStream fsCrypt = new FileStream(intermediateFile, FileMode.Create))
{
using (ICryptoTransform encryptor = aes.CreateEncryptor(key, IV))
{
using (CryptoStream cs = new CryptoStream(fsCrypt, encryptor, CryptoStreamMode.Write))
{
using (FileStream fsIn = new FileStream(fileName, FileMode.Open))
{
int data;
while ((data = fsIn.ReadByte()) != -1) cs.WriteByte((byte)data);
successful = true;
}
}
}
}
}
if (successful)
{
/// File encryption successfuly completed => rotate files
if (File.Exists(backupFile)) File.Delete(backupFile);
File.Move(fileName, backupFile);
File.Move(intermediateFile, fileName);
return;
}
else
{
Failed(fileName, intermediateFile);
return;
}
}
catch (Exception)
{
Failed(fileName, intermediateFile);
return;
}
}
static void Failed(string fileName, string toBeDeleted)
{
if (File.Exists(toBeDeleted))
{
File.Delete(toBeDeleted);
}
Console.WriteLine(string.Format("Encryption of file {0} failed.", fileName));
Console.ReadKey();
}
}
}
-36
View File
@@ -1,36 +0,0 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Encrypt")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Encrypt")]
[assembly: AssemblyCopyright("Copyright © 2019")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("0f602531-6f1f-416e-af4d-9242855715a8")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// 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("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
-3
View File
@@ -1,3 +0,0 @@
<?xml version="1.0"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
+2 -2
View File
@@ -135,10 +135,10 @@ namespace Results.Entities
public virtual double TargetTime() { return TestData.TargetTime; }
public virtual string Method() { return TestData.Method; }
public virtual string RefFlowmeter() { return (Components != null) ? Components.Flowmeter : string.Empty; }
public virtual bool IsRelErrTest() { return (MethodClass != null) ? (MethodClass.Contains("FixedStart") || MethodClass.Contains("FlyingStart") || MethodClass.Contains("CombinedWithDetection") || MethodClass.Contains("DiverterTest")) : true; }
public virtual bool IsRelErrTest() { return (MethodClass != null) ? (MethodClass.Contains("FixedStart") || MethodClass.Contains("FlyingStart") || MethodClass.Contains("CombinedWithDetection")) : true; }
public virtual bool IsPMaxTest() { return (MethodClass != null) ? (MethodClass.Contains("PMaxTest") || MethodClass.Contains("LeakTest")) : true; }
public virtual bool IsStartStop() { return (MethodClass != null) ? MethodClass.Contains("FixedStart") : true; }
public virtual bool IsDiverter() { return (MethodClass != null) ? ((MethodClass.Contains("FlyingStart") && MethodClass.Contains("MassColl")) || MethodClass.Contains("DiverterTest")) : true; }
public virtual bool IsDiverter() { return (MethodClass != null) ? (MethodClass.Contains("FlyingStart") && MethodClass.Contains("MassColl")) : true; }
public virtual bool IsVolumeMethod() { return (MethodClass != null) ? (MethodClass.Contains("TestMethods.FixedStart.") || MethodClass.Contains("TestMethods.FlyingStart.")) : false; }
public virtual string MethodElde()
-6
View File
@@ -528,12 +528,6 @@ namespace Results.Entities
return NokColor;
}
}
else if (Disabled)
{
/// Water meter was not completed yet => did not pass, did not fail
message = Strings.This_position_is_disabled;
return NotCompletedColor;
}
else
{
/// Water meter was not completed yet => did not pass, did not fail
+298 -194
View File
@@ -1,5 +1,10 @@
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 log4net;
using Config.Entities;
@@ -13,33 +18,43 @@ namespace Results.Forms
{
static readonly ILog log = LogManager.GetLogger(typeof(BatchResultsDlg));
DateTime lastRedraw;
DateTime lastSizeChange;
bool loaded;
///
/// Public members
///
public Results.BatchResults Results;
public IList<Results.WMeterRsltItemSpec> Items;
public MetersArrangement MetersArrangement;
public TestsArrangement TestsArrangement;
public int NrMetersInOneGroup;
public bool ShowDisabledPositions;
public int MinWidth;
public int MinHeight;
public IList<Results.WMeterRsltItemSpec> RsltItems_Screen_SingleWM;
public IList<Results.WMeterRsltItemSpec> RsltItems_Screen_CombinedWM;
public IList<Results.WMeterRsltItemSpec> RsltItems_Screen_HeatM;
public int[] RsltsClmnWidths { set { rsltsClmnWidths = value; } }
public int PopupResultsLeft;
public int PopupResultsTop;
public int PopupResultsWidth;
public int PopupResultsHeight;
public int[] RsltsClmnWidths;
public Results.BatchResults Results { set { Display(value); } }
///
/// Private members
///
IOneWMResultsCtrl[] wmRsltsCtrl; /// An array of controls with water meter results.
IOneWMResultsCtrl firstEnabledControl;
DateTime lastRedraw;
DateTime lastSizeChange;
int metersInOneGroup;
int nrGroups;
Results.BatchResults results;
MetersKind metersKind;
OneWMResultsCtrl firstListView;
public int[] rsltsClmnWidths;
int rsltsClmnCount { get { return (rsltsClmnWidths != null) ? rsltsClmnWidths.Length : 0; } }
int lvWidth;
int lvHeight;
Timer timer;
@@ -47,193 +62,310 @@ namespace Results.Forms
public BatchResultsDlg()
{
InitializeComponent();
Text = Strings.Results;
firstEnabledControl = null;
lastSizeChange = DateTime.Now;
nrGroups = 1;
metersInOneGroup = 1;
/// Create a timer with one second interval.
// Create a timer with a ten second interval.
timer = new Timer();
timer.Interval = 1000; /// ms
timer.Interval = 500; /// ms
timer.Tick += new EventHandler(OnTimer);
timer.Start();
}
private void BatchResultsDlg_Load(object sender, EventArgs e)
{
if (PopupResultsLeft != 0) Left = PopupResultsLeft;
if (PopupResultsTop != 0) Top = PopupResultsTop;
if (PopupResultsWidth != 0) Width = PopupResultsWidth;
if (PopupResultsLeft != 0) Left = PopupResultsLeft;
if (PopupResultsTop != 0) Top = PopupResultsTop;
if (PopupResultsWidth != 0) Width = PopupResultsWidth;
if (PopupResultsHeight != 0) Height = PopupResultsHeight;
CreateControlsAndFillPanel(Results);
UpdateColumnWidths(RsltsClmnWidths);
UpdateResults(Results);
loaded = true;
if (results != null) Redraw();
}
public void Display(Results.BatchResults results)
{
this.results = results;
if (loaded) Redraw();
}
///
/// Handle double-click inside a water meter results control
///
void OnDoubleClick(object sender, Results.Forms.WaterMeterEventArgs args)
IList<Results.WMeterRsltItemSpec> GetRsltItems(MetersKind metersKind)
{
if (Results.WaterMeters != null && args.WMPosition > 0)
IList<Results.WMeterRsltItemSpec> srcItems;
switch (metersKind)
{
foreach (var wm in Results.WaterMeters)
{
if ((wm != null) && (wm.WMPosition == args.WMPosition))
{
ShowMoreWMResults(wm);
return;
}
}
default:
case MetersKind.Single: srcItems = RsltItems_Screen_SingleWM; break;
case MetersKind.Combined: srcItems = RsltItems_Screen_CombinedWM; break;
case MetersKind.HeatMeter: srcItems = RsltItems_Screen_HeatM; break;
}
MessageBox.Show(Strings.No_water_meter);
return;
}
void UpdateColumnWidths(int[] columnWidths)
{
foreach (var ctrl in wmRsltsCtrl) ctrl.Update(columnWidths);
}
void UpdateScrollpositions(int scrollStart)
{
/// TODO
IList<Results.WMeterRsltItemSpec> copiedItems = new List<Results.WMeterRsltItemSpec>();
foreach (var it in srcItems) copiedItems.Add(it.Clone());
return copiedItems;
}
/// <summary>
/// Re-draw the results. Apply new settings if they changed.
/// </summary>
void CreateControlsAndFillPanel(Results.BatchResults results)
public void Redraw()
{
if ((results == null) || (results.WMPositionsCount == 0))
lastRedraw = DateTime.Now;
this.SuspendLayout();
try
{
/// There are no water meters at all
/// Determine how many water meters were enabled for result evaluation and printing
int enabledWMsCount = 0;
for (int i = 0; i < results.WMPositionsCount; i++)
{
if (results.WaterMeters[i] != null && !results.WaterMeters[i].Disabled)
{
enabledWMsCount++;
}
}
int metersInOneGroup = Math.Max(1, Math.Min(enabledWMsCount, NrMetersInOneGroup));
int nrGroups = Math.Max(1, (enabledWMsCount + metersInOneGroup - 1) / metersInOneGroup);
if (MetersArrangement == MetersArrangement.Horizontally)
{
flowLayoutPanel.FlowDirection = FlowDirection.LeftToRight;
lvWidth = flowLayoutPanel.Width / metersInOneGroup - 6;
lvHeight = flowLayoutPanel.Height / nrGroups - 6;
}
else
{
flowLayoutPanel.FlowDirection = FlowDirection.TopDown;
lvWidth = flowLayoutPanel.Width / nrGroups - 6;
lvHeight = flowLayoutPanel.Height / metersInOneGroup - 6;
}
flowLayoutPanel.Controls.Clear();
wmRsltsCtrl = new OneWMResultsRowsCtrl[0];
firstEnabledControl = null;
flowLayoutPanel.WrapContents = true;
flowLayoutPanel.AutoScroll = true;
bool first = true;
for (int i = 0; i < results.WMPositionsCount; i++)
{
if (results.WaterMeters[i] != null && !results.WaterMeters[i].Disabled)
{
OneWMResultsCtrl lview = (TestsArrangement == TestsArrangement.Rows)
? GetResultsTestsAreRows(results.WaterMeters[i], i + 1)
: GetResultsTestsAreColumns(results.WaterMeters[i], i + 1);
if (lview != null)
{
flowLayoutPanel.Controls.Add(lview);
if (first)
{
firstListView = lview;
first = false;
}
lview.WMResultsClickedHandler += delegate(object sender, Results.Forms.WaterMeterEventArgs args)
{
if (InvokeRequired)
{
Invoke(new EventHandler<Results.Forms.WaterMeterEventArgs>(OnDoubleClick), sender, args);
}
else
{
OnDoubleClick(sender, args);
}
};
}
}
}
}
catch (Exception e)
{
log.FatalFormat("Redrawing results failed : {0}", e.Message);
if (e.InnerException != null)
{
log.FatalFormat("InnerMessage : {0}", e.InnerException.Message);
}
log.FatalFormat("StackTrace : {0}{1}", Environment.NewLine, e.StackTrace);
}
this.ResumeLayout(false);
}
/// <summary>
/// Get an empty ListView control with appropriate parameters.
/// </summary>
/// <returns>ListView control</returns>
OneWMResultsCtrl GetListView(Color backColor, Results.Entities.WaterMeter wm)
{
return new OneWMResultsCtrl(backColor, lvWidth, lvHeight, wm);
}
///
OneWMResultsCtrl GetListView(Results.Entities.WaterMeter wm)
{
return GetListView(Color.White, wm);
}
/// <summary>
/// Get a ListView control filled with results of the meter 'mtr'
/// </summary>
/// <param name="mtr">Water meter number (1-based): 1 .. Config.Data.WMsCount</param>
/// <returns>ListView object</returns>
OneWMResultsCtrl GetResultsTestsAreRows(Results.Entities.WaterMeter wMtr, int printedWMNr)
{
metersKind = wMtr.Compound() ? MetersKind.Combined : (wMtr.HeatMeter() ? MetersKind.HeatMeter : MetersKind.Single);
string message = string.Empty;
Color commonBackColor = wMtr.GetColorOfResults(false, out message);
OneWMResultsCtrl lview = GetListView(commonBackColor, wMtr);
#if ORACLE_DB
lview.Caption = string.Format("{0} ({1}) {2}", (string.IsNullOrEmpty(wMtr.SerialNr) ? string.Empty : wMtr.SerialNr), (wMtr.Pruefindex % 100), message);
#else
lview.Caption = string.Format("s/n = {0}", string.IsNullOrEmpty(wMtr.SerialNr) ? string.Empty : wMtr.SerialNr);
#endif
IList<Results.WMeterRsltItemSpec> items = GetRsltItems(metersKind);
if (items == null || items.Count == 0) return lview;
// Header
lview.Columns.Add(printedWMNr.ToString(), (rsltsClmnCount > 0) ? rsltsClmnWidths[0] : 40);
int col = 1;
foreach (var item in items)
{
lview.Columns.Add(item.Caption, (rsltsClmnCount > col) ? rsltsClmnWidths[col] : 70);
col++;
}
IList<string> testNames = wMtr.GetAllDecoratedTestNames();
int ix = 0;
foreach (var mtr in wMtr.MeterTestRslts)
{
if (mtr != null && mtr.IsPilotRslt() && mtr.TestDone && mtr.Publish() != Config.Entities.Publish.Never
&& mtr.Publish() != Config.Entities.Publish.Internal)
{
ListViewItem lvi = new ListViewItem(testNames[ix++]);
for (int i = 0; i < items.Count; i++)
{
string str = items[i].Print(wMtr, mtr.Name());
/// Extract and use color information
string[] texts = str.Split(new char[] { '|' });
if (texts.Length == 1)
{
lvi.SubItems.Add(str);
}
else if (texts.Length == 2)
{
Color color = texts[1].Equals("Green") ? Color.Green : (texts[1].Equals("Red") ? Color.Red : Color.White);
lvi.UseItemStyleForSubItems = false;
lvi.SubItems.Add(texts[0]);
lvi.SubItems[lvi.SubItems.Count - 1].BackColor = color;
}
else
{
lvi.SubItems.Add(string.Empty);
}
}
lview.Items.Add(lvi);
}
}
return lview;
}
/// <summary>
/// Get a ListView control filled with results of the meter 'mtr'
/// </summary>
/// <param name="mtr">Water meter number (1-based): 1 .. Config.Data.WMsCount</param>
/// <returns>ListView object</returns>
OneWMResultsCtrl GetResultsTestsAreColumns(Results.Entities.WaterMeter wMtr, int printedWMNr)
{
metersKind = wMtr.Compound() ? MetersKind.Combined : (wMtr.HeatMeter() ? MetersKind.HeatMeter : MetersKind.Single);
string message;
Color commonBackColor = wMtr.GetColorOfResults(false, out message);
OneWMResultsCtrl lview = GetListView(commonBackColor, wMtr);
#if ORACLE_DB
lview.Caption = string.Format("{0} ({1}) {2}", (string.IsNullOrEmpty(wMtr.SerialNr) ? string.Empty : wMtr.SerialNr), (wMtr.Pruefindex % 100), message);
#else
lview.Caption = string.Format("s/n = {0}", string.IsNullOrEmpty(wMtr.SerialNr) ? string.Empty : wMtr.SerialNr);
#endif
IList<Results.WMeterRsltItemSpec> items = GetRsltItems(metersKind);
if (items == null || items.Count == 0) return lview;
// Header
lview.Columns.Add(printedWMNr.ToString(), (rsltsClmnCount > 0) ? rsltsClmnWidths[0] : 40);
int i = 1;
foreach (var str in wMtr.GetAllDecoratedTestNames())
{
lview.Columns.Add(str, (rsltsClmnCount > i) ? rsltsClmnWidths[i] : 70);
i++;
}
foreach (var item in items)
{
ListViewItem lvi = new ListViewItem(item.Caption);
foreach (var mtr in wMtr.MeterTestRslts)
{
if (mtr != null && mtr.IsPilotRslt() && mtr.TestDone && mtr.Publish() != Config.Entities.Publish.Never &&
mtr.Publish() != Config.Entities.Publish.Internal)
{
string str = item.Print(wMtr, mtr.Name());
string[] texts = str.Split(new char[] { '|' });
if (texts.Length == 1)
{
lvi.SubItems.Add(str);
}
else if (texts.Length == 2)
{
Color color = texts[1].Equals("Green") ? Color.Green : (texts[1].Equals("Red") ? Color.Red : Color.White);
lvi.UseItemStyleForSubItems = false;
lvi.SubItems.Add(texts[0]);
lvi.SubItems[lvi.SubItems.Count - 1].BackColor = color;
}
else
{
lvi.SubItems.Add(string.Empty);
}
}
}
lview.Items.Add(lvi);
}
return lview;
}
void OnDoubleClick(object sender, Results.Forms.WaterMeterEventArgs args)
{
if ( args.WM == null || args.WM.Disabled)
{
MessageBox.Show(Strings.No_water_meter);
return;
}
///
/// Determine water meter positions count
///
int displayedControlsCount = 0;
for (int i = 0; i < results.WaterMeters.Length; i++)
else if ((TracingDB.DB.SessionFactory == null) || string.IsNullOrEmpty(args.WM.SerialNr))
{
if (results.WaterMeters[i] != null)
{
if (ShowDisabledPositions || !results.WaterMeters[i].Disabled)
{
displayedControlsCount++;
}
}
}
///
/// Calculate geometry
///
metersInOneGroup = Math.Max(1, Math.Min(displayedControlsCount, NrMetersInOneGroup));
nrGroups = Math.Max(1, (displayedControlsCount + metersInOneGroup - 1) / metersInOneGroup);
int oneWidth;
int oneHeight;
///
if (MetersArrangement == MetersArrangement.Horizontally)
{
flowLayoutPanel.FlowDirection = FlowDirection.LeftToRight;
oneWidth = Math.Max(MinWidth, flowLayoutPanel.Width / metersInOneGroup - 6);
oneHeight = Math.Max(MinHeight, flowLayoutPanel.Height / nrGroups - 6);
}
else
{
flowLayoutPanel.FlowDirection = FlowDirection.TopDown;
oneWidth = Math.Max(MinWidth, flowLayoutPanel.Width / nrGroups - 6);
oneHeight = Math.Max(MinHeight, flowLayoutPanel.Height / metersInOneGroup - 6);
}
///
/// Create controls and fill the FlowLayoutPanel
///
flowLayoutPanel.SuspendLayout();
flowLayoutPanel.Controls.Clear();
flowLayoutPanel.WrapContents = true;
flowLayoutPanel.AutoScroll = true;
wmRsltsCtrl = new IOneWMResultsCtrl[displayedControlsCount];
int ix = 0;
firstEnabledControl = null;
for (int i = 0; i < results.WaterMeters.Length; i++)
{
if (results.WaterMeters[i] != null)
{
if (!results.WaterMeters[i].Disabled || ShowDisabledPositions)
{
/// Create one water meter position / control
wmRsltsCtrl[ix] = (TestsArrangement == TestsArrangement.Rows)
? new OneWMResultsRowsCtrl() as IOneWMResultsCtrl
: new OneWMResultsColumnsCtrl() as IOneWMResultsCtrl;
wmRsltsCtrl[ix].Width = oneWidth;
wmRsltsCtrl[ix].Height = oneHeight;
wmRsltsCtrl[ix].Update(Items);
wmRsltsCtrl[ix].WMResultsClickedHandler += delegate(object s, Results.Forms.WaterMeterEventArgs args)
{
if (InvokeRequired)
{
Invoke(new EventHandler<Results.Forms.WaterMeterEventArgs>(OnDoubleClick), s, args);
}
else
{
OnDoubleClick(s, args);
}
};
flowLayoutPanel.Controls.Add(wmRsltsCtrl[ix] as UserControl);
if ((firstEnabledControl == null) && !results.WaterMeters[i].Disabled) firstEnabledControl = wmRsltsCtrl[ix];
ix++;
}
}
}
flowLayoutPanel.ResumeLayout();
lastRedraw = DateTime.Now;
}
void UpdateResults(Results.BatchResults batchResults)
{
if ((batchResults != null) && (batchResults.WaterMeters != null))
{
int ctrlIx = 0;
for (int i = 0; i < batchResults.WaterMeters.Length; i++)
{
if (!batchResults.WaterMeters[i].Disabled || ShowDisabledPositions)
{
if (ctrlIx < wmRsltsCtrl.Length) wmRsltsCtrl[ctrlIx++].Update(batchResults.WaterMeters[i]);
}
}
}
}
void ShowMoreWMResults(Results.Entities.WaterMeter wm)
{
if ((TracingDB.DB.SessionFactory == null) || string.IsNullOrEmpty(wm.SerialNr))
{
new Results.Forms.MoreWMResultsDlg(wm, null).ShowDialog();
new Results.Forms.MoreWMResultsDlg( args.WM, null).ShowDialog();
}
else
{
using (ISession session = TracingDB.DB.SessionFactory.OpenSession())
{
IList<ReferenceRecord> refRecords = session.QueryOver<ReferenceRecord>()
.Where(x => (x.Code == wm.SerialNr))
.Where(x => (x.Code == args.WM.SerialNr))
.OrderBy(x => x.TimeStamp).Desc
.List();
for (int i = 0; i < refRecords.Count; i++)
@@ -259,7 +391,7 @@ namespace Results.Forms
}
}
new Results.Forms.MoreWMResultsDlg(wm, refRecords).ShowDialog();
new Results.Forms.MoreWMResultsDlg(args.WM, refRecords).ShowDialog();
}
}
}
@@ -273,7 +405,6 @@ namespace Results.Forms
PopupResultsHeight = Height;
}
private void flowLayoutPanel_SizeChanged(object sender, EventArgs e)
{
lastSizeChange = DateTime.Now;
@@ -283,40 +414,13 @@ namespace Results.Forms
{
if (DateTime.Compare(lastSizeChange, lastRedraw) > 0)
{
/// The last size change was more recent then the last redraw
/// The last size change was later then the last redraw
DateTime now = DateTime.Now;
if (DateTime.Compare(lastSizeChange + new TimeSpan(0, 0, 1), now) < 0)
{
/// More then 1 second since the last panel size change
/// Calculate geometry
int oneWidth;
int oneHeight;
///
if (MetersArrangement == MetersArrangement.Horizontally)
{
flowLayoutPanel.FlowDirection = FlowDirection.LeftToRight;
oneWidth = Math.Max(MinWidth, flowLayoutPanel.Width / metersInOneGroup - 6);
oneHeight = Math.Max(MinHeight, flowLayoutPanel.Height / nrGroups - 6);
}
else
{
flowLayoutPanel.FlowDirection = FlowDirection.TopDown;
oneWidth = Math.Max(MinWidth, flowLayoutPanel.Width / nrGroups - 6);
oneHeight = Math.Max(MinHeight, flowLayoutPanel.Height / metersInOneGroup - 6);
}
/// Update size of controls
flowLayoutPanel.SuspendLayout();
///
foreach (var oneCtrl in wmRsltsCtrl)
{
oneCtrl.Width = oneWidth;
oneCtrl.Height = oneHeight;
}
///
flowLayoutPanel.ResumeLayout();
/// More then 1s since the last size change
Redraw();
}
}
}
-25
View File
@@ -1,25 +0,0 @@
///
/// Copyright (c) 2019 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
namespace Results.Forms
{
public interface IOneWMResultsCtrl
{
event EventHandler<WaterMeterEventArgs> WMResultsClickedHandler;
bool Disabled { get; } /// true when water meter position is disabled
int WMPosition { get; } /// 1-based WM position
int Width { get; set; } /// Control width
int Height { get; set; } /// Control height
ListView.ColumnHeaderCollection Columns { get; } /// Embedded ListView control columns
void Update(int[] columnWidths);
void Update(IList<Results.WMeterRsltItemSpec> items);
void Update(Results.Entities.WaterMeter wMtr);
}
}
+24 -11
View File
@@ -29,13 +29,15 @@
private void InitializeComponent()
{
this.tabControl1 = new System.Windows.Forms.TabControl();
this.allResultsTabPage = new System.Windows.Forms.TabPage();
this.graphsTabPage = new System.Windows.Forms.TabPage();
this.productionTracingTabPage = new System.Windows.Forms.TabPage();
this.productionTracingSplitContainer = new System.Windows.Forms.SplitContainer();
this.messageLabel = new System.Windows.Forms.Label();
this.tracingResultsListView = new System.Windows.Forms.ListView();
this.allResultsTabPage = new System.Windows.Forms.TabPage();
this.oneWMResultsCtrl = new Results.Forms.OneWMResultsCtrl();
this.tabControl1.SuspendLayout();
this.allResultsTabPage.SuspendLayout();
this.productionTracingTabPage.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.productionTracingSplitContainer)).BeginInit();
this.productionTracingSplitContainer.Panel1.SuspendLayout();
@@ -55,6 +57,17 @@
this.tabControl1.Size = new System.Drawing.Size(1195, 448);
this.tabControl1.TabIndex = 0;
//
// allResultsTabPage
//
this.allResultsTabPage.Controls.Add(this.oneWMResultsCtrl);
this.allResultsTabPage.Location = new System.Drawing.Point(4, 22);
this.allResultsTabPage.Name = "allResultsTabPage";
this.allResultsTabPage.Padding = new System.Windows.Forms.Padding(3);
this.allResultsTabPage.Size = new System.Drawing.Size(1187, 422);
this.allResultsTabPage.TabIndex = 0;
this.allResultsTabPage.Text = "All results";
this.allResultsTabPage.UseVisualStyleBackColor = true;
//
// graphsTabPage
//
this.graphsTabPage.Location = new System.Drawing.Point(4, 22);
@@ -120,15 +133,14 @@
this.tracingResultsListView.UseCompatibleStateImageBehavior = false;
this.tracingResultsListView.View = System.Windows.Forms.View.Details;
//
// allResultsTabPage
// oneWMResultsCtrl
//
this.allResultsTabPage.Location = new System.Drawing.Point(4, 22);
this.allResultsTabPage.Name = "allResultsTabPage";
this.allResultsTabPage.Padding = new System.Windows.Forms.Padding(3);
this.allResultsTabPage.Size = new System.Drawing.Size(1187, 422);
this.allResultsTabPage.TabIndex = 0;
this.allResultsTabPage.Text = "All results";
this.allResultsTabPage.UseVisualStyleBackColor = true;
this.oneWMResultsCtrl.Caption = "";
this.oneWMResultsCtrl.Dock = System.Windows.Forms.DockStyle.Fill;
this.oneWMResultsCtrl.Location = new System.Drawing.Point(3, 3);
this.oneWMResultsCtrl.Name = "oneWMResultsCtrl";
this.oneWMResultsCtrl.Size = new System.Drawing.Size(1181, 416);
this.oneWMResultsCtrl.TabIndex = 0;
//
// MoreWMResultsDlg
//
@@ -140,6 +152,7 @@
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Water meter results";
this.tabControl1.ResumeLayout(false);
this.allResultsTabPage.ResumeLayout(false);
this.productionTracingTabPage.ResumeLayout(false);
this.productionTracingSplitContainer.Panel1.ResumeLayout(false);
this.productionTracingSplitContainer.Panel1.PerformLayout();
@@ -153,12 +166,12 @@
#endregion
private System.Windows.Forms.TabControl tabControl1;
private OneWMResultsRowsCtrl oneWMResultsCtrl;
private System.Windows.Forms.TabPage allResultsTabPage;
private OneWMResultsCtrl oneWMResultsCtrl;
private System.Windows.Forms.TabPage graphsTabPage;
private System.Windows.Forms.TabPage productionTracingTabPage;
private System.Windows.Forms.SplitContainer productionTracingSplitContainer;
private System.Windows.Forms.Label messageLabel;
private System.Windows.Forms.ListView tracingResultsListView;
private System.Windows.Forms.TabPage allResultsTabPage;
}
}
+48 -86
View File
@@ -51,57 +51,57 @@ namespace Results.Forms
/// <param name="wMtr">Water meter entity</param>
void ShowAllResults(Results.Entities.WaterMeter wMtr)
{
// string message;
// Color commonBackColor = wMtr.GetColorOfResults(false, out message); /// Ony message is used later on
//#if ORACLE_DB
// oneWMResultsCtrl.Caption = string.Format("{0} ({1}) {2}", (string.IsNullOrEmpty(wMtr.SerialNr) ? string.Empty : wMtr.SerialNr), (wMtr.Pruefindex % 100), message);
//#else
// oneWMResultsCtrl.Caption = string.Format("s/n = {0}", string.IsNullOrEmpty(wMtr.SerialNr) ? string.Empty : wMtr.SerialNr);
//#endif
string message;
Color commonBackColor = wMtr.GetColorOfResults(false, out message); /// Ony message is used later on
#if ORACLE_DB
oneWMResultsCtrl.Caption = string.Format("{0} ({1}) {2}", (string.IsNullOrEmpty(wMtr.SerialNr) ? string.Empty : wMtr.SerialNr), (wMtr.Pruefindex % 100), message);
#else
oneWMResultsCtrl.Caption = string.Format("s/n = {0}", string.IsNullOrEmpty(wMtr.SerialNr) ? string.Empty : wMtr.SerialNr);
#endif
// IList<Results.WMeterRsltItemSpec> items = Results.WMeterRsltItemSpec.AllItems;
IList<Results.WMeterRsltItemSpec> items = Results.WMeterRsltItemSpec.AllItems;
// // Header
// oneWMResultsCtrl.Columns.Add(wMtr.WMPosition.ToString(), 100);
// int i = 1;
// foreach (var str in wMtr.GetAllDecoratedTestNames())
// {
// oneWMResultsCtrl.Columns.Add(str, 100);
// i++;
// }
// Header
oneWMResultsCtrl.Columns.Add(wMtr.WMPosition.ToString(), 100);
int i = 1;
foreach (var str in wMtr.GetAllDecoratedTestNames())
{
oneWMResultsCtrl.Columns.Add(str, 100);
i++;
}
// foreach (var item in items)
// {
// ListViewItem lvi = new ListViewItem(item.Name);
foreach (var item in items)
{
ListViewItem lvi = new ListViewItem(item.Name);
// foreach (var mtr in wMtr.MeterTestRslts)
// {
// if (mtr != null && mtr.IsPilotRslt() && mtr.TestDone && mtr.Publish() != Config.Entities.Publish.Never &&
// mtr.Publish() != Config.Entities.Publish.Internal)
// {
// string str = item.Print(wMtr, mtr.Name());
foreach (var mtr in wMtr.MeterTestRslts)
{
if (mtr != null && mtr.IsPilotRslt() && mtr.TestDone && mtr.Publish() != Config.Entities.Publish.Never &&
mtr.Publish() != Config.Entities.Publish.Internal)
{
string str = item.Print(wMtr, mtr.Name());
// string[] texts = str.Split(new char[] { '|' });
// if (texts.Length == 1)
// {
// lvi.SubItems.Add(str);
// }
// else if (texts.Length == 2)
// {
// Color color = texts[1].Equals("Green") ? Color.Green : (texts[1].Equals("Red") ? Color.Red : Color.White);
// lvi.UseItemStyleForSubItems = false;
// lvi.SubItems.Add(texts[0]);
// lvi.SubItems[lvi.SubItems.Count - 1].BackColor = color;
// }
// else
// {
// lvi.SubItems.Add(string.Empty);
// }
// }
// }
string[] texts = str.Split(new char[] { '|' });
if (texts.Length == 1)
{
lvi.SubItems.Add(str);
}
else if (texts.Length == 2)
{
Color color = texts[1].Equals("Green") ? Color.Green : (texts[1].Equals("Red") ? Color.Red : Color.White);
lvi.UseItemStyleForSubItems = false;
lvi.SubItems.Add(texts[0]);
lvi.SubItems[lvi.SubItems.Count - 1].BackColor = color;
}
else
{
lvi.SubItems.Add(string.Empty);
}
}
}
// oneWMResultsCtrl.Items.Add(lvi);
// }
oneWMResultsCtrl.Items.Add(lvi);
}
}
@@ -111,7 +111,7 @@ namespace Results.Forms
//chart.ChartAreas[0].AxisX.Interval = 1;
//chart.ChartAreas[0].AxisX.IntervalType = ;
tabControl1.TabPages[1].Controls.Add(Results.Output.WMChart.GetChart(wm, false));
tabControl1.TabPages[1].Controls.Add(Results.Output.WMChart.GetChart(wm));
}
@@ -131,19 +131,9 @@ namespace Results.Forms
tracingResultsListView.Columns.Add(Strings.Code, 150);
tracingResultsListView.Columns.Add(Strings.Workflow, 450);
if (refRecords == null || refRecords.Count == 0)
foreach (var rr in refRecords)
{
messageLabel.Text = "V sledovaní výroby nie sú žiadne záznamy";
}
else
{
Process proc = refRecords[0].Process;
bool[] isMissing = new bool[proc.Worksteps.Count];
for (int i = 0; i < isMissing.Length; i++) isMissing[i] = true;
foreach (var rr in refRecords)
{
tracingResultsListView.Items.Add(new ListViewItem(new string[]
tracingResultsListView.Items.Add(new ListViewItem(new string[]
{
rr.TimeStamp.ToString("dd.MM.yyyy HH:mm"),
rr.Workstep.Name,
@@ -154,34 +144,6 @@ namespace Results.Forms
rr.Code,
rr.Process.Name,
}));
for (int i = 0; i < isMissing.Length; i++)
{
if (proc.Worksteps[i] == rr.Workstep) isMissing[i] = false;
}
}
string missingWorkplace = null;
for (int i = 0; i < isMissing.Length; i++)
{
if (isMissing[i])
{
if (missingWorkplace == null)
{
missingWorkplace = proc.Worksteps[i].Name;
messageLabel.Text = string.Format("Chýba záznam z pracoviska {0}", missingWorkplace);
}
else
{
messageLabel.Text = string.Format("Chýba záznam z pracoviska {0} aj z nasledujúcich pracovísk", missingWorkplace);
}
}
}
if (missingWorkplace == null)
{
messageLabel.Text = "Všetko je OK";
}
}
}
}
-103
View File
@@ -1,103 +0,0 @@
namespace Results.Forms
{
partial class OneWMResultsColumnsCtrl
{
/// <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.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.tBox = new System.Windows.Forms.TextBox();
this.lView = new System.Windows.Forms.ListView();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
this.splitContainer1.SuspendLayout();
this.SuspendLayout();
//
// splitContainer1
//
this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer1.FixedPanel = System.Windows.Forms.FixedPanel.Panel1;
this.splitContainer1.Location = new System.Drawing.Point(0, 0);
this.splitContainer1.Name = "splitContainer1";
this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal;
//
// splitContainer1.Panel1
//
this.splitContainer1.Panel1.Controls.Add(this.tBox);
//
// splitContainer1.Panel2
//
this.splitContainer1.Panel2.Controls.Add(this.lView);
this.splitContainer1.Size = new System.Drawing.Size(352, 318);
this.splitContainer1.SplitterDistance = 25;
this.splitContainer1.SplitterWidth = 1;
this.splitContainer1.TabIndex = 0;
//
// tBox
//
this.tBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.tBox.Location = new System.Drawing.Point(0, 0);
this.tBox.Name = "tBox";
this.tBox.Size = new System.Drawing.Size(352, 20);
this.tBox.TabIndex = 0;
this.tBox.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.tBox_MouseDoubleClick);
//
// lView
//
this.lView.Dock = System.Windows.Forms.DockStyle.Fill;
this.lView.FullRowSelect = true;
this.lView.GridLines = true;
this.lView.Location = new System.Drawing.Point(0, 0);
this.lView.Name = "lView";
this.lView.Size = new System.Drawing.Size(352, 292);
this.lView.TabIndex = 0;
this.lView.UseCompatibleStateImageBehavior = false;
this.lView.View = System.Windows.Forms.View.Details;
//
// OneWMResultsCtrl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.splitContainer1);
this.Name = "OneWMResultsCtrl";
this.Size = new System.Drawing.Size(352, 318);
this.splitContainer1.Panel1.ResumeLayout(false);
this.splitContainer1.Panel1.PerformLayout();
this.splitContainer1.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
this.splitContainer1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.SplitContainer splitContainer1;
private System.Windows.Forms.TextBox tBox;
private System.Windows.Forms.ListView lView;
}
}
-159
View File
@@ -1,159 +0,0 @@
///
/// Copyright (c) 2019 Sensus Slovensko a.s.
///
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Collections.Generic;
namespace Results.Forms
{
public partial class OneWMResultsColumnsCtrl : UserControl, IOneWMResultsCtrl
{
public event EventHandler<WaterMeterEventArgs> WMResultsClickedHandler;
///
private void tBox_MouseDoubleClick(object sender, MouseEventArgs e)
{
try
{
if (WMResultsClickedHandler != null) WMResultsClickedHandler(sender, new WaterMeterEventArgs(wmPosition));
}
catch (Exception)
{
}
}
bool disabled;
int wmPosition; /// 1-based water meter position
string caption;
Color bkColor;
int[] columnWidths;
IList<Results.WMeterRsltItemSpec> items;
public bool Disabled { get { return disabled; } } /// Read only
public int WMPosition { get { return wmPosition; } } /// Read only
public ListView.ColumnHeaderCollection Columns { get { return lView.Columns; } } /// Read only
public OneWMResultsColumnsCtrl()
{
InitializeComponent();
disabled = false;
wmPosition = 0;
tBox.Text = caption = "---";
tBox.BackColor = lView.BackColor = bkColor = Color.White;
items = new List<Results.WMeterRsltItemSpec>();
columnWidths = new int[0];
}
public void Update(int[] columnWidths)
{
this.columnWidths = columnWidths;
/// Always update ListView column widths
int col = 0;
foreach (ColumnHeader column in lView.Columns)
{
column.Width = (columnWidths != null && columnWidths.Length > col) ? columnWidths[col] : ((col == 0) ? 40 : 70);
col++;
}
}
public void Update(IList<Results.WMeterRsltItemSpec> items)
{
this.items = items;
}
public void Update(Results.Entities.WaterMeter wMtr)
{
if (wMtr == null || wMtr.Disabled)
{
/// Water meter position is disabled
this.disabled = true;
lView.Items.Clear();
tBox.Text = caption = "---";
tBox.BackColor = lView.BackColor = bkColor = Color.White;
return;
}
/// Update background color
string message = string.Empty;
Update(wMtr.GetColorOfResults(false, out message));
/// Update caption
#if ORACLE_DB
tBox.Text = caption = string.Format("{0} ({1}) {2}", (string.IsNullOrEmpty(wMtr.SerialNr) ? string.Empty : wMtr.SerialNr), (wMtr.Pruefindex % 100), message);
#else
tBox.Text = caption = string.Format("s/n = {0}", string.IsNullOrEmpty(wMtr.SerialNr) ? string.Empty : wMtr.SerialNr);
#endif
/// Header
lView.Columns.Add(wmPosition.ToString(), (columnWidths.Length > 0) ? columnWidths[0] : 40);
int col = 1;
foreach (var str in wMtr.GetAllDecoratedTestNames())
{
lView.Columns.Add(str, (columnWidths.Length > col) ? columnWidths[col] : 70);
col++;
}
lView.Items.Clear();
if (items == null || items.Count == 0) return;
foreach (var item in items)
{
ListViewItem lvi = new ListViewItem(item.Caption);
foreach (var mtr in wMtr.MeterTestRslts)
{
if (mtr != null && mtr.IsPilotRslt() && mtr.TestDone && mtr.Publish() != Config.Entities.Publish.Never &&
mtr.Publish() != Config.Entities.Publish.Internal)
{
string str = item.Print(wMtr, mtr.Name());
string[] texts = str.Split(new char[] { '|' });
if (texts.Length == 1)
{
lvi.SubItems.Add(str);
}
else if (texts.Length == 2)
{
Color color = texts[1].Equals("Green") ? Color.Green : (texts[1].Equals("Red") ? Color.Red : Color.White);
lvi.UseItemStyleForSubItems = false;
lvi.SubItems.Add(texts[0]);
lvi.SubItems[lvi.SubItems.Count - 1].BackColor = color;
}
else
{
lvi.SubItems.Add(string.Empty);
}
}
}
lView.Items.Add(lvi);
}
}
///
/// Private
///
void Update(int wmPosition)
{
this.wmPosition = wmPosition;
if (lView.Columns.Count > 0)
{
lView.Columns[0].Text = wmPosition.ToString();
}
}
void Update(Color backColor)
{
if (this.bkColor != backColor)
{
tBox.BackColor = lView.BackColor = this.bkColor = backColor;
}
}
}
}
@@ -1,6 +1,6 @@
namespace Results.Forms
{
partial class OneWMResultsRowsCtrl
partial class OneWMResultsCtrl
{
/// <summary>
/// Required designer variable.
+41
View File
@@ -0,0 +1,41 @@
using System;
using System.Drawing;
using System.Windows.Forms;
using log4net;
namespace Results.Forms
{
public partial class OneWMResultsCtrl : UserControl
{
static readonly ILog log = LogManager.GetLogger(typeof(OneWMResultsCtrl));
public event EventHandler<WaterMeterEventArgs> WMResultsClickedHandler;
public OneWMResultsCtrl()
{
InitializeComponent();
}
public OneWMResultsCtrl(Color backColor, int lvWidth, int lvHeight, Results.Entities.WaterMeter wm)
: this()
{
lView.BackColor = backColor;
tBox.BackColor = backColor;
Size = new System.Drawing.Size(lvWidth, lvHeight);
WM = wm;
}
public Results.Entities.WaterMeter WM;
public string Caption { get { return tBox.Text; } set { tBox.Text = value; } }
public ListView.ColumnHeaderCollection Columns { get { return lView.Columns; } }
public ListView.ListViewItemCollection Items { get { return lView.Items; } }
public Color BColor { set { lView.BackColor = value; tBox.BackColor = value; } }
private void tBox_MouseDoubleClick(object sender, MouseEventArgs e)
{
if (WMResultsClickedHandler == null) return;
try { WMResultsClickedHandler(sender, new WaterMeterEventArgs(WM)); }
catch (Exception exc) { log.Error("WMResultsClickedHandler(...) failed", exc); }
}
}
}
-169
View File
@@ -1,169 +0,0 @@
///
/// Copyright (c) 2019 Sensus Slovensko a.s.
///
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Collections.Generic;
namespace Results.Forms
{
public partial class OneWMResultsRowsCtrl : UserControl, IOneWMResultsCtrl
{
public event EventHandler<WaterMeterEventArgs> WMResultsClickedHandler;
///
private void tBox_MouseDoubleClick(object sender, MouseEventArgs e)
{
try
{
if (WMResultsClickedHandler != null) WMResultsClickedHandler(sender, new WaterMeterEventArgs(wmPosition));
}
catch (Exception)
{
}
}
bool disabled;
int wmPosition; /// 1-based water meter position
string caption;
Color bkColor;
int[] columnWidths;
IList<Results.WMeterRsltItemSpec> items;
public bool Disabled { get { return disabled; } } /// Read only
public int WMPosition { get { return wmPosition; } } /// Read only
public ListView.ColumnHeaderCollection Columns { get { return lView.Columns; } } /// Read only
public OneWMResultsRowsCtrl()
{
InitializeComponent();
disabled = false;
wmPosition = 0;
tBox.Text = caption = "---";
tBox.BackColor = lView.BackColor = bkColor = Color.White;
items = new List<Results.WMeterRsltItemSpec>();
columnWidths = new int[0];
}
public void Update(int[] columnWidths)
{
this.columnWidths = columnWidths;
/// Always update ListView column widths
int col = 0;
foreach (ColumnHeader column in lView.Columns)
{
column.Width = (columnWidths != null && columnWidths.Length > col) ? columnWidths[col] : ((col == 0) ? 40 : 70);
col++;
}
}
public void Update(IList<Results.WMeterRsltItemSpec> items)
{
this.items = items;
/// Always draw ListView header
lView.Columns.Clear();
lView.Columns.Add(wmPosition.ToString(), (columnWidths.Length > 0) ? columnWidths[0] : 40);
if (items == null || items.Count == 0) return;
int col = 1;
foreach (var item in items)
{
lView.Columns.Add(item.Caption, (columnWidths.Length > col) ? columnWidths[col] : 70);
col++;
}
}
public void Update(Results.Entities.WaterMeter wMtr)
{
if (wMtr == null || wMtr.Disabled)
{
/// Water meter position is disabled
this.disabled = true;
lView.Items.Clear();
tBox.Text = caption = "---";
tBox.BackColor = lView.BackColor = bkColor = Color.White;
return;
}
/// Update background color
string message = string.Empty;
Update(wMtr.GetColorOfResults(false, out message));
/// Update caption
#if ORACLE_DB
tBox.Text = caption = string.Format("{0} ({1}) {2}", (string.IsNullOrEmpty(wMtr.SerialNr) ? string.Empty : wMtr.SerialNr), (wMtr.Pruefindex % 100), message);
#else
tBox.Text = caption = string.Format("s/n = {0}", string.IsNullOrEmpty(wMtr.SerialNr) ? string.Empty : wMtr.SerialNr);
#endif
Update(wMtr.WMPosition);
/// Update test results
IList<string> testNames = wMtr.GetAllDecoratedTestNames();
int ix = 0;
lView.Items.Clear();
foreach (var mtr in wMtr.MeterTestRslts)
{
if (mtr != null && mtr.IsPilotRslt() && mtr.TestDone && mtr.Publish() != Config.Entities.Publish.Never
&& mtr.Publish() != Config.Entities.Publish.Internal)
{
ListViewItem lvi = new ListViewItem(testNames[ix++]);
if (items != null)
{
for (int i = 0; i < items.Count; i++)
{
string str = items[i].Print(wMtr, mtr.Name());
/// Extract and use color information
string[] texts = str.Split(new char[] { '|' });
if (texts.Length == 1)
{
lvi.SubItems.Add(str);
}
else if (texts.Length == 2)
{
Color color = texts[1].Equals("Green") ? Color.Green : (texts[1].Equals("Red") ? Color.Red : Color.White);
lvi.UseItemStyleForSubItems = false;
lvi.SubItems.Add(texts[0]);
lvi.SubItems[lvi.SubItems.Count - 1].BackColor = color;
}
else
{
lvi.SubItems.Add(string.Empty);
}
}
}
lView.Items.Add(lvi);
}
}
}
///
/// Private
///
void Update(int wmPosition)
{
this.wmPosition = wmPosition;
if (lView.Columns.Count > 0)
{
lView.Columns[0].Text = wmPosition.ToString();
}
}
void Update(Color backColor)
{
if (this.bkColor != backColor)
{
tBox.BackColor = lView.BackColor = this.bkColor = backColor;
}
}
}
}
-120
View File
@@ -1,120 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
+2 -2
View File
@@ -7,8 +7,8 @@ namespace Results.Forms
{
public class WaterMeterEventArgs : EventArgs
{
public int WMPosition;
public Results.Entities.WaterMeter WM;
public WaterMeterEventArgs(int wmPosition) { WMPosition = wmPosition; }
public WaterMeterEventArgs(Results.Entities.WaterMeter wm) { WM = wm; }
}
}
@@ -155,7 +155,7 @@ namespace Results.Output.Printers.OnePerMeter
if ((cfg.GraphHgh != 0) && (cfg.GraphWid != 0))
{
Rectangle pos = new Rectangle(cfg.GraphLeft, cfg.GraphTop, cfg.GraphWid, cfg.GraphHgh);
WMChart.GetChart(wm, true).Printing.PrintPaint(e.Graphics, pos);
WMChart.GetChart(wm).Printing.PrintPaint(e.Graphics, pos);
}
float tableTop = cfg.TopMargin;
+4 -6
View File
@@ -12,12 +12,12 @@ namespace Results.Output
{
public class WMChart
{
public static Chart GetChart(WaterMeter wm, bool isPrinter)
public static Chart GetChart(WaterMeter wm)
{
return GetChart(wm, isPrinter, Config.Unit.lph, false);
return GetChart(wm, Config.Unit.lph, false);
}
public static Chart GetChart(WaterMeter wm, bool isPrinter, Config.Unit flowUnit, bool isQ4)
public static Chart GetChart(WaterMeter wm, Config.Unit flowUnit, bool isQ4)
{
IList<PointF> unsortedPoints = new List<PointF>();
foreach (var mtr in wm.MeterTestRslts)
@@ -97,9 +97,7 @@ namespace Results.Output
Series line = new Series { Name = Strings.Relative_error, ChartArea = "ChartArea1", ChartType = SeriesChartType.Line, Color = Color.DeepSkyBlue };
Series dots = new Series { Name = Strings.Relative_error + " ", ChartArea = "ChartArea1", ChartType = SeriesChartType.Point, Color = Color.RoyalBlue };
dots.MarkerStyle = MarkerStyle.Circle;
if (isPrinter) dots.MarkerSize = 1;
foreach (var point in sortedPoints)
foreach (var point in sortedPoints)
{
line.Points.AddXY(point.X, point.Y);
dots.Points.AddXY(point.X, point.Y);
+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.18.1290.0")]
[assembly: AssemblyFileVersion("2.18.1290.0")]
[assembly: AssemblyVersion("2.18.1254.0")]
[assembly: AssemblyFileVersion("2.18.1254.0")]
-9
View File
@@ -1230,15 +1230,6 @@ namespace Results.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to This position is disabled.
/// </summary>
internal static string This_position_is_disabled {
get {
return ResourceManager.GetString("This_position_is_disabled", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to to.
/// </summary>
-3
View File
@@ -333,7 +333,4 @@
<data name="Flow" xml:space="preserve">
<value>Průtok</value>
</data>
<data name="This_position_is_disabled" xml:space="preserve">
<value>Taro pozice je vypnuta</value>
</data>
</root>
-3
View File
@@ -816,7 +816,4 @@
<data name="Relative_error" xml:space="preserve">
<value>Relative error</value>
</data>
<data name="This_position_is_disabled" xml:space="preserve">
<value>This position is disabled</value>
</data>
</root>
+7 -17
View File
@@ -18,7 +18,7 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG;TURA_IPERL;IPERL;ORACLE_DB;LANG_SK</DefineConstants>
<DefineConstants>TRACE;DEBUG;PUCHONG_200</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
@@ -27,7 +27,7 @@
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE;TURA_IPERL;IPERL;ORACLE_DB;LANG_SK</DefineConstants>
<DefineConstants>TRACE;PUCHONG_200</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
@@ -75,7 +75,6 @@
<Compile Include="Forms\BatchResultsDlg.Designer.cs">
<DependentUpon>BatchResultsDlg.cs</DependentUpon>
</Compile>
<Compile Include="Forms\IOneWMResultsCtrl.cs" />
<Compile Include="Forms\ListViewEx.cs">
<SubType>Component</SubType>
</Compile>
@@ -88,17 +87,11 @@
<Compile Include="Forms\MoreWMResultsDlg.Designer.cs">
<DependentUpon>MoreWMResultsDlg.cs</DependentUpon>
</Compile>
<Compile Include="Forms\OneWMResultsColumnsCtrl.cs">
<Compile Include="Forms\OneWMResultsCtrl.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Forms\OneWMResultsColumnsCtrl.designer.cs">
<DependentUpon>OneWMResultsColumnsCtrl.cs</DependentUpon>
</Compile>
<Compile Include="Forms\OneWMResultsRowsCtrl.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Forms\OneWMResultsRowsCtrl.Designer.cs">
<DependentUpon>OneWMResultsRowsCtrl.cs</DependentUpon>
<Compile Include="Forms\OneWMResultsCtrl.Designer.cs">
<DependentUpon>OneWMResultsCtrl.cs</DependentUpon>
</Compile>
<Compile Include="Forms\ResultsConfigCtrl.cs">
<SubType>UserControl</SubType>
@@ -194,11 +187,8 @@
<EmbeddedResource Include="Forms\MoreWMResultsDlg.resx">
<DependentUpon>MoreWMResultsDlg.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\OneWMResultsColumnsCtrl.resx">
<DependentUpon>OneWMResultsColumnsCtrl.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\OneWMResultsRowsCtrl.resx">
<DependentUpon>OneWMResultsRowsCtrl.cs</DependentUpon>
<EmbeddedResource Include="Forms\OneWMResultsCtrl.resx">
<DependentUpon>OneWMResultsCtrl.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\ResultsConfigCtrl.resx">
<DependentUpon>ResultsConfigCtrl.cs</DependentUpon>
+1 -5
View File
@@ -27,9 +27,7 @@ namespace Results
case 7: return 29; /// PT7, special
case 8: return 36; /// WR13
case 9: return 37; /// WR15
case 10: return 38; /// WR14
case 11: return 39; /// WR18
case 12: return 40; /// WR19
case 10: return 38; /// WR16
default: return 0;
}
}
@@ -45,8 +43,6 @@ namespace Results
case 8: return "WR13";
case 9: return "WR15";
case 10: return "WR14";
case 11: return "WR18";
case 12: return "WR19";
default: return string.Empty;
}
}
+1 -1
View File
@@ -109,7 +109,7 @@ namespace ResultsBrowser
public LocalSettings()
{
#if TURA_IPERL || TURA_IPERL_NEW || TURA_SPECIAL
#if TURA_IPERL || TURA_SPECIAL
Bench1 = "WR10";
Bench2 = "WR11";
Bench3 = "WR13";
+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.18.1273.0")]
[assembly: AssemblyFileVersion("2.18.1273.0")]
[assembly: AssemblyVersion("2.18.1243.0")]
[assembly: AssemblyFileVersion("2.18.1243.0")]
+2 -2
View File
@@ -21,7 +21,7 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG;TURA_IPERL;IPERL;ORACLE_DB;LANG_SK</DefineConstants>
<DefineConstants>TRACE;DEBUG;PUCHONG_200</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
@@ -31,7 +31,7 @@
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE;TURA_IPERL;IPERL;ORACLE_DB;LANG_SK</DefineConstants>
<DefineConstants>TRACE;PUCHONG_200</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
-24
View File
@@ -48,10 +48,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GemCard", "GemCard\GemCard.
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Statistics", "Statistics\Statistics.csproj", "{36755E1D-6FC3-4D9C-8DD3-0250D51532E0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Decrypt", "Decrypt\Decrypt.csproj", "{D476ABBE-A455-4476-8A8D-3F6151217B51}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Encrypt", "Encrypt\Encrypt.csproj", "{DA9B09F3-A99D-4883-A954-537560453674}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -190,26 +186,6 @@ Global
{36755E1D-6FC3-4D9C-8DD3-0250D51532E0}.Release|Mixed Platforms.Build.0 = Release|x86
{36755E1D-6FC3-4D9C-8DD3-0250D51532E0}.Release|x86.ActiveCfg = Release|x86
{36755E1D-6FC3-4D9C-8DD3-0250D51532E0}.Release|x86.Build.0 = Release|x86
{D476ABBE-A455-4476-8A8D-3F6151217B51}.Debug|Any CPU.ActiveCfg = Debug|x86
{D476ABBE-A455-4476-8A8D-3F6151217B51}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
{D476ABBE-A455-4476-8A8D-3F6151217B51}.Debug|Mixed Platforms.Build.0 = Debug|x86
{D476ABBE-A455-4476-8A8D-3F6151217B51}.Debug|x86.ActiveCfg = Debug|x86
{D476ABBE-A455-4476-8A8D-3F6151217B51}.Debug|x86.Build.0 = Debug|x86
{D476ABBE-A455-4476-8A8D-3F6151217B51}.Release|Any CPU.ActiveCfg = Release|x86
{D476ABBE-A455-4476-8A8D-3F6151217B51}.Release|Mixed Platforms.ActiveCfg = Release|x86
{D476ABBE-A455-4476-8A8D-3F6151217B51}.Release|Mixed Platforms.Build.0 = Release|x86
{D476ABBE-A455-4476-8A8D-3F6151217B51}.Release|x86.ActiveCfg = Release|x86
{D476ABBE-A455-4476-8A8D-3F6151217B51}.Release|x86.Build.0 = Release|x86
{DA9B09F3-A99D-4883-A954-537560453674}.Debug|Any CPU.ActiveCfg = Debug|x86
{DA9B09F3-A99D-4883-A954-537560453674}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
{DA9B09F3-A99D-4883-A954-537560453674}.Debug|Mixed Platforms.Build.0 = Debug|x86
{DA9B09F3-A99D-4883-A954-537560453674}.Debug|x86.ActiveCfg = Debug|x86
{DA9B09F3-A99D-4883-A954-537560453674}.Debug|x86.Build.0 = Debug|x86
{DA9B09F3-A99D-4883-A954-537560453674}.Release|Any CPU.ActiveCfg = Release|x86
{DA9B09F3-A99D-4883-A954-537560453674}.Release|Mixed Platforms.ActiveCfg = Release|x86
{DA9B09F3-A99D-4883-A954-537560453674}.Release|Mixed Platforms.Build.0 = Release|x86
{DA9B09F3-A99D-4883-A954-537560453674}.Release|x86.ActiveCfg = Release|x86
{DA9B09F3-A99D-4883-A954-537560453674}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -71,10 +71,6 @@ namespace TBF.BenchControl.Ambient.Comet
serialPort = new SerialPort(comPortName, ambientCfg.BaudRate, ambientCfg.Parity, ambientCfg.DataBits, ambientCfg.StopBits);
serialPort.Handshake = ambientCfg.Handshake;
serialPort.Open();
if (ambientCfg.SetDtrToOne)
{
serialPort.DtrEnable = true;
}
msrmntTimeStamp = 0;
msrmntState = MsrmntState.Busy;
@@ -25,7 +25,6 @@ namespace TBF.BenchControl.Ambient.Comet
public int DataBits;
public StopBits StopBits;
public Handshake Handshake;
public bool SetDtrToOne;
/// Private parameterless constructor invoked by all other (public) constructors
AmbientCfg()
@@ -38,7 +37,6 @@ namespace TBF.BenchControl.Ambient.Comet
DataBits = 8;
StopBits = System.IO.Ports.StopBits.Two;
Handshake = System.IO.Ports.Handshake.None;
SetDtrToOne = false;
}
public AmbientCfg(IComponentFactory factory)
+173 -187
View File
@@ -31,192 +31,179 @@ namespace TBF.BenchControl.Ambient.Comet
/// </summary>
private void InitializeComponent()
{
this.comPortNrTextBox = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.baudRateLabel = new System.Windows.Forms.Label();
this.baudRateTextBox = new System.Windows.Forms.TextBox();
this.partityLabel = new System.Windows.Forms.Label();
this.dataBitsLabel = new System.Windows.Forms.Label();
this.dataBitsTextBox = new System.Windows.Forms.TextBox();
this.stopBitsLabel = new System.Windows.Forms.Label();
this.handshakeLabel = new System.Windows.Forms.Label();
this.nameTextBox = new System.Windows.Forms.TextBox();
this.nameLabel = new System.Windows.Forms.Label();
this.classNameLabel = new System.Windows.Forms.Label();
this.parityComboBox = new System.Windows.Forms.ComboBox();
this.stopBitsComboBox = new System.Windows.Forms.ComboBox();
this.handshakeComboBox = new System.Windows.Forms.ComboBox();
this.setDtrCheckBox = new System.Windows.Forms.CheckBox();
this.SuspendLayout();
//
// comPortNrTextBox
//
this.comPortNrTextBox.Enabled = false;
this.comPortNrTextBox.Location = new System.Drawing.Point(140, 52);
this.comPortNrTextBox.Name = "comPortNrTextBox";
this.comPortNrTextBox.Size = new System.Drawing.Size(34, 20);
this.comPortNrTextBox.TabIndex = 4;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(29, 55);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(98, 13);
this.label1.TabIndex = 3;
this.label1.Text = "Serial Port Number:";
//
// baudRateLabel
//
this.baudRateLabel.AutoSize = true;
this.baudRateLabel.Location = new System.Drawing.Point(29, 79);
this.baudRateLabel.Name = "baudRateLabel";
this.baudRateLabel.Size = new System.Drawing.Size(58, 13);
this.baudRateLabel.TabIndex = 5;
this.baudRateLabel.Text = "Baud Rate";
//
// baudRateTextBox
//
this.baudRateTextBox.Enabled = false;
this.baudRateTextBox.Location = new System.Drawing.Point(140, 76);
this.baudRateTextBox.Name = "baudRateTextBox";
this.baudRateTextBox.Size = new System.Drawing.Size(130, 20);
this.baudRateTextBox.TabIndex = 6;
//
// partityLabel
//
this.partityLabel.AutoSize = true;
this.partityLabel.Location = new System.Drawing.Point(29, 103);
this.partityLabel.Name = "partityLabel";
this.partityLabel.Size = new System.Drawing.Size(33, 13);
this.partityLabel.TabIndex = 7;
this.partityLabel.Text = "Parity";
//
// dataBitsLabel
//
this.dataBitsLabel.AutoSize = true;
this.dataBitsLabel.Location = new System.Drawing.Point(29, 127);
this.dataBitsLabel.Name = "dataBitsLabel";
this.dataBitsLabel.Size = new System.Drawing.Size(50, 13);
this.dataBitsLabel.TabIndex = 9;
this.dataBitsLabel.Text = "Data Bits";
//
// dataBitsTextBox
//
this.dataBitsTextBox.Enabled = false;
this.dataBitsTextBox.Location = new System.Drawing.Point(140, 124);
this.dataBitsTextBox.Name = "dataBitsTextBox";
this.dataBitsTextBox.Size = new System.Drawing.Size(34, 20);
this.dataBitsTextBox.TabIndex = 10;
//
// stopBitsLabel
//
this.stopBitsLabel.AutoSize = true;
this.stopBitsLabel.Location = new System.Drawing.Point(29, 151);
this.stopBitsLabel.Name = "stopBitsLabel";
this.stopBitsLabel.Size = new System.Drawing.Size(49, 13);
this.stopBitsLabel.TabIndex = 11;
this.stopBitsLabel.Text = "Stop Bits";
//
// handshakeLabel
//
this.handshakeLabel.AutoSize = true;
this.handshakeLabel.Location = new System.Drawing.Point(29, 175);
this.handshakeLabel.Name = "handshakeLabel";
this.handshakeLabel.Size = new System.Drawing.Size(62, 13);
this.handshakeLabel.TabIndex = 13;
this.handshakeLabel.Text = "Handshake";
//
// nameTextBox
//
this.nameTextBox.Enabled = false;
this.nameTextBox.Location = new System.Drawing.Point(140, 28);
this.nameTextBox.Name = "nameTextBox";
this.nameTextBox.Size = new System.Drawing.Size(130, 20);
this.nameTextBox.TabIndex = 2;
//
// nameLabel
//
this.nameLabel.AutoSize = true;
this.nameLabel.Location = new System.Drawing.Point(30, 31);
this.nameLabel.Name = "nameLabel";
this.nameLabel.Size = new System.Drawing.Size(35, 13);
this.nameLabel.TabIndex = 1;
this.nameLabel.Text = "Name";
//
// classNameLabel
//
this.classNameLabel.AutoSize = true;
this.classNameLabel.Location = new System.Drawing.Point(137, 7);
this.classNameLabel.Name = "classNameLabel";
this.classNameLabel.Size = new System.Drawing.Size(83, 13);
this.classNameLabel.TabIndex = 0;
this.classNameLabel.Text = "ComonentName";
//
// parityComboBox
//
this.parityComboBox.Enabled = false;
this.parityComboBox.FormattingEnabled = true;
this.parityComboBox.Location = new System.Drawing.Point(140, 100);
this.parityComboBox.Name = "parityComboBox";
this.parityComboBox.Size = new System.Drawing.Size(130, 21);
this.parityComboBox.TabIndex = 8;
//
// stopBitsComboBox
//
this.stopBitsComboBox.Enabled = false;
this.stopBitsComboBox.FormattingEnabled = true;
this.stopBitsComboBox.Location = new System.Drawing.Point(140, 148);
this.stopBitsComboBox.Name = "stopBitsComboBox";
this.stopBitsComboBox.Size = new System.Drawing.Size(130, 21);
this.stopBitsComboBox.TabIndex = 12;
//
// handshakeComboBox
//
this.handshakeComboBox.Enabled = false;
this.handshakeComboBox.FormattingEnabled = true;
this.handshakeComboBox.Location = new System.Drawing.Point(140, 172);
this.handshakeComboBox.Name = "handshakeComboBox";
this.handshakeComboBox.Size = new System.Drawing.Size(130, 21);
this.handshakeComboBox.TabIndex = 14;
//
// setDtrCheckBox
//
this.setDtrCheckBox.AutoSize = true;
this.setDtrCheckBox.Enabled = false;
this.setDtrCheckBox.Location = new System.Drawing.Point(140, 201);
this.setDtrCheckBox.Name = "setDtrCheckBox";
this.setDtrCheckBox.Size = new System.Drawing.Size(89, 17);
this.setDtrCheckBox.TabIndex = 15;
this.setDtrCheckBox.Text = "Set DTR to 1";
this.setDtrCheckBox.UseVisualStyleBackColor = true;
//
// AmbientCfgCtrl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.SystemColors.Control;
this.Controls.Add(this.setDtrCheckBox);
this.Controls.Add(this.handshakeComboBox);
this.Controls.Add(this.stopBitsComboBox);
this.Controls.Add(this.parityComboBox);
this.Controls.Add(this.nameTextBox);
this.Controls.Add(this.nameLabel);
this.Controls.Add(this.classNameLabel);
this.Controls.Add(this.handshakeLabel);
this.Controls.Add(this.stopBitsLabel);
this.Controls.Add(this.dataBitsTextBox);
this.Controls.Add(this.dataBitsLabel);
this.Controls.Add(this.partityLabel);
this.Controls.Add(this.baudRateTextBox);
this.Controls.Add(this.baudRateLabel);
this.Controls.Add(this.comPortNrTextBox);
this.Controls.Add(this.label1);
this.Name = "AmbientCfgCtrl";
this.Size = new System.Drawing.Size(300, 240);
this.Load += new System.EventHandler(this.AbbientCfgCtrl_Load);
this.ResumeLayout(false);
this.PerformLayout();
this.comPortNrTextBox = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.baudRateLabel = new System.Windows.Forms.Label();
this.baudRateTextBox = new System.Windows.Forms.TextBox();
this.partityLabel = new System.Windows.Forms.Label();
this.dataBitsLabel = new System.Windows.Forms.Label();
this.dataBitsTextBox = new System.Windows.Forms.TextBox();
this.stopBitsLabel = new System.Windows.Forms.Label();
this.handshakeLabel = new System.Windows.Forms.Label();
this.nameTextBox = new System.Windows.Forms.TextBox();
this.nameLabel = new System.Windows.Forms.Label();
this.classNameLabel = new System.Windows.Forms.Label();
this.parityComboBox = new System.Windows.Forms.ComboBox();
this.stopBitsComboBox = new System.Windows.Forms.ComboBox();
this.handshakeComboBox = new System.Windows.Forms.ComboBox();
this.SuspendLayout();
//
// comPortNrTextBox
//
this.comPortNrTextBox.Enabled = false;
this.comPortNrTextBox.Location = new System.Drawing.Point(140, 52);
this.comPortNrTextBox.Name = "comPortNrTextBox";
this.comPortNrTextBox.Size = new System.Drawing.Size(34, 20);
this.comPortNrTextBox.TabIndex = 4;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(29, 55);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(98, 13);
this.label1.TabIndex = 3;
this.label1.Text = "Serial Port Number:";
//
// baudRateLabel
//
this.baudRateLabel.AutoSize = true;
this.baudRateLabel.Location = new System.Drawing.Point(29, 79);
this.baudRateLabel.Name = "baudRateLabel";
this.baudRateLabel.Size = new System.Drawing.Size(58, 13);
this.baudRateLabel.TabIndex = 5;
this.baudRateLabel.Text = "Baud Rate";
//
// baudRateTextBox
//
this.baudRateTextBox.Enabled = false;
this.baudRateTextBox.Location = new System.Drawing.Point(140, 76);
this.baudRateTextBox.Name = "baudRateTextBox";
this.baudRateTextBox.Size = new System.Drawing.Size(130, 20);
this.baudRateTextBox.TabIndex = 6;
//
// partityLabel
//
this.partityLabel.AutoSize = true;
this.partityLabel.Location = new System.Drawing.Point(29, 103);
this.partityLabel.Name = "partityLabel";
this.partityLabel.Size = new System.Drawing.Size(33, 13);
this.partityLabel.TabIndex = 7;
this.partityLabel.Text = "Parity";
//
// dataBitsLabel
//
this.dataBitsLabel.AutoSize = true;
this.dataBitsLabel.Location = new System.Drawing.Point(29, 127);
this.dataBitsLabel.Name = "dataBitsLabel";
this.dataBitsLabel.Size = new System.Drawing.Size(50, 13);
this.dataBitsLabel.TabIndex = 9;
this.dataBitsLabel.Text = "Data Bits";
//
// dataBitsTextBox
//
this.dataBitsTextBox.Enabled = false;
this.dataBitsTextBox.Location = new System.Drawing.Point(140, 124);
this.dataBitsTextBox.Name = "dataBitsTextBox";
this.dataBitsTextBox.Size = new System.Drawing.Size(34, 20);
this.dataBitsTextBox.TabIndex = 10;
//
// stopBitsLabel
//
this.stopBitsLabel.AutoSize = true;
this.stopBitsLabel.Location = new System.Drawing.Point(29, 151);
this.stopBitsLabel.Name = "stopBitsLabel";
this.stopBitsLabel.Size = new System.Drawing.Size(49, 13);
this.stopBitsLabel.TabIndex = 11;
this.stopBitsLabel.Text = "Stop Bits";
//
// handshakeLabel
//
this.handshakeLabel.AutoSize = true;
this.handshakeLabel.Location = new System.Drawing.Point(29, 175);
this.handshakeLabel.Name = "handshakeLabel";
this.handshakeLabel.Size = new System.Drawing.Size(62, 13);
this.handshakeLabel.TabIndex = 13;
this.handshakeLabel.Text = "Handshake";
//
// nameTextBox
//
this.nameTextBox.Enabled = false;
this.nameTextBox.Location = new System.Drawing.Point(140, 28);
this.nameTextBox.Name = "nameTextBox";
this.nameTextBox.Size = new System.Drawing.Size(130, 20);
this.nameTextBox.TabIndex = 2;
//
// nameLabel
//
this.nameLabel.AutoSize = true;
this.nameLabel.Location = new System.Drawing.Point(30, 31);
this.nameLabel.Name = "nameLabel";
this.nameLabel.Size = new System.Drawing.Size(35, 13);
this.nameLabel.TabIndex = 1;
this.nameLabel.Text = "Name";
//
// classNameLabel
//
this.classNameLabel.AutoSize = true;
this.classNameLabel.Location = new System.Drawing.Point(137, 7);
this.classNameLabel.Name = "classNameLabel";
this.classNameLabel.Size = new System.Drawing.Size(83, 13);
this.classNameLabel.TabIndex = 0;
this.classNameLabel.Text = "ComonentName";
//
// parityComboBox
//
this.parityComboBox.Enabled = false;
this.parityComboBox.FormattingEnabled = true;
this.parityComboBox.Location = new System.Drawing.Point(140, 100);
this.parityComboBox.Name = "parityComboBox";
this.parityComboBox.Size = new System.Drawing.Size(130, 21);
this.parityComboBox.TabIndex = 8;
//
// stopBitsComboBox
//
this.stopBitsComboBox.Enabled = false;
this.stopBitsComboBox.FormattingEnabled = true;
this.stopBitsComboBox.Location = new System.Drawing.Point(140, 148);
this.stopBitsComboBox.Name = "stopBitsComboBox";
this.stopBitsComboBox.Size = new System.Drawing.Size(130, 21);
this.stopBitsComboBox.TabIndex = 12;
//
// handshakeComboBox
//
this.handshakeComboBox.Enabled = false;
this.handshakeComboBox.FormattingEnabled = true;
this.handshakeComboBox.Location = new System.Drawing.Point(140, 172);
this.handshakeComboBox.Name = "handshakeComboBox";
this.handshakeComboBox.Size = new System.Drawing.Size(130, 21);
this.handshakeComboBox.TabIndex = 14;
//
// AmbientCfgCtrl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.SystemColors.Control;
this.Controls.Add(this.handshakeComboBox);
this.Controls.Add(this.stopBitsComboBox);
this.Controls.Add(this.parityComboBox);
this.Controls.Add(this.nameTextBox);
this.Controls.Add(this.nameLabel);
this.Controls.Add(this.classNameLabel);
this.Controls.Add(this.handshakeLabel);
this.Controls.Add(this.stopBitsLabel);
this.Controls.Add(this.dataBitsTextBox);
this.Controls.Add(this.dataBitsLabel);
this.Controls.Add(this.partityLabel);
this.Controls.Add(this.baudRateTextBox);
this.Controls.Add(this.baudRateLabel);
this.Controls.Add(this.comPortNrTextBox);
this.Controls.Add(this.label1);
this.Name = "AmbientCfgCtrl";
this.Size = new System.Drawing.Size(300, 240);
this.Load += new System.EventHandler(this.AbbientCfgCtrl_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
@@ -237,7 +224,6 @@ namespace TBF.BenchControl.Ambient.Comet
private System.Windows.Forms.ComboBox parityComboBox;
private System.Windows.Forms.ComboBox stopBitsComboBox;
private System.Windows.Forms.ComboBox handshakeComboBox;
private System.Windows.Forms.CheckBox setDtrCheckBox;
}
}
@@ -110,7 +110,6 @@ namespace TBF.BenchControl.Ambient.Comet
dataBitsTextBox.Text = config.DataBits.ToString();
stopBitsComboBox.Text = config.StopBits.ToString();
handshakeComboBox.Text = config.Handshake.ToString();
setDtrCheckBox.Checked = config.SetDtrToOne;
}
public void Unlock()
@@ -122,7 +121,6 @@ namespace TBF.BenchControl.Ambient.Comet
dataBitsTextBox.Enabled = true;
stopBitsComboBox.Enabled = true;
handshakeComboBox.Enabled = true;
setDtrCheckBox.Enabled = true;
}
public CfgUpdateFlags UpdateCfg()
@@ -138,7 +136,6 @@ namespace TBF.BenchControl.Ambient.Comet
config.DataBits = int.Parse(dataBitsTextBox.Text);
config.StopBits = GetStopBits(stopBitsComboBox.SelectedItem.ToString());
config.Handshake = GetHandshake(handshakeComboBox.SelectedItem.ToString());
config.SetDtrToOne = setDtrCheckBox.Checked;
return flags;
}
+1 -5
View File
@@ -20,11 +20,7 @@ namespace TBF.BenchControl
public int ItemNr { get { return cfg.ItemNr; } }
public DebugMode DebugLevel { get { return cfg.DebugLevel; } set { cfg.DebugLevel = value; } }
public LogLevel LogLevel { get { return cfg.LogLevel; } }
public IList<MeasurementCorrection> Corrections
{
get { return cfg.Corrections; }
set { cfg.Corrections = value; }
}
public IList<MeasurementCorrection> Corrections { get { return cfg.Corrections; } }
/// Constructor, components created in this way is used by
+1 -1
View File
@@ -19,7 +19,7 @@ namespace TBF.BenchControl.Elde
EnduranceCycleStop = 13,
}
#if FUZHOU_300 || IZRAEL_200 || TORINO_50 || BADGER_MALA_TRAT || BADGER_STREDNA_TRAT || TURA_IPERL || TURA_IPERL_NEW || TURA_SPECIAL || BADGER_VELKA_TRAT || PUCHONG_200 || SLM_50 || GENESIS || MALTA_WSD25 || SLM_END || WARSAW_END || BERLIN || SLM_150 || PETERSBURG_50 || PETERSBURG_200 || DEWA_300 || KEMPNO_50 || BAHRAIN_50 || RUM_MOB || KRAKOW_50 || JUZNA_AFRIKA_50 || IZRAEL_25 || ZAMBIA || ZODINO || FEWA_50 || FILIPINY_50 || SENTEC || FUZHOU_100 || CEVAK_200 || IZRAEL_50
#if FUZHOU_300 || IZRAEL_200 || TORINO_50 || BADGER_MALA_TRAT || BADGER_STREDNA_TRAT || TURA_IPERL || TURA_SPECIAL || BADGER_VELKA_TRAT || PUCHONG_200 || SLM_50 || GENESIS || MALTA_WSD25 || SLM_END || WARSAW_END || BERLIN || SLM_150 || PETERSBURG_50 || PETERSBURG_200 || DEWA_300 || KEMPNO_50 || BAHRAIN_50 || RUM_MOB || KRAKOW_50 || JUZNA_AFRIKA_50 || IZRAEL_25 || ZAMBIA || ZODINO || FEWA_50 || SENTEC || FUZHOU_100 || CEVAK_200 || IZRAEL_50
public enum StatusP : ulong
{
RefFlowMeterMask = 0x7, /// bits 0,1,2
+1 -1
View File
@@ -150,7 +150,7 @@ namespace TBF.BenchControl.Elde
{100,500}, {100,500}, {100,500}, {100,500} };
public byte[] MeretRS485Address = new byte[4];
public float[] EtCalib = new float[8] { 1, 1, 1, 1, 1, 1, 1, 1 };
#elif MUNICH || TORINO_50 || BADGER_MALA_TRAT || BADGER_STREDNA_TRAT || TORUN_50 || CEVAK_40 || TURA_IPERL || TURA_IPERL_NEW || TURA_SPECIAL || MURES_40 || FUZHOU_50 || SLM_50 || PETERSBURG_50 || KEMPNO_50 || BAHRAIN_50 || KRAKOW_50 || JUZNA_AFRIKA_50 || IZRAEL_25 || ZAMBIA || ZODINO || FEWA_50 || FILIPINY_50 || FUZHOU_100
#elif MUNICH || TORINO_50 || BADGER_MALA_TRAT || BADGER_STREDNA_TRAT || TORUN_50 || CEVAK_40 || TURA_IPERL || TURA_SPECIAL || MURES_40 || FUZHOU_50 || SLM_50 || PETERSBURG_50 || KEMPNO_50 || BAHRAIN_50 || KRAKOW_50 || JUZNA_AFRIKA_50 || IZRAEL_25 || ZAMBIA || ZODINO || FEWA_50 || FUZHOU_100
public uint[,] RegValveCalib = new uint[8,2] {{100,500},{100,500},{100,500},{100,500},{100,500},{100,500},{100,500},{100,500}};
public byte[] MeretRS485Address = new byte[4];
public float[] EtCalib = new float[5] { 1, 1, 1, 1, 1 };
+4 -4
View File
@@ -71,7 +71,7 @@ namespace TBF.BenchControl.Elde
public UInt128 RRoute { get { return ctrlBrdComponent.rRoute; } }
#endif
#if GENESIS || KEMPNO_50 || KRAKOW_50 || BAHRAIN_50 || BADGER_STREDNA_TRAT || JUZNA_AFRIKA_50 || IZRAEL_25 || ZAMBIA || ZODINO || FEWA_50 || FILIPINY_50 || SENTEC || FUZHOU_100 || CEVAK_200 || IZRAEL_50 || DEWA_300 || PUCHONG_200 || TURA_IPERL_NEW
#if GENESIS || KEMPNO_50 || KRAKOW_50 || BAHRAIN_50 || BADGER_STREDNA_TRAT || JUZNA_AFRIKA_50 || IZRAEL_25 || ZAMBIA || ZODINO || FEWA_50 || SENTEC || FUZHOU_100 || CEVAK_200 || IZRAEL_50 || DEWA_300 || PUCHONG_200
public uint DivTime(int id) { return ctrlBrdComponent.divTime[id]; }
public void SetDivLimit(int divNo, uint limLoPct, uint limHiPct)
{
@@ -131,7 +131,7 @@ namespace TBF.BenchControl.Elde
public uint[] WMeterCont { get { return new uint[3]; } } /// Dummy
#endif
#if KEMPNO_50 || KRAKOW_50 || JUZNA_AFRIKA_50 || IZRAEL_25 || ZAMBIA || ZODINO || FEWA_50 || FILIPINY_50 || FUZHOU_100 || CEVAK_200 || IZRAEL_50
#if KEMPNO_50 || KRAKOW_50 || JUZNA_AFRIKA_50 || IZRAEL_25 || ZAMBIA || ZODINO || FEWA_50 || FUZHOU_100 || CEVAK_200 || IZRAEL_50
public float ValveOpenCloseTime { get { return ctrlBrdComponent.ValveMoveTime[0]; } }
#else
public float ValveOpenCloseTime { get { return 0.001f; } }
@@ -401,11 +401,11 @@ namespace TBF.BenchControl.Elde
uint[] pulsesArr = new uint[] { (uint)totalRefPulses, (uint)massRefPulses };
ctrlBrdComponent.SendCommand((uint)cmd, (byte)refFlowMeterNr, (ulong)(route & (UInt128)0xFFFFFFFFFFFFFFFF), (ulong)(route >> 64), pulsesArr, (uint)testMethods,
filterConstants, fmFreq, (uint)regConst, (uint)shortImp, (uint)stopDevs);
#elif JUZNA_AFRIKA_50 || IZRAEL_25 || ZAMBIA || ZODINO || FEWA_50 || FILIPINY_50 || SENTEC || FUZHOU_100 || CEVAK_200 || IZRAEL_50
#elif JUZNA_AFRIKA_50 || IZRAEL_25 || ZAMBIA || ZODINO || FEWA_50 || SENTEC || FUZHOU_100 || CEVAK_200 || IZRAEL_50
uint[] pulsesArr = new uint[] { (uint)totalRefPulses, (uint)massRefPulses };
ctrlBrdComponent.SendCommand((uint)cmd, (byte)refFlowMeterNr, (ulong)route, pulsesArr, (uint)testMethods,
filterConstants, fmFreq, (uint)regConst, (uint)shortImp, (uint)stopDevs);
#else /// if TURA_IPERL || TURA_IPERL_NEW || TURA_SPECIAL || MALTA_WSD25 || SLM_50 || SLM_END || WARSAW_END || PETERSBURG_50 || KEMPNO_50 || BAHRAIN_50 || RUM_MOB || KRAKOW_50 || BADGER_STREDNA_TRAT || PUCHONG_200
#else /// if TURA_IPERL || TURA_SPECIAL || MALTA_WSD25 || SLM_50 || SLM_END || WARSAW_END || PETERSBURG_50 || KEMPNO_50 || BAHRAIN_50 || RUM_MOB || KRAKOW_50 || BADGER_STREDNA_TRAT || PUCHONG_200
uint[] pulsesArr = new uint[] { (uint)totalRefPulses, (uint)massRefPulses };
ctrlBrdComponent.SendCommand((uint)cmd, (byte)refFlowMeterNr, (ulong)route, pulsesArr, (uint)testMethods,
Convert.ToSingle(filterConstants[0]), fmFreq, (uint)regConst, (uint)shortImp, (uint)stopDevs);
+1 -3
View File
@@ -119,10 +119,8 @@ namespace TBF.BenchControl.Elde.Diverter
flowMtrNr4Cmd = (divNrFromName == 4) ? 5 : divNrFromName;
#elif DEWA_300 || PUCHONG_200
flowMtrNr4Cmd = divNrFromName + 2; /// Div1: 1,2,3, Div2: 4, Div3: 5, Div4: 6, Div5: 7
#elif TURA_IPERL || TURA_IPERL_NEW
#elif TURA_IPERL
flowMtrNr4Cmd = divNrFromName + 16 * divNrFromName;
#elif FILIPINY_50
flowMtrNr4Cmd = (divNrFromName == 1) ? 1 : 7;
#else
flowMtrNr4Cmd = (divNrFromName == 1) ? 1 : 3;
#endif
+1 -24
View File
@@ -1,7 +1,6 @@
///
/// Copyright (c) 2013-2016 Sensus Metering Systems
///
using System;
using System.IO;
using System.Collections.Generic;
using System.Xml.Serialization;
@@ -9,7 +8,7 @@ using TBF.BenchControl.Generic;
namespace TBF.BenchControl.Elde.Diverter
{
public class DiverterCfg : ComponentCfgBase, IChildComponentCfg, GenericDevices.ICalibInfoCfg
public class DiverterCfg : ComponentCfgBase, IChildComponentCfg
{
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(DiverterCfg) })[0];
public override XmlSerializer GetSerializer() { return Serializer; }
@@ -27,27 +26,6 @@ namespace TBF.BenchControl.Elde.Diverter
public int ThresholdLo; /// 0..100 in %, threshold for low level when diverter transition time is measured
public int ThresholdHi; /// 0..100 in %, threshold for high level when diverter transition time is measured
/// Calibration info serialized parameters displayed in Metrology tab page
string calibCertificateNr;
DateTime calibDate;
DateTime calibValidDate;
public string CalibCertificateNr
{
get { return calibCertificateNr; }
set { calibCertificateNr = value; }
}
public DateTime CalibDate
{
get { return calibDate; }
set { calibDate = value; }
}
public DateTime CalibValidDate
{
get { return calibValidDate; }
set { calibValidDate = value; }
}
/// Private parameterless constructor invoked by all other (public) constructors
DiverterCfg()
{
@@ -60,7 +38,6 @@ namespace TBF.BenchControl.Elde.Diverter
StartingLevel = 50;
ThresholdLo = 10;
ThresholdHi = 90;
calibCertificateNr = string.Empty;
}
public DiverterCfg(IComponentFactory factory)
+1 -3
View File
@@ -113,12 +113,10 @@ namespace TBF.BenchControl.Elde
void SendStartCommand()
{
controlBoard.SyncRoute();
#if TURA_IPERL || TURA_IPERL_NEW || TURA_SPECIAL || BADGER_VELKA_TRAT || SLM_50
#if TURA_IPERL || TURA_SPECIAL || BADGER_VELKA_TRAT || SLM_50
int flowMeterIdxAndDiv = flowMeterNr + 16 * diverterNr;
#elif BADGER_STREDNA_TRAT
int flowMeterIdxAndDiv = flowMeterNr + 8 * (diverterNr - 1);
#elif FILIPINY_50
int flowMeterIdxAndDiv = flowMeterNr + ((flowMeterNr == 3) ? (4 * (diverterNr - 1)) : 0);
#else
int flowMeterIdxAndDiv = flowMeterNr;
#endif
-4
View File
@@ -1,8 +1,6 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
///
using System.Collections.Generic;
namespace TBF.BenchControl.Generic
{
public interface IComponent
@@ -19,8 +17,6 @@ namespace TBF.BenchControl.Generic
IComponentCfg Cfg { get; }
IList<Config.Entities.MeasurementCorrection> Corrections { get; set; }
void StartChangeHandler();
void StopChangeHandler();
@@ -5,7 +5,7 @@ using System.Net.NetworkInformation;
using System.Text;
using System.Web;
namespace TBF.BenchControl.Network
namespace TBF.BenchControl.Network.Adapter
{
/// <summary>
/// Class for the storing information about a network adapter.
@@ -22,32 +22,23 @@ namespace TBF.BenchControl.Network
Description = description;
}
/// Member function
public IPAddress GetBroadcastAddress()
{
return AdapterInfo.GetBroadcastAddress(IPAddress, NetMask);
byte[] ipAdressBytes = IPAddress.GetAddressBytes();
byte[] subnetMaskBytes = NetMask.GetAddressBytes();
if (ipAdressBytes.Length != subnetMaskBytes.Length)
throw new ArgumentException("Lengths of IP address and subnet mask do not match.");
byte[] broadcastAddress = new byte[ipAdressBytes.Length];
for (int i = 0; i < broadcastAddress.Length; i++)
{
broadcastAddress[i] = (byte)(ipAdressBytes[i] | (subnetMaskBytes[i] ^ 255));
}
return new IPAddress(broadcastAddress);
}
/// Static function
static public IPAddress GetBroadcastAddress(IPAddress ipAddress, IPAddress netMask)
{
byte[] ipAdressBytes = ipAddress.GetAddressBytes();
byte[] subnetMaskBytes = netMask.GetAddressBytes();
if (ipAdressBytes.Length != subnetMaskBytes.Length)
{
throw new ArgumentException("Lengths of IP address and subnet mask do not match.");
}
byte[] broadcastAddress = new byte[ipAdressBytes.Length];
for (int i = 0; i < broadcastAddress.Length; i++)
{
broadcastAddress[i] = (byte)(ipAdressBytes[i] | (subnetMaskBytes[i] ^ 255));
}
return new IPAddress(broadcastAddress);
}
///------------------------------------------------------
/// Static members and functions
///------------------------------------------------------
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2019 Sensus Slovensko a.s.
/// Copyright (c) 2013-2016 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
@@ -15,13 +15,6 @@ namespace TBF.BenchControl.Operations
SequenceBase sequenceBase;
bool heatMeters;
/// Constructor: No heat meters
public ProcessDataLoggingOp(ILog logger, SequenceBase sequenceBase)
: this (logger, sequenceBase, false)
{
}
/// Constructor: Heat meters are optional
public ProcessDataLoggingOp(ILog logger, SequenceBase sequenceBase, bool heatMeters)
{
this.logger = logger;
@@ -19,7 +19,6 @@ namespace TBF.BenchControl.Output.DB.ProductionTracing
public string Workplace;
public string ConnStr;
public string NetAdapter;
public bool CheckPreviousRecords;
public bool SaveTracingRecords;
@@ -29,7 +28,6 @@ namespace TBF.BenchControl.Output.DB.ProductionTracing
{
ParentName = string.Empty;
Workplace = "WR10";
NetAdapter = string.Empty;
ConnStr = "SERVER=10.42.128.16; DATABASE=sledovanie2019; UID=vyroba2019; PASSWORD=qwerty; CHARSET=utf8;";
CheckPreviousRecords = true;
SaveTracingRecords = true;
@@ -4,7 +4,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using log4net;
using NHibernate;
using NHibernate.Criterion;
@@ -37,12 +36,6 @@ namespace TBF.BenchControl.Output.DB.ProductionTracing
MonitoringCfg tracingCfg;
string workplace { get { return tracingCfg.Workplace; } }
readonly IPAddress ipAddress;
readonly IPAddress netMask;
public IPAddress IPAddress { get { return ipAddress; } }
public IPAddress NetMask { get { return netMask; } }
enum OpState
{
@@ -91,12 +84,6 @@ namespace TBF.BenchControl.Output.DB.ProductionTracing
{
tracingCfg = cfg as MonitoringCfg;
if (tracingCfg == null) throw new ArgumentException("tracingCfg");
Network.AdapterInfo.RefreshNetAdaptersInfo();
Network.AdapterInfo netadapter = Network.AdapterInfo.GetNetAdapter(tracingCfg.NetAdapter);
ipAddress = netadapter.IPAddress;
netMask = netadapter.NetMask;
currentOpState = OpState.None;
log.Debug(this.ToString());
}
@@ -108,8 +95,6 @@ namespace TBF.BenchControl.Output.DB.ProductionTracing
{
if (tracingCfg.DebugLevel == DebugMode.Simulate) return;
string ipAddress = GetIPAddress();
///
/// Session factory is used to create database sessions
///
@@ -123,16 +108,13 @@ namespace TBF.BenchControl.Output.DB.ProductionTracing
///
ISession session = sessionFactory.OpenSession();
#if !DEBUG
/// Only release version registers a workplace
TracingDB.DB.RegisterWorkplace(session,
workplace,
Users.GlobalData.GetCurrentUserName(),
GetIPAddress(),
"1.2.3.4",
"<multiple>",
WorkstepName,
DateTime.Now + new TimeSpan(15, 0, 0, 0));
#endif
session.Flush();
session.Close();
TracingDB.DB.SessionFactory = sessionFactory;
@@ -141,11 +123,6 @@ namespace TBF.BenchControl.Output.DB.ProductionTracing
currentProcess = null;
}
///
string GetIPAddress()
{
return (ipAddress != null) ? ipAddress.ToString() : "1.2.3.4";
}
///
public void RunDeviceBefore() { }
public void RunDeviceAfter() { }
///
@@ -5,8 +5,6 @@ using System;
using System.Windows.Forms;
using Config.Entities;
using TBF.BenchControl.Generic;
using System.Collections.Generic;
using System.Net;
namespace TBF.BenchControl.Output.DB.ProductionTracing
{
@@ -32,7 +30,6 @@ namespace TBF.BenchControl.Output.DB.ProductionTracing
private void WriterCfgCtrl_Load(object sender, EventArgs e)
{
if (config == null) return;
Redraw();
}
@@ -50,53 +47,6 @@ namespace TBF.BenchControl.Output.DB.ProductionTracing
connStrTextBox.Text = config.ConnStr;
checkPreviousRecordsCheckBox.Checked = config.CheckPreviousRecords;
saveTracingRecordsCheckBox.Checked = config.SaveTracingRecords;
Network.AdapterInfo.RefreshNetAdaptersInfo();
IList<Network.AdapterInfo> adapters = Network.AdapterInfo.NetAdapters;
string cfgAdapter = string.Empty;
foreach (Network.AdapterInfo ai in adapters)
{
string record;
if (ai.IPAddress == null)
{
/// This happens with network adapters that currently have no IP address,
/// for instance not connected wireless or dial-up adapters
record = "???.???.???.???";
}
else
{
/// Do not consider IPv6 adapters as well as "Any", "Broadcast", "Loopback" or "None" addresses
if ((ai.IPAddress.AddressFamily == System.Net.Sockets.AddressFamily.InterNetworkV6) ||
ai.IPAddress.Equals(IPAddress.Any) ||
ai.IPAddress.Equals(IPAddress.Broadcast) ||
ai.IPAddress.Equals(IPAddress.IPv6Any) ||
ai.IPAddress.Equals(IPAddress.IPv6Loopback) ||
ai.IPAddress.Equals(IPAddress.IPv6None) ||
ai.IPAddress.Equals(IPAddress.Loopback) ||
ai.IPAddress.Equals(IPAddress.None))
{
continue;
}
record = ai.IPAddress.ToString();
}
record += " - " + ai.Description;
int i = netAdapterComboBox.Items.Add(record);
if (ai.Description == config.NetAdapter)
{
/// Select the adapter currently in the configuration
netAdapterComboBox.SelectedIndex = i;
}
}
/// Select the first one if the adapter from the configuration does not exist on the system
if (netAdapterComboBox.SelectedIndex < 0 && netAdapterComboBox.Items.Count > 0)
{
netAdapterComboBox.SelectedIndex = 0;
}
}
public void Unlock()
@@ -104,7 +54,6 @@ namespace TBF.BenchControl.Output.DB.ProductionTracing
nameTextBox.Enabled = true;
workplaceTextBox.Enabled = true;
connStrTextBox.Enabled = true;
netAdapterComboBox.Enabled = true;
checkPreviousRecordsCheckBox.Enabled = true;
saveTracingRecordsCheckBox.Enabled = true;
}
@@ -131,16 +80,6 @@ namespace TBF.BenchControl.Output.DB.ProductionTracing
flags |= UpdateDifferent(ref config.CheckPreviousRecords, checkPreviousRecordsCheckBox.Checked, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
flags |= UpdateDifferent(ref config.SaveTracingRecords, saveTracingRecordsCheckBox.Checked, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
/// Network adapter
string strAdapter = netAdapterComboBox.Text;
int iDash = strAdapter.IndexOf(" - ");
string netAdapter = (iDash < 0) ? "" : strAdapter.Substring(iDash + 3);
if (config.NetAdapter != netAdapter)
{
config.NetAdapter = netAdapter;
flags |= (CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
}
return flags;
}
}
@@ -40,8 +40,6 @@ namespace TBF.BenchControl.Output.DB.ProductionTracing
this.connStrLabel = new System.Windows.Forms.Label();
this.saveTracingRecordsCheckBox = new System.Windows.Forms.CheckBox();
this.checkPreviousRecordsCheckBox = new System.Windows.Forms.CheckBox();
this.netAdapterLabel = new System.Windows.Forms.Label();
this.netAdapterComboBox = new System.Windows.Forms.ComboBox();
this.SuspendLayout();
//
// nameTextBox
@@ -93,7 +91,7 @@ namespace TBF.BenchControl.Output.DB.ProductionTracing
this.connStrTextBox.Location = new System.Drawing.Point(110, 93);
this.connStrTextBox.Name = "connStrTextBox";
this.connStrTextBox.Size = new System.Drawing.Size(327, 20);
this.connStrTextBox.TabIndex = 6;
this.connStrTextBox.TabIndex = 22;
//
// connStrLabel
//
@@ -101,17 +99,17 @@ namespace TBF.BenchControl.Output.DB.ProductionTracing
this.connStrLabel.Location = new System.Drawing.Point(15, 96);
this.connStrLabel.Name = "connStrLabel";
this.connStrLabel.Size = new System.Drawing.Size(89, 13);
this.connStrLabel.TabIndex = 5;
this.connStrLabel.TabIndex = 21;
this.connStrLabel.Text = "Connection string";
//
// saveTracingRecordsCheckBox
//
this.saveTracingRecordsCheckBox.AutoSize = true;
this.saveTracingRecordsCheckBox.Enabled = false;
this.saveTracingRecordsCheckBox.Location = new System.Drawing.Point(110, 177);
this.saveTracingRecordsCheckBox.Location = new System.Drawing.Point(110, 154);
this.saveTracingRecordsCheckBox.Name = "saveTracingRecordsCheckBox";
this.saveTracingRecordsCheckBox.Size = new System.Drawing.Size(177, 17);
this.saveTracingRecordsCheckBox.TabIndex = 10;
this.saveTracingRecordsCheckBox.TabIndex = 24;
this.saveTracingRecordsCheckBox.Text = "Save production tracing records";
this.saveTracingRecordsCheckBox.UseVisualStyleBackColor = true;
//
@@ -119,36 +117,17 @@ namespace TBF.BenchControl.Output.DB.ProductionTracing
//
this.checkPreviousRecordsCheckBox.AutoSize = true;
this.checkPreviousRecordsCheckBox.Enabled = false;
this.checkPreviousRecordsCheckBox.Location = new System.Drawing.Point(110, 154);
this.checkPreviousRecordsCheckBox.Location = new System.Drawing.Point(110, 131);
this.checkPreviousRecordsCheckBox.Name = "checkPreviousRecordsCheckBox";
this.checkPreviousRecordsCheckBox.Size = new System.Drawing.Size(138, 17);
this.checkPreviousRecordsCheckBox.TabIndex = 9;
this.checkPreviousRecordsCheckBox.TabIndex = 23;
this.checkPreviousRecordsCheckBox.Text = "Check previous records";
this.checkPreviousRecordsCheckBox.UseVisualStyleBackColor = true;
//
// netAdapterLabel
//
this.netAdapterLabel.AutoSize = true;
this.netAdapterLabel.Location = new System.Drawing.Point(15, 122);
this.netAdapterLabel.Name = "netAdapterLabel";
this.netAdapterLabel.Size = new System.Drawing.Size(86, 13);
this.netAdapterLabel.TabIndex = 7;
this.netAdapterLabel.Text = "Network adapter";
//
// netAdapterComboBox
//
this.netAdapterComboBox.FormattingEnabled = true;
this.netAdapterComboBox.Location = new System.Drawing.Point(110, 119);
this.netAdapterComboBox.Name = "netAdapterComboBox";
this.netAdapterComboBox.Size = new System.Drawing.Size(327, 21);
this.netAdapterComboBox.TabIndex = 11;
//
// TracingCfgCtrl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.netAdapterComboBox);
this.Controls.Add(this.netAdapterLabel);
this.Controls.Add(this.saveTracingRecordsCheckBox);
this.Controls.Add(this.checkPreviousRecordsCheckBox);
this.Controls.Add(this.connStrTextBox);
@@ -177,7 +156,5 @@ namespace TBF.BenchControl.Output.DB.ProductionTracing
private System.Windows.Forms.Label connStrLabel;
private System.Windows.Forms.CheckBox saveTracingRecordsCheckBox;
private System.Windows.Forms.CheckBox checkPreviousRecordsCheckBox;
private System.Windows.Forms.Label netAdapterLabel;
private System.Windows.Forms.ComboBox netAdapterComboBox;
}
}
@@ -1,26 +0,0 @@
///
/// Copyright (c) 2019 Sensus Slovensko a.s.
///
using System.Collections.Generic;
using TBF.BenchControl.Generic;
namespace TBF.BenchControl.Output.DB.SaveDiverterCorrections
{
public class Factory : IComponentFactory
{
public string ClassName { get { return this.GetType().Namespace.Substring(17); } }
public void ResetStaticProperties() { SaveDiverterCorr.ResetStaticProperties(); }
public IComponent DummyComponent() { return new SaveDiverterCorr(); }
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new SaveDiverterCorr(cfg); }
public IComponentCfg DefaultConfig() { return new SaveDiverterCorrCfg(this.GetType().Namespace.Substring(24), this); }
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
{
return ComponentCfgBase.CreateFromDbEntity(SaveDiverterCorrCfg.Serializer, component, this);
}
}
}
@@ -1,259 +0,0 @@
///
/// Copyright (c) 2019 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using log4net;
using NHibernate;
using NHibernate.Criterion;
using Config;
using Config.Entities;
using TracingDB.Entities;
using TBF.BenchControl.Generic;
using TBF.BenchControl.GenericDevices;
namespace TBF.BenchControl.Output.DB.SaveDiverterCorrections
{
public enum Retv
{
OK,
Error,
}
public class SaveDiverterCorr : ComponentBase, IOperation, GenericDevices.IResultsWriter
{
private static readonly ILog log = LogManager.GetLogger(typeof(SaveDiverterCorr));
public override string ToString() { return string.Format("SaveDiverterCorr({0})", Cfg.ToString(1)); }
SaveDiverterCorrCfg myCfg;
enum CurrentOp
{
None,
SaveDiverterCorrections,
}
CurrentOp currentOp;
bool opCompleted;
bool anyError;
/// <summary>
/// Results to parse for reference flowmeter corrections
/// </summary>
Results.Entities.Batch batch;
IList<MeasurementCorrection> newCorrections;
public SaveDiverterCorr() {}
public SaveDiverterCorr(Generic.IComponentCfg cfg)
: base(cfg)
{
myCfg = cfg as SaveDiverterCorrCfg;
currentOp = CurrentOp.None;
log.Debug(this.ToString());
}
/// <summary>
/// Writes the test cycle results into a file, Events: Event.ResultsWritten
/// </summary>
/// <param name="procedure">Procedure to print the results of</param>
/// <param name="unsortedResults">Results to write into the file</param>
/// <returns>Reference to the operation</returns>
public IOperation WriteResultsOp(Results.Entities.Batch batch)
{
if (currentOp != CurrentOp.None)
throw new Exception("Sequence error");
else
currentOp = CurrentOp.SaveDiverterCorrections;
this.batch = batch;
return this;
}
IList<MeasurementCorrection> CalculateCorrectionsFromResuls(Results.Entities.Batch batch, string diverterName)
{
/// Create a list of all test flows in this procedure
IList<double> targetFlows = new List<double>();
foreach (var tr in batch.TestRslts)
{
if (tr.TestDone && tr.Evaluate() &&
(tr.Name().Contains(myCfg.PatternForShortTests) || tr.Name().Contains(myCfg.PatternForLongTests)) &&
(tr.Components != null) && (tr.Components.Diverter == diverterName))
{
double trgtFlow = (tr.TestData.Qfrom + tr.TestData.Qto) / 2;
if (!targetFlows.Contains(trgtFlow)) targetFlows.Add(trgtFlow);
}
}
IList<MeasurementCorrection> rslt = new List<MeasurementCorrection>();
foreach (double trgtFlow in targetFlows)
{
IList<Results.Entities.TestRslt> shortTestRslts = new List<Results.Entities.TestRslt>();
IList<Results.Entities.TestRslt> longTestRslts = new List<Results.Entities.TestRslt>();
///
foreach (var tr in batch.TestRslts)
{
if (tr.TestDone && tr.Evaluate() && (tr.Components != null) && (tr.Components.Diverter == diverterName) &&
(trgtFlow == (tr.TestData.Qfrom + tr.TestData.Qto) / 2))
{
if (tr.Name().Contains(myCfg.PatternForShortTests)) shortTestRslts.Add(tr);
else if (tr.Name().Contains(myCfg.PatternForLongTests)) longTestRslts.Add(tr);
}
}
if (shortTestRslts.Count == 1 && longTestRslts.Count == 1)
{
Results.Entities.TestRslt shTR = shortTestRslts[0];
Results.Entities.TestRslt loTR = longTestRslts[0];
/// Calculate a correction and add it to the list
try
{
double factor = loTR.PulsesMaster / shTR.PulsesMaster * (loTR.MassEnd - loTR.MassStart) / (shTR.MassEnd - shTR.MassStart);
double correction = (factor - 1.0) * loTR.TestTime / (myCfg.ShortTestDiversionsCount - 1);
rslt.Add(new MeasurementCorrection { RangeIx = 0, Measurement = (float)trgtFlow, Correction = (float)correction });
log.InfoFormat("Calculated diverter correction at {0} m3/h: {1} s", trgtFlow, correction);
}
catch (Exception exc)
{
log.ErrorFormat("Error when calculationg diverter correction at {0} m3/h: {1}", trgtFlow, exc.Message);
}
}
}
return rslt;
}
void DeleteExistingCorrections(ISession session, Component dbCmpnt, IComponent runtimeCmpnt)
{
for (int i = dbCmpnt.Corrections.Count - 1; i >= 0; i--)
{
session.Delete(dbCmpnt.Corrections[i]);
}
dbCmpnt.Corrections = new List<MeasurementCorrection>();
runtimeCmpnt.Corrections = new List<MeasurementCorrection>();
session.SaveOrUpdate(dbCmpnt);
}
void SaveNewCorrections(ISession session, Component dbCmpnt, IComponent runtimeCmpnt, IList<MeasurementCorrection> corrections)
{
if (dbCmpnt.Corrections == null) dbCmpnt.Corrections = new List<MeasurementCorrection>();
if (runtimeCmpnt.Corrections == null) runtimeCmpnt.Corrections = new List<MeasurementCorrection>();
foreach (var mc in corrections)
{
mc.RangeIx = 0;
dbCmpnt.Corrections.Add(mc);
runtimeCmpnt.Corrections.Add(mc);
session.SaveOrUpdate(mc);
}
ICalibInfoCfg cfg = TbfComponents.CmpntCfgFromCmpntEntity(dbCmpnt) as ICalibInfoCfg;
if (cfg != null)
{
cfg.CalibCertificateNr = string.Format(myCfg.CertificateFmt, batch.StartTime, batch.EndTime, batch.BatchNr);
cfg.CalibDate = DateTime.Now;
cfg.CalibValidDate = DateTime.Now + new TimeSpan(myCfg.ValidityDays, 0, 0, 0);
Component modified = cfg.CreateDbEntity();
dbCmpnt.Parameters = modified.Parameters;
}
session.SaveOrUpdate(dbCmpnt);
}
/// <summary>Start this operation</summary>
public void Start()
{
opCompleted = false;
anyError = false;
}
/// <summary>Run this operation</summary>
/// <returns>Event.ResultsWritten or Event.Error</returns>
public Event Run()
{
if (myCfg.DebugLevel == DebugMode.Simulate)
{
opCompleted = true;
return Event.ResultsWritten;
}
if (currentOp == CurrentOp.SaveDiverterCorrections)
{
if (!opCompleted)
{
ITransaction transaction = null;
try
{
ISession session = Config.FluentCommon.CreateSession(Users.Entities.DBKind.Config);
transaction = session.BeginTransaction();
for (int div = 1; div <= myCfg.DivertersCount(); div++)
{
string diverterName = myCfg.GetDiverterName(div);
Elde.Diverter.Diverter diverter = TbfComponents.FindComponent(diverterName) as Elde.Diverter.Diverter;
if (diverter != null)
{
var cmpntEntities = session.QueryOver<Component>()
.Where(cmpnt => (cmpnt.Name == diverterName))
.List();
var runtimeComponent = TbfComponents.FindComponent(diverterName);
if ((cmpntEntities.Count != 1) || (runtimeComponent == null))
{
log.ErrorFormat("No unique diverter named {0}", diverterName);
continue;
}
newCorrections = CalculateCorrectionsFromResuls(batch, diverterName);
DeleteExistingCorrections(session, cmpntEntities[0], runtimeComponent);
SaveNewCorrections(session, cmpntEntities[0], runtimeComponent, newCorrections);
}
}
transaction.Commit();
session.Flush();
opCompleted = true;
log.WarnFormat("Measurement corrections successfully saved");
}
catch (Exception exc)
{
if (transaction != null && !transaction.WasCommitted) transaction.Rollback();
anyError = true;
log.ErrorFormat("Failed to write corrections calculated from batch {0}: {1}", batch.BatchNr, exc.Message);
}
}
if (anyError)
return Event.ResultsNotWritten;
else
return Event.ResultsWritten;
}
else
{
return Event.None;
}
}
/// <summary>Stop this operation</summary>
public void Stop()
{
currentOp = CurrentOp.None;
}
}
}
@@ -1,86 +0,0 @@
///
/// Copyright (c) 2019 Sensus Slovensko a.s.
///
using System.Xml.Serialization;
using TBF.BenchControl.Generic;
namespace TBF.BenchControl.Output.DB.SaveDiverterCorrections
{
public class SaveDiverterCorrCfg : ComponentCfgBase, Generic.IComponentCfg
{
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(SaveDiverterCorrCfg) })[0];
public override XmlSerializer GetSerializer() { return Serializer; }
public IComponentCfgCtrl GetControl() { return new SaveDiverterCorrCfgCtrl(); }
public string Diverter1;
public string Diverter2;
public string Diverter3;
public string Diverter4;
public string Diverter5;
public string Diverter6;
public string PatternForShortTests;
public string PatternForLongTests;
public int ShortTestDiversionsCount;
public string CertificateFmt;
public int ValidityDays;
public int DivertersCount() { return 6; }
/// <summary>
/// Get flowmeter name
/// </summary>
/// <param name="d">Flowmeter index 1 .. FlowmetersCount()==7</param>
/// <returns>Flowmeter name or null</returns>
public string GetDiverterName(int d)
{
switch (d)
{
case 1: return Diverter1;
case 2: return Diverter2;
case 3: return Diverter3;
case 4: return Diverter4;
case 5: return Diverter5;
case 6: return Diverter6;
case 7: return ShortTestDiversionsCount.ToString();
default: return null;
}
}
/// Private parameterless constructor invoked by all other (public) constructors
SaveDiverterCorrCfg()
{
ParentName = string.Empty;
Diverter1 = "Div1";
Diverter2 = "Div2";
Diverter3 = null;
Diverter4 = null;
Diverter5 = null;
Diverter6 = null;
ShortTestDiversionsCount = 10;
PatternForShortTests = "short";
PatternForLongTests = "long";
}
public SaveDiverterCorrCfg(string name, IComponentFactory factory)
: this()
{
this.Name = name;
this.Factory = factory;
}
public string ToString(int i)
{
return string.Format("Name={0}, Flowmtr1={1}, Flowmtr2={2}, Flowmtr3={3}, Flowmtr4={4}, Flowmtr5={5}, Flowmtr6={6}",
Name,
string.IsNullOrEmpty(Diverter1) ? "---" : Diverter1,
string.IsNullOrEmpty(Diverter2) ? "---" : Diverter2,
string.IsNullOrEmpty(Diverter3) ? "---" : Diverter3,
string.IsNullOrEmpty(Diverter4) ? "---" : Diverter4,
string.IsNullOrEmpty(Diverter5) ? "---" : Diverter5,
string.IsNullOrEmpty(Diverter6) ? "---" : Diverter6);
}
}
}
@@ -1,185 +0,0 @@
///
/// Copyright (c) 2019 Sensus Slovensko a.s.
///
using System;
using System.Windows.Forms;
using Config.Entities;
using TBF.BenchControl.Generic;
namespace TBF.BenchControl.Output.DB.SaveDiverterCorrections
{
public partial class SaveDiverterCorrCfgCtrl : Configs.ConfigCtrlUtils, IComponentCfgCtrl
{
public bool ShowMore { get { return false; } }
ComponentParametersDlg parent;
SaveDiverterCorrCfg config;
public IComponentCfg Config
{
get { return config as IComponentCfg; }
set
{
config = value as SaveDiverterCorrCfg;
Redraw();
}
}
public SaveDiverterCorrCfgCtrl()
{
InitializeComponent();
}
private void WriterCfgCtrl_Load(object sender, EventArgs e)
{
parent = ParentForm as ComponentParametersDlg;
if (parent == null) return;
if (parent.TbfComponents != null)
{
diverter1ComboBox.Items.Add("---");
diverter2ComboBox.Items.Add("---");
diverter3ComboBox.Items.Add("---");
diverter4ComboBox.Items.Add("---");
diverter5ComboBox.Items.Add("---");
diverter6ComboBox.Items.Add("---");
///
foreach (var cmpnt in parent.TbfComponents)
{
if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is TBF.BenchControl.Elde.Diverter.DiverterFactory)
{
diverter1ComboBox.Items.Add(cmpnt.Name);
diverter2ComboBox.Items.Add(cmpnt.Name);
diverter3ComboBox.Items.Add(cmpnt.Name);
diverter4ComboBox.Items.Add(cmpnt.Name);
diverter5ComboBox.Items.Add(cmpnt.Name);
diverter6ComboBox.Items.Add(cmpnt.Name);
}
}
}
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;
diverter1ComboBox.Text = string.IsNullOrEmpty(config.Diverter1) ? "---" : config.Diverter1;
diverter2ComboBox.Text = string.IsNullOrEmpty(config.Diverter2) ? "---" : config.Diverter2;
diverter3ComboBox.Text = string.IsNullOrEmpty(config.Diverter3) ? "---" : config.Diverter3;
diverter4ComboBox.Text = string.IsNullOrEmpty(config.Diverter4) ? "---" : config.Diverter4;
diverter5ComboBox.Text = string.IsNullOrEmpty(config.Diverter5) ? "---" : config.Diverter5;
diverter6ComboBox.Text = string.IsNullOrEmpty(config.Diverter6) ? "---" : config.Diverter6;
patternShortTextBox.Text = config.PatternForShortTests;
patternLongTextBox.Text = config.PatternForLongTests;
diversionsCountTextBox.Text = config.ShortTestDiversionsCount.ToString();
certificateTextBox.Text = config.CertificateFmt;
validityTextBox.Text = config.ValidityDays.ToString();
}
public void Unlock()
{
nameTextBox.Enabled = true;
diverter1ComboBox.Enabled = true;
diverter2ComboBox.Enabled = true;
diverter3ComboBox.Enabled = true;
diverter4ComboBox.Enabled = true;
diverter5ComboBox.Enabled = true;
diverter6ComboBox.Enabled = true;
patternShortTextBox.Enabled = true;
patternLongTextBox.Enabled = true;
diversionsCountTextBox.Enabled = true;
certificateTextBox.Enabled = true;
validityTextBox.Enabled = true;
}
public CfgUpdateFlags VerifyCfg(ref string message)
{
CfgUpdateFlags flags = CfgUpdateFlags.None;
if (!diverter1ComboBox.Items.Contains(diverter1ComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + string.Format("Invalid {0}", diverter1Label.Text);
}
if (!diverter2ComboBox.Items.Contains(diverter2ComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + string.Format("Invalid {0}", diverter2Label.Text);
}
if (!diverter3ComboBox.Items.Contains(diverter3ComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + string.Format("Invalid {0}", diverter3Label.Text);
}
if (!diverter4ComboBox.Items.Contains(diverter4ComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + string.Format("Invalid {0}", diverter4Label.Text);
}
if (!diverter5ComboBox.Items.Contains(diverter5ComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + string.Format("Invalid {0}", diverter5Label.Text);
}
if (!diverter6ComboBox.Items.Contains(diverter6ComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + string.Format("Invalid {0}", diverter6Label.Text);
}
int tmp;
if (!int.TryParse(diversionsCountTextBox.Text, out tmp) || tmp <= 2)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + string.Format("Invalid {0}", validityLabel.Text);
}
if (!int.TryParse(validityTextBox.Text, out tmp) || tmp < 0)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + string.Format("Invalid {0}", validityLabel.Text);
}
return flags;
}
public CfgUpdateFlags UpdateCfg()
{
CfgUpdateFlags flags = CfgUpdateFlags.None;
if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed
if (config.Name != nameTextBox.Text)
{
config.Name = nameTextBox.Text;
flags |= CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd;
}
flags |= UpdateDifferent(ref config.Diverter1, diverter1ComboBox.Text, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
flags |= UpdateDifferent(ref config.Diverter2, diverter2ComboBox.Text, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
flags |= UpdateDifferent(ref config.Diverter3, diverter3ComboBox.Text, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
flags |= UpdateDifferent(ref config.Diverter4, diverter4ComboBox.Text, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
flags |= UpdateDifferent(ref config.Diverter5, diverter5ComboBox.Text, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
flags |= UpdateDifferent(ref config.Diverter6, diverter6ComboBox.Text, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
flags |= UpdateDifferent(ref config.PatternForShortTests, patternShortTextBox.Text, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
flags |= UpdateDifferent(ref config.PatternForLongTests, patternLongTextBox.Text, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
flags |= UpdateDifferent(ref config.ShortTestDiversionsCount, diversionsCountTextBox.Text, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
flags |= UpdateDifferent(ref config.CertificateFmt, certificateTextBox.Text, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
flags |= UpdateDifferent(ref config.ValidityDays, validityTextBox.Text, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
return flags;
}
}
}
@@ -1,369 +0,0 @@
///
/// Copyright (c) 2019 Sensus Slovensko a.s.
///
namespace TBF.BenchControl.Output.DB.SaveDiverterCorrections
{
partial class SaveDiverterCorrCfgCtrl
{
/// <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.diverter1Label = new System.Windows.Forms.Label();
this.diverter1ComboBox = new System.Windows.Forms.ComboBox();
this.diverter2ComboBox = new System.Windows.Forms.ComboBox();
this.diverter2Label = new System.Windows.Forms.Label();
this.diverter3ComboBox = new System.Windows.Forms.ComboBox();
this.diverter3Label = new System.Windows.Forms.Label();
this.diverter4ComboBox = new System.Windows.Forms.ComboBox();
this.diverter4Label = new System.Windows.Forms.Label();
this.diverter5ComboBox = new System.Windows.Forms.ComboBox();
this.diverter5Label = new System.Windows.Forms.Label();
this.diverter6ComboBox = new System.Windows.Forms.ComboBox();
this.diverter6Label = new System.Windows.Forms.Label();
this.certificateTextBox = new System.Windows.Forms.TextBox();
this.certificateLabel = new System.Windows.Forms.Label();
this.validityTextBox = new System.Windows.Forms.TextBox();
this.validityLabel = new System.Windows.Forms.Label();
this.paternShortLabel = new System.Windows.Forms.Label();
this.patternShortTextBox = new System.Windows.Forms.TextBox();
this.patternLongTextBox = new System.Windows.Forms.TextBox();
this.patternLongLabel = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.diversionsCountTextBox = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// nameTextBox
//
this.nameTextBox.Enabled = false;
this.nameTextBox.Location = new System.Drawing.Point(124, 31);
this.nameTextBox.Name = "nameTextBox";
this.nameTextBox.Size = new System.Drawing.Size(285, 20);
this.nameTextBox.TabIndex = 2;
//
// nameLabel
//
this.nameLabel.AutoSize = true;
this.nameLabel.Location = new System.Drawing.Point(15, 34);
this.nameLabel.Name = "nameLabel";
this.nameLabel.Size = new System.Drawing.Size(35, 13);
this.nameLabel.TabIndex = 1;
this.nameLabel.Text = "Name";
//
// classNameLabel
//
this.classNameLabel.AutoSize = true;
this.classNameLabel.Location = new System.Drawing.Point(136, 9);
this.classNameLabel.Name = "classNameLabel";
this.classNameLabel.Size = new System.Drawing.Size(83, 13);
this.classNameLabel.TabIndex = 0;
this.classNameLabel.Text = "ComonentName";
//
// diverter1Label
//
this.diverter1Label.AutoSize = true;
this.diverter1Label.Location = new System.Drawing.Point(15, 57);
this.diverter1Label.Name = "diverter1Label";
this.diverter1Label.Size = new System.Drawing.Size(53, 13);
this.diverter1Label.TabIndex = 3;
this.diverter1Label.Text = "Diverter 1";
//
// diverter1ComboBox
//
this.diverter1ComboBox.Enabled = false;
this.diverter1ComboBox.FormattingEnabled = true;
this.diverter1ComboBox.Location = new System.Drawing.Point(124, 54);
this.diverter1ComboBox.Name = "diverter1ComboBox";
this.diverter1ComboBox.Size = new System.Drawing.Size(69, 21);
this.diverter1ComboBox.TabIndex = 4;
//
// diverter2ComboBox
//
this.diverter2ComboBox.Enabled = false;
this.diverter2ComboBox.FormattingEnabled = true;
this.diverter2ComboBox.Location = new System.Drawing.Point(124, 78);
this.diverter2ComboBox.Name = "diverter2ComboBox";
this.diverter2ComboBox.Size = new System.Drawing.Size(69, 21);
this.diverter2ComboBox.TabIndex = 6;
//
// diverter2Label
//
this.diverter2Label.AutoSize = true;
this.diverter2Label.Location = new System.Drawing.Point(15, 81);
this.diverter2Label.Name = "diverter2Label";
this.diverter2Label.Size = new System.Drawing.Size(53, 13);
this.diverter2Label.TabIndex = 5;
this.diverter2Label.Text = "Diverter 2";
//
// diverter3ComboBox
//
this.diverter3ComboBox.Enabled = false;
this.diverter3ComboBox.FormattingEnabled = true;
this.diverter3ComboBox.Location = new System.Drawing.Point(124, 102);
this.diverter3ComboBox.Name = "diverter3ComboBox";
this.diverter3ComboBox.Size = new System.Drawing.Size(69, 21);
this.diverter3ComboBox.TabIndex = 8;
//
// diverter3Label
//
this.diverter3Label.AutoSize = true;
this.diverter3Label.Location = new System.Drawing.Point(15, 105);
this.diverter3Label.Name = "diverter3Label";
this.diverter3Label.Size = new System.Drawing.Size(53, 13);
this.diverter3Label.TabIndex = 7;
this.diverter3Label.Text = "Diverter 3";
//
// diverter4ComboBox
//
this.diverter4ComboBox.Enabled = false;
this.diverter4ComboBox.FormattingEnabled = true;
this.diverter4ComboBox.Location = new System.Drawing.Point(124, 126);
this.diverter4ComboBox.Name = "diverter4ComboBox";
this.diverter4ComboBox.Size = new System.Drawing.Size(69, 21);
this.diverter4ComboBox.TabIndex = 10;
//
// diverter4Label
//
this.diverter4Label.AutoSize = true;
this.diverter4Label.Location = new System.Drawing.Point(15, 129);
this.diverter4Label.Name = "diverter4Label";
this.diverter4Label.Size = new System.Drawing.Size(53, 13);
this.diverter4Label.TabIndex = 9;
this.diverter4Label.Text = "Diverter 4";
//
// diverter5ComboBox
//
this.diverter5ComboBox.Enabled = false;
this.diverter5ComboBox.FormattingEnabled = true;
this.diverter5ComboBox.Location = new System.Drawing.Point(124, 150);
this.diverter5ComboBox.Name = "diverter5ComboBox";
this.diverter5ComboBox.Size = new System.Drawing.Size(69, 21);
this.diverter5ComboBox.TabIndex = 12;
//
// diverter5Label
//
this.diverter5Label.AutoSize = true;
this.diverter5Label.Location = new System.Drawing.Point(15, 153);
this.diverter5Label.Name = "diverter5Label";
this.diverter5Label.Size = new System.Drawing.Size(53, 13);
this.diverter5Label.TabIndex = 11;
this.diverter5Label.Text = "Diverter 5";
//
// diverter6ComboBox
//
this.diverter6ComboBox.Enabled = false;
this.diverter6ComboBox.FormattingEnabled = true;
this.diverter6ComboBox.Location = new System.Drawing.Point(124, 174);
this.diverter6ComboBox.Name = "diverter6ComboBox";
this.diverter6ComboBox.Size = new System.Drawing.Size(69, 21);
this.diverter6ComboBox.TabIndex = 14;
//
// diverter6Label
//
this.diverter6Label.AutoSize = true;
this.diverter6Label.Location = new System.Drawing.Point(15, 177);
this.diverter6Label.Name = "diverter6Label";
this.diverter6Label.Size = new System.Drawing.Size(53, 13);
this.diverter6Label.TabIndex = 13;
this.diverter6Label.Text = "Diverter 6";
//
// certificateTextBox
//
this.certificateTextBox.Enabled = false;
this.certificateTextBox.Location = new System.Drawing.Point(124, 244);
this.certificateTextBox.Name = "certificateTextBox";
this.certificateTextBox.Size = new System.Drawing.Size(285, 20);
this.certificateTextBox.TabIndex = 20;
//
// certificateLabel
//
this.certificateLabel.AutoSize = true;
this.certificateLabel.Location = new System.Drawing.Point(15, 247);
this.certificateLabel.Name = "certificateLabel";
this.certificateLabel.Size = new System.Drawing.Size(54, 13);
this.certificateLabel.TabIndex = 19;
this.certificateLabel.Text = "Certificate";
//
// validityTextBox
//
this.validityTextBox.Enabled = false;
this.validityTextBox.Location = new System.Drawing.Point(124, 267);
this.validityTextBox.Name = "validityTextBox";
this.validityTextBox.Size = new System.Drawing.Size(43, 20);
this.validityTextBox.TabIndex = 22;
//
// validityLabel
//
this.validityLabel.AutoSize = true;
this.validityLabel.Location = new System.Drawing.Point(15, 270);
this.validityLabel.Name = "validityLabel";
this.validityLabel.Size = new System.Drawing.Size(71, 13);
this.validityLabel.TabIndex = 21;
this.validityLabel.Text = "Validity (days)";
//
// paternShortLabel
//
this.paternShortLabel.AutoSize = true;
this.paternShortLabel.Location = new System.Drawing.Point(15, 201);
this.paternShortLabel.Name = "paternShortLabel";
this.paternShortLabel.Size = new System.Drawing.Size(107, 13);
this.paternShortLabel.TabIndex = 15;
this.paternShortLabel.Text = "Pattern for short tests";
//
// patternShortTextBox
//
this.patternShortTextBox.Enabled = false;
this.patternShortTextBox.Location = new System.Drawing.Point(124, 198);
this.patternShortTextBox.Name = "patternShortTextBox";
this.patternShortTextBox.Size = new System.Drawing.Size(107, 20);
this.patternShortTextBox.TabIndex = 16;
//
// patternLongTextBox
//
this.patternLongTextBox.Enabled = false;
this.patternLongTextBox.Location = new System.Drawing.Point(124, 221);
this.patternLongTextBox.Name = "patternLongTextBox";
this.patternLongTextBox.Size = new System.Drawing.Size(107, 20);
this.patternLongTextBox.TabIndex = 18;
//
// patternLongLabel
//
this.patternLongLabel.AutoSize = true;
this.patternLongLabel.Location = new System.Drawing.Point(15, 224);
this.patternLongLabel.Name = "patternLongLabel";
this.patternLongLabel.Size = new System.Drawing.Size(104, 13);
this.patternLongLabel.TabIndex = 17;
this.patternLongLabel.Text = "Pattern for long tests";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(245, 201);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(132, 13);
this.label1.TabIndex = 23;
this.label1.Text = "Short test diversions count";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(245, 224);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(131, 13);
this.label2.TabIndex = 24;
this.label2.Text = "Long test diversions count";
//
// diversionsCountTextBox
//
this.diversionsCountTextBox.Enabled = false;
this.diversionsCountTextBox.Location = new System.Drawing.Point(378, 198);
this.diversionsCountTextBox.Name = "diversionsCountTextBox";
this.diversionsCountTextBox.Size = new System.Drawing.Size(31, 20);
this.diversionsCountTextBox.TabIndex = 25;
//
// textBox2
//
this.textBox2.Enabled = false;
this.textBox2.Location = new System.Drawing.Point(378, 221);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(31, 20);
this.textBox2.TabIndex = 26;
this.textBox2.Text = "1";
//
// SaveDiverterCorrCfgCtrl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.textBox2);
this.Controls.Add(this.diversionsCountTextBox);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.patternLongLabel);
this.Controls.Add(this.patternLongTextBox);
this.Controls.Add(this.patternShortTextBox);
this.Controls.Add(this.paternShortLabel);
this.Controls.Add(this.validityTextBox);
this.Controls.Add(this.validityLabel);
this.Controls.Add(this.certificateTextBox);
this.Controls.Add(this.certificateLabel);
this.Controls.Add(this.diverter6ComboBox);
this.Controls.Add(this.diverter6Label);
this.Controls.Add(this.diverter5ComboBox);
this.Controls.Add(this.diverter5Label);
this.Controls.Add(this.diverter4ComboBox);
this.Controls.Add(this.diverter4Label);
this.Controls.Add(this.diverter3ComboBox);
this.Controls.Add(this.diverter3Label);
this.Controls.Add(this.diverter2ComboBox);
this.Controls.Add(this.diverter2Label);
this.Controls.Add(this.diverter1ComboBox);
this.Controls.Add(this.diverter1Label);
this.Controls.Add(this.nameTextBox);
this.Controls.Add(this.nameLabel);
this.Controls.Add(this.classNameLabel);
this.Name = "SaveDiverterCorrCfgCtrl";
this.Size = new System.Drawing.Size(450, 300);
this.Load += new System.EventHandler(this.WriterCfgCtrl_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 diverter1Label;
private System.Windows.Forms.ComboBox diverter1ComboBox;
private System.Windows.Forms.ComboBox diverter2ComboBox;
private System.Windows.Forms.Label diverter2Label;
private System.Windows.Forms.ComboBox diverter3ComboBox;
private System.Windows.Forms.Label diverter3Label;
private System.Windows.Forms.ComboBox diverter4ComboBox;
private System.Windows.Forms.Label diverter4Label;
private System.Windows.Forms.ComboBox diverter5ComboBox;
private System.Windows.Forms.Label diverter5Label;
private System.Windows.Forms.ComboBox diverter6ComboBox;
private System.Windows.Forms.Label diverter6Label;
private System.Windows.Forms.TextBox certificateTextBox;
private System.Windows.Forms.Label certificateLabel;
private System.Windows.Forms.TextBox validityTextBox;
private System.Windows.Forms.Label validityLabel;
private System.Windows.Forms.Label paternShortLabel;
private System.Windows.Forms.TextBox patternShortTextBox;
private System.Windows.Forms.TextBox patternLongTextBox;
private System.Windows.Forms.Label patternLongLabel;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox diversionsCountTextBox;
private System.Windows.Forms.TextBox textBox2;
}
}
@@ -1,120 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2018-2019 Sensus Slovensko a.s.
/// Copyright (c) 2018 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
@@ -119,44 +119,32 @@ namespace TBF.BenchControl.Output.DB.SaveFlowmeterCorrections
}
void DeleteExistingCorrections(ISession session, Component dbCmpnt, IComponent runtimeCmpnt, int rangeIx)
void DeleteExistingCorrections(ISession session, Component cmpnt, int rangeIx)
{
/// Delete correction from DB entity
for (int i = dbCmpnt.Corrections.Count - 1; i >= 0; i--)
for (int i = cmpnt.Corrections.Count - 1; i >= 0; i--)
{
if (dbCmpnt.Corrections[i].RangeIx == rangeIx)
if (cmpnt.Corrections[i].RangeIx == rangeIx)
{
session.Delete(dbCmpnt.Corrections[i]);
dbCmpnt.Corrections.RemoveAt(i);
}
}
session.SaveOrUpdate(dbCmpnt);
/// Delete corrections from runtime flowmeter component
for (int i = runtimeCmpnt.Corrections.Count - 1; i >= 0; i--)
{
if (runtimeCmpnt.Corrections[i].RangeIx == rangeIx)
{
runtimeCmpnt.Corrections.RemoveAt(i);
session.Delete(cmpnt.Corrections[i]);
cmpnt.Corrections.RemoveAt(i);
}
}
session.SaveOrUpdate(cmpnt);
}
void SaveNewCorrections(ISession session, Component dbCmpnt, IComponent runtimeCmpnt, int rangeIx, IList<MeasurementCorrection> corrections)
void SaveNewCorrections(ISession session, Component cmpnt, int rangeIx, IList<MeasurementCorrection> corrections)
{
if (dbCmpnt.Corrections == null) dbCmpnt.Corrections = new List<MeasurementCorrection>();
if (runtimeCmpnt.Corrections == null) runtimeCmpnt.Corrections = new List<MeasurementCorrection>();
if (cmpnt.Corrections == null) cmpnt.Corrections = new List<MeasurementCorrection>();
foreach (var mc in corrections)
{
mc.RangeIx = rangeIx;
dbCmpnt.Corrections.Add(mc);
runtimeCmpnt.Corrections.Add(mc);
cmpnt.Corrections.Add(mc);
session.SaveOrUpdate(mc);
}
ICalibRangesCfg cfg = TbfComponents.CmpntCfgFromCmpntEntity(dbCmpnt) as ICalibRangesCfg;
ICalibRangesCfg cfg = TbfComponents.CmpntCfgFromCmpntEntity(cmpnt) as ICalibRangesCfg;
if (cfg != null)
{
cfg.SetCalibDate(rangeIx, DateTime.Now);
@@ -172,10 +160,10 @@ namespace TBF.BenchControl.Output.DB.SaveFlowmeterCorrections
}
Component modified = cfg.CreateDbEntity();
dbCmpnt.Parameters = modified.Parameters;
cmpnt.Parameters = modified.Parameters;
}
session.SaveOrUpdate(dbCmpnt);
session.SaveOrUpdate(cmpnt);
}
@@ -217,9 +205,7 @@ namespace TBF.BenchControl.Output.DB.SaveFlowmeterCorrections
.Where(cmpnt => (cmpnt.Name == flowmeterName))
.List();
var runtimeComponent = TbfComponents.FindComponent(flowmeterName);
if ((cmpntEntities.Count != 1) || (runtimeComponent == null))
if (cmpntEntities.Count != 1)
{
log.ErrorFormat("No unique flowmeter named {0}", myCfg.GetFlowmeterName(fmtr));
continue;
@@ -232,8 +218,8 @@ namespace TBF.BenchControl.Output.DB.SaveFlowmeterCorrections
double tempRngLo = flowmeter.GetTempLo(rng);
double tempRngHi = flowmeter.GetTempHi(rng);
newCorrections = GetCorrections(batch, flowmeterName, rng, tempRngLo, tempRngHi);
DeleteExistingCorrections(session, cmpntEntities[0], runtimeComponent, rng);
SaveNewCorrections(session, cmpntEntities[0], runtimeComponent, rng, newCorrections);
DeleteExistingCorrections(session, cmpntEntities[0], rng);
SaveNewCorrections(session, cmpntEntities[0], rng, newCorrections);
}
}
}
@@ -216,14 +216,7 @@ namespace TBF.BenchControl.Output.DB.SaveFlowmeterCorrections
public string ToString(int i)
{
return string.Format("Name={0}, Flowmtr1={1}, Flowmtr2={2}, Flowmtr3={3}, Flowmtr4={4}, Flowmtr5={5}, Flowmtr6={6}, Flowmtr7={7}",
Name,
string.IsNullOrEmpty(Flowmeter1) ? "---" : Flowmeter1,
string.IsNullOrEmpty(Flowmeter2) ? "---" : Flowmeter2,
string.IsNullOrEmpty(Flowmeter3) ? "---" : Flowmeter3,
string.IsNullOrEmpty(Flowmeter4) ? "---" : Flowmeter4,
string.IsNullOrEmpty(Flowmeter5) ? "---" : Flowmeter5,
string.IsNullOrEmpty(Flowmeter6) ? "---" : Flowmeter6,
string.IsNullOrEmpty(Flowmeter7) ? "---" : Flowmeter7);
Name, Flowmeter1, Flowmeter2, Flowmeter3, Flowmeter4, Flowmeter5, Flowmeter6, Flowmeter7);
}
}
}
@@ -173,7 +173,7 @@ namespace TBF.BenchControl.Output.FileWriters.IperlLogger
public Retv WriteLogsToDisk(TextWriter logger, Results.Entities.Batch batch)
{
#if TURA_IPERL || TURA_IPERL_NEW || TURA_SPECIAL
#if TURA_IPERL || TURA_SPECIAL
/// Obtain one representative water meter data
Results.Entities.WaterMeter wm0 = null;
+22 -58
View File
@@ -498,19 +498,33 @@ namespace TBF.BenchControl.Sequences
}
else if (selection == Selection.RestoreAndFixBatch)
{
///
/// Restore and fix a batch - part 1 (fix "Previous workstep is missing" error)
///
BatchRslts = CreateNewBatchResults(newBatchNr, StateMachine.Procedure);
RestoreBatchResults(TBF.UiBridge.Bridge.BatchNr, ref BatchRslts); /// pass the original batch number of the batch to be restored
///
/// Fix "Previous workstep is missing" error in this batch
///
for (int i = 0; i < BatchRslts.WaterMeters.Length; i++)
{
WaterMeter wm = BatchRslts.WaterMeters[i];
if (wm != null && wm.Passed)
if (wm != null)
{
/// Water meter passed and was already saved to Oracle, do not reload & fix it now
wm.Disabled = true;
if (wm.Passed)
{
wm.Disabled = true;
}
else if (!wm.Disabled)
{
wm.ErrorFlags = wm.ErrorFlags & (~(int)ErrorFlagMask.E28);
foreach (var mtr in wm.MeterTestRslts)
{
if (mtr.TestData().Evaluate && (mtr.TestData().Name == "Kontrola montaze") && (mtr.TestData().Method == "iPerlCommunication"))
{
mtr.TestDone = true;
mtr.Passed = true;
}
}
}
}
}
}
@@ -681,48 +695,6 @@ namespace TBF.BenchControl.Sequences
log.ErrorFormat("StartInfoReader failed to read data from the database");
/// TODO: Message for an operator? Error?
}
else if (selection == Selection.RestoreAndFixBatch)
{
/// Restore and fix a batch - part 2
for (int i = 0; i < BatchRslts.WaterMeters.Length; i++)
{
WaterMeter wm = BatchRslts.WaterMeters[i];
if (wm != null && !wm.Disabled)
{
/// Water meter did not pass
foreach (var mtr in wm.MeterTestRslts)
{
/// Find test entitled 'Kontrola montaze'
if (mtr.TestData().Evaluate && (mtr.TestData().Name == "Kontrola montaze") && (mtr.TestData().Method == "iPerlCommunication"))
{
/// This meter test result (mtr) is 'Kontrola montaze'
if (wm.LastRecordIsNok)
{
/// There is still a production tracing error, last record is missing
wm.ErrorFlags |= (int)Config.Entities.ErrorFlagMask.E28; /// Set E28
}
else
{
/// No production tracing error, last record is OK
wm.ErrorFlags &= ~(int)Config.Entities.ErrorFlagMask.E28; /// Clear E28
}
if ((wm.ErrorFlags & (int)Config.Entities.ErrorFlagMask.E28) != 0)
{
/// Previous workstep missing or NOK (production tracing error)
mtr.ErrorIndicators |= (int)ErrorFlagMask.E28;
mtr.Passed = false;
}
else
{
/// Previous step is OK
mtr.Passed = true;
}
}
}
}
}
}
/// Redraw on-screen results
Bridge.OnTestCompleted(this, new TestCompletedEventArgs(string.Empty, null));
@@ -806,10 +778,7 @@ namespace TBF.BenchControl.Sequences
///------------------------------------------------------------------------------------------------------------
if (selection == Selection.Cycle || selection == Selection.RestOfCycle)
{
/// A sequence of tests will be executed
IList<DeferredTestEvaluationData> deferredData = new List<DeferredTestEvaluationData>();
bool veryFirstTestInTheRestOfCycle = true;
int selsctedTestIx = simultWithPurgingCount; /// Applies when selection == Selection.Cycle
int repetNr = 1;
@@ -931,12 +900,10 @@ namespace TBF.BenchControl.Sequences
bool doOneMoreRepetition = false;
do
{
bool doExecuteTransitionBefore = isOuterLoopMode || (repetNr == 1) || veryFirstTestInTheRestOfCycle;
veryFirstTestInTheRestOfCycle = false;
if (testMethod.DoTransitions())
{
/// Make a transition before a test and before each test repetition
rsltTransBefore = Transition(doExecuteTransitionBefore ? transitionBefore : null, TransitionContext.BeforeTest); /// Transition or SetRoute - start of test
rsltTransBefore = Transition(transitionBefore, TransitionContext.BeforeTest); /// Transition or SetRoute - start of test
log.InfoFormat("Test {0}: Transition({1}, BeforeTest) returned {2}", test.Name, (transitionBefore == null ? "null" : transitionBefore.Name), rsltTransBefore);
}
if (rsltTransBefore != Event.Done) break;
@@ -1078,11 +1045,8 @@ namespace TBF.BenchControl.Sequences
deferredData.Clear();
}
///------------------------------------------------------------------------------------------------------------
else
else /// if (selection == Selection.Test or Q1 or Q2 or Q3)
{
/// selection == Selection.Test or Selection.Q1 or Selection.Q2 or Selection.Q3
/// Single test will be executed
int repetNr;
Test test = TBF.BenchControl.StateMachine.GetTest(selectedTestName, out repetNr);
if (test == null)
+1 -1
View File
@@ -67,7 +67,7 @@ namespace TBF.BenchControl
/// Time and synchronization
#if TURA_IPERL || TURA_IPERL_NEW
#if TURA_IPERL
public const int Period = 2; /// State machine period in sec.
#else
public const int Period = 1; /// State machine period in sec.
+1 -3
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2019 Sensus Slovensko a.s.
/// Copyright (c) 2013-2018 Sensus Slovensko a.s.
///
using System.Collections.Generic;
using Config.Entities;
@@ -54,7 +54,6 @@ namespace TBF.BenchControl
Factories.Add(new TestMethods.ChangeFlowDirection.Factory());
Factories.Add(new TestMethods.CombinedWithDetection.TestMethodFactory());
Factories.Add(new TestMethods.Counter.Factory());
Factories.Add(new TestMethods.DiverterTest.Factory());
Factories.Add(new TestMethods.Endurance.Factory());
Factories.Add(new TestMethods.FixedStart.Single.Factory());
Factories.Add(new TestMethods.FixedStart.Compound.Factory());
@@ -121,7 +120,6 @@ namespace TBF.BenchControl
Factories.Add(new Network.Camera.RoiForFixedStart.Factory());
Factories.Add(new Network.Comet.Ambient.Factory());
Factories.Add(new Output.DB.ProductionTracing.Factory());
Factories.Add(new Output.DB.SaveDiverterCorrections.Factory());
Factories.Add(new Output.DB.SaveFlowmeterCorrections.Factory());
Factories.Add(new Output.DB.SensusOracle.Factory());
Factories.Add(new Output.FileWriters.Basic.FactorySingle());
+3 -3
View File
@@ -388,7 +388,7 @@ namespace TBF.BenchControl
const ulong Path3 = VI3;
const ulong Path4 = VI4;
const ulong Path5 = 0;
#elif TORUN_50 || TURA_IPERL || TURA_IPERL_NEW
#elif TORUN_50 || TURA_IPERL
const ulong VL11 = (1L << 0);
const ulong VL13 = (1L << 1);
const ulong VL15 = (1L << 2);
@@ -545,7 +545,7 @@ namespace TBF.BenchControl
if (Div1sim && (SimRoute & Path1) == Path1) Mass1sim += DiffKg(Flow1sim, time);
if (Div1sim && (SimRoute & Path2) == Path2) Mass1sim += DiffKg(Flow2sim, time);
if (Div1sim && (SimRoute & Path3) == Path3) Mass1sim += DiffKg(Flow3sim, time);
#elif TORUN_50 || TURA_IPERL || TURA_IPERL_NEW /// Path1,2,3,4,5 do WT1, Path6 do WT2
#elif TORUN_50 || TURA_IPERL /// Path1,2,3,4,5 do WT1, Path6 do WT2
if (Div1sim && (SimRoute & Path1) == Path1) Mass1sim += DiffKg(Flow1sim, time);
if (Div1sim && (SimRoute & Path2) == Path2) Mass1sim += DiffKg(Flow2sim, time);
if (Div1sim && (SimRoute & Path3) == Path3) Mass1sim += DiffKg(Flow3sim, time);
@@ -695,7 +695,7 @@ namespace TBF.BenchControl
if (toTank) { /* throw (new Exception()); */ }
break;
}
#elif TORUN_50 || TURA_IPERL || TURA_IPERL_NEW
#elif TORUN_50 || TURA_IPERL
switch (regulValveNo)
{
case 1:
@@ -107,7 +107,6 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
//--------------------------------
State.Create(string.Format("{0}({1}) : Stop diverter gate etc", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperations(readTempPressOps)
.AddOperation(cBrd.StopPreviousOp())
.EnterState();
do {
@@ -332,9 +331,9 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
case Event.UiCmdStop: goto stopTest;
}
int diff = RegisterReaders[(test.Part - 1) * 2 + 1].WMPulses - lastWMPulses[(test.Part - 1) * 2 + 1];
flowsForDetection[0] = cBrd.ReferenceFreq * outPath.FlowMeter.NominalFlow / 2000.0;
double diff = RegisterReaders[(test.Part - 1) * 2 + 1].WMPulses - lastWMPulses[(test.Part - 1) * 2 + 1];
pulseFreqsForDetection[0] = diff / (double)(StateMachine.Time - lastTime);
pulseFreqsForDetection[0] = (double)diff / (double)(StateMachine.Time - lastTime);
lastTime = StateMachine.Time;
}
@@ -396,20 +395,20 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
aveFreqBefore.ToString("F2"),
aveFreqAfter.ToString("F2")));
//detectedFlow = (aveFlowBefore + aveFlowAfter) / 2;
//detectedFlow = (aveFlowBefore + aveFlowAfter) / 2.0f;
detectedFlow = aveFlowBefore;
if (rvPulse > 0)
{
/// rise
detected = (aveFreqAfter < aveFreqBefore * (1 - testParams.DetectionThreshold));
targetReached = ((aveFlowAfter + aveFlowBefore) / 2) > testParams.TargetQ;
detected = (aveFreqAfter < aveFreqBefore * (1.0f - testParams.DetectionThreshold));
targetReached = ((aveFlowAfter + aveFlowBefore) / 2.0f) > testParams.TargetQ;
}
else
{
/// fall
detected = (aveFreqAfter > (aveFreqBefore + testParams.OffsetPulsesFreq) * (1 + testParams.DetectionThreshold));
targetReached = ((aveFlowAfter + aveFlowBefore) / 2) < testParams.TargetQ;
detected = (aveFreqAfter > (aveFreqBefore + testParams.OffsetPulsesFreq) * (1.0f + testParams.DetectionThreshold));
targetReached = ((aveFlowAfter + aveFlowBefore) / 2.0f) < testParams.TargetQ;
}
}
@@ -1,40 +0,0 @@
///
/// Copyright (c) 2019 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using log4net;
using Config.Entities;
namespace TBF.BenchControl.TestMethods.DiverterTest
{
public class Component : ComponentBase, GenericDevices.ITestMethod
{
private static readonly ILog log = LogManager.GetLogger(typeof(Component));
public override string ToString()
{
return string.Format("{0}({1})", this.GetType().Namespace.Substring(17), Cfg.ToString(1));
}
public bool CanTest(MetersKind meters) { return meters == MetersKind.Single; }
public bool DoTransitions() { return true; }
readonly TestMethodCfg testMethodCfg;
public Component()
{
}
public Component(Generic.IComponentCfg cfg)
: base(cfg)
{
testMethodCfg = cfg as TestMethodCfg;
log.Debug(this.ToString());
}
public IList<Event> Execute(Test test, int repetNr, bool isLastRepetition)
{
return (new DiverterTestSeq()).Execute(test, repetNr, isLastRepetition, testMethodCfg.TestParams);
}
}
}
@@ -1,885 +0,0 @@
///
/// Copyright (c) 2019 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using System.Text;
using log4net;
using TBF.BenchControl;
using TBF.Boxes;
using TBF.Resources;
using TBF.UiBridge;
using TBF.BenchControl.GenericDevices;
namespace TBF.BenchControl.TestMethods.DiverterTest
{
public class DiverterTestSeq : Sequences.SequenceBase
{
private static readonly ILog log = LogManager.GetLogger(typeof(DiverterTestSeq));
/// <summary>
/// Flying start mass collection method sequence
/// </summary>
/// <param name="test">Test entity</param>
/// <returns>
/// Event.Done . . . . . . . OK
/// Event.UiCmdStop . . . . Stopped by the user using the on-screen button STOP
/// Event.OpArgumentError . Target flow is out of range
/// Event.Error . . . . . . Unspecified error
/// </returns>
public IList<Event> Execute(Config.Entities.Test test, int repetitionNr, bool isLastRepetition, TestParams testParams)
{
IScale scale = outPath.Scale as IScale;
if (scale == null)
{
Bridge.OnError(this, Strings.Missing_a_scale);
return new List<Event> { Event.ConfigurationError }; /// or Event.UiCmdStop ???
}
int rangeIx = 0; /// Default range, used for non-Elde flowmeters
if (outPath.FlowMeter is Elde.FlowMeter.FlowMeter)
{
Elde.FlowMeter.FlowMeter eldeFM = outPath.FlowMeter as Elde.FlowMeter.FlowMeter;
rangeIx = -1; /// Indicates invalid range
for (int r = 0; r <= 5; r++)
{
if (eldeFM.RangeEnabled(r) && eldeFM.GetTempLo(r) <= test.TempLimLo
&& eldeFM.GetTempHi(r) >= test.TempLimHi)
{
rangeIx = r;
}
}
if (rangeIx == -1)
{
Bridge.OnError(this, Strings.Flow_meter_temperature_range_does_not_fit_this_test_conditions);
return new List<Event> { Event.ConfigurationError }; /// or Event.UiCmdStop ???
}
}
if (test.Volume > scale.Capacity * Constants.TankFullFactor)
{
Bridge.OnError(this, Strings.Test_volume_exceeds_the_scale_capacity);
return new List<Event> { Event.ConfigurationError };
}
IList<Event> e; /// Events from currently running operations
Event retVal = Event.Done;
Elde.ControlBoardDev cBrd = StateMachine.ControlBoard;
int tMass1 = 0;
int tMass2 = 0;
checkUiOp = new Operations.CheckUIOp(true); /// Runs in more then one state
processDataLoggingOp = new TBF.BenchControl.Operations.ProcessDataLoggingOp(processDataLogger, this);
int[] filters = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 };
if (sensPath != null && sensPath.RegisterReaders != null)
{
foreach (var rr in sensPath.RegisterReaders)
{
TBF.BenchControl.Elde.RegisterReader.RegisterReader eldeRR = rr as TBF.BenchControl.Elde.RegisterReader.RegisterReader;
if ((eldeRR != null) && (eldeRR.Position >= 1) && (eldeRR.Position <= 8))
{
filters[eldeRR.Position - 1] = eldeRR.Filter;
}
}
}
cBrd.SetFiltersPidShortPulses(filters, outPath.PidCoef, (test.TolerRed == 0) ? 0 : 1);
IList<IOperation> readTempPressOps = new List<IOperation>();
if(benchPath.TempMtrUp != null) readTempPressOps.Add(benchPath.TempMtrUp.ReadTempOp(ref TempUp));
if(benchPath.TempMtrDown != null) readTempPressOps.Add(benchPath.TempMtrDown.ReadTempOp(ref TempDown));
if(outPath.TempDiv != null) readTempPressOps.Add(outPath.TempDiv.ReadTempOp(ref TempDiv));
if(benchPath.PressMtrUp != null) readTempPressOps.Add(benchPath.PressMtrUp.ReadPressureOp(ref PressUp));
if(benchPath.PressMtrDown != null) readTempPressOps.Add(benchPath.PressMtrDown.ReadPressureOp(ref PressDown));
if(benchPath.PressMtrDelta != null) readTempPressOps.Add(benchPath.PressMtrDelta.ReadPressureOp(ref PressDelta));
FloatBox switchTimeStart = new FloatBox(0.001f); /// in seconds, initial value is 1 ms
FloatBox switchTimeEnd = new FloatBox(0.001f); /// in seconds, initial value is 1 ms
LtrPerRefPulse = outPath.FlowMeter.LtrPerPulse;
int totalPulses = (int)(test.Volume / LtrPerRefPulse + 0.5f);
//====================================
loop:
/// Read pressure and temperature once before calling Bridge.OnTestSelected(...)
State.Create(string.Format("{0}({1}) : Measuring process data", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperations(readTempPressOps)
.EnterState();
do {
e = StateMachine.WaitRunDevsRunOps();
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
}
while (e.Contains(Event.Busy));
/// Start the test, initialize test results
Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, null, totalPulses));
string testName = Results.Utils.GetTestName(test.Name, test.Repeats, repetitionNr);
TestStartTime = DateTime.Now;
//------------------------------------------------
Bridge.OnActivity(this, Strings.Checking_tank_capacity);
//------------------------------------------------
bool drainTheTank = test.DoDraining;
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(string.Format("{0}({1}) : Checking available tank capacity", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperations(readTempPressOps)
.AddOperation(scale.ReadMassOp(ref Mass))
.EnterState();
do {
e = StateMachine.WaitRunDevsRunOps();
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 >= scale.Capacity * Constants.TankFullFactor)
{
drainTheTank = true;
}
}
///
if (drainTheTank)
{
#if BERLIN || SENTEC
switch (DrainTheTank(outPath.Scale, readTempPressOps))
{
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}) : Open the drain valve", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperation(StateMachine.ControlBoard.SetValvesOp(scale.DrainValve, null))
.AddOperations(readTempPressOps)
.EnterState();
do {
e = StateMachine.WaitRunDevsRunOps();
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
}
while (e.Contains(Event.ValvesBusy));
#endif
}
//------------------------------------------------
Bridge.OnActivity(this, Strings.Starting_the_pump);
//------------------------------------------------
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(string.Format("{0}({1}) : Starting the pump", test.Method, test.Name))
.AddOperation(checkUiOp)
// .AddOperation(new Operations.SetAllRegulValvesOp(inPath.RegulValves, inPath.RegulValvesPct, 60))
.AddOperations(readTempPressOps)
.AddOperation(inPath.Pump != null ? cBrd.SetValvesOp(inPath.Pump, null) : null)
.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; }
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
}
while (e.Contains(Event.ValvesBusy) /* || !e.Contains(Event.AllPositionsReached)*/);
if (test.TimePump2StartV > 0)
{
State.Create(string.Format("{0}({1}) : Waiting after the pump started", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperation(new Operations.TimerOp(test.TimePump2StartV))
.AddOperations(readTempPressOps)
.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.TimerExpired));
}
if (benchPath.StopBFValve != null)
{
State.Create(string.Format("{0}({1}) : Opening the stop backflow valve", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperation(StateMachine.ControlBoard.SetValvesOp(benchPath.StopBFValve, null))
.AddOperations(readTempPressOps)
.EnterState();
do {
e = StateMachine.WaitRunDevsRunOps();
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
}
while (!e.Contains(Event.ValvesSet));
}
if (test.TimeBeforeFlow > 0)
{
State.Create(string.Format("{0}({1}) : Waiting before flow setting process starts", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperation(new Operations.TimerOp(test.TimeBeforeFlow))
.AddOperations(readTempPressOps)
.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.TimerExpired));
}
setting_flow:
//------------------------------------------------
Bridge.OnActivity(this, Strings.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, RefFlow, FlowSettingTimeoutSec))
.AddOperations(readTempPressOps)
.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.OpArgumentError)) { retVal = Event.OpArgumentError; goto stopTest; }
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
if (e.Contains(Event.RegulValveTimeOut))
{
Bridge.OnError(this, Strings.Flow_adjustment_failed);
retVal = Event.RecoverableError;
goto stopTest;
}
if (e.Contains(Event.Next)) goto flow_set;
}
while (!e.Contains(Event.FlowReached));
flow_set:
int flowSetTime = StateMachine.Time - flowSetTime0;
double currentFlow = RefFlow.Val;
if (test.DoControlWaterTemp && (benchPath.TempMtrUp != null) && (benchPath.TempMtrDown != null))
{
//---------------------------------------------------
Bridge.OnActivity(this, Strings.Setting_temperature);
//---------------------------------------------------
State.Create(string.Format("{0}({1}) : Wait until the water temperature is within limits", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperations(readTempPressOps)
.EnterState();
do {
e = StateMachine.WaitRunDevsRunOps();
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
if (e.Contains(Event.Next)) goto temperature_set;
if ((test.TempLimLo <= TempUp.Val) && (TempUp.Val <= test.TempLimHi) &&
(test.TempLimLo <= TempDown.Val) && (TempDown.Val <= test.TempLimHi))
{
goto temperature_set;
}
}
while (true);
}
temperature_set:
///
/// Prepare cameras, ROI-s and measurementOperations
///
/// Find successfully detected ROI-s
IList<GenericDevices.IRoi> rois = new List<GenericDevices.IRoi>();
foreach (var rr in sensPath.RegisterReaders)
{
GenericDevices.IRoi cameraRoI = rr as GenericDevices.IRoi;
if ((cameraRoI != null) && cameraRoI.Detected)
{
rois.Add(cameraRoI);
}
}
/// Find cameras
IList<GenericDevices.ICamera> cameras = new List<GenericDevices.ICamera>();
foreach (var roi in rois)
{
if (roi.Camera != null && !cameras.Contains(roi.Camera))
{
cameras.Add(roi.Camera);
roi.Camera.ClearRoiParams();
}
}
/// Register ROI-parameters to cameras
foreach (var roi in rois) roi.RegisterRoiToCamera();
/// Prepare measurementOperations
IList<IOperation> measureOperations = new List<IOperation>();
foreach (var camera in cameras) measureOperations.Add(camera.MeasurementOp());
if (drainTheTank)
{
//------------------------------------------------
Bridge.OnActivity(this, Strings.Closing_the_tank);
//------------------------------------------------
///
/// Make sure tank draining completed
///
switch (DrainTheTank(scale, readTempPressOps))
{
case Event.Error: { retVal = Event.Error; goto stopTest; }
case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; }
}
drainTheTank = false;
}
else
{
/// Close the drain valve anyway
State.Create(string.Format("{0}({1}) : Close the drain valve", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperations(readTempPressOps)
.AddOperation(StateMachine.ControlBoard.SetValvesOp(null, scale.DrainValve))
.EnterState();
do {
e = StateMachine.WaitRunDevsRunOps();
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
}
while (e.Contains(Event.ValvesBusy));
}
//------------------------------------------------
Bridge.OnActivity(this, Strings.Measuring_the_weight);
//------------------------------------------------
if (test.TimeFlow2Mass > 0)
{
State.Create(string.Format("{0}({1}) : Waiting before 1st mass measurement", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperations(readTempPressOps)
.AddOperation(new Operations.TimerOp(test.TimeFlow2Mass))
.EnterState();
do {
e = StateMachine.WaitRunDevsRunOps();
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
if (TestAndLogUiCmdStop(test,e)) { retVal = Event.UiCmdStop; goto stopTest; }
}
while (!e.Contains(Event.TimerExpired));
}
LogProcessDataTestInfo(processDataLogger, test.Procedure.Name, test.Name);
LogProcessDataHeader(processDataLogger, "Start mass");
State.Create(string.Format("{0}({1}) : Measuring the start mass", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperations(measureOperations)
.AddOperation(processDataLoggingOp)
.AddOperation(scale.ReadStableMassOp(ref StartMass, test.MassRepeats, test.MassSpread, test.MassMethod))
.AddOperations(readTempPressOps)
.AddOperation(new Operations.TimerOp(StableMassMsrmntTimeoutSec))
.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.TimerExpired))
{
Bridge.OnError(this, Strings.Mass_measurement_timeout);
retVal = Event.RecoverableError;
goto stopTest;
}
}
while (!e.Contains(Event.BalanceDone));
Mass.Val = StartMass.Val;
tMass1 = StateMachine.Time;
log.WarnFormat("Start mass = {0}kg", StartMass);
///
/// Initialize cumulated reference and water metert pulses
///
int[] cumulativeEtPulses = new int[Config.Data.WMsCount + 1]; /// 0 .. Config.Data.WMsCount
int[] cumulativeWMPulses = new int[Config.Data.WMsCount + 1]; /// 1 .. Config.Data.WMsCount
double[] cumulativeTestTime = new double[Config.Data.WMsCount + 1]; /// 0 .. Config.Data.WMsCount
for (int i = 0; i <= Config.Data.WMsCount; i++)
{
cumulativeEtPulses[i] = 0;
if (i > 0) cumulativeWMPulses[i] = 0;
cumulativeTestTime[i] = 0;
}
StartNewStatistics(StateMachine.Time, BatchRslts.Batch.BatchNr, test.Name, repetitionNr, 0);
///
/// Diverter test loop
///
for (int divRepetNr = 1; divRepetNr <= testParams.DivRepetitions; divRepetNr++)
{
LogProcessDataHeader(processDataLogger, string.Format("Measurement {0}", divRepetNr + 1));
//------------------------------------------------
Bridge.OnActivity(this, Strings.Test_in_progress);
//------------------------------------------------
State.Create(string.Format("{0}({1}) : Starting the test", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperations(readTempPressOps)
.AddOperations(measureOperations)
.AddOperation(processDataLoggingOp)
.AddOperation(cBrd.StartMeasurementOp(outPath, Elde.TestMethods.Diverter | Elde.TestMethods.Synchro, test.Qfrom, test.Qto, totalPulses/ testParams.DivRepetitions))
.EnterState();
do {
e = StateMachine.WaitRunDevsRunOps();
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
}
while (!e.Contains(Event.MeasurementStarted));
foreach (var rr in sensPath.RegisterReaders)
{
GenericDevices.IHasTestName readerWithTstName = rr as GenericDevices.IHasTestName;
if (readerWithTstName != null)
{
readerWithTstName.TestName = test.Name;
readerWithTstName.TestRepeats = test.Repeats;
readerWithTstName.RepetitionNr = repetitionNr;
}
}
/// Measurement loop - preparation
readRegistersOp = new Operations.ReadMoreRegistersOp(sensPath.RegisterReaders);
int estimtdEndTime = StateMachine.Time + (int)(test.TstTime / testParams.DivRepetitions);
/// Measurement loop - begin
State.Create(string.Format("{0}({1}) : Reading watermeters {2}", test.Method, test.Name, divRepetNr))
.AddOperation(checkUiOp)
.AddOperations(readTempPressOps)
.AddOperations(measureOperations)
.AddOperation(readRegistersOp)
.AddOperation(scale.ReadMassOp(ref Mass))
//.AddOperation(cBrd.ReadDiverterTransitionOp(outPath.Diverter, 2, 4, switchTimeStart, DiverterStart, BatchRslts.Batch.BatchNr, test.Name, repetitionNr))
.AddOperation(cBrd.QueryMeasurementEndOp())
.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; }
//------------------------------------------------
int remainingTime = Math.Max(estimtdEndTime - StateMachine.Time, 0);
if (remainingTime > 60)
{
Bridge.OnActivity(this, string.Format("{0}. {1} ... {2} {3} {4} {5}", divRepetNr, Strings.Test_in_progress, remainingTime / 60, "min", remainingTime % 60, Strings.sec));
}
else
{
Bridge.OnActivity(this, string.Format("{0}. {1} ... {2} s", divRepetNr, Strings.Test_in_progress, remainingTime));
}
//------------------------------------------------
RefFreq.Val = cBrd.ReferenceFreq;
RefFlow.Val = cBrd.ReferenceFlow;
UpdateAllStatistics(StateMachine.Time);
Bridge.OnProcessData(this, new ProcessDataEventArgs(test, repetitionNr, Config.Entities.Progress.Test));
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.Test));
if (e.Contains(Event.MeasurementCompleted)) break;
}
while (!e.Contains(Event.Next)); /// 'Next' button can be used in Debug version
LogProcessDataHeader(processDataLogger, string.Format("Delay {0}", divRepetNr));
if (divRepetNr < testParams.DivRepetitions)
{
/// This is not the last diverter repetition
/// Delay 5s
State.Create(string.Format("{0}({1}) : Delay {2}", test.Method, test.Name, divRepetNr))
.AddOperation(checkUiOp)
.AddOperations(readTempPressOps)
.AddOperation(processDataLoggingOp)
.AddOperation(new Operations.TimerOp(5))
.EnterState();
do
{
e = StateMachine.WaitRunDevsRunOps();
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
}
while (!e.Contains(Event.TimerExpired));
/// Accumulate partial pulses
cumulativeEtPulses[0] += cBrd.EtPulses(0);
cumulativeTestTime[0] += cBrd.TTime;
for (int i = 1; i <= Config.Data.WMsCount; i++)
{
cumulativeEtPulses[i] += cBrd.EtPulses(i);
cumulativeWMPulses[i] += cBrd.WMeterPulses(i);
cumulativeTestTime[i] += cBrd.ImpulseTime(i);
}
}
} /// end for ... diverter test loop
/// Measurement loop - end
test_completed:
StopRecordingStatistics();
State.Create(string.Format("{0}({1}) : Stopping flow regulation", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperations(readTempPressOps)
.AddOperation(cBrd.StopFlowRegulationOp(outPath))
.EnterState();
do {
e = StateMachine.WaitRunDevsRunOps();
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
}
while (!e.Contains(Event.FlowRegulationStopped));
///
/// (Berlin:) Water is stopped immediately after the test and before the 2nd mass measurement in case:
/// - no 'transition sequence after test' is used
/// - this is the last (or the only) test repetition or test is a part of an 'outer loop'
///
#if !CEVAK_200
if (isLastRepetition && transitionAfter == null)
#endif
{
if (inPath.Pump is GenericDevices.IPumpFM) (inPath.Pump as GenericDevices.IPumpFM).TurnOff();
State.Create("SequenceBase : Transition : TestEnd - Default action")
.AddOperation(checkUiOp)
.AddOperations(readTempPressOps)
.AddOperation(new MettlerToledo.KeepReadingMassesOp())
.AddOperation(StateMachine.ControlBoard.SetValvesOp(StateMachine.DefaultValvesOpen, StateMachine.DefaultValvesClose))
.EnterState();
do {
e = StateMachine.WaitRunDevsRunOps();
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
if (TestAndLogUiCmdStop(e)) { retVal = Event.UiCmdStop; goto stopTest; }
}
while (!e.Contains(Event.ValvesSet));
}
//------------------------------------------------
Bridge.OnActivity(this, Strings.Measuring_the_weight);
//------------------------------------------------
State.Create(string.Format("{0}({1}) : Waiting before the 2nd mass measurement", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperations(readTempPressOps)
.AddOperation(scale.ReadMassOp(ref Mass))
.AddOperation(cBrd.ReadDiverterTransitionOp(outPath.Diverter, 2, 4, switchTimeEnd, DiverterEnd, BatchRslts.Batch.BatchNr, test.Name, repetitionNr))
.AddOperation(processDataLoggingOp)
.AddOperation(new Operations.TimerOp(test.TimeStop2Mass))
.EnterState();
do {
e = StateMachine.WaitRunDevsRunOps();
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
if (TestAndLogUiCmdStop(test,e)) { retVal = Event.UiCmdStop; goto stopTest; }
}
while (!e.Contains(Event.TimerExpired) || !e.Contains(Event.BalanceDone));
LogProcessDataHeader(processDataLogger, "End mass");
State.Create(string.Format("{0}({1}) : Measuring the end mass", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperations(readTempPressOps)
.AddOperation(scale.ReadStableMassOp(ref EndMass, test.MassRepeats, test.MassSpread, test.MassMethod))
.AddOperation(new Operations.TimerOp(StableMassMsrmntTimeoutSec))
.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.TimerExpired))
{
Bridge.OnError(this, Strings.Mass_measurement_timeout);
retVal = Event.RecoverableError;
goto stopTest;
}
}
while (!e.Contains(Event.BalanceDone));
///
tMass2 = StateMachine.Time;
log.WarnFormat("End mass = {0}kg", EndMass);
TestEndTime = DateTime.Now;
//------------------------------------------------
Bridge.OnActivity(this, Strings.Test_completed);
//------------------------------------------------
///
/// Accumulate partial pulses from the last diverter repetition
///
cumulativeEtPulses[0] += cBrd.EtPulses(0);
cumulativeTestTime[0] += cBrd.TTime;
for (int i = 1; i <= Config.Data.WMsCount; i++)
{
cumulativeEtPulses[i] += cBrd.EtPulses(i);
cumulativeWMPulses[i] += cBrd.WMeterPulses(i);
cumulativeTestTime[i] += cBrd.ImpulseTime(i);
}
///
/// Populate TestResult data entity with data
///
Results.Entities.TestRslt tstRslt = BatchRslts.GetTestRslt(testName, test.Part);
if (tstRslt != null)
{
UpdateTempPressDensAmb(tstRslt);
/// Main results
tstRslt.MethodClass = TbfComponents.FindComponent(test.Method).ClassName;
tstRslt.StartTime = TestStartTime;
tstRslt.EndTime = TestEndTime;
tstRslt.FlowSetTime = flowSetTime;
tstRslt.TestTime = cumulativeTestTime[0]; /// [s] measurement time
tstRslt.TimeBtwnMassMsrmnts = tMass2 - tMass1;
double massOfEvaporatedWater = (double)tstRslt.TimeBtwnMassMsrmnts * outPath.Scale.EvaporationRate(tstRslt.TempDivMean);
tstRslt.PulsesMaster = Convert.ToDouble(cumulativeEtPulses[0]); /// Pulses of the master flow meter (test total)
tstRslt.MassStartRaw = StartMass.Val;
tstRslt.MassStart = Config.Formulas.CorrectedValue(tstRslt.MassStartRaw, scale.Corrections);
tstRslt.MassEndRaw = EndMass.Val;
tstRslt.MassEnd = Config.Formulas.CorrectedValue(tstRslt.MassEndRaw, scale.Corrections);
tstRslt.FlowMass = 3600.0 * (tstRslt.MassEnd - tstRslt.MassStart + massOfEvaporatedWater) / tstRslt.TestTime; /// [kg/h]
tstRslt.FlowVolume = 3.6 * LtrPerRefPulse * tstRslt.PulsesMaster / tstRslt.TestTime; /// [m3/h]
tstRslt.Buoyancy = Config.Formulas.Buoyancy();
tstRslt.VolumeCTV = 1000 * tstRslt.Buoyancy * (tstRslt.MassEnd - tstRslt.MassStart + massOfEvaporatedWater) / tstRslt.DensityLine; /// [l] commercially true volume
if ((outPath.Diverter != null) && (tstRslt.TestTime > float.Epsilon))
{
tstRslt.TestTimeCorrection = testParams.DivRepetitions * outPath.Diverter.TestTimeCorrection(tstRslt.FlowVolume);
tstRslt.VolumeCTV *= tstRslt.TestTime + tstRslt.TestTimeCorrection;
tstRslt.VolumeCTV /= tstRslt.TestTime;
}
tstRslt.VolumeMaster = LtrPerRefPulse * tstRslt.PulsesMaster; /// [l] volume from the master flow meter
tstRslt.ConstMasterRaw = outPath.FlowMeter.LtrPerPulse; /// Uncorrected master flowmeter coefficient
tstRslt.ConstMasterCorr = outPath.FlowMeter.LtrPerPulseCorrected(tstRslt.FlowVolume, rangeIx); /// Corrected master pulses per liter
tstRslt.ConstMaster = (tstRslt.VolumeMaster == 0) ? tstRslt.ConstMasterCorr : (LtrPerRefPulse * tstRslt.VolumeCTV / tstRslt.VolumeMaster);
/// Calculated master pulses per liter
tstRslt.ErrorMaster = Config.Formulas.ErrorFromVolumes(tstRslt.VolumeMaster, tstRslt.VolumeCTV);
tstRslt.FlowMean = (float)RefFlowStat.Average;
tstRslt.FlowStart = (float)RefFlowStat.First;
tstRslt.FlowEnd = (float)RefFlowStat.Last;
tstRslt.FlowMin = (float)RefFlowStat.Min;
tstRslt.FlowMax = (float)RefFlowStat.Max;
tstRslt.DiverterStart = switchTimeStart.Val;
tstRslt.DivStart10 = 0;
tstRslt.DivStart50 = 0;
tstRslt.DivStart90 = 0;
tstRslt.DiverterEnd = switchTimeEnd.Val;
tstRslt.DivEnd90 = 0;
tstRslt.DivEnd50 = 0;
tstRslt.DivEnd10 = 0;
log.DebugFormat("Diverter switch time [s]: Start: {0}ms ({1} {2} {3}) End: {4}ms ({5} {6} {7})",
(tstRslt.DiverterStart * 1000).ToString("F0"), tstRslt.DivStart10, tstRslt.DivStart50, tstRslt.DivStart90,
(tstRslt.DiverterEnd * 1000).ToString("F0"), tstRslt.DivEnd90, tstRslt.DivEnd50, tstRslt.DivEnd10);
tstRslt.ErrorFlagsMd = (ErrorFlagsComp != null) ? (sbyte)ErrorFlagsComp.Mode : (sbyte)0;
tstRslt.ErrorFlags = (ErrorFlagsComp != null) ? ErrorFlagsComp.GetErrorFlags(tstRslt, true, false, tstRslt.DiverterStart, tstRslt.DiverterEnd) : 0;
///
/// Single meters
///
for (int i = 0; i < BatchRslts.WMPositionsCount; i++)
{
if (!test.IsPartCompatible(Utils.PartNr(i + 1, BatchRslts.Batch.Compound))) continue;
/// MetersKind.Single meters
Results.Entities.MeterTestRslt meterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.Single);
GenericDevices.IRegisterReader regReader = sensPath.RegisterReaders[i];
GenericDevices.IDatastreamReader dstrReader = regReader as GenericDevices.IDatastreamReader;
TestMethods.iPerlCommunication.iPerlHead.IperlHead iPerl = regReader as TestMethods.iPerlCommunication.iPerlHead.IperlHead;
GenericDevices.IRoi cameraRoi = regReader as GenericDevices.IRoi;
if (meterRslt != null && regReader != null)
{
meterRslt.RegReaderType = (int)regReader.RegisterReaderType;
meterRslt.PulsesPerLiter = regReader.PulsesPerLtr;
meterRslt.PulsesMeter = Convert.ToDouble(regReader.WMPulses);
if (dstrReader != null)
{
meterRslt.TimestampStart = dstrReader.TimestampSecStart;
meterRslt.TimestampEnd = dstrReader.NoSamples ? (dstrReader.TimestampSecStart + tstRslt.TestTime) : dstrReader.TimestampSecEnd;
meterRslt.TestTime = meterRslt.TimestampEnd - meterRslt.TimestampStart;
meterRslt.VolumeStart = dstrReader.VolumeLtrStart; /// liter
meterRslt.VolumeEnd = dstrReader.VolumeLtrEnd; /// liter
meterRslt.VolumeMeter = Math.Abs(dstrReader.VolumeLtrEnd - dstrReader.VolumeLtrStart);
meterRslt.VolumeRef = tstRslt.VolumeCTV * meterRslt.TestTime / tstRslt.TestTime;
meterRslt.PulsesMaster = tstRslt.PulsesMaster * meterRslt.TestTime / tstRslt.TestTime;
if (iPerl != null)
{
if (iPerl.ResultCode != 0 && (meterRslt.WaterMeter.ResultCode & (int)Results.Entities.ResultCode.OptoErrorCodeMask) == 0)
{
meterRslt.WaterMeter.ResultCode |= iPerl.ResultCode;
}
#if IPERL
meterRslt.WaterMeter.CalibFactor = iPerl.CalibFactor;
#endif
iPerl.LastTestResult2 = iPerl.LastTestResult; /// Save shift previous test result
iPerl.LastTestResult = meterRslt; /// Save this test result
}
}
else if (cameraRoi != null)
{
meterRslt.TimestampStart = cameraRoi.TimestampStart; /// second
meterRslt.TimestampEnd = cameraRoi.TimestampEnd; /// second
meterRslt.VolumeStart = cameraRoi.VolumeStart; /// liter
meterRslt.VolumeEnd = cameraRoi.VolumeEnd; /// liter
meterRslt.VolumeMeter = cameraRoi.VolumeEnd - cameraRoi.VolumeStart; /// liter
if (meterRslt.VolumeMeter != 0)
{
/// Normal measurement with camera
meterRslt.TestTime = cameraRoi.TimestampEnd - cameraRoi.TimestampStart; /// second
meterRslt.VolumeRef = tstRslt.VolumeCTV * meterRslt.TestTime / tstRslt.TestTime;
meterRslt.PulsesMaster = tstRslt.PulsesMaster * meterRslt.TestTime / tstRslt.TestTime;
}
else
{
/// None or one pulse from the water meter using camera
meterRslt.TestTime = tstRslt.TestTime;
meterRslt.VolumeRef = tstRslt.VolumeCTV;
meterRslt.PulsesMaster = tstRslt.PulsesMaster;
}
}
else
{
meterRslt.PulsesMaster = Convert.ToDouble(cumulativeEtPulses[i + 1]);
meterRslt.VolumeMeter = cumulativeWMPulses[i + 1] * regReader.LtrsPerPulse; /// liter
meterRslt.VolumeStart = 0; /// liter
meterRslt.VolumeEnd = meterRslt.VolumeMeter; /// liter
if (regReader.WMPulses >= 1)
{
/// Normal measurement
meterRslt.TestTime = cumulativeTestTime[i + 1];
meterRslt.VolumeRef = meterRslt.PulsesMaster * tstRslt.ConstMaster; /// liter
}
else
{
/// None or one pulse from the water meter
meterRslt.TestTime = cumulativeTestTime[0];
meterRslt.VolumeRef = tstRslt.VolumeCTV; /// liter
}
}
meterRslt.Error = Config.Formulas.ErrorFromVolumes(meterRslt.VolumeMeter, meterRslt.VolumeRef);
meterRslt.Passed = (meterRslt.Error >= test.GetErrLimLo(tstRslt.VolumeCTV, tstRslt.TestTime) + test.Uncertainty)
&& (meterRslt.Error <= test.GetErrLimHi(tstRslt.VolumeCTV, tstRslt.TestTime) - test.Uncertainty)
&& (tstRslt.ErrorFlags == 0 || tstRslt.ErrorFlagsMode() != Config.Entities.ErrorFlagsMode.On);
meterRslt.TestDone = true;
tstRslt.TestDone = true;
}
}
tstRslt.Components = Results.Entities.Components.UpdateList(BatchRslts.ComponentsList,
new Results.Entities.Components((BenchInfo != null) ? BenchInfo.TestBenchId : 1,
(BenchInfo != null) ? BenchInfo.TestBenchName : "testbench",
inPath.Pump != null ? inPath.Pump.Name : string.Empty,
outPath.FlowMeter != null ? outPath.FlowMeter.Name : string.Empty,
scale != null ? scale.Name : string.Empty,
outPath.RegulValve != null ? outPath.RegulValve.Name : string.Empty,
outPath.Diverter != null ? outPath.Diverter.Name : string.Empty));
/// Update water meter error flags
if (ErrorFlagsComp != null)
{
for (int i = 0; i < BatchRslts.WMPositionsCount; i++)
{
if (BatchRslts.WaterMeters[i] != null)
{
BatchRslts.WaterMeters[i].ErrorFlags = ErrorFlagsComp.GetWMtrErrorFlags(BatchRslts.WaterMeters[i].MeterTestRslts);
}
}
}
/// Update results
Bridge.OnTestCompleted(this, new TestCompletedEventArgs(testName, tstRslt));
}
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.TransitionAfter));
/// Append the results to the CSV-file
allResults.Info(TestResult2CsvLine(testName, test.Part));
stopTest:
StopRecordingStatistics(); /// Make sure graph files are closed
///
/// Quit this sequence
///
if (isLastRepetition || retVal == Event.UiCmdStop || retVal == Event.OpArgumentError
|| retVal == Event.Error || retVal == Event.ConfigurationError)
{
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)) break;
}
while (!e.Contains(Event.PreviousStopped));
}
stopTestWOStoppingDivGateEtc:
return new List<Event> { retVal };
}
}
}
@@ -1,26 +0,0 @@
///
/// Copyright (c) 2019 Sensus Slovensko a.s.
///
using System.Collections.Generic;
using TBF.BenchControl.Generic;
namespace TBF.BenchControl.TestMethods.DiverterTest
{
public class Factory : IComponentFactory
{
public string ClassName { get { return this.GetType().Namespace.Substring(17); } }
public void ResetStaticProperties() { Component.ResetStaticProperties(); }
public IComponent DummyComponent() { return new Component(); }
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new Component(cfg); }
public IComponentCfg DefaultConfig() { return new TestMethodCfg(this.GetType().Namespace.Substring(29), this); }
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
{
return ComponentCfgBase.CreateFromDbEntity(TestMethodCfg.Serializer, component, this);
}
}
}
@@ -1,49 +0,0 @@
///
/// Copyright (c) 2019 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using System.IO;
using System.Xml.Serialization;
using Config.Entities;
using TBF.BenchControl.Generic;
namespace TBF.BenchControl.TestMethods.DiverterTest
{
public class TestMethodCfg : ComponentCfgBase, Generic.IComponentCfg
{
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(TestMethodCfg) })[0];
public override XmlSerializer GetSerializer() { return Serializer; }
public IComponentCfgCtrl GetControl() { return new TestMethodCfgCtrl(); }
/// <summary> Test parameters </summary>
[XmlIgnore]
public TestParams TestParams;
public override IParamsProvider GetRuntimeTestParamsProvider() { return TestParams; }
public override IParamsProvider CreateTestParamsProvider() { return new TestParams(true); }
public override IParamsProvider GetUITestParamsProvider(Test test)
{
return (test.Method == Name) ? base.GetUITestParamsProvider(test) : null;
}
/// Private parameterless constructor invoked by all other (public) constructors
TestMethodCfg()
{
TestParams = new TestParams(true);
}
public TestMethodCfg(string name, IComponentFactory factory)
: this()
{
Name = name;
ParentName = string.Empty;
Factory = factory;
}
public string ToString(int i)
{
return string.Format("Name={0}", Name);
}
}
}
@@ -1,69 +0,0 @@
///
/// Copyright (c) 2019 Sensus Slovensko a.s.
///
using System;
using System.Windows.Forms;
using Config.Entities;
using TBF.BenchControl.Generic;
namespace TBF.BenchControl.TestMethods.DiverterTest
{
public partial class TestMethodCfgCtrl : UserControl, IComponentCfgCtrl
{
public bool ShowMore { get { return false; } }
TestMethodCfg config;
public IComponentCfg Config
{
get { return config as IComponentCfg; }
set
{
config = value as TestMethodCfg;
Redraw();
}
}
public TestMethodCfgCtrl()
{
InitializeComponent();
}
private void EntryFormCfgCtrl_Load(object sender, EventArgs e)
{
Redraw();
}
public void Closing()
{
}
void Redraw()
{
if (config == null) return; /// Control was not loaded, settings were not changed
classNameLabel.Text = config.Factory.ClassName;
nameTextBox.Text = config.Name;
}
public void Unlock()
{
nameTextBox.Enabled = true;
}
public CfgUpdateFlags VerifyCfg(ref string message)
{
CfgUpdateFlags flags = CfgUpdateFlags.None;
return flags;
}
public CfgUpdateFlags UpdateCfg()
{
CfgUpdateFlags flags = CfgUpdateFlags.RestartRqrd;
if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed
config.Name = nameTextBox.Text;
return flags;
}
}
}
@@ -1,86 +0,0 @@
///
/// Copyright (c) 2019 Sensus Slovensko a.s.
///
namespace TBF.BenchControl.TestMethods.DiverterTest
{
partial class TestMethodCfgCtrl
{
/// <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.SuspendLayout();
//
// nameTextBox
//
this.nameTextBox.Enabled = false;
this.nameTextBox.Location = new System.Drawing.Point(137, 57);
this.nameTextBox.Name = "nameTextBox";
this.nameTextBox.Size = new System.Drawing.Size(130, 20);
this.nameTextBox.TabIndex = 5;
//
// nameLabel
//
this.nameLabel.AutoSize = true;
this.nameLabel.Location = new System.Drawing.Point(27, 60);
this.nameLabel.Name = "nameLabel";
this.nameLabel.Size = new System.Drawing.Size(35, 13);
this.nameLabel.TabIndex = 4;
this.nameLabel.Text = "Name";
//
// classNameLabel
//
this.classNameLabel.AutoSize = true;
this.classNameLabel.Location = new System.Drawing.Point(134, 33);
this.classNameLabel.Name = "classNameLabel";
this.classNameLabel.Size = new System.Drawing.Size(83, 13);
this.classNameLabel.TabIndex = 3;
this.classNameLabel.Text = "ComonentName";
//
// BasicPrinterCfgCtrl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.nameTextBox);
this.Controls.Add(this.nameLabel);
this.Controls.Add(this.classNameLabel);
this.Name = "BasicPrinterCfgCtrl";
this.Size = new System.Drawing.Size(300, 200);
this.Load += new System.EventHandler(this.EntryFormCfgCtrl_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;
}
}
@@ -1,120 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
@@ -1,119 +0,0 @@
///
/// Copyright (c) 2019 Sensus Slovensko a.s.
///
using System;
using System.IO;
using System.Xml.Serialization;
using Config.Entities;
using TBF.BenchControl.Generic;
using TBF.Resources;
namespace TBF.BenchControl.TestMethods.DiverterTest
{
public class TestParams : TestParamsBase, IParamsProvider, ITestParams
{
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(TestParams) })[0];
public override XmlSerializer GetSerializer() { return Serializer; }
public int DivRepetitions; /// Duration of the test in [s]
public override void InitializeAll()
{
DivRepetitions = 10;
}
string[] paramNames = new string[]
{
Strings.Repeats_nr_chdr,
};
public override string ParamName(int i) { return paramNames[i]; }
public override int ParamsCount() { return paramNames.Length; }
public override string ToString(int i)
{
switch (i)
{
case 0: return DivRepetitions.ToString();
default: return string.Empty;
}
}
public CfgUpdateFlags UpdateParam(int i, string strValue)
{
switch (i)
{
case 0: DivRepetitions = int.Parse(strValue); return CfgUpdateFlags.None;
default: return CfgUpdateFlags.None;
}
}
public bool ValidateParam(int i, string strValue, out string message)
{
message = string.Empty;
int iDummy;
switch (i)
{
case 0:
if (int.TryParse(strValue, out iDummy) && (iDummy > 0)) return true;
break;
default:
message = "Invalid index";
return false;
}
message = ParamName(i) + " is invalid";
return false;
}
void CopyContentTo(TestParams prms)
{
prms.DivRepetitions = this.DivRepetitions;
}
public IParamsProvider Clone()
{
TestParams pars = new TestParams();
CopyContentTo(pars);
return pars;
}
public override void UpdateFromDbEntity(ComponentTest dbEntity)
{
if (dbEntity == null) return;
try
{
TestParams tmp = Serializer.Deserialize(new StringReader(dbEntity.Parameters)) as TestParams;
testParamsEntity = dbEntity;
componentName = dbEntity.CmpntName;
test = dbEntity.Test;
if (tmp != null) tmp.CopyContentTo(this);
}
catch
{
}
}
/// <summary>
/// Parameterless constructor initializes the parameters
/// </summary>
public TestParams()
{
}
public TestParams(bool initialize)
{
if (initialize) InitializeAll();
}
public TestParams(ComponentTest testParamsEntity, string componentName, Test test)
{
this.testParamsEntity = testParamsEntity;
this.componentName = componentName;
this.test = test;
}
}
}
@@ -68,19 +68,11 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollComparative
}
string vlvNames = (singleTestParams != null) ? singleTestParams.ValveName
: ((compoundTestParams != null) ? compoundTestParams.ValveName
: heatMetersTestParams.ValveName);
IList<IValve> compareValves = new List<IValve>();
///
string[] vlvNamesArr = vlvNames.Split(new char[] { ',', ';' });
foreach (var vlv in vlvNamesArr)
{
IValve valveComp = TbfComponents.FindComponent(vlv.Trim()) as IValve;
if (valveComp != null) compareValves.Add(valveComp);
}
///
if (compareValves.Count == 0)
string vlvName = (singleTestParams != null) ? singleTestParams.ValveName
: ((compoundTestParams != null) ? compoundTestParams.ValveName
: heatMetersTestParams.ValveName);
IValve compareValve = TbfComponents.FindComponent(vlvName) as IValve;
if (compareValve == null)
{
Bridge.OnError(this, Strings.Missing_a_valve_for_comparative_method);
return new List<Event> { Event.ConfigurationError };
@@ -489,7 +481,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollComparative
State.Create(string.Format("{0}({1}) : Activate ref. mass valve", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperations(readTempPressOps)
.AddOperation(StateMachine.ControlBoard.SetValvesOp(compareValves, null))
.AddOperation(StateMachine.ControlBoard.SetValvesOp(compareValve, null))
.AddOperation(scale.ReadMassOp(ref Mass))
.EnterState();
do {
@@ -555,7 +547,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollComparative
State.Create(string.Format("{0}({1}) : Deactivate ref. mass valve", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperations(readTempPressOps)
.AddOperation(StateMachine.ControlBoard.SetValvesOp(null, compareValves))
.AddOperation(StateMachine.ControlBoard.SetValvesOp(null, compareValve))
.AddOperation(scale.ReadMassOp(ref Mass))
.EnterState();
do {
@@ -12,10 +12,7 @@ namespace TBF.BenchControl.TestMethods.PMaxTest
public class TestMethod : ComponentBase, GenericDevices.ITestMethod
{
private static readonly ILog log = LogManager.GetLogger(typeof(TestMethod));
public override string ToString()
{
return string.Format("{0}({1})", this.GetType().Namespace.Substring(17), Cfg.ToString(1));
}
public override string ToString() { return string.Format("TestMethods.PMaxTest({0})", Cfg.ToString(1)); }
public bool CanTest(MetersKind meters) { return true; }
public bool DoTransitions() { return true; }
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2019 Sensus Slovensko a.s.
/// Copyright (c) 2018 Sensus Slovensko a.s.
///
using System.Collections.Generic;
using TBF.BenchControl.Generic;
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2019 Sensus Slovensko a.s.
/// Copyright (c) 2018 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
@@ -33,36 +33,14 @@ namespace TBF.BenchControl.TestMethods.SensitivityTest
{
if (debugLevel == Config.Entities.DebugMode.Simulate)
{
return new List<Event> { Event.Done }; /// TODO: Test method simulation
/// TODO: Test method simulation
return new List<Event> { Event.Done };
}
int rangeIx = 0; /// Default range, used for non-Elde flowmeters
if (outPath.FlowMeter is Elde.FlowMeter.FlowMeter)
{
Elde.FlowMeter.FlowMeter eldeFM = outPath.FlowMeter as Elde.FlowMeter.FlowMeter;
rangeIx = -1; /// Indicates invalid range
for (int r = 0; r <= 5; r++)
{
if (eldeFM.RangeEnabled(r) && eldeFM.GetTempLo(r) <= test.TempLimLo
&& eldeFM.GetTempHi(r) >= test.TempLimHi)
{
rangeIx = r;
}
}
if (rangeIx == -1)
{
Bridge.OnError(this, Strings.Flow_meter_temperature_range_does_not_fit_this_test_conditions);
return new List<Event> { Event.ConfigurationError }; /// or Event.UiCmdStop ???
}
}
IList<Event> e; /// Events from currently running operations
Event retVal = Event.Done;
IList<Event> e; /// Events from currently running operations
Elde.ControlBoardDev cBrd = StateMachine.ControlBoard;
checkUiOp = new Operations.CheckUIOp(true); /// Runs in more then one state
processDataLoggingOp = new TBF.BenchControl.Operations.ProcessDataLoggingOp(processDataLogger, this, false);
int[] filters = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 };
@@ -95,8 +73,8 @@ namespace TBF.BenchControl.TestMethods.SensitivityTest
float switchTimeStart = 0.001f; /// in seconds, original vale is 1 ms
float switchTimeEnd = 0.001f; /// in seconds, original vale is 1 ms
/// This is to calculate increments of WM pulses
/// Specific for combined meters
int[] lastWMPulses = new int[Config.Data.WMsCount];
//--------------------------------
@@ -119,26 +97,15 @@ namespace TBF.BenchControl.TestMethods.SensitivityTest
/// 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);
/// Meters path is required for the following:
readRegistersOp = new Operations.ReadMoreRegistersOp(sensPath.RegisterReaders);
//====================================
loop:
/// Read pressure and temperature once before calling Bridge.OnTestSelected(...)
State.Create(string.Format("{0}({1}) : Measuring process data", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperations(readTempPressOps)
.EnterState();
do
{
e = StateMachine.WaitRunDevsRunOps();
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
}
while (e.Contains(Event.Busy));
/// Start the test, initialize test results
/// Start the test, initialize test results
Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, heatMetersPath, totalPulses));
string testName = Results.Utils.GetTestName(test.Name, test.Repeats, repetitionNr);
TestStartTime = DateTime.Now;
@@ -186,7 +153,7 @@ namespace TBF.BenchControl.TestMethods.SensitivityTest
//------------------------------------------------
Bridge.OnActivity(this, Strings.Switching_flow_detection);
//------------------------------------------------
State.Create(string.Format("{0}({1}) : Start the pump", test.Method, test.Name))
State.Create(string.Format("{0}({1}) : Starting the pump", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperations(readTempPressOps)
.AddOperations(measureOperations)
@@ -201,8 +168,8 @@ namespace TBF.BenchControl.TestMethods.SensitivityTest
}
while (!e.Contains(Event.ValvesSet));
State.Create(string.Format("{0}({1}) : Set the initial flow", test.Method, test.Name))
//--------------------------------
State.Create(string.Format("{0}({1}) : Setting the initial flow", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperations(readTempPressOps)
.AddOperations(measureOperations)
@@ -212,12 +179,11 @@ namespace TBF.BenchControl.TestMethods.SensitivityTest
e = StateMachine.WaitRunDevsRunOps();
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.SwitchingFlowDetection));
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
if (TestAndLogUiCmdStop(test,e)) goto stopTest;
if (e.Contains(Event.RegulValveTimeOut))
{
Bridge.OnError(this, Strings.Flow_adjustment_failed);
retVal = Event.RecoverableError;
goto stopTest;
goto error;
}
if (e.Contains(Event.Next)) goto init_flow_set;
}
@@ -226,8 +192,8 @@ namespace TBF.BenchControl.TestMethods.SensitivityTest
//--------------------------------
switch (ReadRegistersTempPressAmbient(measureOperations, false))
{
case Event.Error: { retVal = Event.Error; goto stopTest; }
case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; }
case Event.Error: goto error;
case Event.UiCmdStop: goto stopTest;
}
@@ -241,177 +207,136 @@ namespace TBF.BenchControl.TestMethods.SensitivityTest
/// Allocate detection buffers
double[] flowsForDetection = new double[DetectionBufferSize];
double[,] pulseFreqsForDetection = new double[Config.Data.WMsCount, DetectionBufferSize];
double[] pulseFreqsForDetection = new double[DetectionBufferSize];
/// Current values
flowsForDetection[0] = RefFlow.Val;
for (int i = 0; i < Config.Data.WMsCount; i++) pulseFreqsForDetection[i, 0] = 0;
pulseFreqsForDetection[0] = 0.0f;
int startTime = StateMachine.Time;
int lastTime = StateMachine.Time;
/// Detection parameters
float rvPulse = (testParams.TargetQ > (test.Qfrom + test.Qto) / 2.0f) ? 0.05f : -0.05f; // rise or fall?
rvPulse *= (100.0f * testParams.RateOfChange);
bool[] detected = new bool[Config.Data.WMsCount];
double[] detectedFlow = new double[Config.Data.WMsCount];
for (int i = 0; i < detectedFlow.Length; i++)
{
detected[i] = false;
detectedFlow[i] = 0;
}
bool allDetected = false;
bool detected = false;
bool targetReached = false;
double detectedFlow = 0;
int detectionStartTime = StateMachine.Time;
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.SwitchingFlowDetection));
do
{
//--------------------------------
{
//--------------------------------
State.Create(string.Format("{0}({1}) : Changing the RV position", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperation(checkUiOp)
.AddOperations(readTempPressOps)
.AddOperations(measureOperations)
.AddOperation(outPath.RegulValve.ChangeRegulValvePositionOp(rvPulse))
.EnterState();
do
{
e = StateMachine.WaitRunDevsRunOps();
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.SwitchingFlowDetection));
.EnterState();
do {
e = StateMachine.WaitRunDevsRunOps();
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.SwitchingFlowDetection));
if (TestAndLogUiCmdStop(test, e)) goto stopTest;
}
if (TestAndLogUiCmdStop(test,e)) goto stopTest;
}
while (!e.Contains(Event.PositionReached));
// Last pulses are kept to calculate differences
for (int i = 0; i < Config.Data.WMsCount; i++) lastWMPulses[i] = RegisterReaders[i].WMPulses;
// Shift data in the detection buffers
for (int i = DetectionBufferSize - 2; i >= 0; i--)
{
/// Last pulses are kept to calculate differences
for (int i = 0; i < Config.Data.WMsCount; i++)
{
if (RegisterReaders[i] != null) lastWMPulses[i] = RegisterReaders[i].WMPulses;
}
/// Shift data in the detection buffers
for (int j = DetectionBufferSize - 2; j >= 0; j--)
{
flowsForDetection[j + 1] = flowsForDetection[j];
for (int i = 0; i < Config.Data.WMsCount; i++) pulseFreqsForDetection[i, j+1] = pulseFreqsForDetection[i, j];
}
switch (ReadRegistersTempPressAmbient(measureOperations, false))
{
case Event.Error: { retVal = Event.Error; goto stopTest; }
case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; }
}
/// TODO: !!! The following can only be done for compound meters
flowsForDetection[0] = cBrd.ReferenceFreq * outPath.FlowMeter.NominalFlow / 2000.0f;
for (int i = 0; i < Config.Data.WMsCount; i++)
{
double diff = (RegisterReaders[i] != null) ? (RegisterReaders[i].WMPulses - lastWMPulses[i]) : 0;
pulseFreqsForDetection[i, 0] = diff / (double)(StateMachine.Time - lastTime);
}
lastTime = StateMachine.Time;
flowsForDetection[i+1] = flowsForDetection[i];
pulseFreqsForDetection[i+1] = pulseFreqsForDetection[i];
}
if (StateMachine.Time - detectionStartTime > 15)
{
if ((flowsForDetection[0] > 0) && (flowsForDetection[DetectionBufferSize - 1] > 0))
{
double[] flowBefore = new double[DetectionKernelSize];
double[] flowAfter = new double[DetectionKernelSize];
for (int j = 0; j < DetectionKernelSize; j++)
{
flowBefore[j] = flowsForDetection[DetectionBufferSize - DetectionKernelSize + j];
flowAfter[j] = flowsForDetection[j];
}
switch (ReadRegistersTempPressAmbient(measureOperations, false))
{
case Event.Error: goto error;
case Event.UiCmdStop: goto stopTest;
}
Array.Sort(flowBefore);
Array.Sort(flowAfter);
flowBefore[0] = 0;
flowAfter[0] = 0;
flowBefore[DetectionKernelSize - 1] = 0;
flowAfter[DetectionKernelSize - 1] = 0;
///
double aveFlowBefore = 0;
double aveFlowAfter = 0;
foreach (var f in flowBefore) aveFlowBefore += f;
foreach (var f in flowAfter) aveFlowAfter += f;
aveFlowBefore /= (double)(DetectionKernelSize - 2);
aveFlowAfter /= (double)(DetectionKernelSize - 2);
int time = StateMachine.Time;
UiBridge.Bridge.OnLog(this, string.Format("Time={0}: Flow{1}, aveFlowB={2}, aveFlowA={3}\r\n",
StateMachine.Time - startTime,
flowsForDetection[0].ToString("F2"),
aveFlowBefore.ToString("F2"),
aveFlowAfter.ToString("F2")));
/// TODO: !!! The following can only be done for compound meters
int diff = RegisterReaders[(test.Part - 1) * 2 + 1].WMPulses - lastWMPulses[(test.Part - 1) * 2 + 1];
flowsForDetection[0] = cBrd.ReferenceFreq * outPath.FlowMeter.NominalFlow / 2000.0f;
pulseFreqsForDetection[0] = (float)diff / (float)(time - lastTime);
lastTime = StateMachine.Time;
for (int i = 0; i < Config.Data.WMsCount; i++)
{
if ((BatchRslts.WaterMeters[i] != null) && !BatchRslts.WaterMeters[i].Disabled && (RegisterReaders[i] != null) && !detected[i])
{
double[] freqBefore = new double[DetectionKernelSize];
double[] freqAfter = new double[DetectionKernelSize];
for (int j = 0; j < DetectionKernelSize; j++)
{
freqBefore[j] = pulseFreqsForDetection[i, DetectionBufferSize - DetectionKernelSize + j];
freqAfter[j] = pulseFreqsForDetection[i, j];
}
/// Do NOT skip the smallest and the largest flow
//Array.Sort(freqBefore);
//Array.Sort(freqAfter);
//freqBefore[0] = 0;
//freqAfter[0] = 0;
//freqBefore[DetectionKernelSize - 1] = 0;
//freqAfter[DetectionKernelSize - 1] = 0;
///
double aveFreqBefore = 0;
double aveFreqAfter = 0;
foreach (var f in freqBefore) aveFreqBefore += f;
foreach (var f in freqAfter) aveFreqAfter += f;
aveFreqBefore /= (double)(DetectionKernelSize);
aveFreqAfter /= (double)(DetectionKernelSize);
if (StateMachine.Time - detectionStartTime > 15)
{
if ((flowsForDetection[0] > 0) && (flowsForDetection[DetectionBufferSize - 1] > 0))
{
double[] flowBefore = new double[DetectionKernelSize];
double[] flowAfter = new double[DetectionKernelSize];
double[] freqBefore = new double[DetectionKernelSize];
double[] freqAfter = new double[DetectionKernelSize];
for (int i = 0; i < DetectionKernelSize; i++)
{
flowBefore[i] = flowsForDetection[DetectionBufferSize - DetectionKernelSize + i];
freqBefore[i] = pulseFreqsForDetection[DetectionBufferSize - DetectionKernelSize + i];
flowAfter[i] = flowsForDetection[i];
freqAfter[i] = pulseFreqsForDetection[i];
}
Array.Sort(flowBefore);
Array.Sort(flowAfter);
Array.Sort(freqBefore);
Array.Sort(freqAfter);
flowBefore[0] = 0;
flowAfter[0] = 0;
//freqBefore[0] = 0;
//freqAfter[0] = 0;
flowBefore[DetectionKernelSize - 1] = 0;
flowAfter[DetectionKernelSize - 1] = 0;
//freqBefore[DetectionKernelSize - 1] = 0;
//freqAfter[DetectionKernelSize - 1] = 0;
double aveFlowBefore = 0;
double aveFlowAfter = 0;
double aveFreqBefore = 0;
double aveFreqAfter = 0;
foreach (var f in flowBefore) aveFlowBefore += f;
foreach (var f in flowAfter) aveFlowAfter += f;
foreach (var f in freqBefore) aveFreqBefore += f;
foreach (var f in freqAfter) aveFreqAfter += f;
aveFlowBefore /= (double)(DetectionKernelSize - 2);
aveFlowAfter /= (double)(DetectionKernelSize - 2);
aveFreqBefore /= (double)(DetectionKernelSize);
aveFreqAfter /= (double)(DetectionKernelSize);
UiBridge.Bridge.OnLog(this, string.Format(" WM{0}: pulseFreq={1}, aveFreqB={2}, aveFreqA={3}\r\n",
BatchRslts.WaterMeters[i].WMPosition,
pulseFreqsForDetection[i, 0].ToString("F2"),
aveFreqBefore.ToString("F2"),
aveFreqAfter.ToString("F2")));
UiBridge.Bridge.OnLog(this, string.Format("time={0}, flow{1}, aveFlowB={2}, aveFlowA={3}, pulseFreq={4}, aveFreqB={5}, aveFreqA={6}\r\n",
time - startTime,
flowsForDetection[0].ToString("F2"),
aveFlowBefore.ToString("F2"),
aveFlowAfter.ToString("F2"),
pulseFreqsForDetection[0].ToString("F2"),
aveFreqBefore.ToString("F2"),
aveFreqAfter.ToString("F2")));
//detectedFlow[i] = (aveFlowBefore + aveFlowAfter) / 2;
detectedFlow[i] = aveFlowBefore;
//detectedFlow = (aveFlowBefore + aveFlowAfter) / 2.0f;
detectedFlow = aveFlowBefore;
if (rvPulse > 0)
{
/// rise
detected[i] = (aveFreqAfter < aveFreqBefore * (1 - testParams.DetectionThreshold));
targetReached = ((aveFlowAfter + aveFlowBefore) / 2) > testParams.TargetQ;
}
else
{
/// fall
detected[i] = (aveFreqAfter > aveFreqBefore * (1 + testParams.DetectionThreshold));
targetReached = ((aveFlowAfter + aveFlowBefore) / 2) < testParams.TargetQ;
}
}
}
if (rvPulse > 0)
{
detected = (aveFreqAfter < aveFreqBefore * (1.0f - testParams.DetectionThreshold));
targetReached = ((aveFlowAfter + aveFlowBefore) / 2.0f) > testParams.TargetQ;
}
else
{
detected = (aveFreqAfter > aveFreqBefore * (1.0f + testParams.DetectionThreshold));
targetReached = ((aveFlowAfter + aveFlowBefore) / 2.0f) < testParams.TargetQ;
}
}
}
}
while (!detected && !targetReached);
allDetected = true;
for (int i = 0; i < Config.Data.WMsCount; i++)
{
if ((BatchRslts.WaterMeters[i] != null) && !BatchRslts.WaterMeters[i].Disabled && (RegisterReaders[i] != null) && !detected[i]) allDetected = false;
}
}
}
}
while (!allDetected && !targetReached);
for (int i = 0; i < Config.Data.WMsCount; i++)
{
UiBridge.Bridge.OnLog(this, string.Format("detected flow[{0}]={1}\r\n", i+1, detectedFlow[i].ToString("F4")));
}
Qrise = detectedFlow;
UiBridge.Bridge.OnLog(this, string.Format("detected flow={0}\r\n", detectedFlow.ToString("F2")));
int flowSetTime1 = StateMachine.Time;
@@ -504,10 +429,16 @@ namespace TBF.BenchControl.TestMethods.SensitivityTest
{
meterRslt.RegReaderType = (int)regReader.RegisterReaderType;
meterRslt.PulsesPerLiter = regReader.PulsesPerLtr;
meterRslt.Error = detectedFlow[i];
meterRslt.Passed = (tstRslt.TestData.ErrLimLo <= detectedFlow[i]) && (detectedFlow[i] <= tstRslt.TestData.ErrLimHi);
meterRslt.Passed = (Qrise <= test.Qto) && (tstRslt.ErrorFlags == 0 || tstRslt.ErrorFlagsMode() != Config.Entities.ErrorFlagsMode.On);
meterRslt.TestDone = true;
tstRslt.TestDone = true;
if (Qrise != 0)
{
BatchRslts.WaterMeters[i].QRise = Qrise;
}
BatchRslts.WaterMeters[i].QFall = 0;
}
}
@@ -556,38 +487,43 @@ namespace TBF.BenchControl.TestMethods.SensitivityTest
.EnterState();
do {
e = StateMachine.WaitRunDevsRunOps();
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
if (e.Contains(Event.Error)) goto error;
}
while (!e.Contains(Event.ValvesSet) || ((inPath.Pump is GenericDevices.IPumpFM) && !e.Contains(Event.TurnPumpOnOffDone)));
}
return new List<Event> { Event.Done };
//====================================
stopTest:
StopRecordingStatistics(); /// Make sure graph files are closed
State.Create(string.Format("{0}({1}) : User selected STOP -> Closing the valves", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperation((inPath != null && inPath.Pump is GenericDevices.IPumpFM) ? (inPath.Pump as GenericDevices.IPumpFM).TurnOffOp() : null)
.AddOperation(cBrd.SetValvesOp(StateMachine.DefaultValvesOpen, StateMachine.DefaultValvesClose))
.EnterState();
do {
e = StateMachine.WaitRunDevsRunOps();
if (e.Contains(Event.Error)) goto error;
}
while (!e.Contains(Event.ValvesSet));
///
/// Quit this sequence
///
if (isLastRepetition || retVal == Event.UiCmdStop || retVal == Event.OpArgumentError
|| retVal == Event.Error || retVal == Event.ConfigurationError)
{
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)) break;
}
while (!e.Contains(Event.PreviousStopped));
}
return new List<Event> { Event.UiCmdStop };
stopTestWOStoppingDivGateEtc:
//====================================
error:
State.Create(string.Format("{0}({1}) : close_before_error", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperation((inPath != null && inPath.Pump is GenericDevices.IPumpFM) ? (inPath.Pump as GenericDevices.IPumpFM).TurnOffOp() : null)
.AddOperation(cBrd.SetValvesOp(StateMachine.DefaultValvesOpen, StateMachine.DefaultValvesClose))
.EnterState();
do {
e = StateMachine.WaitRunDevsRunOps();
if (e.Contains(Event.Error)) break;
}
while (!e.Contains(Event.ValvesSet));
return new List<Event> { retVal };
return new List<Event> { Event.Error };
}
}
}
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2019 Sensus Slovensko a.s.
/// Copyright (c) 2018 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2019 Sensus Slovensko a.s.
/// Copyright (c) 2018 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
@@ -7,6 +7,7 @@ using System.IO;
using System.Xml.Serialization;
using Config.Entities;
using TBF.BenchControl.Generic;
using TBF.BenchControl.Configs.NameOnly;
namespace TBF.BenchControl.TestMethods.SensitivityTest
{
@@ -1,69 +0,0 @@
///
/// Copyright (c) 2019 Sensus Metering Systems
///
using System;
using System.Windows.Forms;
using Config.Entities;
using TBF.BenchControl.Generic;
namespace TBF.BenchControl.TestMethods.SensitivityTest
{
public partial class TestMethodCfgCtrl : UserControl, IComponentCfgCtrl
{
public bool ShowMore { get { return false; } }
TestMethodCfg config;
public IComponentCfg Config
{
get { return config as IComponentCfg; }
set
{
config = value as TestMethodCfg;
Redraw();
}
}
public TestMethodCfgCtrl()
{
InitializeComponent();
}
private void EntryFormCfgCtrl_Load(object sender, EventArgs e)
{
Redraw();
}
public void Closing()
{
}
void Redraw()
{
if (config == null) return; /// Control was not loaded, settings were not changed
classNameLabel.Text = config.Factory.ClassName;
nameTextBox.Text = config.Name;
}
public void Unlock()
{
nameTextBox.Enabled = true;
}
public CfgUpdateFlags VerifyCfg(ref string message)
{
CfgUpdateFlags flags = CfgUpdateFlags.None;
return flags;
}
public CfgUpdateFlags UpdateCfg()
{
CfgUpdateFlags flags = CfgUpdateFlags.RestartRqrd;
if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed
config.Name = nameTextBox.Text;
return flags;
}
}
}
@@ -1,86 +0,0 @@
///
/// Copyright (c) 2019 Sensus Metering Systems
///
namespace TBF.BenchControl.TestMethods.SensitivityTest
{
partial class TestMethodCfgCtrl
{
/// <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.SuspendLayout();
//
// nameTextBox
//
this.nameTextBox.Enabled = false;
this.nameTextBox.Location = new System.Drawing.Point(137, 57);
this.nameTextBox.Name = "nameTextBox";
this.nameTextBox.Size = new System.Drawing.Size(130, 20);
this.nameTextBox.TabIndex = 5;
//
// nameLabel
//
this.nameLabel.AutoSize = true;
this.nameLabel.Location = new System.Drawing.Point(27, 60);
this.nameLabel.Name = "nameLabel";
this.nameLabel.Size = new System.Drawing.Size(35, 13);
this.nameLabel.TabIndex = 4;
this.nameLabel.Text = "Name";
//
// classNameLabel
//
this.classNameLabel.AutoSize = true;
this.classNameLabel.Location = new System.Drawing.Point(134, 33);
this.classNameLabel.Name = "classNameLabel";
this.classNameLabel.Size = new System.Drawing.Size(83, 13);
this.classNameLabel.TabIndex = 3;
this.classNameLabel.Text = "ComonentName";
//
// BasicPrinterCfgCtrl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.nameTextBox);
this.Controls.Add(this.nameLabel);
this.Controls.Add(this.classNameLabel);
this.Name = "BasicPrinterCfgCtrl";
this.Size = new System.Drawing.Size(300, 200);
this.Load += new System.EventHandler(this.EntryFormCfgCtrl_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;
}
}
@@ -1,120 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2019 Sensus Slovensko a.s.
/// Copyright (c) 2018 Sensus Slovensko a.s.
///
using System;
using System.IO;
+14 -40
View File
@@ -314,54 +314,28 @@ namespace TBF
/// </summary>
void SaveUISettings()
{
/// Obtain ComponentsmanagerDlg dimensions, etc.
bool isMaximized = (WindowState == FormWindowState.Maximized);
int left = (WindowState == FormWindowState.Normal) ? Location.X : RestoreBounds.Left;
int top = (WindowState == FormWindowState.Normal) ? Location.Y : RestoreBounds.Top;
int width = (WindowState == FormWindowState.Normal) ? Size.Width : RestoreBounds.Width;
int height = (WindowState == FormWindowState.Normal) ? Size.Height : RestoreBounds.Height;
LocalSettings ls = Program.LocalSettings;
/// Compare list view column widths with the saved ones
bool anyColumnDiffers = false;
if ((int)Column.ColumnsCount != ls.ComponentsColumnCount)
if (WindowState == FormWindowState.Normal)
{
anyColumnDiffers = true;
Program.LocalSettings.ComponentsDlgLeft = Location.X;
Program.LocalSettings.ComponentsDlgTop = Location.Y;
Program.LocalSettings.ComponentsDlgWidth = Size.Width;
Program.LocalSettings.ComponentsDlgHeight = Size.Height;
}
else
{
for (int i = 0; i < (int)Column.ColumnsCount; i++)
{
if (listViewEx.Columns[i].Width != ls.ComponentsColumnWidths[i]) { anyColumnDiffers = true; break; }
}
Program.LocalSettings.ComponentsDlgLeft = RestoreBounds.Left;
Program.LocalSettings.ComponentsDlgTop = RestoreBounds.Top;
Program.LocalSettings.ComponentsDlgWidth = RestoreBounds.Width;
Program.LocalSettings.ComponentsDlgHeight = RestoreBounds.Height;
}
if (ls != null && (ls.ComponentsDlgMaximized != isMaximized ||
ls.ComponentsDlgLeft != left ||
ls.ComponentsDlgTop != top ||
ls.ComponentsDlgWidth != width ||
ls.ComponentsDlgHeight != height ||
anyColumnDiffers))
/// Update the column widths
Program.LocalSettings.ComponentsColumnWidths = new int[(int)Column.ColumnsCount];
for (int i = 0; i < (int)Column.ColumnsCount; i++)
{
/// At least one ComponentsManagerDlg dimension differs => Update local settings and save them
///
ls.ComponentsDlgMaximized = isMaximized;
ls.ComponentsDlgLeft = left;
ls.ComponentsDlgTop = top;
ls.ComponentsDlgWidth = width;
ls.ComponentsDlgHeight = height;
/// List view column widths
ls.ComponentsColumnWidths = new int[(int)Column.ColumnsCount];
for (int i = 0; i < (int)Column.ColumnsCount; i++)
{
ls.ComponentsColumnWidths[i] = listViewEx.Columns[i].Width;
}
ls.Save();
Program.LocalSettings.ComponentsColumnWidths[i] = listViewEx.Columns[i].Width;
}
Program.LocalSettings.Save();
}
///
+18 -29
View File
@@ -49,26 +49,25 @@ namespace TBF.Forms
this.testConnResultsDbBtn = new System.Windows.Forms.Button();
this.createConfigDbBtn = new System.Windows.Forms.Button();
this.createResultsDbBtn = new System.Windows.Forms.Button();
this.createUsersDbBtn = new System.Windows.Forms.Button();
this.testConnUsersDbBtn = new System.Windows.Forms.Button();
this.usersDbTypeComboBox = new System.Windows.Forms.ComboBox();
this.usersLabel = new System.Windows.Forms.Label();
this.usersDbConnectionStringTextBox = new System.Windows.Forms.TextBox();
this.importResultsDbBtn = new System.Windows.Forms.Button();
this.importConfigDbBtn = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// okButton
//
resources.ApplyResources(this.okButton, "okButton");
this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK;
resources.ApplyResources(this.okButton, "okButton");
this.okButton.Name = "okButton";
this.okButton.UseVisualStyleBackColor = true;
this.okButton.Click += new System.EventHandler(this.okButton_Click);
//
// cancelButton
//
resources.ApplyResources(this.cancelButton, "cancelButton");
this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
resources.ApplyResources(this.cancelButton, "cancelButton");
this.cancelButton.Name = "cancelButton";
this.cancelButton.UseVisualStyleBackColor = true;
this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click);
@@ -133,40 +132,48 @@ namespace TBF.Forms
//
// testConnConfigDbBtn
//
resources.ApplyResources(this.testConnConfigDbBtn, "testConnConfigDbBtn");
this.testConnConfigDbBtn.DialogResult = System.Windows.Forms.DialogResult.Cancel;
resources.ApplyResources(this.testConnConfigDbBtn, "testConnConfigDbBtn");
this.testConnConfigDbBtn.Name = "testConnConfigDbBtn";
this.testConnConfigDbBtn.UseVisualStyleBackColor = true;
this.testConnConfigDbBtn.Click += new System.EventHandler(this.testConnConfigDbBtn_Click);
//
// testConnResultsDbBtn
//
resources.ApplyResources(this.testConnResultsDbBtn, "testConnResultsDbBtn");
this.testConnResultsDbBtn.DialogResult = System.Windows.Forms.DialogResult.Cancel;
resources.ApplyResources(this.testConnResultsDbBtn, "testConnResultsDbBtn");
this.testConnResultsDbBtn.Name = "testConnResultsDbBtn";
this.testConnResultsDbBtn.UseVisualStyleBackColor = true;
this.testConnResultsDbBtn.Click += new System.EventHandler(this.testConnResultsDbBtn_Click);
//
// createConfigDbBtn
//
resources.ApplyResources(this.createConfigDbBtn, "createConfigDbBtn");
this.createConfigDbBtn.DialogResult = System.Windows.Forms.DialogResult.Cancel;
resources.ApplyResources(this.createConfigDbBtn, "createConfigDbBtn");
this.createConfigDbBtn.Name = "createConfigDbBtn";
this.createConfigDbBtn.UseVisualStyleBackColor = true;
this.createConfigDbBtn.Click += new System.EventHandler(this.createConfigDbBtn_Click);
//
// createResultsDbBtn
//
resources.ApplyResources(this.createResultsDbBtn, "createResultsDbBtn");
this.createResultsDbBtn.DialogResult = System.Windows.Forms.DialogResult.Cancel;
resources.ApplyResources(this.createResultsDbBtn, "createResultsDbBtn");
this.createResultsDbBtn.Name = "createResultsDbBtn";
this.createResultsDbBtn.UseVisualStyleBackColor = true;
this.createResultsDbBtn.Click += new System.EventHandler(this.createResultsDbBtn_Click);
//
// createUsersDbBtn
//
this.createUsersDbBtn.DialogResult = System.Windows.Forms.DialogResult.Cancel;
resources.ApplyResources(this.createUsersDbBtn, "createUsersDbBtn");
this.createUsersDbBtn.Name = "createUsersDbBtn";
this.createUsersDbBtn.UseVisualStyleBackColor = true;
this.createUsersDbBtn.Click += new System.EventHandler(this.createUsersDbBtn_Click);
//
// testConnUsersDbBtn
//
resources.ApplyResources(this.testConnUsersDbBtn, "testConnUsersDbBtn");
this.testConnUsersDbBtn.DialogResult = System.Windows.Forms.DialogResult.Cancel;
resources.ApplyResources(this.testConnUsersDbBtn, "testConnUsersDbBtn");
this.testConnUsersDbBtn.Name = "testConnUsersDbBtn";
this.testConnUsersDbBtn.UseVisualStyleBackColor = true;
this.testConnUsersDbBtn.Click += new System.EventHandler(this.testConnUsersDbBtn_Click);
@@ -187,28 +194,11 @@ namespace TBF.Forms
resources.ApplyResources(this.usersDbConnectionStringTextBox, "usersDbConnectionStringTextBox");
this.usersDbConnectionStringTextBox.Name = "usersDbConnectionStringTextBox";
//
// importResultsDbBtn
//
resources.ApplyResources(this.importResultsDbBtn, "importResultsDbBtn");
this.importResultsDbBtn.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.importResultsDbBtn.Name = "importResultsDbBtn";
this.importResultsDbBtn.UseVisualStyleBackColor = true;
this.importResultsDbBtn.Click += new System.EventHandler(this.importResultsDbBtn_Click);
//
// importConfigDbBtn
//
resources.ApplyResources(this.importConfigDbBtn, "importConfigDbBtn");
this.importConfigDbBtn.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.importConfigDbBtn.Name = "importConfigDbBtn";
this.importConfigDbBtn.UseVisualStyleBackColor = true;
this.importConfigDbBtn.Click += new System.EventHandler(this.importConfigDbBtn_Click);
//
// DatabaseSettingsDlg
//
resources.ApplyResources(this, "$this");
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.importResultsDbBtn);
this.Controls.Add(this.importConfigDbBtn);
this.Controls.Add(this.createUsersDbBtn);
this.Controls.Add(this.testConnUsersDbBtn);
this.Controls.Add(this.usersDbTypeComboBox);
this.Controls.Add(this.usersLabel);
@@ -259,11 +249,10 @@ namespace TBF.Forms
private System.Windows.Forms.Button testConnResultsDbBtn;
private System.Windows.Forms.Button createConfigDbBtn;
private System.Windows.Forms.Button createResultsDbBtn;
private System.Windows.Forms.Button createUsersDbBtn;
private System.Windows.Forms.Button testConnUsersDbBtn;
private System.Windows.Forms.ComboBox usersDbTypeComboBox;
private System.Windows.Forms.Label usersLabel;
private System.Windows.Forms.TextBox usersDbConnectionStringTextBox;
private System.Windows.Forms.Button importResultsDbBtn;
private System.Windows.Forms.Button importConfigDbBtn;
}
}
+47 -183
View File
@@ -1,12 +1,8 @@
///
/// Copyright (c) 2013-2019 Sensus Metering Systems
/// Copyright (c) 2013-2016 Sensus Metering Systems
///
using System;
using System.Windows.Forms;
using System.Drawing;
using System.IO;
using System.Diagnostics;
using log4net;
using TBF.Resources;
namespace TBF.Forms
@@ -16,8 +12,6 @@ namespace TBF.Forms
/// </summary>
public partial class DatabaseSettingsDlg : Form
{
static readonly ILog log = LogManager.GetLogger(typeof(DatabaseSettingsDlg));
// Reference to bench DB settins (not a local copy)
Config.DatabaseSettings bench;
@@ -50,6 +44,7 @@ namespace TBF.Forms
createConfigDbBtn.Text = Strings.Create_DB;
createResultsDbBtn.Text = Strings.Create_DB;
createUsersDbBtn.Text = Strings.Create_DB;
okButton.Text = Strings.OkBtnText;
cancelButton.Text = Strings.CancelBtnText;
@@ -135,61 +130,70 @@ namespace TBF.Forms
Close();
}
private void testConnConfigDbBtn_Click(object sender, EventArgs e)
{
}
private void testConnResultsDbBtn_Click(object sender, EventArgs e)
{
}
private void testConnUsersDbBtn_Click(object sender, EventArgs e)
{
}
private void createConfigDbBtn_Click(object sender, EventArgs e)
{
/// Update database connection strings
if (!UpdateBenchFromUIControls()) return;
if (DialogResult.OK == MessageBox.Show(Strings.DB_will_be_overwritten + Environment.NewLine +
Strings.Do_you_want_to_proceed, Strings.Warning,
MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation))
try
{
try
{
Cursor.Current = Cursors.WaitCursor;
Config.FluentCommon.CreateEmptyConfigDB(bench.ProceduresDBSettings.DbType, bench.ProceduresDBSettings.ConnectionString);
MessageBox.Show(Strings.DB_was_successfully_created, Strings.Notification);
Cursor.Current = Cursors.Default;
DialogResult = DialogResult.None;
}
catch (Exception exception)
{
Cursor.Current = Cursors.Default;
MessageBox.Show(Strings.Error_while_creating_DB_Reason + exception.Message, Strings.Error);
}
Cursor.Current = Cursors.WaitCursor;
Config.FluentCommon.CreateEmptyConfigDB(bench.ProceduresDBSettings.DbType, bench.ProceduresDBSettings.ConnectionString);
MessageBox.Show(Strings.DB_was_successfully_created, Strings.Notification);
Cursor.Current = Cursors.Default;
DialogResult = DialogResult.None;
}
catch (Exception exception)
{
Cursor.Current = Cursors.Default;
MessageBox.Show(Strings.Error_while_creating_DB_Reason + exception.Message, Strings.Error);
}
}
private void createResultsDbBtn_Click(object sender, EventArgs e)
{
/// Update database connection strings
if (!UpdateBenchFromUIControls()) return;
if (DialogResult.OK == MessageBox.Show(Strings.DB_will_be_overwritten + Environment.NewLine +
Strings.Do_you_want_to_proceed, Strings.Warning,
MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation))
try
{
Cursor.Current = Cursors.WaitCursor;
Results.DB.DbType = bench.WaterMetersDBSettings.DbType;
Results.DB.ConnectionString = bench.WaterMetersDBSettings.ConnectionString;
Results.DB.CreateEmptyDB();
MessageBox.Show(Strings.DB_was_successfully_created, Strings.Notification);
Cursor.Current = Cursors.Default;
DialogResult = DialogResult.None;
}
catch (Exception exception)
{
Cursor.Current = Cursors.Default;
string msg = Strings.Error_while_creating_DB_Reason + Environment.NewLine + exception.Message;
if (exception.InnerException != null)
{
msg += Environment.NewLine + exception.InnerException.Message;
}
MessageBox.Show(msg, Strings.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void createUsersDbBtn_Click(object sender, EventArgs e)
{
if (!UpdateBenchFromUIControls()) return;
if (DialogResult.OK == MessageBox.Show(Strings.DB_will_be_overwritten + Environment.NewLine +
Strings.Do_you_want_to_proceed, Strings.Warning,
MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation))
try
{
Cursor.Current = Cursors.WaitCursor;
Results.DB.DbType = bench.WaterMetersDBSettings.DbType;
Results.DB.ConnectionString = bench.WaterMetersDBSettings.ConnectionString;
Results.DB.CreateEmptyDB();
Users.DB.DbType = bench.UsersDBSettings.DbType;
Users.DB.ConnectionString = bench.UsersDBSettings.ConnectionString;
Users.DB.CreateEmptyDB();
MessageBox.Show(Strings.DB_was_successfully_created, Strings.Notification);
Cursor.Current = Cursors.Default;
DialogResult = DialogResult.None;
@@ -204,159 +208,19 @@ namespace TBF.Forms
}
MessageBox.Show(msg, Strings.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
//private void createUsersDbBtn_Click(object sender, EventArgs e)
//{
// /// Update database connection strings
// if (!UpdateBenchFromUIControls()) return;
// if (DialogResult.OK == MessageBox.Show(Strings.DB_will_be_overwritten + Environment.NewLine +
// Strings.Do_you_want_to_proceed, Strings.Warning,
// MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation))
// {
// try
// {
// Cursor.Current = Cursors.WaitCursor;
// Users.DB.DbType = bench.UsersDBSettings.DbType;
// Users.DB.ConnectionString = bench.UsersDBSettings.ConnectionString;
// Users.DB.CreateEmptyDB();
// MessageBox.Show(Strings.DB_was_successfully_created, Strings.Notification);
// Cursor.Current = Cursors.Default;
// DialogResult = DialogResult.None;
// }
// catch (Exception exception)
// {
// Cursor.Current = Cursors.Default;
// string msg = Strings.Error_while_creating_DB_Reason + Environment.NewLine + exception.Message;
// if (exception.InnerException != null)
// {
// msg += Environment.NewLine + exception.InnerException.Message;
// }
// MessageBox.Show(msg, Strings.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
// }
// }
//}
/// <summary>
/// Configuration database import (UI)
/// </summary>
private void importConfigDbBtn_Click(object sender, EventArgs e)
private void testConnConfigDbBtn_Click(object sender, EventArgs e)
{
/// Update database connection strings
if (!UpdateBenchFromUIControls()) return;
if (MessageBox.Show(Strings.Do_you_want_to_restore_configuration_qm,
string.Empty,
MessageBoxButtons.YesNo,
MessageBoxIcon.Question) == DialogResult.Yes)
{
OpenFileDialog dlg = new OpenFileDialog();
dlg.InitialDirectory = string.Format(@"C:\TBF\DbBackups\");
if (dlg.ShowDialog() != DialogResult.OK) return;
DBImportMessageStart("Importing database with configuration");
ImportDatabase(Config.Data.CurrentBench.ProceduresDBSettings.ConnectionString, dlg.FileName);
DBImportMessageEnd();
}
}
/// <summary>
/// Results database import (UI)
/// </summary>
private void importResultsDbBtn_Click(object sender, EventArgs e)
private void testConnResultsDbBtn_Click(object sender, EventArgs e)
{
/// Update database connection strings
if (!UpdateBenchFromUIControls()) return;
if (MessageBox.Show(Strings.Do_you_want_to_restore_results_qm,
string.Empty,
MessageBoxButtons.YesNo,
MessageBoxIcon.Question) == DialogResult.Yes)
{
OpenFileDialog dlg = new OpenFileDialog();
dlg.InitialDirectory = string.Format(@"C:\TBF\DbBackups\");
if (dlg.ShowDialog() != DialogResult.OK) return;
DBImportMessageStart("Importing database with results");
ImportDatabase(Config.Data.CurrentBench.WaterMetersDBSettings.ConnectionString, dlg.FileName);
DBImportMessageEnd();
}
}
TBF.Forms.ModelessActivityForm form;
System.Threading.Thread formThread;
///
void DBImportMessageStart(string message)
private void testConnUsersDbBtn_Click(object sender, EventArgs e)
{
form = new TBF.Forms.ModelessActivityForm()
{
Message = message,
FontFamily = "Arial",
FontSize = 24,
FontStyle = FontStyle.Regular,
BackgroundColor = Color.RoyalBlue,
};
formThread = new System.Threading.Thread(() => form.ShowDialog());
formThread.Start();
}
///
void DBImportMessageEnd()
{
if (form != null && formThread != null)
{
form.CloseForm(null, new EventArgs());
formThread.Join();
}
form = null;
formThread = null;
}
/// <summary>
/// Database import (functionality)
/// Invokes:
/// mysql -u[userName] --default-character-set=utf8 --database [databaseName]
/// SOURCE {SQL file name]
/// </summary>
/// <param name="connectionString">DB connection string</param>
/// <param name="outputFileName">Output file name</param>
void ImportDatabase(string connectionString, string inputFileName)
{
string databaseName = Config.Utils.GetDBName(connectionString);
string userName = Config.Utils.GetDBUser(connectionString);
string password = Config.Utils.GetDBPassword(connectionString); /// TODO: Use password
try
{
Process proc = new Process();
proc.StartInfo.FileName = @"C:\xampp\mysql\bin\mysql.exe";
proc.StartInfo.Arguments = string.Format("--user={0} --default-character-set=utf8 --database={2}", userName, password, databaseName);
proc.StartInfo.UseShellExecute = false; /// Must be false to redirect standard input or standard output
proc.StartInfo.RedirectStandardOutput = false;
proc.StartInfo.RedirectStandardInput = true;
proc.StartInfo.CreateNoWindow = false;
//proc.StartInfo.Verb = "runas"; /// To run mysql.exe as administrator
Debug.WriteLine("Ideme na to.");
proc.Start();
string command = string.Format("SOURCE {0}{1}", inputFileName, Environment.NewLine);
proc.StandardInput.Write(command);
Debug.Write(command);
proc.StandardInput.Write(string.Format("exit{0}", Environment.NewLine));
Debug.WriteLine("exit");
proc.WaitForExit();
log.ErrorFormat("Database {0} imported from file {1}", databaseName, inputFileName);
}
catch (Exception exc)
{
log.FatalFormat("Failed to import database {0} from file {1}: {2}", databaseName, inputFileName, exc.Message);
}
}
}
}
+68 -122
View File
@@ -117,16 +117,12 @@
<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.Location" type="System.Drawing.Point, System.Drawing">
<value>801, 15</value>
<value>614, 15</value>
</data>
<data name="okButton.Size" type="System.Drawing.Size, System.Drawing">
<value>312, 28</value>
<value>225, 28</value>
</data>
<assembly alias="mscorlib" name="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="okButton.TabIndex" type="System.Int32, mscorlib">
@@ -145,16 +141,13 @@
<value>$this</value>
</data>
<data name="&gt;&gt;okButton.ZOrder" xml:space="preserve">
<value>21</value>
</data>
<data name="cancelButton.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Right</value>
<value>20</value>
</data>
<data name="cancelButton.Location" type="System.Drawing.Point, System.Drawing">
<value>801, 49</value>
<value>614, 49</value>
</data>
<data name="cancelButton.Size" type="System.Drawing.Size, System.Drawing">
<value>312, 28</value>
<value>225, 28</value>
</data>
<data name="cancelButton.TabIndex" type="System.Int32, mscorlib">
<value>13</value>
@@ -172,7 +165,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;cancelButton.ZOrder" xml:space="preserve">
<value>22</value>
<value>21</value>
</data>
<data name="label1.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@@ -199,7 +192,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;label1.ZOrder" xml:space="preserve">
<value>20</value>
<value>19</value>
</data>
<data name="benchNameTextBox.Location" type="System.Drawing.Point, System.Drawing">
<value>116, 15</value>
@@ -220,7 +213,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;benchNameTextBox.ZOrder" xml:space="preserve">
<value>19</value>
<value>18</value>
</data>
<data name="connectionStringLabel.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@@ -247,13 +240,13 @@
<value>$this</value>
</data>
<data name="&gt;&gt;connectionStringLabel.ZOrder" xml:space="preserve">
<value>18</value>
<value>17</value>
</data>
<data name="configDbConnectionStringTextBox.Location" type="System.Drawing.Point, System.Drawing">
<value>202, 107</value>
</data>
<data name="configDbConnectionStringTextBox.Size" type="System.Drawing.Size, System.Drawing">
<value>589, 20</value>
<value>406, 20</value>
</data>
<data name="configDbConnectionStringTextBox.TabIndex" type="System.Int32, mscorlib">
<value>20</value>
@@ -268,13 +261,13 @@
<value>$this</value>
</data>
<data name="&gt;&gt;configDbConnectionStringTextBox.ZOrder" xml:space="preserve">
<value>17</value>
<value>16</value>
</data>
<data name="resultsDbConnectionStringTextBox.Location" type="System.Drawing.Point, System.Drawing">
<value>202, 137</value>
</data>
<data name="resultsDbConnectionStringTextBox.Size" type="System.Drawing.Size, System.Drawing">
<value>589, 20</value>
<value>406, 20</value>
</data>
<data name="resultsDbConnectionStringTextBox.TabIndex" type="System.Int32, mscorlib">
<value>22</value>
@@ -289,7 +282,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;resultsDbConnectionStringTextBox.ZOrder" xml:space="preserve">
<value>16</value>
<value>15</value>
</data>
<data name="configLabel.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@@ -316,7 +309,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;configLabel.ZOrder" xml:space="preserve">
<value>15</value>
<value>14</value>
</data>
<data name="resultsLabel.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@@ -343,7 +336,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;resultsLabel.ZOrder" xml:space="preserve">
<value>14</value>
<value>13</value>
</data>
<data name="realBenchCheckBox.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@@ -370,7 +363,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;realBenchCheckBox.ZOrder" xml:space="preserve">
<value>13</value>
<value>12</value>
</data>
<data name="dbTypeLabel.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@@ -397,7 +390,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;dbTypeLabel.ZOrder" xml:space="preserve">
<value>12</value>
<value>11</value>
</data>
<data name="configDbTypeComboBox.Location" type="System.Drawing.Point, System.Drawing">
<value>116, 107</value>
@@ -418,7 +411,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;configDbTypeComboBox.ZOrder" xml:space="preserve">
<value>11</value>
<value>10</value>
</data>
<data name="resultsDbTypeComboBox.Location" type="System.Drawing.Point, System.Drawing">
<value>116, 137</value>
@@ -439,19 +432,17 @@
<value>$this</value>
</data>
<data name="&gt;&gt;resultsDbTypeComboBox.ZOrder" xml:space="preserve">
<value>10</value>
</data>
<data name="testConnConfigDbBtn.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Right</value>
<value>9</value>
</data>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="testConnConfigDbBtn.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="testConnConfigDbBtn.Location" type="System.Drawing.Point, System.Drawing">
<value>801, 105</value>
<value>614, 105</value>
</data>
<data name="testConnConfigDbBtn.Size" type="System.Drawing.Size, System.Drawing">
<value>100, 23</value>
<value>95, 23</value>
</data>
<data name="testConnConfigDbBtn.TabIndex" type="System.Int32, mscorlib">
<value>62</value>
@@ -469,19 +460,16 @@
<value>$this</value>
</data>
<data name="&gt;&gt;testConnConfigDbBtn.ZOrder" xml:space="preserve">
<value>9</value>
</data>
<data name="testConnResultsDbBtn.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Right</value>
<value>8</value>
</data>
<data name="testConnResultsDbBtn.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="testConnResultsDbBtn.Location" type="System.Drawing.Point, System.Drawing">
<value>801, 135</value>
<value>614, 135</value>
</data>
<data name="testConnResultsDbBtn.Size" type="System.Drawing.Size, System.Drawing">
<value>100, 23</value>
<value>95, 23</value>
</data>
<data name="testConnResultsDbBtn.TabIndex" type="System.Int32, mscorlib">
<value>64</value>
@@ -499,25 +487,22 @@
<value>$this</value>
</data>
<data name="&gt;&gt;testConnResultsDbBtn.ZOrder" xml:space="preserve">
<value>8</value>
</data>
<data name="createConfigDbBtn.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Right</value>
<value>7</value>
</data>
<data name="createConfigDbBtn.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="createConfigDbBtn.Location" type="System.Drawing.Point, System.Drawing">
<value>907, 104</value>
<value>715, 104</value>
</data>
<data name="createConfigDbBtn.Size" type="System.Drawing.Size, System.Drawing">
<value>100, 23</value>
<value>124, 23</value>
</data>
<data name="createConfigDbBtn.TabIndex" type="System.Int32, mscorlib">
<value>66</value>
</data>
<data name="createConfigDbBtn.Text" xml:space="preserve">
<value>Create new DB</value>
<value>Create DB</value>
</data>
<data name="&gt;&gt;createConfigDbBtn.Name" xml:space="preserve">
<value>createConfigDbBtn</value>
@@ -529,25 +514,22 @@
<value>$this</value>
</data>
<data name="&gt;&gt;createConfigDbBtn.ZOrder" xml:space="preserve">
<value>7</value>
</data>
<data name="createResultsDbBtn.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Right</value>
<value>6</value>
</data>
<data name="createResultsDbBtn.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="createResultsDbBtn.Location" type="System.Drawing.Point, System.Drawing">
<value>907, 134</value>
<value>715, 134</value>
</data>
<data name="createResultsDbBtn.Size" type="System.Drawing.Size, System.Drawing">
<value>100, 23</value>
<value>124, 23</value>
</data>
<data name="createResultsDbBtn.TabIndex" type="System.Int32, mscorlib">
<value>68</value>
</data>
<data name="createResultsDbBtn.Text" xml:space="preserve">
<value>Create new DB</value>
<value>Create DB</value>
</data>
<data name="&gt;&gt;createResultsDbBtn.Name" xml:space="preserve">
<value>createResultsDbBtn</value>
@@ -559,19 +541,43 @@
<value>$this</value>
</data>
<data name="&gt;&gt;createResultsDbBtn.ZOrder" xml:space="preserve">
<value>6</value>
<value>5</value>
</data>
<data name="testConnUsersDbBtn.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Right</value>
<data name="createUsersDbBtn.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="createUsersDbBtn.Location" type="System.Drawing.Point, System.Drawing">
<value>715, 164</value>
</data>
<data name="createUsersDbBtn.Size" type="System.Drawing.Size, System.Drawing">
<value>124, 23</value>
</data>
<data name="createUsersDbBtn.TabIndex" type="System.Int32, mscorlib">
<value>73</value>
</data>
<data name="createUsersDbBtn.Text" xml:space="preserve">
<value>Create DB</value>
</data>
<data name="&gt;&gt;createUsersDbBtn.Name" xml:space="preserve">
<value>createUsersDbBtn</value>
</data>
<data name="&gt;&gt;createUsersDbBtn.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;createUsersDbBtn.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;createUsersDbBtn.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<data name="testConnUsersDbBtn.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="testConnUsersDbBtn.Location" type="System.Drawing.Point, System.Drawing">
<value>801, 165</value>
<value>614, 165</value>
</data>
<data name="testConnUsersDbBtn.Size" type="System.Drawing.Size, System.Drawing">
<value>100, 23</value>
<value>95, 23</value>
</data>
<data name="testConnUsersDbBtn.TabIndex" type="System.Int32, mscorlib">
<value>72</value>
@@ -589,7 +595,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;testConnUsersDbBtn.ZOrder" xml:space="preserve">
<value>2</value>
<value>1</value>
</data>
<data name="usersDbTypeComboBox.Location" type="System.Drawing.Point, System.Drawing">
<value>116, 167</value>
@@ -610,7 +616,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;usersDbTypeComboBox.ZOrder" xml:space="preserve">
<value>3</value>
<value>2</value>
</data>
<data name="usersLabel.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@@ -640,13 +646,13 @@
<value>$this</value>
</data>
<data name="&gt;&gt;usersLabel.ZOrder" xml:space="preserve">
<value>4</value>
<value>3</value>
</data>
<data name="usersDbConnectionStringTextBox.Location" type="System.Drawing.Point, System.Drawing">
<value>202, 167</value>
</data>
<data name="usersDbConnectionStringTextBox.Size" type="System.Drawing.Size, System.Drawing">
<value>589, 20</value>
<value>406, 20</value>
</data>
<data name="usersDbConnectionStringTextBox.TabIndex" type="System.Int32, mscorlib">
<value>69</value>
@@ -661,67 +667,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;usersDbConnectionStringTextBox.ZOrder" xml:space="preserve">
<value>5</value>
</data>
<data name="importResultsDbBtn.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Right</value>
</data>
<data name="importResultsDbBtn.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="importResultsDbBtn.Location" type="System.Drawing.Point, System.Drawing">
<value>1013, 134</value>
</data>
<data name="importResultsDbBtn.Size" type="System.Drawing.Size, System.Drawing">
<value>100, 23</value>
</data>
<data name="importResultsDbBtn.TabIndex" type="System.Int32, mscorlib">
<value>75</value>
</data>
<data name="importResultsDbBtn.Text" xml:space="preserve">
<value>Import DB</value>
</data>
<data name="&gt;&gt;importResultsDbBtn.Name" xml:space="preserve">
<value>importResultsDbBtn</value>
</data>
<data name="&gt;&gt;importResultsDbBtn.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;importResultsDbBtn.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;importResultsDbBtn.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<data name="importConfigDbBtn.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Right</value>
</data>
<data name="importConfigDbBtn.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="importConfigDbBtn.Location" type="System.Drawing.Point, System.Drawing">
<value>1013, 104</value>
</data>
<data name="importConfigDbBtn.Size" type="System.Drawing.Size, System.Drawing">
<value>100, 23</value>
</data>
<data name="importConfigDbBtn.TabIndex" type="System.Int32, mscorlib">
<value>74</value>
</data>
<data name="importConfigDbBtn.Text" xml:space="preserve">
<value>Import DB</value>
</data>
<data name="&gt;&gt;importConfigDbBtn.Name" xml:space="preserve">
<value>importConfigDbBtn</value>
</data>
<data name="&gt;&gt;importConfigDbBtn.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;importConfigDbBtn.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;importConfigDbBtn.ZOrder" xml:space="preserve">
<value>1</value>
<value>4</value>
</data>
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
@@ -730,7 +676,7 @@
<value>6, 13</value>
</data>
<data name="$this.ClientSize" type="System.Drawing.Size, System.Drawing">
<value>1125, 202</value>
<value>853, 202</value>
</data>
<data name="$this.StartPosition" type="System.Windows.Forms.FormStartPosition, System.Windows.Forms">
<value>CenterParent</value>
+7 -9
View File
@@ -27,6 +27,7 @@ namespace TBF.Forms
/// Smart card support, card S/N is used as user.Tag
GemCard.CardNative card;
string[] cardReaders;
string smartCardReader;
/// Readonly public properties to do the authorization.
@@ -98,22 +99,19 @@ namespace TBF.Forms
smartCardReader = null; /// null = No smart card reader detected
#if TURA_IPERL || TURA_IPERL_NEW || TURA_SPECIAL
#if TURA_IPERL || TURA_SPECIAL
try
{
card = new CardNative();
/// Find NFC smart card reader
string[] cardReaders = card.ListReaders();
if (cardReaders != null)
cardReaders = card.ListReaders();
foreach (var crd in cardReaders)
{
foreach (var crd in cardReaders)
if (crd.Contains("NFC"))
{
if (crd.Contains("NFC"))
{
smartCardReader = crd; /// NFC smart card reader detected
break;
}
smartCardReader = crd; /// NFC smart card reader detected
break;
}
}
+1 -1
View File
@@ -102,7 +102,7 @@ namespace TBF.Forms
{
parent.OnReload(this, new PreviousResultIdEventArgs(BatchNr));
}
#if TURA_IPERL || TURA_IPERL_NEW || TURA_SPECIAL
#if TURA_IPERL || TURA_SPECIAL
else if (mode == PreviousResultsMode.Fix)
{
/// Access only to thise who manage production tracing
+29 -48
View File
@@ -235,62 +235,43 @@ 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;
dlg.PopupResultsWidth = Program.LocalSettings.PopupResultsWidth;
dlg.PopupResultsHeight = Program.LocalSettings.PopupResultsHeight;
dlg.MetersArrangement = Program.LocalSettings.ResultsConfigMeters;
dlg.TestsArrangement = Program.LocalSettings.ResultsConfigTests;
dlg.NrMetersInOneGroup = Math.Max(1, Program.LocalSettings.ResultsConfigMetersInOneGroup);
dlg.RsltItems_Screen_SingleWM = Results.WMeterRsltItemSpec.FromStrArray(Program.LocalSettings.RsltItems_Screen_SingleWM);
dlg.RsltItems_Screen_CombinedWM = Results.WMeterRsltItemSpec.FromStrArray(Program.LocalSettings.RsltItems_Screen_CombinedWM);
dlg.RsltItems_Screen_HeatM = Results.WMeterRsltItemSpec.FromStrArray(Program.LocalSettings.RsltItems_Screen_HeatM);
dlg.RsltsClmnWidths = Program.LocalSettings.RsltsClmnWidths;
foreach (var b in batches)
{
if (b.BatchNr == data.BatchNr)
{
if (b.WaterMeters == null || b.WaterMeters.Count == 0)
{
return; /// No water meters in the selected batch
}
/// Prepare result items
IList<Results.WMeterRsltItemSpec> items = null;
foreach (var wm in b.WaterMeters)
{
if (wm != null)
{
if (wm.WaterMeterData.Compound)
{
items = Results.WMeterRsltItemSpec.FromStrArray(Program.LocalSettings.RsltItems_Screen_CombinedWM);
}
else if (wm.WaterMeterData.HeatMeter)
{
items = Results.WMeterRsltItemSpec.FromStrArray(Program.LocalSettings.RsltItems_Screen_HeatM);
}
else
{
items = Results.WMeterRsltItemSpec.FromStrArray(Program.LocalSettings.RsltItems_Screen_SingleWM);
}
break;
}
}
if (items == null) items = new List<Results.WMeterRsltItemSpec>();
/// Show dialog with results
Results.Forms.BatchResultsDlg dlg = new Results.Forms.BatchResultsDlg
{
Text = string.Format(Strings.Results_of_batch_0, b.BatchNr),
Results = Results.BatchResults.FromBatch(b),
Items = items,
PopupResultsLeft = Program.LocalSettings.PopupResultsLeft,
PopupResultsTop = Program.LocalSettings.PopupResultsTop,
PopupResultsWidth = Program.LocalSettings.PopupResultsWidth,
PopupResultsHeight = Program.LocalSettings.PopupResultsHeight,
MetersArrangement = Program.LocalSettings.ResultsConfigMeters,
TestsArrangement = Program.LocalSettings.ResultsConfigTests,
NrMetersInOneGroup = Math.Max(1, Program.LocalSettings.ResultsConfigMetersInOneGroup),
ShowDisabledPositions = Program.LocalSettings.ShowDisabledPositions,
MinWidth = Program.LocalSettings.ResultsConfigMinWidth,
MinHeight = Program.LocalSettings.ResultsConfigMinHeight,
RsltsClmnWidths = Program.LocalSettings.RsltsClmnWidths,
};
dlg.Results = Results.BatchResults.FromBatch(b);
dlg.Text = string.Format(Strings.Results_of_batch_0, b.BatchNr);
dlg.Show();
break;
}
}
//if (dlg.PopupResultsLeft != Program.LocalSettings.PopupResultsLeft ||
// dlg.PopupResultsTop != Program.LocalSettings.PopupResultsTop ||
// dlg.PopupResultsWidth != Program.LocalSettings.PopupResultsWidth ||
// dlg.PopupResultsHeight != Program.LocalSettings.PopupResultsHeight)
//{
// Program.LocalSettings.PopupResultsLeft = dlg.PopupResultsLeft;
// Program.LocalSettings.PopupResultsTop = dlg.PopupResultsTop;
// Program.LocalSettings.PopupResultsWidth = dlg.PopupResultsWidth;
// Program.LocalSettings.PopupResultsHeight = dlg.PopupResultsHeight;
// Program.LocalSettings.Save();
//}
}
-14
View File
@@ -35,7 +35,6 @@ namespace TBF.Forms
this.testsColumnsRadioButton = new System.Windows.Forms.RadioButton();
this.testsArangementGroupBox = new System.Windows.Forms.GroupBox();
this.metersArangementGroupBox = new System.Windows.Forms.GroupBox();
this.showDisabledCheckBox = new System.Windows.Forms.CheckBox();
this.minHeightTextBox = new System.Windows.Forms.TextBox();
this.minHeightLabel = new System.Windows.Forms.Label();
this.minWidthTextBox = new System.Windows.Forms.TextBox();
@@ -89,7 +88,6 @@ namespace TBF.Forms
//
// metersArangementGroupBox
//
this.metersArangementGroupBox.Controls.Add(this.showDisabledCheckBox);
this.metersArangementGroupBox.Controls.Add(this.minHeightTextBox);
this.metersArangementGroupBox.Controls.Add(this.minHeightLabel);
this.metersArangementGroupBox.Controls.Add(this.minWidthTextBox);
@@ -105,17 +103,6 @@ namespace TBF.Forms
this.metersArangementGroupBox.TabStop = false;
this.metersArangementGroupBox.Text = "Arangement of tested meters";
//
// showDisabledCheckBox
//
this.showDisabledCheckBox.AutoSize = true;
this.showDisabledCheckBox.Enabled = false;
this.showDisabledCheckBox.Location = new System.Drawing.Point(200, 44);
this.showDisabledCheckBox.Name = "showDisabledCheckBox";
this.showDisabledCheckBox.Size = new System.Drawing.Size(139, 17);
this.showDisabledCheckBox.TabIndex = 10;
this.showDisabledCheckBox.Text = "Show disabled positions";
this.showDisabledCheckBox.UseVisualStyleBackColor = true;
//
// minHeightTextBox
//
this.minHeightTextBox.Enabled = false;
@@ -276,6 +263,5 @@ namespace TBF.Forms
private System.Windows.Forms.Label minHeightLabel;
private System.Windows.Forms.TextBox minWidthTextBox;
private System.Windows.Forms.Label minWidthLabel;
private System.Windows.Forms.CheckBox showDisabledCheckBox;
}
}
+5 -7
View File
@@ -22,7 +22,6 @@ namespace TBF.Forms
public TestsArrangement TestsArrangement;
public MetersArrangement MetersArrangement;
public int NrMetersInOneGroup;
public bool ShowDisabledPositions;
public int MinWidth;
public int MinHeight;
@@ -63,7 +62,6 @@ namespace TBF.Forms
horizontallyRadioButton.Text = Strings.Horizontally;
verticallyRadioButton.Text = Strings.Vertically;
nrMetersLabel.Text = string.Format("{0}:", Strings.Nr_meters_in_a_group);
showDisabledCheckBox.Text = Strings.Show_disabled_positions;
minWidthLabel.Text = string.Format("{0}:", Strings.Min_width);
minHeightLabel.Text = string.Format("{0}:", Strings.Min_height);
unlockButton.Text = Strings.UnlockBtnText;
@@ -81,7 +79,6 @@ namespace TBF.Forms
horizontallyRadioButton.Checked = (MetersArrangement == MetersArrangement.Horizontally);
verticallyRadioButton.Checked = (MetersArrangement == MetersArrangement.Vertically);
nrMetersTextBox.Text = NrMetersInOneGroup.ToString();
showDisabledCheckBox.Checked = ShowDisabledPositions;
minWidthTextBox.Text = MinWidth.ToString();
minHeightTextBox.Text = MinHeight.ToString();
}
@@ -116,7 +113,6 @@ namespace TBF.Forms
verticallyRadioButton.Enabled = true;
horizontallyRadioButton.Enabled = true;
nrMetersTextBox.Enabled = true;
showDisabledCheckBox.Enabled = true;
minWidthTextBox.Enabled = true;
minHeightTextBox.Enabled = true;
resultsConfigCtrl.Unlocked = true;
@@ -125,9 +121,11 @@ namespace TBF.Forms
void okButton_Click(object sender, EventArgs e)
{
TestsArrangement = testsColumnsRadioButton.Checked ? TestsArrangement.Columns : TestsArrangement.Rows;
MetersArrangement = horizontallyRadioButton.Checked ? MetersArrangement.Horizontally : MetersArrangement.Vertically;
ShowDisabledPositions = showDisabledCheckBox.Checked;
if (testsColumnsRadioButton.Checked) TestsArrangement = TestsArrangement.Columns;
else TestsArrangement = TestsArrangement.Rows;
if (horizontallyRadioButton.Checked) MetersArrangement = MetersArrangement.Horizontally;
else MetersArrangement = MetersArrangement.Vertically;
int tmpInt;
if (int.TryParse(nrMetersTextBox.Text, out tmpInt) && tmpInt > 0) { NrMetersInOneGroup = tmpInt; }

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