Initial commit 4

This commit is contained in:
Rowlander 2021-10-01 11:12:07 +02:00
parent 70e2645059
commit e1b07a8e0f
1947 changed files with 836444 additions and 0 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

25
TBF_V2/Sources/TBF/.gitignore vendored Normal file
View File

@ -0,0 +1,25 @@
Config/bin/
Config/obj/
DeviceTest/bin/
DeviceTest/obj/
Dirichlet.Numerics/bin
Dirichlet.Numerics/obj
GraphLib/bin
GraphLib/obj
MonitoringDB/bin
MonitoringDB/obj
Results/bin/
Results/obj/
ResultsBrowser/bin/
ResultsBrowser/obj/
TBF/bin/
TBF/obj/
TBFSetup/Debug/
TBFSetup/Release/
Users/bin/
Users/obj/
UserManagement/bin/
UserManagement/obj/
Doc/
*.suo
*.bak

View File

@ -0,0 +1,152 @@
<?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)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{743DF7DB-C7B6-42EB-986D-0F485E5588E4}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Config</RootNamespace>
<AssemblyName>Config</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG;GENESIS;IPERL;LANG_DE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE;GENESIS;IPERL;LANG_DE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="ControlComponent3U">
<HintPath>..\..\..\Debug\ControlComponent3U.dll</HintPath>
</Reference>
<Reference Include="FluentNHibernate">
<HintPath>..\packages\FluentNHibernate.2.0.3.0\lib\net40\FluentNHibernate.dll</HintPath>
</Reference>
<Reference Include="Iesi.Collections">
<HintPath>..\packages\Iesi.Collections.4.0.0.4000\lib\net40\Iesi.Collections.dll</HintPath>
</Reference>
<Reference Include="log4net">
<HintPath>..\packages\log4net.2.0.2\lib\net40-full\log4net.dll</HintPath>
</Reference>
<Reference Include="MySql.Data">
<HintPath>..\packages\MySql.Data.6.6.5\lib\net40\MySql.Data.dll</HintPath>
</Reference>
<Reference Include="NHibernate">
<HintPath>..\packages\NHibernate.4.0.4.4000\lib\net40\NHibernate.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data.SQLite">
<HintPath>..\packages\System.Data.SQLite.1.0.90.0\lib\net40\System.Data.SQLite.dll</HintPath>
</Reference>
<Reference Include="System.Data.SQLite.Linq">
<HintPath>..\packages\System.Data.SQLite.1.0.90.0\lib\net40\System.Data.SQLite.Linq.dll</HintPath>
</Reference>
<Reference Include="System.Windows.Forms" />
<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="Data.cs" />
<Compile Include="DatabaseSettings.cs" />
<Compile Include="Entities\BenchPath.cs" />
<Compile Include="Entities\Component.cs" />
<Compile Include="Entities\ComponentProcedure.cs" />
<Compile Include="Entities\ComponentTest.cs" />
<Compile Include="Entities\Enums.cs" />
<Compile Include="Entities\FeedingPath.cs" />
<Compile Include="Entities\Group.cs" />
<Compile Include="Entities\HeatMetersPath.cs" />
<Compile Include="Entities\IHasItemNr.cs" />
<Compile Include="Entities\IHasName.cs" />
<Compile Include="Entities\IHasValves.cs" />
<Compile Include="Entities\IParamsProvider.cs" />
<Compile Include="Entities\MeasurementCorrection.cs" />
<Compile Include="Entities\MetersPath.cs" />
<Compile Include="Entities\OutputPath.cs" />
<Compile Include="Entities\Procedure.cs" />
<Compile Include="Entities\ProcedureHistory.cs" />
<Compile Include="Entities\Test.cs" />
<Compile Include="Entities\TransitionSequence.cs" />
<Compile Include="Entities\TransitionStep.cs" />
<Compile Include="Entities\User.cs" />
<Compile Include="Entities\VirtualBenchSequence.cs" />
<Compile Include="Entities\VirtualBenchStep.cs" />
<Compile Include="Entities\Watermeter.cs" />
<Compile Include="Entities\WMType.cs" />
<Compile Include="FluentCommon.cs" />
<Compile Include="Formulas.cs" />
<Compile Include="Mappings\BenchPathMap.cs" />
<Compile Include="Mappings\ComponentMap.cs" />
<Compile Include="Mappings\ComponentProcedureMap.cs" />
<Compile Include="Mappings\ComponentTestMap.cs" />
<Compile Include="Mappings\FeedingPathMap.cs" />
<Compile Include="Mappings\GroupMap.cs" />
<Compile Include="Mappings\HeatMetersPathMap.cs" />
<Compile Include="Mappings\MeasurementCorrectionMap.cs" />
<Compile Include="Mappings\MetersPathMap.cs" />
<Compile Include="Mappings\OutputPathMap.cs" />
<Compile Include="Mappings\ProcedureMap.cs" />
<Compile Include="Mappings\TestMap.cs" />
<Compile Include="Mappings\TransitionSequenceMap.cs" />
<Compile Include="Mappings\TransitionStepMap.cs" />
<Compile Include="Mappings\UserMap.cs" />
<Compile Include="Mappings\VirtualBenchSequenceMap.cs" />
<Compile Include="Mappings\VirtualBenchStepMap.cs" />
<Compile Include="Mappings\WatermeterMap.cs" />
<Compile Include="Mappings\WMTypeMap.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Resources\Strings.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Strings.resx</DependentUpon>
</Compile>
<Compile Include="Units.cs" />
<Compile Include="Utils.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Resources\Strings.cs.resx" />
<EmbeddedResource Include="Resources\Strings.de.resx" />
<EmbeddedResource Include="Resources\Strings.it.resx" />
<EmbeddedResource Include="Resources\Strings.pl.resx" />
<EmbeddedResource Include="Resources\Strings.resx">
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Resources\Strings.ru.resx" />
<EmbeddedResource Include="Resources\Strings.zh-CN.resx" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Users\Users.csproj">
<Project>{6E5CB0E9-E1B6-4E5D-AC6E-B1049E180F2B}</Project>
<Name>Users</Name>
</ProjectReference>
</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>

View File

@ -0,0 +1,96 @@
using System;
namespace Config
{
public class Data : Users.GlobalData
{
public const string AdminUsername = "admin";
public const string AdminPassword = "staratura";
public const string SQLiteDbFName = "SQLite.db";
#if MUNICH
public const int WMsCount = 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
public const int WMsCount = 3;
public const int LineSize = 3;
public const int CompoundWMsCount = 1;
public const int HeatMetersCount = 0;
public const int MaxPartNr = WMsCount / LineSize;
#elif FUZHOU300 || FUZHOU150 || PT200IL || PUCHONG_PT200 || GENESIS || SLM_150 || PETERSBURG_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 DUBAJ_50
public const int WMsCount = 10;
public const int LineSize = 5;
public const int CompoundWMsCount = 0;
public const int HeatMetersCount = 0;
public const int MaxPartNr = WMsCount / LineSize;
#elif FUZHOU100
public const int WMsCount = 10;
public const int LineSize = 10;
public const int CompoundWMsCount = 1;
public const int HeatMetersCount = 0;
public const int MaxPartNr = WMsCount / LineSize;
#elif TORINO50 || BADGER_MALA_TRAT || BERLIN
public const int WMsCount = 6;
public const int LineSize = 6;
public const int CompoundWMsCount = 1;
public const int HeatMetersCount = 0;
public const int MaxPartNr = 1;
#elif TORUN_PT50_2015 || CEVAK_PT40_272 || MURES_PT40 || FUZHOU_40 || PETERSBURG_50 || KEMPNO_50 || BAHRAIN_50 || KRAKOW_50 || JUZNA_AFRIKA_50 || ZAMBIA
public const int WMsCount = 20;
public const int LineSize = 10;
public const int CompoundWMsCount = 1;
public const int HeatMetersCount = 0;
public const int MaxPartNr = WMsCount / LineSize;
#elif RUM_MOB
public const int WMsCount = 8;
public const int LineSize = 8;
public const int CompoundWMsCount = 1;
public const int HeatMetersCount = 0;
public const int MaxPartNr = WMsCount / LineSize;
#elif TURA_IPERL
public const int WMsCount = 40;
public const int LineSize = 20;
public const int CompoundWMsCount = 1;
public const int HeatMetersCount = 0;
public const int MaxPartNr = WMsCount / LineSize;
#elif TURA_SPECIAL || SENTEC
public const int WMsCount = 6;
public const int LineSize = 6;
public const int CompoundWMsCount = 1;
public const int HeatMetersCount = 0;
public const int MaxPartNr = WMsCount / LineSize;
#elif SLM_50
public const int WMsCount = 12;
public const int LineSize = 12;
public const int CompoundWMsCount = 1;
public const int HeatMetersCount = 6;
public const int MaxPartNr = WMsCount / LineSize;
#elif SLM_END || WARSAW_END
public const int WMsCount = 10;
public const int LineSize = 5;
public const int CompoundWMsCount = 1;
public const int HeatMetersCount = 0;
public const int MaxPartNr = 4;
#elif MALTA_WSD25
public const int WMsCount = 6;
public const int LineSize = 6;
public const int CompoundWMsCount = 0;
public const int HeatMetersCount = 0;
public const int MaxPartNr = WMsCount / LineSize;
#endif
///
/// Database related: This object reference is set after a successful user login
///
public static DatabaseSettings CurrentBench;
}
}

View File

@ -0,0 +1,54 @@
///
/// Copyright (c) 2013-2017 Sensus Metering Systems
///
using System;
using System.Text;
using System.Xml.Serialization;
namespace Config
{
/// <summary>
/// Test bench database settings, contains bench name and settings od several databases
/// </summary>
public class DatabaseSettings : ICloneable
{
// Public fields
public string BenchName;
public bool IsRealBench;
public Users.DBSettings ProceduresDBSettings; /// Config database settings
public Users.DBSettings WaterMetersDBSettings; /// Results database settings
public Users.DBSettings UsersDBSettings; /// Users database settings
// Constructor
public DatabaseSettings()
{
BenchName = String.Empty; /// Empty string (avoid null)
IsRealBench = false;
ProceduresDBSettings = new Users.DBSettings(Users.Entities.DBType.MySql, string.Empty);
WaterMetersDBSettings = new Users.DBSettings(Users.Entities.DBType.MySql, string.Empty);
UsersDBSettings = new Users.DBSettings(Users.Entities.DBType.MySql, string.Empty);
}
public object Clone()
{
DatabaseSettings result = new DatabaseSettings();
result.BenchName = BenchName;
result.IsRealBench = IsRealBench;
result.ProceduresDBSettings = (Users.DBSettings)ProceduresDBSettings.Clone();
result.WaterMetersDBSettings = (Users.DBSettings)WaterMetersDBSettings.Clone();
result.UsersDBSettings = (Users.DBSettings)ProceduresDBSettings.Clone();
return result;
}
public override string ToString()
{
return string.Format("{0} config={1} results={2} users={3}",
BenchName,
ProceduresDBSettings.ConnectionString,
WaterMetersDBSettings.ConnectionString,
UsersDBSettings.ConnectionString);
}
}
}

View File

@ -0,0 +1,61 @@
///
/// Copyright (c) 2013-2017 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
namespace Config.Entities
{
public class BenchPath : IHasName, IHasItemNr, IHasValves
{
public virtual int Id { get; protected set; }
public virtual int ItemNr { get; set; }
public virtual string Name { get; set; }
public virtual string OriName { get; set; } /// Not mapped to database
public virtual float Qfrom { get; set; } /// Water flow in [m3/h]
public virtual float Qto { get; set; } /// Water flow in [m3/h]
public virtual string TempMtrUp { get; set; }
public virtual string TempMtrDown { get; set; }
public virtual string PressMtrUp { get; set; }
public virtual string PressMtrDown { get; set; }
public virtual string PressMtrDelta { get; set; }
public virtual string StopBFValve { get; set; }
/// Valves
public virtual string ValvesOpen { get; set; }
public virtual string ValvesClose { get; set; }
/// ------------- Additional stuff not mapped into the database -------------
public BenchPath()
{
ValvesOpen = string.Empty;
ValvesClose = string.Empty;
}
public BenchPath(string name, int itemNr)
: this()
{
Name = name;
ItemNr = itemNr;
}
public virtual BenchPath Clone(string name, int itemNr)
{
BenchPath result = new BenchPath(name, itemNr);
result.Qfrom = Qfrom;
result.Qto = Qto;
result.TempMtrUp = TempMtrUp;
result.TempMtrDown = TempMtrDown;
result.PressMtrUp = PressMtrUp;
result.PressMtrDown = PressMtrDown;
result.PressMtrDelta = PressMtrDelta;
result.StopBFValve = StopBFValve;
result.ValvesOpen = ValvesOpen;
result.ValvesClose = ValvesClose;
return result;
}
}
}

View File

@ -0,0 +1,136 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
namespace Config.Entities
{
public class Component : IHasName, IHasItemNr
{
public virtual int Id { get; protected set; }
public virtual int ItemNr { get; set; }
public virtual string Name { get; set; }
public virtual string ClassName { get; set; }
public virtual string ParentName { get; set; }
public virtual DebugMode Mode { get; set; }
public virtual LogLevel Logging { get; set; }
public virtual string Parameters { get; set; }
public virtual IList<MeasurementCorrection> Corrections { get; set; }
/// ------------- Additional stuff not mapped into the database -------------
public Component()
{
Name = string.Empty;
ClassName = string.Empty;
Corrections = new List<MeasurementCorrection>();
}
public static Component CreateFromCfg(string name, string className, string parentName, int itemNr,
DebugMode debugLevel, LogLevel logLevel, string parameters)
{
Component result = new Component();
result.ItemNr = itemNr;
result.Name = name;
result.ClassName = className;
result.ParentName = parentName;
result.Mode = debugLevel;
result.Logging = logLevel;
result.Parameters = parameters;
return result;
}
// Makes a new copy of this object (not just a reference)
public virtual Component Clone()
{
Component result = new Component();
result.ItemNr = ItemNr;
result.Name = Name;
result.ClassName = ClassName;
result.ParentName = ParentName;
result.Mode = Mode;
result.Logging = Logging;
result.Parameters = Parameters;
return result;
}
public virtual void Export(StreamWriter output)
{
output.WriteLine(Name);
output.WriteLine(ClassName);
output.WriteLine(ParentName);
output.WriteLine(Mode.ToString());
output.WriteLine(Logging.ToString());
output.Write(Parameters);
output.Close();
}
public static Component Import(StreamReader input)
{
Component result = new Component();
result.Name = input.ReadLine();
result.ClassName = input.ReadLine();
result.ParentName = input.ReadLine();
string line = input.ReadLine();
if (line.Equals(DebugMode.DetectedOff.ToString())) result.Mode = DebugMode.DetectedOff;
else if (line.Equals(DebugMode.DetectedOn.ToString())) result.Mode = DebugMode.DetectedOn;
else if (line.Equals(DebugMode.Normal.ToString())) result.Mode = DebugMode.Normal;
else if (line.Equals(DebugMode.AutoDetect.ToString())) result.Mode = DebugMode.AutoDetect;
else if (line.Equals(DebugMode.FailureDuringOperation.ToString())) result.Mode = DebugMode.FailureDuringOperation;
else if (line.Equals(DebugMode.Off.ToString())) result.Mode = DebugMode.Off;
else if (line.Equals(DebugMode.Record.ToString())) result.Mode = DebugMode.Record;
else if (line.Equals(DebugMode.Reply.ToString())) result.Mode = DebugMode.Reply;
else if (line.Equals(DebugMode.Simulate.ToString())) result.Mode = DebugMode.Simulate;
else if (line.Equals(DebugMode.Inherit.ToString())) result.Mode = DebugMode.Inherit;
line = input.ReadLine();
if (line.Equals(LogLevel.Off.ToString())) result.Logging = LogLevel.Off;
else if (line.Equals(LogLevel.Fatal.ToString())) result.Logging = LogLevel.Fatal;
else if (line.Equals(LogLevel.Error.ToString())) result.Logging = LogLevel.Error;
else if (line.Equals(LogLevel.Warn.ToString())) result.Logging = LogLevel.Warn;
else if (line.Equals(LogLevel.Info.ToString())) result.Logging = LogLevel.Info;
else if (line.Equals(LogLevel.Debug.ToString())) result.Logging = LogLevel.Debug;
else if (line.Equals(LogLevel.All.ToString())) result.Logging = LogLevel.All;
result.Parameters = string.Empty;
line = input.ReadLine();
while (line != null)
{
result.Parameters += line;
result.Parameters += Environment.NewLine;
line = input.ReadLine();
}
return result;
}
public virtual string ToString(string indent)
{
string result = string.Empty;
result += indent + "ItemNr = " + (ItemNr + 1).ToString() + Environment.NewLine;
result += indent + "Name = " + Name + Environment.NewLine;
result += indent + "ClassName = " + ClassName + Environment.NewLine;
if (ParentName != null)
{
result += indent + "ParentName = " + ParentName + Environment.NewLine;
}
result += indent + "DebugLevel = " + Mode.ToString() + Environment.NewLine;
result += indent + "LogLevel = " + Logging.ToString() + Environment.NewLine;
result += indent + "Parameters = " + Parameters + Environment.NewLine;
return result;
}
public override string ToString()
{
return string.Format("{0} ({1})", Name, ClassName);
}
}
}

View File

@ -0,0 +1,61 @@
///
/// Copyright (c) 2013-2018 Sensus Slovensko a.s.
///
using System;
using System.IO;
namespace Config.Entities
{
public class ComponentProcedure
{
public virtual int Id { get; protected set; }
public virtual string CmpntName { get; set; } /// Component name
public virtual string Parameters { get; set; }
public virtual Procedure Procedure { get; set; }
IParamsProvider paramsProvider;
///
public virtual IParamsProvider GetParamsProvider() { return paramsProvider; }
public virtual void SetParamsProvider(IParamsProvider paramsProvider) { this.paramsProvider = paramsProvider; }
protected ComponentProcedure() { }
public ComponentProcedure(string name, string parameters, Procedure procedure)
{
this.CmpntName = name;
this.Parameters = parameters;
this.Procedure = procedure;
}
public virtual ComponentProcedure Clone(Procedure newProcedure)
{
return new ComponentProcedure(CmpntName, Parameters, newProcedure);
}
public virtual void Export(StreamWriter output)
{
output.WriteLine(CmpntName);
output.WriteLine(Parameters.Replace(Environment.NewLine, "~"));
}
public static ComponentProcedure Import(StreamReader input, Procedure newProcedure)
{
string firstLine = input.ReadLine();
if (string.IsNullOrEmpty(firstLine)) return null;
try
{
string cmptnName = firstLine;
string parameters = input.ReadLine().Replace("~", Environment.NewLine);
return new ComponentProcedure(cmptnName, parameters, newProcedure);
}
catch (Exception)
{
return null;
}
}
}
}

View File

@ -0,0 +1,61 @@
///
/// Copyright (c) 2013-2018 Sensus Slovensko a.s.
///
using System;
using System.IO;
namespace Config.Entities
{
public class ComponentTest
{
public virtual int Id { get; protected set; }
public virtual string CmpntName { get; set; } /// Component name
public virtual string Parameters { get; set; }
public virtual Test Test { get; set; }
IParamsProvider paramsProvider;
///
public virtual IParamsProvider GetParamsProvider() { return paramsProvider; }
public virtual void SetParamsProvider(IParamsProvider paramsProvider) { this.paramsProvider = paramsProvider; }
protected ComponentTest() { }
public ComponentTest(string name, string parameters, Test test)
{
this.CmpntName = name;
this.Parameters = parameters;
this.Test = test;
}
public virtual ComponentTest Clone()
{
return new ComponentTest(CmpntName, Parameters, Test);
}
public virtual void Export(StreamWriter output)
{
output.WriteLine(CmpntName);
output.WriteLine(Parameters.Replace(Environment.NewLine, "~"));
}
public static ComponentTest Import(StreamReader input, Test newTest)
{
string firstLine = input.ReadLine();
if (string.IsNullOrEmpty(firstLine)) return null;
try
{
string cmptnName = firstLine;
string parameters = input.ReadLine().Replace("~", Environment.NewLine);
return new ComponentTest(cmptnName, parameters, newTest);
}
catch (Exception)
{
return null;
}
}
}
}

View File

@ -0,0 +1,493 @@
///
/// Copyright (c) 2013-2017 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
using System.Reflection;
namespace Config.Entities
{
/// <summary>
/// Helper class to assign descriptions to enum values
/// </summary>
public class Description : Attribute
{
public string Text;
public Description(string t)
{
Text = t;
}
}
public static class GetDescription
{
/// Extension method for enum-s
public static string ToDescription(this Enum en)
{
Type type = en.GetType();
MemberInfo[] memInfo = type.GetMember(en.ToString());
if (memInfo != null && memInfo.Length > 0)
{
object[] attrs = memInfo[0].GetCustomAttributes(typeof(Description), false);
if (attrs != null && attrs.Length > 0)
return ((Description)attrs[0]).Text;
}
return en.ToString(); /// Return ToString() value in case there is no description
}
}
/// <summary>
/// Flags returned by each device configuration control Verify(...) function.
/// </summary>
public enum CfgUpdateFlags
{
None = 0,
Error = 0x1, /// Some settings in the user control are invalid and cannot be set
Warning = 0x02, /// Some settings in the user control are suspicious, can be set after user confirmation
RestartRqrd = 0x04, /// TBF program restart is required to apply all changed parameters
AnyChange = 0x08, /// At least one parameter have changed
VolatileChange = 0x10,
InvokeCfgChange = 0x20, /// Invoke CfgChange handler of the component
}
public enum RemoteDBUse
{
[Description("Local DB only")] LocalDBOnly,
[Description("Remote DB only")] RemoteDBOnly,
[Description("Both DB-s, local 1st")] BothDBsLocalFirst,
[Description("Both DB-s, remote 1st")] BothDBsRemoteFirst,
Count,
}
/// <summary>
/// Contains a procedure name and a database specification (local/remote).
/// </summary>
public class ProcedureInfo
{
public readonly string Name;
public readonly Users.Entities.DBKind DBKind;
public ProcedureInfo(string name, Users.Entities.DBKind dbKind)
{
Name = name;
DBKind = dbKind;
}
}
public enum ProcedureState
{
Active,
History,
Count,
}
/// <summary> Kind of meters for the procedure / test </summary>
public enum MetersKind
{
#if LANG_DE
[Description("Wasserzähler")] Single,
[Description("Verbundwasserzähler")] Combined,
[Description("Wärmezähler")] HeatMeter,
#elif LANG_CS
[Description("Vodoměry")] Single,
[Description("Kombinované vodoměry")] Combined,
[Description("Měřiče tepla")] HeatMeter,
#elif LANG_RU
[Description("Счетчик")] Single,
[Description("Комбинированный счетчик")] Combined,
[Description("Счетчик тепла")] HeatMeter,
#else
[Description("Water meters")] Single,
[Description("Compound water meters")] Combined,
[Description("Heat meters")] HeatMeter,
#endif
}
public enum CompoundMeterId : byte
{
Single,
CompoundMain,
CompoundAux,
Compound,
HeatMeterVolume,
HeatMeterEnergy,
SingleOrCompound, /// Only used when querying results
}
public enum Medium
{
[Description("")] NotSpecified,
#if LANG_PL
[Description("zimna")] ColdWater,
[Description("ciepła")] HotWater,
#elif LANG_IT
[Description("freddo")] ColdWater,
[Description("caldo")] HotWater,
#else
[Description("cold")] ColdWater,
[Description("hot")] HotWater,
#endif
Count
}
public enum Mounting
{
[Description("")] NotSpecified,
#if LANG_DE
[Description("H")] H, /// horizontal
[Description("V")] V, /// vertical
[Description("STR")] S, /// standrohre
[Description("F")] F, /// fall
#else
[Description("H")] H, /// horizontal
[Description("V")] V, /// vertical
[Description("S")] S, /// steig
[Description("F")] F, /// fall
#endif
Count
}
public enum TemperatureClass
{
[Description("")] NotSpecified,
[Description("T30")] T30,
[Description("T50")] T50,
[Description("T70")] T70,
[Description("T90")] T90,
[Description("T130")] T130,
[Description("T180")] T180,
[Description("T30/70")] T30_70,
[Description("T30/90")] T30_90,
[Description("T30/130")] T30_130,
[Description("T30/180")] T30_180,
[Description("30")] t30,
[Description("50")] t50,
[Description("70")] t70,
[Description("90")] t90,
[Description("130")] t130,
[Description("180")] t180,
Count
}
public enum FlowProfileSensitivityClass
{
[Description("")] NotSpecified,
[Description("U0")] U0, /// ?
[Description("D0")] D0, /// ?
Count
}
public enum PressureLossClass
{
[Description("")] NotSpecified,
[Description("dp63")] dp63, /// 0.063 MPa = 0.63 bar, TODO: Change to "Δp63"
[Description("dp40")] dp40, /// 0.040 MPa = 0.40 bar
[Description("dp25")] dp25, /// 0.025 MPa = 0.25 bar
[Description("dp16")] dp16, /// 0.016 MPa = 0.16 bar
[Description("dp10")] dp10, /// 0.010 MPa = 0.10 bar
Count
}
/// <summary> Maximum Admissible Pressure </summary>
public enum MaxAdmissiblePressure
{
[Description("")] NotSpecified,
[Description("MAP6")] MAP6,
[Description("MAP10")] MAP10,
[Description("MAP16")] MAP16,
[Description("MAP25")] MAP25,
[Description("MAP40")] MAP40,
Count
}
/// <summary> Register reader type </summary>
public enum RegisterReaderType
{
Unknown,
Pulses, /// Sick, optical and similar
Camera, /// CLP1611
DataStream, /// iPerl
Manual, /// Entered by human via form (also from camera images)
Count
}
/// <summary> Transition step is finished when this condition is fulfilled </summary>
public enum StepCondition
{
None,
Scale1Empty,
Scale2Empty,
Scale3Empty,
AllScalesEmpty,
Count
}
public enum Publish : sbyte
{
#if LANG_DE
/// german
[Description("nie")] Never = 0,
[Description("immer")] Always = 1,
[Description("Bildschirm")] OnScreen = 2,
[Description("intern")] Internal = 3,
#elif LANG_CS
/// czech
[Description("nikdy")] Never = 0,
[Description("vždy")] Always = 1,
[Description("na obrazovku")] OnScreen = 2,
[Description("interně")] Internal = 3,
#elif LANG_SK
/// slovak
[Description("nikdy")] Never = 0,
[Description("vždy")] Always = 1,
[Description("na obrazovku")] OnScreen = 2,
[Description("interne")] Internal = 3,
#elif LANG_PL
/// polish
[Description("nigdy")] Never = 0,
[Description("zawsze")] Always = 1,
[Description("na ekranie")] OnScreen = 2,
[Description("wewnętrznie")] Internal = 3,
#elif LANG_RU
/// russian
[Description("никогда")] Never = 0,
[Description("всегда")] Always = 1,
[Description("толька экран")] OnScreen = 2,
[Description("внутренно")] Internal = 3,
#else
/// english
[Description("Never")] Never = 0,
[Description("Always")] Always = 1,
[Description("On screen")] OnScreen = 2,
[Description("Internal")] Internal = 3,
#endif
Count
}
public enum MassMethod : byte
{
#if LANG_DE
/// nemecky
[Description("Waage")] Scale,
[Description("Spanne")] Spread,
[Description("Standardabw.")] StdDev,
#elif LANG_CS
/// cesky
[Description("váhou")] Scale,
[Description("max.rozdíl")] Spread,
[Description("std.dev.")] StdDev,
#else
[Description("Scale")] Scale,
[Description("Spread")] Spread,
[Description("Std.dev.")] StdDev,
#endif
Count
}
public enum TestRedType
{
Fix,
/// etc.
Count,
}
public enum FQC1
{
FQC1,
FQP1,
Count,
}
public enum Progress
{
JustStarted,
TransitionBefore,
SwitchingFlowDetection,
FlowSetting,
Aborted, /// Use as an argument when a test was aborted
Test,
TransitionAfter,
Completed,
Count,
}
public enum Device
{
Screen,
Printer,
Disk,
}
public enum PageOrientation
{
Portrait,
Landscape,
Count,
}
public enum ItemCategory
{
#if LANG_DE
[Description("Allgemein")] Other,
[Description("Prüfstanddaten")] BenchData,
[Description("Prüfstandergebnisse")] BenchResult,
[Description("Prüfpunktdaten")] TestData,
[Description("Prüfpunktergebnisse")] TestResult,
[Description("Wasserzelledaten")] MeterData,
[Description("Wasserzelleergebnisse")] MeterResult,
#else
[Description("Other")] Other,
[Description("Bench data")] BenchData,
[Description("Bench result")] BenchResult,
[Description("Test data")] TestData,
[Description("Test result")] TestResult,
[Description("Meter data")] MeterData,
[Description("Meter result")] MeterResult,
#endif
Count,
}
/// <summary> Possible modes of operation of components and devices. </summary>
public enum DebugMode
{
#if LANG_DE
[Description("Erkennen-aus")] DetectedOff = -2,
[Description("Erkennen-ein")] DetectedOn = -1,
[Description("Normal")] Normal = 0, /// Normal operation
[Description("Auto-erkennen")] AutoDetect, /// The component (device) will be auto-detected
[Description("Fehler")] FailureDuringOperation, /// Failure during operation -> disabled
[Description("Aus")] Off, /// The component is off
[Description("Aufzeichnen")] Record,
[Description("Reply")] Reply,
[Description("Simuliert")] Simulate, /// Test bench simulation, this mode does not require any hardware
[Description("Geerbt")] Inherit,
#else
[Description("Detected off")] DetectedOff = -2,
[Description("Detected on")] DetectedOn = -1,
[Description("Normal")] Normal = 0, /// Normal operation
[Description("Auto detect")] AutoDetect, /// The component (device) will be auto-detected
[Description("Run-time error")] FailureDuringOperation, /// Failure during operation -> disabled
[Description("Off")] Off, /// The component is off
[Description("Record")] Record,
[Description("Reply")] Reply,
[Description("Simulate")] Simulate, /// Test bench simulation, this mode does not require any hardware
[Description("Inherit")] Inherit,
#endif
Count,
}
public enum LogLevel
{
#if LANG_DE
[Description("Aus")] Off,
[Description("Schwerwiegend")] Fatal,
[Description("Fehler")] Error,
[Description("Warnung")] Warn,
[Description("Info")] Info,
[Description("Debug")] Debug,
[Description("Alles")] All,
#else
[Description("Off")] Off,
[Description("Fatal")] Fatal,
[Description("Error")] Error,
[Description("Warn")] Warn,
[Description("Info")] Info,
[Description("Debug")] Debug,
[Description("All")] All,
#endif
Count,
}
/// <summary> Arrangement of tests </summary>
public enum TestsArrangement
{
Rows,
Columns,
}
/// <summary> Arrangement of meters </summary>
public enum MetersArrangement
{
Vertically,
Horizontally,
}
public enum Alignment
{
#if LANG_DE
[Description("links")] Left,
[Description("zentriert")] Center,
[Description("rechts")] Right,
[Description("angepasst")] Justified,
#else
[Description("Left")] Left,
[Description("Center")] Center,
[Description("Right")] Right,
[Description("Justified")] Justified,
#endif
Count
}
public enum VertAlignment
{
[Description("Top")] Top,
[Description("Middle")] Middle,
[Description("Bottom")] Bottom,
}
public enum TableForm
{
None,
Rows,
Columns,
ColumnsPL,
Count,
}
public enum ImageRotation
{
[Description("0 deg")] None,
[Description("90 deg")] Deg90,
[Description("180 deg")] Deg180,
[Description("270 deg")] Deg270,
Count
}
public enum CameraDisplayResolution
{
Small,
Medium,
Large,
// FullScreen,
Count,
}
public enum ErrorFlagsMode : sbyte
{
#if LANG_DE
[Description("aus")] Off,
[Description("info")] Info,
[Description("ein")] On,
#elif LANG_CS
[Description("vypnuto")] Off,
[Description("info")] Info,
[Description("zapnuto")] On,
#elif LANG_RU
[Description("выкл")] Off,
[Description("инфо")] Info,
[Description("вкл")] On,
#elif LANG_PL
[Description("nie")] Off,
[Description("info")] Info,
[Description("tak")] On,
#else // LANG_EN
[Description("off")] Off,
[Description("info")] Info,
[Description("on")] On,
#endif
Count
}
}

View File

@ -0,0 +1,53 @@
///
/// Copyright (c) 2013-2017 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
namespace Config.Entities
{
public class FeedingPath : IHasName, IHasItemNr, IHasValves
{
public virtual int Id { get; protected set; }
public virtual int ItemNr { get; set; }
public virtual string Name { get; set; }
public virtual string OriName { get; set; } /// Not mapped to database
public virtual float Qfrom { get; set; } /// Water flow in [m3/h]
public virtual float Qto { get; set; } /// Water flow in [m3/h]
public virtual string Pump { get; set; }
public virtual string RegulValvesPct { get; set; } /// Positions of regulation valves in % separated by ';'
/// Valves
public virtual string ValvesOpen { get; set; }
public virtual string ValvesClose { get; set; }
/// ------------- Additional stuff not mapped into the database -------------
public FeedingPath()
{
ValvesOpen = string.Empty;
ValvesClose = string.Empty;
}
public FeedingPath(string name, int itemNr)
: this()
{
Name = name;
ItemNr = itemNr;
}
public virtual FeedingPath Clone(string name, int itemNr)
{
FeedingPath result = new FeedingPath(name, itemNr);
result.Qfrom = Qfrom;
result.Qto = Qto;
result.Pump = Pump;
result.RegulValvesPct = RegulValvesPct;
result.ValvesOpen = ValvesOpen;
result.ValvesClose = ValvesClose;
return result;
}
}
}

View File

@ -0,0 +1,24 @@
///
/// Copyright (c) 2013-2017 Sensus Metering Systems
///
using System;
namespace Config.Entities
{
public class Group
{
public virtual int Id { get; protected set; }
public virtual int Gid { get; set; }
public virtual string Name { get; set; }
public Group()
{
}
public Group(int gid, string name)
{
Gid = gid;
Name = name;
}
}
}

View File

