Preferred units in all BenchInfo components and IBenchInfo, Units.ConvertFrom/To for float.

This commit is contained in:
Milan Hanajik
2021-11-04 08:53:12 +01:00
parent e0c2004f52
commit 50494fccc9
6 changed files with 287 additions and 51 deletions
@@ -6,6 +6,7 @@ using System.Collections.Generic;
using System.Xml.Serialization;
using log4net;
using Common;
using Config;
using TBF.Rig.Generic;
namespace TBF.Rig.DataContainers.BenchInfo.Extended
@@ -28,6 +29,12 @@ namespace TBF.Rig.DataContainers.BenchInfo.Extended
public string Address4 { get { return myCfg.Address4; } }
public string Address5 { get { return myCfg.Address5; } }
public RemoteDBUse RemoteDBUse { get { return myCfg.RemoteDBUse; } }
public Unit VolumeUnit { get { return myCfg.VolumeUnit; } }
public Unit FlowUnit { get { return myCfg.FlowUnit; } }
public Unit MassUnit { get { return myCfg.MassUnit; } }
public Unit TempUnit { get { return myCfg.TempUnit; } }
public Unit PressUnit { get { return myCfg.PressUnit; } }
public Unit LenghtUnit { get { return myCfg.LenghtUnit; } }
public Component() { }
@@ -5,6 +5,7 @@ using System;
using System.Collections.Generic;
using System.Xml.Serialization;
using Common;
using Config;
using Config.Entities;
using TBF.Rig.Generic;
@@ -34,6 +35,12 @@ namespace TBF.Rig.DataContainers.BenchInfo.Extended
public string ApprovalDate;
public string ApprovedBy;
public RemoteDBUse RemoteDBUse;
public Unit VolumeUnit;
public Unit FlowUnit;
public Unit MassUnit;
public Unit TempUnit;
public Unit PressUnit;
public Unit LenghtUnit;
/// Private parameterless constructor invoked by all other (public) constructors
ComponentCfg() {}
@@ -65,6 +72,13 @@ namespace TBF.Rig.DataContainers.BenchInfo.Extended
ApprovedBy = string.Empty;
RemoteDBUse = RemoteDBUse.LocalDBOnly;
VolumeUnit = Unit.l;
FlowUnit = Unit.m3ph;
MassUnit = Unit.kg;
TempUnit = Unit.C;
PressUnit = Unit.bar;
LenghtUnit = Unit.mm;
}
string[] paramNames = new string[]
@@ -80,21 +94,58 @@ namespace TBF.Rig.DataContainers.BenchInfo.Extended
"Approval date",
"Approved by",
"Remote DB use",
"Preffered volume unit",
"Preffered flow unit",
"Preffered mass unit",
"Preffered temperature unit",
"Preffered pressure unit",
"Preffered lenght unit",
};
public string ParamName(int i) { return paramNames[i]; }
public int ParamsCount() { return paramNames.Length; }
public ICollection<string> ParamValues(int i)
{
if (i == 10)
var list = new List<string>();
switch (i)
{
IList<string> list = new List<string>();
for (RemoteDBUse rdbu = 0; rdbu < RemoteDBUse.Count; rdbu++) list.Add(rdbu.ToDescription());
return list;
}
else
{
return null;
case 10:
for (RemoteDBUse rdbu = 0; rdbu < RemoteDBUse.Count; rdbu++)
list.Add(rdbu.ToDescription());
return list;
case 11:
for (Unit unit = 0; unit < Unit.Count; unit++)
if (Units.IsQuantity(unit, Quantity.Volume))
list.Add(unit.ToDescription());
return list;
case 12:
for (Unit unit = 0; unit < Unit.Count; unit++)
if (Units.IsQuantity(unit, Quantity.Flow))
list.Add(unit.ToDescription());
return list;
case 13:
for (Unit unit = 0; unit < Unit.Count; unit++)
if (Units.IsQuantity(unit, Quantity.Mass))
list.Add(unit.ToDescription());
return list;
case 14:
for (Unit unit = 0; unit < Unit.Count; unit++)
if (Units.IsQuantity(unit, Quantity.Temperature))
list.Add(unit.ToDescription());
return list;
case 15:
for (Unit unit = 0; unit < Unit.Count; unit++)
if (Units.IsQuantity(unit, Quantity.Pressure))
list.Add(unit.ToDescription());
return list;
case 16:
for (Unit unit = 0; unit < Unit.Count; unit++)
if (Units.IsQuantity(unit, Quantity.Length))
list.Add(unit.ToDescription());
return list;
default:
return null;
}
}
@@ -118,6 +169,12 @@ namespace TBF.Rig.DataContainers.BenchInfo.Extended
case 8: return ApprovalDate;
case 9: return ApprovedBy;
case 10: return RemoteDBUse.ToDescription();
case 11: return VolumeUnit.ToDescription();
case 12: return FlowUnit.ToDescription();
case 13: return MassUnit.ToDescription();
case 14: return TempUnit.ToDescription();
case 15: return PressUnit.ToDescription();
case 16: return LenghtUnit.ToDescription();
default: return string.Empty;
}
}
@@ -155,7 +212,32 @@ namespace TBF.Rig.DataContainers.BenchInfo.Extended
}
return CfgUpdateFlags.Error;
default: return CfgUpdateFlags.None;
case 11:
VolumeUnit = Units.FromDescription(strValue);
return CfgUpdateFlags.RestartRqrd;
case 12:
FlowUnit = Units.FromDescription(strValue);
return CfgUpdateFlags.RestartRqrd;
case 13:
MassUnit = Units.FromDescription(strValue);
return CfgUpdateFlags.RestartRqrd;
case 14:
TempUnit = Units.FromDescription(strValue);
return CfgUpdateFlags.RestartRqrd;
case 15:
PressUnit = Units.FromDescription(strValue);
return CfgUpdateFlags.RestartRqrd;
case 16:
LenghtUnit = Units.FromDescription(strValue);
return CfgUpdateFlags.RestartRqrd;
default:
return CfgUpdateFlags.None;
}
}
@@ -185,6 +267,14 @@ namespace TBF.Rig.DataContainers.BenchInfo.Extended
if (strValue == rdbu.ToDescription()) return true;
}
return false;
case 11:
case 12:
case 13:
case 14:
case 15:
case 16:
if (ParamValues(i).Contains(strValue)) return true;
break;
default:
message = "Invalid index";
return false;
@@ -207,6 +297,12 @@ namespace TBF.Rig.DataContainers.BenchInfo.Extended
prms.ApprovalDate = this.ApprovalDate;
prms.ApprovedBy = this.ApprovedBy;
prms.RemoteDBUse = this.RemoteDBUse;
prms.VolumeUnit = this.VolumeUnit;
prms.FlowUnit = this.FlowUnit;
prms.MassUnit = this.MassUnit;
prms.TempUnit = this.TempUnit;
prms.PressUnit = this.PressUnit;
prms.LenghtUnit = this.LenghtUnit;
}
public Config.Entities.IParamsProvider Clone()
@@ -6,6 +6,7 @@ using System.Collections.Generic;
using System.Xml.Serialization;
using log4net;
using Common;
using Config;
using TBF.Rig;
using TBF.Rig.Generic;
using TBF.Resources;
@@ -30,6 +31,12 @@ namespace TBF.Rig.DataContainers.BenchInfo.iPerl
public string Address4 { get { return myCfg.Address4; } }
public string Address5 { get { return myCfg.Address5; } }
public RemoteDBUse RemoteDBUse { get { return myCfg.RemoteDBUse; } }
public Unit VolumeUnit { get { return myCfg.VolumeUnit; } }
public Unit FlowUnit { get { return myCfg.FlowUnit; } }
public Unit MassUnit { get { return myCfg.MassUnit; } }
public Unit TempUnit { get { return myCfg.TempUnit; } }
public Unit PressUnit { get { return myCfg.PressUnit; } }
public Unit LenghtUnit { get { return myCfg.LenghtUnit; } }
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
@@ -5,6 +5,7 @@ using System;
using System.Collections.Generic;
using System.Xml.Serialization;
using Common;
using Config;
using Config.Entities;
using TBF.Rig.Generic;
using TBF.Resources;
@@ -35,6 +36,12 @@ namespace TBF.Rig.DataContainers.BenchInfo.iPerl
public string ApprovalDate;
public string ApprovedBy;
public RemoteDBUse RemoteDBUse;
public Unit VolumeUnit;
public Unit FlowUnit;
public Unit MassUnit;
public Unit TempUnit;
public Unit PressUnit;
public Unit LenghtUnit;
public Side Side;
public int MaxTestIndex; /// (MaxPruefindex % 100) value when to reject water meters completely if they are NOK
@@ -71,6 +78,12 @@ namespace TBF.Rig.DataContainers.BenchInfo.iPerl
ApprovalDate = string.Empty;
ApprovedBy = string.Empty;
RemoteDBUse = RemoteDBUse.LocalDBOnly;
VolumeUnit = Unit.l;
FlowUnit = Unit.m3ph;
MassUnit = Unit.kg;
TempUnit = Unit.C;
PressUnit = Unit.bar;
LenghtUnit = Unit.mm;
Side = Side.Left;
MaxTestIndex = 4;
@@ -92,6 +105,12 @@ namespace TBF.Rig.DataContainers.BenchInfo.iPerl
"Approval date",
"Approved by",
"Remote DB use",
"Preffered volume unit",
"Preffered flow unit",
"Preffered mass unit",
"Preffered temperature unit",
"Preffered pressure unit",
"Preffered lenght unit",
Strings.Side,
"Max.test index",
};
@@ -100,21 +119,50 @@ namespace TBF.Rig.DataContainers.BenchInfo.iPerl
public ICollection<string> ParamValues(int i)
{
if (i == 10)
var list = new List<string>();
switch (i)
{
IList<string> list = new List<string>();
for (RemoteDBUse rdbu = 0; rdbu < RemoteDBUse.Count; rdbu++) list.Add(rdbu.ToDescription());
return list;
}
else if (i == 11)
{
IList<string> list = new List<string>();
for (Side side = 0; side < Side.Count; side++) list.Add(side.ToDescription());
return list;
}
else
{
return null;
case 10:
for (RemoteDBUse rdbu = 0; rdbu < RemoteDBUse.Count; rdbu++)
list.Add(rdbu.ToDescription());
return list;
case 11:
for (Unit unit = 0; unit < Unit.Count; unit++)
if (Units.IsQuantity(unit, Quantity.Volume))
list.Add(unit.ToDescription());
return list;
case 12:
for (Unit unit = 0; unit < Unit.Count; unit++)
if (Units.IsQuantity(unit, Quantity.Flow))
list.Add(unit.ToDescription());
return list;
case 13:
for (Unit unit = 0; unit < Unit.Count; unit++)
if (Units.IsQuantity(unit, Quantity.Mass))
list.Add(unit.ToDescription());
return list;
case 14:
for (Unit unit = 0; unit < Unit.Count; unit++)
if (Units.IsQuantity(unit, Quantity.Temperature))
list.Add(unit.ToDescription());
return list;
case 15:
for (Unit unit = 0; unit < Unit.Count; unit++)
if (Units.IsQuantity(unit, Quantity.Pressure))
list.Add(unit.ToDescription());
return list;
case 16:
for (Unit unit = 0; unit < Unit.Count; unit++)
if (Units.IsQuantity(unit, Quantity.Length))
list.Add(unit.ToDescription());
return list;
case 17:
for (Side side = 0; side < Side.Count; side++)
list.Add(side.ToDescription());
return list;
default:
return null;
}
}
@@ -138,8 +186,14 @@ namespace TBF.Rig.DataContainers.BenchInfo.iPerl
case 8: return ApprovalDate;
case 9: return ApprovedBy;
case 10: return RemoteDBUse.ToDescription();
case 11: return Side.ToDescription();
case 12: return MaxTestIndex.ToString();
case 11: return VolumeUnit.ToDescription();
case 12: return FlowUnit.ToDescription();
case 13: return MassUnit.ToDescription();
case 14: return TempUnit.ToDescription();
case 15: return PressUnit.ToDescription();
case 16: return LenghtUnit.ToDescription();
case 17: return Side.ToDescription();
case 18: return MaxTestIndex.ToString();
default: return string.Empty;
}
}
@@ -178,6 +232,30 @@ namespace TBF.Rig.DataContainers.BenchInfo.iPerl
return CfgUpdateFlags.Error;
case 11:
VolumeUnit = Units.FromDescription(strValue);
return CfgUpdateFlags.RestartRqrd;
case 12:
FlowUnit = Units.FromDescription(strValue);
return CfgUpdateFlags.RestartRqrd;
case 13:
MassUnit = Units.FromDescription(strValue);
return CfgUpdateFlags.RestartRqrd;
case 14:
TempUnit = Units.FromDescription(strValue);
return CfgUpdateFlags.RestartRqrd;
case 15:
PressUnit = Units.FromDescription(strValue);
return CfgUpdateFlags.RestartRqrd;
case 16:
LenghtUnit = Units.FromDescription(strValue);
return CfgUpdateFlags.RestartRqrd;
case 17:
for (Side side = 0; side < Side.Count; side++)
{
if (strValue == side.ToDescription())
@@ -195,7 +273,7 @@ namespace TBF.Rig.DataContainers.BenchInfo.iPerl
}
return CfgUpdateFlags.Error;
case 12: MaxTestIndex = int.Parse(strValue); return CfgUpdateFlags.RestartRqrd;
case 18: MaxTestIndex = int.Parse(strValue); return CfgUpdateFlags.RestartRqrd;
default: return CfgUpdateFlags.None;
}
}
@@ -218,7 +296,7 @@ namespace TBF.Rig.DataContainers.BenchInfo.iPerl
case 9:
return true;
case 1:
case 12:
case 18:
if (int.TryParse(strValue, out idummy) && (idummy >= 0)) return true;
break;
case 10:
@@ -228,6 +306,14 @@ namespace TBF.Rig.DataContainers.BenchInfo.iPerl
}
break;
case 11:
case 12:
case 13:
case 14:
case 15:
case 16:
if (ParamValues(i).Contains(strValue)) return true;
break;
case 17:
for (Side side = 0; side < Side.Count; side++)
{
if (strValue == side.ToDescription()) return true;
@@ -255,6 +341,12 @@ namespace TBF.Rig.DataContainers.BenchInfo.iPerl
prms.ApprovalDate = this.ApprovalDate;
prms.ApprovedBy = this.ApprovedBy;
prms.RemoteDBUse = this.RemoteDBUse;
prms.VolumeUnit = this.VolumeUnit;
prms.FlowUnit = this.FlowUnit;
prms.MassUnit = this.MassUnit;
prms.TempUnit = this.TempUnit;
prms.PressUnit = this.PressUnit;
prms.LenghtUnit = this.LenghtUnit;
prms.Side = this.Side;
prms.MaxTestIndex = this.MaxTestIndex;
}
+8 -1
View File
@@ -1,7 +1,8 @@
///
/// Copyright (c) 2015-2018 Sensus Slovensko a.s.
/// Copyright (c) 2015-2021 Sensus Slovensko a.s.
///
using Common;
using Config;
using TBF.Rig.Generic;
namespace TBF.Rig.GenericDevices
@@ -19,5 +20,11 @@ namespace TBF.Rig.GenericDevices
string Address4 { get; }
string Address5 { get; }
RemoteDBUse RemoteDBUse { get; }
Unit VolumeUnit { get; }
Unit FlowUnit { get; }
Unit MassUnit { get; }
Unit TempUnit { get; }
Unit PressUnit { get; }
Unit LenghtUnit { get; }
}
}