float -> double : Qtg, Qfrom, Qto, Volume, TestTime, ver. 2.33.2033

This commit is contained in:
Milan Hanajik 2023-03-31 13:16:58 +02:00
parent f457278342
commit aa10ea5c04
8 changed files with 64 additions and 53 deletions

View File

@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2022 Sensus Slovensko a.s.
/// Copyright (c) 2013-2023 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
@ -22,11 +22,11 @@ namespace Config.Entities
public virtual TestProfile Profile { get; set; } /// UserDefined, Protected, UserDefinedHeatMeter, ProtectedHeatMeter
public virtual sbyte Publish { get; set; } /// 0=no, 1=in all protocols, 2=on screen, 3=internal
public virtual bool DoEvaluate { get; set; }
public virtual float Qtg { get; set; } /// Target water flow [m3/h]
public virtual float Qfrom { get; set; } /// Water flow low limit in [m3/h]
public virtual float Qto { get; set; } /// Water flow high limit in [m3/h]
public virtual float Volume { get; set; } /// Test volume (target) in [l]
public virtual float TestTime { get; set; } /// Test time (estimate) in [s]
public virtual double Qtg { get; set; } /// Target water flow [m3/h]
public virtual double Qfrom { get; set; } /// Water flow low limit in [m3/h]
public virtual double Qto { get; set; } /// Water flow high limit in [m3/h]
public virtual double Volume { get; set; } /// Test volume (target) in [l]
public virtual double TestTime { get; set; } /// Test time (estimate) in [s]
public virtual string Method { get; set; }
public virtual float ErrLimLo { get; set; } /// in [%] usually < 0, in case of heat meters: 1=class1, 2=class2, 3=class3
public virtual float ErrLimHi { get; set; } /// in [%] usually > 0, in case of heat meters: -Qn in m3/h
@ -292,11 +292,11 @@ namespace Config.Entities
tst.Part = int.Parse(input.ReadLine(), ci);
tst.Publish = sbyte.Parse(input.ReadLine(), ci);
tst.DoEvaluate = bool.Parse(input.ReadLine());
tst.Qtg = float.Parse(input.ReadLine(), ci);
tst.Qfrom = float.Parse(input.ReadLine(), ci);
tst.Qto = float.Parse(input.ReadLine(), ci);
tst.Volume = float.Parse(input.ReadLine(), ci);
tst.TestTime = float.Parse(input.ReadLine(), ci);
tst.Qtg = double.Parse(input.ReadLine(), ci);
tst.Qfrom = double.Parse(input.ReadLine(), ci);
tst.Qto = double.Parse(input.ReadLine(), ci);
tst.Volume = double.Parse(input.ReadLine(), ci);
tst.TestTime = double.Parse(input.ReadLine(), ci);
tst.Method = input.ReadLine();
tst.ErrLimLo = float.Parse(input.ReadLine(), ci);
tst.ErrLimHi = float.Parse(input.ReadLine(), ci);

View File

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

View File

@ -914,13 +914,13 @@ namespace TBF.Rig.Sequences
}
float TimeEstimateTotal = 0; /// Time estimate of the selected cycle or test
double TimeEstimateTotal = 0; /// Time estimate of the selected cycle or test
for (int i = selsctedTestIx; i < StateMachine.TestInstances.Length - simultWithEvacuationCount; i++)
{
Test test = StateMachine.TestInstances[i].Test;
TimeEstimateTotal += (test.TestTime + 10.0f);
TimeEstimateTotal += (test.TestTime + 10);
/// Try to fetch all test paths and transitions
/// to detect configuration errors as early as possible.

View File

@ -78,8 +78,8 @@ namespace TBF.Rig.Sequences
protected static Rig.MetersPath nextSensPath;
protected static Rig.HeatMetersPath nextHeatMetersPath;
protected static TransitionSequence nextTransitionBefore;
protected static float nextQfrom;
protected static float nextQto;
protected static double nextQfrom;
protected static double nextQto;
protected static float nextPumpPower;
protected static float nextPidCoef;
protected static double nextTolerRed;

View File

@ -428,14 +428,14 @@ namespace TBF.Rig.TestMethods.CombinedWithDetection
//UiBridge.Bridge.OnEvent(this, string.Format("detected flow={0}\r\n", detectedFlow.ToString("F2")));
float qfrom_detected = (float)(detectedFlow + testParams.RelativeQfrom);
float qto_detected = (float)(detectedFlow + testParams.RelativeQto);
double qfrom_detected = detectedFlow + testParams.RelativeQfrom;
double qto_detected = detectedFlow + testParams.RelativeQto;
/// Update test results with the test flow determined from the detected switching flow
float Qave_lps = (qfrom_detected + qto_detected) / 7.2f;
float testTimeFromDetectedFlow = test.Volume / Qave_lps; /// Test volume wont be changed
double Qave_lps = (qfrom_detected + qto_detected) / 7.2;
double testTimeFromDetectedFlow = test.Volume / Qave_lps; /// Test volume wont be changed
float relativeQave = (testParams.RelativeQfrom + testParams.RelativeQto) / 2.0f;
double relativeQave = (testParams.RelativeQfrom + testParams.RelativeQto) / 2;
bool goBackToInitFlow = ((rvPulse > 0) && (relativeQave < 0)) ||
((rvPulse < 0) && (relativeQave > 0));

View File

@ -921,18 +921,18 @@ namespace TBF.UI.Procedures
double dtmp;
#if SHOW_Q_TG
if (test.QtgTextChngd && Utils.TryParseUDouble(lvi.SubItems[(int)MtrlgyClmn.Qtg].Text, out dtmp))
test.Qtg = Convert.ToSingle(Units.ConvertFrom(test.FlowUnit, dtmp));
test.Qtg = Units.ConvertFrom(test.FlowUnit, dtmp);
#endif
if (test.QfromTextChngd && Utils.TryParseUDouble(lvi.SubItems[(int)MtrlgyClmn.Qfrom].Text, out dtmp))
test.Qfrom = Convert.ToSingle(Units.ConvertFrom(test.FlowUnit, dtmp));
test.Qfrom = Units.ConvertFrom(test.FlowUnit, dtmp);
if (test.QtoTextChngd && Utils.TryParseUDouble(lvi.SubItems[(int)MtrlgyClmn.Qto].Text, out dtmp))
test.Qto = Convert.ToSingle(Units.ConvertFrom(test.FlowUnit, dtmp));
test.Qto = Units.ConvertFrom(test.FlowUnit, dtmp);
if (test.VolumeTextChngd && Utils.TryParseUDouble(lvi.SubItems[(int)MtrlgyClmn.Volume].Text, out dtmp))
test.Volume = Convert.ToSingle(Units.ConvertFrom(test.VolumeUnit, dtmp));
test.Volume = Units.ConvertFrom(test.VolumeUnit, dtmp);
if (Utils.TryParseUFloat(lvi.SubItems[(int)MtrlgyClmn.TestTime].Text, out tmp)) test.TestTime = tmp;
if (Utils.TryParseUDouble(lvi.SubItems[(int)MtrlgyClmn.TestTime].Text, out dtmp)) test.TestTime = dtmp;
if (Utils.TryParseSFloat(lvi.SubItems[(int)MtrlgyClmn.ErrLimLo].Text, out tmp)) test.ErrLimLo = tmp;
if (Utils.TryParseSFloat(lvi.SubItems[(int)MtrlgyClmn.ErrLimHi].Text, out tmp)) test.ErrLimHi = tmp;
@ -951,6 +951,9 @@ namespace TBF.UI.Procedures
{
MtrlgyClmn column = (MtrlgyClmn)e.SubItem;
#if SHOW_Q_TG
if (e.SubItem == (int)MtrlgyClmn.Qtg) return;
#endif
/// Unit change is allowed when locked
if ((column != MtrlgyClmn.FlowUnit && column != MtrlgyClmn.VolumeUnit) &&
(!unlocked || column >= MtrlgyClmn.ColumnsCount))
@ -961,9 +964,6 @@ namespace TBF.UI.Procedures
MtrlgyClmn[] protectedColumns = new MtrlgyClmn[]
{
MtrlgyClmn.Name,
#if SHOW_Q_TG
MtrlgyClmn.Qtg,
#endif
MtrlgyClmn.Qfrom, MtrlgyClmn.Qto,
MtrlgyClmn.ErrLimLo, MtrlgyClmn.ErrLimHi,
};
@ -974,6 +974,9 @@ namespace TBF.UI.Procedures
void metrology1ListViewEx_SubItemRightClicked(object sender, SubItemEventArgs e)
{
#if SHOW_Q_TG
if (e.SubItem == (int)MtrlgyClmn.Qtg) return;
#endif
if (!unlocked || e.SubItem >= (int)MtrlgyClmn.ColumnsCount) return;
if (DialogResult.Yes == MessageBox.Show(Strings.Do_you_want_to_copy_this_value_to_all_cells_below_this_cell,
@ -1013,6 +1016,7 @@ namespace TBF.UI.Procedures
Unit newUnit;
int dummy;
float fdummy;
double ddummy;
switch (column)
{
@ -1070,56 +1074,56 @@ namespace TBF.UI.Procedures
if (e.DisplayText == e.Item.SubItems[e.SubItem].Text) return; /// Nothing changed
float qFrom = 1.0f;
float qTo = 1.0f;
float volume = 0.0f;
float testTime = 0.0f;
double qFrom = 1.0;
double qTo = 1.0;
double volume = 0.0;
double testTime = 0.0;
bool calculateVolume = false;
bool calculateTime = false;
bool allOk = true;
if (column == MtrlgyClmn.Qfrom && Utils.TryParseUFloat(e.DisplayText, out qFrom))
if (column == MtrlgyClmn.Qfrom && Utils.TryParseUDouble(e.DisplayText, out qFrom))
{
allOk &= Utils.TryParseUFloat(e.Item.SubItems[(int)MtrlgyClmn.Qto].Text, out qTo);
allOk &= Utils.TryParseUFloat(e.Item.SubItems[(int)MtrlgyClmn.Volume].Text, out volume);
allOk &= Utils.TryParseUDouble(e.Item.SubItems[(int)MtrlgyClmn.Qto].Text, out qTo);
allOk &= Utils.TryParseUDouble(e.Item.SubItems[(int)MtrlgyClmn.Volume].Text, out volume);
if (allOk)
{
test.QfromTextChngd = true;
calculateTime = true;
}
}
else if (column == MtrlgyClmn.Qto && Utils.TryParseUFloat(e.DisplayText, out qTo))
else if (column == MtrlgyClmn.Qto && Utils.TryParseUDouble(e.DisplayText, out qTo))
{
allOk &= Utils.TryParseUFloat(e.Item.SubItems[(int)MtrlgyClmn.Qfrom].Text, out qFrom);
allOk &= Utils.TryParseUFloat(e.Item.SubItems[(int)MtrlgyClmn.Volume].Text, out volume);
allOk &= Utils.TryParseUDouble(e.Item.SubItems[(int)MtrlgyClmn.Qfrom].Text, out qFrom);
allOk &= Utils.TryParseUDouble(e.Item.SubItems[(int)MtrlgyClmn.Volume].Text, out volume);
if (allOk)
{
test.QtoTextChngd = true;
calculateTime = true;
}
}
else if (column == MtrlgyClmn.Volume && Utils.TryParseUFloat(e.DisplayText, out volume))
else if (column == MtrlgyClmn.Volume && Utils.TryParseUDouble(e.DisplayText, out volume))
{
allOk &= Utils.TryParseUFloat(e.Item.SubItems[(int)MtrlgyClmn.Qfrom].Text, out qFrom);
allOk &= Utils.TryParseUFloat(e.Item.SubItems[(int)MtrlgyClmn.Qto].Text, out qTo);
allOk &= Utils.TryParseUDouble(e.Item.SubItems[(int)MtrlgyClmn.Qfrom].Text, out qFrom);
allOk &= Utils.TryParseUDouble(e.Item.SubItems[(int)MtrlgyClmn.Qto].Text, out qTo);
if (allOk)
{
test.VolumeTextChngd = true;
calculateTime = true;
}
}
else if (column == MtrlgyClmn.TestTime && Utils.TryParseUFloat(e.DisplayText, out testTime))
else if (column == MtrlgyClmn.TestTime && Utils.TryParseUDouble(e.DisplayText, out testTime))
{
allOk &= Utils.TryParseUFloat(e.Item.SubItems[(int)MtrlgyClmn.Qfrom].Text, out qFrom);
allOk &= Utils.TryParseUFloat(e.Item.SubItems[(int)MtrlgyClmn.Qto].Text, out qTo);
allOk &= Utils.TryParseUDouble(e.Item.SubItems[(int)MtrlgyClmn.Qfrom].Text, out qFrom);
allOk &= Utils.TryParseUDouble(e.Item.SubItems[(int)MtrlgyClmn.Qto].Text, out qTo);
if (allOk)
{
calculateVolume = true;
}
}
float qAveLps = Units.ConvertFrom(test.FlowUnit, qFrom + qTo) / 7.2f;
double qAveLps = Units.ConvertFrom(test.FlowUnit, qFrom + qTo) / 7.2;
if (calculateTime)
{
@ -1129,14 +1133,14 @@ namespace TBF.UI.Procedures
return;
}
float volumeLtr = Units.ConvertFrom(test.VolumeUnit, volume);
double volumeLtr = Units.ConvertFrom(test.VolumeUnit, volume);
testTime = volumeLtr / qAveLps;
e.Item.SubItems[(int)MtrlgyClmn.TestTime].Text = testTime.ToString();
return;
}
else if (calculateVolume)
{
var volumeLtr = testTime * qAveLps;
double volumeLtr = testTime * qAveLps;
e.Item.SubItems[(int)MtrlgyClmn.Volume].Text = Units.ConvertTo(test.VolumeUnit, volumeLtr).ToString();
test.VolumeTextChngd = true;
return;
@ -1258,7 +1262,7 @@ namespace TBF.UI.Procedures
}
ComboBox tempUnitBox = new ComboBox();
for (Common.Unit u = 0; u < Common.Unit.Count; u++)
for (Unit u = 0; u < Unit.Count; u++)
{
if (Units.IsTemperature(u)) tempUnitBox.Items.Add(u.ToDescription());
}
@ -2566,7 +2570,7 @@ namespace TBF.UI.Procedures
string selector = flowDlg.Selector;
/// Depending on the chosen Q select the paths
float Qaver = (test.Qfrom + test.Qto) / 2.0f;
double Qaver = (test.Qfrom + test.Qto) / 2;
foreach (var path in feedingPaths)
{
if ((path.Qfrom <= Qaver) && (Qaver <= path.Qto) &&

View File

@ -441,7 +441,7 @@ namespace TBF.UI.Procedures.TestWizard
if (test != null)
{
/// Depending on the chosen Q select the paths
float Qaver = (test.Qfrom + test.Qto) / 2.0f;
double Qaver = (test.Qfrom + test.Qto) / 2;
foreach (var path in fPaths)
{
if ((path.Qfrom <= Qaver) && (Qaver <= path.Qto) &&

View File

@ -1264,7 +1264,14 @@ namespace TBF.UI.Settings
private void upgradeDb_232_233_Button_Click(object sender, EventArgs e)
{
string[] configDbCommands = new string[] { };
string[] configDbCommands = new string[]
{
"ALTER TABLE `test` CHANGE `Qtg` `Qtg` DOUBLE NOT NULL DEFAULT '0';",
"ALTER TABLE `test` CHANGE `Qfrom` `Qfrom` DOUBLE NOT NULL DEFAULT '0';",
"ALTER TABLE `test` CHANGE `Qto` `Qto` DOUBLE NOT NULL DEFAULT '0';",
"ALTER TABLE `test` CHANGE `Volume` `Volume` DOUBLE NOT NULL DEFAULT '0';",
"ALTER TABLE `test` CHANGE `TstTime` `TstTime` DOUBLE NOT NULL DEFAULT '0';"
};
string[] resultsDbCommands = new string[]
{