@ -0,0 +1,65 @@
///
/// Copyright (c) 2016-2017 Sensus Metering Systems
///
using System;
namespace Config.Entities
{
public class HeatMetersPath : IHasName, IHasItemNr
{
public virtual int Id { get; protected set; }
public virtual int ItemNr { get; set; }
public virtual string Name { get; set; }
public virtual string OriName { get; set; } /// Not mapped to database
public virtual float TempWarmFrom { get; set; } /// Warm temperature range from [°C]
public virtual float TempWarmTo { get; set; } /// Warm temperature range to [°C]
public virtual float TempColdFrom { get; set; } /// Cold temperature range from [°C]
public virtual float TempColdTo { get; set; } /// Cold temperature renge to [°C]
public virtual string TMeterRefWarm1 { get; set; }
public virtual string TMeterRefWarm2 { get; set; }
public virtual string TMeterRefCold1 { get; set; }
public virtual string TMeterRefCold2 { get; set; }
public virtual string TMeterWorkWarm1 { get; set; }
public virtual string TMeterWorkWarm2 { get; set; }
public virtual string TMeterWorkCold1 { get; set; }
public virtual string TMeterWorkCold2 { get; set; }
/// ------------- Additional stuff not mapped into the database -------------
public HeatMetersPath()
{
}
public HeatMetersPath(string name, int itemNr)
: this()
{
Name = name;
ItemNr = itemNr;
}
public virtual HeatMetersPath Clone(string name, int itemNr)
{
HeatMetersPath result = new HeatMetersPath(name, itemNr);
result.TempWarmFrom = TempWarmFrom;
result.TempWarmTo = TempWarmTo;
result.TempColdFrom = TempColdFrom;
result.TempColdTo = TempColdTo;
result.TMeterRefWarm1 = TMeterRefWarm1;
result.TMeterRefWarm2 = TMeterRefWarm2;
result.TMeterRefCold1 = TMeterRefCold1;
result.TMeterRefCold2 = TMeterRefCold2;
result.TMeterWorkWarm1 = TMeterWorkWarm1;
result.TMeterWorkWarm2 = TMeterWorkWarm2;
result.TMeterWorkCold1 = TMeterWorkCold1;
result.TMeterWorkCold2 = TMeterWorkCold2;
return result;
}
}
}

View File

@ -0,0 +1,11 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
///
namespace Config.Entities
{
public interface IHasItemNr
{
int Id { get; }
int ItemNr { get; set; }
}
}

View File

@ -0,0 +1,11 @@
///
/// Copyright (c) 2017 Sensus Metering Systems
///
namespace Config.Entities
{
public interface IHasName
{
int Id { get; }
string Name { get; set; }
}
}

View File

@ -0,0 +1,11 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
///
namespace Config.Entities
{
public interface IHasValves
{
string ValvesOpen { get; set; } /// List of valves to be opened
string ValvesClose { get; set; } /// List of valves to be closed
}
}

View File

@ -0,0 +1,71 @@
///
/// Copyright (c) 2013-2018 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using System.Xml.Serialization;
namespace Config.Entities
{
public interface IParamsProvider
{
/// <summary>
/// Get XML Serializer
/// </summary>
XmlSerializer GetSerializer();
string ComponentName { get; }
/// <summary>
/// Number of parameters
/// </summary>
int ParamsCount();
/// <summary>
/// Returns a parameter name
/// </summary>
/// <param name="ix">Zero based index of the parameter</param>
string ParamName(int ix);
/// <summary>
/// Returns a list of possible values of one parameter (ComboBox when editing) or null (Textbox when editing).
/// </summary>
/// <param name="ix">Zero based index of the parameter</param>
IList<string> ParamValues(int ix);
/// <summary>
/// Returns a parameter value in the string form
/// </summary>
/// <param name="ix">Zero based index of the parameter</param>
string ToString(int ix);
/// <summary>
/// Initialize values of all parameters
/// </summary>
void InitializeAll();
/// <summary>
/// Validates the string representation of a parameter
/// </summary>
/// <param name="ix">Zero based index of the parameter</param>
/// <param name="strValue">String representation of the parameter</param>
/// <param name="message">Warning message in case the string is wrong or null</param>
/// <returns>true = string is OK, false = string is wrong (see 'message')</returns>
bool ValidateParam(int ix, string strValue, out string message);
/// <summary>
/// Update the parameter from a string
/// </summary>
/// <param name="ix">Zero based index of the parameter</param>
/// <param name="strValue">String representation of the parameter</param>
CfgUpdateFlags UpdateParam(int ix, string strValue);
void UpdateEmbeddedDbEntity();
/// <summary>
/// Creates an object copy
/// </summary>
/// <returns></returns>
IParamsProvider Clone();
}
}

View File

@ -0,0 +1,22 @@
///
/// Copyright (c) 2013-2018 Sensus Slovensko a.s.
///
using System;
namespace Config.Entities
{
public class MeasurementCorrection
{
public virtual int Id { get; protected set; }
public virtual int RangeIx { get; set; } /// 0..5
public virtual float Measurement { get; set; }
public virtual float Correction { get; set; }
public MeasurementCorrection() { }
public MeasurementCorrection(int rangeIx)
{
RangeIx = rangeIx;
}
}
}

View File

@ -0,0 +1,209 @@
///
/// Copyright (c) 2013-2017 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
namespace Config.Entities
{
public class MetersPath : IHasName, IHasItemNr
{
public virtual int Id { get; protected set; }
public virtual int ItemNr { get; set; }
public virtual string Name { get; set; }
public virtual string OriName { get; set; } /// Not mapped to database
/// Sensors
public virtual string Sensor1 { get; set; }
public virtual string Sensor2 { get; set; }
public virtual string Sensor3 { get; set; }
public virtual string Sensor4 { get; set; }
public virtual string Sensor5 { get; set; }
public virtual string Sensor6 { get; set; }
public virtual string Sensor7 { get; set; }
public virtual string Sensor8 { get; set; }
public virtual string Sensor9 { get; set; }
public virtual string Sensor10 { get; set; }
public virtual string Sensor11 { get; set; }
public virtual string Sensor12 { get; set; }
public virtual string Sensor13 { get; set; }
public virtual string Sensor14 { get; set; }
public virtual string Sensor15 { get; set; }
public virtual string Sensor16 { get; set; }
public virtual string Sensor17 { get; set; }
public virtual string Sensor18 { get; set; }
public virtual string Sensor19 { get; set; }
public virtual string Sensor20 { get; set; }
public virtual string Sensor21 { get; set; }
public virtual string Sensor22 { get; set; }
public virtual string Sensor23 { get; set; }
public virtual string Sensor24 { get; set; }
public virtual string Sensor25 { get; set; }
public virtual string Sensor26 { get; set; }
public virtual string Sensor27 { get; set; }
public virtual string Sensor28 { get; set; }
public virtual string Sensor29 { get; set; }
public virtual string Sensor30 { get; set; }
public virtual string Sensor31 { get; set; }
public virtual string Sensor32 { get; set; }
public virtual string Sensor33 { get; set; }
public virtual string Sensor34 { get; set; }
public virtual string Sensor35 { get; set; }
public virtual string Sensor36 { get; set; }
public virtual string Sensor37 { get; set; }
public virtual string Sensor38 { get; set; }
public virtual string Sensor39 { get; set; }
public virtual string Sensor40 { get; set; }
/// ------------- Additional stuff not mapped into the database -------------
public MetersPath()
{
}
public MetersPath(string name, int itemNr)
: this()
{
Name = name;
ItemNr = itemNr;
}
public virtual MetersPath Clone(string name, int itemNr)
{
MetersPath result = new MetersPath(name, itemNr);
result.Sensor1 = Sensor1;
result.Sensor2 = Sensor2;
result.Sensor3 = Sensor3;
result.Sensor4 = Sensor4;
result.Sensor5 = Sensor5;
result.Sensor6 = Sensor6;
result.Sensor7 = Sensor7;
result.Sensor8 = Sensor8;
result.Sensor9 = Sensor9;
result.Sensor10 = Sensor10;
result.Sensor11 = Sensor11;
result.Sensor12 = Sensor12;
result.Sensor13 = Sensor13;
result.Sensor14 = Sensor14;
result.Sensor15 = Sensor15;
result.Sensor16 = Sensor16;
result.Sensor17 = Sensor17;
result.Sensor18 = Sensor18;
result.Sensor19 = Sensor19;
result.Sensor20 = Sensor20;
result.Sensor21 = Sensor21;
result.Sensor22 = Sensor22;
result.Sensor23 = Sensor23;
result.Sensor24 = Sensor24;
result.Sensor25 = Sensor25;
result.Sensor26 = Sensor26;
result.Sensor27 = Sensor27;
result.Sensor28 = Sensor28;
result.Sensor29 = Sensor29;
result.Sensor30 = Sensor30;
result.Sensor31 = Sensor31;
result.Sensor32 = Sensor32;
result.Sensor33 = Sensor33;
result.Sensor34 = Sensor34;
result.Sensor35 = Sensor35;
result.Sensor36 = Sensor36;
result.Sensor37 = Sensor37;
result.Sensor38 = Sensor38;
result.Sensor39 = Sensor39;
result.Sensor40 = Sensor40;
return result;
}
/// Returns the component name
public virtual string GetSensor(int i)
{
if (i == 0) return Sensor1;
else if (i == 1) return Sensor2;
else if (i == 2) return Sensor3;
else if (i == 3) return Sensor4;
else if (i == 4) return Sensor5;
else if (i == 5) return Sensor6;
else if (i == 6) return Sensor7;
else if (i == 7) return Sensor8;
else if (i == 8) return Sensor9;
else if (i == 9) return Sensor10;
else if (i == 10) return Sensor11;
else if (i == 11) return Sensor12;
else if (i == 12) return Sensor13;
else if (i == 13) return Sensor14;
else if (i == 14) return Sensor15;
else if (i == 15) return Sensor16;
else if (i == 16) return Sensor17;
else if (i == 17) return Sensor18;
else if (i == 18) return Sensor19;
else if (i == 19) return Sensor20;
else if (i == 20) return Sensor21;
else if (i == 21) return Sensor22;
else if (i == 22) return Sensor23;
else if (i == 23) return Sensor24;
else if (i == 24) return Sensor25;
else if (i == 25) return Sensor26;
else if (i == 26) return Sensor27;
else if (i == 27) return Sensor28;
else if (i == 28) return Sensor29;
else if (i == 29) return Sensor30;
else if (i == 30) return Sensor31;
else if (i == 31) return Sensor32;
else if (i == 32) return Sensor33;
else if (i == 33) return Sensor34;
else if (i == 34) return Sensor35;
else if (i == 35) return Sensor36;
else if (i == 36) return Sensor37;
else if (i == 37) return Sensor38;
else if (i == 38) return Sensor39;
else if (i == 39) return Sensor40;
else return null;
}
/// Sets the component name
public virtual void SetSensor(int i, string cmpntName)
{
if (i == 0) Sensor1 = cmpntName;
else if (i == 1) Sensor2 = cmpntName;
else if (i == 2) Sensor3 = cmpntName;
else if (i == 3) Sensor4 = cmpntName;
else if (i == 4) Sensor5 = cmpntName;
else if (i == 5) Sensor6 = cmpntName;
else if (i == 6) Sensor7 = cmpntName;
else if (i == 7) Sensor8 = cmpntName;
else if (i == 8) Sensor9 = cmpntName;
else if (i == 9) Sensor10 = cmpntName;
else if (i == 10) Sensor11 = cmpntName;
else if (i == 11) Sensor12 = cmpntName;
else if (i == 12) Sensor13 = cmpntName;
else if (i == 13) Sensor14 = cmpntName;
else if (i == 14) Sensor15 = cmpntName;
else if (i == 15) Sensor16 = cmpntName;
else if (i == 16) Sensor17 = cmpntName;
else if (i == 17) Sensor18 = cmpntName;
else if (i == 18) Sensor19 = cmpntName;
else if (i == 19) Sensor20 = cmpntName;
else if (i == 20) Sensor21 = cmpntName;
else if (i == 21) Sensor22 = cmpntName;
else if (i == 22) Sensor23 = cmpntName;
else if (i == 23) Sensor24 = cmpntName;
else if (i == 24) Sensor25 = cmpntName;
else if (i == 25) Sensor26 = cmpntName;
else if (i == 26) Sensor27 = cmpntName;
else if (i == 27) Sensor28 = cmpntName;
else if (i == 28) Sensor29 = cmpntName;
else if (i == 29) Sensor30 = cmpntName;
else if (i == 30) Sensor31 = cmpntName;
else if (i == 31) Sensor32 = cmpntName;
else if (i == 32) Sensor33 = cmpntName;
else if (i == 33) Sensor34 = cmpntName;
else if (i == 34) Sensor35 = cmpntName;
else if (i == 35) Sensor36 = cmpntName;
else if (i == 36) Sensor37 = cmpntName;
else if (i == 37) Sensor38 = cmpntName;
else if (i == 38) Sensor39 = cmpntName;
else if (i == 39) Sensor40 = cmpntName;
}
}
}

View File

@ -0,0 +1,66 @@
///
/// Copyright (c) 2013-2017 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
namespace Config.Entities
{
public class OutputPath : IHasName, IHasItemNr, IHasValves
{
public virtual int Id { get; protected set; }
public virtual int ItemNr { get; set; }
public virtual string Name { get; set; }
public virtual string OriName { get; set; } /// Not mapped to database
public virtual float Qfrom { get; set; } /// Water flow in [m3/h]
public virtual float Qto { get; set; } /// Water flow in [m3/h]
public virtual string RegulValve { get; set; }
public virtual string FlowMeter { get; set; }
public virtual float PidCoef { get; set; } /// PID coefficient for the regulation path
public virtual string StartValve { get; set; }
public virtual string Diverter { get; set; }
public virtual string TempDiv { get; set; }
public virtual string Scale { get; set; }
public virtual string EmptyTankValve { get; set; } /// Not used anywhere
/// Valves
public virtual string ValvesOpen { get; set; }
public virtual string ValvesClose { get; set; }
/// ------------- Additional stuff not mapped into the database -------------
public OutputPath()
{
ValvesOpen = string.Empty;
ValvesClose = string.Empty;
}
public OutputPath(string name, int itemNr)
: this()
{
Name = name;
ItemNr = itemNr;
}
public virtual OutputPath Clone(string name, int itemNr)
{
OutputPath result = new OutputPath(name, itemNr);
result.Name = Name;
result.Qfrom = Qfrom;
result.Qto = Qto;
result.RegulValve = RegulValve;
result.FlowMeter = FlowMeter;
result.PidCoef = PidCoef;
result.StartValve = StartValve;
result.Diverter = Diverter;
result.TempDiv = TempDiv;
result.Scale = Scale;
result.EmptyTankValve = EmptyTankValve;
result.ValvesOpen = ValvesOpen;
result.ValvesClose = ValvesClose;
return result;
}
}
}

View File

@ -0,0 +1,242 @@
///
/// Copyright (c) 2013-2017 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
namespace Config.Entities
{
/// <summary>
/// Stores one test procedure, supports revisions and history log
/// </summary>
public class Procedure : IHasName, IHasItemNr
{
public virtual int Id { get; protected set; }
public virtual int ItemNr { get; set; }
public virtual string Name { get; set; }
public virtual string Description { get; set; } /// Short description
public virtual string CreationUser { get; set; } /// Name of the user who has created or changed this procedure
public virtual DateTime CreationTime { get; set; } /// Date and time of the creation or change
public virtual string LastChgUser { get; set; } /// Name of the user who has created or changed this procedure
public virtual DateTime LastChgTime { get; set; } /// Date and time of the creation or change
public virtual string LongDescription { get; set; } /// Long description (notes)
public virtual ProcedureState ProcedureState { get; set; }
public virtual int Revision { get; set; }
public virtual int PredecessorId { get; set; }
public virtual bool ObtainedByCopy { get; set; } /// Initial version of this procedure was a copy of another procedure
///
public virtual MetersKind MetersKind { get; set; } /// single / compound / heat meters
public virtual string Watermeters { get; set; } /// Water meter name or Id
public virtual bool Protected { get; set; } /// true = procedure cannot be changed by a testing specialist
public virtual bool MustBeComplete { get; set; } /// true = procedure can be finished just when all tests were finished
public virtual bool ManualCtrlDisabled { get; set; } /// true = manual control of valves, etc. is disabled
public virtual string DataEntry { get; set; } /// Component to use for data entry
public virtual string ResultsPrinter { get; set; } /// Component to use for printing the results
public virtual string ResultsWriter { get; set; } /// Component to use for saving the results into the file
public virtual string TransitionStart { get; set; }
public virtual string TransitionEnd { get; set; }
public virtual string AltProcName { get; set; } /// Alternative procedure name (null or string.Empty = no alt. procedure)
public virtual int AltProcPeriod { get; set; } /// Period of alternative procedures (0 = no alt. procedure)
public virtual IList<ComponentProcedure> MoreParams { get; set; }
public virtual IList<Test> Tests { get; set; }
/// ------------- Additional stuff not mapped into the database -------------
public Procedure()
{
MoreParams = new List<ComponentProcedure>();
Tests = new List<Test>();
///
/// Default values
///
CreationUser = (Users.GlobalData.CurrentUser != null) ? Users.GlobalData.CurrentUser.UserName : null;
CreationTime = DateTime.Now;
LastChgUser = CreationUser;
LastChgTime = CreationTime;
MetersKind = Entities.MetersKind.Single;
Watermeters = string.Empty;
Description = string.Empty;
LongDescription = string.Empty;
}
public Procedure(string name, int itemNr)
: this()
{
Name = name;
ItemNr = itemNr;
}
public virtual Procedure Clone()
{
Procedure result = new Procedure();
result.ItemNr = ItemNr;
result.Name = Name;
result.Description = Description;
result.CreationUser = CreationUser;
result.CreationTime = CreationTime;
result.LastChgUser = LastChgUser;
result.LastChgTime = LastChgTime;
result.LongDescription = LongDescription;
result.ProcedureState = ProcedureState;
result.Revision = Revision;
result.PredecessorId = Id;
result.ObtainedByCopy = ObtainedByCopy;
result.MetersKind = MetersKind;
result.Watermeters = Watermeters;
result.Protected = Protected;
result.MustBeComplete = MustBeComplete;
result.ManualCtrlDisabled = ManualCtrlDisabled;
result.DataEntry = DataEntry;
result.ResultsPrinter = ResultsPrinter;
result.ResultsWriter = ResultsWriter;
result.TransitionStart = TransitionStart;
result.TransitionEnd = TransitionEnd;
foreach (var prms in MoreParams) { result.MoreParams.Add(prms.Clone(result)); }
foreach (var test in Tests) { result.Tests.Add(test.Clone()); }
return result;
}
public virtual void Export(StreamWriter output)
{
output.WriteLine(ItemNr.ToString(CultureInfo.InvariantCulture));
output.WriteLine(Name);
output.WriteLine(Description);
output.WriteLine(CreationUser);
output.WriteLine(CreationTime.ToString(CultureInfo.InvariantCulture));
output.WriteLine(LastChgUser);
output.WriteLine(LastChgTime.ToString(CultureInfo.InvariantCulture));
output.WriteLine(MetersKind.ToString());
output.WriteLine(Watermeters);
output.WriteLine(Protected.ToString());
output.WriteLine(MustBeComplete.ToString());
output.WriteLine(ManualCtrlDisabled.ToString());
output.WriteLine(DataEntry);
output.WriteLine(ResultsPrinter);
output.WriteLine(ResultsWriter);
output.WriteLine(TransitionStart);
output.WriteLine(TransitionEnd);
foreach (var prms in MoreParams) { prms.Export(output); }
output.WriteLine();
foreach (var test in Tests) { test.Export(output); }
output.WriteLine();
output.Close();
}
public static Procedure Import(StreamReader input)
{
Procedure result = new Procedure();
result.ItemNr = int.Parse(input.ReadLine(), CultureInfo.InvariantCulture);
result.Name = input.ReadLine();
result.Description = input.ReadLine();
result.CreationUser = input.ReadLine();
result.CreationTime = DateTime.Parse(input.ReadLine(), CultureInfo.InvariantCulture);
result.LastChgUser = input.ReadLine();
result.LastChgTime = DateTime.Parse(input.ReadLine(), CultureInfo.InvariantCulture);
string line = input.ReadLine();
result.MetersKind = line.Equals(MetersKind.Single.ToString()) ? MetersKind.Single : (line.Equals(MetersKind.Combined.ToString()) ? MetersKind.Combined : MetersKind.HeatMeter);
result.Watermeters = input.ReadLine();
result.Protected = bool.Parse(input.ReadLine());
result.MustBeComplete = bool.Parse(input.ReadLine());
result.ManualCtrlDisabled = bool.Parse(input.ReadLine());
result.DataEntry = input.ReadLine();
result.ResultsPrinter = input.ReadLine();
result.ResultsWriter = input.ReadLine();
result.TransitionStart = input.ReadLine();
result.TransitionEnd = input.ReadLine();
while(true)
{
ComponentProcedure prms = ComponentProcedure.Import(input, result);
if (prms == null)
break;
else
result.MoreParams.Add(prms);
}
while (true)
{
Test tst = Test.Import(input, result);
if (tst == null)
break;
else
result.Tests.Add(tst);
}
return result;
}
public virtual string Compare(StreamReader inp)
{
System.Text.StringBuilder diff = new System.Text.StringBuilder();
const string fmt = "{0} = {1}\r\n (in the file {2})\r\n";
string ln;
ln = inp.ReadLine(); /// skip ItemNr
ln = inp.ReadLine(); if (ln != Name) { diff.AppendFormat(fmt, "Name", Name, ln); };
ln = inp.ReadLine(); if (ln != Description) { diff.AppendFormat(fmt, "Description", Description, ln); };
ln = inp.ReadLine(); /// skip CreationUser
ln = inp.ReadLine(); /// skip CreationTime
ln = inp.ReadLine(); /// skip LastChgUser
ln = inp.ReadLine(); /// skip LastChgTime
ln = inp.ReadLine(); if (ln != MetersKind.ToString()) { diff.AppendFormat(fmt, "MetersKind", MetersKind, ln); };
ln = inp.ReadLine(); if (ln != Watermeters) { diff.AppendFormat(fmt, "Watermeters", Watermeters, ln); };
ln = inp.ReadLine(); if (ln != Protected.ToString()) { diff.AppendFormat(fmt, "Protected", Protected, ln); };
ln = inp.ReadLine(); if (ln != MustBeComplete.ToString()) { diff.AppendFormat(fmt, "MustBeComplete", MustBeComplete, ln); };
ln = inp.ReadLine(); if (ln != ManualCtrlDisabled.ToString()) { diff.AppendFormat(fmt, "ManualCtrlDisabled", ManualCtrlDisabled, ln); };
ln = inp.ReadLine(); if (ln != DataEntry) { diff.AppendFormat(fmt, "DataEntry", DataEntry, ln); };
ln = inp.ReadLine(); if (ln != ResultsPrinter) { diff.AppendFormat(fmt, "ResultsPrinter", ResultsPrinter, ln); };
ln = inp.ReadLine(); if (ln != ResultsWriter) { diff.AppendFormat(fmt, "ResultsWriter", ResultsWriter, ln); };
ln = inp.ReadLine(); if (ln != TransitionStart) { diff.AppendFormat(fmt, "TransitionStart", TransitionStart, ln); };
ln = inp.ReadLine(); if (ln != TransitionEnd) { diff.AppendFormat(fmt, "TransitionEnd", TransitionEnd, ln); };
/// TODO Compare componentprocedure-s
while (ComponentProcedure.Import(inp, null) != null)
{
}
//foreach (var test in Tests)
//{
// string testDiff = test.Compare(inp);
// if (testDiff.Contains(
//}
//bool extraTestsInFile = true;
//while (Test.Import(inp, null) != null) { extraTestsInFile = true; }
return diff.ToString();
}
public virtual ComponentProcedure GetProcedureParamsEntity(string cmpntName)
{
foreach (var procPrms in MoreParams)
{
if (procPrms.CmpntName == cmpntName) return procPrms;
}
return null;
}
public override string ToString()
{
return string.Format("{0}, rev.{1}", Name, Revision);
}
}
}

View File

@ -0,0 +1,31 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
namespace Config.Entities
{
public class ProcedureHistory
{
public virtual int Id { get; protected set; }
public virtual Procedure Current { get; set; }
public virtual IList<Procedure> OldProcedures { get; set; }
/// ------------- Additional stuff not mapped into the database -------------
public ProcedureHistory()
{
Current = new Procedure();
OldProcedures = new List<Procedure>();
}
public virtual ProcedureHistory Clone()
{
ProcedureHistory result = new ProcedureHistory();
result.Current = Current.Clone();
foreach (Procedure p in OldProcedures) result.OldProcedures.Add(p.Clone());
return result;
}
}
}

View File

