Streamline uncertainty handling by modifying data structures and methods, replacing `SerNo` with a generic `val` array. Introduce `PreviousResultsDlgUncertainty` for expanded result management, and incorporate Excel template handling for uncertainty calculations. Ensure backward compatibility while refining code for clarity and efficiency.
325 lines
20 KiB
C#
325 lines
20 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Windows.Forms;
|
|
using Common;
|
|
using Results.Entities;
|
|
|
|
namespace Results.Uncertainty
|
|
{
|
|
public class ProcessDataLine
|
|
{
|
|
public DateTime DateTime;
|
|
public int Batch; //"B" //Batch - B
|
|
public string TestName; //"C", "Q1 (1/5)", formatStr); //Test Name - C
|
|
public int Reports; //"D", 5, formatInt); //Reports
|
|
public int RepCyc; //"E", 1, formatInt); //Rep cyc
|
|
public string TestMeth; //"F", "FlyingStartMassCollection", formatStr); //Test Meth.
|
|
public int TargetVOL; //"G", 1, formatInt); //Target VOL.
|
|
public double TargetQMin; //"H", 0.005, formatD4); //Target Q -
|
|
public double TargetQPlus; //"I", 0.0055, formatD4); //Target Q +
|
|
public int ErrLimitMin; //"J", -2, formatInt); //Err. LIMIT -
|
|
public int ErrLimitPlus; //"K", -2, formatInt); //Err. LIMIT +
|
|
public int TargetTempFrom; //"L", 15, formatInt); //Target temp from - L
|
|
public int TargetTempTo; //"M", 25, formatInt); //Target temp to - M
|
|
public int TargetPressFrom; //"N", 0, formatInt); //Target press from - N
|
|
public int TargetPressTo; //"O", 16, formatInt); //Target press to - O
|
|
public string MIDNumberName; //"P", "I4", formatStr);
|
|
public double MIDNumberValue; //"Q", 998.1848d, formatD4); //MID number - PQ
|
|
public string COR; //"R", "WT2", formatStr); //COR - R
|
|
public double TempAmbM; //"S", 20.0, formatD1); //Temp.Amb M - S
|
|
public int PressAmbM; //"T", 1010, formatInt); //Press.Amb M - T
|
|
public double HumidAmbM; //"U", 52.7, formatD1); //Humid.Amb M - U
|
|
public int PressUpME; //"V", 272, formatInt); //Press. UP ME - V
|
|
public int PressDwME; //"W", 277, formatInt); //Press. DW ME - W
|
|
public int PressDeME; //"X", 0, formatInt); //Press. DE ME - X
|
|
public int PressUpST; //"Y", 272, formatInt); //Press. UP ST - Y
|
|
public int PressDwST; //"Z", 277, formatInt); //Press. DW ST - Z
|
|
public int PressDES; //"AA", 0, formatInt); //Press. DES - AA
|
|
public int PressUpEN; //"AB", 271, formatInt); //Press UP EN - AB
|
|
public int PressDwEN; //"AC", 276, formatInt); //Press DW EN
|
|
public int PressDEE; //"AD", 0, formatInt); //Press. DEE
|
|
public double TempUpME; //"AE", 17.27103, formatD4); //Temp. UP ME
|
|
public double TempDwME; //"AF", 17.84066, formatD4); //Temp. DW ME
|
|
public double TempDiME; //"AG", 18.25793, formatD4); //Temp. DI ME
|
|
public double TempLoME; //"AH", 0, formatD4); //Temp. LO ME
|
|
public double TempHiME; //"AI", 0, formatD4); //Temp. HI ME
|
|
public double TempUpST; //"AJ", 17.18227, formatD4); //Temp. UP ST
|
|
public double TempDwST; //"AK", 17.78378, formatD4); //Temp. DW ST
|
|
public double TempDiST; //"AL", 18.1312, formatD4); //Temp. DI ST
|
|
public double TempLoST; //"AM", 0, formatD4); //Temp. LO ST
|
|
public double TempHiST; //"AN", 0, formatD4); //Temp. HI ST
|
|
public double TempUpEN; //"AO", 17.3036, formatD4); //Temp. UP EN
|
|
public double TempDwEN; //"AP", 17.88913, formatD4); //Temp. DW EN
|
|
public double TempDiEN; //"AQ", 18.35797, formatD4); //Temp. DI EN
|
|
public double TempLoEN; //"AR", 0, formatD4); //Temp. LO EN
|
|
public double TempHiEN; //"AS", 0, formatD4); //Temp. HI EN
|
|
|
|
//Mass vakues
|
|
public double MassStRaw; // "AT", iRowI, 18.104, formatD3); //Mass ST raw()
|
|
public double MassSt; // "AU", iRowI, 18.104, formatD3); //Mass ST ()
|
|
public double MassEnRaw; // "AV", iRowI, 19.087, formatD3); //Mass EN raw()
|
|
public double MassEn; // "AW", iRowI, 19.087, formatD3); //Mass EN ()
|
|
public double Mass; // "AX", iRowI, 0.983, formatD3); //Mass
|
|
|
|
//calculated values
|
|
public double RoWa; // "AY", iRowI, 999.0094727, formatD7); //Ro Wa
|
|
public double TempLnME; // "AZ", iRowI, 17.55585, formatD7); //Temp. LN ME
|
|
public double RoWat; // "BA", iRowI, 999.2654076, formatD7); //Ro Wat
|
|
public double RoAir; // "BB", iRowI, 0, formatD7); // Ro AIR
|
|
public double Kbuoyancy; // "BC", iRowI, 1.00103, formatD7); // Kbuoyancy
|
|
public int DensityOfSample; // "BD", iRowI, 998, formatInt); //Density of sample
|
|
public int TTempRO; // "BE", iRowI, 23, formatInt); //TTemp. RO()
|
|
|
|
public double QMax; // "BF", iRowI, 0.00539688, formatD7); //Q max ()
|
|
public double QMin; // "BG", iRowI, 0.005288206, formatD7); //Q min ()
|
|
public double QMean; // "BH", iRowI, 0.005257821, formatD7); //Q mean
|
|
public double Qctv; ///< "BI", iRowI, 23, formatD7); //Qctv
|
|
public double VolRI; // "BJ", iRowI, 1.00006944444444, formatD7); //Vol. RI
|
|
public double DivCorrection; // "BK", iRowI, 0, formatD3); //Div correction
|
|
public double T; // "BL", iRowI, 674.242981, formatD3); //T(s)()
|
|
|
|
public double ERelRef; ///< "BM", iRowI, 1.557125667, formatD7); //E rel.ref. ()
|
|
|
|
//CellData(worksheet, "BN", iRowI, , formatD7);
|
|
public int KMind; ///< "BO", iRowI, 14400, formatInt); //K MID ()
|
|
//CellData(worksheet, "BP", iRowI, , formatInt);//Const.MAS
|
|
|
|
//Additional values
|
|
public int DiverterStartTime; //"BQ", iRowI, 84, formatInt); //Diverter start time
|
|
|
|
public int DiverterEndTime; //"BR", iRowI, 86, formatInt); //Diverter end time
|
|
|
|
public int DiverterStartValeveOpenTime;//"BS", iRowI, 0, formatInt); // /// BS [ms] Start valve open time
|
|
public int DiverterStartValeveCloseTime;//"BT", iRowI, 0, formatInt); // /// BT [ms] Start valve close time
|
|
|
|
public double TempUpMax; //"BU", iRowI, 17.40029, formatD7); //Temp. UP max
|
|
public double TempDwMax; //"BV", iRowI, 17.91978, formatD7); // Temp DW max
|
|
public double TempUpMin; //"BW", iRowI, 17.14815, formatD7); //Temp UP min
|
|
public double TempDwMin; //"BX", iRowI, 17.74739, formatD7); //Temp DW min
|
|
public double TempT10; //"BY", iRowI, 0, formatD7); //10 - T1,2
|
|
|
|
public double TempAmbEn; //"BZ", iRowI, 20.1, formatD1); //Temp Amb En
|
|
public int PressAmbEn; //"CA", iRowI, 1010, formatInt); //Press Amb En
|
|
public double HumAmbEn; //"CB", iRowI, 52.8, formatD1); //Hum Amb En
|
|
|
|
//checking
|
|
|
|
public int RefPulses; //"CC", iRowI, 14401, formatInt); //Ref pulses()
|
|
public int DiverterTestTimeCorrection; //CellData(worksheet, "CD", iRowI, , formatInt); /// CD [ms] Diverter test time correction
|
|
|
|
public IList<ProcessDataMeterLine> processDataMeterList = new List<ProcessDataMeterLine>();
|
|
|
|
|
|
|
|
public void InitDefault()
|
|
{
|
|
DateTime = DateTime.Now;
|
|
Batch = 914;
|
|
TestName = "Q1 (1/5)";
|
|
Reports = 5;
|
|
RepCyc = 1;
|
|
TestMeth = "FlyingStartMassCollection";
|
|
TargetVOL = 1;
|
|
TargetQMin = 0.005;
|
|
TargetQPlus = 0.0055;
|
|
ErrLimitMin = -2;
|
|
ErrLimitPlus = -2;
|
|
TargetTempFrom = 15;
|
|
TargetTempTo = 25;
|
|
TargetPressFrom = 0;
|
|
TargetPressTo = 16;
|
|
MIDNumberName = "I4";
|
|
MIDNumberValue = 998.1848d;
|
|
COR = "WT2";
|
|
TempAmbM = 20.0;
|
|
PressAmbM = 1010;
|
|
HumidAmbM = 52.7;
|
|
PressUpME = 272;
|
|
PressDwME = 277;
|
|
PressDeME = 0;
|
|
PressUpST = 272;
|
|
PressDwST = 277;
|
|
PressDES = 0;
|
|
PressUpEN = 271;
|
|
PressDwEN = 276;
|
|
PressDEE = 0;
|
|
TempUpME = 17.27103;
|
|
TempDwME = 17.84066;
|
|
TempDiME = 18.25793;
|
|
TempLoME = 0;
|
|
TempHiME = 0;
|
|
TempUpST = 17.18227;
|
|
TempDwST = 17.78378;
|
|
TempDiST = 18.1312;
|
|
TempLoST = 0;
|
|
TempHiST = 0;
|
|
TempUpEN = 17.3036;
|
|
TempDwEN = 17.88913;
|
|
TempDiEN = 18.35797;
|
|
TempLoEN = 0;
|
|
TempHiEN = 0;
|
|
MassStRaw = 18.104;
|
|
MassSt = 18.104;
|
|
MassEnRaw = 19.087;
|
|
MassEn = 19.087;
|
|
Mass = 0.983;
|
|
RoWa = 999.0094727;
|
|
TempLnME = 17.55585;
|
|
RoWat = 999.2654076;
|
|
RoAir = 0;
|
|
Kbuoyancy = 1.00103;
|
|
DensityOfSample = 998;
|
|
TTempRO = 23;
|
|
QMax = 0.00539688;
|
|
QMin = 0.005288206;
|
|
QMean = 0.005257821;
|
|
Qctv = 23;
|
|
VolRI = 1.00006944444444;
|
|
DivCorrection = 0;
|
|
T = 674.242981;
|
|
ERelRef = 1.557125667;
|
|
KMind = 14400;
|
|
DiverterStartTime = 84;
|
|
DiverterEndTime = 86;
|
|
TempUpMax = 17.40029;
|
|
TempDwMax = 17.91978;
|
|
TempUpMin = 17.14815;
|
|
TempDwMin = 17.74739;
|
|
TempT10 = 0;
|
|
TempAmbEn = 20.1;
|
|
PressAmbEn = 1010;
|
|
HumAmbEn = 52.8;
|
|
RefPulses = 14401;
|
|
DiverterTestTimeCorrection = 0;
|
|
for (int i = 0; i < 3; i++)
|
|
{
|
|
|
|
|
|
ProcessDataMeterLine meterLine = new ProcessDataMeterLine();
|
|
meterLine.InitDefault();
|
|
meterLine.val[0] = $"XXXX{i}";
|
|
processDataMeterList.Add(meterLine);
|
|
}
|
|
}
|
|
|
|
|
|
public void Init(Results.Entities.TestRslt tstRslt)
|
|
{
|
|
|
|
bool isPMaxTest = tstRslt.IsPMaxTest();
|
|
bool isStartStop = tstRslt.IsStartStop();
|
|
bool isDiverter = tstRslt.IsDiverter();
|
|
bool isVolumeMethod = tstRslt.IsVolumeMethod();
|
|
|
|
DateTime =tstRslt.StartTime; /// A
|
|
Batch = tstRslt.Batch.BatchNr; /// B
|
|
/// Test information, target values, etc.
|
|
TestName = tstRslt.Name(); /// C
|
|
Reports = tstRslt.Repeats(); /// D
|
|
RepCyc = tstRslt.RepetitionNr; /// E
|
|
TestMeth = tstRslt.Method(); /// F
|
|
TargetVOL = Convert.ToInt32(tstRslt.TargetVolume()); /// G
|
|
TargetQMin = tstRslt.Qfrom(); /// H
|
|
TargetQPlus = tstRslt.Qto(); /// I
|
|
ErrLimitMin = Convert.ToInt32(tstRslt.ErrLimLo() + tstRslt.ErrLimMargin()); /// J
|
|
ErrLimitPlus = Convert.ToInt32(tstRslt.ErrLimHi() - tstRslt.ErrLimMargin()); /// K
|
|
TargetTempFrom = Convert.ToInt32(Double.Parse(string.Format("{0:F1}", tstRslt.TempLimLo()))); /// L
|
|
TargetTempTo = Convert.ToInt32(Double.Parse(string.Format("{0:F1}", tstRslt.TempLimHi()))); /// M
|
|
TargetPressFrom = 0; /// N
|
|
TargetPressTo = 16; /// O
|
|
MIDNumberName = tstRslt.RefFlowmeter(); /// P
|
|
MIDNumberValue = Double.Parse(string.Format("{0:F4}", Formulas.DistilledWaterDensityFromTemp(tstRslt.AmbTempMean))); /// Q [kg/m3] hustota vody pri teplote okolia z priemernej teploty okolia bez korekcie na realnu hustotu vody
|
|
COR = ((tstRslt.Components != null) ? tstRslt.Components.Scale : string.Empty); /// R
|
|
|
|
/// Ambient
|
|
TempAmbM = Double.Parse(string.Format("{0:F1}", Units.ConvertTo(Unit.C, tstRslt.AmbTempStart))); /// S [°C]
|
|
PressAmbM = Convert.ToInt32(Double.Parse(string.Format("{0:F0}", Units.ConvertTo(Unit.mbar, tstRslt.AmbPressStart)))); /// T [mbar]
|
|
HumidAmbM = Double.Parse(string.Format("{0:F1}", Units.ConvertTo(Unit.RPct, tstRslt.AmbHumiStart))); /// U [R%]
|
|
|
|
/// Pressure
|
|
PressUpME = Convert.ToInt32(Double.Parse(string.Format("{0:F0}", Units.ConvertTo(Unit.kPa, tstRslt.PressUpMean)))); /// V [kPa]
|
|
PressDwME = Convert.ToInt32(Double.Parse(string.Format("{0:F0}", Units.ConvertTo(Unit.kPa, tstRslt.PressDownMean)))); /// W [kPa]
|
|
PressDeME = Convert.ToInt32(Double.Parse(string.Format("{0:F1}", Units.ConvertTo(Unit.kPa, tstRslt.PressDeltaMean)))); /// X [kPa]
|
|
PressUpST = Convert.ToInt32(Double.Parse(string.Format("{0:F0}", Units.ConvertTo(Unit.kPa, tstRslt.PressUpStart)))); /// Y [kPa]
|
|
PressDwST = Convert.ToInt32(Double.Parse(string.Format("{0:F0}", Units.ConvertTo(Unit.kPa, tstRslt.PressDownStart)))); /// Z [kPa]
|
|
PressDES = Convert.ToInt32(Double.Parse(string.Format("{0:F1}", Units.ConvertTo(Unit.kPa, tstRslt.PressDeltaStart)))); /// AA [kPa]
|
|
PressUpEN = Convert.ToInt32(Double.Parse(string.Format("{0:F0}", Units.ConvertTo(Unit.kPa, tstRslt.PressUpEnd)))); /// AB [kPa]
|
|
PressDwEN = Convert.ToInt32(Double.Parse(string.Format("{0:F0}", Units.ConvertTo(Unit.kPa, tstRslt.PressDownEnd)))); /// AC [kPa]
|
|
PressDEE = Convert.ToInt32(Double.Parse(string.Format("{0:F1}", Units.ConvertTo(Unit.kPa, tstRslt.PressDeltaEnd)))); /// AD [kPa]
|
|
|
|
/// Temperature
|
|
TempUpME = (Units.ConvertTo(Unit.C, tstRslt.TempUpMean)); /// AE [°C]
|
|
TempDwME = (Units.ConvertTo(Unit.C, tstRslt.TempDownMean)); /// AF [°C]
|
|
TempDiME = (Units.ConvertTo(Unit.C, tstRslt.TempDivMean)); /// AG [°C]
|
|
TempLoME = (Units.ConvertTo(Unit.C, tstRslt.Custom1)); /// AH [°C] T hi mean
|
|
TempHiME = (Units.ConvertTo(Unit.C, tstRslt.Custom6)); /// AI [°C] T lo mean
|
|
TempUpST = (Units.ConvertTo(Unit.C, tstRslt.TempUpStart)); /// AJ [°C]
|
|
TempDwST = (Units.ConvertTo(Unit.C, tstRslt.TempDownStart)); /// AK [°C]
|
|
TempDiST = (Units.ConvertTo(Unit.C, tstRslt.TempDivStart)); /// AL [°C]
|
|
TempLoST = (Units.ConvertTo(Unit.C, tstRslt.Custom2)); /// AM [°C] T hi start
|
|
TempHiST = (Units.ConvertTo(Unit.C, tstRslt.Custom7)); /// AN [°C] T lo start
|
|
TempUpEN = (Units.ConvertTo(Unit.C, tstRslt.TempUpEnd)); /// AO [°C]
|
|
TempDwEN = (Units.ConvertTo(Unit.C, tstRslt.TempDownEnd)); /// AP [°C]
|
|
TempDiEN = (Units.ConvertTo(Unit.C, tstRslt.TempDivEnd)); /// AQ [°C]
|
|
TempLoEN = (Units.ConvertTo(Unit.C, tstRslt.Custom3)); /// AR [°C] T hi end
|
|
TempHiEN = (Units.ConvertTo(Unit.C, tstRslt.Custom8)); /// AS [°C] T lo end
|
|
|
|
/// Mass
|
|
MassStRaw = (tstRslt.MassStartRaw); /// AT [kg]
|
|
MassSt = (tstRslt.MassStart); /// AU [kg]
|
|
MassEnRaw = (tstRslt.MassEndRaw); /// AV [kg]
|
|
MassEn = (tstRslt.MassEnd); /// AW [kg]
|
|
Mass = (tstRslt.MassEnd - tstRslt.MassStart); /// AX [kg]
|
|
|
|
/// Density and buoyancy
|
|
RoWa = (tstRslt.DensityDiv); /// AY [kg/m3]
|
|
TempLnME = ((tstRslt.TempUpMean + tstRslt.TempDownMean) / 2); /// AZ [°C] Tline ... priemerna teplota v linii
|
|
RoWat = (tstRslt.DensityLine); /// BA [kg/m3]
|
|
RoAir = (tstRslt.MassOfEvapWater); /// BB [kg] mass of evaporated water
|
|
Kbuoyancy = (tstRslt.Batch.Buoyancy); /// BC Buoyancy: Sheet1 - X9
|
|
|
|
DensityOfSample = Convert.ToInt32(tstRslt.Batch.SampleDensity); /// BD
|
|
TTempRO = Convert.ToInt32(tstRslt.Batch.SampleTemp); /// BE
|
|
QMax = (tstRslt.FlowMax); /// BF pipe expansion: teraz vynechat
|
|
QMin = (tstRslt.FlowMin); /// BG [kg/h] Qm
|
|
QMean = (tstRslt.Flow); /// BH [l/h] Qv
|
|
Qctv = (tstRslt.VolumeCTV); /// BI [l] Vet .... komercne prava hodnota objemu - podla vahy
|
|
VolRI = (tstRslt.VolumeMaster); /// BJ [l] Velm ... objem podla etalonu (Prolonged: objem do vahy podla impulzov hradlovanych klapkou)
|
|
DivCorrection = (tstRslt.TestTimeCorrection); /// BK [s] test time correction (diverter correction)
|
|
/// (ori.) BK [l] Vmass .. objem podla druheho etalonu / prietokomeru pred tratou (teraz vynechavame)
|
|
T = (tstRslt.TestTime); /// BL [s]
|
|
ERelRef = (isVolumeMethod ? Formulas.ErrorFromVolumes(tstRslt.ConstMasterCorr, tstRslt.ConstMasterRaw) : tstRslt.ErrorMaster);
|
|
/// BM [%] Eelm .... chyba etalonu voci komercne pravej hodnote
|
|
KMind = Convert.ToInt32((tstRslt.ConstMasterRaw != 0) ? (1 / tstRslt.ConstMasterRaw) : 0); /// BO [pls/l] Const.MID .. konstanta etalonu
|
|
DiverterStartTime = Convert.ToInt32(Double.Parse(string.Format("{0:F0}", isDiverter ? 1000.0F * tstRslt.DiverterStart : 0))); /// BQ [ms] Diverter start time
|
|
DiverterEndTime = Convert.ToInt32(Double.Parse(string.Format("{0:F0}", isDiverter ? 1000.0F * tstRslt.DiverterEnd : 0))); /// BR [ms] Diverter end time
|
|
DiverterStartValeveOpenTime = Convert.ToInt32(Double.Parse(string.Format("{0:F0}", isStartStop ? 1000.0F * tstRslt.DiverterStart : 0))); /// BS [ms] Start valve open time
|
|
DiverterStartValeveCloseTime = Convert.ToInt32(Double.Parse(string.Format("{0:F0}", isStartStop ? 1000.0F * tstRslt.DiverterEnd : 0))); /// BT [ms] Start valve close time
|
|
|
|
TempUpMax = (tstRslt.TempUpMax); /// BU [°C]
|
|
TempDwMax = (tstRslt.TempDownMax); /// BV [°C]
|
|
TempUpMin = (tstRslt.TempUpMin); /// BW [°C]
|
|
TempDwMin = (tstRslt.TempDownMin); /// BX [°C]
|
|
TempT10 = (isPMaxTest ? tstRslt.TestTime : 0); /// BY [s] Duration of the pressure test
|
|
TempAmbEn = Double.Parse(string.Format("{0:F1}", Units.ConvertTo(Unit.C, tstRslt.AmbTempEnd))); /// BZ [°C]
|
|
PressAmbEn = Convert.ToInt32(Double.Parse(string.Format("{0:F0}", Units.ConvertTo(Unit.mbar, tstRslt.AmbPressEnd)))); /// CA [mbar]
|
|
HumAmbEn = Double.Parse(string.Format("{0:F1}", Units.ConvertTo(Unit.RPct, tstRslt.AmbHumiEnd))); /// CB [R%]
|
|
RefPulses = Convert.ToInt32(tstRslt.PulsesMaster); /// CC Celkovy pocet et. pulzov skusky (Prolonged : do vahy)
|
|
DiverterTestTimeCorrection = Convert.ToInt32(1000 * tstRslt.TestTimeCorrection); /// CD [ms] Diverter test time correction
|
|
|
|
BatchResults batchResults = BatchResults.FromBatch(tstRslt.Batch);
|
|
for (int i = 0; i < batchResults.WMPositionsCount; i++)
|
|
{
|
|
if (batchResults.Batch.WaterMeters != null &&
|
|
batchResults.Batch.WaterMeters.Count > i &&
|
|
batchResults.Batch.WaterMeters[i] != null &&
|
|
!batchResults.Batch.WaterMeters[i].Disabled)
|
|
{
|
|
|
|
ProcessDataMeterLine meterLine = new ProcessDataMeterLine(tstRslt, batchResults, i);
|
|
processDataMeterList.Add(meterLine);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |