Upgrade - Replace PulsesTypeByQuantity with MultiFunctionalVariables unit filtering based on RegisterReader quantity type - remove PulsesTypeByQuantity-based parameter values

- generate available units using Units.IsQuantity(...)
- use Quantity.MultiFunctionalVariables to populate supported units
- centralize unit selection through Units.GetQuantity()
This commit is contained in:
Marek Frniak 2026-07-17 15:20:03 +02:00
parent 83c1f0e817
commit b746ceb34a
15 changed files with 210 additions and 148 deletions

View File

@ -2,6 +2,7 @@
/// Copyright (c) 2016-2021 Sensus Slovensko a.s.
///
using System;
using System.Linq;
namespace Common
{
@ -286,97 +287,97 @@ namespace Common
public static bool IsQuantity(Unit unit, Quantity quantity)
{
return (quantity == GetQuantity(unit));
return GetQuantity(unit).Contains(quantity);
}
public static Quantity GetQuantity(Unit unit)
public static Quantity[] GetQuantity(Unit unit)
{
switch (unit)
{
case Unit.pulse:
case Unit.degree:
return Quantity.Pulses;
return new[] { Quantity.Pulses };
case Unit.ml:
return Quantity.Volume;
return new[] { Quantity.Volume, Quantity.MultiFunctionalVariables };
case Unit.l:
return Quantity.Volume;
return new[] { Quantity.Volume, Quantity.MultiFunctionalVariables };
case Unit.dm3:
return Quantity.Volume;
return new[] { Quantity.Volume, Quantity.MultiFunctionalVariables };
case Unit.USgal:
return Quantity.Volume;
return new[] { Quantity.Volume, Quantity.MultiFunctionalVariables };
case Unit.UKgal:
return Quantity.Volume;
return new[] { Quantity.Volume, Quantity.MultiFunctionalVariables };
case Unit.cf:
return Quantity.Volume;
return new[] { Quantity.Volume, Quantity.MultiFunctionalVariables };
case Unit.m3:
return Quantity.Volume;
return new[] { Quantity.Volume, Quantity.MultiFunctionalVariables };
case Unit.lph:
return Quantity.Flow;
return new[] { Quantity.Flow };
case Unit.cfph:
return Quantity.Flow;
return new[] { Quantity.Flow };
case Unit.lpm:
return Quantity.Flow;
return new[] { Quantity.Flow };
case Unit.USgalpm:
return Quantity.Flow;
return new[] { Quantity.Flow };
case Unit.m3ph:
return Quantity.Flow;
return new[] { Quantity.Flow };
case Unit.lps:
return Quantity.Flow;
return new[] { Quantity.Flow };
case Unit.USgalps:
return Quantity.Flow;
return new[] { Quantity.Flow };
case Unit.m3pm:
return Quantity.Flow;
return new[] { Quantity.Flow };
case Unit.cfs:
return Quantity.Flow;
return new[] { Quantity.Flow };
case Unit.gps:
return Quantity.MassFlow;
return new[] { Quantity.MassFlow};
case Unit.gpm:
return Quantity.MassFlow;
return new[] { Quantity.MassFlow};
case Unit.gph:
return Quantity.MassFlow;
return new[] { Quantity.MassFlow};
case Unit.kgps:
return Quantity.MassFlow;
return new[] { Quantity.MassFlow};
case Unit.kgpm:
return Quantity.MassFlow;
return new[] { Quantity.MassFlow};
case Unit.kgph:
return Quantity.MassFlow;
return new[] { Quantity.MassFlow};
case Unit.tps:
return Quantity.MassFlow;
return new[] { Quantity.MassFlow};
case Unit.tpm:
return Quantity.MassFlow;
return new[] { Quantity.MassFlow};
case Unit.tph:
return Quantity.MassFlow;
return new[] { Quantity.MassFlow};
case Unit.lbps:
return Quantity.MassFlow;
return new[] { Quantity.MassFlow};
case Unit.lbpm:
return Quantity.MassFlow;
return new[] { Quantity.MassFlow};
case Unit.lbph:
return Quantity.MassFlow;
return new[] { Quantity.MassFlow};
case Unit.g:
return Quantity.Mass;
return new[] { Quantity.Mass, Quantity.MultiFunctionalVariables };
case Unit.oz:
return Quantity.Mass;
return new[] { Quantity.Mass, Quantity.MultiFunctionalVariables };
case Unit.lb:
return Quantity.Mass;
return new[] { Quantity.Mass, Quantity.MultiFunctionalVariables };
case Unit.kg:
return Quantity.Mass;
return new[] { Quantity.Mass, Quantity.MultiFunctionalVariables };
case Unit.t:
return Quantity.Mass;
return new[] { Quantity.Mass, Quantity.MultiFunctionalVariables };
case Unit.ms:
case Unit.s:
case Unit.min:
case Unit.hour:
return Quantity.Time;
return new[] { Quantity.Time };
case Unit.C:
case Unit.F:
case Unit.K:
return Quantity.Temperature;
return new[] { Quantity.Temperature };
case Unit.Pa:
case Unit.hPa:
@ -386,14 +387,14 @@ namespace Common
case Unit.psi:
case Unit.bar:
case Unit.MPa:
return Quantity.Pressure;
return new[] { Quantity.Pressure };
case Unit.RPct:
return Quantity.Humidity;
return new[] { Quantity.Humidity };
case Unit.Promile:
case Unit.Pct:
return Quantity.Error;
return new[] { Quantity.Error };
case Unit.mm:
case Unit.cm:
@ -402,23 +403,23 @@ namespace Common
case Unit.foot:
case Unit.yard:
case Unit.m:
return Quantity.Length;
return new[] { Quantity.Length };
case Unit.kgpm3:
case Unit.kgpm3:
case Unit.kgpl:
return Quantity.Density;
return new[] { Quantity.Density };
case Unit.J:
case Unit.J:
case Unit.kJ:
case Unit.MJ:
case Unit.Wh:
case Unit.kWh:
case Unit.MWh:
return Quantity.Energy;
return new[] { Quantity.Energy };
case Unit.uSpcm:
case Unit.mSpm:
return Quantity.Conductivity;
return new[] { Quantity.Conductivity };
case Unit.ppl:
case Unit.ppdm3:
@ -428,22 +429,22 @@ namespace Common
case Unit.dm3pp:
case Unit.lpdeg:
case Unit.dm3pdeg:
return Quantity.PulsePerLtr;
return new[] { Quantity.PulsePerLtr };
case Unit.ppkWh:
case Unit.kWhpp:
return Quantity.PulsePerKWh;
return new[] { Quantity.PulsePerKWh };
case Unit.A:
case Unit.mA:
return Quantity.Current;
return new[] { Quantity.Current };
case Unit.V:
case Unit.mV:
return Quantity.Voltage;
return new[] { Quantity.Voltage };
default:
return Quantity.Number;
return new[] { Quantity.Number };
}
}

View File

@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// Build Number
// Revision
//
[assembly: AssemblyVersion("3.9.3134.105")]
[assembly: AssemblyFileVersion("3.9.3134.105")]
[assembly: AssemblyVersion("3.9.3134.106")]
[assembly: AssemblyFileVersion("3.9.3134.106")]

View File

@ -1,6 +1,7 @@
//------------------------------------------------------------------------------
// <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.
@ -18,7 +19,7 @@ namespace TBF.Resources {
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "18.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Strings {
@ -4452,7 +4453,7 @@ namespace TBF.Resources {
}
/// <summary>
/// Looks up a localized string similar to Pulses per liter.
/// Looks up a localized string similar to Pulses per unit.
/// </summary>
internal static string PulsesPerLtr {
get {

View File

@ -529,7 +529,7 @@
<value>Rychlost změny [%]</value>
</data>
<data name="PulsesPerLtr" xml:space="preserve">
<value>Impulsy na litr</value>
<value>Impulsy na jednotky</value>
</data>
<data name="Component" xml:space="preserve">
<value>Komponent</value>
@ -1734,6 +1734,18 @@
<data name="ShowDialog" xml:space="preserve">
<value>Zobraz Okno</value>
</data>
<data name="PulsesPerUnit" xml:space="preserve">
<value />
</data>
<data name="PulsesPerKilogram" xml:space="preserve">
<value />
</data>
<data name="Units" xml:space="preserve">
<value />
</data>
<data name="Test_in_calculation" xml:space="preserve">
<value>Probíhá výpočet</value>
</data>
<data name="Arrangement_of_test" xml:space="preserve">
<value>Uspořádání testu</value>
</data>
@ -1755,16 +1767,4 @@
<data name="Reload" xml:space="preserve">
<value>Znovu otevřít</value>
</data>
<data name="PulsesPerUnit" xml:space="preserve">
<value />
</data>
<data name="PulsesPerKilogram" xml:space="preserve">
<value />
</data>
<data name="Units" xml:space="preserve">
<value />
</data>
<data name="Test_in_calculation" xml:space="preserve">
<value>Probíhá výpočet</value>
</data>
</root>

View File

@ -532,7 +532,7 @@
<value>Durchflussänderung [%]</value>
</data>
<data name="PulsesPerLtr" xml:space="preserve">
<value>Impulse pro Liter</value>
<value>Impulse pro Einheit</value>
</data>
<data name="Component" xml:space="preserve">
<value>Komponente</value>
@ -2187,6 +2187,15 @@
<data name="ShowDialog" xml:space="preserve">
<value>Dialog anzeigen</value>
</data>
<data name="PulsesPerUnit" xml:space="preserve">
<value />
</data>
<data name="PulsesPerKilogram" xml:space="preserve">
<value />
</data>
<data name="Units" xml:space="preserve">
<value />
</data>
<data name="Meter_types_tested" xml:space="preserve">
<value>Wasserzähler geprüft</value>
</data>
@ -2220,13 +2229,4 @@
<data name="Opto_head_was_disabled_by_the_user" xml:space="preserve">
<value>Abtastkopf wurde deaktiviert vom Benutzer!</value>
</data>
<data name="PulsesPerUnit" xml:space="preserve">
<value />
</data>
<data name="PulsesPerKilogram" xml:space="preserve">
<value />
</data>
<data name="Units" xml:space="preserve">
<value />
</data>
</root>

View File

@ -117,6 +117,9 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="PulsesPerLtr" xml:space="preserve">
<value>pulsos por unidad</value>
</data>
<data name="Activity" xml:space="preserve">
<value>Activity in Spanish</value>
</data>

View File

@ -529,7 +529,7 @@
<value>Taux de changement [%]</value>
</data>
<data name="PulsesPerLtr" xml:space="preserve">
<value>Impulsions par litre</value>
<value>impulsions par unité</value>
</data>
<data name="Component" xml:space="preserve">
<value>Composant</value>
@ -2004,6 +2004,15 @@
<data name="ShowDialog" xml:space="preserve">
<value>Afficher la boîte de dialogue</value>
</data>
<data name="PulsesPerUnit" xml:space="preserve">
<value />
</data>
<data name="PulsesPerKilogram" xml:space="preserve">
<value />
</data>
<data name="Units" xml:space="preserve">
<value />
</data>
<data name="Meter_types_tested" xml:space="preserve">
<value>Types compteurs testés</value>
</data>
@ -2019,13 +2028,4 @@
<data name="Test_time_s_chdr" xml:space="preserve">
<value>Temps test [s]</value>
</data>
<data name="PulsesPerUnit" xml:space="preserve">
<value />
</data>
<data name="PulsesPerKilogram" xml:space="preserve">
<value />
</data>
<data name="Units" xml:space="preserve">
<value />
</data>
</root>

View File

@ -529,7 +529,7 @@
<value>tasso di cambio [%]</value>
</data>
<data name="PulsesPerLtr" xml:space="preserve">
<value>impulsi per litro</value>
<value>impulsi per unità</value>
</data>
<data name="Component" xml:space="preserve">
<value>componente</value>
@ -1761,6 +1761,15 @@
<data name="ShowDialog" xml:space="preserve">
<value>Mostra dialogo</value>
</data>
<data name="PulsesPerUnit" xml:space="preserve">
<value />
</data>
<data name="PulsesPerKilogram" xml:space="preserve">
<value />
</data>
<data name="Units" xml:space="preserve">
<value />
</data>
<data name="Meter_types_tested" xml:space="preserve">
<value>tipi di contatori testati</value>
</data>
@ -1791,13 +1800,4 @@
<data name="Drain" xml:space="preserve">
<value>Drenare</value>
</data>
<data name="PulsesPerUnit" xml:space="preserve">
<value />
</data>
<data name="PulsesPerKilogram" xml:space="preserve">
<value />
</data>
<data name="Units" xml:space="preserve">
<value />
</data>
</root>

View File

@ -520,7 +520,7 @@
<value>Szybkość zmian [%]</value>
</data>
<data name="PulsesPerLtr" xml:space="preserve">
<value>Impulsy na litr</value>
<value>impulsów na jednostkę</value>
</data>
<data name="Component" xml:space="preserve">
<value>Element</value>
@ -1644,6 +1644,15 @@
<data name="Voltage" xml:space="preserve">
<value>Napięcie</value>
</data>
<data name="PulsesPerUnit" xml:space="preserve">
<value />
</data>
<data name="PulsesPerKilogram" xml:space="preserve">
<value />
</data>
<data name="Units" xml:space="preserve">
<value />
</data>
<data name="Arrangement_of_test" xml:space="preserve">
<value>Układ testu</value>
</data>
@ -1695,13 +1704,4 @@
<data name="Again" xml:space="preserve">
<value>Jeszcze raz</value>
</data>
<data name="PulsesPerUnit" xml:space="preserve">
<value />
</data>
<data name="PulsesPerKilogram" xml:space="preserve">
<value />
</data>
<data name="Units" xml:space="preserve">
<value />
</data>
</root>

View File

@ -541,7 +541,7 @@
<value>Rate of change [%]</value>
</data>
<data name="PulsesPerLtr" xml:space="preserve">
<value>Pulses per liter</value>
<value>Pulses per unit</value>
</data>
<data name="DelaySendImage" xml:space="preserve">
<value>Delay between pictures</value>

View File

@ -433,7 +433,7 @@
<value>Variatie debit [%]</value>
</data>
<data name="PulsesPerLtr" xml:space="preserve">
<value>impuls pe litru</value>
<value>impulsuri pe unitate</value>
</data>
<data name="Component" xml:space="preserve">
<value>Componenta</value>
@ -819,6 +819,15 @@
<data name="SaveCommunication" xml:space="preserve">
<value>Save Communication</value>
</data>
<data name="PulsesPerUnit" xml:space="preserve">
<value />
</data>
<data name="PulsesPerKilogram" xml:space="preserve">
<value />
</data>
<data name="Units" xml:space="preserve">
<value />
</data>
<data name="cold" xml:space="preserve">
<value>rece</value>
</data>
@ -843,13 +852,4 @@
<data name="WMSN" xml:space="preserve">
<value>seria</value>
</data>
<data name="PulsesPerUnit" xml:space="preserve">
<value />
</data>
<data name="PulsesPerKilogram" xml:space="preserve">
<value />
</data>
<data name="Units" xml:space="preserve">
<value />
</data>
</root>

View File

@ -520,7 +520,7 @@
<value>Скорость изменения [%]</value>
</data>
<data name="PulsesPerLtr" xml:space="preserve">
<value>Импульсов на литр</value>
<value>импульсов на единицу</value>
</data>
<data name="Component" xml:space="preserve">
<value>Компонент</value>
@ -1554,6 +1554,15 @@
<data name="Voltage" xml:space="preserve">
<value>Voltage</value>
</data>
<data name="PulsesPerUnit" xml:space="preserve">
<value />
</data>
<data name="PulsesPerKilogram" xml:space="preserve">
<value />
</data>
<data name="Units" xml:space="preserve">
<value />
</data>
<data name="cold" xml:space="preserve">
<value>холодный</value>
</data>
@ -1608,13 +1617,4 @@
<data name="Again" xml:space="preserve">
<value>Снова</value>
</data>
<data name="PulsesPerUnit" xml:space="preserve">
<value />
</data>
<data name="PulsesPerKilogram" xml:space="preserve">
<value />
</data>
<data name="Units" xml:space="preserve">
<value />
</data>
</root>

View File

@ -135,6 +135,9 @@
<data name="Compound_meters" xml:space="preserve">
<value>Združené vodomery</value>
</data>
<data name="PulsesPerLtr" xml:space="preserve">
<value>Pulzy na jednotky</value>
</data>
<data name="Activity" xml:space="preserve">
<value>Činnosť</value>
</data>

View File

@ -24,14 +24,14 @@ namespace TBF.Rig.RegisterReaders.PulsesFromUniCB
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(RRProcParams) })[0];
public override XmlSerializer GetSerializer() { return Serializer; }
public double PulsesPerLtr; /// [l^-1]
public string Units; /// [kg^-1]...MF
public double PulsesPerLtr;
public string Units;
public int Filter;
public override void InitializeAll()
{
PulsesPerLtr = 1.0;
Units = "---"; //...MF
Units = "---";
Filter = 0;
}
@ -43,7 +43,7 @@ namespace TBF.Rig.RegisterReaders.PulsesFromUniCB
Strings.Filter,
};
//...MF
private void RefreshParamNames(int i) {
if (i == 0)
{
@ -56,12 +56,12 @@ namespace TBF.Rig.RegisterReaders.PulsesFromUniCB
public override string ParamName(int i)
{
//if(i==0) RefreshParamNames(0);//...MF
//if(i==0) RefreshParamNames(0);
return paramNames[i];
}
public override int ParamsCount() { return paramNames.Length; }
public ICollection<string> ParamValues(int ix)
/*public ICollection<string> ParamValues(int ix)
{
var values = new List<string>();
switch (ix)
@ -72,6 +72,33 @@ namespace TBF.Rig.RegisterReaders.PulsesFromUniCB
default:
return null;
}
}*/
public ICollection<string> ParamValues(int ix)
{
switch (ix)
{
case 1:
{
var values = new List<string>
{
Unit.None.ToDescription()
};
for (Unit unit = (Unit)1; unit < Unit.Count; unit++)
{
if (Common.Units.IsQuantity(unit, Quantity.MultiFunctionalVariables))
{
values.Add(unit.ToDescription());
}
}
return values;
}
default:
return null;
}
}
public override string ToString(int i)
@ -127,7 +154,7 @@ namespace TBF.Rig.RegisterReaders.PulsesFromUniCB
void CopyContentTo(RRProcParams prms)
{
prms.PulsesPerLtr = this.PulsesPerLtr;
prms.Units = this.Units; //...MF
prms.Units = this.Units;
prms.Filter = this.Filter;
}

View File

@ -24,23 +24,23 @@ namespace TBF.Rig.RegisterReaders.StandingStartStop
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(RRProcParams) })[0];
public override XmlSerializer GetSerializer() { return Serializer; }
public double PulsesPerLtr; /// Target low limit of the flow increase or decrease
public string Units; /// [kg^-1]...MF
public double PulsesPerLtr;
public string Units;
public override void InitializeAll()
{
PulsesPerLtr = 1.0;
Units = "---"; //...MF
Units = "---";
}
string[] paramNames = new string[]
{
//Strings.PulsesPerLtr,
Strings.PulsesPerUnit,//...MF
Strings.Units,//...MF
Strings.PulsesPerUnit,
Strings.Units,
};
//...MF
private void RefreshParamNames(int i)
{
if (i == 0)
@ -54,7 +54,7 @@ namespace TBF.Rig.RegisterReaders.StandingStartStop
public override string ParamName(int i) { return paramNames[i]; }
public override int ParamsCount() { return paramNames.Length; }
public ICollection<string> ParamValues(int ix)
/*marek mareciinopublic ICollection<string> ParamValues(int ix)
{
var values = new List<string>();
switch (ix)
@ -65,6 +65,33 @@ namespace TBF.Rig.RegisterReaders.StandingStartStop
default:
return null;
}
}*/
public ICollection<string> ParamValues(int ix)
{
switch (ix)
{
case 1:
{
var values = new List<string>
{
Unit.None.ToDescription()
};
for (Unit unit = (Unit)1; unit < Unit.Count; unit++)
{
if (Common.Units.IsQuantity(unit, Quantity.MultiFunctionalVariables))
{
values.Add(unit.ToDescription());
}
}
return values;
}
default:
return null;
}
}
public override string ToString(int i)
@ -72,7 +99,7 @@ namespace TBF.Rig.RegisterReaders.StandingStartStop
switch (i)
{
case 0: return PulsesPerLtr.ToString();
case 1: return Units;//...MF
case 1: return Units;
default: return string.Empty;
}
}
@ -113,7 +140,7 @@ namespace TBF.Rig.RegisterReaders.StandingStartStop
void CopyContentTo(RRProcParams prms)
{
prms.PulsesPerLtr = this.PulsesPerLtr;
prms.Units = this.Units; //...MF
prms.Units = this.Units;
}
public IParamsProvider Clone()