@ -0,0 +1,369 @@
///
/// Copyright (c) 2013-2017 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
namespace Config.Entities
{
/// <summary>
/// Test, consisting of one or more repetitions of the test 'SingleTest'.
/// </summary>
public class Test : IHasName, IHasItemNr
{
public virtual int Id { get; protected set; }
public virtual int ItemNr { get; set; }
public virtual string Name { get; set; }
public virtual int Part { get; set; } /// Part=0 ... test of all WM-s
/// Part>0 ... part of a set of tests with the same Name: subset of WM-s is given by MetersPath
public virtual sbyte Publish { get; set; } /// 0=no, 1=in all protocols, 2=on screen, 3=internal
public virtual bool DoEvaluate { get; set; }
public virtual float Qfrom { get; set; } /// Water flow low limit in [m3/h]
public virtual float Qto { get; set; } /// Water flow high limit in [m3/h]
public virtual float Volume { get; set; } /// Test volume (target) in [l]
public virtual float TstTime { get; set; } /// Test time (estimate) in [s]
public virtual string Method { get; set; }
public virtual float ErrLimLo { get; set; } /// in [%] (usually < 0) or 1=class1, 2=class2, 3=class3
public virtual float ErrLimHi { get; set; } /// in [%] (usually > 0) or -Qn in m3/h
public virtual float Uncertainty { get; set; } /// int [%] makes error limits tighter: 0 <= Uncertainty <= abs(ErrLimXx)
public virtual int Repeats { get; set; }
public virtual bool DoDraining { get; set; }
public virtual bool DoZeroing { get; set; }
public virtual bool DoControlWaterTemp { get; set; }
public virtual float TempLimLo { get; set; } /// Lower limit for the controlled temperature
public virtual float TempLimHi { get; set; } /// Upper limit for the controlled temperature
public virtual float PumpPower { get; set; } /// Power of the pump in [%] in the range 0 .. 100.0f, use values 0% and 100% for non-FM pumps
public virtual int MassRepeats { get; set; } /// Number of mass. measurements at the beginning/end of test, 0 = default (=5)
public virtual float MassSpread { get; set; } /// Max spread of mass. measurements at the beginning/end of test, 0 = default
public virtual MassMethod MassMethod { get; set; } /// method of mass. measurement at the beginning/end of test: false=slow (precise), true=using immediate mass measurement and evaluation
public virtual int TimeBeforeFlow { get; set; } /// Delay time before the start of flow control in [s]
public virtual int TimeFlow2Mass { get; set; } /// Delay time from the flow stable to the 1st mass measurement in [s]
public virtual int TimePump2StartV { get; set; } /// Delay time from the start of the pump to opening the start valve in [s]
public virtual int TimeStop2Mass { get; set; } /// Delay time from the test end (diverted) to the 2nd mass measuremen in [s]
public virtual double TolerRed { get; set; } /// = Filter
public virtual TestRedType RedType { get; set; }
public virtual string FeedingPath { get; set; }
public virtual string BenchPath { get; set; }
public virtual string OutputPath { get; set; }
public virtual string MetersPath { get; set; }
#if HEAT_METERS
public virtual string HeatMetersPath { get; set; }
#endif
public virtual string RelTransBefore { get; set; }
public virtual string RelTransBetween { get; set; }
public virtual string RelTransAfter { get; set; }
public virtual string TransitionAfter { get; set; }
public virtual IList<ComponentTest> MoreParams { get; set; }
public virtual Procedure Procedure { get; set; }
/// ------------- Additional stuff not mapped into the database -------------
public Test()
{
MoreParams = new List<ComponentTest>();
///
/// Default values
///
Publish = (sbyte)Config.Entities.Publish.Always;
DoEvaluate = true;
Repeats = 1;
DoDraining = false;
DoZeroing = false;
DoControlWaterTemp = false;
TempLimLo = 15.0f;
TempLimHi = 25.0f;
ErrLimLo = -2.0f; /// [%] lower error limit
ErrLimHi = 2.0f; /// [%] upper error limit
Uncertainty = 0;
PumpPower = 60.0f; /// [%]
MassRepeats = 0; /// default
MassSpread = 0; /// default
MassMethod = MassMethod.Scale; /// default
TimeBeforeFlow = 10; /// [s] time before the start of flow control in [s]
TimeFlow2Mass = 5; /// [s] time from the flow stable to the 1st mass measurement in [s]
TimePump2StartV = 1; /// [s] time from the 1st mass measurement to the test start in [s]
TimeStop2Mass = 5; /// [s] between the test end and the final mass measurement
TolerRed = 0; /// = Filter parameter
RelTransBefore = string.Empty;
RelTransBetween = string.Empty;
RelTransAfter = string.Empty;
TransitionAfter = string.Empty;
}
public Test(string name, int itemNr, Procedure procedure)
: this()
{
Name = name;
ItemNr = itemNr;
Procedure = procedure;
}
// Makes a new copy of this object (not just a reference)
public virtual Test Clone()
{
Test result = new Test(Name, ItemNr, Procedure);
result.Part = Part;
result.Publish = Publish;
result.DoEvaluate = DoEvaluate;
result.Qfrom = Qfrom;
result.Qto = Qto;
result.Volume = Volume;
result.TstTime = TstTime;
result.Method = Method;
result.ErrLimLo = ErrLimLo;
result.ErrLimHi = ErrLimHi;
result.Uncertainty = Uncertainty;
result.Repeats = Repeats;
result.DoDraining = DoDraining;
result.DoZeroing = DoZeroing;
result.DoControlWaterTemp = DoControlWaterTemp;
result.TempLimLo = TempLimLo;
result.TempLimHi = TempLimHi;
result.PumpPower = PumpPower;
result.MassRepeats = MassRepeats;
result.MassSpread = MassSpread;
result.MassMethod = MassMethod;
result.TimeBeforeFlow = TimeBeforeFlow;
result.TimeFlow2Mass = TimeFlow2Mass;
result.TimePump2StartV = TimePump2StartV;
result.TimeStop2Mass = TimeStop2Mass;
result.TolerRed = TolerRed;
result.RedType = RedType;
result.FeedingPath = FeedingPath;
result.BenchPath = BenchPath;
result.OutputPath = OutputPath;
result.MetersPath = MetersPath;
#if HEAT_METERS
result.HeatMetersPath = HeatMetersPath;
#endif
result.RelTransBefore = RelTransBefore;
result.RelTransBetween = RelTransBetween;
result.RelTransAfter = RelTransAfter;
result.TransitionAfter = TransitionAfter;
foreach (var prms in MoreParams) { result.MoreParams.Add(prms.Clone()); }
return result;
}
public virtual void Export(StreamWriter output)
{
CultureInfo ci = CultureInfo.InvariantCulture;
output.WriteLine(Name);
output.WriteLine(Part.ToString(ci));
output.WriteLine(Publish.ToString(ci));
output.WriteLine(DoEvaluate.ToString());
output.WriteLine(Qfrom.ToString(ci));
output.WriteLine(Qto.ToString(ci));
output.WriteLine(Volume.ToString(ci));
output.WriteLine(TstTime.ToString(ci));
output.WriteLine(Method);
output.WriteLine(ErrLimLo.ToString(ci));
output.WriteLine(ErrLimHi.ToString(ci));
output.WriteLine(Uncertainty.ToString(ci));
output.WriteLine(Repeats.ToString(ci));
output.WriteLine(DoDraining.ToString());
output.WriteLine(DoZeroing.ToString());
output.WriteLine(DoControlWaterTemp.ToString());
output.WriteLine(TempLimLo.ToString(ci));
output.WriteLine(TempLimHi.ToString(ci));
output.WriteLine(PumpPower.ToString(ci));
output.WriteLine(MassRepeats.ToString(ci));
output.WriteLine(MassSpread.ToString(ci));
output.WriteLine(((byte)MassMethod).ToString(ci));
output.WriteLine(TimeBeforeFlow.ToString(ci));
output.WriteLine(TimeFlow2Mass.ToString(ci));
output.WriteLine(TimePump2StartV.ToString(ci));
output.WriteLine(TimeStop2Mass.ToString(ci));
output.WriteLine(FeedingPath);
output.WriteLine(BenchPath);
output.WriteLine(OutputPath);
output.WriteLine(MetersPath);
output.WriteLine(RelTransBefore);
output.WriteLine(RelTransBetween);
output.WriteLine(RelTransAfter);
output.WriteLine(TransitionAfter);
foreach (var prms in MoreParams) { prms.Export(output); }
output.WriteLine();
}
public static Test Import(StreamReader input, Procedure newProcedure)
{
string firstLine = input.ReadLine();
if (string.IsNullOrEmpty(firstLine))
{
return null;
}
CultureInfo ci = CultureInfo.InvariantCulture;
Test tst = new Test();
tst.Name = firstLine;
tst.Part = int.Parse(input.ReadLine(), ci);
tst.Publish = sbyte.Parse(input.ReadLine(), ci);
tst.DoEvaluate = bool.Parse(input.ReadLine());
tst.Qfrom = float.Parse(input.ReadLine(), ci);
tst.Qto = float.Parse(input.ReadLine(), ci);
tst.Volume = float.Parse(input.ReadLine(), ci);
tst.TstTime = float.Parse(input.ReadLine(), ci);
tst.Method = input.ReadLine();
tst.ErrLimLo = float.Parse(input.ReadLine(), ci);
tst.ErrLimHi = float.Parse(input.ReadLine(), ci);
tst.Uncertainty = float.Parse(input.ReadLine(), ci);
tst.Repeats = int.Parse(input.ReadLine(), ci);
tst.DoDraining = bool.Parse(input.ReadLine());
tst.DoZeroing = bool.Parse(input.ReadLine());
tst.DoControlWaterTemp = bool.Parse(input.ReadLine());
tst.TempLimLo = float.Parse(input.ReadLine(), ci);
tst.TempLimHi = float.Parse(input.ReadLine(), ci);
tst.PumpPower = float.Parse(input.ReadLine(), ci);
tst.MassRepeats = int.Parse(input.ReadLine(), ci);
tst.MassSpread = float.Parse(input.ReadLine(), ci);
tst.MassMethod = (MassMethod)byte.Parse(input.ReadLine(), ci);
tst.TimeBeforeFlow = int.Parse(input.ReadLine(), ci);
tst.TimeFlow2Mass = int.Parse(input.ReadLine(), ci);
tst.TimePump2StartV = int.Parse(input.ReadLine(), ci);
tst.TimeStop2Mass = int.Parse(input.ReadLine(), ci);
tst.FeedingPath = input.ReadLine();
tst.BenchPath = input.ReadLine();
tst.OutputPath = input.ReadLine();
tst.MetersPath = input.ReadLine();
tst.RelTransBefore = input.ReadLine();
tst.RelTransBetween = input.ReadLine();
tst.RelTransAfter = input.ReadLine();
tst.TransitionAfter = input.ReadLine();
while (true)
{
ComponentTest prms = ComponentTest.Import(input, tst);
if (prms == null)
break;
else
tst.MoreParams.Add(prms);
}
tst.Procedure = newProcedure;
return tst;
}
public virtual string Compare(StreamReader inp)
{
System.Text.StringBuilder diff = new System.Text.StringBuilder();
string fmt = string.Format("Test {0} : ", Name) + "{0} = {1}\r\n (in the file {2})\r\n";
string ln;
CultureInfo ci = CultureInfo.InvariantCulture;
string firstLine = inp.ReadLine();
if (string.IsNullOrEmpty(firstLine)) return string.Format("Test {0} is missing in the file\r\n", Name);
if (Name != firstLine) { diff.AppendFormat(fmt, "Name", Name, firstLine); };
ln = inp.ReadLine(); if (ln != Part.ToString(ci)) { diff.AppendFormat(fmt, "Part", Part.ToString(ci), ln); };
ln = inp.ReadLine(); if (ln != Publish.ToString(ci)) { diff.AppendFormat(fmt, "Publish", Publish.ToString(ci), ln); };
ln = inp.ReadLine(); if (ln != DoEvaluate.ToString(ci)) { diff.AppendFormat(fmt, "Evaluate", DoEvaluate.ToString(ci), ln); };
ln = inp.ReadLine(); if (ln != Qfrom.ToString(ci)) { diff.AppendFormat(fmt, "Qfrom", Qfrom.ToString(ci), ln); };
ln = inp.ReadLine(); if (ln != Qto.ToString(ci)) { diff.AppendFormat(fmt, "Qto", Qto.ToString(ci), ln); };
ln = inp.ReadLine(); if (ln != Volume.ToString(ci)) { diff.AppendFormat(fmt, "Volume", Volume.ToString(ci), ln); };
ln = inp.ReadLine(); if (ln != TstTime.ToString(ci)) { diff.AppendFormat(fmt, "TstTime", TstTime.ToString(ci), ln); };
ln = inp.ReadLine(); if (ln != Method) { diff.AppendFormat(fmt, "Method", Method, ln); };
ln = inp.ReadLine(); if (ln != ErrLimLo.ToString(ci)) { diff.AppendFormat(fmt, "ErrLimLo", ErrLimLo.ToString(ci), ln); };
ln = inp.ReadLine(); if (ln != ErrLimHi.ToString(ci)) { diff.AppendFormat(fmt, "ErrLimHi", ErrLimHi.ToString(ci), ln); };
ln = inp.ReadLine(); if (ln != Uncertainty.ToString(ci)) { diff.AppendFormat(fmt, "Uncertainty", Uncertainty.ToString(ci), ln); };
ln = inp.ReadLine(); if (ln != Repeats.ToString(ci)) { diff.AppendFormat(fmt, "Repeats", Repeats.ToString(ci), ln); };
ln = inp.ReadLine(); if (ln != DoDraining.ToString(ci)) { diff.AppendFormat(fmt, "Draining", DoDraining.ToString(ci), ln); };
ln = inp.ReadLine(); if (ln != DoZeroing.ToString(ci)) { diff.AppendFormat(fmt, "Zeroing", DoZeroing.ToString(ci), ln); };
ln = inp.ReadLine(); if (ln != DoControlWaterTemp.ToString()) { diff.AppendFormat(fmt, "DoControlWaterTemp", DoControlWaterTemp.ToString(ci), ln); };
ln = inp.ReadLine(); if (ln != TempLimLo.ToString(ci)) { diff.AppendFormat(fmt, "TempLimLo", TempLimLo.ToString(ci), ln); };
ln = inp.ReadLine(); if (ln != TempLimHi.ToString(ci)) { diff.AppendFormat(fmt, "TempLimHi", TempLimHi.ToString(ci), ln); };
ln = inp.ReadLine(); if (ln != PumpPower.ToString(ci)) { diff.AppendFormat(fmt, "PumpPower", PumpPower.ToString(ci), ln); };
ln = inp.ReadLine(); if (ln != MassRepeats.ToString(ci)) { diff.AppendFormat(fmt, "MassRepeats", MassRepeats.ToString(ci), ln); };
ln = inp.ReadLine(); if (ln != MassSpread.ToString(ci)) { diff.AppendFormat(fmt, "MassSpread", MassSpread.ToString(ci), ln); };
ln = inp.ReadLine(); if (ln != ((byte)MassMethod).ToString(ci)) { diff.AppendFormat(fmt, "MassMethod", ((byte)MassMethod).ToString(ci), ln); };
ln = inp.ReadLine(); if (ln != TimeBeforeFlow.ToString(ci)) { diff.AppendFormat(fmt, "TimeBeforeFlow", TimeBeforeFlow.ToString(ci), ln); };
ln = inp.ReadLine(); if (ln != TimeFlow2Mass.ToString(ci)) { diff.AppendFormat(fmt, "TimeFlow2Mass", TimeFlow2Mass.ToString(ci), ln); };
ln = inp.ReadLine(); if (ln != TimePump2StartV.ToString(ci)) { diff.AppendFormat(fmt, "TimePump2StartV", TimePump2StartV.ToString(ci), ln); };
ln = inp.ReadLine(); if (ln != TimeStop2Mass.ToString(ci)) { diff.AppendFormat(fmt, "TimeStop2Mass", TimeStop2Mass.ToString(ci), ln); };
ln = inp.ReadLine(); if (ln != FeedingPath) { diff.AppendFormat(fmt, "FeedingPath", FeedingPath, ln); };
ln = inp.ReadLine(); if (ln != BenchPath) { diff.AppendFormat(fmt, "BenchPath", BenchPath, ln); };
ln = inp.ReadLine(); if (ln != OutputPath) { diff.AppendFormat(fmt, "OutputPath", OutputPath, ln); };
ln = inp.ReadLine(); if (ln != MetersPath) { diff.AppendFormat(fmt, "MetersPath", MetersPath, ln); };
ln = inp.ReadLine(); if (ln != RelTransBefore) { diff.AppendFormat(fmt, "RelTransBefore", RelTransBefore, ln); };
ln = inp.ReadLine(); if (ln != RelTransBetween) { diff.AppendFormat(fmt, "RelTransBetween", RelTransBetween, ln); };
ln = inp.ReadLine(); if (ln != RelTransAfter) { diff.AppendFormat(fmt, "RelTransAfter", RelTransAfter, ln); };
ln = inp.ReadLine(); if (ln != TransitionAfter) { diff.AppendFormat(fmt, "TransitionAfter", TransitionAfter, ln); };
return diff.ToString();
}
public virtual ComponentTest GetTestParamsEntity(string cmpntName)
{
foreach (var tstPrms in MoreParams)
{
if (tstPrms.CmpntName == cmpntName) return tstPrms;
}
return null;
}
public virtual float GetErrLimLo(float flow)
{
if (ErrLimLo <= ErrLimHi)
{
return ErrLimLo; /// Error limit of a water meter
}
else
{
/// Metrological class and nominal flow of a heat meter
int metrClass = (int)Math.Round(ErrLimLo);
float Qp = Math.Abs(ErrLimHi);
float Q = Math.Max(flow, 0.00001f); /// to avoid division by zero
/// Calculate the error limit of a heat meter
switch (metrClass)
{
default:
case 1: return -Math.Min(3.5f, 1.0f + 0.01f * Qp / Q);
case 2: return -Math.Min(5.0f, 2.0f + 0.02f * Qp / Q);
case 3: return -Math.Min(5.0f, 3.0f + 0.05f * Qp / Q);
}
}
}
public virtual float GetErrLimHi(float flow)
{
if (ErrLimLo <= ErrLimHi)
{
return ErrLimHi; /// Error limit of a water meter
}
else
{
/// Metrological class and nominal flow of a heat meter
int metrClass = (int)Math.Round(ErrLimLo);
float Qp = Math.Abs(ErrLimHi);
float Q = Math.Max(flow, 0.00001f); /// to avoid division by zero
/// Calculate the error limit of a heat meter
switch (metrClass)
{
default:
case 1: return +Math.Min(3.5f, 1.0f + 0.01f * Qp / Q);
case 2: return +Math.Min(5.0f, 2.0f + 0.02f * Qp / Q);
case 3: return +Math.Min(5.0f, 3.0f + 0.05f * Qp / Q);
}
}
}
public override string ToString()
{
string partStr = (Part > 0) ? string.Format(", part {0}", Part) : string.Empty;
return string.Format("{0}(P.{1},{2}){3}", Name, ((Publish)Publish).ToString(), DoEvaluate ? "E" : "-", partStr);
}
}
}

View File

@ -0,0 +1,41 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
///
using System.Collections.Generic;
namespace Config.Entities
{
/// <summary>
/// Stores one transition sequence containing a list of transition steps
/// </summary>
public class TransitionSequence : IHasName, IHasItemNr
{
public virtual int Id { get; protected set; }
public virtual int ItemNr { get; set; }
public virtual string Name { get; set; }
public virtual string OriName { get; set; } /// Not mapped to database
public virtual string Description { get; set; } /// Short description
public virtual IList<TransitionStep> TransitionSteps { get; set; }
public TransitionSequence()
{
TransitionSteps = new List<TransitionStep>();
}
public TransitionSequence(string name, int itemNr)
: this()
{
Name = name;
ItemNr = itemNr;
}
public virtual TransitionSequence Clone()
{
TransitionSequence result = new TransitionSequence();
result.Name = Name;
result.Description = Description;
foreach (var step in TransitionSteps) { result.TransitionSteps.Add(step.Clone()); }
return result;
}
}
}

View File

@ -0,0 +1,65 @@
///
/// Copyright (c) 2013-2015, 2017 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
namespace Config.Entities
{
public class TransitionStep : IHasItemNr, IHasValves
{
public virtual int Id { get; protected set; }
public virtual int ItemNr { get; set; } /// Order of the preparation step
public virtual int Duration { get; set; } /// Duration in seconds
public virtual string Message { get; set; } /// Message
public virtual string EndCondition { get; set; } /// Condition when transition step is finished (next to the duration)
public virtual string ValvesOpen { get; set; } /// List of valves to be opened
public virtual string ValvesClose { get; set; } /// List of valves to be closed
public virtual string RegulValvesPct { get; set; } /// Positions of regulation valves in % separated by ';'
public virtual string PumpWithFMPcts { get; set; } /// Power of FM controlled pumps in % separated by ';'
public virtual TransitionSequence TransitionSequence { get; set; }
/// ------------- Additional stuff not mapped into the database -------------
public TransitionStep()
{
Duration = 5; /// sec.
EndCondition = "None";
}
public TransitionStep(int itemNr, TransitionSequence sequence)
: this()
{
ItemNr = itemNr;
TransitionSequence = sequence;
}
public virtual TransitionStep Clone()
{
TransitionStep result = new TransitionStep(ItemNr, TransitionSequence);
result.Duration = Duration;
result.Message = Message;
result.EndCondition = EndCondition;
result.ValvesOpen = ValvesOpen;
result.ValvesClose = ValvesClose;
result.RegulValvesPct = RegulValvesPct;
result.PumpWithFMPcts = PumpWithFMPcts;
return result;
}
public virtual string ToString(string indent)
{
string result = "";
result += indent + "ItemNr = " + ItemNr.ToString() + ", ";
result += indent + "Duration = " + Duration.ToString() + ", ";
result += indent + "Message = " + Message + ", ";
result += indent + "EndCondition = " + EndCondition + ", ";
result += indent + "ValvesOpen = " + ValvesOpen + ", ";
result += indent + "ValvesClose = " + ValvesClose + ", ";
result += indent + "RegulValvesPct = " + RegulValvesPct + ", ";
result += indent + "PumpsWithFMPct = " + PumpWithFMPcts + Environment.NewLine;
return result;
}
}
}

View File

@ -0,0 +1,43 @@
///
/// Copyright (c) 2013-2017 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
namespace Config.Entities
{
public class User
{
public virtual int Id { get; protected set; }
public virtual string UserName { get; set; } /// = name, alias, abbreviation
public virtual string FullName { get; set; } /// = description
public virtual int Number { get; set; }
public virtual string Password { get; set; }
public virtual DateTime LastPwChange { get; set; }
public virtual IList<Group> Groups { get; set; } //User can be a member of a list of groups
public User()
{
Groups = new List<Group>();
}
/// <summary>
/// Adds a group to the user.
/// </summary>
/// <param name="group">Group to be added</param>
public virtual void AddGroup(Group group)
{
Groups.Add(group);
}
/// <summary>
/// Encrypts and sets users password.
/// </summary>
/// <param name="password">Unencrypted password</param>
public virtual void SetPassword(string password)
{
Password = Users.Entities.User.getHash(password);
LastPwChange = DateTime.Now;
}
}
}

View File

@ -0,0 +1,39 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
namespace Config.Entities
{
public class VirtualBenchSequence : IHasName, IHasItemNr
{
public virtual int Id { get; protected set; }
public virtual int ItemNr { get; set; }
public virtual string Name { get; set; }
public virtual string OriName { get; set; } /// Not mapped to database
public virtual string Description { get; set; } /// Short description
public virtual IList<VirtualBenchStep> VirtualBenchSteps { get; set; }
public VirtualBenchSequence()
{
VirtualBenchSteps = new List<VirtualBenchStep>();
}
public VirtualBenchSequence(string name, int itemNr)
: this()
{
Name = name;
ItemNr = itemNr;
}
public virtual VirtualBenchSequence Clone()
{
VirtualBenchSequence result = new VirtualBenchSequence();
result.Name = Name;
result.Description = Description;
foreach (var step in VirtualBenchSteps) { result.VirtualBenchSteps.Add(step.Clone()); }
return result;
}
}
}

View File

@ -0,0 +1,39 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
namespace Config.Entities
{
public class VirtualBenchStep : IHasItemNr
{
public virtual int Id { get; protected set; }
public virtual int ItemNr { get; set; } /// Order of the preparation step
public virtual int Duration { get; set; } /// Duration in seconds
///
public virtual VirtualBenchSequence VirtualBenchSequence { get; set; }
/// ------------- Additional stuff not mapped into the database -------------
public VirtualBenchStep()
{
Duration = 5; /// sec.
}
public VirtualBenchStep(int itemNr, VirtualBenchSequence sequence)
: this()
{
ItemNr = itemNr;
VirtualBenchSequence = sequence;
}
public virtual VirtualBenchStep Clone()
{
VirtualBenchStep result = new VirtualBenchStep(ItemNr, VirtualBenchSequence);
return result;
}
}
}

View File

@ -0,0 +1,78 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
/// This class holds the watermeter type specific data
/// that have all watermaters of the same type in common
namespace Config.Entities
{
public class WMType
{
// mapped
public virtual int Id { get; protected set; } /// primary key
public virtual DateTime CreateTime { get; set; } /// Date and time of the creation or change
public virtual string CreateUserName { get; set; } /// Name of the user who has created or changed this procedure
public virtual string CreateDescription { get; set; } /// Description\
public virtual string Name { get; set; } /// type name
public virtual float PulseRate { get; set; } /// Pulses per Liter
// not yet mapped
public virtual int IdentNr { get; protected set; } /// identification number of watermeter tzpe
public virtual int Diameter { get; set; } /// nominal diameter
public virtual int Pressure { get; set; } /// nominal pressure
public virtual int Length { get; set; } /// construction length
public virtual int Temperatur { get; set; } /// nominal temperature in C
public virtual float NominalFlow { get; set; } /// nominal flow Qn
/// ------------- Additional stuff not mapped into the database -------------
public WMType()
{
}
public static WMType DefaultWMType()
{
WMType procedure = new WMType()
{
CreateTime = DateTime.Now,
CreateUserName = Users.GlobalData.CurrentUser.UserName,
CreateDescription = "A default water meter created.",
Name = "Watermeter",
PulseRate = 1000,
};
return procedure;
}
public virtual WMType Clone()
{
WMType result = new WMType();
result.CreateTime = CreateTime;
result.CreateUserName = CreateUserName;
result.CreateDescription = CreateDescription;
result.Name = Name;
result.PulseRate = PulseRate;
return result;
}
public override string ToString()
{
string result = "";
result += "WMTpe: " + Environment.NewLine;
result += " Name = " + Name + Environment.NewLine;
result += " Created by = " + CreateUserName + Environment.NewLine;
result += " Created on = " + CreateTime.ToString() + Environment.NewLine;
result += " Description = " + CreateDescription + Environment.NewLine;
result += " Pulse rate = " + PulseRate.ToString() + Environment.NewLine;
return result;
}
}
}

View File

@ -0,0 +1,40 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NHibernate;
using FluentNHibernate;
namespace Config.Entities
{
public class Watermeter
{
public virtual int Id { get; protected set; } /// primary key
public virtual DateTime CreateTime { get; set; } /// Date and time of the creation or change
public virtual string CreateUserName { get; set; } /// Name of the user who has created or changed this procedure
public virtual string CreateDescription { get; set; } /// Description
/// mapped
public virtual string Serial { get; set; } /// serial number
public virtual WMType WMType { get; set; } /// type of watermeter
///
/// <summary>
/// Load a watermeter from the database
/// </summary>
public static Watermeter LoadBySerialnr(string SerialNr)
{
IList<Watermeter> ListOfWatermeters = FluentCommon.CreateSession(Users.Entities.DBKind.Results)
.CreateQuery("FROM Watermeter WHERE Serial = :SerialNrParameter")
.SetParameter("SerialNrParameter", SerialNr)
.List<Watermeter>();
if (ListOfWatermeters.Count > 0) return ListOfWatermeters.ElementAt(0);
return null;
}
}
}

View File

@ -0,0 +1,247 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
///
using System;
using System.Windows.Forms;
using FluentNHibernate.Cfg;
using FluentNHibernate.Cfg.Db;
using NHibernate;
using NHibernate.Cfg;
using NHibernate.Tool.hbm2ddl;
using Config.Resources;
namespace Config
{
public static class FluentCommon
{
/// <summary>
/// Session factories for regular sessions.
/// </summary>
public static ISessionFactory[] SessionFactories = new ISessionFactory[(int)Users.Entities.DBKind.Count];
/// <summary>
/// NHibernate session factory (to create the database session 'SessionFactory')
/// </summary>
/// <returns>A database session</returns>
static ISessionFactory CreateSessionFactory(Users.Entities.DBKind database)
{
Users.Entities.DBType dbType;
string connectionString;
switch (database)
{
default:
case Users.Entities.DBKind.Config:
dbType = Data.CurrentBench.ProceduresDBSettings.DbType;
connectionString = Data.CurrentBench.ProceduresDBSettings.ConnectionString;
break;
case Users.Entities.DBKind.Results:
dbType = Data.CurrentBench.WaterMetersDBSettings.DbType;
connectionString = Data.CurrentBench.WaterMetersDBSettings.ConnectionString;
break;
case Users.Entities.DBKind.RemoteConfig:
dbType = Data.CurrentBench.UsersDBSettings.DbType;
connectionString = Data.CurrentBench.UsersDBSettings.ConnectionString;
break;
}
return CreateSessionFactory(database, dbType, connectionString, false);
}
/// <summary>
/// NHibernate session factory (to create the database session 'SessionFactory')
/// </summary>
/// <returns>A database session</returns>
public static ISessionFactory CreateSessionFactory(Users.Entities.DBKind database, Users.Entities.DBType dbType, string connectionString, bool createDB)
{
try
{
FluentConfiguration cfg = Fluently.Configure();
switch (dbType)
{
default:
case Users.Entities.DBType.SQLite:
cfg = cfg.Database(SQLiteConfiguration.Standard.UsingFile(connectionString));
break;
case Users.Entities.DBType.MySql:
cfg = cfg.Database(MySQLConfiguration.Standard.ConnectionString(connectionString));
break;
}
switch (database)
{
default:
case Users.Entities.DBKind.Config:
case Users.Entities.DBKind.RemoteConfig:
cfg = cfg.Mappings(m => m.FluentMappings.AddFromAssemblyOf<Data>());
break;
case Users.Entities.DBKind.Results:
cfg = cfg.Mappings(m => m.FluentMappings.AddFromAssemblyOf<Data>());
break;
}
if (createDB)
{
return cfg.ExposeConfiguration(BuildSchemaCreate).BuildSessionFactory();
}
else
{
return cfg.ExposeConfiguration(BuildSchema).BuildSessionFactory();
}
}
catch (Exception exc)
{
MessageBox.Show(string.Format(Strings.Cannot_open_DB_Cause_0, exc.Message),
Strings.Error,
MessageBoxButtons.OK,
MessageBoxIcon.Error);
return null;
}
}
public delegate void BuildSchemaDlgt(Configuration config);
static void BuildSchema(Configuration config)
{
/// This NHibernate tool takes a configuration (with mapping info in)
/// and exports a database schema from it
new SchemaExport(config).SetOutputFile("db_schema");
}
static void BuildSchemaCreate(Configuration config)
{
/// This NHibernate tool takes a configuration (with mapping info in)
/// and exports a database schema from it
new SchemaExport(config).Create(true, true);
}
/// Create a NHibernate session for the given database
public static ISession CreateSession(Users.Entities.DBKind database)
{
int ix = (int)database;
if (ix < 0 || ix >= (int)Users.Entities.DBKind.Count) return null;
if (SessionFactories[ix] == null) SessionFactories[ix] = CreateSessionFactory(database);
return SessionFactories[ix].OpenSession();
}
public static void SaveToDb(Users.Entities.DBKind database, object obj)
{
SaveToDb(CreateSession(database), obj);
}
public static void SaveToDb(ISession session, object obj)
{
using (var transaction = session.BeginTransaction())
{
try
{
session.SaveOrUpdate(obj);
transaction.Commit();
}
catch
{
transaction.Rollback();
}
}
}
public static void DeleteFromDb(Users.Entities.DBKind database, object obj)
{
DeleteFromDb(CreateSession(database), obj);
}
public static void DeleteFromDb(ISession session, object obj)
{
using (var transaction = session.BeginTransaction())
{
session.Delete(obj);
transaction.Commit();
}
}
/// <summary>
/// Create an empty users database.
/// Database contains only the user 'admin' and the control board component 'CB'.
/// </summary>
/// <param name="dbType">DBType.SQLite or DBType.MySql</param>
/// <param name="connectionString">Connection string</param>
/// <returns>true=success, false=error</returns>
public static bool CreateEmptyConfigDB(Users.Entities.DBType dbType, string connectionString)
{
ISessionFactory sessionFactory = CreateSessionFactory(Users.Entities.DBKind.Config, dbType, connectionString, true);
if (sessionFactory == null) return false;
/// Populate the database
using (var session = sessionFactory.OpenSession())
{
using (var transaction = session.BeginTransaction())
{
///
/// Prepare all groups
///
var testers = new Config.Entities.Group((int)Users.Grp.GID.Testers, Strings.Tester);
var testingSpecialists = new Config.Entities.Group((int)Users.Grp.GID.TestingSpecialists, Strings.Testing_Specialist);
var headOfLab = new Config.Entities.Group((int)Users.Grp.GID.HeadOfLab, Strings.Head_of_Lab);
var maintenanceSpecialists = new Config.Entities.Group((int)Users.Grp.GID.MaintenanceSpecialists, Strings.Maintenance_Specialist);
var metrologists = new Config.Entities.Group((int)Users.Grp.GID.Metrologists, Strings.Metrologist);
var calibrationSpecialists = new Config.Entities.Group((int)Users.Grp.GID.CalibrationSpecialists, Strings.Calibration_Specialist);
var administrators = new Config.Entities.Group((int)Users.Grp.GID.Administrators, Strings.Administrator);
/// Create the user 'admin' add his groups
var admin = new Config.Entities.User
{
UserName = Data.AdminUsername,
FullName = Strings.Administrator,
LastPwChange = DateTime.Now
};
admin.SetPassword(Data.AdminPassword);
admin.AddGroup(testers);
admin.AddGroup(testingSpecialists);
admin.AddGroup(headOfLab);
admin.AddGroup(maintenanceSpecialists);
admin.AddGroup(metrologists);
admin.AddGroup(calibrationSpecialists);
admin.AddGroup(administrators);
session.SaveOrUpdate(admin);
///// Create the control board component
//var cmpnt = (new BenchControl.Elde.ControlBoardCfg(new BenchControl.Elde.ControlBoardFactory())).CreateDbEntity();
//session.SaveOrUpdate(cmpnt);
transaction.Commit();
}
}
return true;
}
/// <summary>
/// Create an empty water meters database
/// </summary>
/// <param name="dbType">DBType.SQLite or DBType.MySql</param>
/// <param name="connectionString">Connection string</param>
/// <returns>true=success, false=error</returns>
public static bool CreateEmptyResultsDB(Users.Entities.DBType dbType, string connectionString)
{
ISessionFactory sessionFactory = CreateSessionFactory(Users.Entities.DBKind.Results, dbType, connectionString, true);
if (sessionFactory == null) return false;
/// Populate the database
//using (var session = sessionFactory.OpenSession())
//{
// using (var transaction = session.BeginTransaction())
// {
// /// Create one component
// var cmpnt = (new BenchControl.Elde.ControlBoardCfg("CB", 1)).CreateDbEntity();
// session.SaveOrUpdate(cmpnt);
// transaction.Commit();
// }
//}
return true;
}
}
}

View File

@ -0,0 +1,399 @@
///
/// Copyright (c) 2013-2018 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using log4net;
namespace Config
{
public static class Formulas
{
private static readonly ILog log = LogManager.GetLogger(typeof(Formulas));
private static readonly ILog logrefError = LogManager.GetLogger("RefErrorLog");
///
/// Tables to calculate specific enthalpy
///
private static readonly int[] Ii;
private static readonly int[] Ji;
private static readonly double[] ni;
private static readonly double[] Di;
/// <summary>
/// Constructor
/// </summary>
static Formulas()
{
///
/// Initialize tables to calculate specific enthalpies
///
Ii = new int[34] { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 8, 8, 21, 23, 29, 30, 31, 32 };
Ji = new int[34] { -2, -1, 0, 1, 2, 3, 4, 5, -9, -7, -1, 0, 1, 3, -3, 0, 1, 3, 17, -4, 0, 6, -5, -2, 10, -8, -11, -6, -29, -31, -38, -39, -40, -41 };
ni = new double[34] {
0.14632971213167, /// 1
-0.84548187169114, /// 2
-0.37563603672040E1, /// 3
0.33855169168385E1, /// 4
-0.95791963387872, /// 5
0.15772038513228, /// 6
-0.16616417199501E-1, /// 7
0.81214629983568E-3, /// 8
0.28319080123804E-3, /// 9
-0.60706301565874E-3, /// 10
-0.18990068218419E-1, /// 11
-0.32529748770505E-1, /// 12
-0.21841717175414E-1, /// 13
-0.52838357969930E-4, /// 14
-0.47184321073267E-3, /// 15
-0.30001780793026E-3, /// 16
0.47661393906987E-4, /// 17
-0.44141845330846E-5, /// 18
-0.72694996297594E-15, /// 19
-0.31679644845054E-4, /// 20
-0.28270797985312E-5, /// 21
-0.85205128120103E-9, /// 22
-0.22425281908000E-5, /// 23
-0.65171222895601E-6, /// 24
-0.14341729937924E-12, /// 25
-0.40516996860117E-6, /// 26
-0.12734301741641E-8, /// 27
-0.17424871230634E-9, /// 28
-0.68762131295531E-18, /// 29
0.14478307828521E-19, /// 30
0.26335781662795E-22, /// 31
-0.11947622640071E-22, /// 32
0.18228094581404E-23, /// 33
-0.93537087292458E-25, /// 34
};
///
/// Initialize a table to calculate temperature of a platinum thermometer from resistance
///
Di = new double[]
{
439.932854,
472.418020,
37.684494,
7.472018,
2.920828,
0.005184,
-0.963864,
-0.188732,
0.191203,
0.049025,
};
}
/// <summary>
/// Calculate density of distilled water from temperature
/// </summary>
/// <param name="t">ITS-90 temperature in [°C]</param>
/// <returns>Density in [kg/m3]</returns>
public static double DistilledWaterDensityFromTemp(double t)
{
if (t <= 40)
{
const double c0 = 999.839564;
const double c1 = 0.067998613;
const double c2 = -0.0091101468;
const double c3 = 0.00010058299;
const double c4 = -0.0000011275659;
const double c5 = 6.5985371e-09;
return ((((c5 * t + c4) * t + c3) * t + c2) * t + c1) * t + c0;
}
else
{
const double a0 = 9.9983952E2;
const double a1 = 1.6952577E1;
const double a2 = -7.9905127E-3;
const double a3 = -4.6241757E-5;
const double a4 = 1.0584601E-7;
const double a5 = -2.8103006E-10;
const double b = 1.6887236E-2;
return (((((a5 * t + a4) * t + a3) * t + a2) * t + a1) * t + a0) / (1.0 + b * t);
}
}
/// <summary>
/// Calculate density of distilled water from temperature (obsolete)
/// </summary>
/// <param name="t">IPTS-68 temperature in [°C]</param>
/// <returns>Density in [kg/m3]</returns>
public static double DistilledWaterDensityFromTempIPTS68(double t)
{
const double a0 = 999.842594;
const double a1 = 0.06793952;
const double a2 = -0.009095290;
const double a3 = 0.0001001685;
const double a4 = -0.000001120083;
const double a5 = 6.536332e-09;
return ((((a5 * t + a4) * t + a3) * t + a2) * t + a1) * t + a0;
}
/// <summary>
/// Calculate density by comparing calculated data and data from a certificate
/// </summary>
/// <param name="realDensity">Density from a certificate in [kg/m3]</param>
/// <param name="atTemperature">Temperature from a certificate in [°C]</param>
/// <returns>Density correction in [kg/m3]</returns>
public static double DensityCorrection(double realDensity, double atTemperature)
{
/// Calculated data
double calculatedDensity = DistilledWaterDensityFromTemp(atTemperature);
return realDensity - calculatedDensity;
}
/// <summary>
/// Calculate corrected (real) water density from temperature
/// </summary>
/// <param name="t">Temperature in [°C]</param>
/// <returns>Density in [kg/m3]</returns>
public static double WaterDensityFromTemp(double t, double realDensity, double atTemperature)
{
return DistilledWaterDensityFromTemp(t) + DensityCorrection(realDensity, atTemperature);
}
/// <summary>
/// Calculate corrected (real) water density from temperature
/// </summary>
/// <param name="t">Temperature in [°C]</param>
/// <returns>Density in [kg/m3]</returns>
public static double WaterDensityFromTempPress(double temp, double pressure, double realDensity, double atTemperature)
{
double x0 = 5.08821E-10;
double x1 = 1.2639418;
double x2 = 0.2660269;
double x3 = 0.3734838;
double x4 = 2.0205242;
double theta = temp / 100.0;
double B = x0 * (((x3 * theta + x2) * theta + x1) * theta + 1) / (1 + x4 * theta);
return WaterDensityFromTemp(temp, realDensity, atTemperature) * (1 + B * Config.Units.ConvertTo(Config.Unit.Pa, pressure));
}
public static float AirDensityFromAmbientVales(float tempC, float pressureBar, float humiPct)
{
double pressurePa = 100000.0 * (double)pressureBar; /// [Pa]
double tempKelvin = 273.15 + (double)tempC;
double coef1 = 1.2811805 / 10000.0 * tempKelvin * tempKelvin
- 1.950987 / 100.0 * tempKelvin
+ 34.04926034
- 6.353631 * 1000.0 / tempKelvin;
double coef3 = humiPct / 100.0 * System.Math.Exp(coef1) / pressurePa;
double airDensityKgm3 = 0.00348353 * pressurePa * (1.0 - 0.378 * coef3) / tempKelvin; /// kg/m3
return (float)airDensityKgm3;
}
/// <summary>
/// Convert 'pulses' to 'volume', prevent division by zero
/// </summary>
public static double VolumeFromPulses(int pulses, double pulsesPerLiter)
{
if (pulsesPerLiter <= double.Epsilon) return 0;
return Convert.ToDouble(pulses) / pulsesPerLiter;
}
/// <summary>
/// Calculate the error in % from 'measured' and 'true' volume, prevent division by zero
/// </summary>
public static double ErrorFromVolumes(double measuredVolume, double trueVolume)
{
if (trueVolume <= float.Epsilon)
{
if (measuredVolume <= float.Epsilon)
{
log.WarnFormat("ErrorFromVolumes({0},{1}) returns {2}", measuredVolume, trueVolume, -100.0);
return -100.0;
}
log.WarnFormat("ErrorFromVolumes({0},{1}) returns {2}", measuredVolume, trueVolume, 99.0);
return 99.0;
}
double error = 100.0 * (measuredVolume - trueVolume) / trueVolume;
log.InfoFormat("ErrorFromVolumes({0},{1}) returns {2}", measuredVolume, trueVolume, error);
return error;
}
/// <summary>
/// Calculates corrected value form a list of corrections by interpolation.
/// It is assumed that values in the list 'corrections' are sorted.
/// </summary>
/// <param name="rawMeasurement">Raw uncorrected value</param>
/// <param name="corrections">Sorted (value, correction) pairs</param>
/// <returns>Corrected value</returns>
public static double CorrectedValue(double rawValue, IList<Config.Entities.MeasurementCorrection> corrections)
{
logrefError.InfoFormat("call CorrectedValue({0},{1}.Count)", rawValue, corrections.Count);
if (corrections == null || corrections.Count == 0)
{
logrefError.InfoFormat("CorrectedValue({0},{1}.Count) return rawValue... no correction found", rawValue, corrections.Count);
return rawValue;
}
if (rawValue < corrections[0].Measurement)
{
logrefError.InfoFormat("CorrectedValue({0},{1}.Count) return {2}... rawValue < corrections[0].Measurement", rawValue, corrections.Count, rawValue + corrections[0].Correction);
return rawValue + corrections[0].Correction;
}
int count = corrections.Count;
for (int i = 1; i < count; i++)
{
if (rawValue < corrections[i].Measurement)
{
double d1 = rawValue - corrections[i-1].Measurement;
double d2 = corrections[i].Measurement - rawValue;
double corr;
if (d1 + d2 <= float.Epsilon)
{
corr = (corrections[i - 1].Correction + corrections[i].Correction) / 2.0;
logrefError.InfoFormat("CorrectedValue({0},{1}.Count) return {2}... (corrections[i - 1].Correction + corrections[i].Correction) / 2.0", rawValue, corrections.Count, rawValue + corr);
}
else
{
corr = (corrections[i - 1].Correction * d2 + corrections[i].Correction * d1) / (d1 + d2);
logrefError.InfoFormat("CorrectedValue({0},{1}.Count) return {2}... (corrections[i - 1].Correction * d2 + corrections[i].Correction * d1) / (d1 + d2)", rawValue, corrections.Count, rawValue + corr);
}
return rawValue + corr;
}
}
logrefError.InfoFormat("CorrectedValue({0},{1}.Count) return {2}... rawValue < corrections[0].Measurement", rawValue, corrections.Count, rawValue + corrections[count - 1].Correction);
return rawValue + corrections[count - 1].Correction;
}
/// <summary>
/// Converts a measurement error to a correction (used when preparing correction tables).
/// </summary>
/// <param name="measuredValue">Measured value (in arbitrary units)</param>
/// <param name="error">Measurement error in %</param>
/// <returns>Correction in the same units as the measured value</returns>
public static double CorrectionFromError(double measuredValue, double error)
{
double trueValue = measuredValue / (1 + error/100);
double correction = trueValue - measuredValue;
return correction;
}
/// <summary>
/// Calculates the heat coefficient for water
/// </summary>
/// <param name="pressure">Pressure [bar]</param>
/// <param name="T_in">Inlet temperature [°C]</param>
/// <param name="T_out">Outlet temperature [°C]</param>
/// <param name="flowMeasuredAtInlet">true = flow measured @inlet, false = flow measured @outlet</param>
/// <returns> Heat coefficient for water [J/(m3 K)]</returns>
public static double HeatCoefficientWater(double pressure, double T_in, double T_out, bool flowMeasuredAtInlet)
{
if (T_in == T_out) return 0;
const double R = 461.526; /// [J kg^-1 K^-1]
const double p_star_Pa = 16.53E6; /// [Pa] (=16.53 MPa)
const double T_star = 1386.0; /// [K]
double T_in_K = Config.Units.ConvertTo(Config.Unit.K, T_in);
double T_out_K = Config.Units.ConvertTo(Config.Unit.K, T_out);
double tau_in = T_star / T_in_K;
double tau_out = T_star / T_out_K;
double pi = Config.Units.ConvertTo(Config.Unit.Pa, pressure) / p_star_Pa;
double h_in = tau_in * GammaTau(pi, tau_in) * R * T_in_K;
double h_out = tau_out * GammaTau(pi, tau_out) * R * T_out_K;
double ni = flowMeasuredAtInlet ? GammaPi(pi, tau_in) * R * T_in_K / p_star_Pa
: GammaPi(pi, tau_out) * R * T_out_K / p_star_Pa;
return (h_in - h_out) / (ni * (T_in - T_out));
}
/// <summary>
/// gamma(pi) see also STN EN 1434-1 Annex A (A.4)
/// </summary>
/// <param name="pi">pi = p / p* where p* = 16.53 MPa</param>
/// <param name="tau">tau = T* / T where T* = 1386 K</param>
/// <returns>gamma(pi)</returns>
static double GammaPi(double pi, double tau)
{
double result = 0;
for (int i = 0; i < 34; i++)
{
result -= ni[i] * Ii[i] * Math.Pow(7.1 - pi, Ii[i] - 1) * Math.Pow(tau - 1.222, Ji[i]);
}
return result;
}
/// <summary>
/// gamma(tau) see also STN EN 1434-1 Annex A (A.7)
/// </summary>
/// <param name="pi">pi = p / p* where p* = 16.53 MPa</param>
/// <param name="tau">tau = T* / T where T* = 1386 K</param>
/// <returns>gamma(tau)</returns>
static double GammaTau(double pi, double tau)
{
double result = 0;
for (int i = 0; i < 34; i++)
{
result += ni[i] * Math.Pow(7.1 - pi, Ii[i]) * Ji[i] * Math.Pow(tau - 1.222, Ji[i] - 1);
}
return result;
}
/// <summary>
/// Conversion of measured resistance of a platinum thermometer to temperature according to ITS-90
/// </summary>
/// <param name="R">Measured resistance in [°C]</param>
/// <param name="R001C">Calibrated resistance in Ohm at 0.01°C</param>
/// <param name="a7">Calibrated ITS-90 coefficient a7</param>
/// <param name="b7">Calibrated ITS-90 coefficient b7</param>
/// <param name="c7">Calibrated ITS-90 coefficient c7</param>
/// <returns>Temperature in [°C]</returns>
public static double PlatinumResistanceTM_ITS90_R2T(double R, double R001C, double a7, double b7, double c7)
{
double w = R / R001C; /// ratio
double r1 = w - 1.0;
double dw = r1 * (a7 + r1 * (b7 + r1 * c7)); /// = a7*r1 + b7*r1^2 + c7*r1^3
double wr = w - dw;
double x = (wr - 2.64) / 1.64;
double sum = 0;
for (int i = Di.Length - 1; i >= 0; i--)
{
sum = sum * x + Di[i];
}
return sum;
}
/// <summary>
/// Conversion of measured resistance of a platinum thermometer to temperature using Callendar-Van Dusen equations
/// </summary>
/// <param name="R">Measured resistance in [°C]</param>
/// <param name="R0">Calibrated resistance in Ohm at 0°C</param>
/// <param name="A">Calibration coefficient a</param>
/// <param name="B">Calibration coefficient b</param>
/// <returns>Temperature in [°C]</returns>
public static double PlatinumResistanceTM_ITS27_R2T(double R, double R0, double A, double B)
{
if (R0 * R0 * A * A - 4 * R0 * B * (R0 - R) <= 0) return 0; /// Out of range
return (-(R0 * A) + Math.Sqrt(R0 * R0 * A * A - 4 * R0 * B * (R0 - R))) / (2 * R0 * B);
}
public static double Buoyancy()
{
return 1.00103;
}
}
}

View File

@ -0,0 +1,32 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
///
using FluentNHibernate.Mapping;
using Config.Entities;
namespace Config.Mappings
{
class BenchPathMap : ClassMap<BenchPath>
{
public BenchPathMap()
{
Id(x => x.Id);
Map(x => x.ItemNr);
Map(x => x.Name);
Map(x => x.Qfrom);
Map(x => x.Qto);
Map(x => x.TempMtrUp).Column("TempIn");
Map(x => x.TempMtrDown).Column("TempOut");
Map(x => x.PressMtrUp).Column("PressIn");
Map(x => x.PressMtrDown).Column("PressOut");
Map(x => x.PressMtrDelta);
Map(x => x.StopBFValve);
Map(x => x.ValvesOpen)
.CustomType("StringClob")
.CustomSqlType("varchar(8000)");
Map(x => x.ValvesClose)
.CustomType("StringClob")
.CustomSqlType("varchar(8000)");
}
}
}

View File

@ -0,0 +1,28 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
///
using FluentNHibernate.Mapping;
using Config.Entities;
namespace Config.Mappings
{
class ComponentMap : ClassMap<Component>
{
public ComponentMap()
{
Id(x => x.Id);
Map(x => x.Name);
Map(x => x.ClassName);
Map(x => x.ParentName);
Map(x => x.ItemNr);
Map(x => x.Mode);
Map(x => x.Logging);
Map(x => x.Parameters)
.CustomType("StringClob")
.CustomSqlType("varchar(8000)");
HasMany(x => x.Corrections)
.OrderBy("Measurement")
.Cascade.All();
}
}
}

View File

@ -0,0 +1,22 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
///
using FluentNHibernate.Mapping;
using Config.Entities;
namespace Config.Mappings
{
class ComponentProcedureMap : ClassMap<ComponentProcedure>
{
public ComponentProcedureMap()
{
Id(x => x.Id);
Map(x => x.CmpntName);
Map(x => x.Parameters)
.CustomType("StringClob")
.CustomSqlType("varchar(8000)");
References(x => x.Procedure);
}
}
}

View File

@ -0,0 +1,22 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
///
using FluentNHibernate.Mapping;
using Config.Entities;
namespace Config.Mappings
{
class ComponentTestMap : ClassMap<ComponentTest>
{
public ComponentTestMap()
{
Id(x => x.Id);
Map(x => x.CmpntName);
Map(x => x.Parameters)
.CustomType("StringClob")
.CustomSqlType("varchar(8000)");
References(x => x.Test);
}
}
}

View File

@ -0,0 +1,28 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
///
using FluentNHibernate.Mapping;
using Config.Entities;
namespace Config.Mappings
{
class FeedingPathMap : ClassMap<FeedingPath>
{
public FeedingPathMap()
{
Id(x => x.Id);
Map(x => x.ItemNr);
Map(x => x.Name);
Map(x => x.Qfrom);
Map(x => x.Qto);
Map(x => x.Pump);
Map(x => x.RegulValvesPct);
Map(x => x.ValvesOpen)
.CustomType("StringClob")
.CustomSqlType("varchar(8000)");
Map(x => x.ValvesClose)
.CustomType("StringClob")
.CustomSqlType("varchar(8000)");
}
}
}

View File

@ -0,0 +1,17 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
///
using FluentNHibernate.Mapping;
namespace Config.Mappings
{
class GroupMap : ClassMap<Entities.Group>
{
public GroupMap()
{
Id(x => x.Id);
Map(x => x.Gid);
Map(x => x.Name);
}
}
}

View File

@ -0,0 +1,35 @@
///
/// Copyright (c) 2016 Sensus Metering Systems
///
using FluentNHibernate.Mapping;
using Config.Entities;
namespace Config.Mappings
{
#if HEAT_METERS
class HeatMetersPathMap : ClassMap<HeatMetersPath>
{
public HeatMetersPathMap()
{
Id(x => x.Id);
Map(x => x.ItemNr);
Map(x => x.Name);
Map(x => x.TempWarmFrom);
Map(x => x.TempWarmTo);
Map(x => x.TempColdFrom);
Map(x => x.TempColdTo);
Map(x => x.TMeterRefWarm1);
Map(x => x.TMeterRefWarm2);
Map(x => x.TMeterRefCold1);
Map(x => x.TMeterRefCold2);
Map(x => x.TMeterWorkWarm1);
Map(x => x.TMeterWorkWarm2);
Map(x => x.TMeterWorkCold1);
Map(x => x.TMeterWorkCold2);
}
}
#endif
}

View File

@ -0,0 +1,19 @@
///
/// Copyright (c) 2013-2018 Sensus Slovensko a.s.
///
using FluentNHibernate.Mapping;
using Config.Entities;
namespace Config.Mappings
{
class MeasurementCorrectionMap : ClassMap<MeasurementCorrection>
{
public MeasurementCorrectionMap()
{
Id(x => x.Id);
Map(x => x.RangeIx);
Map(x => x.Measurement);
Map(x => x.Correction);
}
}
}

View File

@ -0,0 +1,61 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
///
using FluentNHibernate.Mapping;
using Config.Entities;
namespace Config.Mappings
{
class MetersPathMap : ClassMap<MetersPath>
{
public MetersPathMap()
{
Id(x => x.Id);
Map(x => x.ItemNr);
Map(x => x.Name);
#pragma warning disable
if (Config.Data.WMsCount >= 1) Map(x => x.Sensor1);
if (Config.Data.WMsCount >= 2) Map(x => x.Sensor2);
if (Config.Data.WMsCount >= 3) Map(x => x.Sensor3);
if (Config.Data.WMsCount >= 4) Map(x => x.Sensor4);
if (Config.Data.WMsCount >= 5) Map(x => x.Sensor5);
if (Config.Data.WMsCount >= 6) Map(x => x.Sensor6);
if (Config.Data.WMsCount >= 7) Map(x => x.Sensor7);
if (Config.Data.WMsCount >= 8) Map(x => x.Sensor8);
if (Config.Data.WMsCount >= 9) Map(x => x.Sensor9);
if (Config.Data.WMsCount >= 10) Map(x => x.Sensor10);
if (Config.Data.WMsCount >= 11) Map(x => x.Sensor11);
if (Config.Data.WMsCount >= 12) Map(x => x.Sensor12);
if (Config.Data.WMsCount >= 13) Map(x => x.Sensor13);
if (Config.Data.WMsCount >= 14) Map(x => x.Sensor14);
if (Config.Data.WMsCount >= 15) Map(x => x.Sensor15);
if (Config.Data.WMsCount >= 16) Map(x => x.Sensor16);
if (Config.Data.WMsCount >= 17) Map(x => x.Sensor17);
if (Config.Data.WMsCount >= 18) Map(x => x.Sensor18);
if (Config.Data.WMsCount >= 19) Map(x => x.Sensor19);
if (Config.Data.WMsCount >= 20) Map(x => x.Sensor20);
if (Config.Data.WMsCount >= 21) Map(x => x.Sensor21);
if (Config.Data.WMsCount >= 22) Map(x => x.Sensor22);
if (Config.Data.WMsCount >= 23) Map(x => x.Sensor23);
if (Config.Data.WMsCount >= 24) Map(x => x.Sensor24);
if (Config.Data.WMsCount >= 25) Map(x => x.Sensor25);
if (Config.Data.WMsCount >= 26) Map(x => x.Sensor26);
if (Config.Data.WMsCount >= 27) Map(x => x.Sensor27);
if (Config.Data.WMsCount >= 28) Map(x => x.Sensor28);
if (Config.Data.WMsCount >= 29) Map(x => x.Sensor29);
if (Config.Data.WMsCount >= 30) Map(x => x.Sensor30);
if (Config.Data.WMsCount >= 31) Map(x => x.Sensor31);
if (Config.Data.WMsCount >= 32) Map(x => x.Sensor32);
if (Config.Data.WMsCount >= 33) Map(x => x.Sensor33);
if (Config.Data.WMsCount >= 34) Map(x => x.Sensor34);
if (Config.Data.WMsCount >= 35) Map(x => x.Sensor35);
if (Config.Data.WMsCount >= 36) Map(x => x.Sensor36);
if (Config.Data.WMsCount >= 37) Map(x => x.Sensor37);
if (Config.Data.WMsCount >= 38) Map(x => x.Sensor38);
if (Config.Data.WMsCount >= 39) Map(x => x.Sensor39);
if (Config.Data.WMsCount >= 40) Map(x => x.Sensor40);
#pragma warning restore
}
}
}

View File

@ -0,0 +1,35 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
///
using FluentNHibernate.Mapping;
using Config.Entities;
namespace Config.Mappings
{
class OutputPathMap : ClassMap<OutputPath>
{
public OutputPathMap()
{
Id(x => x.Id);
Map(x => x.ItemNr);
Map(x => x.Name);
Map(x => x.Qfrom);
Map(x => x.Qto);
Map(x => x.RegulValve);
Map(x => x.FlowMeter);
Map(x => x.PidCoef);
Map(x => x.StartValve);
Map(x => x.Diverter);
Map(x => x.TempDiv);
Map(x => x.Scale)
.Column("Balance");
Map(x => x.EmptyTankValve);
Map(x => x.ValvesOpen)
.CustomType("StringClob")
.CustomSqlType("varchar(8000)");
Map(x => x.ValvesClose)
.CustomType("StringClob")
.CustomSqlType("varchar(8000)");
}
}
}

View File

@ -0,0 +1,53 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
///
using FluentNHibernate.Mapping;
using Config.Entities;
namespace Config.Mappings
{
class ProcedureMap : ClassMap<Procedure>
{
public ProcedureMap()
{
Id(x => x.Id);
Map(x => x.ItemNr);
Map(x => x.Name);
Map(x => x.Description);
Map(x => x.CreationUser);
Map(x => x.CreationTime);
Map(x => x.LastChgUser);
Map(x => x.LastChgTime);
Map(x => x.LongDescription);
Map(x => x.ProcedureState);
Map(x => x.Revision);
Map(x => x.PredecessorId);
Map(x => x.ObtainedByCopy);
Map(x => x.MetersKind);
Map(x => x.Watermeters);
Map(x => x.Protected);
Map(x => x.MustBeComplete);
Map(x => x.ManualCtrlDisabled);
Map(x => x.DataEntry);
Map(x => x.ResultsPrinter);
Map(x => x.ResultsWriter);
Map(x => x.TransitionStart);
Map(x => x.TransitionEnd);
Map(x => x.AltProcName);
Map(x => x.AltProcPeriod);
////Map(x => x.MetrologicalClass);
////HasOne(x => x.WMType);
HasMany(x => x.MoreParams)
.Cascade.All();
HasMany(x => x.Tests)
.OrderBy("ItemNr")
.Cascade.All();
}
}
}

View File

@ -0,0 +1,65 @@
///
/// Copyright (c) 2013-2017 Sensus Metering Systems
///
using FluentNHibernate.Mapping;
using Config.Entities;
namespace Config.Mappings
{
class TestMap : ClassMap<Test>
{
public TestMap()
{
Id(x => x.Id);
Map(x => x.ItemNr);
Map(x => x.Name);
Map(x => x.Part);
Map(x => x.Publish);
Map(x => x.DoEvaluate)
.Column("Evaluate");
Map(x => x.Qfrom);
Map(x => x.Qto);
Map(x => x.Volume);
Map(x => x.TstTime);
Map(x => x.Repeats);
Map(x => x.DoDraining)
.Column("Emptying");
Map(x => x.DoZeroing)
.Column("Zeroing");
Map(x => x.DoControlWaterTemp);
Map(x => x.TempLimLo);
Map(x => x.TempLimHi);
Map(x => x.PumpPower);
Map(x => x.MassRepeats);
Map(x => x.MassSpread);
Map(x => x.MassMethod)
.CustomType<byte>();
Map(x => x.TimeBeforeFlow);
Map(x => x.TimeFlow2Mass);
Map(x => x.TimePump2StartV)
.Column("TimeMass2Start");
Map(x => x.TimeStop2Mass);
Map(x => x.Method);
Map(x => x.ErrLimLo);
Map(x => x.ErrLimHi);
Map(x => x.Uncertainty);
Map(x => x.TolerRed)
.Column("TolerRed"); /// ???
Map(x => x.RedType); /// ???
Map(x => x.FeedingPath);
Map(x => x.BenchPath);
Map(x => x.OutputPath);
Map(x => x.MetersPath);
#if HEAT_METERS
Map(x => x.HeatMetersPath);
#endif
Map(x => x.RelTransBefore);
Map(x => x.RelTransBetween);
Map(x => x.RelTransAfter);
Map(x => x.TransitionAfter);
HasMany(x => x.MoreParams)
.Cascade.All();
References(x => x.Procedure);
}
}
}

View File

@ -0,0 +1,22 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
///
using FluentNHibernate.Mapping;
using Config.Entities;
namespace Config.Mappings
{
class TransitionSequenceMap : ClassMap<TransitionSequence>
{
public TransitionSequenceMap()
{
Id(x => x.Id);
Map(x => x.ItemNr);
Map(x => x.Name);
Map(x => x.Description);
HasMany(x => x.TransitionSteps)
.OrderBy("ItemNr")
.Cascade.All();
}
}
}

View File

@ -0,0 +1,30 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
///
using FluentNHibernate.Mapping;
using Config.Entities;
namespace Config.Mappings
{
class TransitionStepMap : ClassMap<TransitionStep>
{
public TransitionStepMap()
{
Id(x => x.Id);
Map(x => x.ItemNr);
Map(x => x.Duration);
Map(x => x.Message);
Map(x => x.EndCondition);
Map(x => x.ValvesOpen)
.CustomType("StringClob")
.CustomSqlType("varchar(8000)");
Map(x => x.ValvesClose)
.CustomType("StringClob")
.CustomSqlType("varchar(8000)");
Map(x => x.RegulValvesPct);
Map(x => x.PumpWithFMPcts);
References(x => x.TransitionSequence);
}
}
}

View File

@ -0,0 +1,22 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
///
using FluentNHibernate.Mapping;
namespace Config.Mappings
{
class UserMap : ClassMap<Entities.User>
{
public UserMap()
{
Id(x => x.Id);
Map(x => x.UserName).Column("Name");
Map(x => x.Number);
Map(x => x.Password);
Map(x => x.FullName).Column("Description");
Map(x => x.LastPwChange);
HasMany(x => x.Groups)
.Cascade.All();
}
}
}

View File

@ -0,0 +1,22 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
///
using FluentNHibernate.Mapping;
using Config.Entities;
namespace Config.Mappings
{
class VirtualBenchSequenceMap : ClassMap<VirtualBenchSequence>
{
public VirtualBenchSequenceMap()
{
Id(x => x.Id);
Map(x => x.ItemNr);
Map(x => x.Name);
Map(x => x.Description);
HasMany(x => x.VirtualBenchSteps)
.OrderBy("ItemNr")
.Cascade.All();
}
}
}

View File

@ -0,0 +1,20 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
///
using FluentNHibernate.Mapping;
using Config.Entities;
namespace Config.Mappings
{
class VirtualBenchStepMap : ClassMap<VirtualBenchStep>
{
public VirtualBenchStepMap()
{
Id(x => x.Id);
Map(x => x.ItemNr);
Map(x => x.Duration);
References(x => x.VirtualBenchSequence);
}
}
}

View File

@ -0,0 +1,20 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
///
using FluentNHibernate.Mapping;
namespace Config.Mappings
{
class WMTypeMap : ClassMap<Entities.WMType>
{
public WMTypeMap()
{
Id(x => x.Id);
Map(x => x.CreateTime);
Map(x => x.CreateUserName);
Map(x => x.CreateDescription);
Map(x => x.Name);
Map(x => x.PulseRate);
}
}
}

View File

@ -0,0 +1,19 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
///
using FluentNHibernate.Mapping;
namespace Config.Mappings
{
class WatermeterMap : ClassMap<Entities.Watermeter>
{
public WatermeterMap()
{
Id(x => x.Id);
Map(x => x.Serial);
// HasOne(x => x.WMType)
// .Cascade.All();
References(x => x.WMType);
}
}
}

View File

@ -0,0 +1,36 @@
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("Config")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Sensus")]
[assembly: AssemblyProduct("Config")]
[assembly: AssemblyCopyright("Copyright © 2013 - 2018 Sensus Slovensko a.s.")]
[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("3fc3ff67-7386-4aff-9855-bef33d5fa0d3")]
// 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("2.18.928.0")]
[assembly: AssemblyFileVersion("2.18.928.0")]

View File

