Compare commits

..
189 changed files with 230073 additions and 719 deletions
+2 -2
View File
@@ -30,8 +30,8 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="log4net">
<HintPath>..\packages\log4net.2.0.2\lib\net40-full\log4net.dll</HintPath>
<Reference Include="log4net, Version=2.0.15.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\packages\log4net.2.0.15\lib\net45\log4net.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
+43 -1
View File
@@ -105,6 +105,14 @@ namespace Common
///
[Description("pulse/kWh")] ppkWh, /// * 1 pulse/kWh
[Description("kWh/pulse")] kWhpp, /// 1 kWh/pulse
///
[Description("A")] A, /// *1 A
[Description("mA")] mA, /// 1 mA = 0.001 A
///
[Description("V")] V, /// *1 V
[Description("mV")] mV, /// 1 mV = 0.001 V
Count
}
@@ -135,6 +143,8 @@ namespace Common
[Description("Boolean")] Boolean,
[Description("Datum und Uhrzeit")] DateTime,
[Description("Aufgezählt")] Enumerated,
[Description("Strom")] Current,
[Description("Spannung")] Voltage,
#elif LANG_PL
[Description("Objętość")] Volume,
[Description("Przepływ")] Flow,
@@ -158,6 +168,8 @@ namespace Common
[Description("Boolean")] Boolean,
[Description("Data i czas")] DateTime,
[Description("Wyliczone")] Enumerated,
[Description("Prąd")] Current,
[Description("Napięcie")] Voltage,
#elif LANG_CS
[Description("Objem")] Volume,
[Description("Průtok")] Flow,
@@ -181,6 +193,8 @@ namespace Common
[Description("Boolean")] Boolean,
[Description("Datum a čas")] DateTime,
[Description("Vyjmenované")] Enumerated,
[Description("Proud")] Current,
[Description("Napětí")] Voltage,
#elif LANG_IT
[Description("Volume")] Volume,
[Description("Flusso")] Flow,
@@ -204,6 +218,8 @@ namespace Common
[Description("Boolean")] Boolean,
[Description("Data e ora")] DateTime,
[Description("Enumerato")] Enumerated,
[Description("Corrente")] Current,
[Description("Voltaggio")] Voltage,
#else
[Description("Volume")] Volume,
[Description("Flow")] Flow,
@@ -227,6 +243,8 @@ namespace Common
[Description("Boolean")] Boolean,
[Description("Date and time")] DateTime,
[Description("Enumerated")] Enumerated,
[Description("Current")] Current,
[Description("Voltage")] Voltage,
#endif
Count,
}
@@ -242,7 +260,8 @@ namespace Common
{
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.uSpcm || unit == Unit.ppl || unit == Unit.ppkWh;
unit == Unit.J || unit == Unit.uSpcm || unit == Unit.ppl || unit == Unit.ppkWh || unit == Unit.A ||
unit == Unit.V;
}
public static bool IsQuantity(Unit unit, Quantity quantity)
@@ -351,6 +370,14 @@ namespace Common
case Unit.ppkWh:
case Unit.kWhpp:
return Quantity.PulsePerKWh;
case Unit.A:
case Unit.mA:
return Quantity.Current;
case Unit.V:
case Unit.mV:
return Quantity.Voltage;
default:
return Quantity.Number;
@@ -372,6 +399,8 @@ namespace Common
public static bool IsPulsePerLtr(Unit unit) { return IsQuantity(unit, Quantity.PulsePerLtr); }
public static bool IsPulsePerKWh(Unit unit) { return IsQuantity(unit, Quantity.PulsePerKWh); }
public static bool IsConductivity(Unit unit) { return IsQuantity(unit, Quantity.Conductivity); }
public static bool IsCurrent(Unit unit) { return IsQuantity(unit, Quantity.Current); }
public static bool IsVoltage(Unit unit) { return IsQuantity(unit, Quantity.Voltage); }
@@ -455,6 +484,13 @@ namespace Common
case Unit.dm3pp:
case Unit.lpdeg:
case Unit.dm3pdeg: return (v <= float.Epsilon) ? 0 : 1/v;
/// Current: internal representation in A
case Unit.mA: return 1000 * v; /// 1000 mA = 1 A
/// Voltage: internal representation in V
case Unit.mV: return 1000 * v; /// 1000 mV = 1 V
default: return v; /// Do not convert
}
@@ -534,6 +570,12 @@ namespace Common
/// Electrical conductivity
case Unit.mSpm: return 10 * v;
/// Current: internal representation in A
case Unit.mA: return 0.001 * v; /// 1 mA = 0.001 A
/// Voltage: internal representation in V
case Unit.mV: return 0.001 * v; /// 1 mV = 0.001 V
/// Invert
case Unit.kWhpp:
+4
View File
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="log4net" version="2.0.15" targetFramework="net472" />
</packages>
+1 -1
View File
@@ -43,7 +43,7 @@
<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>
<HintPath>..\packages\log4net.2.0.15\lib\net45\log4net.dll</HintPath>
</Reference>
<Reference Include="MySql.Data">
<HintPath>..\packages\MySql.Data.6.6.5\lib\net40\MySql.Data.dll</HintPath>
+6
View File
@@ -22,6 +22,9 @@ namespace Config.Entities
public virtual string PressMtrUp { get; set; }
public virtual string PressMtrDown { get; set; }
public virtual string PressMtrDelta { get; set; }
public virtual string ElectricMtrUp { get; set; }
public virtual string ElectricMtrDown { get; set; }
public virtual string ElectricMtrDelta { get; set; }
public virtual string StopBFValve { get; set; }
/// Valves
@@ -59,6 +62,9 @@ namespace Config.Entities
result.PressMtrUp = PressMtrUp;
result.PressMtrDown = PressMtrDown;
result.PressMtrDelta = PressMtrDelta;
result.ElectricMtrUp = ElectricMtrUp;
result.ElectricMtrDown = ElectricMtrDown;
result.ElectricMtrDelta = ElectricMtrDelta;
result.StopBFValve = StopBFValve;
result.ValvesOpen = ValvesOpen;
result.ValvesClose = ValvesClose;
+2
View File
@@ -78,6 +78,7 @@ namespace Config.Entities
public virtual Unit TempUnit { get; set; } /// Not mapped to database, used in ProcedureDlg / Metrology1Tab
public virtual Unit PressUnit { get; set; } /// Not mapped to database, used in ProcedureDlg / Metrology1Tab
public virtual Unit LengthUnit { get; set; } /// Not mapped to database, used in ProcedureDlg / Metrology1Tab
public virtual Unit ElectricUnit { get; set; } /// Not mapped to database, used in ProcedureDlg / Metrology1Tab
/// Wrappers
public virtual double QfromM3ph()
@@ -209,6 +210,7 @@ namespace Config.Entities
result.TempUnit = TempUnit;
result.PressUnit = PressUnit;
result.LengthUnit = LengthUnit;
result.ElectricUnit = ElectricUnit;
foreach (var prms in MoreParams) { result.MoreParams.Add(prms.Clone()); }
return result;
@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
</configuration>
@@ -1 +0,0 @@
22fa51b09dbd9afa4c5d73fd5d4267426f09bc510527f701d437b89d74765cc0
@@ -1,18 +0,0 @@
C:\VSProjects\proj9\tbf\DataStreamInterfaceTest\bin\Debug\Doc\Software interface for datastream water meters.docx
C:\VSProjects\proj9\tbf\DataStreamInterfaceTest\bin\Debug\DataStreamInterfaceTest.exe.config
C:\VSProjects\proj9\tbf\DataStreamInterfaceTest\bin\Debug\DataStreamInterfaceTest.exe
C:\VSProjects\proj9\tbf\DataStreamInterfaceTest\bin\Debug\DataStreamInterfaceTest.pdb
C:\VSProjects\proj9\tbf\DataStreamInterfaceTest\bin\Debug\DataStreamInterface.dll
C:\VSProjects\proj9\tbf\DataStreamInterfaceTest\bin\Debug\DataStreamInterface.pdb
C:\VSProjects\proj9\tbf\DataStreamInterfaceTest\obj\Debug\DataStreamInterfaceTest.csproj.AssemblyReference.cache
C:\VSProjects\proj9\tbf\DataStreamInterfaceTest\obj\Debug\DataStreamInterfaceTest.DemoMainWnd.resources
C:\VSProjects\proj9\tbf\DataStreamInterfaceTest\obj\Debug\DataStreamInterfaceTest.GetDblValueDlg.resources
C:\VSProjects\proj9\tbf\DataStreamInterfaceTest\obj\Debug\DataStreamInterfaceTest.GetFrameBoundariesDlg.resources
C:\VSProjects\proj9\tbf\DataStreamInterfaceTest\obj\Debug\DataStreamInterfaceTest.GetIntegerNumberDlg.resources
C:\VSProjects\proj9\tbf\DataStreamInterfaceTest\obj\Debug\DataStreamInterfaceTest.GetStateDlg.resources
C:\VSProjects\proj9\tbf\DataStreamInterfaceTest\obj\Debug\DataStreamInterfaceTest.Properties.Resources.resources
C:\VSProjects\proj9\tbf\DataStreamInterfaceTest\obj\Debug\DataStreamInterfaceTest.csproj.GenerateResource.cache
C:\VSProjects\proj9\tbf\DataStreamInterfaceTest\obj\Debug\DataStreamInterfaceTest.csproj.CoreCompileInputs.cache
C:\VSProjects\proj9\tbf\DataStreamInterfaceTest\obj\Debug\DataStre.F4216CC0.Up2Date
C:\VSProjects\proj9\tbf\DataStreamInterfaceTest\obj\Debug\DataStreamInterfaceTest.exe
C:\VSProjects\proj9\tbf\DataStreamInterfaceTest\obj\Debug\DataStreamInterfaceTest.pdb
+2 -3
View File
@@ -40,9 +40,8 @@
<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 Include="log4net, Version=2.0.15.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\packages\log4net.2.0.15\lib\net45\log4net.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
+4
View File
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="log4net" version="2.0.15" targetFramework="net472" />
</packages>
+1 -1
View File
@@ -49,7 +49,7 @@
<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>
<HintPath>..\packages\log4net.2.0.15\lib\net45\log4net.dll</HintPath>
</Reference>
<Reference Include="MySql.Data">
<HintPath>..\packages\MySql.Data.6.6.5\lib\net40\MySql.Data.dll</HintPath>
+2 -2
View File
@@ -46,8 +46,8 @@
<SpecificVersion>False</SpecificVersion>
<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 Include="log4net, Version=2.0.15.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\packages\log4net.2.0.15\lib\net45\log4net.dll</HintPath>
</Reference>
<Reference Include="MySql.Data">
<HintPath>..\packages\MySql.Data.6.6.5\lib\net40\MySql.Data.dll</HintPath>
+4
View File
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="log4net" version="2.0.15" targetFramework="net472" />
</packages>
+3 -2
View File
@@ -38,8 +38,8 @@
<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 Include="log4net, Version=2.0.15.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\packages\log4net.2.0.15\lib\net45\log4net.dll</HintPath>
</Reference>
<Reference Include="MySql.Data">
<HintPath>..\packages\MySql.Data.6.6.5\lib\net40\MySql.Data.dll</HintPath>
@@ -62,6 +62,7 @@
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Config\Config.csproj">
+4
View File
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="log4net" version="2.0.15" targetFramework="net472" />
</packages>
+2 -2
View File
@@ -48,8 +48,8 @@
<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 Include="log4net, Version=2.0.15.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\packages\log4net.2.0.15\lib\net45\log4net.dll</HintPath>
</Reference>
<Reference Include="MySql.Data">
<HintPath>..\packages\MySql.Data.6.6.5\lib\net40\MySql.Data.dll</HintPath>
+4
View File
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="log4net" version="2.0.15" targetFramework="net472" />
</packages>
+2 -2
View File
@@ -49,8 +49,8 @@
<HintPath>..\packages\Iesi.Collections.4.0.0.4000\lib\net40\Iesi.Collections.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="log4net">
<HintPath>..\packages\log4net.2.0.2\lib\net40-full\log4net.dll</HintPath>
<Reference Include="log4net, Version=2.0.15.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\packages\log4net.2.0.15\lib\net45\log4net.dll</HintPath>
</Reference>
<Reference Include="MySql.Data, Version=6.6.5.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
+1
View File
@@ -3,4 +3,5 @@
<package id="FluentNHibernate" version="2.0.3.0" targetFramework="net40" />
<package id="Iesi.Collections" version="4.0.0.4000" targetFramework="net40" />
<package id="NHibernate" version="4.0.4.4000" targetFramework="net40" />
<package id="log4net" version="2.0.15" targetFramework="net472" />
</packages>
+2 -2
View File
@@ -34,8 +34,8 @@
<Reference Include="Gma.QrCodeNet.Encoding">
<HintPath>..\packages\QrCode.Net.0.4.0.0\net40\Gma.QrCodeNet.Encoding.dll</HintPath>
</Reference>
<Reference Include="log4net">
<HintPath>..\packages\log4net.2.0.2\lib\net40-full\log4net.dll</HintPath>
<Reference Include="log4net, Version=2.0.15.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\packages\log4net.2.0.15\lib\net45\log4net.dll</HintPath>
</Reference>
<Reference Include="NHibernate">
<HintPath>..\packages\NHibernate.4.0.4.4000\lib\net40\NHibernate.dll</HintPath>
+4
View File
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="log4net" version="2.0.15" targetFramework="net472" />
</packages>
+17 -19
View File
@@ -19,7 +19,7 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG</DefineConstants>
<DefineConstants>TRACE;DEBUG;LANG_PL</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>AnyCPU</PlatformTarget>
@@ -29,7 +29,7 @@
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<DefineConstants>TRACE;LANG_PL</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
@@ -44,8 +44,8 @@
<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 Include="log4net, Version=2.0.15.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\packages\log4net.2.0.15\lib\net45\log4net.dll</HintPath>
</Reference>
<Reference Include="MySql.Data">
<HintPath>..\packages\MySql.Data.6.6.5\lib\net40\MySql.Data.dll</HintPath>
@@ -75,6 +75,12 @@
<Compile Include="Entities\WaterMeterData.cs" />
<Compile Include="Entities\WaterMeter.cs" />
<Compile Include="DB.cs" />
<Compile Include="Forms\BatchResultsDlg.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Forms\BatchResultsDlg.Designer.cs">
<DependentUpon>BatchResultsDlg.cs</DependentUpon>
</Compile>
<Compile Include="Forms\IOneWMResultsCtrl.cs" />
<Compile Include="Forms\ManualEntryConfigCtrl.cs">
<SubType>UserControl</SubType>
@@ -118,10 +124,6 @@
<Compile Include="Forms\ResultsConfigDlg.designer.cs">
<DependentUpon>ResultsConfigDlg.cs</DependentUpon>
</Compile>
<Compile Include="Forms\TracingResultsDlg.cs" />
<Compile Include="Forms\TracingResultsDlg.Designer.cs">
<DependentUpon>TracingResultsDlg.cs</DependentUpon>
</Compile>
<Compile Include="Forms\WaterMeterEventArgs.cs" />
<Compile Include="ItemID.cs" />
<Compile Include="ManualEntryItemSpec.cs" />
@@ -132,6 +134,7 @@
<Compile Include="Mappings\TestRsltMap.cs" />
<Compile Include="Mappings\WaterMeterDataMap.cs" />
<Compile Include="Mappings\WaterMeterMap.cs" />
<Compile Include="Output\Cell.cs" />
<Compile Include="Output\Printers\Enhanced\EnhancedPrintDocument.cs">
<SubType>Component</SubType>
</Compile>
@@ -149,7 +152,6 @@
<SubType>Component</SubType>
</Compile>
<Compile Include="Output\Printers\OnePerBatch\OnePerBatchPrinterCfg.cs" />
<Compile Include="Output\Printers\Munich\MunichPrintDocument.cs" />
<Compile Include="Output\Printers\OnePerMeter\OnePerMeterPrintDocument.cs">
<SubType>Component</SubType>
</Compile>
@@ -188,13 +190,9 @@
<Project>{32817bf9-e380-4467-9c7f-936f4b122bc7}</Project>
<Name>GenCode128</Name>
</ProjectReference>
<ProjectReference Include="..\TracingDB\TracingDB.csproj">
<Project>{EFEC8A31-3022-4DA7-A8F6-16D30A94C3FF}</Project>
<Name>TracingDB</Name>
</ProjectReference>
<ProjectReference Include="..\Users\Users.csproj">
<Project>{6E5CB0E9-E1B6-4E5D-AC6E-B1049E180F2B}</Project>
<Name>Users</Name>
<ProjectReference Include="..\SharedDatabase\SharedDatabase.csproj">
<Project>{211b5e3f-9996-48a7-abde-c878dd2d71c2}</Project>
<Name>SharedDatabase</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
@@ -203,6 +201,9 @@
<Folder Include="Output\FileWriters\OneFilePerMeter\" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Forms\BatchResultsDlg.resx">
<DependentUpon>BatchResultsDlg.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\ManualEntryConfigCtrl.resx">
<DependentUpon>ManualEntryConfigCtrl.cs</DependentUpon>
</EmbeddedResource>
@@ -224,9 +225,6 @@
<EmbeddedResource Include="Forms\ResultsConfigDlg.resx">
<DependentUpon>ResultsConfigDlg.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\TracingResultsDlg.resx">
<DependentUpon>TracingResultsDlg.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
+4
View File
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="log4net" version="2.0.15" targetFramework="net472" />
</packages>
+4 -2
View File
@@ -47,8 +47,8 @@
<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 Include="log4net, Version=2.0.15.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\packages\log4net.2.0.15\lib\net45\log4net.dll</HintPath>
</Reference>
<Reference Include="MySql.Data">
<HintPath>..\packages\MySql.Data.6.6.5\lib\net40\MySql.Data.dll</HintPath>
@@ -65,7 +65,9 @@
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Web" />
<Reference Include="System.Windows.Forms.DataVisualization" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
+1
View File
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Oracle.ManagedDataAccess" version="19.11.0" targetFramework="net472" />
<package id="log4net" version="2.0.15" targetFramework="net472" />
</packages>
+6
View File
@@ -332,6 +332,12 @@ namespace SchematicDrawing
Shapes[DrShIx(Shape.PressM, Sz.M)] = new DrawingShape(Shape.PressM, Sz.M, 0, 0);
Shapes[DrShIx(Shape.PressM, Sz.L)] = new DrawingShape(Shape.PressM, Sz.L, 0, 0);
Shapes[DrShIx(Shape.PressM, Sz.XL)] = new DrawingShape(Shape.PressM, Sz.XL, 0, 0);
/// Electric meter
Shapes[DrShIx(Shape.ElectricM, Sz.S)] = new DrawingShape(Shape.ElectricM, Sz.S, 0, 0);
Shapes[DrShIx(Shape.ElectricM, Sz.M)] = new DrawingShape(Shape.ElectricM, Sz.M, 0, 0);
Shapes[DrShIx(Shape.ElectricM, Sz.L)] = new DrawingShape(Shape.ElectricM, Sz.L, 0, 0);
Shapes[DrShIx(Shape.ElectricM, Sz.XL)] = new DrawingShape(Shape.ElectricM, Sz.XL, 0, 0);
/// Parallel flow meters
Shapes[DrShIx(Shape.ParallelFlowM, Sz.S)] = new DrawingShape(Shape.ParallelFlowM, Sz.S, 0, 0);
+1
View File
@@ -51,6 +51,7 @@ namespace SchematicDrawing
Vacuum,
Valve,
WaterM,
ElectricM,
Count,
Custom,
+2 -2
View File
@@ -36,8 +36,8 @@
<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 Include="log4net, Version=2.0.15.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\packages\log4net.2.0.15\lib\net45\log4net.dll</HintPath>
</Reference>
<Reference Include="MySql.Data">
<HintPath>..\packages\MySql.Data.6.6.5\lib\net40\MySql.Data.dll</HintPath>
+4
View File
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="log4net" version="2.0.15" targetFramework="net472" />
</packages>
+17 -1
View File
@@ -1,6 +1,8 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
# Visual Studio Version 17
VisualStudioVersion = 17.8.34330.188
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TBF", "TBF\TBF.csproj", "{8648FD92-CDA1-4C3A-B5F9-FE547CE1FA48}"
ProjectSection(ProjectDependencies) = postProject
{7EBEEA14-91C4-48D7-AF0A-7A4BC3FF9A28} = {7EBEEA14-91C4-48D7-AF0A-7A4BC3FF9A28}
@@ -100,6 +102,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "S640TestApp", "S640TestApp\
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LabelPrinting", "LabelPrinting\LabelPrinting.csproj", "{E4531D13-317C-4D9F-809F-5533B5C3C8BF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TBFTests", "TBFTests\TBFTests.csproj", "{77EB589F-C670-4489-AAD6-2A3C02061FD1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -446,6 +450,18 @@ Global
{E4531D13-317C-4D9F-809F-5533B5C3C8BF}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{E4531D13-317C-4D9F-809F-5533B5C3C8BF}.Release|x86.ActiveCfg = Release|Any CPU
{E4531D13-317C-4D9F-809F-5533B5C3C8BF}.Release|x86.Build.0 = Release|Any CPU
{77EB589F-C670-4489-AAD6-2A3C02061FD1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{77EB589F-C670-4489-AAD6-2A3C02061FD1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{77EB589F-C670-4489-AAD6-2A3C02061FD1}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{77EB589F-C670-4489-AAD6-2A3C02061FD1}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{77EB589F-C670-4489-AAD6-2A3C02061FD1}.Debug|x86.ActiveCfg = Debug|Any CPU
{77EB589F-C670-4489-AAD6-2A3C02061FD1}.Debug|x86.Build.0 = Debug|Any CPU
{77EB589F-C670-4489-AAD6-2A3C02061FD1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{77EB589F-C670-4489-AAD6-2A3C02061FD1}.Release|Any CPU.Build.0 = Release|Any CPU
{77EB589F-C670-4489-AAD6-2A3C02061FD1}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{77EB589F-C670-4489-AAD6-2A3C02061FD1}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{77EB589F-C670-4489-AAD6-2A3C02061FD1}.Release|x86.ActiveCfg = Release|Any CPU
{77EB589F-C670-4489-AAD6-2A3C02061FD1}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
+2 -2
View File
@@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
// Build Number
// Revision
//
[assembly: AssemblyVersion("3.9.2139.0")]
[assembly: AssemblyFileVersion("3.9.2139.0")]
[assembly: AssemblyVersion("3.9.2141.1")]
[assembly: AssemblyFileVersion("3.9.2141.1")]
+20 -3
View File
@@ -1,7 +1,6 @@
//------------------------------------------------------------------------------
// <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.
@@ -1257,12 +1256,21 @@ namespace TBF.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Current.
/// </summary>
internal static string Current {
get {
return ResourceManager.GetString("Current", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to current.
/// </summary>
internal static string current {
internal static string current_ {
get {
return ResourceManager.GetString("current", resourceCulture);
return ResourceManager.GetString("current_", resourceCulture);
}
}
@@ -6813,6 +6821,15 @@ namespace TBF.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Voltage.
/// </summary>
internal static string Voltage {
get {
return ResourceManager.GetString("Voltage", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Volume.
/// </summary>
+6
View File
@@ -1746,4 +1746,10 @@
<data name="Print" xml:space="preserve">
<value>Tisknout</value>
</data>
<data name="Current" xml:space="preserve">
<value>Proud</value>
</data>
<data name="Voltage" xml:space="preserve">
<value>Napětí</value>
</data>
</root>
+6
View File
@@ -2211,4 +2211,10 @@
<data name="Calibration_certificate_validity_expired" xml:space="preserve">
<value>Kalibrierschein gültigkeit abgelaufen</value>
</data>
<data name="Current" xml:space="preserve">
<value>Strom</value>
</data>
<data name="Voltage" xml:space="preserve">
<value>Spannung</value>
</data>
</root>
+6
View File
@@ -2010,4 +2010,10 @@
<data name="Fill" xml:space="preserve">
<value>Inonder</value>
</data>
<data name="Current" xml:space="preserve">
<value>Curren</value>
</data>
<data name="Voltage" xml:space="preserve">
<value>Tension</value>
</data>
</root>
+6
View File
@@ -1779,4 +1779,10 @@
<data name="Start_cycle" xml:space="preserve">
<value>Avviare il ciclo</value>
</data>
<data name="Current" xml:space="preserve">
<value>Corrente</value>
</data>
<data name="Voltage" xml:space="preserve">
<value>Voltaggio</value>
</data>
</root>
+6
View File
@@ -1686,4 +1686,10 @@
<data name="Uncertainty" xml:space="preserve">
<value>Nepevność</value>
</data>
<data name="Current" xml:space="preserve">
<value>Prąd</value>
</data>
<data name="Voltage" xml:space="preserve">
<value>Napięcie</value>
</data>
</root>
+7 -1
View File
@@ -1813,7 +1813,7 @@
<data name="Refresh" xml:space="preserve">
<value>Refresh</value>
</data>
<data name="current" xml:space="preserve">
<data name="current_" xml:space="preserve">
<value>current</value>
</data>
<data name="Flow" xml:space="preserve">
@@ -2449,4 +2449,10 @@
<data name="Test_Bench_Framework" xml:space="preserve">
<value>Test Bench Framework</value>
</data>
<data name="Current" xml:space="preserve">
<value>Current</value>
</data>
<data name="Voltage" xml:space="preserve">
<value>Voltage</value>
</data>
</root>
+6
View File
@@ -831,4 +831,10 @@
<data name="Evaporation" xml:space="preserve">
<value>Evaporare</value>
</data>
<data name="Current" xml:space="preserve">
<value>Current</value>
</data>
<data name="Voltage" xml:space="preserve">
<value>Voltage</value>
</data>
</root>
+6
View File
@@ -1599,4 +1599,10 @@
<data name="Evaporation" xml:space="preserve">
<value>испарение</value>
</data>
<data name="Current" xml:space="preserve">
<value>Current</value>
</data>
<data name="Voltage" xml:space="preserve">
<value>Voltage</value>
</data>
</root>
File diff suppressed because it is too large Load Diff
+6
View File
@@ -1191,4 +1191,10 @@
<data name="Evaporation" xml:space="preserve">
<value>蒸发</value>
</data>
<data name="Current" xml:space="preserve">
<value>Current</value>
</data>
<data name="Voltage" xml:space="preserve">
<value>Voltage</value>
</data>
</root>
+6
View File
@@ -18,6 +18,9 @@ namespace TBF.Rig
public IPressureMeter PressMtrUp;
public IPressureMeter PressMtrDown;
public IPressureMeter PressMtrDelta;
public IAdjustableMeter ElectricMtrUp;
public IAdjustableMeter ElectricMtrDown;
public IAdjustableMeter ElectricMtrDelta;
public IValve StopBFValve;
public IList<IValve> ValvesOpen;
public IList<IValve> ValvesClose;
@@ -43,6 +46,9 @@ namespace TBF.Rig
PressMtrUp = TbfComponents.FindComponent(entity.PressMtrUp, components) as IPressureMeter;
PressMtrDown = TbfComponents.FindComponent(entity.PressMtrDown, components) as IPressureMeter;
PressMtrDelta = TbfComponents.FindComponent(entity.PressMtrDelta, components) as IPressureMeter;
ElectricMtrUp = TbfComponents.FindComponent(entity.ElectricMtrUp, components) as IAdjustableMeter;
ElectricMtrDown = TbfComponents.FindComponent(entity.ElectricMtrDown, components) as IAdjustableMeter;
ElectricMtrDelta = TbfComponents.FindComponent(entity.ElectricMtrDelta, components) as IAdjustableMeter;
StopBFValve = TbfComponents.FindComponent(entity.StopBFValve, components) as IValve;
string[] vOpen = entity.ValvesOpen.Split(new char[] { ';' });
+7 -9
View File
@@ -29,14 +29,12 @@ namespace TBF.Rig.BuiltIn
/// Relative time in [s] from the start of the operation
int timeShift; /// Set in SetValvesOp(cb, bool open, OutputPath outPath, DateTimeBox timeStamp)
int waitOnCBDelay = 2; // additional wait for the correct ControlBoard response in [s]
/// <summary>
/// Processes coupled valves and creates switch points.
/// </summary>
/// <param name="valvesOpen">A list of opening master valves</param>
/// <param name="valvesClose">A list of closing master valves</param>
/// <returns></returns>
/// <summary>
/// Processes coupled valves and creates switch points.
/// </summary>
/// <param name="valvesOpen">A list of opening master valves</param>
/// <param name="valvesClose">A list of closing master valves</param>
/// <returns></returns>
IList<SwitchPoint> AddSwitchPoints(IList<SwitchPoint> swPoints, IList<IValve> valvesOpen, IList<IValve> valvesClose, int time)
{
int ix0 = swPoints.Count;
@@ -279,7 +277,7 @@ namespace TBF.Rig.BuiltIn
{
if (nextIx >= switchPoints.Count)
{
return (StateMachine.Time >= swStartTime + maxDelayTime + waitOnCBDelay) ? Event.ValvesSet : Event.ValvesBusy;
return (StateMachine.Time >= swStartTime + maxDelayTime) ? Event.ValvesSet : Event.ValvesBusy;
}
if (StateMachine.Time >= swStartTime + switchPoints[nextIx].TimeSec)
+2 -2
View File
@@ -125,7 +125,7 @@ namespace TBF.Rig.Danfoss.VLT2800
int bitNr; /// 0 .. 127
public UInt128 Mask; /// derived from bitPosition in the constructor
public bool State { get { return (TBF.Rig.StateMachine.ControlBoard.Route & Mask) != 0; } }
public bool State { get { return (TBF.Rig.StateMachine.ControlBoardMain.Route & Mask) != 0; } }
/// Private fields
SerialPort serialPort;
@@ -148,7 +148,7 @@ namespace TBF.Rig.Danfoss.VLT2800
public override void Initialize()
{
if (TBF.Rig.StateMachine.ControlBoard == null) throw new Exception("Control board is missing");
if (TBF.Rig.StateMachine.ControlBoardMain == null) throw new Exception("Control board is missing");
bitNr = pumpCfg.BitNr;
Mask = (((UInt128)1) << bitNr);
@@ -35,6 +35,7 @@ namespace TBF.Rig.DataContainer.BenchInfo
public Unit TempUnit { get { return myCfg.TempUnit; } }
public Unit PressUnit { get { return myCfg.PressUnit; } }
public Unit LengthUnit { get { return myCfg.LenghtUnit; } }
public Unit ElectricUnit { get { return myCfg.ElectricUnit; } }
public ICollection<ProcedureSelection> Sources
{
@@ -47,6 +47,7 @@ namespace TBF.Rig.DataContainer.BenchInfo
public ProcedureSelection Source2; /// 21
public ProcedureSelection Source3; /// 22
public ProcedureSelection Source4; /// 23
public Unit ElectricUnit; /// 24
/// Private parameterless constructor invoked by all other (public) constructors
ComponentCfg() {}
@@ -36,6 +36,7 @@ namespace TBF.Rig.DataContainer.iPerlBenchInfo
public Unit TempUnit { get { return myCfg.TempUnit; } }
public Unit PressUnit { get { return myCfg.PressUnit; } }
public Unit LengthUnit { get { return myCfg.LenghtUnit; } }
public Unit ElectricUnit { get { return myCfg.ElectricUnit; } }
public Side Side { get { return myCfg.Side; } }
public int MaxTestIndex { get { return myCfg.MaxTestIndex; } } /// (MaxPruefindex % 100) value when to reject water meters completely if they are NOK
@@ -49,6 +49,7 @@ namespace TBF.Rig.DataContainer.iPerlBenchInfo
public ProcedureSelection Source2; /// 23
public ProcedureSelection Source3; /// 24
public ProcedureSelection Source4; /// 25
public Unit ElectricUnit; /// 26
/// Calibration info serialized parameters displayed in Metrology tab page
public string CalibCertificateNr { get; set; }
@@ -99,6 +100,7 @@ namespace TBF.Rig.DataContainer.iPerlBenchInfo
Source2 = ProcedureSelection.FromLocalDB;
Source3 = ProcedureSelection.None;
Source4 = ProcedureSelection.None;
ElectricUnit = Unit.A;
CalibCertificateNr = string.Empty;
CalibDate = TBF.UI.Constants.MinDate;
@@ -133,6 +135,7 @@ namespace TBF.Rig.DataContainer.iPerlBenchInfo
"Procedure selection source 2", /// 23
"Procedure selection source 3", /// 24
"Procedure selection source 4", /// 25
"Preffered electric unit", /// 26
};
public string ParamName(int i) { return paramNames[i]; }
public int ParamsCount() { return paramNames.Length; }
@@ -193,6 +196,13 @@ namespace TBF.Rig.DataContainer.iPerlBenchInfo
for (ProcedureSelection src = 0; src < ProcedureSelection.Count; src++)
list.Add(src.ToDescription());
return list;
case 26:
for (Unit unit = 0; unit < Unit.Count; unit++)
if (Units.IsQuantity(unit, Quantity.Current) ||
Units.IsQuantity(unit, Quantity.Voltage))
list.Add(unit.ToDescription());
return list;
default:
return null;
@@ -229,6 +239,7 @@ namespace TBF.Rig.DataContainer.iPerlBenchInfo
case 23: return Source2.ToDescription();
case 24: return Source3.ToDescription();
case 25: return Source4.ToDescription();
case 26: return ElectricUnit.ToDescription();
default:
return string.Format("{0}: Bench={1}, ID={2}, Mtrs={3}, Lines={4}, Compund mtrs={5}, S1={6}, S2={7}, S3={8}, S4={9}",
Name, TestBenchName, TestBenchId, WaterMetersCount, LinesCount, CompoundMetersCount, Source1, Source2, Source3, Source4);
@@ -329,6 +340,10 @@ namespace TBF.Rig.DataContainer.iPerlBenchInfo
}
break;
case 26:
ElectricUnit = Units.FromDescription(str);
return CfgUpdateFlags.RestartRqrd;
default: return CfgUpdateFlags.None;
}
return CfgUpdateFlags.Error;
@@ -388,6 +403,10 @@ namespace TBF.Rig.DataContainer.iPerlBenchInfo
if (str == source.ToDescription()) return true;
}
break;
case 26:
if (ParamValues(i).Contains(str)) return true;
break;
default:
message = "Invalid index";
return false;
@@ -425,6 +444,7 @@ namespace TBF.Rig.DataContainer.iPerlBenchInfo
prms.Source2 = Source2;
prms.Source3 = Source3;
prms.Source4 = Source4;
prms.ElectricUnit = ElectricUnit;
prms.CalibCertificateNr = this.CalibCertificateNr;
prms.CertPath = this.CertPath;
@@ -0,0 +1,31 @@
using TBF.Boxes;
using TBF.Rig.Generic;
namespace TBF.Rig.GenericDevices
{
public interface IAdjustableMeter : IComponent
{
/// <summary>
/// Events: PressureDone, Error
/// </summary>
/// <param name="pressure">Reference to a variable for the measured pressure in bar</param>
/// <returns>ReadPressureOp instance reference casted to IOperaton</returns>
IOperation ReadAdjustableOp(ref DoubleBox value);
/// <summary>
/// Events: pressureDone, Error
/// </summary>
/// <param name="pressure">Reference to a variable for the measured pressure in bar</param>
/// <param name="pressureDone">Event returned when measurement done</param>
/// <returns>ReadPressureOp instance reference casted to IOperaton</returns>
IOperation ReadAdjustableOp(ref DoubleBox value, Event valueDone);
bool MsrmntAvailable { get; }
double MeasuredVal { get; }
double MsrdValLimLo { get; }
double MsrdValLimHi { get; }
string MsrdFormat { get; }
Common.Unit MsrdUnit { get; }
string AltString { get; }
}
}
+2 -1
View File
@@ -29,5 +29,6 @@ namespace TBF.Rig.GenericDevices
Unit TempUnit { get; }
Unit PressUnit { get; }
Unit LengthUnit { get; }
}
Unit ElectricUnit { get; }
}
}
+2 -2
View File
@@ -79,8 +79,8 @@ namespace TBF.Rig.MettlerToledo
if (drainValve == null) throw new Exception(string.Format("{0} is missing a drain valve", Name));
openTheDrainValveOp = new BuiltIn.SetValvesOp(StateMachine.ControlBoard, drainValve, null);
closeTheDrainValveOp = new BuiltIn.SetValvesOp(StateMachine.ControlBoard, null, drainValve);
openTheDrainValveOp = new BuiltIn.SetValvesOp(StateMachine.ControlBoardMain, drainValve, null);
closeTheDrainValveOp = new BuiltIn.SetValvesOp(StateMachine.ControlBoardMain, null, drainValve);
waitTankIsEmptyOp = new WaitTankEmptyOp(this);
Various.TankWithLevelMsrmnt.TankCfg tankCfg = tankDrainingCfg as Various.TankWithLevelMsrmnt.TankCfg;
@@ -0,0 +1,286 @@
///
/// Copyright (c) 2016-2020 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using log4net;
using Common;
using Config.Entities;
using SchematicDrawing;
using TBF.Rig.Generic;
using TBF.Boxes;
using TBF.Resources;
using TBF.Rig.GenericDevices;
namespace TBF.Rig.Modbus.Meret.AdjustableScale
{
public class AdjustableMeter : ComponentBase, IAdjustableMeter, IDevice, ISequenceCondition, IDrawingItCmpntWithMeasuredVal
{
private static readonly ILog log = LogManager.GetLogger(typeof(AdjustableMeter));
public override string ToString() { return string.Format("{0}({1})", ClassName, Cfg.ToString(-1)); }
readonly AdjustableMeterCfg _adjustableMtrCfg;
public IDrawingItem DrawingItem { get { return _adjustableMtrCfg as IDrawingItem; } }
Common.Modbus modbus;
double receivedValue;
double receivedAmpers;
public bool MsrmntAvailable { get { return true; } }
public double MeasuredVal { get { return receivedValue; } }
public double MsrdValLimLo { get { return Units.ConvertFrom(MsrdUnit, _adjustableMtrCfg.MsrdValLimLo); } }
public double MsrdValLimHi { get { return Units.ConvertFrom(MsrdUnit, _adjustableMtrCfg.MsrdValLimHi); } }
public Unit MsrdUnit { get { return _adjustableMtrCfg.MsrdUnit; } }
public string MsrdFormat { get { return _adjustableMtrCfg.MsrdFormat; } }
public string AltString { get { return string.Empty; } }
int ticketNumber; /// 0 .. number of devices registered for regular polling - 1
public double CorrectionValLo { get { return Units.ConvertFrom(MsrdUnit, _adjustableMtrCfg.CorrectionValLo); } }
public double CorrectionValHi { get { return Units.ConvertFrom(MsrdUnit, _adjustableMtrCfg.CorrectionValHi); } }
IList<MeasurementCorrection> CorrectionsLocal;
public AdjustableMeter() { }
public AdjustableMeter(Generic.IComponentCfg cfg, IList<Generic.IComponent> components)
: base(cfg)
{
_adjustableMtrCfg = cfg as AdjustableMeterCfg;
CreateConditions();
}
///
/// IDevice interface
///
public override void Initialize()
{
if (DebugLevel == DebugMode.Normal)
{
InitModbus();
if (CorrectionValLo != 0 || CorrectionValHi != 0 ) {
CorrectionsLocal = new List<MeasurementCorrection>();
MeasurementCorrection Lo, Hi;
Lo = new MeasurementCorrection(1);
Lo.Measurement = CorrectionValLo;
Lo.Correction = MsrdValLimLo;
CorrectionsLocal.Add(Lo);
Hi = new MeasurementCorrection(2);
Hi.Measurement = CorrectionValHi;
Hi.Correction = MsrdValLimHi;
CorrectionsLocal.Add(Hi);
log.FatalFormat("{0} Correction initialised - CorrectionValLo: {1} CorrectionValHi: {2}", Name, CorrectionValLo, CorrectionValHi);
}
}
else
{
log.FatalFormat("{0} simulated: {1}", Name, this);
}
}
private void InitModbus()
{
modbus = TbfComponents.FindComponent(_adjustableMtrCfg.ParentName) as Common.Modbus;
if (modbus == null) throw new Exception("Cannot find " + Name + " parent");
modbus.ComponentNames[_adjustableMtrCfg.ModbusAddress] = Name;
ticketNumber = modbus.RegisterForPolling();
log.FatalFormat("{0} initialized: {1}", Name, this);
}
public void RunDeviceBefore()
{
if (DebugLevel == DebugMode.Normal && modbus.ReceivedTelegrams[_adjustableMtrCfg.ModbusAddress].Count > 0)
{
byte[] telegram = modbus.ReceivedTelegrams[_adjustableMtrCfg.ModbusAddress].Dequeue();
if (telegram.Length == 9 && telegram[1] == 4 && telegram[2] == 4)
{
/// Swap byte order
byte t1 = telegram[3];
byte t2 = telegram[4];
byte t3 = telegram[5];
byte t4 = telegram[6];
telegram[3] = t4;
telegram[4] = t3;
telegram[5] = t2;
telegram[6] = t1;
receivedAmpers = Units.ConvertFrom(Unit.A, System.BitConverter.ToSingle(telegram, 3));
if (CorrectionsLocal != null)
{
receivedValue = GetCorrectionLimitLessHi(receivedAmpers, CorrectionsLocal);
}
else
{
receivedValue = receivedAmpers;
}
log.WarnFormat("Adjustable meter: {0}={1} Unit interpolated from Ampers: {2}", Name, receivedValue.ToString("F3"), receivedAmpers.ToString("F3"));
}
}
}
/// <summary>
/// Get a correction from 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 GetCorrectionLimitLessHi(double rawValue, IList<MeasurementCorrection> corrections)
{
if ((corrections == null) || (corrections.Count == 0)) return 0; /// No correction
if (rawValue < corrections[0].Measurement)
{
/// rawValue is below the lowest value in the correction table
return corrections[0].Correction;
}
for (int i = 1; i < corrections.Count; i++)
{
if (rawValue < corrections[i].Measurement)
{
double d1 = rawValue - corrections[i - 1].Measurement;
double d2 = corrections[i].Measurement - rawValue;
if (d1 + d2 <= float.Epsilon)
{
/// Neigboring values in the corection table are close to each other -> calculate the average
return (corrections[i - 1].Correction + corrections[i].Correction) / 2.0;
}
else
{
/// Interpolate the correction from neigboring values in the corection table
return (corrections[i - 1].Correction * d2 + corrections[i].Correction * d1) / (d1 + d2);
}
}
}
int lastCorrection = corrections.Count - 1;
if (lastCorrection > 0)
{
double d1 = rawValue - corrections[lastCorrection - 1].Measurement;
double d2 = corrections[lastCorrection].Measurement - rawValue;
return (corrections[lastCorrection - 1].Correction * d2 + corrections[lastCorrection].Correction * d1) /
(d1 + d2);
}
/// rawValue is above the highest value in the correction table
return corrections[corrections.Count - 1].Correction;
}
public void RunDeviceAfter()
{
if (DebugLevel == DebugMode.Normal && modbus.IsMyTurn(ticketNumber))
{
const byte Function = 4; /// Read input registers
const ushort Address = 0; /// Pressure
modbus.SendMessage((byte)_adjustableMtrCfg.ModbusAddress, Function, Address, 2, Name);
}
}
public void StopDevice() { }
public void StopDevice2() { }
/// <summary>
/// Returns the water pressure
/// </summary>
/// <returns>Pressure in mBar</returns>
public double ReadPressure()
{
if (DebugLevel == DebugMode.Normal)
{
return MeasurementCorrection.CorrectedValue(receivedValue, Corrections);
}
else if (DebugLevel == DebugMode.Simulate)
{
return 1.0;
}
else
{
return 0;
}
}
/// <summary>
/// Events: PressureDone, Error
/// </summary>
/// <param name="pressureBox">Reference to a variable for the pressure in Bar</param>
/// <returns>ReadPressureOp instance reference casted to IOperaton</returns>
public IOperation ReadAdjustableOp(ref DoubleBox value)
{
return new ReadValueOp(this, ref value);
}
/// <summary>
/// Events: valueDone, Error
/// </summary>
/// <param name="pressureBox">Reference to a variable for the pressure in Bar</param>
/// <param name="pressureDone">Event returned when measurement done</param>
/// <returns>ReadPressureOp instance reference casted to IOperaton</returns>
public IOperation ReadAdjustableOp(ref DoubleBox value, Event valueDone)
{
return new ReadValueOp(this, ref value, valueDone);
}
///
/// ISequenceCondition interface implementation (conditions in transition sequences)
///
IList<string> sequenceConditionNames;
IList<IOperation> sequenceConditions;
public int ConditionsCount { get { return sequenceConditions != null ? sequenceConditions.Count : 0; } }
/// Strings are added to the combo-box for transition sequence condition selection
public string ConditionName(int i)
{
if (sequenceConditionNames != null && i < sequenceConditionNames.Count && i >= 0)
return sequenceConditionNames[i];
else
return string.Empty;
}
/// Operations are executed as a part of a transition sequence
public IOperation ConditionOp(int i)
{
if (sequenceConditions != null && i < sequenceConditions.Count && i >= 0)
return sequenceConditions[i];
else
return null;
}
void ClearConditions()
{
sequenceConditionNames = new List<string>();
sequenceConditions = new List<IOperation>();
}
void AddCondition(string conditionName, IOperation conditionOperation)
{
sequenceConditionNames.Add(conditionName);
sequenceConditions.Add(conditionOperation);
}
/// <summary>
/// Create a list of conditions
/// </summary>
void CreateConditions()
{
ClearConditions();
foreach (var pressLimit in new double[] { 2.18, 2.2, 2.22, 2.24, 2.26, 2.27 })
{
AddCondition(string.Format("{0} {1} > {2} bar", Strings.Wait_until, Name, pressLimit), new WaitUntilValueIsOp(this, Pr.IsGT, pressLimit));
AddCondition(string.Format("{0} {1} < {2} bar", Strings.Wait_until, Name, pressLimit), new WaitUntilValueIsOp(this, Pr.IsLT, pressLimit));
}
}
}
}
@@ -0,0 +1,240 @@
///
/// Copyright (c) 2021-2023 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml.Serialization;
using Common;
using Config.Entities;
using SchematicDrawing;
using TBF.Rig.Generic;
namespace TBF.Rig.Modbus.Meret.AdjustableScale
{
public class AdjustableMeterCfg : ComponentCfgBase, IChildComponentCfg, GenericDevices.ICalibInfoCfg, IParamsProvider,
IDrawingItemWithMeasuredVal
{
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(AdjustableMeterCfg) })[0];
public override XmlSerializer GetSerializer() { return Serializer; }
public IComponentCfgCtrl GetControl(IList<Config.Entities.Component> cmpntEntities)
{
var parents = cmpntEntities.Where(x => x.ClassName == "Modbus.Common");
return new Configs.ParamsProvider.ComponentCfgCtrl(this, parents);
}
///
/// Serialized parameters
///
public int ModbusAddress; /// 0 (1..254)
public double DefaultPressure; /// 1
public string MsrdFormat { get; set; } /// 2
public Unit MsrdUnit { get; set; } /// 3
public double MsrdValLimLo { get; set; } /// 4
public double MsrdValLimHi { get; set; } /// 5
public double CorrectionValLo { get ; set; } /// 6
public double CorrectionValHi { get ; set; } /// 7
/// Calibration info serialized parameters displayed in Metrology tab page
public string CalibCertificateNr { get; set; }
public string CertPath { get; set; }
public DateTime CalibDate { get; set; }
public DateTime CalibValidDate { get; set; }
/// Schematic drawing info
public Shape Shape { get; set; }
public int X { get; set; }
public int Y { get; set; }
public Sz Sz { get; set; }
public Orient Orient { get; set; }
public bool Flip { get; set; }
public int LblX { get; set; }
public int LblY { get; set; }
public Orient LblOrient { get; set; }
public int MsrdX { get; set; }
public int MsrdY { get; set; }
public Orient MsrdOrient { get; set; }
[XmlIgnore]
public IList<GNode> GNodes { get; set; }
/// Private parameterless constructor invoked by all other (public) constructors
AdjustableMeterCfg()
{
GNodes = new List<GNode>();
}
public AdjustableMeterCfg(IComponentFactory factory)
: this()
{
Shape = Shape.ElectricM;
Sz = Sz.M;
Factory = factory;
Name = "Ad";
ParentName = "Modbus";
InitializeAll();
}
public string ComponentName { get { return Name; } }
public void InitializeAll()
{
ModbusAddress = 49;
DefaultPressure = 2.34;
MsrdFormat = "{0:F2} A";
MsrdUnit = Unit.A;
MsrdValLimLo = -0.1;
MsrdValLimHi = 25.0;
CorrectionValLo = 0.0;
CorrectionValHi = 0.0;
MsrdY = 22;
}
string[] paramNames = new string[]
{
"Modbus address", /// 0
"Default value", /// 1
"Display format", /// 2
"Unit", /// 3
"Limit Lo", /// 4
"Limit Hi", /// 5
"Correction limit Lo", /// 6
"Correction limit Hi", /// 7
};
public string ParamName(int i) { return paramNames[i]; }
public int ParamsCount() { return paramNames.Length; }
public ICollection<string> ParamValues(int i)
{
switch (i)
{
case 3:
return new string[] { "A", "mA", "V", "mV", "Pa", "hPa", "mbar", "kPa", "inHg", "psi", "bar", "MPa" };
default:
return null;
}
}
public string ToString(int i)
{
switch (i)
{
case 0: return ModbusAddress.ToString();
case 1: return DefaultPressure.ToString();
case 2: return MsrdFormat;
case 3: return MsrdUnit.ToDescription();
case 4: return MsrdValLimLo.ToString();
case 5: return MsrdValLimHi.ToString();
case 6: return CorrectionValLo.ToString();
case 7: return CorrectionValHi.ToString();
default:
return string.Format("{0}({1}) address={2}", Name, string.IsNullOrEmpty(ParentName) ? "-" : ParentName, ModbusAddress);
}
}
public CfgUpdateFlags UpdateParam(int i, string str)
{
switch (i)
{
case 0: ModbusAddress = int.Parse(str); return CfgUpdateFlags.RestartRqrd;
case 1: DefaultPressure = Utils.ParseSDouble(str); return CfgUpdateFlags.RestartRqrd;
case 2: MsrdFormat = str; return CfgUpdateFlags.RestartRqrd;
case 3:
foreach (var u in new Unit[] { Unit.A, Unit.mA, Unit.V, Unit.mV, Unit.Pa, Unit.hPa, Unit.mbar, Unit.kPa, Unit.inHg, Unit.psi, Unit.bar, Unit.MPa })
{
if (str == u.ToDescription())
{
MsrdUnit = u;
return CfgUpdateFlags.RestartRqrd;
}
}
return CfgUpdateFlags.None;
case 4: MsrdValLimLo = Utils.ParseSDouble(str); return CfgUpdateFlags.RestartRqrd;
case 5: MsrdValLimHi = Utils.ParseSDouble(str); return CfgUpdateFlags.RestartRqrd;
case 6: CorrectionValLo = Utils.ParseSDouble(str); return CfgUpdateFlags.RestartRqrd;
case 7: CorrectionValHi = Utils.ParseSDouble(str); return CfgUpdateFlags.RestartRqrd;
default: return CfgUpdateFlags.None;
}
}
public bool ValidateParam(int i, string str, out string message)
{
message = string.Empty;
int idummy;
double dummy;
switch (i)
{
case 0:
if (int.TryParse(str, out idummy) && idummy >= 1 && idummy <= 254) return true;
break;
case 1:
case 4:
case 5:
case 6:
case 7:
if (TBF.Utils.TryParseSDouble(str, out dummy)) return true;
break;
case 2:
return true;
case 3:
if (ParamValues(i).Contains(str)) return true;
break;
default:
message = "Invalid index";
return false;
}
message = ParamName(i) + " is invalid";
return false;
}
void CopyContentTo(AdjustableMeterCfg prms)
{
prms.ParentName = this.ParentName;
prms.CalibCertificateNr = this.CalibCertificateNr;
prms.CertPath = this.CertPath;
prms.CalibDate = this.CalibDate;
prms.CalibValidDate = this.CalibValidDate;
prms.Shape = this.Shape;
prms.Sz = this.Sz;
prms.Orient = this.Orient;
prms.Flip = this.Flip;
prms.LblX = this.LblX;
prms.LblY = this.LblY;
prms.LblOrient = this.LblOrient;
prms.MsrdX = this.MsrdX;
prms.MsrdY = this.MsrdY;
prms.MsrdOrient = this.MsrdOrient;
prms.ModbusAddress = this.ModbusAddress;
prms.DefaultPressure = this.DefaultPressure;
prms.MsrdFormat = this.MsrdFormat;
prms.MsrdUnit = this.MsrdUnit;
prms.MsrdValLimLo = this.MsrdValLimLo;
prms.MsrdValLimHi = this.MsrdValLimHi;
prms.CorrectionValLo = this.CorrectionValLo;
prms.CorrectionValHi = this.CorrectionValHi;
}
public IParamsProvider Clone()
{
AdjustableMeterCfg pars = new AdjustableMeterCfg();
CopyContentTo(pars);
return pars;
}
public bool UpdateEmbeddedDbEntity()
{
return true; /// =OK, do nothing
}
}
}
@@ -0,0 +1,25 @@
///
/// Copyright (c) 2016-2020 Sensus Slovensko a.s.
///
using System.Collections.Generic;
using TBF.Rig.Generic;
namespace TBF.Rig.Modbus.Meret.AdjustableScale
{
public class Factory : IComponentFactory
{
public string ClassName { get { return GetType().Namespace.Substring(8); } }
public override string ToString() { return ClassName; }
public IComponent DummyComponent() { return new AdjustableMeter(); }
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new AdjustableMeter(cfg, components); }
public IComponentCfg DefaultConfig() { return new AdjustableMeterCfg(this); }
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
{
return ComponentCfgBase.CreateFromDbEntity(AdjustableMeterCfg.Serializer, component, this);
}
}
}
@@ -0,0 +1,60 @@
///
/// Copyright (c) 2016-2021 Sensus Slovensko a.s.
///
using System;
using log4net;
using TBF.Boxes;
namespace TBF.Rig.Modbus.Meret.AdjustableScale
{
public class ReadValueOp : IOperation
{
private static readonly ILog log = LogManager.GetLogger(typeof(ReadValueOp));
public override string ToString() { return string.Format("ReadPressureOp(.,{0},.)", eventDone); }
/// Set by the constructor
readonly AdjustableMeter _adjustableMeter;
readonly DoubleBox value; /// Box for the measured value
readonly Event eventDone;
/// <summary>
/// Events: PressureDone or Error
/// </summary>
/// <param name="adjustableMeter">Pressure meter reference</param>
/// <param name="value">Reference to the measured pressure variable, value is in bar</param>
/// <param name="eventDone">Event to be returned by Run() when completed OK</param>
public ReadValueOp(AdjustableMeter adjustableMeter, ref DoubleBox value, Event eventDone)
{
if (adjustableMeter == null) throw new ArgumentNullException("adjustableMeter");
this._adjustableMeter = adjustableMeter;
this.value = value;
this.eventDone = eventDone;
log.Debug(this.ToString());
}
public ReadValueOp(AdjustableMeter adjustableMeter, ref DoubleBox value)
: this(adjustableMeter, ref value, Event.PressureDone)
{
}
/// <summary>Start this operation</summary>
public void Start()
{
if (value != null) value.Val = _adjustableMeter.ReadPressure();
}
/// <summary>Run this operation</summary>
/// <returns>
/// Event.PressureInDone or Event.PressureOutDone
/// </returns>
public Event Run()
{
if (value != null) value.Val = _adjustableMeter.ReadPressure();
return eventDone;
}
/// <summary>Stop this operation</summary>
public void Stop() { }
}
}
@@ -0,0 +1,61 @@
///
/// Copyright (c) 2022 Sensus Slovensko a.s.
///
using System;
using log4net;
namespace TBF.Rig.Modbus.Meret.AdjustableScale
{
public enum Pr
{
IsGT,
IsLT,
}
public class WaitUntilValueIsOp : IOperation
{
private static readonly ILog log = LogManager.GetLogger(typeof(WaitUntilValueIsOp));
public override string ToString() { return string.Format("WaitUntilPressureIsOp({0}, {1}, {2:F1}bar)", meter.Name, condition, valueLimit); }
/// Set by the constructor
readonly AdjustableMeter meter;
readonly double valueLimit;
readonly Pr condition;
/// <summary>
/// Events: PressureInDone, PressureOutDone or Error
/// </summary>
/// <param name="meter">Temp. controller reference</param>
/// <param name="eventDone">Event to be returned by Run() when completed OK</param>
public WaitUntilValueIsOp(AdjustableMeter meter, Pr condition, double valueLimit)
{
if (meter == null) throw new ArgumentNullException("tempControl");
this.meter = meter;
this.valueLimit = valueLimit;
this.condition = condition;
log.Debug(this.ToString());
}
/// <summary>Start this operation</summary>
public void Start() { }
/// <summary>Run this operation</summary>
public Event Run()
{
if (condition == Pr.IsGT && meter.ReadPressure() > valueLimit)
{
return Event.ConditionMet;
}
else if (condition == Pr.IsLT && meter.ReadPressure() < valueLimit)
{
return Event.ConditionMet;
}
return Event.ConditionNotMet;
}
/// <summary>Stop this operation</summary>
public void Stop() { }
}
}
+2 -2
View File
@@ -191,7 +191,7 @@ namespace TBF.Rig.Modbus.TankSelector
/// </summary>
void RecoverState()
{
latchedDigitalInputs = StateMachine.ControlBoard.DigitalInputs;
latchedDigitalInputs = StateMachine.ControlBoardMain.DigitalInputs;
if ((latchedDigitalInputs & (ulong)DigitalInputs.ColdTankSelected) != 0)
{
if ((latchedDigitalInputs & (ulong)DigitalInputs.Pumping_WaitingLevel) == 0)
@@ -228,7 +228,7 @@ namespace TBF.Rig.Modbus.TankSelector
/// </summary>
void DetectNoTankSelected()
{
ulong digiIn = StateMachine.ControlBoard.DigitalInputs;
ulong digiIn = StateMachine.ControlBoardMain.DigitalInputs;
if (digiIn == latchedDigitalInputs)
{
+1 -1
View File
@@ -220,7 +220,7 @@ namespace TBF.Rig.Network.Camera.Roi
cameraPulses = NetCamera.GetResult(roiHandle, out cameraTime);
}
wmRefPulses = StateMachine.ControlBoard.RefPulses;
wmRefPulses = StateMachine.ControlBoardMain.RefPulses;
}
///
@@ -57,7 +57,7 @@ namespace TBF.Rig.Network.Camera.RoiForFixedStart
public int WMPulses { get { return (int)(WMVolume / LtrsPerPulse); } }
public int WMRefPulses { get { return StateMachine.ControlBoard.RefPulses; ; } }
public int WMRefPulses { get { return StateMachine.ControlBoardMain.RefPulses; ; } }
public Roi() { }
@@ -0,0 +1,25 @@
///
/// Copyright (c) 2015-2018 Sensus Slovensko a.s.
///
using System.Collections.Generic;
using TBF.Rig.Generic;
namespace TBF.Rig.Output.Printers.GroupPrinting.Single
{
public class Factory : IComponentFactory
{
public string ClassName { get { return this.GetType().Namespace.Substring(8); } }
public override string ToString() { return ClassName; }
public IComponent DummyComponent() { return new Printer(); }
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new Printer(cfg); }
public IComponentCfg DefaultConfig() { return new PrinterCfg(this.GetType().Namespace.Substring(15), this); }
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
{
return ComponentCfgBase.CreateFromDbEntity(PrinterCfg.Serializer, component, this);
}
}
}
@@ -0,0 +1,112 @@
using System.Collections.Generic;
using System.Xml;
using Common;
using Config.Entities;
using Config.Resources;
using NHibernate;
namespace TBF.Rig.Output.Printers.GroupPrinting.Single
{
public class GroupPrinterUtils
{
public static ISession GetCorrespondedEntities(in IList<Component> cmpntEntities, in List<string> itemsToPrint)
{
ISession session = TBF.DB.CreateSession(DBKind.Config);
IList<Component> cmpntEntitiesAll = session.QueryOver<Component>()
.OrderBy(x => x.ItemNr).Asc
.List<Component>();
cmpntEntities?.Clear();
List<PrinterDef> printerDefs = new List<PrinterDef>();
if (itemsToPrint != null && itemsToPrint.Count > 0)
{
foreach (string printer in itemsToPrint)
{
printerDefs.Add(PrinterDef.fromString(printer));
}
}
if (printerDefs.Count > 0)
{
foreach (PrinterDef printerDef in printerDefs)
{
foreach (var component in cmpntEntitiesAll)
{
if (printerDef.Equals(PrinterDef.fromComponent(component)))
{
cmpntEntities.Add(component);
}
}
}
}
return session;
}
public static string[] GetExpandedGroupPrinters(string[] printers)
{
List<string> allPrinters = new List<string>();
ISession session = TBF.DB.CreateSession(DBKind.Config);
IList<Component> cmpntEntitiesAll = session.QueryOver<Component>()
.OrderBy(x => x.ItemNr).Asc
.List<Component>();
string groupPrinterClassName = new Factory().ClassName;
foreach (string printer in printers)
{
foreach (var component in cmpntEntitiesAll)
{
if (printer.Equals(component.Name))
{
if (component.ClassName.Equals(groupPrinterClassName))
{
List<PrinterDef> printersDef = PrinterDef.fromParametersString(component.Parameters);
foreach (PrinterDef printerDef in printersDef)
{
allPrinters.Add(printerDef.Name);
}
}
else
{
allPrinters.Add(printer);
}
}
}
}
return allPrinters.ToArray();
}
public static void UpdateParametersInEntitys(ISession session, IList<Component> cmpntEntities,string definedPrinter)
{
{
using (var transaction = session.BeginTransaction())
{
foreach (Component printerItem in cmpntEntities)
{
XmlDocument xmlDocument = new XmlDocument();
xmlDocument.LoadXml(printerItem.Parameters);
XmlNodeList printerCfg = xmlDocument.GetElementsByTagName("PrinterName");
foreach (XmlNode itemNode in printerCfg)
{
itemNode.InnerText = definedPrinter;
}
printerItem.Parameters = xmlDocument.OuterXml;
session.SaveOrUpdate(printerItem); /// Save user 'admin'
}
transaction.Commit();
}
}
}
}
}
@@ -0,0 +1,209 @@
///
/// Copyright (c) 2015-2023 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using log4net;
using System.Globalization;
using System.Threading;
using Common;
using Common.Forms;
using Results.Output.Printers.Label;
namespace TBF.Rig.Output.Printers.GroupPrinting.Single
{
public class Printer : ComponentBase, IOperation, GenericDevices.IResultsPrinter
{
private static readonly ILog log = LogManager.GetLogger(typeof(Printer));
public override string ToString() { return string.Format("{0}({1})", ClassName, Cfg.ToString(-1)); }
readonly PrinterCfg printerCfg;
public bool SupressPrinting { get { return (printerCfg.NrOfCopies == 0); } }
Results.Entities.Batch batch; /// Data to print
IList<Results.WMeterRsltItemSpec> commonItems; /// Items to print
bool printingCompleted = false;
bool statusDlgShown = false;
ModelessForm modelessForm;
public Printer() { }
public Printer(Generic.IComponentCfg cfg)
: base(cfg)
{
printerCfg = cfg as PrinterCfg;
}
public override void Initialize()
{
ApplyConfig();
if (printerCfg.DebugLevel == DebugMode.Normal)
{
string message;
if (!PrinterStatus.IsOnline(printerCfg.PrinterName, out message)) throw new ApplicationException(message);
log.FatalFormat("{0} initialized: {1}", Name, this);
}
else
{
log.FatalFormat("{0} simulated: {1}", Name, this);
}
}
void ApplyConfig()
{
commonItems = Results.WMeterRsltItemSpec.FromStrArray(printerCfg.ItemsToPrint);
}
#region Configuration Change Handling
public static void OnCfgChange(object sender, CfgChangeArgs args)
{
if (CfgChangeHandler == null) return;
try { CfgChangeHandler(sender, args); }
catch (Exception e) { log.Error("CfgChangeHandler(...) failed", e); }
}
public static event EventHandler<CfgChangeArgs> CfgChangeHandler;
public override void StartChangeHandler()
{
CfgChangeHandler += delegate(object sender, CfgChangeArgs args)
{
PrinterCfg newCfg = args.Cfg as PrinterCfg;
if (newCfg != null && newCfg.Name.Equals(Name))
{
if (args.Command == CfgChangeCmd.CfgChange)
{
printerCfg.Template = newCfg.Template;
printerCfg.PageOrientation = newCfg.PageOrientation;
printerCfg.PaperWidth = newCfg.PaperWidth;
printerCfg.PaperHeight = newCfg.PaperHeight;
printerCfg.ItemsToPrint = newCfg.ItemsToPrint;
printerCfg.FontFamily = newCfg.FontFamily;
printerCfg.FontSize = newCfg.FontSize;
printerCfg.FontStyle = newCfg.FontStyle;
printerCfg.Culture = newCfg.Culture;
printerCfg.NrOfCopies = newCfg.NrOfCopies;
printerCfg.GoodOnly = newCfg.GoodOnly;
printerCfg.BarcodeType = newCfg.BarcodeType;
printerCfg.BarcodeLeft = newCfg.BarcodeLeft;
printerCfg.BarcodeTop = newCfg.BarcodeTop;
printerCfg.BarcodeWidth = newCfg.BarcodeWidth;
printerCfg.BarcodeHeight = newCfg.BarcodeHeight;
ApplyConfig();
}
}
};
}
#endregion Configuration Change Handling
/// <summary>
/// Prints the test cycle results, Events: Event.ResultsPrinted
/// </summary>
/// <param name="batch">Batch results to print</param>
/// <returns>Reference to the operation</returns>
public IOperation ProcessResultsOp(Results.Entities.Batch batch)
{
this.batch = batch;
return this;
}
/// <summary>Start this operation</summary>
public void Start()
{
printingCompleted = false;
statusDlgShown = false;
}
/// <summary>Run this operation</summary>
/// <returns>Event.ResultsPrinted</returns>
public Event Run()
{
string message;
if (printingCompleted || printerCfg.DebugLevel != DebugMode.Normal)
{
return Event.ResultsPrinted;
}
else if (PrinterStatus.IsOnline(printerCfg.PrinterName, out message))
{
if (statusDlgShown)
{
statusDlgShown = false;
if (modelessForm != null) modelessForm.Close();
}
/// Printer is online => Print results now
CultureInfo oriCulture = Thread.CurrentThread.CurrentCulture;
if (printerCfg.Culture != Culture.system)
{
Thread.CurrentThread.CurrentCulture = new CultureInfo(printerCfg.Culture.ToString());
}
foreach (var wm in batch.WaterMeters)
{
if (wm != null && !wm.Disabled && wm.PrintLabel && (!printerCfg.GoodOnly || wm.Passed))
{
PrintResults(wm, string.Format("{0}-{1}", batch.BatchNr, wm.WMPosition));
}
}
Thread.CurrentThread.CurrentCulture = oriCulture;
printingCompleted = true;
return Event.ResultsPrinted;
}
else
{
if (!statusDlgShown)
{
statusDlgShown = true;
modelessForm = new ModelessForm(message);
new Thread(() => System.Windows.Forms.Application.Run(modelessForm)).Start();
}
return Event.Busy;
}
}
/// <summary>Stop this operation</summary>
public void Stop()
{
}
public void PrintResults(Results.Entities.WaterMeter wm, string documentName)
{
LabelPrinterCfg cfg = new LabelPrinterCfg
{
Template = printerCfg.Template,
PageOrientation = printerCfg.PageOrientation,
PaperWidth = printerCfg.PaperWidth,
PaperHeight = printerCfg.PaperHeight,
ItemsToPrint = printerCfg.ItemsToPrint,
FontFamily = printerCfg.FontFamily,
FontSize = printerCfg.FontSize,
FontStyle = printerCfg.FontStyle,
CultureInfo = (printerCfg.Culture == Culture.system) ? Thread.CurrentThread.CurrentCulture : new CultureInfo(printerCfg.Culture.ToString()),
GoodOnly = printerCfg.GoodOnly,
BarcodeType = printerCfg.BarcodeType,
BarcodeLeft = printerCfg.BarcodeLeft,
BarcodeTop = printerCfg.BarcodeTop,
BarcodeWidth = printerCfg.BarcodeWidth,
BarcodeHeight = printerCfg.BarcodeHeight,
};
for (int i = 1; i <= printerCfg.NrOfCopies; i++)
{
string docNameEx = string.Format((printerCfg.NrOfCopies == 1) ? "{0}" : "{0}_{1}", documentName, i);
var pd = new LabelPrintDocument(cfg, wm, docNameEx);
if (!string.IsNullOrEmpty(printerCfg.PrinterName)) pd.PrinterSettings.PrinterName = printerCfg.PrinterName;
pd.Print();
}
}
}
}
@@ -0,0 +1,80 @@
///
/// Copyright (c) 2015-2023 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using System.IO;
using System.Xml.Serialization;
using Common;
using TBF.Rig.Generic;
namespace TBF.Rig.Output.Printers.GroupPrinting.Single
{
public class PrinterCfg : ComponentCfgBase, Generic.IComponentCfg
{
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(PrinterCfg) })[0];
public override XmlSerializer GetSerializer() { return Serializer; }
public IComponentCfgCtrl GetControl(IList<Config.Entities.Component> cmpntEntities) { return new PrinterCfgCtrl(); }
///
/// Serialized parameters
///
public string PrinterName;
public string Template; /// Full path to a 'png' file
public PageOrientation PageOrientation;
public int PaperWidth; /// In 0,254 mm = 1/100 in = 100dpi pixels count
public int PaperHeight; /// In 0,254 mm = 1/100 in = 100dpi pixels count
public string[] ItemsToPrint;
public string FontFamily;
public int FontSize;
public int FontStyle;
public Culture Culture;
public int NrOfCopies;
public bool GoodOnly;
public Results.Output.Printers.BarcodeType BarcodeType;
public int BarcodeLeft;
public int BarcodeTop;
public int BarcodeWidth;
public int BarcodeHeight;
/// Private parameterless constructor invoked by all other (public) constructors
PrinterCfg()
{
}
public PrinterCfg(string name, IComponentFactory factory)
: this()
{
this.Name = name;
this.Factory = factory;
ParentName = string.Empty;
Template = string.Empty;
PageOrientation = PageOrientation.Portrait;
PaperWidth = 827; /// A4 width
PaperHeight = 1169; /// A4 height
FontFamily = "Arial";
FontSize = 10;
FontStyle = 0;
NrOfCopies = 1;
GoodOnly = false;
BarcodeType = Results.Output.Printers.BarcodeType.None;
}
public string ToString(int i)
{
return string.Format("Name={0}, Orientation={1}, PaperWidth={2}, PaperHeight={3}, TemplateFile={4}, GoodOnly={5}, Barcode={6}",
Name,
PageOrientation,
PaperWidth,
PaperHeight,
Template,
GoodOnly ? "yes" : "no",
BarcodeType.ToString()
);
}
}
}
@@ -0,0 +1,292 @@
///
/// Copyright (c) 2015-2023 Sensus Slovensko a.s.
///
using System;
using System.Collections;
using System.Collections.Generic;
using System.Drawing.Printing;
using System.IO;
using System.Linq;
using System.Windows.Forms;
using log4net;
using Common;
using Config.Entities;
using FluentNHibernate.Conventions;
using log4net.Repository.Hierarchy;
using NHibernate;
using TBF.Resources;
using TBF.Rig.Generic;
using TBF.Rig.Configs;
namespace TBF.Rig.Output.Printers.GroupPrinting.Single
{
public partial class PrinterCfgCtrl : ConfigCtrlUtils, IComponentCfgCtrl
{
static readonly ILog log = LogManager.GetLogger(typeof(PrinterCfgCtrl));
public bool ShowMore
{
get { return false; }
}
IList<Component> cmpntEntities;
private ISession session;
PrinterCfg config;
public IComponentCfg Config
{
get { return config as IComponentCfg; }
set
{
config = value as PrinterCfg;
Redraw();
}
}
List<string> itemsToPrint;
public PrinterCfgCtrl()
{
InitializeComponent();
Localize();
}
private void PrinterCfgCtrl_Load(object sender, EventArgs e)
{
printerComboBox.Items.Add(Strings.default_printer);
foreach (var p in PrinterSettings.InstalledPrinters) printerComboBox.Items.Add(p);
EnableEdit(false);
InintComponents();
Redraw();
}
void Localize()
{
}
public void Closing()
{
// if (printerComboBox.Enabled && !printerComboBox.Text.IsEmpty())
// {
// GroupPrinterUtils.UpdateParametersInEntitys(session, cmpntEntities, printerComboBox.Text);
// }
}
void InintComponents()
{
cmpntEntities = cmpntEntities == null ? new List<Component>() : cmpntEntities;
itemsToPrint = config.ItemsToPrint?.ToList();
session = GroupPrinterUtils.GetCorrespondedEntities(in cmpntEntities, in itemsToPrint);
RedrawAll();
}
void Redraw()
{
if (config == null) return; /// Control was not loaded, settings were not changed
classNameLabel.Text = config.Factory.ClassName;
nameTextBox.Text = config.Name;
printerComboBox.Text =
string.IsNullOrEmpty(config.PrinterName) ? Strings.default_printer : config.PrinterName;
}
public void Unlock()
{
EnableEdit(true);
}
private void EnableEdit(bool bEnable)
{
nameTextBox.Enabled = bEnable;
printerComboBox.Enabled = bEnable;
selectPrinterButton.Enabled = bEnable;
btListAdd.Enabled = bEnable;
btListRemove.Enabled = bEnable;
btMoveUp.Enabled = bEnable;
btMoveDown.Enabled = bEnable;
listViewEx.Enabled = bEnable;
}
public CfgUpdateFlags VerifyCfg(ref string message)
{
CfgUpdateFlags flags = CfgUpdateFlags.None;
return flags;
}
public CfgUpdateFlags UpdateCfg()
{
CfgUpdateFlags flags = CfgUpdateFlags.None;
if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed
if (config.Name != nameTextBox.Text)
{
config.Name = nameTextBox.Text;
flags |= (CfgUpdateFlags.RestartRqrd | CfgUpdateFlags.AnyChange);
}
string newPrinter = (printerComboBox.Text == Strings.default_printer) ? string.Empty : printerComboBox.Text;
if (config.PrinterName != newPrinter)
{
config.PrinterName = newPrinter;
flags |= (CfgUpdateFlags.RestartRqrd | CfgUpdateFlags.AnyChange);
}
if ((flags & CfgUpdateFlags.InvokeCfgChange) != 0)
{
Printer.OnCfgChange(this, new CfgChangeArgs(CfgChangeCmd.CfgChange, config));
}
List<string> itemsComponent = new List<string>();
foreach (Component entity in cmpntEntities)
{
itemsComponent.Add(PrinterDef.fromComponent(entity).ToString());
}
config.ItemsToPrint = itemsComponent.ToArray();
return flags;
}
#region Configuration Change Handling
public static void OnCmdResponse(object sender, CmdResponseArgs args)
{
if (CmdResponseHandler == null) return;
try
{
CmdResponseHandler(sender, args);
}
catch (Exception e)
{
log.Error("CmdResponseHandler(...) failed", e);
}
}
public static event EventHandler<CmdResponseArgs> CmdResponseHandler;
public void StartResponseHandler()
{
}
public void StopResponseHandler()
{
}
#endregion Configuration Change Handling
private void selectPrinterButton_Click(object sender, EventArgs e)
{
PrintDialog dlg = new PrintDialog();
if (dlg.ShowDialog() == DialogResult.OK)
{
printerComboBox.Text = dlg.PrinterSettings.PrinterName;
}
}
private void btListAdd_Click(object sender, EventArgs e)
{
PrinterTestBenchComponentSelectorDlg dlg = new PrinterTestBenchComponentSelectorDlg();
if (dlg.ShowDialog() == DialogResult.OK)
{
if (cmpntEntities == null)
{
cmpntEntities = new List<Component>();
}
else
{
if (cmpntEntities.Any(com => com.ItemNr == dlg.SelectedComponent.ItemNr))
{
MessageBox.Show("Item is in list included already!", "Warning", MessageBoxButtons.OK,
MessageBoxIcon.Warning);
return;
}
}
cmpntEntities.Add(dlg.SelectedComponent);
RedrawAll();
}
}
void RedrawAll()
{
listViewEx.Items.Clear();
foreach (var cmpnt in cmpntEntities) DrawOne(cmpnt);
}
void DrawOne(Component cmpnt)
{
ListViewItem lvi = new ListViewItem(cmpnt.ItemNr.ToString());
lvi.Tag = cmpnt;
lvi.SubItems.Add(cmpnt.Name);
listViewEx.Items.Add(lvi);
}
////////////////////////
private void btListRemove_Click(object sender, EventArgs e)
{
if (listViewEx.SelectedItems.Count > 0)
{
int selectedIndex = listViewEx.SelectedIndices[0];
Component cmpntEntity = cmpntEntities[selectedIndex];
if (MessageBox.Show($"Do you want remove {cmpntEntity.Name} from list?", "Remove Action",
MessageBoxButtons.YesNo,
MessageBoxIcon.Warning) == DialogResult.Yes)
{
cmpntEntities.Remove(cmpntEntity);
listViewEx.Items.RemoveAt(selectedIndex);
}
}
}
private void btMoveUp_Click(object sender, EventArgs e)
{
if (listViewEx.SelectedItems.Count > 0)
{
int selectedIndex = listViewEx.SelectedIndices[0];
if (selectedIndex > 0)
{
int newItemIndex = (selectedIndex - 1);
Component cmpntEntity = cmpntEntities[selectedIndex];
cmpntEntities.Insert(newItemIndex, cmpntEntity);
cmpntEntities.RemoveAt(selectedIndex + 1);
RedrawAll();
listViewEx.Items[newItemIndex].Selected = true;
}
}
}
private void btMoveDown_Click(object sender, EventArgs e)
{
if (listViewEx.SelectedItems.Count > 0)
{
int selectedIndex = listViewEx.SelectedIndices[0];
if (selectedIndex < listViewEx.Items.Count - 1)
{
Component cmpntEntity = cmpntEntities[selectedIndex];
int newItemIndex = selectedIndex + 2;
cmpntEntities.Insert(newItemIndex, cmpntEntity);
cmpntEntities.RemoveAt(selectedIndex);
RedrawAll();
listViewEx.Items[newItemIndex - 1].Selected = true;
}
}
}
}
}
@@ -0,0 +1,228 @@
///
/// Copyright (c) 2015-2020 Sensus Slovensko a.s.
///
namespace TBF.Rig.Output.Printers.GroupPrinting.Single
{
partial class PrinterCfgCtrl
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.nameTextBox = new System.Windows.Forms.TextBox();
this.nameLabel = new System.Windows.Forms.Label();
this.classNameLabel = new System.Windows.Forms.Label();
this.printerComboBox = new System.Windows.Forms.ComboBox();
this.selectPrinterButton = new System.Windows.Forms.Button();
this.printerLabel = new System.Windows.Forms.Label();
this.listViewEx = new Common.Forms.ListViewEx();
this.columnItem = new System.Windows.Forms.ColumnHeader();
this.columnName = new System.Windows.Forms.ColumnHeader();
this.btListAdd = new System.Windows.Forms.Button();
this.btListRemove = new System.Windows.Forms.Button();
this.label3 = new System.Windows.Forms.Label();
this.btMoveUp = new System.Windows.Forms.Button();
this.btMoveDown = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// nameTextBox
//
this.nameTextBox.Enabled = false;
this.nameTextBox.Location = new System.Drawing.Point(183, 63);
this.nameTextBox.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.nameTextBox.Name = "nameTextBox";
this.nameTextBox.Size = new System.Drawing.Size(340, 26);
this.nameTextBox.TabIndex = 2;
//
// nameLabel
//
this.nameLabel.AutoSize = true;
this.nameLabel.Location = new System.Drawing.Point(12, 68);
this.nameLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.nameLabel.Name = "nameLabel";
this.nameLabel.Size = new System.Drawing.Size(51, 20);
this.nameLabel.TabIndex = 1;
this.nameLabel.Text = "Name";
//
// classNameLabel
//
this.classNameLabel.AutoSize = true;
this.classNameLabel.Location = new System.Drawing.Point(178, 26);
this.classNameLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.classNameLabel.Name = "classNameLabel";
this.classNameLabel.Size = new System.Drawing.Size(92, 20);
this.classNameLabel.TabIndex = 0;
this.classNameLabel.Text = "Class name";
//
// printerComboBox
//
this.printerComboBox.Enabled = false;
this.printerComboBox.FormattingEnabled = true;
this.printerComboBox.Location = new System.Drawing.Point(183, 98);
this.printerComboBox.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.printerComboBox.Name = "printerComboBox";
this.printerComboBox.Size = new System.Drawing.Size(340, 28);
this.printerComboBox.TabIndex = 59;
//
// selectPrinterButton
//
this.selectPrinterButton.Enabled = false;
this.selectPrinterButton.Location = new System.Drawing.Point(105, 97);
this.selectPrinterButton.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.selectPrinterButton.Name = "selectPrinterButton";
this.selectPrinterButton.Size = new System.Drawing.Size(75, 34);
this.selectPrinterButton.TabIndex = 58;
this.selectPrinterButton.Text = "Select";
this.selectPrinterButton.UseVisualStyleBackColor = true;
this.selectPrinterButton.Click += new System.EventHandler(this.selectPrinterButton_Click);
//
// printerLabel
//
this.printerLabel.AutoSize = true;
this.printerLabel.Location = new System.Drawing.Point(12, 103);
this.printerLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.printerLabel.Name = "printerLabel";
this.printerLabel.Size = new System.Drawing.Size(55, 20);
this.printerLabel.TabIndex = 57;
this.printerLabel.Text = "Printer";
//
// listViewEx
//
this.listViewEx.AllowColumnReorder = true;
this.listViewEx.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { this.columnItem, this.columnName });
this.listViewEx.DoubleClickActivation = false;
this.listViewEx.FullRowSelect = true;
this.listViewEx.HideSelection = false;
this.listViewEx.Location = new System.Drawing.Point(183, 136);
this.listViewEx.Name = "listViewEx";
this.listViewEx.Size = new System.Drawing.Size(340, 344);
this.listViewEx.TabIndex = 60;
this.listViewEx.UseCompatibleStateImageBehavior = false;
this.listViewEx.View = System.Windows.Forms.View.Details;
//
// columnItem
//
this.columnItem.Text = "No";
this.columnItem.Width = 40;
//
// columnName
//
this.columnName.Text = "Name";
this.columnName.Width = 321;
//
// btListAdd
//
this.btListAdd.Location = new System.Drawing.Point(24, 165);
this.btListAdd.Name = "btListAdd";
this.btListAdd.Size = new System.Drawing.Size(115, 30);
this.btListAdd.TabIndex = 61;
this.btListAdd.Text = "Add";
this.btListAdd.UseVisualStyleBackColor = true;
this.btListAdd.Click += new System.EventHandler(this.btListAdd_Click);
//
// btListRemove
//
this.btListRemove.Location = new System.Drawing.Point(24, 201);
this.btListRemove.Name = "btListRemove";
this.btListRemove.Size = new System.Drawing.Size(115, 30);
this.btListRemove.TabIndex = 62;
this.btListRemove.Text = "Remove";
this.btListRemove.UseVisualStyleBackColor = true;
this.btListRemove.Click += new System.EventHandler(this.btListRemove_Click);
//
// label3
//
this.label3.Location = new System.Drawing.Point(12, 136);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(166, 26);
this.label3.TabIndex = 63;
this.label3.Text = "List of Print Assembly";
//
// btMoveUp
//
this.btMoveUp.Location = new System.Drawing.Point(24, 237);
this.btMoveUp.Name = "btMoveUp";
this.btMoveUp.Size = new System.Drawing.Size(115, 30);
this.btMoveUp.TabIndex = 64;
this.btMoveUp.Text = "Move Up";
this.btMoveUp.UseVisualStyleBackColor = true;
this.btMoveUp.Click += new System.EventHandler(this.btMoveUp_Click);
//
// btMoveDown
//
this.btMoveDown.Location = new System.Drawing.Point(24, 273);
this.btMoveDown.Name = "btMoveDown";
this.btMoveDown.Size = new System.Drawing.Size(115, 30);
this.btMoveDown.TabIndex = 65;
this.btMoveDown.Text = "Move Down";
this.btMoveDown.UseVisualStyleBackColor = true;
this.btMoveDown.Click += new System.EventHandler(this.btMoveDown_Click);
//
// PrinterCfgCtrl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.btMoveDown);
this.Controls.Add(this.btMoveUp);
this.Controls.Add(this.label3);
this.Controls.Add(this.btListRemove);
this.Controls.Add(this.btListAdd);
this.Controls.Add(this.listViewEx);
this.Controls.Add(this.printerComboBox);
this.Controls.Add(this.selectPrinterButton);
this.Controls.Add(this.printerLabel);
this.Controls.Add(this.nameTextBox);
this.Controls.Add(this.nameLabel);
this.Controls.Add(this.classNameLabel);
this.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.Name = "PrinterCfgCtrl";
this.Size = new System.Drawing.Size(558, 593);
this.Load += new System.EventHandler(this.PrinterCfgCtrl_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
private System.Windows.Forms.Button btMoveUp;
private System.Windows.Forms.Button btMoveDown;
private System.Windows.Forms.ColumnHeader columnItem;
private System.Windows.Forms.ColumnHeader columnName;
private System.Windows.Forms.Label label3;
private Common.Forms.ListViewEx listViewEx;
private System.Windows.Forms.Button btListAdd;
private System.Windows.Forms.Button btListRemove;
#endregion
private System.Windows.Forms.TextBox nameTextBox;
private System.Windows.Forms.Label nameLabel;
private System.Windows.Forms.Label classNameLabel;
private System.Windows.Forms.ComboBox printerComboBox;
private System.Windows.Forms.Button selectPrinterButton;
private System.Windows.Forms.Label printerLabel;
}
}
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
@@ -0,0 +1,95 @@
using System;
using System.Collections.Generic;
using System.Xml;
using Config.Entities;
using log4net;
namespace TBF.Rig.Output.Printers.GroupPrinting.Single
{
public class PrinterDef
{
static readonly ILog log = LogManager.GetLogger(typeof(PrinterCfgCtrl));
public String Name { get; set; }
public String ObjName { get; set; }
public override bool Equals(object obj)
{
if (obj == null || !(obj is PrinterDef))
{
return false;
}
return Name.Equals(((PrinterDef)obj).Name) &&
ObjName.Equals(((PrinterDef)obj).ObjName);
}
public override string ToString()
{
return $"{Name}:{ObjName}";
}
public Component toComponent(IList<Component> components)
{
foreach (Component component in components)
{
if (component.Name.Equals(Name) && component.ClassName.Equals(ObjName))
{
return component;
}
}
return null;
}
public static PrinterDef fromString(string formated)
{
try
{
PrinterDef printerDef = new PrinterDef();
string[] spliteStrings = formated.Split(':');
printerDef.Name = spliteStrings[0];
printerDef.ObjName = spliteStrings[1];
return printerDef;
}
catch (Exception e)
{
log.Error(e.StackTrace);
}
return null;
}
public static List<PrinterDef> fromParametersString(string parameters)
{
List<PrinterDef> printerDefs = new List<PrinterDef>();
// we have group printer
XmlDocument xmlDocument = new XmlDocument();
xmlDocument.LoadXml(parameters);
XmlNodeList printerCfg = xmlDocument.GetElementsByTagName("ItemsToPrint");
// Extract the text content of each <string> element within ItemsToPrint
List<string> itemsToPrint = new List<string>();
foreach (XmlNode itemNode in printerCfg)
{
// Process each "ItemsToPrint" element here
foreach (XmlNode itemToPrint in itemNode.ChildNodes)
{
if (itemToPrint.NodeType == XmlNodeType.Element && itemToPrint.Name == "string")
{
printerDefs.Add(PrinterDef.fromString(itemToPrint.InnerText));
}
}
}
return printerDefs;
}
public static PrinterDef fromComponent(Component component)
{
PrinterDef printerDef = new PrinterDef();
printerDef.Name = component.Name;
printerDef.ObjName = component.ClassName;
return printerDef;
}
}
}
@@ -0,0 +1,125 @@
using System.ComponentModel;
namespace TBF.Rig.Output.Printers.GroupPrinting.Single
{
partial class PrinterTestBenchComponentSelectorDlg
{
/// <summary>
/// Required designer variable.
/// </summary>
private 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.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.listViewEx = new Common.Forms.ListViewEx();
this.btSelect = new System.Windows.Forms.Button();
this.btCancel = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
this.splitContainer1.SuspendLayout();
this.SuspendLayout();
//
// splitContainer1
//
this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer1.FixedPanel = System.Windows.Forms.FixedPanel.Panel2;
this.splitContainer1.IsSplitterFixed = true;
this.splitContainer1.Location = new System.Drawing.Point(0, 0);
this.splitContainer1.Name = "splitContainer1";
//
// splitContainer1.Panel1
//
this.splitContainer1.Panel1.Controls.Add(this.listViewEx);
//
// splitContainer1.Panel2
//
this.splitContainer1.Panel2.Controls.Add(this.btCancel);
this.splitContainer1.Panel2.Controls.Add(this.btSelect);
this.splitContainer1.Size = new System.Drawing.Size(926, 471);
this.splitContainer1.SplitterDistance = 732;
this.splitContainer1.TabIndex = 0;
//
// listViewEx
//
this.listViewEx.AllowColumnReorder = true;
this.listViewEx.Dock = System.Windows.Forms.DockStyle.Fill;
this.listViewEx.DoubleClickActivation = false;
this.listViewEx.FullRowSelect = true;
this.listViewEx.HideSelection = false;
this.listViewEx.Location = new System.Drawing.Point(0, 0);
this.listViewEx.Name = "listViewEx";
this.listViewEx.Size = new System.Drawing.Size(732, 471);
this.listViewEx.TabIndex = 0;
this.listViewEx.UseCompatibleStateImageBehavior = false;
this.listViewEx.View = System.Windows.Forms.View.Details;
//
// btSelect
//
this.btSelect.Location = new System.Drawing.Point(30, 12);
this.btSelect.Name = "btSelect";
this.btSelect.Size = new System.Drawing.Size(135, 60);
this.btSelect.TabIndex = 0;
this.btSelect.Text = "Select";
this.btSelect.UseVisualStyleBackColor = true;
this.btSelect.Click += new System.EventHandler(this.btSelect_Click);
//
// btCancel
//
this.btCancel.Location = new System.Drawing.Point(32, 89);
this.btCancel.Name = "btCancel";
this.btCancel.Size = new System.Drawing.Size(132, 53);
this.btCancel.TabIndex = 1;
this.btCancel.Text = "Cancel";
this.btCancel.UseVisualStyleBackColor = true;
this.btCancel.Click += new System.EventHandler(this.btCancel_Click);
//
// PrinterTestBenchComponentSelectorDlg
//
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.SystemColors.Control;
this.ClientSize = new System.Drawing.Size(926, 471);
this.Controls.Add(this.splitContainer1);
this.Location = new System.Drawing.Point(15, 15);
this.Name = "PrinterTestBenchComponentSelectorDlg";
this.Load += new System.EventHandler(this.PrinterTestBenchComponentSelectorDlg_Load);
this.splitContainer1.Panel1.ResumeLayout(false);
this.splitContainer1.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
this.splitContainer1.ResumeLayout(false);
this.ResumeLayout(false);
}
private System.Windows.Forms.Button btCancel;
private System.Windows.Forms.Button btSelect;
private Common.Forms.ListViewEx listViewEx;
private System.Windows.Forms.SplitContainer splitContainer1;
#endregion
}
}
@@ -0,0 +1,192 @@
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using Common;
using Config.Entities;
using log4net;
using NHibernate;
using TBF.Resources;
using TBF.Rig.Generic;
namespace TBF.Rig.Output.Printers.GroupPrinting.Single
{
public partial class PrinterTestBenchComponentSelectorDlg : Form
{
static readonly ILog log = LogManager.GetLogger(typeof(PrinterTestBenchComponentSelectorDlg));
/// <summary>
/// List of components (=component configuration instances)
/// </summary>
IList<Component> cmpntEntities;
public Component SelectedComponent { get; set; }
ISession session;
MySortOrder sortOrder = MySortOrder.Ascending;
int sortColumn = -1; /// 0-based index of column to be used for sorting
public PrinterTestBenchComponentSelectorDlg()
{
InitializeComponent();
}
private void LoadFormPosition()
{
LocalSettings ls = Program.LocalSettings;
Width = (ls.ComponentsDlgWidth > 0) ? ls.ComponentsDlgWidth : 850;
Height = (ls.ComponentsDlgHeight > 0) ? ls.ComponentsDlgHeight : 500;
Left = (ls.ComponentsDlgLeft != 0) ? ls.ComponentsDlgLeft : 200;
Top = (ls.ComponentsDlgTop != 0) ? ls.ComponentsDlgTop : 100;
}
/// <summary>
/// Save the dialog position and ListViewEx column widths
/// </summary>
void SaveUISettings()
{
/// Obtain ComponentsmanagerDlg dimensions, etc.
bool isMaximized = (WindowState == FormWindowState.Maximized);
int left = (WindowState == FormWindowState.Normal) ? Location.X : RestoreBounds.Left;
int top = (WindowState == FormWindowState.Normal) ? Location.Y : RestoreBounds.Top;
int width = (WindowState == FormWindowState.Normal) ? Size.Width : RestoreBounds.Width;
int height = (WindowState == FormWindowState.Normal) ? Size.Height : RestoreBounds.Height;
LocalSettings ls = Program.LocalSettings;
/// Compare list view column widths with the saved ones
bool anyColumnDiffers = false;
// if ((int)Column.ColumnsCount != ls.ComponentsColumnCount)
// {
// anyColumnDiffers = true;
// }
// else
// {
// for (int i = 0; i < (int)Column.ColumnsCount; i++)
// {
// if (listViewEx.Columns[i].Width != ls.ComponentsColumnWidths[i]) { anyColumnDiffers = true; break; }
// }
// }
if (ls != null && (ls.ComponentsDlgMaximized != isMaximized ||
ls.ComponentsDlgLeft != left ||
ls.ComponentsDlgTop != top ||
ls.ComponentsDlgWidth != width ||
ls.ComponentsDlgHeight != height ||
anyColumnDiffers))
{
/// At least one ComponentsManagerDlg dimension differs => Update local settings and save them
///
ls.ComponentsDlgMaximized = isMaximized;
ls.ComponentsDlgLeft = left;
ls.ComponentsDlgTop = top;
ls.ComponentsDlgWidth = width;
ls.ComponentsDlgHeight = height;
/// List view column widths
// ls.ComponentsColumnWidths = new int[(int)Column.ColumnsCount];
// for (int i = 0; i < (int)Column.ColumnsCount; i++)
// {
// ls.ComponentsColumnWidths[i] = listViewEx.Columns[i].Width;
// }
ls.Save();
}
}
private void btSelect_Click(object sender, EventArgs e)
{
if (listViewEx.SelectedItems.Count > 0)
{
SelectedComponent = cmpntEntities[listViewEx.SelectedIndices[0]];
this.DialogResult = DialogResult.OK;
this.Close();
}
else
{
MessageBox.Show("No Selection", "Selection", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void PrinterTestBenchComponentSelectorDlg_Load(object sender, EventArgs e)
{
LoadFormPosition();
LocalSettings ls = Program.LocalSettings;
listViewEx.Columns.Add(Strings.Nr, (ls.ComponentsColumnCount > 0) ? ls.ComponentsColumnWidths[0] : 40);
listViewEx.Columns.Add(Strings.Name, (ls.ComponentsColumnCount > 1) ? ls.ComponentsColumnWidths[1] : 80);
listViewEx.Columns.Add(Strings.Type, (ls.ComponentsColumnCount > 2) ? ls.ComponentsColumnWidths[2] : 120);
listViewEx.Columns.Add(Strings.Parent, (ls.ComponentsColumnCount > 3) ? ls.ComponentsColumnWidths[3] : 55);
listViewEx.Columns.Add(Strings.Parameters, (ls.ComponentsColumnCount > 6) ? ls.ComponentsColumnWidths[6] : 600);
listViewEx.HeaderStyle = ColumnHeaderStyle.Clickable;
GetEntities();
RedrawAll();
}
private void GetEntities()
{
session = TBF.DB.CreateSession(DBKind.Config);
IList<Component> cmpntEntitiesAll = session.QueryOver<Component>()
.OrderBy(x => x.ItemNr).Asc
.List<Component>();
if (cmpntEntities == null)
{
cmpntEntities = new List<Component>();
}
else
{
cmpntEntities.Clear();
}
foreach (var component in cmpntEntitiesAll)
{
if (component.ClassName.StartsWith("Output.Printers.OnePerMeter"))
{
cmpntEntities.Add(component);
}
}
}
void RedrawAll()
{
listViewEx.Items.Clear();
foreach (var cmpnt in cmpntEntities) DrawOne(cmpnt);
}
void DrawOne(Component cmpnt)
{
ListViewItem lvi = new ListViewItem(cmpnt.ItemNr.ToString());
lvi.Tag = cmpnt;
lvi.SubItems.Add(cmpnt.Name);
lvi.SubItems.Add(string.IsNullOrEmpty(cmpnt.ClassName) ? string.Empty : cmpnt.ClassName);
lvi.SubItems.Add(string.IsNullOrEmpty(cmpnt.Parent) ? string.Empty : cmpnt.Parent);
IComponentCfg cmpCfg = TbfComponents.CmpntCfgFromCmpntEntity(cmpnt);
if (cmpCfg != null)
{
lvi.SubItems.Add(cmpCfg.ToString(-1));
}
else
{
lvi.SubItems.Add("Not a component");
}
listViewEx.Items.Add(lvi);
}
private void btCancel_Click(object sender, EventArgs e)
{
SaveUISettings();
SelectedComponent = null;
this.DialogResult = DialogResult.Cancel;
this.Close();
}
}
}
@@ -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>
@@ -182,7 +182,7 @@ namespace TBF.Rig.RegisterReaders.DataStream.Reader
endWMState = VolumeLtrEnd;
wmVolume = Math.Abs(VolumeLtrEnd - VolumeLtrStart);
wmPulses = (int)Math.Round(wmVolume * PulsesPerLtr);
wmRefPulses = StateMachine.ControlBoard.RefPulses;
wmRefPulses = StateMachine.ControlBoardMain.RefPulses;
log.DebugFormat("Stop() ... Position={0}, wmVolume={1}, wmPulses={2}, wmRefPulses={3}", Position, wmVolume, wmPulses, wmRefPulses);
}
}
@@ -0,0 +1,24 @@
using System.Collections.Generic;
using Config.Entities;
using TBF.Rig.Generic;
namespace TBF.Rig.RegisterReaders.FrequencyMeterFromUniCB
{
public class Factory : IComponentFactory
{
public string ClassName { get { return GetType().Namespace.Substring(8); } }
public override string ToString() { return ClassName; }
public IComponent DummyComponent() { return new FrequencyRegisterReader(); }
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new FrequencyRegisterReader(cfg, components); }
public IComponentCfg DefaultConfig() { return new RRCfg("Frequency", this); }
public IComponentCfg CmpntCfgFromCmpntEntity(Component component)
{
return ComponentCfgBase.CreateFromDbEntity(RRCfg.Serializer, component, this);
}
}
}
@@ -0,0 +1,47 @@
using System;
using System.Collections.Generic;
using Common;
using log4net;
using TBF.Rig.GenericDevices;
namespace TBF.Rig.RegisterReaders.FrequencyMeterFromUniCB
{
public class FrequencyRegisterReader : ComponentBase, GenericDevices.IRegReader
{
private static readonly ILog log = LogManager.GetLogger(typeof(FrequencyRegisterReader));
public override string ToString() { return string.Format("{0}({1})", ClassName, Cfg.ToString(-1)); }
readonly RRCfg rrCfg;
readonly TBF.Rig.ControlBoard.IControlBoard cb;
public int Position { get{ return rrCfg.Position; } }
public Common.RegisterReaderType RegisterReaderType { get { return Common.RegisterReaderType.Pulses; } }
public double PulsesPerLtr { get { return rrCfg.ProcParams.PulsesPerLtr; } }
public double LtrsPerPulse { get { return (PulsesPerLtr <= float.Epsilon) ? 1.0 : (1 / PulsesPerLtr); ; } }
public int Filter { get { return rrCfg.ProcParams.Filter; } }
public int WMPulses { get { return cb.PulsesWM(Position); } }
public int WMRefPulses { get { return cb.RefPulsesWM(Position); } }
public double WMVolume { get { return LtrsPerPulse * Convert.ToDouble(WMPulses); } }
public double BeginWMState { get { return 0; } } /// Always 0
public double EndWMState { get { return WMVolume; } } /// Derived from WMVolume
public FrequencyRegisterReader() { }
public FrequencyRegisterReader(Generic.IComponentCfg cfg, IList<Generic.IComponent> components)
: base(cfg)
{
rrCfg = cfg as RRCfg;
cb = TbfComponents.FindComponent(cfg.ParentName, components) as TBF.Rig.ControlBoard.IControlBoard;
if (cb == null) throw new Exception("Cannot find " + Name + " parent");
log.Warn(this.ToString());
}
public override void Initialize() { }
}
}
@@ -0,0 +1,51 @@
using System.Collections.Generic;
using System.Xml.Serialization;
using Common;
using Config.Entities;
using TBF.Rig.Generic;
namespace TBF.Rig.RegisterReaders.FrequencyMeterFromUniCB
{
public class RRCfg : ComponentCfgBase, Generic.IChildComponentCfg
{
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(RRCfg) })[0];
public override XmlSerializer GetSerializer() { return Serializer; }
IComponentCfgCtrl IComponentCfg.GetControl(IList<Component> cmpntEntities) { return new RRCfgCtrl(); }
///
/// Serialized parameters
///
public int Position; /// 1..nrWaterMeters
/// <summary> Procedure parameters </summary>
[XmlIgnore]
public RRProcParams ProcParams;
public override IParamsProvider GetRuntimeProcParamsProvider() { return ProcParams; }
public override IParamsProvider CreateProcParamsProvider() { return new RRProcParams(true); }
/// Private parameterless constructor invoked by all other (public) constructors
RRCfg()
{
ProcParams = new RRProcParams(true);
}
public RRCfg(string name, IComponentFactory factory)
: this()
{
Name = name;
Factory = factory;
ParentName = "UniCB";
Position = 1;
}
string IComponentCfg.ToString(int i)
{
return string.Format("Name={0}, Parent={1}, Position={2}",
Name,
(string.IsNullOrEmpty(ParentName) ? "-" : ParentName),
Position);
}
}
}
@@ -0,0 +1,106 @@
///
/// Copyright (c) 2021 Sensus Slovensko a.s.
///
using System;
using System.Windows.Forms;
using Common;
using TBF.Rig.Generic;
using TBF.UI.Bench.Components;
namespace TBF.Rig.RegisterReaders.FrequencyMeterFromUniCB
{
public partial class RRCfgCtrl : UserControl, IComponentCfgCtrl
{
ComponentParametersDlg parent;
bool IComponentCfgCtrl.ShowMore { get { return false; } }
RRCfg config;
IComponentCfg IComponentCfgCtrl.Config
{
get { return config as IComponentCfg; }
set
{
config = value as RRCfg;
Redraw();
}
}
public RRCfgCtrl()
{
InitializeComponent();
}
private void RegisterReaderCfgCtrl_Load(object sender, EventArgs e)
{
parent = ParentForm as ComponentParametersDlg;
if (parent == null) return;
if (parent.CmpntEntities != null)
{
foreach (var cmpnt in parent.CmpntEntities)
{
if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is ControlBoard.Uni.Factory)
{
parentNameComboBox.Items.Add(cmpnt.Name);
}
}
}
Redraw();
}
void IComponentCfgCtrl.Closing()
{
}
void Redraw()
{
if (config == null) return; /// Control was not loaded, settings were not changed
componentNameLabel.Text = config.Factory.ClassName;
nameTextBox.Text = config.Name;
parentNameComboBox.Text = string.IsNullOrEmpty(config.ParentName) ? "---" : config.ParentName;
positionTextBox.Text = config.Position.ToString();
}
void IComponentCfgCtrl.Unlock()
{
nameTextBox.Enabled = true;
parentNameComboBox.Enabled = true;
positionTextBox.Enabled = true;
}
CfgUpdateFlags IComponentCfgCtrl.VerifyCfg(ref string message)
{
CfgUpdateFlags flags = CfgUpdateFlags.None;
int dummy;
if (!parentNameComboBox.Items.Contains(parentNameComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Invalid 'Parent Name'";
}
if (!int.TryParse(positionTextBox.Text, out dummy) || (dummy < 1))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'Position' should be >= 1";
}
return flags;
}
CfgUpdateFlags IComponentCfgCtrl.UpdateCfg()
{
CfgUpdateFlags flags = CfgUpdateFlags.RestartRqrd;
if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed
config.Name = nameTextBox.Text;
config.ParentName = parentNameComboBox.Text.Equals("---") ? string.Empty : parentNameComboBox.Text;
config.Position = int.Parse(positionTextBox.Text);
return flags;
}
}
}
@@ -0,0 +1,133 @@
///
/// Copyright (c) 2021 Sensus Slovensko a.s.
///
namespace TBF.Rig.RegisterReaders.FrequencyMeterFromUniCB
{
partial class RRCfgCtrl
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.positionTextBox = new System.Windows.Forms.TextBox();
this.positionLabel = new System.Windows.Forms.Label();
this.parentNameLabel = new System.Windows.Forms.Label();
this.nameTextBox = new System.Windows.Forms.TextBox();
this.nameLabel = new System.Windows.Forms.Label();
this.componentNameLabel = new System.Windows.Forms.Label();
this.parentNameComboBox = new System.Windows.Forms.ComboBox();
this.SuspendLayout();
//
// positionTextBox
//
this.positionTextBox.Enabled = false;
this.positionTextBox.Location = new System.Drawing.Point(136, 119);
this.positionTextBox.Name = "positionTextBox";
this.positionTextBox.Size = new System.Drawing.Size(46, 20);
this.positionTextBox.TabIndex = 6;
//
// positionLabel
//
this.positionLabel.AutoSize = true;
this.positionLabel.Location = new System.Drawing.Point(26, 122);
this.positionLabel.Name = "positionLabel";
this.positionLabel.Size = new System.Drawing.Size(44, 13);
this.positionLabel.TabIndex = 5;
this.positionLabel.Text = "Position";
//
// parentNameLabel
//
this.parentNameLabel.AutoSize = true;
this.parentNameLabel.Location = new System.Drawing.Point(26, 96);
this.parentNameLabel.Name = "parentNameLabel";
this.parentNameLabel.Size = new System.Drawing.Size(69, 13);
this.parentNameLabel.TabIndex = 3;
this.parentNameLabel.Text = "Parent Name";
//
// nameTextBox
//
this.nameTextBox.Enabled = false;
this.nameTextBox.Location = new System.Drawing.Point(136, 67);
this.nameTextBox.Name = "nameTextBox";
this.nameTextBox.Size = new System.Drawing.Size(130, 20);
this.nameTextBox.TabIndex = 2;
//
// nameLabel
//
this.nameLabel.AutoSize = true;
this.nameLabel.Location = new System.Drawing.Point(26, 70);
this.nameLabel.Name = "nameLabel";
this.nameLabel.Size = new System.Drawing.Size(35, 13);
this.nameLabel.TabIndex = 1;
this.nameLabel.Text = "Name";
//
// componentNameLabel
//
this.componentNameLabel.AutoSize = true;
this.componentNameLabel.Location = new System.Drawing.Point(133, 43);
this.componentNameLabel.Name = "componentNameLabel";
this.componentNameLabel.Size = new System.Drawing.Size(83, 13);
this.componentNameLabel.TabIndex = 0;
this.componentNameLabel.Text = "ComonentName";
//
// parentNameComboBox
//
this.parentNameComboBox.Enabled = false;
this.parentNameComboBox.FormattingEnabled = true;
this.parentNameComboBox.Location = new System.Drawing.Point(136, 93);
this.parentNameComboBox.Name = "parentNameComboBox";
this.parentNameComboBox.Size = new System.Drawing.Size(130, 21);
this.parentNameComboBox.TabIndex = 4;
//
// RegisterReaderCfgCtrl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.parentNameComboBox);
this.Controls.Add(this.positionTextBox);
this.Controls.Add(this.positionLabel);
this.Controls.Add(this.parentNameLabel);
this.Controls.Add(this.nameTextBox);
this.Controls.Add(this.nameLabel);
this.Controls.Add(this.componentNameLabel);
this.Name = "RegisterReaderCfgCtrl";
this.Size = new System.Drawing.Size(300, 200);
this.Load += new System.EventHandler(this.RegisterReaderCfgCtrl_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TextBox positionTextBox;
private System.Windows.Forms.Label positionLabel;
private System.Windows.Forms.Label parentNameLabel;
private System.Windows.Forms.TextBox nameTextBox;
private System.Windows.Forms.Label nameLabel;
private System.Windows.Forms.Label componentNameLabel;
private System.Windows.Forms.ComboBox parentNameComboBox;
}
}
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
@@ -0,0 +1,132 @@
///
/// Copyright (c) 2021 Sensus Slovensko a.s.
///
using System;
using System.IO;
using System.Text;
using System.Xml.Serialization;
using Common;
using Config.Entities;
using TBF.Rig.Generic;
using TBF.Resources;
namespace TBF.Rig.RegisterReaders.FrequencyMeterFromUniCB
{
public class RRProcParams : ProcedureParamsBase, IParamsProvider, IProcedureParams
{
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(RRProcParams) })[0];
public override XmlSerializer GetSerializer() { return Serializer; }
public double PulsesPerLtr; /// [l^-1]
public int Filter;
public override void InitializeAll()
{
PulsesPerLtr = 1.0;
Filter = 0;
}
string[] paramNames = new string[]
{
Strings.PulsesPerLtr,
Strings.Filter,
};
public override string ParamName(int i) { return paramNames[i]; }
public override int ParamsCount() { return paramNames.Length; }
public override string ToString(int i)
{
switch (i)
{
case 0: return PulsesPerLtr.ToString();
case 1: return Filter.ToString();
default: return string.Empty;
}
}
/// Retrieves parameters from UI controls
CfgUpdateFlags IParamsProvider.UpdateParam(int i, string strValue)
{
switch (i)
{
case 0: PulsesPerLtr = Utils.ParseUDouble(strValue); return CfgUpdateFlags.None;
case 1: Filter = int.Parse(strValue); return CfgUpdateFlags.None;
default: return CfgUpdateFlags.None;
}
}
/// Verifies whether strings in UI controls represent valid parameters
bool IParamsProvider.ValidateParam(int i, string strValue, out string message)
{
message = string.Empty;
double dummy;
int idummy;
switch (i)
{
case 0:
if (Utils.TryParseUDouble(strValue, out dummy)) return true;
break;
case 1:
if (int.TryParse(strValue, out idummy) && (idummy >= 0)) return true;
break;
default:
message = "Invalid index";
return false;
}
message = ParamName(i) + " is invalid";
return false;
}
void CopyContentTo(RRProcParams prms)
{
prms.PulsesPerLtr = this.PulsesPerLtr;
prms.Filter = this.Filter;
}
IParamsProvider IParamsProvider.Clone()
{
RRProcParams pars = new RRProcParams();
CopyContentTo(pars);
return pars;
}
public override void UpdateFromDbEntity(ComponentProcedure dbEntity)
{
if (dbEntity == null) return;
try
{
RRProcParams tmp = Serializer.Deserialize(new StringReader(dbEntity.Parameters)) as RRProcParams;
procedureParamsEntity = dbEntity;
componentName = dbEntity.CmpntName;
procedure = dbEntity.Procedure;
if (tmp != null) tmp.CopyContentTo(this);
}
catch
{
}
}
public RRProcParams()
{
}
public RRProcParams(bool initialize)
{
if (initialize) InitializeAll();
}
public RRProcParams(ComponentProcedure procedureParamsEntity, string componentName, Procedure procedure)
{
this.procedureParamsEntity = procedureParamsEntity;
this.componentName = componentName;
this.procedure = procedure;
}
}
}
@@ -75,7 +75,7 @@ namespace TBF.Rig.RegisterReaders.KPackE.RegisterReader
radio = (Radio.Radio)TbfComponents.FindComponent(cfg.ParentName, components);
if (radio == null) throw new Exception(string.Format("Cannot find a parent of {0}", Name));
uniCB = StateMachine.ControlBoard as TBF.Rig.ControlBoard.Uni.UniCB;
uniCB = StateMachine.ControlBoardMain as TBF.Rig.ControlBoard.Uni.UniCB;
if (uniCB == null) throw new Exception("Missing ELDE control board");
log.Warn(this.ToString());

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