@ -0,0 +1,164 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Config.Resources {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Strings {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Strings() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Config.Resources.Strings", typeof(Strings).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// Looks up a localized string similar to Administrator.
/// </summary>
internal static string Administrator {
get {
return ResourceManager.GetString("Administrator", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Calibration Specialist.
/// </summary>
internal static string Calibration_Specialist {
get {
return ResourceManager.GetString("Calibration_Specialist", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Cannot open DB Cause 0.
/// </summary>
internal static string Cannot_open_DB_Cause_0 {
get {
return ResourceManager.GetString("Cannot_open_DB_Cause_0", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Error.
/// </summary>
internal static string Error
{
get
{
return ResourceManager.GetString("Error", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Failed.
/// </summary>
internal static string Failed {
get {
return ResourceManager.GetString("Failed", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Head of Lab.
/// </summary>
internal static string Head_of_Lab {
get {
return ResourceManager.GetString("Head_of_Lab", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Maintenance Specialist.
/// </summary>
internal static string Maintenance_Specialist {
get {
return ResourceManager.GetString("Maintenance_Specialist", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Metrologist.
/// </summary>
internal static string Metrologist {
get {
return ResourceManager.GetString("Metrologist", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Passed.
/// </summary>
internal static string Passed {
get {
return ResourceManager.GetString("Passed", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Tester.
/// </summary>
internal static string Tester {
get {
return ResourceManager.GetString("Tester", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Testing Specialist.
/// </summary>
internal static string Testing_Specialist {
get {
return ResourceManager.GetString("Testing_Specialist", resourceCulture);
}
}
}
}

View File

@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="Error" xml:space="preserve">
<value>Chyba</value>
</data>
</root>

View File

@ -0,0 +1,153 @@
<?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>
<data name="Administrator" xml:space="preserve">
<value>Administrator</value>
</data>
<data name="Calibration_Specialist" xml:space="preserve">
<value>Kalibriertechniker</value>
</data>
<data name="Head_of_Lab" xml:space="preserve">
<value>Laborleiter</value>
</data>
<data name="Maintenance_Specialist" xml:space="preserve">
<value>Wartungstechniker</value>
</data>
<data name="Metrologist" xml:space="preserve">
<value>Messtechniker</value>
</data>
<data name="Tester" xml:space="preserve">
<value>Prüfer</value>
</data>
<data name="Testing_Specialist" xml:space="preserve">
<value>Prüftechniker</value>
</data>
<data name="Failed" xml:space="preserve">
<value>NiO</value>
</data>
<data name="Passed" xml:space="preserve">
<value>iO</value>
</data>
<data name="Error" xml:space="preserve">
<value>Fehler</value>
</data>
<data name="Cannot_open_DB_Cause_0" xml:space="preserve">
<value>Datenbank kann nicht geöffnet.\\r\\nUrsache:\\r\\n{0}</value>
</data>
</root>

View File

@ -0,0 +1,153 @@
<?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>
<data name="Administrator" xml:space="preserve">
<value>Amministratore</value>
</data>
<data name="Calibration_Specialist" xml:space="preserve">
<value>esperto in calibrazione</value>
</data>
<data name="Head_of_Lab" xml:space="preserve">
<value>capo di laboratorio</value>
</data>
<data name="Maintenance_Specialist" xml:space="preserve">
<value>esperto di manutenzione</value>
</data>
<data name="Metrologist" xml:space="preserve">
<value>metrologo</value>
</data>
<data name="Tester" xml:space="preserve">
<value>tester</value>
</data>
<data name="Testing_Specialist" xml:space="preserve">
<value>esperto di prove </value>
</data>
<data name="Failed" xml:space="preserve">
<value>NOK</value>
</data>
<data name="Passed" xml:space="preserve">
<value>ok</value>
</data>
<data name="Cannot_open_DB_Cause_0" xml:space="preserve">
<value>Impossibile aprire il database\\r\\nCause:\\r\\n{0}</value>
</data>
<data name="Error" xml:space="preserve">
<value>Errore</value>
</data>
</root>

View File

@ -0,0 +1,153 @@
<?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>
<data name="Administrator" xml:space="preserve">
<value>Administrator</value>
</data>
<data name="Calibration_Specialist" xml:space="preserve">
<value>Specjalista ds. kalibracji</value>
</data>
<data name="Head_of_Lab" xml:space="preserve">
<value>Kierownik Laboratorium</value>
</data>
<data name="Maintenance_Specialist" xml:space="preserve">
<value>Konserwator</value>
</data>
<data name="Metrologist" xml:space="preserve">
<value>Metrolog</value>
</data>
<data name="Tester" xml:space="preserve">
<value>Pracownik przeprowadzający testy</value>
</data>
<data name="Testing_Specialist" xml:space="preserve">
<value>Specjalista ds. testów</value>
</data>
<data name="Failed" xml:space="preserve">
<value>Niepowodzenie</value>
</data>
<data name="Passed" xml:space="preserve">
<value>OK</value>
</data>
<data name="Cannot_open_DB_Cause_0" xml:space="preserve">
<value>Nie można otworzyć \\r\\nCause:\\r\\n{0}</value>
</data>
<data name="Error" xml:space="preserve">
<value>Błąd</value>
</data>
</root>

View File

@ -0,0 +1,153 @@
<?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>
<data name="Administrator" xml:space="preserve">
<value>Administrator</value>
</data>
<data name="Calibration_Specialist" xml:space="preserve">
<value>Calibration Specialist</value>
</data>
<data name="Head_of_Lab" xml:space="preserve">
<value>Head of Lab</value>
</data>
<data name="Maintenance_Specialist" xml:space="preserve">
<value>Maintenance Specialist</value>
</data>
<data name="Metrologist" xml:space="preserve">
<value>Metrologist</value>
</data>
<data name="Tester" xml:space="preserve">
<value>Tester</value>
</data>
<data name="Testing_Specialist" xml:space="preserve">
<value>Testing Specialist</value>
</data>
<data name="Failed" xml:space="preserve">
<value>NOK</value>
</data>
<data name="Passed" xml:space="preserve">
<value>OK</value>
</data>
<data name="Cannot_open_DB_Cause_0" xml:space="preserve">
<value>Cannot open database.\\r\\nCause:\\r\\n{0}</value>
</data>
<data name="Error" xml:space="preserve">
<value>Error</value>
</data>
</root>

View File

@ -0,0 +1,153 @@
<?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>
<data name="Administrator" xml:space="preserve">
<value>Администратор</value>
</data>
<data name="Calibration_Specialist" xml:space="preserve">
<value>Специалист по калибровке</value>
</data>
<data name="Head_of_Lab" xml:space="preserve">
<value>Руководитель лаборатории</value>
</data>
<data name="Maintenance_Specialist" xml:space="preserve">
<value>Специалист по техобслуживанию</value>
</data>
<data name="Metrologist" xml:space="preserve">
<value>Метролог</value>
</data>
<data name="Tester" xml:space="preserve">
<value>Контролер</value>
</data>
<data name="Testing_Specialist" xml:space="preserve">
<value>Специалист по тестированию</value>
</data>
<data name="Failed" xml:space="preserve">
<value>NOK</value>
</data>
<data name="Passed" xml:space="preserve">
<value>OK</value>
</data>
<data name="Cannot_open_DB_Cause_0" xml:space="preserve">
<value>Не удается открыть БД.\\r\\nCause:\\r\\n{0}</value>
</data>
<data name="Error" xml:space="preserve">
<value>Ошибка</value>
</data>
</root>

View File

@ -0,0 +1,128 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 1.3
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">1.3</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1">this is my long string</data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
[base64 mime encoded serialized .NET Framework object]
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
[base64 mime encoded string representing a byte array form of the .NET Framework object]
</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.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:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<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" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</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>1.3</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="Administrator" xml:space="preserve">
<value>管理员</value>
</data>
<data name="Calibration_Specialist" xml:space="preserve">
<value>校准专员</value>
</data>
<data name="Failed" xml:space="preserve">
<value>NOK</value>
</data>
<data name="Head_of_Lab" xml:space="preserve">
<value>实验室负责人</value>
</data>
<data name="Maintenance_Specialist" xml:space="preserve">
<value>维护专员</value>
</data>
<data name="Metrologist" xml:space="preserve">
<value>计量者</value>
</data>
<data name="Passed" xml:space="preserve">
<value>好</value>
</data>
<data name="Tester" xml:space="preserve">
<value>测试仪</value>
</data>
<data name="Testing_Specialist" xml:space="preserve">
<value>测试专员</value>
</data>
</root>

View File

@ -0,0 +1,478 @@
///
/// Copyright (c) 2016-2018 Sensus Slovensko a.s.
///
using System;
using System.Reflection;
using Config.Entities;
namespace Config
{
public enum Unit
{
[Description("---")] None,
[Description("imp.")] pulse,
#if LANG_PL
[Description("stopień")] degree,
#else
[Description("degree")] degree,
#endif
[Description("l")] l, /// * 1 liter
[Description("dm3")] dm3, /// 1 dm3 = 1 liter
[Description("m3")] m3, /// 1000 l
[Description("gal(UK)")] gal_UK, /// 1 gal(UK) = 4.54609 l
[Description("gal(US)")] gal_US, /// 1 gal(US) = 3.78541178 l
[Description("l/h")] lph, /// 1 liter/h
[Description("m3/h")] m3ph, /// * 1 m3/h = 1000 l/h
[Description("g")] g, /// 0.001 kg
[Description("kg")] kg, /// * 1 kilogram
[Description("t")] t, /// 1000 kg
[Description("lb")] lb, /// 0.45359237 kg
[Description("s")] s, /// * 1 second
[Description("min")] min, /// 1 min = 60 s
[Description("hr")] hour, /// 1 hour = 60 min = 3600 s
[Description("ms")] ms, /// 1 ms = 0.001 s
[Description("°C")] C, /// * degree Celsius (°C)
[Description("°F")] F, /// degree Fahrenheit
[Description("K")] K, /// degree Kelvin
[Description("Pa")] Pa, /// 1 Pa = 0.01 hPa
[Description("hPa")] hPa, /// 1 hPa = 100 Pa
[Description("kPa")] kPa, /// 1 kPa = 10 HPa
[Description("MPa")] MPa, /// 1 MPa = 10000 hPa
[Description("mbar")] mbar, /// 1 mbar = 1 hPa = 100 Pa
[Description("bar")] bar, /// * 1 Bar = 1000 mbar = 0.1 MPa = 100000 Pa
[Description("inHg")] inHg, /// 1 inHg = 33.864 hPa
[Description("R%")] RPct, /// * 1 R%
[Description("%")] Pct, /// * 1 %
[Description("promile")] Promile, /// 1 promile = 0.1 %
[Description("mm")] mm, /// * 1 millimeter
[Description("cm")] cm, /// 1 cm = 10 mm
[Description("m")] m, /// 1 m = 1000 mm
[Description("in")] inch, /// 1 inch = 25.4 mm
[Description("kg/m3")] kgpm3, /// * 1 kg/m3 = 0.001 kg/l
[Description("kg/l")] kgpl, /// 1 kg/l = 1000 kg/m3
[Description("J")] J, /// * 1 Joul
[Description("kJ")] kJ, /// 1 kJ = 1000 J
[Description("MJ")] MJ, /// 1 MJ = 1000000 J
[Description("Wh")] Wh, /// 1 Wh = 3600 J
[Description("kWh")] kWh, /// 1 kWh = 3600000 J
[Description("MWh")] MWh, /// 1 MWh = 3600000000 J
#if LANG_PL
[Description("imp/l")] ppl, /// * 1 pulse/l
[Description("imp/dm3")] ppdm3, /// * 1 pulse/dm3
[Description("stopień/l")] degpl, /// * 1 degree/l
[Description("stopień/dm3")] degpdm3, /// * 1 degree/dm3
[Description("l/imp")] lpp, /// * 1 l/pulse
[Description("dm3/imp")] dm3pp, /// * 1 dm3/pulse
[Description("l/stopień")] lpdeg, /// * 1 l/degree
[Description("dm3/stopień")] dm3pdeg, /// * 1 dm3/degree
#else
[Description("pulse/l")] ppl, /// * 1 pulse/l
[Description("pulse/dm3")] ppdm3, /// * 1 pulse/dm3
[Description("degree/l")] degpl, /// * 1 degree/l
[Description("degree/dm3")] degpdm3, /// * 1 degree/dm3
[Description("l/pulse")] lpp, /// * 1 l/pulse
[Description("dm3/pulse")] dm3pp, /// * 1 dm3/pulse
[Description("l/degree")] lpdeg, /// * 1 l/degree
[Description("dm3/degree")] dm3pdeg, /// * 1 dm3/degree
#endif
///
[Description("pulse/kWh")] ppkWh, /// * 1 pulse/kWh
[Description("kWh/pulse")] kWhpp, /// * 1 kWh/pulse
Count
}
public enum Quantity
{
/// Quantities with units and conversions (double -> double)
#if LANG_DE
[Description("Volumen")] Volume,
[Description("Durchfluss")] Flow,
[Description("Masse")] Mass,
[Description("Zeit")] Time,
[Description("Temperatur")] Temperature,
[Description("Druck")] Pressure,
[Description("Feuchtigkeit")] Humidity,
[Description("Fehler")] Error,
[Description("Länge")] Length,
[Description("Dichte")] Density,
[Description("Energie")] Energy,
[Description("Impulse")] Pulses,
[Description("Impulse/l")] PulsePerLtr,
[Description("Impulse/kWh")] PulsePerKWh,
/// Quantities without units and conversions
[Description("Nummer")] Number,
[Description("Text")] String,
[Description("Boolean")] Boolean,
[Description("Datum und Uhrzeit")] DateTime,
#elif LANG_PL
[Description("Objętość")] Volume,
[Description("Przepływ")] Flow,
[Description("Masa")] Mass,
[Description("Czas")] Time,
[Description("Temperatura")] Temperature,
[Description("Ciśnienie")] Pressure,
[Description("Wilgotność")] Humidity,
[Description("Błąd")] Error,
[Description("Długość")] Length,
[Description("Gęstość")] Density,
[Description("Energia")] Energy,
[Description("Impulsy")] Pulses,
[Description("Impulsy/litr")] PulsePerLtr,
[Description("Impulsy/kWh")] PulsePerKWh,
/// Quantities without units and conversions
[Description("Numer")] Number,
[Description("Tekst")] String,
[Description("Boolean")] Boolean,
[Description("Data i czas")] DateTime,
#elif LANG_CS
[Description("Objem")] Volume,
[Description("Průtok")] Flow,
[Description("Hmotnost")] Mass,
[Description("Čas")] Time,
[Description("Teplota")] Temperature,
[Description("Tlak")] Pressure,
[Description("Vlhkost")] Humidity,
[Description("Chyba")] Error,
[Description("Délka")] Length,
[Description("Hustota")] Density,
[Description("Energie")] Energy,
[Description("Pulzy")] Pulses,
[Description("Pulzy/litr")] PulsePerLtr,
[Description("Pulzy/kWh")] PulsePerKWh,
/// Quantities without units and conversions
[Description("Počet")] Number,
[Description("Text")] String,
[Description("Boolean")] Boolean,
[Description("Datum a čas")] DateTime,
#elif LANG_IT
[Description("Volume")] Volume,
[Description("Flusso")] Flow,
[Description("Massa")] Mass,
[Description("Tempo")] Time,
[Description("Temperatura")] Temperature,
[Description("Pressione")] Pressure,
[Description("Umidità")] Humidity,
[Description("Errore")] Error,
[Description("Lungezza")] Length,
[Description("Densità")] Density,
[Description("Energia")] Energy,
[Description("Impulso")] Pulses,
[Description("Impulso/litro")] PulsePerLtr,
[Description("Impulso/kWh")] PulsePerKWh,
/// Quantities without units and conversions
[Description("Numero")] Number,
[Description("Stringa")] String,
[Description("Boolean")] Boolean,
[Description("Data e ora")] DateTime,
#else
[Description("Volume")] Volume,
[Description("Flow")] Flow,
[Description("Mass")] Mass,
[Description("Time")] Time,
[Description("Temperature")] Temperature,
[Description("Pressure")] Pressure,
[Description("Humidity")] Humidity,
[Description("Error")] Error,
[Description("Length")] Length,
[Description("Density")] Density,
[Description("Energy")] Energy,
[Description("Pulses")] Pulses,
[Description("Pulses/liter")] PulsePerLtr,
[Description("Pulses/kWh")] PulsePerKWh,
/// Quantities without units and conversions
[Description("Number")] Number,
[Description("String")] String,
[Description("Boolean")] Boolean,
[Description("Date and time")] DateTime,
#endif
Count,
}
public static class Units
{
public static bool IsUnitless(Quantity quantity)
{
return quantity >= Quantity.Number;
}
public static bool IsDefaultUnit(Unit unit)
{
return unit == Unit.l || unit == Unit.m3ph || unit == Unit.kg || unit == Unit.s || unit == Unit.C || unit == Unit.bar || unit == Unit.RPct ||
unit == Unit.Pct || unit == Unit.mm || unit == Unit.kgpm3 || unit == Unit.J || unit == Unit.ppl || unit == Unit.ppkWh;
}
public static bool IsQuantity(Unit units, Quantity quantity)
{
return (quantity == GetQuantity(units));
}
public static Quantity GetQuantity(Unit units)
{
switch (units)
{
case Unit.pulse:
case Unit.degree:
return Config.Quantity.Pulses;
case Unit.l:
case Unit.dm3:
case Unit.m3:
case Unit.gal_UK:
case Unit.gal_US:
return Config.Quantity.Volume;
case Unit.lph:
case Unit.m3ph:
return Config.Quantity.Flow;
case Unit.g:
case Unit.kg:
case Unit.t:
case Unit.lb:
return Config.Quantity.Mass;
case Unit.s:
case Unit.min:
case Unit.hour:
case Unit.ms:
return Config.Quantity.Time;
case Unit.C:
case Unit.F:
case Unit.K:
return Config.Quantity.Temperature;
case Unit.Pa:
case Unit.hPa:
case Unit.mbar:
case Unit.kPa:
case Unit.bar:
case Unit.MPa:
case Unit.inHg:
return Config.Quantity.Pressure;
case Unit.RPct:
return Config.Quantity.Humidity;
case Unit.Pct:
case Unit.Promile:
return Config.Quantity.Error;
case Unit.mm:
case Unit.cm:
case Unit.m:
case Unit.inch:
return Config.Quantity.Length;
case Unit.kgpm3:
case Unit.kgpl:
return Config.Quantity.Density;
case Unit.J:
case Unit.kJ:
case Unit.MJ:
case Unit.Wh:
case Unit.kWh:
case Unit.MWh:
return Config.Quantity.Energy;
case Unit.ppl:
case Unit.ppdm3:
case Unit.degpl:
case Unit.degpdm3:
case Unit.lpp:
case Unit.dm3pp:
case Unit.lpdeg:
case Unit.dm3pdeg:
return Config.Quantity.PulsePerLtr;
case Unit.ppkWh:
case Unit.kWhpp:
return Config.Quantity.PulsePerKWh;
default:
return Config.Quantity.Number;
}
}
public static bool IsVolume(Unit units) { return IsQuantity(units, Config.Quantity.Volume); }
public static bool IsFlow(Unit units) { return IsQuantity(units, Config.Quantity.Flow); }
public static bool IsMass(Unit units) { return IsQuantity(units, Config.Quantity.Mass); }
public static bool IsTime(Unit units) { return IsQuantity(units, Config.Quantity.Time); }
public static bool IsTemperature(Unit units) { return IsQuantity(units, Config.Quantity.Temperature); }
public static bool IsPressure(Unit units) { return IsQuantity(units, Config.Quantity.Pressure); }
public static bool IsHumidity(Unit units) { return IsQuantity(units, Config.Quantity.Humidity); }
public static bool IsError(Unit units) { return IsQuantity(units, Config.Quantity.Error); }
public static bool IsLength(Unit units) { return IsQuantity(units, Config.Quantity.Length); }
public static bool IsDensity(Unit units) { return IsQuantity(units, Config.Quantity.Density); }
public static bool IsEnergy(Unit units) { return IsQuantity(units, Config.Quantity.Energy); }
public static bool IsPulses(Unit units) { return IsQuantity(units, Config.Quantity.Pulses); }
public static bool IsPulsePerLtr(Unit units) { return IsQuantity(units, Config.Quantity.PulsePerLtr); }
public static bool IsPulsePerKWh(Unit units) { return IsQuantity(units, Config.Quantity.PulsePerKWh); }
public static double ConvertTo(Unit units, double v)
{
switch (units)
{
/// Volume: internal representation in l
case Unit.dm3:
case Unit.l: return v; /// 1 liter
case Unit.m3: return 0.001 * v; /// 1 m3 = 1000 l
case Unit.gal_UK: return 0.21996925 * v; /// 1 gal(UK) = 4.54609 l
case Unit.gal_US: return 0.26417205 * v; /// 1 gal(US) = 3.78541178 l
/// Flow: internal representation in m3/h
case Unit.lph: return 1000 * v; /// 1 liter/h
case Unit.m3ph: return v; /// 1 m3/h = 1000 l/h
/// Mass: internal representation in kg
case Unit.g: return 1000 * v; /// 1 g = 0.001 kg
case Unit.kg: return v; /// 1 kilogram
case Unit.t: return 0.001 * v; /// 1 t = 1000 kg
case Unit.lb: return 2.2046226 * v; /// 1 lb = 0.45359237 kg
/// Time or duration: internal representation in seconds [s]
case Unit.s: return v;
case Unit.min: return v / 60;
case Unit.hour: return v / 3600;
case Unit.ms: return 1000 * v;
/// Temperature: internal representation in °C
case Unit.C: return v; /// degree Celsius (°C)
case Unit.F: return 1.8 * v + 32; /// degree Fahrenheit
case Unit.K: return v + 273.15; /// degree Kelvin
/// Pressure: internal representation in bar = 0.1 MPa
case Unit.Pa: return 100000 * v; /// 1 hPa = 100 Pa
case Unit.hPa: return 1000 * v; /// 1 hPa = 100 Pa
case Unit.mbar: return 1000 * v; /// 1 mbar = 1 hPa = 100 Pa
case Unit.kPa: return 100 * v; /// 1 kPa = 10 HPa
case Unit.bar: return v; /// 1 bar = 1000 mbar = 100000 Pa
case Unit.MPa: return 0.1 * v; /// 1 MPa = 10000 hPa
case Unit.inHg: return 29.53 * v; /// 1 inHg = 33.864 hPa
/// Error: internal representation in %
case Unit.Pct: return v; /// 1 %
case Unit.Promile: return 10 * v; /// 1 promile = 0.1 %
/// Diameter, length: internal representation in mm
case Unit.mm: return v; /// 1 mm
case Unit.cm: return 0.1 * v; /// 1 cm = 10 mm
case Unit.m: return 0.001 * v; /// 1 m = 1000 mm
case Unit.inch: return v / 25.4; /// 1 inch = 25.4 mm
/// Density: internal representation in kg/m3
case Unit.kgpm3: return v;
case Unit.kgpl: return 0.001 * v;
/// Energy, internal representation in Joul
case Unit.J: return v; /// 1 Joul
case Unit.kJ: return 0.001 * v; /// 1 kJ = 1000 J
case Unit.MJ: return 0.000001 * v; /// 1 kJ = 1000000 J
case Unit.Wh: return v / 3600.0; /// 1 Wh = 3600 J
case Unit.kWh: return v / 3600000.0; /// 1 kWh = 3600000 J
case Unit.MWh: return v / 3600000000.0;/// 1 MWh = 3600000000 J
case Unit.kWhpp:
case Unit.lpp:
case Unit.dm3pp:
case Unit.lpdeg:
case Unit.dm3pdeg: return ((v <= float.Epsilon) ? 0 : 1 / v);
default: return v;
}
}
public static double ConvertFrom(Unit units, double v)
{
switch (units)
{
/// Volume: internal representation in l
case Unit.dm3:
case Unit.l: return v; /// 1 liter
case Unit.m3: return 1000 * v; /// 1000 l
case Unit.gal_UK: return 4.54609 * v; /// 1 gal(UK) = 4.54609 l
case Unit.gal_US: return 3.78541178 * v; /// 1 gal(US) = 3.78541178 l
/// Flow: internal representation in m3/h
case Unit.lph: return 0.001 * v; /// 1 liter/h
case Unit.m3ph: return v; /// 1 m3/h = 1000 l/h
/// Mass: internal representation in kg
case Unit.g: return 0.001 * v; /// 1 g = 0.001 kg
case Unit.kg: return v; /// 1 kilogram
case Unit.t: return 1000 * v; /// 1 t = 1000 kg
case Unit.lb: return 0.45359237 * v; /// 1 lb = 0.45359237 kg
/// Time or duration: internal representation in seconds [s]
case Unit.s: return v;
case Unit.min: return 60 * v;
case Unit.hour: return 3600 * v;
case Unit.ms: return v / 1000;
/// Temperature: internal representation in °C
case Unit.C: return v; /// degree Celsius (°C)
case Unit.F: return 5 * (v-32) / 9; /// degree Fahrenheit
case Unit.K: return v - 273.15; /// degree Kelvin
/// Pressure: internal representation in bar = 0.1 MPa
case Unit.Pa: return 0.00001 * v; /// 1 hPa = 100 Pa
case Unit.hPa: return 0.001 * v; /// 1 hPa = 100 Pa
case Unit.mbar: return 0.001 * v; /// 1 mbar = 1 hPa = 100 Pa
case Unit.kPa: return 0.01 * v; /// 1 kPa = 10 HPa
case Unit.bar: return v; /// 1 bar = 1000 mbar = 100000 Pa
case Unit.MPa: return 10 * v; /// 1 MPa = 10000 hPa
case Unit.inHg: return 0.033864 * v; /// 1 inHg = 33.864 hPa
/// Error: internal representation in %
case Unit.Pct: return v; /// 1 %
case Unit.Promile: return 0.1 * v; /// 1 promile = 0.1 %
/// Diameter, length: internal representation in mm
case Unit.mm: return v; /// 1 mm
case Unit.cm: return 10 * v; /// 1 cm = 10 mm
case Unit.m: return 1000 * v; /// 1 m = 1000 mm
case Unit.inch: return 25.4 * v; /// 1 inch = 25.4 mm
/// Density: internal representation in kg/m3
case Unit.kgpm3: return v;
case Unit.kgpl: return 1000 * v;
/// Energy, internal representation in Joul
case Unit.J: return v; /// 1 Joul
case Unit.kJ: return 1000 * v; /// 1 kJ = 1000 J
case Unit.MJ: return 1000000 * v; /// 1 kJ = 1000000 J
case Unit.Wh: return 3600 * v; /// 1 Wh = 3600 J
case Unit.kWh: return 3600000 * v; /// 1 kWh = 3600000 J
case Unit.MWh: return 3600000000 * v; /// 1 kWh = 3600000000 J
case Unit.kWhpp:
case Unit.lpp:
case Unit.dm3pp:
case Unit.lpdeg:
case Unit.dm3pdeg: return ((v == 0) ? 0 : 1 / v);
default: return v;
}
}
}
}

View File

@ -0,0 +1,69 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Config
{
public static class Utils
{
public static string SignificantDigitsToFmt(double value, int sigDigits)
{
if (sigDigits == 5)
{
if (value >= 9999.5 || value < -9999.5) return "F0";
else if (value >= 999.95 || value < -999.95) return "F1";
else if (value >= 99.995 || value < -99.995) return "F2";
else if (value >= 9.9995 || value < -9.9995) return "F3";
else if (value >= 0.99995 || value < -0.99995) return "F4";
else if (value >= 0.099995 || value < -0.099995) return "F5";
else if (value >= 0.0099995 || value < -0.0099995) return "F6";
else if (value >= 0.00099995 || value < -0.00099995) return "F7";
else if (value >= 0.000099995 || value < -0.000099995) return "F8";
else return "F9";
}
else if (sigDigits == 4)
{
if (value >= 999.5 || value < -999.5) return "F0";
else if (value >= 99.95 || value < -99.95) return "F1";
else if (value >= 9.995 || value < -9.995) return "F2";
else if (value >= 0.9995 || value < -0.9995) return "F3";
else if (value >= 0.09995 || value < -0.09995) return "F4";
else if (value >= 0.009995 || value < -0.009995) return "F5";
else if (value >= 0.0009995 || value < -0.0009995) return "F6";
else if (value >= 0.00009995 || value < -0.00009995) return "F7";
else return "F8";
}
else if (sigDigits == 3)
{
if (value >= 99.5 || value < -99.5) return "F0";
else if (value >= 9.95 || value < -9.95) return "F1";
else if (value >= 0.995 || value < -0.995) return "F2";
else if (value >= 0.0995 || value < -0.0995) return "F3";
else if (value >= 0.00995 || value < -0.00995) return "F4";
else if (value >= 0.000995 || value < -0.000995) return "F5";
else if (value >= 0.0000995 || value < -0.0000995) return "F6";
else return "F7";
}
else if (sigDigits == 2)
{
if (value >= 9.5 || value < -9.5) return "F0";
else if (value >= 0.95 || value < -0.95) return "F1";
else if (value >= 0.095 || value < -0.095) return "F2";
else if (value >= 0.0095 || value < -0.0095) return "F3";
else if (value >= 0.00095 || value < -0.00095) return "F4";
else if (value >= 0.000095 || value < -0.000095) return "F5";
else return "F6";
}
else /// if (sigDigits == 1)
{
if (value >= 0.95 || value < -0.95) return "F0";
else if (value >= 0.095 || value < -0.095) return "F1";
else if (value >= 0.0095 || value < -0.0095) return "F2";
else if (value >= 0.00095 || value < -0.00095) return "F3";
else if (value >= 0.000095 || value < -0.000095) return "F4";
else return "F5";
}
}
}
}

View File

@ -0,0 +1,108 @@
<?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>{6D3384DC-4638-4A92-91A8-F39D900377C6}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>DeviceTest</RootNamespace>
<AssemblyName>DeviceTest</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>DeviceTest.Program</StartupObject>
</PropertyGroup>
<ItemGroup>
<Reference Include="log4net, Version=1.2.12.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\log4net.2.0.2\lib\net40-full\log4net.dll</HintPath>
</Reference>
<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.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="DeviceTestDlg.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="DeviceTestDlg.Designer.cs">
<DependentUpon>DeviceTestDlg.cs</DependentUpon>
</Compile>
<Compile Include="LocalSettings.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="DeviceTestDlg.resx">
<DependentUpon>DeviceTestDlg.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="app.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Config\Config.csproj">
<Project>{743DF7DB-C7B6-42EB-986D-0F485E5588E4}</Project>
<Name>Config</Name>
</ProjectReference>
<ProjectReference Include="..\TBF\TBF.csproj">
<Project>{8648FD92-CDA1-4C3A-B5F9-FE547CE1FA48}</Project>
<Name>TBF</Name>
</ProjectReference>
</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>

View File

@ -0,0 +1,584 @@
namespace DeviceTest
{
partial class DeviceTestDlg
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.parentClassNameComboBox = new System.Windows.Forms.ComboBox();
this.classLabel = new System.Windows.Forms.Label();
this.nameLabel = new System.Windows.Forms.Label();
this.parentNameTextBox = new System.Windows.Forms.TextBox();
this.configureParentButton = new System.Windows.Forms.Button();
this.startButton = new System.Windows.Forms.Button();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.configureComponent1Button = new System.Windows.Forms.Button();
this.componentNameTextBox = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.component1ClassNameComboBox = new System.Windows.Forms.ComboBox();
this.radioButton4 = new System.Windows.Forms.RadioButton();
this.radioButton3 = new System.Windows.Forms.RadioButton();
this.radioButton2 = new System.Windows.Forms.RadioButton();
this.radioButton1 = new System.Windows.Forms.RadioButton();
this.radioButton0 = new System.Windows.Forms.RadioButton();
this.stopButton = new System.Windows.Forms.Button();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.configureComponent2Button = new System.Windows.Forms.Button();
this.component2NameTextBox = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.component2ClassNameComboBox = new System.Windows.Forms.ComboBox();
this.radioButton24 = new System.Windows.Forms.RadioButton();
this.radioButton23 = new System.Windows.Forms.RadioButton();
this.radioButton22 = new System.Windows.Forms.RadioButton();
this.radioButton21 = new System.Windows.Forms.RadioButton();
this.groupBox4 = new System.Windows.Forms.GroupBox();
this.radioButton34 = new System.Windows.Forms.RadioButton();
this.radioButton33 = new System.Windows.Forms.RadioButton();
this.radioButton32 = new System.Windows.Forms.RadioButton();
this.radioButton31 = new System.Windows.Forms.RadioButton();
this.groupBox5 = new System.Windows.Forms.GroupBox();
this.configureComponent3Button = new System.Windows.Forms.Button();
this.component3NameTextBox = new System.Windows.Forms.TextBox();
this.label5 = new System.Windows.Forms.Label();
this.label6 = new System.Windows.Forms.Label();
this.component3ClassNameComboBox = new System.Windows.Forms.ComboBox();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.groupBox3.SuspendLayout();
this.groupBox4.SuspendLayout();
this.groupBox5.SuspendLayout();
this.SuspendLayout();
//
// parentClassNameComboBox
//
this.parentClassNameComboBox.FormattingEnabled = true;
this.parentClassNameComboBox.Location = new System.Drawing.Point(77, 19);
this.parentClassNameComboBox.Name = "parentClassNameComboBox";
this.parentClassNameComboBox.Size = new System.Drawing.Size(299, 21);
this.parentClassNameComboBox.TabIndex = 0;
//
// classLabel
//
this.classLabel.AutoSize = true;
this.classLabel.Location = new System.Drawing.Point(11, 22);
this.classLabel.Name = "classLabel";
this.classLabel.Size = new System.Drawing.Size(32, 13);
this.classLabel.TabIndex = 1;
this.classLabel.Text = "Class";
//
// nameLabel
//
this.nameLabel.AutoSize = true;
this.nameLabel.Location = new System.Drawing.Point(11, 47);
this.nameLabel.Name = "nameLabel";
this.nameLabel.Size = new System.Drawing.Size(35, 13);
this.nameLabel.TabIndex = 2;
this.nameLabel.Text = "Name";
//
// parentNameTextBox
//
this.parentNameTextBox.Enabled = false;
this.parentNameTextBox.Location = new System.Drawing.Point(77, 44);
this.parentNameTextBox.Name = "parentNameTextBox";
this.parentNameTextBox.Size = new System.Drawing.Size(299, 20);
this.parentNameTextBox.TabIndex = 3;
//
// configureParentButton
//
this.configureParentButton.Location = new System.Drawing.Point(395, 19);
this.configureParentButton.Name = "configureParentButton";
this.configureParentButton.Size = new System.Drawing.Size(73, 45);
this.configureParentButton.TabIndex = 4;
this.configureParentButton.Text = "Configure";
this.configureParentButton.UseVisualStyleBackColor = true;
this.configureParentButton.Click += new System.EventHandler(this.configureParentButton_Click);
//
// startButton
//
this.startButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.startButton.Location = new System.Drawing.Point(520, 19);
this.startButton.Name = "startButton";
this.startButton.Size = new System.Drawing.Size(73, 45);
this.startButton.TabIndex = 7;
this.startButton.Text = "Start";
this.startButton.UseVisualStyleBackColor = true;
this.startButton.Click += new System.EventHandler(this.startButton_Click);
//
// groupBox1
//
this.groupBox1.Controls.Add(this.configureParentButton);
this.groupBox1.Controls.Add(this.parentNameTextBox);
this.groupBox1.Controls.Add(this.nameLabel);
this.groupBox1.Controls.Add(this.classLabel);
this.groupBox1.Controls.Add(this.parentClassNameComboBox);
this.groupBox1.Location = new System.Drawing.Point(12, 12);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(486, 75);
this.groupBox1.TabIndex = 8;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Parent component";
//
// groupBox2
//
this.groupBox2.Controls.Add(this.configureComponent1Button);
this.groupBox2.Controls.Add(this.componentNameTextBox);
this.groupBox2.Controls.Add(this.label1);
this.groupBox2.Controls.Add(this.label2);
this.groupBox2.Controls.Add(this.component1ClassNameComboBox);
this.groupBox2.Location = new System.Drawing.Point(12, 93);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(486, 75);
this.groupBox2.TabIndex = 9;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "Component 1";
//
// configureComponentButton
//
this.configureComponent1Button.Location = new System.Drawing.Point(395, 19);
this.configureComponent1Button.Name = "configureComponentButton";
this.configureComponent1Button.Size = new System.Drawing.Size(73, 45);
this.configureComponent1Button.TabIndex = 4;
this.configureComponent1Button.Text = "Configure";
this.configureComponent1Button.UseVisualStyleBackColor = true;
this.configureComponent1Button.Click += new System.EventHandler(this.configureComponent1Button_Click);
//
// componentNameTextBox
//
this.componentNameTextBox.Enabled = false;
this.componentNameTextBox.Location = new System.Drawing.Point(77, 44);
this.componentNameTextBox.Name = "componentNameTextBox";
this.componentNameTextBox.Size = new System.Drawing.Size(299, 20);
this.componentNameTextBox.TabIndex = 3;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(11, 47);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(35, 13);
this.label1.TabIndex = 2;
this.label1.Text = "Name";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(11, 22);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(32, 13);
this.label2.TabIndex = 1;
this.label2.Text = "Class";
//
// componentClassNameComboBox
//
this.component1ClassNameComboBox.FormattingEnabled = true;
this.component1ClassNameComboBox.Location = new System.Drawing.Point(77, 19);
this.component1ClassNameComboBox.Name = "componentClassNameComboBox";
this.component1ClassNameComboBox.Size = new System.Drawing.Size(299, 21);
this.component1ClassNameComboBox.TabIndex = 0;
//
// radioButton4
//
this.radioButton4.AutoSize = true;
this.radioButton4.Location = new System.Drawing.Point(13, 118);
this.radioButton4.Name = "radioButton4";
this.radioButton4.Size = new System.Drawing.Size(51, 17);
this.radioButton4.TabIndex = 9;
this.radioButton4.TabStop = true;
this.radioButton4.Text = "spare";
this.radioButton4.UseVisualStyleBackColor = true;
this.radioButton4.CheckedChanged += new System.EventHandler(this.radioButton4_CheckedChanged);
//
// radioButton3
//
this.radioButton3.AutoSize = true;
this.radioButton3.Location = new System.Drawing.Point(13, 95);
this.radioButton3.Name = "radioButton3";
this.radioButton3.Size = new System.Drawing.Size(51, 17);
this.radioButton3.TabIndex = 8;
this.radioButton3.TabStop = true;
this.radioButton3.Text = "spare";
this.radioButton3.UseVisualStyleBackColor = true;
this.radioButton3.CheckedChanged += new System.EventHandler(this.radioButton3_CheckedChanged);
//
// radioButton2
//
this.radioButton2.AutoSize = true;
this.radioButton2.Location = new System.Drawing.Point(13, 72);
this.radioButton2.Name = "radioButton2";
this.radioButton2.Size = new System.Drawing.Size(51, 17);
this.radioButton2.TabIndex = 7;
this.radioButton2.TabStop = true;
this.radioButton2.Text = "spare";
this.radioButton2.UseVisualStyleBackColor = true;
this.radioButton2.CheckedChanged += new System.EventHandler(this.radioButton2_CheckedChanged);
//
// radioButton1
//
this.radioButton1.AutoSize = true;
this.radioButton1.Location = new System.Drawing.Point(13, 49);
this.radioButton1.Name = "radioButton1";
this.radioButton1.Size = new System.Drawing.Size(106, 17);
this.radioButton1.TabIndex = 6;
this.radioButton1.TabStop = true;
this.radioButton1.Text = "ReadPressureOp";
this.radioButton1.UseVisualStyleBackColor = true;
this.radioButton1.CheckedChanged += new System.EventHandler(this.radioButton1_CheckedChanged);
//
// radioButton0
//
this.radioButton0.AutoSize = true;
this.radioButton0.Location = new System.Drawing.Point(13, 26);
this.radioButton0.Name = "radioButton0";
this.radioButton0.Size = new System.Drawing.Size(94, 17);
this.radioButton0.TabIndex = 5;
this.radioButton0.TabStop = true;
this.radioButton0.Text = "Stop operation";
this.radioButton0.UseVisualStyleBackColor = true;
this.radioButton0.CheckedChanged += new System.EventHandler(this.radioButton0_CheckedChanged);
//
// stopButton
//
this.stopButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.stopButton.Location = new System.Drawing.Point(520, 77);
this.stopButton.Name = "stopButton";
this.stopButton.Size = new System.Drawing.Size(73, 45);
this.stopButton.TabIndex = 10;
this.stopButton.Text = "Stop";
this.stopButton.UseVisualStyleBackColor = true;
this.stopButton.Click += new System.EventHandler(this.stopButton_Click);
//
// groupBox3
//
this.groupBox3.Controls.Add(this.configureComponent2Button);
this.groupBox3.Controls.Add(this.component2NameTextBox);
this.groupBox3.Controls.Add(this.label3);
this.groupBox3.Controls.Add(this.label4);
this.groupBox3.Controls.Add(this.component2ClassNameComboBox);
this.groupBox3.Location = new System.Drawing.Point(12, 174);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(486, 75);
this.groupBox3.TabIndex = 11;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "Component 2";
//
// configureComponent2Button
//
this.configureComponent2Button.Location = new System.Drawing.Point(395, 19);
this.configureComponent2Button.Name = "configureComponent2Button";
this.configureComponent2Button.Size = new System.Drawing.Size(73, 45);
this.configureComponent2Button.TabIndex = 4;
this.configureComponent2Button.Text = "Configure";
this.configureComponent2Button.UseVisualStyleBackColor = true;
this.configureComponent2Button.Click += new System.EventHandler(this.configureComponent2Button_Click);
//
// component2NameTextBox
//
this.component2NameTextBox.Enabled = false;
this.component2NameTextBox.Location = new System.Drawing.Point(77, 44);
this.component2NameTextBox.Name = "component2NameTextBox";
this.component2NameTextBox.Size = new System.Drawing.Size(299, 20);
this.component2NameTextBox.TabIndex = 3;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(11, 47);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(35, 13);
this.label3.TabIndex = 2;
this.label3.Text = "Name";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(11, 22);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(32, 13);
this.label4.TabIndex = 1;
this.label4.Text = "Class";
//
// component2ClassNameComboBox
//
this.component2ClassNameComboBox.FormattingEnabled = true;
this.component2ClassNameComboBox.Location = new System.Drawing.Point(77, 19);
this.component2ClassNameComboBox.Name = "component2ClassNameComboBox";
this.component2ClassNameComboBox.Size = new System.Drawing.Size(299, 21);
this.component2ClassNameComboBox.TabIndex = 0;
//
// radioButton24
//
this.radioButton24.AutoSize = true;
this.radioButton24.Location = new System.Drawing.Point(212, 118);
this.radioButton24.Name = "radioButton24";
this.radioButton24.Size = new System.Drawing.Size(51, 17);
this.radioButton24.TabIndex = 9;
this.radioButton24.TabStop = true;
this.radioButton24.Text = "spare";
this.radioButton24.UseVisualStyleBackColor = true;
this.radioButton24.CheckedChanged += new System.EventHandler(this.radioButton24_CheckedChanged);
//
// radioButton23
//
this.radioButton23.AutoSize = true;
this.radioButton23.Location = new System.Drawing.Point(212, 95);
this.radioButton23.Name = "radioButton23";
this.radioButton23.Size = new System.Drawing.Size(51, 17);
this.radioButton23.TabIndex = 8;
this.radioButton23.TabStop = true;
this.radioButton23.Text = "spare";
this.radioButton23.UseVisualStyleBackColor = true;
this.radioButton23.CheckedChanged += new System.EventHandler(this.radioButton23_CheckedChanged);
//
// radioButton22
//
this.radioButton22.AutoSize = true;
this.radioButton22.Location = new System.Drawing.Point(212, 72);
this.radioButton22.Name = "radioButton22";
this.radioButton22.Size = new System.Drawing.Size(51, 17);
this.radioButton22.TabIndex = 7;
this.radioButton22.TabStop = true;
this.radioButton22.Text = "spare";
this.radioButton22.UseVisualStyleBackColor = true;
this.radioButton22.CheckedChanged += new System.EventHandler(this.radioButton22_CheckedChanged);
//
// radioButton21
//
this.radioButton21.AutoSize = true;
this.radioButton21.Location = new System.Drawing.Point(212, 49);
this.radioButton21.Name = "radioButton21";
this.radioButton21.Size = new System.Drawing.Size(106, 17);
this.radioButton21.TabIndex = 6;
this.radioButton21.TabStop = true;
this.radioButton21.Text = "ReadPressureOp";
this.radioButton21.UseVisualStyleBackColor = true;
this.radioButton21.CheckedChanged += new System.EventHandler(this.radioButton21_CheckedChanged);
//
// groupBox4
//
this.groupBox4.Controls.Add(this.radioButton34);
this.groupBox4.Controls.Add(this.radioButton33);
this.groupBox4.Controls.Add(this.radioButton32);
this.groupBox4.Controls.Add(this.radioButton31);
this.groupBox4.Controls.Add(this.radioButton24);
this.groupBox4.Controls.Add(this.radioButton4);
this.groupBox4.Controls.Add(this.radioButton23);
this.groupBox4.Controls.Add(this.radioButton0);
this.groupBox4.Controls.Add(this.radioButton22);
this.groupBox4.Controls.Add(this.radioButton3);
this.groupBox4.Controls.Add(this.radioButton21);
this.groupBox4.Controls.Add(this.radioButton1);
this.groupBox4.Controls.Add(this.radioButton2);
this.groupBox4.Location = new System.Drawing.Point(12, 349);
this.groupBox4.Name = "groupBox4";
this.groupBox4.Size = new System.Drawing.Size(581, 145);
this.groupBox4.TabIndex = 12;
this.groupBox4.TabStop = false;
this.groupBox4.Text = "Operations";
//
// radioButton34
//
this.radioButton34.AutoSize = true;
this.radioButton34.Location = new System.Drawing.Point(405, 118);
this.radioButton34.Name = "radioButton34";
this.radioButton34.Size = new System.Drawing.Size(51, 17);
this.radioButton34.TabIndex = 13;
this.radioButton34.TabStop = true;
this.radioButton34.Text = "spare";
this.radioButton34.UseVisualStyleBackColor = true;
this.radioButton34.CheckedChanged += new System.EventHandler(this.radioButton34_CheckedChanged);
//
// radioButton33
//
this.radioButton33.AutoSize = true;
this.radioButton33.Location = new System.Drawing.Point(405, 95);
this.radioButton33.Name = "radioButton33";
this.radioButton33.Size = new System.Drawing.Size(51, 17);
this.radioButton33.TabIndex = 12;
this.radioButton33.TabStop = true;
this.radioButton33.Text = "spare";
this.radioButton33.UseVisualStyleBackColor = true;
this.radioButton33.CheckedChanged += new System.EventHandler(this.radioButton33_CheckedChanged);
//
// radioButton32
//
this.radioButton32.AutoSize = true;
this.radioButton32.Location = new System.Drawing.Point(405, 72);
this.radioButton32.Name = "radioButton32";
this.radioButton32.Size = new System.Drawing.Size(51, 17);
this.radioButton32.TabIndex = 11;
this.radioButton32.TabStop = true;
this.radioButton32.Text = "spare";
this.radioButton32.UseVisualStyleBackColor = true;
this.radioButton32.CheckedChanged += new System.EventHandler(this.radioButton32_CheckedChanged);
//
// radioButton31
//
this.radioButton31.AutoSize = true;
this.radioButton31.Location = new System.Drawing.Point(405, 49);
this.radioButton31.Name = "radioButton31";
this.radioButton31.Size = new System.Drawing.Size(106, 17);
this.radioButton31.TabIndex = 10;
this.radioButton31.TabStop = true;
this.radioButton31.Text = "ReadPressureOp";
this.radioButton31.UseVisualStyleBackColor = true;
this.radioButton31.CheckedChanged += new System.EventHandler(this.radioButton31_CheckedChanged);
//
// groupBox5
//
this.groupBox5.Controls.Add(this.configureComponent3Button);
this.groupBox5.Controls.Add(this.component3NameTextBox);
this.groupBox5.Controls.Add(this.label5);
this.groupBox5.Controls.Add(this.label6);
this.groupBox5.Controls.Add(this.component3ClassNameComboBox);
this.groupBox5.Location = new System.Drawing.Point(12, 255);
this.groupBox5.Name = "groupBox5";
this.groupBox5.Size = new System.Drawing.Size(486, 75);
this.groupBox5.TabIndex = 13;
this.groupBox5.TabStop = false;
this.groupBox5.Text = "Component 3";
//
// configureComponent3Button
//
this.configureComponent3Button.Location = new System.Drawing.Point(395, 19);
this.configureComponent3Button.Name = "configureComponent3Button";
this.configureComponent3Button.Size = new System.Drawing.Size(73, 45);
this.configureComponent3Button.TabIndex = 4;
this.configureComponent3Button.Text = "Configure";
this.configureComponent3Button.UseVisualStyleBackColor = true;
this.configureComponent3Button.Click += new System.EventHandler(this.configureComponent3Button_Click);
//
// component3NameTextBox
//
this.component3NameTextBox.Enabled = false;
this.component3NameTextBox.Location = new System.Drawing.Point(77, 44);
this.component3NameTextBox.Name = "component3NameTextBox";
this.component3NameTextBox.Size = new System.Drawing.Size(299, 20);
this.component3NameTextBox.TabIndex = 3;
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(11, 47);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(35, 13);
this.label5.TabIndex = 2;
this.label5.Text = "Name";
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(11, 22);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(32, 13);
this.label6.TabIndex = 1;
this.label6.Text = "Class";
//
// component3ClassNameComboBox
//
this.component3ClassNameComboBox.FormattingEnabled = true;
this.component3ClassNameComboBox.Location = new System.Drawing.Point(77, 19);
this.component3ClassNameComboBox.Name = "component3ClassNameComboBox";
this.component3ClassNameComboBox.Size = new System.Drawing.Size(299, 21);
this.component3ClassNameComboBox.TabIndex = 0;
//
// DeviceTestDlg
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(613, 502);
this.Controls.Add(this.groupBox5);
this.Controls.Add(this.groupBox4);
this.Controls.Add(this.groupBox3);
this.Controls.Add(this.stopButton);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.startButton);
this.Controls.Add(this.groupBox1);
this.Name = "DeviceTestDlg";
this.Text = "Device test";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.DeviceTestDlg_FormClosing);
this.Load += new System.EventHandler(this.DeviceTestDlg_Load);
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
this.groupBox3.ResumeLayout(false);
this.groupBox3.PerformLayout();
this.groupBox4.ResumeLayout(false);
this.groupBox4.PerformLayout();
this.groupBox5.ResumeLayout(false);
this.groupBox5.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.ComboBox parentClassNameComboBox;
private System.Windows.Forms.Label classLabel;
private System.Windows.Forms.Label nameLabel;
private System.Windows.Forms.TextBox parentNameTextBox;
private System.Windows.Forms.Button configureParentButton;
private System.Windows.Forms.Button startButton;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.Button configureComponent1Button;
private System.Windows.Forms.TextBox componentNameTextBox;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.ComboBox component1ClassNameComboBox;
private System.Windows.Forms.RadioButton radioButton4;
private System.Windows.Forms.RadioButton radioButton3;
private System.Windows.Forms.RadioButton radioButton2;
private System.Windows.Forms.RadioButton radioButton1;
private System.Windows.Forms.RadioButton radioButton0;
private System.Windows.Forms.Button stopButton;
private System.Windows.Forms.GroupBox groupBox3;
private System.Windows.Forms.RadioButton radioButton24;
private System.Windows.Forms.RadioButton radioButton23;
private System.Windows.Forms.RadioButton radioButton22;
private System.Windows.Forms.RadioButton radioButton21;
private System.Windows.Forms.Button configureComponent2Button;
private System.Windows.Forms.TextBox component2NameTextBox;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.ComboBox component2ClassNameComboBox;
private System.Windows.Forms.GroupBox groupBox4;
private System.Windows.Forms.GroupBox groupBox5;
private System.Windows.Forms.Button configureComponent3Button;
private System.Windows.Forms.TextBox component3NameTextBox;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.ComboBox component3ClassNameComboBox;
private System.Windows.Forms.RadioButton radioButton34;
private System.Windows.Forms.RadioButton radioButton33;
private System.Windows.Forms.RadioButton radioButton32;
private System.Windows.Forms.RadioButton radioButton31;
}
}

View File

@ -0,0 +1,835 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Threading;
using System.Windows.Forms;
using TBF.BenchControl;
using TBF.BenchControl.Generic;
using TBF.BenchControl.GenericDevices;
using System.Xml.Serialization;
namespace DeviceTest
{
public partial class DeviceTestDlg : Form
{
IList<string> compClasses;
IComponentFactory parentFactory;
IComponentFactory component1Factory;
IComponentFactory component2Factory;
IComponentFactory component3Factory;
IComponentCfg parentCfg;
IComponentCfg component1Cfg;
IComponentCfg component2Cfg;
IComponentCfg component3Cfg;
static IList<TBF.BenchControl.Generic.IDevice> tbfDevices;
static IList<TBF.BenchControl.Generic.IComponent> tbfComponents;
static TBF.BenchControl.Generic.IComponent tbfComponent1forOp;
static TBF.BenchControl.Generic.IComponent tbfComponent2forOp;
static TBF.BenchControl.Generic.IComponent tbfComponent3forOp;
static Thread workerThread;
static bool workerThreadRunning;
static int activeOperationId;
static IOperation operation1;
static IOperation operation2;
static IOperation operation3;
static IOperation operation4;
static IOperation operation21;
static IOperation operation22;
static IOperation operation23;
static IOperation operation24;
static IOperation operation31;
static IOperation operation32;
static IOperation operation33;
static IOperation operation34;
static TBF.Boxes.FloatBox floatBox;
static Event evnt;
static DeviceTestDlg()
{
floatBox = new TBF.Boxes.FloatBox();
floatBox.Format = "F2";
}
public DeviceTestDlg()
{
InitializeComponent();
radioButton0.Checked = true;
stopButton.Enabled = false;
compClasses = new List<string>();
foreach (var componentFactory in TbfComponents.Factories)
{
compClasses.Add(componentFactory.ClassName);
}
tbfComponents = new List<TBF.BenchControl.Generic.IComponent>();
tbfDevices = new List<IDevice>();
}
private void DeviceTestDlg_Load(object sender, EventArgs e)
{
foreach (var clName in compClasses)
{
parentClassNameComboBox.Items.Add(clName);
component1ClassNameComboBox.Items.Add(clName);
component2ClassNameComboBox.Items.Add(clName);
component3ClassNameComboBox.Items.Add(clName);
}
try
{
if (!string.IsNullOrEmpty(Program.LocalSettings.ParentClassName) &&
!string.IsNullOrEmpty(Program.LocalSettings.ParentName) &&
!string.IsNullOrEmpty(Program.LocalSettings.ParentSettings))
{
FactoryFromClassName(Program.LocalSettings.ParentClassName, ref parentFactory);
using (var reader = new StringReader(Program.LocalSettings.ParentSettings))
{
IComponentCfg config = (IComponentCfg)(new XmlSerializer(parentFactory.DefaultConfig().GetType())).Deserialize(reader);
config.Name = Program.LocalSettings.ParentName;
config.ParentName = string.Empty;
config.ItemNr = 0;
config.DebugLevel = Config.Entities.DebugMode.Normal;
config.LogLevel = Config.Entities.LogLevel.Debug;
config.Corrections = null;
config.Factory = parentFactory;
parentCfg = config;
}
parentClassNameComboBox.Text = Program.LocalSettings.ParentClassName;
parentNameTextBox.Text = Program.LocalSettings.ParentName;
}
}
catch
{
parentFactory = null;
parentCfg = null;
parentClassNameComboBox.Text = string.Empty;
parentNameTextBox.Text = string.Empty;
}
try
{
if (!string.IsNullOrEmpty(Program.LocalSettings.ComponentClassName) &&
!string.IsNullOrEmpty(Program.LocalSettings.ComponentName) &&
!string.IsNullOrEmpty(Program.LocalSettings.ComponentSettings))
{
FactoryFromClassName(Program.LocalSettings.ComponentClassName, ref component1Factory);
using (var reader = new StringReader(Program.LocalSettings.ComponentSettings))
{
IComponentCfg config = (IComponentCfg)(new XmlSerializer(component1Factory.DefaultConfig().GetType())).Deserialize(reader);
config.Name = Program.LocalSettings.ComponentName;
config.ParentName = string.IsNullOrEmpty(Program.LocalSettings.ComponentParentName) ? string.Empty : Program.LocalSettings.ComponentParentName;
config.ItemNr = 1;
config.DebugLevel = Config.Entities.DebugMode.Normal;
config.LogLevel = Config.Entities.LogLevel.Debug;
config.Corrections = null;
config.Factory = component1Factory;
component1Cfg = config;
}
component1ClassNameComboBox.Text = Program.LocalSettings.ComponentClassName;
componentNameTextBox.Text = Program.LocalSettings.ComponentName;
UpdateOperations(component1ClassNameComboBox.Text);
}
}
catch
{
component1Factory = null;
component1Cfg = null;
component1ClassNameComboBox.Text = string.Empty;
componentNameTextBox.Text = string.Empty;
}
try
{
if (!string.IsNullOrEmpty(Program.LocalSettings.Component2ClassName) &&
!string.IsNullOrEmpty(Program.LocalSettings.Component2Name) &&
!string.IsNullOrEmpty(Program.LocalSettings.Component2Settings))
{
FactoryFromClassName(Program.LocalSettings.Component2ClassName, ref component2Factory);
using (var reader = new StringReader(Program.LocalSettings.Component2Settings))
{
IComponentCfg config = (IComponentCfg)(new XmlSerializer(component2Factory.DefaultConfig().GetType())).Deserialize(reader);
config.Name = Program.LocalSettings.Component2Name;
config.ParentName = string.IsNullOrEmpty(Program.LocalSettings.Component2ParentName) ? string.Empty : Program.LocalSettings.Component2ParentName;
config.ItemNr = 2;
config.DebugLevel = Config.Entities.DebugMode.Normal;
config.LogLevel = Config.Entities.LogLevel.Debug;
config.Corrections = null;
config.Factory = component2Factory;
component2Cfg = config;
}
component2ClassNameComboBox.Text = Program.LocalSettings.Component2ClassName;
component2NameTextBox.Text = Program.LocalSettings.Component2Name;
UpdateOperations2(component2ClassNameComboBox.Text);
}
}
catch
{
component2Factory = null;
component2Cfg = null;
component2ClassNameComboBox.Text = string.Empty;
component2NameTextBox.Text = string.Empty;
}
try
{
if (!string.IsNullOrEmpty(Program.LocalSettings.Component3ClassName) &&
!string.IsNullOrEmpty(Program.LocalSettings.Component3Name) &&
!string.IsNullOrEmpty(Program.LocalSettings.Component3Settings))
{
FactoryFromClassName(Program.LocalSettings.Component3ClassName, ref component3Factory);
using (var reader = new StringReader(Program.LocalSettings.Component3Settings))
{
IComponentCfg config = (IComponentCfg)(new XmlSerializer(component3Factory.DefaultConfig().GetType())).Deserialize(reader);
config.Name = Program.LocalSettings.Component3Name;
config.ParentName = string.IsNullOrEmpty(Program.LocalSettings.Component3ParentName) ? string.Empty : Program.LocalSettings.Component3ParentName;
config.ItemNr = 3;
config.DebugLevel = Config.Entities.DebugMode.Normal;
config.LogLevel = Config.Entities.LogLevel.Debug;
config.Corrections = null;
config.Factory = component3Factory;
component3Cfg = config;
}
component3ClassNameComboBox.Text = Program.LocalSettings.Component3ClassName;
component3NameTextBox.Text = Program.LocalSettings.Component3Name;
UpdateOperations3(component3ClassNameComboBox.Text);
}
}
catch
{
component3Factory = null;
component3Cfg = null;
component3ClassNameComboBox.Text = string.Empty;
component3NameTextBox.Text = string.Empty;
}
}
void SaveSettings()
{
Program.LocalSettings.ParentClassName = parentClassNameComboBox.Text;
Program.LocalSettings.ParentName = parentNameTextBox.Text;
Program.LocalSettings.ParentSettings = (parentCfg != null) ? parentCfg.CreateDbEntity().Parameters : string.Empty;
Program.LocalSettings.ComponentClassName = component1ClassNameComboBox.Text;
Program.LocalSettings.ComponentName = componentNameTextBox.Text;
Program.LocalSettings.ComponentParentName = (component1Cfg != null) ? component1Cfg.ParentName : string.Empty;
Program.LocalSettings.ComponentSettings = (component1Cfg != null) ? component1Cfg.CreateDbEntity().Parameters : string.Empty;
Program.LocalSettings.Component2ClassName = component2ClassNameComboBox.Text;
Program.LocalSettings.Component2Name = component2NameTextBox.Text;
Program.LocalSettings.Component2ParentName = (component2Cfg != null) ? component2Cfg.ParentName : string.Empty;
Program.LocalSettings.Component2Settings = (component2Cfg != null) ? component2Cfg.CreateDbEntity().Parameters : string.Empty;
Program.LocalSettings.Component3ClassName = component3ClassNameComboBox.Text;
Program.LocalSettings.Component3Name = component3NameTextBox.Text;
Program.LocalSettings.Component3ParentName = (component3Cfg != null) ? component3Cfg.ParentName : string.Empty;
Program.LocalSettings.Component3Settings = (component3Cfg != null) ? component3Cfg.CreateDbEntity().Parameters : string.Empty;
Program.LocalSettings.Save();
}
void UpdateOperations(string className)
{
if (className == "Keithley.TempMeter") radioButton1.Text = "ReadPressureOp";
else if (className == "Network.Camera.CLP1611") radioButton1.Text = "Livestream";
else if (className == "Network.Camera.Roi") radioButton1.Text = "RoiDetection";
else if (className == "Modbus.Easytherm")
{
radioButton1.Text = "SetTemperature(10)";
radioButton2.Text = "SetTemperature(20)";
}
else if (className == "Modbus.TankSelector")
{
radioButton1.Text = "SelectTank 1";
radioButton2.Text = "SelectTank 2";
radioButton3.Text = "SelectTank 3";
radioButton4.Text = "SelectTank -";
}
else radioButton1.Text = "spare";
}
///
void UpdateOperations2(string className)
{
if (className == "Keithley.TempMeter") radioButton21.Text = "ReadPressureOp";
else if (className == "Network.Camera.CLP1611") radioButton21.Text = "Livestream";
else if (className == "Network.Camera.Roi") radioButton21.Text = "RoiDetection";
else if (className == "Modbus.Easytherm")
{
radioButton21.Text = "SetTemperature(10)";
radioButton22.Text = "SetTemperature(20)";
}
else if (className == "Modbus.TankSelector")
{
radioButton21.Text = "SelectTank 1";
radioButton22.Text = "SelectTank 2";
radioButton23.Text = "SelectTank 3";
radioButton24.Text = "SelectTank -";
}
else radioButton21.Text = "spare";
}
///
void UpdateOperations3(string className)
{
if (className == "Keithley.TempMeter") radioButton31.Text = "ReadPressureOp";
else if (className == "Network.Camera.CLP1611") radioButton31.Text = "Livestream";
else if (className == "Network.Camera.Roi") radioButton31.Text = "RoiDetection";
else if (className == "Modbus.Easytherm")
{
radioButton31.Text = "SetTemperature(10)";
radioButton32.Text = "SetTemperature(20)";
}
else if (className == "Modbus.TankSelector")
{
radioButton31.Text = "SelectTank 1";
radioButton32.Text = "SelectTank 2";
radioButton33.Text = "SelectTank 3";
radioButton34.Text = "SelectTank -";
}
else radioButton31.Text = "spare";
}
int GetActiveOperationId()
{
if (radioButton1.Checked) { return 1; }
else if (radioButton2.Checked) { return 2; }
else if (radioButton3.Checked) { return 3; }
else if (radioButton4.Checked) { return 4; }
else if (radioButton21.Checked) { return 21; }
else if (radioButton22.Checked) { return 22; }
else if (radioButton23.Checked) { return 23; }
else if (radioButton24.Checked) { return 24; }
else if (radioButton31.Checked) { return 31; }
else if (radioButton32.Checked) { return 32; }
else if (radioButton33.Checked) { return 33; }
else if (radioButton34.Checked) { return 34; }
else return 0; /// stopOperationRadioButton.Checked
}
private void radioButton0_CheckedChanged(object sender, EventArgs e) { activeOperationId = GetActiveOperationId(); }
private void radioButton1_CheckedChanged(object sender, EventArgs e) { activeOperationId = GetActiveOperationId(); }
private void radioButton2_CheckedChanged(object sender, EventArgs e) { activeOperationId = GetActiveOperationId(); }
private void radioButton3_CheckedChanged(object sender, EventArgs e) { activeOperationId = GetActiveOperationId(); }
private void radioButton4_CheckedChanged(object sender, EventArgs e) { activeOperationId = GetActiveOperationId(); }
///
private void radioButton21_CheckedChanged(object sender, EventArgs e) { activeOperationId = GetActiveOperationId(); }
private void radioButton22_CheckedChanged(object sender, EventArgs e) { activeOperationId = GetActiveOperationId(); }
private void radioButton23_CheckedChanged(object sender, EventArgs e) { activeOperationId = GetActiveOperationId(); }
private void radioButton24_CheckedChanged(object sender, EventArgs e) { activeOperationId = GetActiveOperationId(); }
///
private void radioButton31_CheckedChanged(object sender, EventArgs e) { activeOperationId = GetActiveOperationId(); }
private void radioButton32_CheckedChanged(object sender, EventArgs e) { activeOperationId = GetActiveOperationId(); }
private void radioButton33_CheckedChanged(object sender, EventArgs e) { activeOperationId = GetActiveOperationId(); }
private void radioButton34_CheckedChanged(object sender, EventArgs e) { activeOperationId = GetActiveOperationId(); }
/// <summary>
/// Updates component factory
/// </summary>
/// <param name="className">Component class name</param>
/// <param name="factory">Reference to a factory</param>
/// <returns>true when factory changed</returns>
bool FactoryFromClassName(string className, ref IComponentFactory factory)
{
foreach (var fac in TbfComponents.Factories)
{
if (className == fac.ClassName)
{
if (factory != fac)
{
factory = fac;
return true;
}
else
{
return false;
}
}
}
if (factory != null)
{
factory = null;
return true;
}
return false;
}
private void configureParentButton_Click(object sender, EventArgs e)
{
bool factoryChanged = FactoryFromClassName(parentClassNameComboBox.Text, ref parentFactory);
if (parentFactory == null)
{
MessageBox.Show("Invalid parent class", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
if (factoryChanged || parentCfg == null)
{
parentCfg = parentFactory.DefaultConfig();
}
IComponentCfgCtrl cfgControl = parentCfg.GetControl();
cfgControl.Config = parentCfg;
cfgControl.Config.ItemNr = 0;
TBF.ComponentParametersDlg cfgForm = new TBF.ComponentParametersDlg();
cfgForm.TbfComponents = new List<Config.Entities.Component>();
cfgForm.ComponentCfgCtrl = cfgControl;
cfgForm.UnlockAfterStart = true;
DialogResult dr = cfgForm.ShowDialog();
if (dr != DialogResult.OK) return;
parentNameTextBox.Text = parentCfg.Name;
}
private void configureComponent1Button_Click(object sender, EventArgs e)
{
bool factoryChanged = FactoryFromClassName(component1ClassNameComboBox.Text, ref component1Factory);
if (component1Factory == null)
{
MessageBox.Show("Invalid component class", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
if (factoryChanged || component1Cfg == null)
{
component1Cfg = component1Factory.DefaultConfig();
}
IComponentCfgCtrl cfgControl = component1Cfg.GetControl();
cfgControl.Config = component1Cfg;
cfgControl.Config.ItemNr = 1;
TBF.ComponentParametersDlg cfgForm = new TBF.ComponentParametersDlg();
///
IList<Config.Entities.Component> compEntities = new List<Config.Entities.Component>();
if (parentFactory != null && parentCfg != null) compEntities.Add(parentCfg.CreateDbEntity());
cfgForm.TbfComponents = compEntities;
cfgForm.ComponentCfgCtrl = cfgControl;
cfgForm.UnlockAfterStart = true;
DialogResult dr = cfgForm.ShowDialog();
if (dr != DialogResult.OK) return;
componentNameTextBox.Text = component1Cfg.Name;
UpdateOperations(component1ClassNameComboBox.Text);
}
private void configureComponent2Button_Click(object sender, EventArgs e)
{
bool factoryChanged = FactoryFromClassName(component2ClassNameComboBox.Text, ref component2Factory);
if (component2Factory == null)
{
MessageBox.Show("Invalid component class", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
if (factoryChanged || component2Cfg == null)
{
component2Cfg = component2Factory.DefaultConfig();
}
IComponentCfgCtrl cfgControl = component2Cfg.GetControl();
cfgControl.Config = component2Cfg;
cfgControl.Config.ItemNr = 1;
TBF.ComponentParametersDlg cfgForm = new TBF.ComponentParametersDlg();
///
IList<Config.Entities.Component> compEntities = new List<Config.Entities.Component>();
if (parentFactory != null && parentCfg != null) compEntities.Add(parentCfg.CreateDbEntity());
if (component1Factory != null && component1Cfg != null) compEntities.Add(component1Cfg.CreateDbEntity());
cfgForm.TbfComponents = compEntities;
cfgForm.ComponentCfgCtrl = cfgControl;
cfgForm.UnlockAfterStart = true;
DialogResult dr = cfgForm.ShowDialog();
if (dr != DialogResult.OK) return;
component2NameTextBox.Text = component2Cfg.Name;
UpdateOperations2(component2ClassNameComboBox.Text);
}
private void configureComponent3Button_Click(object sender, EventArgs e)
{
bool factoryChanged = FactoryFromClassName(component3ClassNameComboBox.Text, ref component3Factory);
if (component3Factory == null)
{
MessageBox.Show("Invalid component class", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
if (factoryChanged || component3Cfg == null)
{
component3Cfg = component3Factory.DefaultConfig();
}
IComponentCfgCtrl cfgControl = component3Cfg.GetControl();
cfgControl.Config = component3Cfg;
cfgControl.Config.ItemNr = 1;
TBF.ComponentParametersDlg cfgForm = new TBF.ComponentParametersDlg();
///
IList<Config.Entities.Component> compEntities = new List<Config.Entities.Component>();
if (parentFactory != null && parentCfg != null) compEntities.Add(parentCfg.CreateDbEntity());
if (component1Factory != null && component1Cfg != null) compEntities.Add(component1Cfg.CreateDbEntity());
if (component2Factory != null && component2Cfg != null) compEntities.Add(component2Cfg.CreateDbEntity());
cfgForm.TbfComponents = compEntities;
cfgForm.ComponentCfgCtrl = cfgControl;
cfgForm.UnlockAfterStart = true;
DialogResult dr = cfgForm.ShowDialog();
if (dr != DialogResult.OK) return;
component3NameTextBox.Text = component3Cfg.Name;
UpdateOperations3(component3ClassNameComboBox.Text);
}
private void startButton_Click(object sender, EventArgs e)
{
tbfComponents.Clear();
tbfDevices.Clear();
tbfComponent1forOp = null;
operation1 = null;
operation2 = null;
operation3 = null;
operation4 = null;
tbfComponent2forOp = null;
operation21 = null;
operation22 = null;
operation23 = null;
operation24 = null;
tbfComponent3forOp = null;
operation31 = null;
operation32 = null;
operation33 = null;
operation34 = null;
workerThreadRunning = false;
string initializedDeviceName = "none";
try
{
if (parentFactory != null && parentCfg != null)
{
TBF.BenchControl.Generic.IComponent component = parentFactory.GetComponent(parentCfg, tbfComponents);
tbfComponents.Add(component);
IDevice dev = component as IDevice;
if (dev != null)
{
initializedDeviceName = dev.Name;
dev.Initialize();
tbfDevices.Add(dev);
}
}
if (component1Factory != null && component1Cfg != null)
{
TBF.BenchControl.Generic.IComponent component = component1Factory.GetComponent(component1Cfg, tbfComponents);
tbfComponents.Add(component);
tbfComponent1forOp = component;
IDevice dev = component as IDevice;
if (dev != null)
{
initializedDeviceName = dev.Name;
dev.Initialize();
tbfDevices.Add(dev);
}
}
if (component2Factory != null && component2Cfg != null)
{
TBF.BenchControl.Generic.IComponent component2 = component2Factory.GetComponent(component2Cfg, tbfComponents);
tbfComponents.Add(component2);
tbfComponent2forOp = component2;
IDevice dev = component2 as IDevice;
if (dev != null)
{
initializedDeviceName = dev.Name;
dev.Initialize();
tbfDevices.Add(dev);
}
}
if (component3Factory != null && component3Cfg != null)
{
TBF.BenchControl.Generic.IComponent component3 = component3Factory.GetComponent(component3Cfg, tbfComponents);
tbfComponents.Add(component3);
tbfComponent3forOp = component3;
IDevice dev = component3 as IDevice;
if (dev != null)
{
initializedDeviceName = dev.Name;
dev.Initialize();
tbfDevices.Add(dev);
}
}
if (tbfComponents.Count == 0) throw new Exception("There are no components");
SaveSettings(); /// Save settings after successful initialization
workerThread = new Thread(Worker);
workerThread.CurrentCulture = Thread.CurrentThread.CurrentCulture;
workerThread.CurrentUICulture = Thread.CurrentThread.CurrentUICulture;
workerThreadRunning = true;
workerThread.Start();
startButton.Enabled = false;
stopButton.Enabled = true;
configureComponent2Button.Enabled = false;
configureComponent1Button.Enabled = false;
configureParentButton.Enabled = false;
}
catch (Exception exc)
{
workerThreadRunning = false;
workerThread = null;
MessageBox.Show(exc.Message,
string.Format("'{0}' initialization failed", initializedDeviceName),
MessageBoxButtons.OK,
MessageBoxIcon.Exclamation);
foreach (var dev in tbfDevices) dev.StopDevice();
tbfDevices.Clear();
startButton.Enabled = true;
stopButton.Enabled = false;
configureComponent2Button.Enabled = true;
configureComponent1Button.Enabled = true;
configureParentButton.Enabled = true;
}
}
static void Worker()
{
int activeOperationLocal = 0;
int previousOperation = 0;
if (tbfComponent1forOp is TBF.BenchControl.Modbus.PressureMeter.Meret.PressureMeter)
{
operation1 = (tbfComponent1forOp as TBF.BenchControl.Modbus.PressureMeter.Meret.PressureMeter).ReadPressureOp(ref floatBox);
}
else if (tbfComponent1forOp is TBF.BenchControl.Network.Camera.CLP1611.Camera)
{
operation1 = (tbfComponent1forOp as TBF.BenchControl.Network.Camera.CLP1611.Camera).LiveStreamOp(false);
operation2 = (tbfComponent1forOp as TBF.BenchControl.Network.Camera.CLP1611.Camera).LiveStreamOp(true);
}
else if (tbfComponent1forOp is TBF.BenchControl.Network.Camera.Roi.Roi)
{
operation1 = (tbfComponent1forOp as TBF.BenchControl.Network.Camera.Roi.Roi).RoiDetectionOp();
}
else if (tbfComponent1forOp is TBF.BenchControl.Modbus.Easytherm.Easytherm)
{
operation1 = (tbfComponent1forOp as TBF.BenchControl.Modbus.Easytherm.Easytherm).SetTemperatureOp(10);
operation2 = (tbfComponent1forOp as TBF.BenchControl.Modbus.Easytherm.Easytherm).SetTemperatureOp(20);
}
else if (tbfComponent1forOp is TBF.BenchControl.Modbus.TankSelector.TankSelector)
{
//operation1 = (tbfComponent1forOp as TBF.BenchControl.Modbus.TankSelector.TankSelector).SelectTankOp(1);
//operation2 = (tbfComponent1forOp as TBF.BenchControl.Modbus.TankSelector.TankSelector).SelectTankOp(2);
//operation3 = (tbfComponent1forOp as TBF.BenchControl.Modbus.TankSelector.TankSelector).SelectTankOp(3);
//operation4 = (tbfComponent1forOp as TBF.BenchControl.Modbus.TankSelector.TankSelector).SelectTankOp(0);
}
if (tbfComponent2forOp is TBF.BenchControl.Modbus.PressureMeter.Meret.PressureMeter)
{
operation21 = (tbfComponent2forOp as TBF.BenchControl.Modbus.PressureMeter.Meret.PressureMeter).ReadPressureOp(ref floatBox);
}
else if (tbfComponent2forOp is TBF.BenchControl.Network.Camera.CLP1611.Camera)
{
operation21 = (tbfComponent2forOp as TBF.BenchControl.Network.Camera.CLP1611.Camera).LiveStreamOp(false);
operation22 = (tbfComponent2forOp as TBF.BenchControl.Network.Camera.CLP1611.Camera).LiveStreamOp(true);
}
else if (tbfComponent2forOp is TBF.BenchControl.Network.Camera.Roi.Roi)
{
operation21 = (tbfComponent2forOp as TBF.BenchControl.Network.Camera.Roi.Roi).RoiDetectionOp();
}
else if (tbfComponent2forOp is TBF.BenchControl.Modbus.Easytherm.Easytherm)
{
operation21 = (tbfComponent1forOp as TBF.BenchControl.Modbus.Easytherm.Easytherm).SetTemperatureOp(10);
operation22 = (tbfComponent1forOp as TBF.BenchControl.Modbus.Easytherm.Easytherm).SetTemperatureOp(20);
}
else if (tbfComponent2forOp is TBF.BenchControl.Modbus.TankSelector.TankSelector)
{
//operation21 = (tbfComponent2forOp as TBF.BenchControl.Modbus.TankSelector.TankSelector).SelectTankOp(1);
//operation22 = (tbfComponent2forOp as TBF.BenchControl.Modbus.TankSelector.TankSelector).SelectTankOp(2);
//operation23 = (tbfComponent2forOp as TBF.BenchControl.Modbus.TankSelector.TankSelector).SelectTankOp(3);
//operation24 = (tbfComponent2forOp as TBF.BenchControl.Modbus.TankSelector.TankSelector).SelectTankOp(0);
}
if (tbfComponent3forOp is TBF.BenchControl.Modbus.PressureMeter.Meret.PressureMeter)
{
operation31 = (tbfComponent3forOp as TBF.BenchControl.Modbus.PressureMeter.Meret.PressureMeter).ReadPressureOp(ref floatBox);
}
else if (tbfComponent3forOp is TBF.BenchControl.Network.Camera.CLP1611.Camera)
{
operation31 = (tbfComponent3forOp as TBF.BenchControl.Network.Camera.CLP1611.Camera).LiveStreamOp(false);
operation33 = (tbfComponent3forOp as TBF.BenchControl.Network.Camera.CLP1611.Camera).LiveStreamOp(true);
}
else if (tbfComponent3forOp is TBF.BenchControl.Network.Camera.Roi.Roi)
{
operation31 = (tbfComponent3forOp as TBF.BenchControl.Network.Camera.Roi.Roi).RoiDetectionOp();
}
else if (tbfComponent3forOp is TBF.BenchControl.Modbus.Easytherm.Easytherm)
{
operation31 = (tbfComponent1forOp as TBF.BenchControl.Modbus.Easytherm.Easytherm).SetTemperatureOp(10);
operation32 = (tbfComponent1forOp as TBF.BenchControl.Modbus.Easytherm.Easytherm).SetTemperatureOp(20);
}
else if (tbfComponent3forOp is TBF.BenchControl.Modbus.TankSelector.TankSelector)
{
//operation31 = (tbfComponent3forOp as TBF.BenchControl.Modbus.TankSelector.TankSelector).SelectTankOp(1);
//operation32 = (tbfComponent3forOp as TBF.BenchControl.Modbus.TankSelector.TankSelector).SelectTankOp(2);
//operation33 = (tbfComponent3forOp as TBF.BenchControl.Modbus.TankSelector.TankSelector).SelectTankOp(3);
//operation34 = (tbfComponent3forOp as TBF.BenchControl.Modbus.TankSelector.TankSelector).SelectTankOp(0);
}
while (workerThreadRunning)
{
Thread.Sleep(1000);
if (workerThreadRunning)
{
foreach (var d in tbfDevices) d.RunDeviceBefore();
if (tbfComponent1forOp != null)
{
previousOperation = activeOperationLocal;
activeOperationLocal = activeOperationId;
if (previousOperation == 0 && activeOperationLocal != 0)
{
switch (activeOperationLocal)
{
case 1: if (operation1 != null) operation1.Start(); Debug.WriteLine("op1.Start()"); break;
case 2: if (operation2 != null) operation2.Start(); Debug.WriteLine("op2.Start()"); break;
case 3: if (operation3 != null) operation3.Start(); Debug.WriteLine("op3.Start()"); break;
case 4: if (operation4 != null) operation4.Start(); Debug.WriteLine("op4.Start()"); break;
case 21: if (operation21 != null) operation21.Start(); Debug.WriteLine("op21.Start()"); break;
case 22: if (operation22 != null) operation22.Start(); Debug.WriteLine("op22.Start()"); break;
case 23: if (operation23 != null) operation23.Start(); Debug.WriteLine("op23.Start()"); break;
case 24: if (operation24 != null) operation24.Start(); Debug.WriteLine("op24.Start()"); break;
case 31: if (operation31 != null) operation31.Start(); Debug.WriteLine("op31.Start()"); break;
case 32: if (operation32 != null) operation32.Start(); Debug.WriteLine("op32.Start()"); break;
case 33: if (operation33 != null) operation33.Start(); Debug.WriteLine("op33.Start()"); break;
case 34: if (operation34 != null) operation34.Start(); Debug.WriteLine("op34.Start()"); break;
}
}
else if (previousOperation == activeOperationLocal && activeOperationLocal != 0)
{
switch (activeOperationLocal)
{
case 1: if (operation1 != null) evnt = operation1.Run(); Debug.WriteLine("op1.Run() -> {0}", evnt); break;
case 2: if (operation2 != null) evnt = operation2.Run(); Debug.WriteLine("op2.Run() -> {0}", evnt); break;
case 3: if (operation3 != null) evnt = operation3.Run(); Debug.WriteLine("op3.Run() -> {0}", evnt); break;
case 4: if (operation4 != null) evnt = operation4.Run(); Debug.WriteLine("op4.Run() -> {0}", evnt); break;
case 21: if (operation21 != null) evnt = operation21.Run(); Debug.WriteLine("op21.Run() -> {0}", evnt); break;
case 22: if (operation22 != null) evnt = operation22.Run(); Debug.WriteLine("op22.Run() -> {0}", evnt); break;
case 23: if (operation23 != null) evnt = operation23.Run(); Debug.WriteLine("op23.Run() -> {0}", evnt); break;
case 24: if (operation24 != null) evnt = operation24.Run(); Debug.WriteLine("op24.Run() -> {0}", evnt); break;
case 31: if (operation31 != null) evnt = operation31.Run(); Debug.WriteLine("op31.Run() -> {0}", evnt); break;
case 32: if (operation32 != null) evnt = operation32.Run(); Debug.WriteLine("op32.Run() -> {0}", evnt); break;
case 33: if (operation33 != null) evnt = operation33.Run(); Debug.WriteLine("op33.Run() -> {0}", evnt); break;
case 34: if (operation34 != null) evnt = operation34.Run(); Debug.WriteLine("op34.Run() -> {0}", evnt); break;
default: evnt = Event.None; break;
}
}
else if (previousOperation != 0 && activeOperationLocal == 0)
{
switch (previousOperation)
{
case 1: if (operation1 != null) operation1.Stop(); Debug.WriteLine("op1.Stop()"); break;
case 2: if (operation2 != null) operation2.Stop(); Debug.WriteLine("op2.Stop()"); break;
case 3: if (operation3 != null) operation3.Stop(); Debug.WriteLine("op3.Stop()"); break;
case 4: if (operation4 != null) operation4.Stop(); Debug.WriteLine("op4.Stop()"); break;
case 21: if (operation21 != null) operation21.Stop(); Debug.WriteLine("op21.Stop()"); break;
case 22: if (operation22 != null) operation22.Stop(); Debug.WriteLine("op22.Stop()"); break;
case 23: if (operation23 != null) operation23.Stop(); Debug.WriteLine("op23.Stop()"); break;
case 24: if (operation24 != null) operation24.Stop(); Debug.WriteLine("op24.Stop()"); break;
case 31: if (operation31 != null) operation31.Stop(); Debug.WriteLine("op31.Stop()"); break;
case 32: if (operation32 != null) operation32.Stop(); Debug.WriteLine("op32.Stop()"); break;
case 33: if (operation33 != null) operation33.Stop(); Debug.WriteLine("op33.Stop()"); break;
case 34: if (operation34 != null) operation34.Stop(); Debug.WriteLine("op34.Stop()"); break;
}
}
}
foreach (var d in tbfDevices) d.RunDeviceAfter();
}
}
foreach (var d in tbfDevices) d.StopDevice();
}
private void stopButton_Click(object sender, EventArgs e)
{
Cursor = Cursors.WaitCursor;
workerThreadRunning = false;
workerThread.Join(5000);
workerThread = null;
Cursor = Cursors.Default;
startButton.Enabled = true;
stopButton.Enabled = false;
configureParentButton.Enabled = true;
configureComponent1Button.Enabled = true;
configureComponent2Button.Enabled = true;
configureComponent3Button.Enabled = true;
}
private void DeviceTestDlg_FormClosing(object sender, FormClosingEventArgs e)
{
Cursor = Cursors.WaitCursor;
if (workerThread != null)
{
workerThreadRunning = false;
workerThread.Join(3000);
workerThread = null;
}
Cursor = Cursors.Default;
SaveSettings();
Cursor = Cursors.Default;
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,126 @@
using System;
using System.IO;
using System.Text;
using System.Xml.Serialization;
namespace DeviceTest
{
/// <summary>
/// Class to be serialized to an XML file...
/// </summary>
[XmlRootAttribute("DeviceTest")]
public class LocalSettings
{
public string ParentClassName;
public string ParentName;
public string ParentSettings;
public string ComponentClassName;
public string ComponentName;
public string ComponentParentName;
public string ComponentSettings;
public string Component2ClassName;
public string Component2Name;
public string Component2ParentName;
public string Component2Settings;
public string Component3ClassName;
public string Component3Name;
public string Component3ParentName;
public string Component3Settings;
public LocalSettings()
{
}
/// <summary>
/// Load public fields of this class from the XML file.
/// </summary>
/// <returns>LocalSettings object or null when Load() fails</returns>
public static LocalSettings Load(string fileName)
{
try
{
using (TextReader reader = new StreamReader(fileName))
{
LocalSettings ls = (new XmlSerializer(typeof(LocalSettings))).Deserialize(reader) as LocalSettings;
// Copy the settings just in case De-serialize() completes OK
return ls;
}
}
catch (Exception e)
{
string msg = e.Message;
return null;
}
}
/// <summary>
/// Save public fields of this class to the XML file.
/// </summary>
public void Save()
{
try
{
using (TextWriter writer = new StreamWriter(Program.LocalSettingsFileName))
{
(new XmlSerializer(typeof(LocalSettings))).Serialize(writer, this);
}
}
catch (Exception e)
{
string msg = e.Message;
}
}
/// <summary>
/// Updates history stored in a string array by a new latest string.
/// </summary>
/// <param name="lastStrValue">Last entered string</param>
/// <returns>true = updated and saved</returns>
public bool UpdateHistory(string lastStrValue, ref string[] history)
{
const int MaxHistoryLen = 10;
if (string.IsNullOrEmpty(lastStrValue)) return false;
int currentHistoryLength = (history != null) ? history.Length : 0;
int match = -1;
for (int i = 0; i < currentHistoryLength; i++)
{
if (history[i] == lastStrValue)
{
match = i;
break;
}
}
if (match >= 0 || currentHistoryLength >= MaxHistoryLen)
{
/// History does not have to be extended (because of a match) or should not be extended (because of the lenght)
if (match < 0) match = currentHistoryLength - 1;
for (int j = match; j > 0; j--)
{
history[j] = history[j - 1];
}
history[0] = lastStrValue;
}
else
{
/// History will be extended, new item inserted at the beginning
string[] newHistory = new string[currentHistoryLength + 1];
newHistory[0] = lastStrValue;
for (int j = 1; j <= currentHistoryLength; j++)
{
newHistory[j] = history[j - 1];
}
history = newHistory;
}
Save();
return true;
}
}
}

View File

@ -0,0 +1,111 @@
///
/// Copyright (c) 2016-2017 Sensus Metering Systems
///
using System;
using System.IO;
using System.Windows.Forms;
using log4net;
namespace DeviceTest
{
static class Program
{
/// Program information
public static string Version; /// version string
public static DateTime BuildDateTime; /// date and time of program build
/// log4net
static ILog log;
const string log4netConfigFName = "log4netConfig.xml";
/// Local settings
public static readonly string LocAppDataDir;
public static readonly string LocalSettingsFileName;
public static readonly string LocalSettingsBackupName;
public static LocalSettings LocalSettings;
static Program()
{
/// Program version string
System.Reflection.Assembly thisAssembly = System.Reflection.Assembly.GetExecutingAssembly();
Version ver = thisAssembly.GetName().Version;
Version = string.Format("{0}.{1}.{2}", ver.Major, ver.Minor, ver.Build);
BuildDateTime = new System.IO.FileInfo(thisAssembly.Location).LastWriteTime;
/// Local program configuration directory including the trailing backslash
LocAppDataDir = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) +
Path.DirectorySeparatorChar + "TestBenchFramework" + Path.DirectorySeparatorChar;
LocalSettingsFileName = LocAppDataDir + "DeviceTest.xml";
LocalSettingsBackupName = LocAppDataDir + "DeviceTest.backup.xml";
}
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
///
/// Load the local settings
///
Program.LocalSettings = LocalSettings.Load(Program.LocalSettingsFileName);
if (Program.LocalSettings == null)
{
/// Loading local seetings from regular config file failed. Use the backup
Program.LocalSettings = LocalSettings.Load(Program.LocalSettingsBackupName);
if (Program.LocalSettings == null)
{
MessageBox.Show("Na tomto počítači nebol tento program ani raz spustený.\r\nPoužijú sa základné nastavenia.", "Upozornenie", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
Program.LocalSettings = new LocalSettings();
Directory.CreateDirectory(LocAppDataDir);
Program.LocalSettings.Save();
}
else
{
LocalSettings.Save(); /// Save the settings to overwrite the wrong file
}
}
else
{
/// Loading local seetings from the regular config file was successful. Update the backup
File.Copy(Program.LocalSettingsFileName, Program.LocalSettingsBackupName, true);
}
/// Configure and start logging
log4net.Config.XmlConfigurator.Configure(new System.IO.FileInfo(LocAppDataDir + log4netConfigFName));
log = LogManager.GetLogger(typeof(Program));
log.Fatal("--------------------------------------------------------------------------------");
log.Fatal(string.Format("TBF ver.{0}", Version));
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
try
{
DeviceTestDlg dlg = new DeviceTestDlg();
Application.Run(dlg);
}
catch (Exception exc)
{
LogException(log, "Exception in Application.Run(DeviceTestDlg)", exc);
MessageBox.Show("Program havaroval:" +
Environment.NewLine + Environment.NewLine + exc.Message +
((exc.InnerException == null) ? string.Empty : (Environment.NewLine + exc.InnerException.Message)) +
Environment.NewLine + exc.StackTrace,
"Pozor!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
static void LogException(ILog log, string description, Exception e)
{
log.FatalFormat("---------------( {0} )---------------", description);
log.FatalFormat("Message : {0}", e.Message);
if (e.InnerException != null)
{
log.FatalFormat("InnerMessage : {0}", e.InnerException.Message);
}
log.FatalFormat("StackTrace : {0}{1}", Environment.NewLine, e.StackTrace);
log.Fatal("--------------------------------------");
}
}
}

View File

@ -0,0 +1,36 @@
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("DeviceTest")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("DeviceTest")]
[assembly: AssemblyCopyright("Copyright © 2016")]
[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("a3e8ad92-6617-4f5c-88ce-346d28120fb7")]
// 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")]

View File

@ -0,0 +1,63 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace DeviceTest.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("DeviceTest.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}

View File

@ -0,0 +1,117 @@
<?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.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: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" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</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" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</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=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,26 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace DeviceTest.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
}
}

View File

@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

View File

@ -0,0 +1,3 @@
<?xml version="1.0"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>

View File

@ -0,0 +1,51 @@
<?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)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{439D0878-C76E-452B-B17D-209A89E91D36}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Dirichlet.Numerics</RootNamespace>
<AssemblyName>Dirichlet.Numerics</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<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|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Numerics" />
</ItemGroup>
<ItemGroup>
<Compile Include="Int128.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="UInt128.cs" />
</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>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,36 @@
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("Dirichlet.Numerics")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Dirichlet.Numerics")]
[assembly: AssemblyCopyright("Copyright © 2012")]
[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("a588abc0-c631-4475-9eab-4163d9f81fed")]
// 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")]

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,13 @@
Copyright 2014 Rick Sladkey
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@ -0,0 +1,94 @@
using System;
using System.Text;
namespace GemCard
{
/// <summary>
/// This class represents a command APDU
/// </summary>
public class APDUCommand
{
/// <summary>
/// Minimun size of an APDU command in bytes
/// </summary>
public const int APDU_MIN_LENGTH = 4;
public byte Class; /// Class byte
public byte Ins; /// Instruction byte
public byte P1; /// Parameter P1 byte
public byte P2; /// Parameter P2 byte
public byte[] Data; /// Data to send to the card if any, null if no data to send
public byte Le; /// Number of data expected, 0 if none
/// <summary>
/// Constructor
/// </summary>
/// <param name="bCla">Class byte</param>
/// <param name="bIns">Instruction byte</param>
/// <param name="bP1">Parameter P1 byte</param>
/// <param name="bP2">Parameter P2 byte</param>
/// <param name="baData">Data to send to the card if any, null if no data to send</param>
/// <param name="bLe">Number of data expected, 0 if none</param>
public APDUCommand(byte bCla, byte bIns, byte bP1, byte bP2, byte[] baData, byte bLe)
{
this.Class = bCla;
this.Ins = bIns;
this.P1 = bP1;
this.P2 = bP2;
this.Data = baData;
this.Le = bLe;
}
/// <summary>
/// Update the current APDU with selected parameters
/// </summary>
/// <param name="apduParam">APDU parameters</param>
public void Update(APDUParam apduParam)
{
if (apduParam.UseData) Data = apduParam.Data;
if (apduParam.UseLe) Le = apduParam.Le;
if (apduParam.UseP1) P1 = apduParam.P1;
if (apduParam.UseP2) P2 = apduParam.P2;
if (apduParam.UseChannel) Class += apduParam.Channel;
}
/// <summary>
/// Overrides the ToString method to format to a string the APDUCommand object
/// </summary>
/// <returns></returns>
public override string ToString()
{
string strData = null;
byte bLc = 0;
byte bP3 = Le;
if (Data != null)
{
StringBuilder sData = new StringBuilder(Data.Length * 2);
for (int nI = 0; nI < Data.Length; nI++)
{
sData.AppendFormat("{0:X02}", Data[nI]);
}
strData = "Data=" + sData.ToString();
bLc = (byte) Data.Length;
bP3 = bLc;
}
//string strApdu = string.Format("Class={0:X02} Ins={1:X02} P1={2:X02} P2={3:X02} Le={4:X02} Lc={5:X02} ",
//m_bCla, m_bIns, m_bP1, m_bP2, m_bLe, bLc);
StringBuilder strApdu = new StringBuilder();
strApdu.AppendFormat("Class={0:X02} Ins={1:X02} P1={2:X02} P2={3:X02} P3={4:X02} ",
Class, Ins, P1, P2, bP3);
if (Data != null)
{
strApdu.Append(strData);
}
return strApdu.ToString();
}
}
}

View File

@ -0,0 +1,147 @@
using System;
namespace GemCard
{
/// <summary>
/// This class is used to update a set of parameters of an APDUCommand object
/// </summary>
public class APDUParam
{
byte bClass;
byte bChannel;
byte bP2;
byte bP1;
byte[] baData;
short nLe;
bool fUseP1;
bool fUseP2;
bool fChannel;
bool fData;
bool fClass;
bool fLe;
/// <summary>
/// Resets the current instance, all flags are set to false
/// </summary>
public void Reset()
{
bClass = 0;
bChannel = 0;
bP2 = 0;
bP1 = 0;
baData = null;
nLe = -1;
fUseP1 = false;
fUseP2 = false;
fChannel = false;
fData = false;
fClass = false;
fLe = false;
}
#region Constructors
public APDUParam()
{
Reset();
}
/// <summary>
/// Copy constructor (used for cloning)
/// </summary>
/// <param name="param"></param>
public APDUParam(APDUParam param)
{
// Copy field
if (param.baData != null)
{
param.baData.CopyTo(baData, 0);
}
this.bClass = param.bClass;
this.bChannel = param.bChannel;
this.bP1 = param.bP1;
this.bP2 = param.bP2;
this.nLe = param.nLe;
// Copy flags field
this.fChannel = param.fChannel;
this.fClass = param.fClass;
this.fData = param.fData;
this.fLe = param.fLe;
this.fUseP1 = param.fUseP1;
this.fUseP2 = param.fUseP2;
}
public APDUParam(byte bClass, byte bP1, byte bP2, byte[] baData, short nLe)
{
this.Class = bClass;
this.P1 = bP1;
this.P2 = bP2;
this.Data = baData;
this.Le = (byte)nLe;
}
#endregion
/// <summary>
/// Clones the current APDUParam instance
/// </summary>
/// <returns></returns>
public APDUParam Clone()
{
return new APDUParam(this);
}
#region Properties
public bool UseClass { get { return fClass; } }
public bool UseChannel { get { return fChannel; } }
public bool UseLe { get { return fLe; } }
public bool UseData { get { return fData; } }
public bool UseP1 { get { return fUseP1; } }
public bool UseP2 { get { return fUseP2; } }
public byte P1
{
get { return bP1; }
set { bP1 = value; fUseP1 = true; }
}
public byte P2
{
get { return bP2; }
set { bP2 = value; fUseP2 = true; }
}
public byte[] Data
{
get { return baData; }
set { baData = value; fData = true; }
}
public byte Le
{
get { return (byte)nLe; }
set { nLe = value; fLe = true; }
}
public byte Channel
{
get { return bChannel; }
set { bChannel = value; fChannel = true; }
}
public byte Class
{
get { return bClass; }
set { bClass = value; fClass = true; }
}
#endregion
}
}

View File

@ -0,0 +1,74 @@
using System;
using System.Text;
namespace GemCard
{
/// <summary>
/// This class represents the APDU response sent by the card
/// </summary>
public class APDUResponse
{
/// <summary>
/// Status bytes length
/// </summary>
public const int SW_LENGTH = 2;
/// <summary>
/// Response data. Contains the data sent by the card minus the 2 status bytes (SW1, SW2)
/// null if no data were sent by the card
/// </summary>
public byte[] Data;
public byte SW1;
public byte SW2;
/// <summary>
/// Status get property
/// </summary>
public ushort Status
{
get { return (ushort)(((short)SW1 << 8) + (short)SW2); }
}
/// <summary>
/// Constructor from the byte data sent back by the card
/// </summary>
/// <param name="baData">Buffer of data from the card</param>
public APDUResponse(byte[] baData)
{
if (baData.Length > SW_LENGTH)
{
Data = new byte[baData.Length - SW_LENGTH];
for (int nI = 0; nI < baData.Length - SW_LENGTH; nI++)
{
this.Data[nI] = baData[nI];
}
}
this.SW1 = baData[baData.Length - 2];
this.SW2 = baData[baData.Length - 1];
}
/// <summary>
/// Overrides the ToString method to format to a string the APDUResponse object
/// </summary>
/// <returns></returns>
public override string ToString()
{
if (Data != null)
{
StringBuilder sData = new StringBuilder(Data.Length * 2);
for (int nI = 0; nI < Data.Length; nI++)
{
sData.AppendFormat("{0:X02}", Data[nI]);
}
return sData.ToString();
}
else
{
return string.Empty;
}
}
}
}

View File

@ -0,0 +1,58 @@
using System.Reflection;
using System.Runtime.CompilerServices;
//
// 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("")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
//
// 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 Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.*")]
//
// In order to sign your assembly you must specify a key to use. Refer to the
// Microsoft .NET Framework documentation for more information on assembly signing.
//
// Use the attributes below to control which key is used for signing.
//
// Notes:
// (*) If no key is specified, the assembly is not signed.
// (*) KeyName refers to a key that has been installed in the Crypto Service
// Provider (CSP) on your machine. KeyFile refers to a file which contains
// a key.
// (*) If the KeyFile and the KeyName values are both specified, the
// following processing occurs:
// (1) If the KeyName can be found in the CSP, that key is used.
// (2) If the KeyName does not exist and the KeyFile does exist, the key
// in the KeyFile is installed into the CSP and used.
// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
// When specifying the KeyFile, the location of the KeyFile should be
// relative to the project output directory which is
// %Project Directory%\obj\<configuration>. For example, if your KeyFile is
// located in the project directory, you would specify the AssemblyKeyFile
// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
// documentation for more information on this.
//
[assembly: AssemblyDelaySign(false)]
[assembly: AssemblyKeyFile("")]
[assembly: AssemblyKeyName("")]

View File

@ -0,0 +1,162 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
namespace GemCard
{
/// <summary>
/// Values for AttrId of SCardGetAttrib
/// </summary>
public class SCARD_ATTR_VALUE
{
private const uint
SCARD_CLASS_COMMUNICATIONS = 2,
SCARD_CLASS_PROTOCOL = 3,
SCARD_CLASS_MECHANICAL = 6,
SCARD_CLASS_VENDOR_DEFINED = 7,
SCARD_CLASS_IFD_PROTOCOL = 8,
SCARD_CLASS_ICC_STATE = 9,
SCARD_CLASS_SYSTEM = 0x7fff;
private static UInt32 SCardAttrValue(UInt32 attrClass, UInt32 val)
{
return (attrClass << 16) | val;
}
public static UInt32 CHANNEL_ID { get { return SCardAttrValue(SCARD_CLASS_COMMUNICATIONS, 0x0110); } }
public static UInt32 CHARACTERISTICS { get { return SCardAttrValue(SCARD_CLASS_MECHANICAL, 0x0150); } }
public static UInt32 CURRENT_PROTOCOL_TYPE { get { return SCardAttrValue(SCARD_CLASS_IFD_PROTOCOL, 0x0201); } }
public static UInt32 DEVICE_UNIT { get { return SCardAttrValue(SCARD_CLASS_SYSTEM, 0x0001); } }
public static UInt32 DEVICE_FRIENDLY_NAME { get { return SCardAttrValue(SCARD_CLASS_SYSTEM, 0x0003); } }
public UInt32 DEVICE_SYSTEM_NAME { get { return SCardAttrValue(SCARD_CLASS_SYSTEM, 0x0004); } }
public static UInt32 ICC_PRESENCE { get { return SCardAttrValue(SCARD_CLASS_ICC_STATE, 0x0300); } }
public static UInt32 ICC_INTERFACE_STATUS { get { return SCardAttrValue(SCARD_CLASS_ICC_STATE, 0x0301); } }
public static UInt32 ATR_STRING { get { return SCardAttrValue(SCARD_CLASS_ICC_STATE, 0x0303); } }
public static UInt32 ICC_TYPE_PER_ATR { get { return SCardAttrValue(SCARD_CLASS_ICC_STATE, 0x0304); } }
public static UInt32 PROTOCOL_TYPES { get { return SCardAttrValue(SCARD_CLASS_PROTOCOL, 0x0120); } }
public static UInt32 VENDOR_NAME { get { return SCardAttrValue(SCARD_CLASS_VENDOR_DEFINED, 0x0100); } }
public static UInt32 VENDOR_IFD_TYPE { get { return SCardAttrValue(SCARD_CLASS_VENDOR_DEFINED, 0x0101); } }
public static UInt32 VENDOR_IFD_VERSION { get { return SCardAttrValue(SCARD_CLASS_VENDOR_DEFINED, 0x0102); } }
public static UInt32 VENDOR_IFD_SERIAL_NO { get { return SCardAttrValue(SCARD_CLASS_VENDOR_DEFINED, 0x0103); } }
}
/// <summary>
/// Abstract class that adds a basic event management to the ICard interface.
/// </summary>
abstract public class CardBase : ICard
{
protected const uint INFINITE = 0xFFFFFFFF;
protected const uint WAIT_TIME = 250;
protected bool m_bRunCardDetection = true;
protected Thread m_thread = null;
/// <summary>
/// Event handler for the card insertion
/// </summary>
public event EventHandler<CardInsertedEventArgs> OnCardInserted = null;
/// <summary>
/// Event handler for the card removal
/// </summary>
public event EventHandler<CardRemovedEventArgs> OnCardRemoved = null;
~CardBase()
{
// Stop any eventual card detection thread
StopCardEvents();
}
#region Abstract method that implement the ICard interface
abstract public string[] ListReaders();
abstract public void Connect(string Reader, SHARE ShareMode, PROTOCOL PreferredProtocols);
abstract public void Disconnect(DISCONNECT Disposition);
abstract public APDUResponse Transmit(APDUCommand ApduCmd);
abstract public void BeginTransaction();
abstract public void EndTransaction(DISCONNECT Disposition);
abstract public byte[] GetAttribute(UInt32 AttribId);
#endregion
/// <summary>
/// This method should start a thread that checks for card insertion or removal
/// </summary>
/// <param name="Reader"></param>
public void StartCardEvents(string Reader)
{
if (m_thread == null)
{
m_bRunCardDetection = true;
m_thread = new Thread(new ParameterizedThreadStart(RunCardDetection));
m_thread.Start(Reader);
}
}
/// <summary>
/// Stops the card events thread
/// </summary>
public void StopCardEvents()
{
if (m_thread != null)
{
int
nTimeOut = 10,
nCount = 0;
bool m_bStop = false;
m_bRunCardDetection = false;
do
{
if (nCount > nTimeOut)
{
m_thread.Abort();
break;
}
if (m_thread.ThreadState == ThreadState.Aborted)
m_bStop = true;
if (m_thread.ThreadState == ThreadState.Stopped)
m_bStop = true;
Thread.Sleep(200);
++nCount; // Manage time out
}
while (!m_bStop);
m_thread = null;
}
}
/// <summary>
/// This function must implement a card detection mechanism.
///
/// When card insertion is detected, it must call the method CardInserted()
/// When card removal is detected, it must call the method CardRemoved()
///
/// </summary>
/// <param name="Reader">Name of the reader to scan for card event</param>
abstract protected void RunCardDetection(object Reader);
#region Event methods
protected void CardInserted(object sender, CardInsertedEventArgs args)
{
if (OnCardInserted != null) OnCardInserted(sender, args);
}
protected void CardRemoved(object sender, CardRemovedEventArgs args)
{
if (OnCardRemoved != null) OnCardRemoved(sender, args);
}
#endregion
}
}

View File

@ -0,0 +1,173 @@
using System;
using System.Runtime.InteropServices;
using SCARDSSPLib;
using GemCardExLib;
namespace GemCard
{
/// <summary>
/// Implements the ICard interface using the SCard COM objects from Microsoft and SCardDatabaseEx object
/// for the ListReaders function.
/// </summary>
public class CardCOM : CardBase
{
private ISCard m_itfCard = null;
/// <summary>
/// Default constructor
/// </summary>
public CardCOM()
{
// Create the SCard object
m_itfCard = new CSCardClass();
}
#region ICard Members
/// <summary>
/// Wraps the PCSC function
/// LONG SCardListReaders(SCARDCONTEXT hContext,
/// LPCTSTR mszGroups,
/// LPTSTR mszReaders,
/// LPDWORD pcchReaders
/// );
/// </summary>
/// <returns>A string array of the readers</returns>
public override string[] ListReaders()
{
ISCardDatabaseEx itfCardBase = new SCardDatabaseEx();
return (string[]) itfCardBase.ListReaders();
}
/// <summary>
/// Wraps the PCSC function
/// LONG SCardConnect(
/// IN SCARDCONTEXT hContext,
/// IN LPCTSTR szReader,
/// IN DWORD dwShareMode,
/// IN DWORD dwPreferredProtocols,
/// OUT LPSCARDHANDLE phCard,
/// OUT LPDWORD pdwActiveProtocol
/// );
/// </summary>
/// <param name="Reader"></param>
/// <param name="ShareMode"></param>
/// <param name="PreferredProtocols"></param>
public override void Connect(string Reader, SHARE ShareMode, PROTOCOL PreferredProtocols)
{
// Calls AttachReader to connect to the card
m_itfCard.AttachByReader(Reader, (SCARD_SHARE_MODES) ShareMode, (SCARD_PROTOCOLS) PreferredProtocols);
}
/// <summary>
/// Wraps the PCSC function
/// LONG SCardDisconnect(
/// IN SCARDHANDLE hCard,
/// IN DWORD dwDisposition
/// );
/// </summary>
/// <param name="Disposition"></param>
public override void Disconnect(DISCONNECT Disposition)
{
// Off the connection with the card
m_itfCard.Detach((SCARD_DISPOSITIONS) Disposition);
}
/// <summary>
/// Wraps the PCSC function
/// LONG SCardTransmit(
/// SCARDHANDLE hCard,
/// LPCSCARD_I0_REQUEST pioSendPci,
/// LPCBYTE pbSendBuffer,
/// DWORD cbSendLength,
/// LPSCARD_IO_REQUEST pioRecvPci,
/// LPBYTE pbRecvBuffer,
/// LPDWORD pcbRecvLength
/// );
/// </summary>
/// <param name="ApduCmd">APDUCommand object with the APDU to send to the card</param>
/// <returns>An APDUResponse object with the response from the card</returns>
public override APDUResponse Transmit(APDUCommand ApduCmd)
{
CSCardCmd itfCmd = new CSCardCmdClass();
CByteBuffer itfData = new CByteBufferClass();
int nLe = ApduCmd.Le;
if (ApduCmd.Data == null)
{
itfData.SetSize(0);
}
else
{
int nWrite = 0;
itfData.SetSize(ApduCmd.Data.Length);
itfData.Write(ref ApduCmd.Data[0], ApduCmd.Data.Length, ref nWrite);
}
// Build the APDU command
itfCmd.BuildCmd(ApduCmd.Class, ApduCmd.Ins, ApduCmd.P1, ApduCmd.P2, itfData, ref nLe);
// Send the command
m_itfCard.Transaction(ref itfCmd);
// Analyse the response
int nRead = 0;
byte[] pbResp = new byte[itfCmd.ApduReplyLength];
itfCmd.ApduReply.Read(ref pbResp[0], itfCmd.ApduReplyLength, ref nRead);
return new APDUResponse(pbResp);
}
/// <summary>
/// Wraps the PSCS function
/// LONG SCardBeginTransaction(
/// SCARDHANDLE hCard
// );
/// This function is not supported in the COM implementation
/// </summary>
public override void BeginTransaction()
{
throw new NotImplementedException("BeginTransaction is not supported in the COM implementation");
}
/// <summary>
/// Wraps the PCSC function
/// LONG SCardEndTransaction(
/// SCARDHANDLE hCard,
/// DWORD dwDisposition
/// );
/// This function is not supported in the COM implementation
/// </summary>
/// <param name="Disposition">A value from DISCONNECT enum</param>
public override void EndTransaction(DISCONNECT Disposition)
{
throw new NotImplementedException("EndTransaction is not supported in the COM implementation");
}
/// <summary>
/// Gets the attributes of the card
/// </summary>
/// <param name="AttribId">Identifier for the Attribute to get</param>
/// <returns>Attribute content</returns>
public override byte[] GetAttribute(UInt32 AttribId)
{
throw new NotImplementedException();
}
#endregion
/// <summary>
/// This function must implement a card detection mechanism.
///
/// When card insertion is detected, it must call the method CardInserted()
/// When card removal is detected, it must call the method CardRemoved()
///
/// </summary>
protected override void RunCardDetection(object Reader)
{
throw new Exception("The method or operation is not implemented.");
}
}
}

View File

@ -0,0 +1,9 @@
using System;
namespace GemCard
{
public class CardInsertedEventArgs : EventArgs
{
public CardInsertedEventArgs() { }
}
}

View File

@ -0,0 +1,620 @@
using System;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
namespace GemCard
{
/// <summary>
/// CARD_STATE enumeration, used by the PC/SC function SCardGetStatusChanged
/// </summary>
enum CARD_STATE
{
UNAWARE = 0x00000000,
IGNORE = 0x00000001,
CHANGED = 0x00000002,
UNKNOWN = 0x00000004,
UNAVAILABLE = 0x00000008,
EMPTY = 0x00000010,
PRESENT = 0x00000020,
ATRMATCH = 0x00000040,
EXCLUSIVE = 0x00000080,
INUSE = 0x00000100,
MUTE = 0x00000200,
UNPOWERED = 0x00000400
}
/// <summary>
/// Wraps the SCARD_IO_STRUCTURE
///
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public struct SCard_IO_Request
{
public UInt32 m_dwProtocol;
public UInt32 m_cbPciLength;
}
/// <summary>
/// Wraps theSCARD_READERSTATE structure of PC/SC
/// </summary>
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public struct SCard_ReaderState
{
public string m_szReader;
public IntPtr m_pvUserData;
public UInt32 m_dwCurrentState;
public UInt32 m_dwEventState;
public UInt32 m_cbAtr;
[MarshalAs(UnmanagedType.ByValArray, SizeConst=32)]
public byte[] m_rgbAtr;
}
/// <summary>
/// Implementation of ICard using native (P/Invoke) interoperability for PC/SC
/// </summary>
public class CardNative : CardBase
{
private UInt32 m_hContext = 0;
private UInt32 m_hCard = 0;
private UInt32 m_nProtocol = (uint) PROTOCOL.T0;
private int m_nLastError = 0;
#region PCSC_FUNCTIONS
/// <summary>
/// Native SCardGetStatusChanged from winscard.dll
/// </summary>
/// <param name="hContext"></param>
/// <param name="dwTimeout"></param>
/// <param name="rgReaderStates"></param>
/// <param name="cReaders"></param>
/// <returns></returns>
[DllImport("winscard.dll", SetLastError = true)]
internal static extern int SCardGetStatusChange(UInt32 hContext,
UInt32 dwTimeout,
[In,Out] SCard_ReaderState[] rgReaderStates,
UInt32 cReaders);
/// <summary>
/// Native SCardListReaders function from winscard.dll
/// </summary>
/// <param name="hContext"></param>
/// <param name="mszGroups"></param>
/// <param name="mszReaders"></param>
/// <param name="pcchReaders"></param>
/// <returns></returns>
[DllImport("winscard.dll", SetLastError=true)]
internal static extern int SCardListReaders(UInt32 hContext,
[MarshalAs(UnmanagedType.LPTStr)] string mszGroups,
IntPtr mszReaders,
out UInt32 pcchReaders);
/// <summary>
/// Native SCardEstablishContext function from winscard.dll
/// </summary>
/// <param name="dwScope"></param>
/// <param name="pvReserved1"></param>
/// <param name="pvReserved2"></param>
/// <param name="phContext"></param>
/// <returns></returns>
[DllImport("winscard.dll", SetLastError=true)]
internal static extern int SCardEstablishContext(UInt32 dwScope,
IntPtr pvReserved1,
IntPtr pvReserved2,
IntPtr phContext);
/// <summary>
/// Native SCardReleaseContext function from winscard.dll
/// </summary>
/// <param name="hContext"></param>
/// <returns></returns>
[DllImport("winscard.dll", SetLastError=true)]
internal static extern int SCardReleaseContext(UInt32 hContext);
/// <summary>
/// Native SCardConnect function from winscard.dll
/// </summary>
/// <param name="hContext"></param>
/// <param name="szReader"></param>
/// <param name="dwShareMode"></param>
/// <param name="dwPreferredProtocols"></param>
/// <param name="phCard"></param>
/// <param name="pdwActiveProtocol"></param>
/// <returns></returns>
[DllImport("winscard.dll", SetLastError=true, CharSet=CharSet.Auto)]
internal static extern int SCardConnect(UInt32 hContext,
[MarshalAs(UnmanagedType.LPTStr)] string szReader,
UInt32 dwShareMode,
UInt32 dwPreferredProtocols,
IntPtr phCard,
IntPtr pdwActiveProtocol);
/// <summary>
/// Native SCardDisconnect function from winscard.dll
/// </summary>
/// <param name="hCard"></param>
/// <param name="dwDisposition"></param>
/// <returns></returns>
[DllImport("winscard.dll", SetLastError=true)]
internal static extern int SCardDisconnect(UInt32 hCard,
UInt32 dwDisposition);
/// <summary>
/// Native SCardTransmit function from winscard.dll
/// </summary>
/// <param name="hCard"></param>
/// <param name="pioSendPci"></param>
/// <param name="pbSendBuffer"></param>
/// <param name="cbSendLength"></param>
/// <param name="pioRecvPci"></param>
/// <param name="pbRecvBuffer"></param>
/// <param name="pcbRecvLength"></param>
/// <returns></returns>
[DllImport("winscard.dll", SetLastError=true)]
internal static extern int SCardTransmit(UInt32 hCard,
[In] ref SCard_IO_Request pioSendPci,
byte[] pbSendBuffer,
UInt32 cbSendLength,
IntPtr pioRecvPci,
[Out] byte[] pbRecvBuffer,
out UInt32 pcbRecvLength
);
/// <summary>
/// Native SCardBeginTransaction function of winscard.dll
/// </summary>
/// <param name="hContext"></param>
/// <returns></returns>
[DllImport("winscard.dll", SetLastError = true)]
internal static extern int SCardBeginTransaction(UInt32 hContext);
/// <summary>
/// Native SCardEndTransaction function of winscard.dll
/// </summary>
/// <param name="hContext"></param>
/// <returns></returns>
[DllImport("winscard.dll", SetLastError = true)]
internal static extern int SCardEndTransaction(UInt32 hContext, UInt32 dwDisposition);
[DllImport("winscard.dll", SetLastError = true)]
internal static extern int SCardGetAttrib(UInt32 hCard,
UInt32 dwAttribId,
[Out] byte[] pbAttr,
out UInt32 pcbAttrLen);
#endregion
/// <summary>
/// Default constructor
/// </summary>
public CardNative()
{
}
/// <summary>
/// Object destruction
/// </summary>
~CardNative()
{
Disconnect(DISCONNECT.Unpower);
ReleaseContext();
}
#region ICard Members
/// <summary>
/// Wraps the PCSC function
/// LONG SCardListReaders(SCARDCONTEXT hContext,
/// LPCTSTR mszGroups,
/// LPTSTR mszReaders,
/// LPDWORD pcchReaders
/// );
/// </summary>
/// <returns>A string array of the readers</returns>
public override string[] ListReaders()
{
EstablishContext(SCOPE.User);
string[] sListReaders = null;
UInt32 pchReaders = 0;
IntPtr szListReaders = IntPtr.Zero;
m_nLastError = SCardListReaders(m_hContext, null, szListReaders, out pchReaders);
if (m_nLastError == 0)
{
szListReaders = Marshal.AllocHGlobal((int) pchReaders);
m_nLastError = SCardListReaders(m_hContext, null, szListReaders, out pchReaders);
if (m_nLastError == 0)
{
char[] caReadersData = new char[pchReaders];
int nbReaders = 0;
for (int nI = 0; nI < pchReaders; nI++)
{
caReadersData[nI] = (char) Marshal.ReadByte(szListReaders, nI);
if (caReadersData[nI] == 0)
nbReaders++;
}
// Remove last 0
--nbReaders;
if (nbReaders != 0)
{
sListReaders = new string[nbReaders];
char[] caReader = new char[pchReaders];
int nIdx = 0;
int nIdy = 0;
int nIdz = 0;
// Get the nJ string from the multi-string
while(nIdx < pchReaders - 1)
{
caReader[nIdy] = caReadersData[nIdx];
if (caReader[nIdy] == 0)
{
sListReaders[nIdz] = new string(caReader, 0, nIdy);
++nIdz;
nIdy = 0;
caReader = new char[pchReaders];
}
else
++nIdy;
++nIdx;
}
}
}
Marshal.FreeHGlobal(szListReaders);
}
ReleaseContext();
return sListReaders;
}
/// <summary>
/// Wraps the PCSC function
/// LONG SCardEstablishContext(
/// IN DWORD dwScope,
/// IN LPCVOID pvReserved1,
/// IN LPCVOID pvReserved2,
/// OUT LPSCARDCONTEXT phContext
/// );
/// </summary>
/// <param name="Scope"></param>
public void EstablishContext(SCOPE Scope)
{
IntPtr hContext = Marshal.AllocHGlobal(Marshal.SizeOf(m_hContext));
m_nLastError = SCardEstablishContext((uint) Scope, IntPtr.Zero, IntPtr.Zero, hContext);
if (m_nLastError != 0)
{
string msg = "SCardEstablishContext error: " + m_nLastError;
Marshal.FreeHGlobal(hContext);
throw new Exception(msg);
}
m_hContext = (uint) Marshal.ReadInt32(hContext);
Marshal.FreeHGlobal(hContext);
}
/// <summary>
/// Wraps the PCSC function
/// LONG SCardReleaseContext(
/// IN SCARDCONTEXT hContext
/// );
/// </summary>
public void ReleaseContext()
{
if (m_hContext != 0)
{
m_nLastError = SCardReleaseContext(m_hContext);
if (m_nLastError != 0)
{
string msg = "SCardReleaseContext error: " + m_nLastError;
throw new Exception(msg);
}
m_hContext = 0;
}
}
/// <summary>
/// Wraps the PCSC function
/// LONG SCardConnect(
/// IN SCARDCONTEXT hContext,
/// IN LPCTSTR szReader,
/// IN DWORD dwShareMode,
/// IN DWORD dwPreferredProtocols,
/// OUT LPSCARDHANDLE phCard,
/// OUT LPDWORD pdwActiveProtocol
/// );
/// </summary>
/// <param name="Reader"></param>
/// <param name="ShareMode"></param>
/// <param name="PreferredProtocols"></param>
public override void Connect(string Reader, SHARE ShareMode, PROTOCOL PreferredProtocols)
{
EstablishContext(SCOPE.User);
IntPtr hCard = Marshal.AllocHGlobal(Marshal.SizeOf(m_hCard));
IntPtr pProtocol = Marshal.AllocHGlobal(Marshal.SizeOf(m_nProtocol));
m_nLastError = SCardConnect(m_hContext,
Reader,
(uint) ShareMode,
(uint) PreferredProtocols,
hCard,
pProtocol);
if (m_nLastError != 0)
{
string msg = "SCardConnect error: " + m_nLastError;
Marshal.FreeHGlobal(hCard);
Marshal.FreeHGlobal(pProtocol);
throw new Exception(msg);
}
m_hCard = (uint) Marshal.ReadInt32(hCard);
m_nProtocol = (uint) Marshal.ReadInt32(pProtocol);
Marshal.FreeHGlobal(hCard);
Marshal.FreeHGlobal(pProtocol);
}
/// <summary>
/// Wraps the PCSC function
/// LONG SCardDisconnect(
/// IN SCARDHANDLE hCard,
/// IN DWORD dwDisposition
/// );
/// </summary>
/// <param name="Disposition"></param>
public override void Disconnect(DISCONNECT Disposition)
{
if (m_hCard != 0)
{
m_nLastError = SCardDisconnect(m_hCard, (uint) Disposition);
m_hCard = 0;
if (m_nLastError != 0)
{
string msg = "SCardDisconnect error: " + m_nLastError;
throw new Exception(msg);
}
ReleaseContext();
}
}
/// <summary>
/// Wraps the PCSC function
/// LONG SCardTransmit(
/// SCARDHANDLE hCard,
/// LPCSCARD_I0_REQUEST pioSendPci,
/// LPCBYTE pbSendBuffer,
/// DWORD cbSendLength,
/// LPSCARD_IO_REQUEST pioRecvPci,
/// LPBYTE pbRecvBuffer,
/// LPDWORD pcbRecvLength
/// );
/// </summary>
/// <param name="ApduCmd">APDUCommand object with the APDU to send to the card</param>
/// <returns>An APDUResponse object with the response from the card</returns>
public override APDUResponse Transmit(APDUCommand ApduCmd)
{
uint RecvLength = (uint) (ApduCmd.Le + APDUResponse.SW_LENGTH);
byte[] ApduBuffer = null;
byte[] ApduResponse = new byte[ApduCmd.Le + APDUResponse.SW_LENGTH];
SCard_IO_Request ioRequest = new SCard_IO_Request();
ioRequest.m_dwProtocol = m_nProtocol;
ioRequest.m_cbPciLength = 8;
// Build the command APDU
if (ApduCmd.Data == null)
{
ApduBuffer = new byte[APDUCommand.APDU_MIN_LENGTH + ((ApduCmd.Le != 0) ? 1 : 0)];
if (ApduCmd.Le != 0)
ApduBuffer[4] = (byte) ApduCmd.Le;
}
else
{
ApduBuffer = new byte[APDUCommand.APDU_MIN_LENGTH + 1 + ApduCmd.Data.Length];
for (int nI = 0; nI < ApduCmd.Data.Length; nI++)
ApduBuffer[APDUCommand.APDU_MIN_LENGTH + 1 + nI] = ApduCmd.Data[nI];
ApduBuffer[APDUCommand.APDU_MIN_LENGTH] = (byte) ApduCmd.Data.Length;
}
ApduBuffer[0] = ApduCmd.Class;
ApduBuffer[1] = ApduCmd.Ins;
ApduBuffer[2] = ApduCmd.P1;
ApduBuffer[3] = ApduCmd.P2;
m_nLastError = SCardTransmit(m_hCard, ref ioRequest, ApduBuffer, (uint) ApduBuffer.Length, IntPtr.Zero, ApduResponse, out RecvLength);
if (m_nLastError != 0)
{
string msg = "SCardTransmit error: " + m_nLastError;
throw new Exception(msg);
}
byte[] ApduData = new byte[RecvLength];
for (int nI = 0; nI < RecvLength; nI++)
ApduData[nI] = ApduResponse[nI];
return new APDUResponse(ApduData);
}
/// <summary>
/// Wraps the PSCS function
/// LONG SCardBeginTransaction(
/// SCARDHANDLE hCard
// );
/// </summary>
public override void BeginTransaction()
{
if (m_hCard != 0)
{
m_nLastError = SCardBeginTransaction(m_hCard);
if (m_nLastError != 0)
{
string msg = "SCardBeginTransaction error: " + m_nLastError;
throw new Exception(msg);
}
}
}
/// <summary>
/// Wraps the PCSC function
/// LONG SCardEndTransaction(
/// SCARDHANDLE hCard,
/// DWORD dwDisposition
/// );
/// </summary>
/// <param name="Disposition">A value from DISCONNECT enum</param>
public override void EndTransaction(DISCONNECT Disposition)
{
if (m_hCard != 0)
{
m_nLastError = SCardEndTransaction(m_hCard, (UInt32)Disposition);
if (m_nLastError != 0)
{
string msg = "SCardEndTransaction error: " + m_nLastError;
throw new Exception(msg);
}
}
}
/// <summary>
/// Gets the attributes of the card
/// </summary>
/// <param name="AttribId">Identifier for the Attribute to get</param>
/// <returns>Attribute content</returns>
public override byte[] GetAttribute(UInt32 AttribId)
{
byte[] attr = null;
UInt32 attrLen = 0;
m_nLastError = SCardGetAttrib(m_hCard, AttribId, attr, out attrLen);
if (m_nLastError == 0)
{
if (attrLen != 0)
{
attr = new byte[attrLen];
m_nLastError = SCardGetAttrib(m_hCard, AttribId, attr, out attrLen);
if (m_nLastError != 0)
{
string msg = "SCardGetAttr error: " + m_nLastError;
throw new Exception(msg);
}
}
}
else
{
string msg = "SCardGetAttr error: " + m_nLastError;
throw new Exception(msg);
}
return attr;
}
#endregion
/// <summary>
/// This function must implement a card detection mechanism.
///
/// When card insertion is detected, it must call the method CardInserted()
/// When card removal is detected, it must call the method CardRemoved()
///
/// </summary>
protected override void RunCardDetection(object Reader)
{
bool bFirstLoop = true;
UInt32 hContext = 0; // Local context
IntPtr phContext;
phContext = Marshal.AllocHGlobal(Marshal.SizeOf(hContext));
if (SCardEstablishContext((uint) SCOPE.User, IntPtr.Zero, IntPtr.Zero, phContext) == 0)
{
hContext = (uint)Marshal.ReadInt32(phContext);
Marshal.FreeHGlobal(phContext);
UInt32 nbReaders = 1;
SCard_ReaderState[] readerState = new SCard_ReaderState[nbReaders];
readerState[0].m_dwCurrentState = (UInt32) CARD_STATE.UNAWARE;
readerState[0].m_szReader = (string)Reader;
UInt32 eventState;
UInt32 currentState = readerState[0].m_dwCurrentState;
// Card detection loop
do
{
if (SCardGetStatusChange(hContext, WAIT_TIME
, readerState, nbReaders) == 0)
{
eventState = readerState[0].m_dwEventState;
currentState = readerState[0].m_dwCurrentState;
// Check state
if (((eventState & (uint) CARD_STATE.CHANGED) == (uint) CARD_STATE.CHANGED) && !bFirstLoop)
{
// State has changed
if ((eventState & (uint) CARD_STATE.EMPTY) == (uint) CARD_STATE.EMPTY)
{
// There is no card, card has been removed -> Fire CardRemoved event
CardRemoved(this, new CardRemovedEventArgs());
}
if (((eventState & (uint)CARD_STATE.PRESENT) == (uint)CARD_STATE.PRESENT) &&
((eventState & (uint) CARD_STATE.PRESENT) != (currentState & (uint) CARD_STATE.PRESENT)))
{
// There is a card in the reader -> Fire CardInserted event
CardInserted(this, new CardInsertedEventArgs());
}
if ((eventState & (uint) CARD_STATE.ATRMATCH) == (uint) CARD_STATE.ATRMATCH)
{
// There is a card in the reader and it matches the ATR we were expecting-> Fire CardInserted event
CardInserted(this, new CardInsertedEventArgs());
}
}
// The current stateis now the event state
readerState[0].m_dwCurrentState = eventState;
bFirstLoop = false;
}
Thread.Sleep(100);
if (m_bRunCardDetection == false)
break;
}
while (true); // Exit on request
}
else
{
Marshal.FreeHGlobal(phContext);
throw new Exception("PC/SC error");
}
SCardReleaseContext(hContext);
}
}
}

View File

@ -0,0 +1,9 @@
using System;
namespace GemCard
{
public class CardRemovedEventArgs : EventArgs
{
public CardRemovedEventArgs() { }
}
}

View File

@ -0,0 +1,179 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup>
<ProjectType>Local</ProjectType>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{8B10D15A-39DE-4B56-8DD1-710C1EB3A697}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ApplicationIcon>
</ApplicationIcon>
<AssemblyKeyContainerName>
</AssemblyKeyContainerName>
<AssemblyName>GemCard</AssemblyName>
<AssemblyOriginatorKeyFile>
</AssemblyOriginatorKeyFile>
<DefaultClientScript>JScript</DefaultClientScript>
<DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
<DefaultTargetSchema>IE50</DefaultTargetSchema>
<DelaySign>false</DelaySign>
<OutputType>Library</OutputType>
<RootNamespace>GemCard</RootNamespace>
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
<StartupObject>
</StartupObject>
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>3.5</OldToolsVersion>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<OutputPath>bin\Debug\</OutputPath>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<BaseAddress>285212672</BaseAddress>
<CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DocumentationFile>
</DocumentationFile>
<DebugSymbols>true</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<NoStdLib>false</NoStdLib>
<NoWarn>
</NoWarn>
<Optimize>false</Optimize>
<RegisterForComInterop>false</RegisterForComInterop>
<RemoveIntegerChecks>false</RemoveIntegerChecks>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<OutputPath>bin\Release\</OutputPath>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<BaseAddress>285212672</BaseAddress>
<CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>TRACE</DefineConstants>
<DocumentationFile>
</DocumentationFile>
<DebugSymbols>false</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<NoStdLib>false</NoStdLib>
<NoWarn>
</NoWarn>
<Optimize>true</Optimize>
<RegisterForComInterop>false</RegisterForComInterop>
<RemoveIntegerChecks>false</RemoveIntegerChecks>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<BaseAddress>285212672</BaseAddress>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<FileAlignment>4096</FileAlignment>
<PlatformTarget>x86</PlatformTarget>
<CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
<CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
<CodeAnalysisFailOnMissingRules>false</CodeAnalysisFailOnMissingRules>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<BaseAddress>285212672</BaseAddress>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Optimize>true</Optimize>
<FileAlignment>4096</FileAlignment>
<PlatformTarget>x86</PlatformTarget>
<CodeAnalysisIgnoreBuiltInRuleSets>false</CodeAnalysisIgnoreBuiltInRuleSets>
<CodeAnalysisIgnoreBuiltInRules>false</CodeAnalysisIgnoreBuiltInRules>
</PropertyGroup>
<ItemGroup>
<Reference Include="System">
<Name>System</Name>
</Reference>
<Reference Include="System.Data">
<Name>System.Data</Name>
</Reference>
<Reference Include="System.Xml">
<Name>System.XML</Name>
</Reference>
<COMReference Include="stdole">
<Guid>{00020430-0000-0000-C000-000000000046}</Guid>
<VersionMajor>2</VersionMajor>
<VersionMinor>0</VersionMinor>
<Lcid>0</Lcid>
<WrapperTool>primary</WrapperTool>
<Isolated>False</Isolated>
</COMReference>
</ItemGroup>
<ItemGroup>
<Compile Include="APDUCommand.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="APDUParam.cs" />
<Compile Include="APDUResponse.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="AssemblyInfo.cs" />
<Compile Include="CardBase.cs" />
<Compile Include="CardInsertedEventArgs.cs" />
<Compile Include="CardNative.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="CardRemovedEventArgs.cs" />
<Compile Include="ICard.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="SmartCardException.cs">
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
<Visible>False</Visible>
<ProductName>Windows Installer 3.1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PreBuildEvent>
</PreBuildEvent>
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,149 @@
using System;
namespace GemCard
{
/// <summary>
/// This interface gives access to the basic card functions. It must be implemented by a class.
/// </summary>
public interface ICard
{
/// <summary>
/// Wraps the PCSC funciton
/// LONG SCardListReaders(SCARDCONTEXT hContext,
/// LPCTSTR mszGroups,
/// LPTSTR mszReaders,
/// LPDWORD pcchReaders
/// );
/// </summary>
/// <returns>A string array of the readers</returns>
string[] ListReaders();
/// <summary>
/// Wraps the PCSC function
/// LONG SCardConnect(
/// IN SCARDCONTEXT hContext,
/// IN LPCTSTR szReader,
/// IN DWORD dwShareMode,
/// IN DWORD dwPreferredProtocols,
/// OUT LPSCARDHANDLE phCard,
/// OUT LPDWORD pdwActiveProtocol
/// );
/// </summary>
/// <param name="Reader"></param>
/// <param name="ShareMode"></param>
/// <param name="PreferredProtocols"></param>
void Connect(string Reader, SHARE ShareMode, PROTOCOL PreferredProtocols);
/// <summary>
/// Wraps the PCSC function
/// LONG SCardDisconnect(
/// IN SCARDHANDLE hCard,
/// IN DWORD dwDisposition
/// );
/// </summary>
/// <param name="Disposition"></param>
void Disconnect(DISCONNECT Disposition);
/// <summary>
/// Wraps the PCSC function
/// LONG SCardTransmit(
/// SCARDHANDLE hCard,
/// LPCSCARD_I0_REQUEST pioSendPci,
/// LPCBYTE pbSendBuffer,
/// DWORD cbSendLength,
/// LPSCARD_IO_REQUEST pioRecvPci,
/// LPBYTE pbRecvBuffer,
/// LPDWORD pcbRecvLength
/// );
/// </summary>
/// <param name="ApduCmd">APDUCommand object with the APDU to send to the card</param>
/// <returns>An APDUResponse object with the response from the card</returns>
APDUResponse Transmit(APDUCommand ApduCmd);
/// <summary>
/// Wraps the PSCS function
/// LONG SCardBeginTransaction(
/// SCARDHANDLE hCard
// );
/// </summary>
void BeginTransaction();
/// <summary>
/// Wraps the PCSC function
/// LONG SCardEndTransaction(
/// SCARDHANDLE hCard,
/// DWORD dwDisposition
/// );
/// </summary>
void EndTransaction(DISCONNECT Disposition);
/// <summary>
/// Gets the attributes of the card
/// </summary>
/// <param name="AttribId">Identifier for the Attribute to get</param>
/// <returns>Attribute content</returns>
byte[] GetAttribute(UInt32 AttribId);
}
/// <summary>
/// SCOPE context
/// </summary>
public enum SCOPE
{
/// <summary>
/// The context is a user context, and any database operations are performed within the
/// domain of the user.
/// </summary>
User,
/// <summary>
/// The context is that of the current terminal, and any database operations are performed
/// within the domain of that terminal. (The calling application must have appropriate
/// access permissions for any database actions.)
/// </summary>
Terminal,
/// <summary>
/// The context is the system context, and any database operations are performed within the
/// domain of the system. (The calling application must have appropriate access
/// permissions for any database actions.)
/// </summary>
System
}
/// <summary>
/// SHARE mode enumeration
/// </summary>
public enum SHARE
{
Exclusive = 1, /// This app. is not willing to share this card with other applications.
Shared, /// This app. is willing to share this card with other applications.
Direct, /// This app. demands direct control of the reader, so it is not available to other applications.
}
/// <summary>
/// PROTOCOL enumeration
/// </summary>
public enum PROTOCOL
{
Undefined = 0x00000000, /// There is no active protocol.
T0 = 0x00000001, /// T=0 is the active protocol.
T1 = 0x00000002, /// T=1 is the active protocol.
T0orT1 = T0 | T1, /// T=1 or T=0 can be the active protocol
Raw = 0x00010000, /// Raw is the active protocol.
Default = unchecked ((int) 0x80000000), /// Use implicit PTS.
}
/// <summary>
/// DISCONNECT action enumeration
/// </summary>
public enum DISCONNECT
{
Leave, /// Don't do anything special on close
Reset, /// Reset the card on close
Unpower, /// Power down the card on close
Eject, /// Eject(!) the card on close
}
}

View File

@ -0,0 +1,40 @@
using System;
namespace GemCard
{
/// <summary>
/// Smart card exceptions
/// </summary>
public class SmartCardException : Exception
{
public SmartCardException() : base("Smart card exception")
{
}
public SmartCardException(string Message) : base(Message)
{
}
}
public class ApduCommandException : Exception
{
public const string
NotValidDocument = "The file is not a valid APDU command document",
NoSuchCommand = "No such APDU command in the document",
ParamLeFormat = "Le parameter format is not correct",
ParamP3Format = "P3 parameter format is not correct",
NoSuchSequence = "No such APDU sequence in the document",
MissingApduOrCommand = "An Apdu or a Sequence is missing in this Sequence";
public ApduCommandException() : base("APDU command exception")
{
}
public ApduCommandException(string Message) : base(Message)
{
}
}
}

View File

@ -0,0 +1,87 @@
using System;
using System.Drawing;
/* Copyright (c) 2008-2014 DI Zimmermann Stephan (stefan.zimmermann@tele2.at)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
namespace GraphLib
{
public class BackBuffer
{
private Graphics graphics;
private Bitmap memoryBitmap;
private int width;
private int height;
public BackBuffer()
{
width = 0;
height = 0;
}
public bool Init(Graphics g, int width, int height)
{
if (memoryBitmap != null)
{
memoryBitmap.Dispose();
memoryBitmap = null;
}
if (graphics != null)
{
graphics.Dispose();
graphics = null;
}
if (width == 0 || height == 0)
return false;
if ((width != this.width) || (height != this.height) || graphics == null)
{
this.width = width;
this.height = height;
memoryBitmap = new Bitmap(width, height);
graphics = Graphics.FromImage(memoryBitmap);
}
return true;
}
public void Render(Graphics g)
{
if (memoryBitmap != null)
{
g.DrawImage(memoryBitmap,
new Rectangle(0, 0, width, height),
0, 0, width, height,
GraphicsUnit.Pixel);
}
}
public bool CanDoubleBuffer() { return graphics != null; }
public Graphics Graphics { get { return graphics; } }
}
}

View File

@ -0,0 +1,254 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.ComponentModel;
using System.Drawing;
/* Copyright (c) 2008-2014 DI Zimmermann Stephan (stefan.zimmermann@tele2.at)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
namespace GraphLib
{
public class DataSource
{
public delegate String OnDrawXAxisLabelEvent(DataSource src, int idx);
public delegate String OnDrawYAxisLabelEvent(DataSource src, float value);
public OnDrawXAxisLabelEvent OnRenderXAxisLabel = null;
public OnDrawYAxisLabelEvent OnRenderYAxisLabel = null;
private PointF[] samples = null;
private int length = 0;
private String name = String.Empty;
private int downSample = 1;
private Color color = Color.Black;
public float VisibleDataRange_X = 0;
public float DY = 0;
public float YD0 = -200;
public float YD1 = 200;
public float Cur_YD0 = -200;
public float Cur_YD1 = 200;
public float grid_distance_y = 200; // grid distance in units ( draw a horizontal line every 200 units )
public float off_Y = 0;
public float grid_off_y = 0;
public bool yFlip = true;
public bool Active = true;
public float XAutoScaleOffset = 100;
public float CurGraphHeight = 1.0f;
public float CurGraphWidth = 1.0f;
private bool autoScaleY = false;
private bool autoScaleX = false;
public bool AutoScaleY
{
get { return autoScaleY; }
set { autoScaleY = value; }
}
public bool AutoScaleX
{
get { return autoScaleX; }
set { autoScaleX = value; }
}
public PointF[] Samples
{
get { return samples; }
set
{
samples = value;
length = samples.Length;
}
}
public float XMin
{
get
{
float x_min = float.MaxValue;
if (samples != null && samples.Length > 0)
{
foreach (PointF p in samples) if (p.X < x_min) x_min=p.X;
}
return x_min;
}
}
public float XMax
{
get
{
float x_max = float.MinValue;
if (samples != null && samples.Length > 0)
{
foreach (PointF p in samples) if (p.X > x_max) x_max = p.X;
}
return x_max;
}
}
public float YMin
{
get
{
float y_min = float.MaxValue;
if (samples != null && samples.Length > 0)
{
foreach (PointF p in samples) if (p.Y < y_min) y_min = p.Y;
}
return y_min;
}
}
public float YMax
{
get
{
float y_max = float.MinValue;
if (samples.Length > 0)
{
foreach (PointF p in samples) if (p.Y > y_max) y_max = p.Y;
}
return y_max;
}
}
public void SetDisplayRangeY(float y_start, float y_end)
{
YD0 = y_start;
YD1 = y_end;
}
public void SetGridDistanceY(float grid_dist_y_units)
{
grid_distance_y = grid_dist_y_units;
}
public void SetGridOriginY(float off_y)
{
grid_off_y = off_y;
}
/// <summary>
/// Load Samples from a file. Returns loaded points count.
/// </summary>
/// <param name="pathName">File pathname</param>
/// <returns>Loaded points count</returns>
public int LoadSamples(string pathName, out float yMin, out float yMax)
{
yMin = float.MaxValue;
yMax = float.MinValue;
try
{
Int64 size = new FileInfo(pathName).Length;
if ((size % 8) != 0) return 0;
int samplesCount = (int)(size / 8L) - 1;
if (samplesCount <= 0) return 0;
PointF[] newSamples = new PointF[samplesCount];
using (BinaryReader reader = new BinaryReader(File.Open(pathName, FileMode.Open)))
{
for (int i = 0; i < samplesCount; i++)
{
newSamples[i].X = reader.ReadSingle();
newSamples[i].Y = reader.ReadSingle();
}
yMin = reader.ReadSingle();
yMax = reader.ReadSingle();
}
Samples = newSamples;
return samplesCount;
}
catch (Exception exc)
{
return 0;
}
}
[Category("Properties")] // Take this out, and you will soon have problems with serialization;
[DefaultValue(typeof(string), "")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public String Name
{
get { return name; }
set { name = value; }
}
[Category("Properties")] // Take this out, and you will soon have problems with serialization;
[DefaultValue(typeof(Color), "")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public Color GraphColor
{
get { return color; }
set { color = value; }
}
[Category("Properties")] // Take this out, and you will soon have problems with serialization;
[DefaultValue(typeof(int), "0")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public int Length
{
get { return length; }
set
{
length = value;
if (length != 0)
{
samples = new PointF[length];
}
else
{
// length is 0
if (samples != null)
{
samples = null;
}
}
}
}
[Category("Properties")] // Take this out, and you will soon have problems with serialization;
[DefaultValue(typeof(int), "1")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public int Downsampling
{
get { return downSample; }
set { downSample = value; }
}
}
}

View File

@ -0,0 +1,115 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="12.0">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{0C0A1F4D-1363-4544-A7C5-196C76D26CCA}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ClassLibrary1</RootNamespace>
<AssemblyName>GraphLib</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>2.0</OldToolsVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<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|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Design" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="PlotterGraphPaneEx.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="PlotterGraphPaneEx.Designer.cs">
<DependentUpon>PlotterGraphPaneEx.cs</DependentUpon>
</Compile>
<Compile Include="PlotterDisplayEx.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="PlotterDisplayEx.designer.cs">
<DependentUpon>PlotterDisplayEx.cs</DependentUpon>
</Compile>
<Compile Include="BackBuffer.cs" />
<Compile Include="PlotterGraphSelectCurvesForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="PlotterGraphSelectCurvesForm.Designer.cs">
<DependentUpon>PlotterGraphSelectCurvesForm.cs</DependentUpon>
</Compile>
<Compile Include="DataSource.cs" />
<Compile Include="PrintPreviewForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="PrintPreviewForm.Designer.cs">
<DependentUpon>PrintPreviewForm.cs</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Utils.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="PlotterGraphPaneEx.resx">
<DependentUpon>PlotterGraphPaneEx.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="PlotterDisplayEx.resx">
<DependentUpon>PlotterDisplayEx.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="PlotterGraphSelectCurvesForm.resx">
<SubType>Designer</SubType>
<DependentUpon>PlotterGraphSelectCurvesForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="PrintPreviewForm.resx">
<SubType>Designer</SubType>
<DependentUpon>PrintPreviewForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<SubType>Designer</SubType>
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\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>
-->
<PropertyGroup>
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
</Project>

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