TBF : Type-safe structured queries used everywhere, ver. 2.12.397

This commit is contained in:
Milan Hanajik 2016-12-02 12:52:30 +01:00
parent ae8ba80f67
commit e69836b03c
17 changed files with 325 additions and 299 deletions

View File

@ -321,10 +321,10 @@ namespace TBF.BenchControl.Sequences
///
/// Execute the transition sequence
///
IList<TransitionStep> transitionSteps = StateMachine.WtSession
.CreateQuery("FROM TransitionStep WHERE TransitionSequence = :tsId ORDER BY ItemNr")
.SetParameter("tsId", transitionSequence.Id)
.List<TransitionStep>();
IList<TransitionStep> transitionSteps = StateMachine.WtSession.QueryOver<TransitionStep>()
.Where(x => (x.TransitionSequence == transitionSequence))
.OrderBy(x => x.ItemNr).Asc
.List();
int stepsCount = transitionSteps.Count;

View File

@ -321,16 +321,16 @@ namespace TBF.BenchControl
ISession session = Config.FluentCommon.CreateSession(Config.Entities.DBKind.Config);
WtSession = session;
feedingPaths = session.CreateQuery("FROM FeedingPath ORDER BY ItemNr").List<Config.Entities.FeedingPath>();
benchPaths = session.CreateQuery("FROM BenchPath ORDER BY ItemNr").List<Config.Entities.BenchPath>();
outputPaths = session.CreateQuery("FROM OutputPath ORDER BY ItemNr").List<Config.Entities.OutputPath>();
metersPaths = session.CreateQuery("FROM MetersPath ORDER BY ItemNr").List<Config.Entities.MetersPath>();
TransitionSequences = session.CreateQuery("FROM TransitionSequence ORDER BY ItemNr").List<TransitionSequence>();
feedingPaths = session.QueryOver<Config.Entities.FeedingPath>().OrderBy(x => x.ItemNr).Asc.List();
benchPaths = session.QueryOver<Config.Entities.BenchPath>().OrderBy(x => x.ItemNr).Asc.List();
outputPaths = session.QueryOver<Config.Entities.OutputPath>().OrderBy(x => x.ItemNr).Asc.List();
metersPaths = session.QueryOver<Config.Entities.MetersPath>().OrderBy(x => x.ItemNr).Asc.List();
TransitionSequences = session.QueryOver<TransitionSequence>().OrderBy(x => x.ItemNr).Asc.List();
#if HEAT_METERS_SUPPORT
heatMetersPaths = session.CreateQuery("FROM HeatMetersPath ORDER BY ItemNr").List<Config.Entities.HeatMetersPath>();
heatMetersPaths = session.QueryOver<Config.Entities.HeatMetersPath>().OrderBy(x => x.ItemNr).Asc.List();
#endif
// Automatic detection of empty tank valves
// Automatic detection of empty tank valves
foreach (var opath in outputPaths)
{
if ((EmptyTankValve1 == null) && (Balance1 != null) && (opath.Balance == Balance1.Cfg.Name))
@ -349,10 +349,10 @@ namespace TBF.BenchControl
if (loadPathsOnly) return;
IList<Procedure> selectedProcs = session
.CreateQuery("FROM Procedure WHERE ProcedureState = 'Active' AND Name = :name")
.SetParameter("name", TBF.UiBridge.Bridge.SelectedProcedureName)
.List<Procedure>();
IList<Procedure> selectedProcs = session.QueryOver<Procedure>()
.Where(x => (x.ProcedureState == ProcedureState.Active))
.And(x => (x.Name == TBF.UiBridge.Bridge.SelectedProcedureName))
.List();
if (selectedProcs.Count != 1) return;

View File

@ -130,9 +130,9 @@ namespace TBF.BenchControl
foreach (var factory in Factories) factory.ResetStaticProperties();
/// Load the list of components from the database
IList<Component> cmptnEntities = session
.CreateQuery("FROM Component ORDER BY ItemNr")
.List<Component>();
IList<Component> cmptnEntities = session.QueryOver<Component>()
.OrderBy(x => x.ItemNr).Asc
.List();
/// Convert database entities to TBF components
IList<IComponent> components = new List<BenchControl.Generic.IComponent>();

View File

@ -120,263 +120,286 @@ namespace TBF.BenchControl.TestMethods.Endurance
int flowSetTime = StateMachine.Time - flowSetTime0;
double currentFlow = RefFlow.Val;
/// Extract cameras from the current sensors path, add operations to the detection state
IList<IOperation> measureOperations = new List<IOperation>();
for (int i = 0; i < sensPath.RegisterReaders.Length; i++)
if (test.Part <= 3) /// 0 = measurement
/// 1 = measurement through line 1
/// 2 = measurement through line 2
/// 3 = continuous test
{
GenericDevices.ICameraRoi cameraRoi = sensPath.RegisterReaders[i] as GenericDevices.ICameraRoi;
if (cameraRoi != null) measureOperations.Add(cameraRoi.MeasureOp());
}
///
/// Endurance test : measurement through line 1 or line 2
///
//------------------------------------------------
Bridge.OnActivity(this, Strings.Test_in_progress);
//------------------------------------------------
State.Create("FlyingStart : Starting the test")
.AddOperation(checkUiOp)
.AddOperation(benchPath.TempMtrUp.ReadTempOp(ref TempUp))
.AddOperation(benchPath.TempMtrDown.ReadTempOp(ref TempDown))
.AddOperation(outPath.TempDiv.ReadTempOp(ref TempDiv))
.AddOperation(benchPath.PressMtrUp.ReadPressureOp(ref PressUp))
.AddOperation(benchPath.PressMtrDown.ReadPressureOp(ref PressDown))
.AddOperation(benchPath.PressMtrDelta == null ? null : benchPath.PressMtrDelta.ReadPressureOp(ref PressDelta))
.AddOperation(heatMetersPath == null ? null : heatMetersPath.TMeterRefWarm1.ReadTempOp(ref TempRefHi1))
.AddOperation(heatMetersPath == null ? null : heatMetersPath.TMeterRefWarm2.ReadTempOp(ref TempRefHi2))
.AddOperation(heatMetersPath == null ? null : heatMetersPath.TMeterRefCold1.ReadTempOp(ref TempRefLo1))
.AddOperation(heatMetersPath == null ? null : heatMetersPath.TMeterRefCold2.ReadTempOp(ref TempRefLo2))
.AddOperation((StateMachine.Ambient != null)
? StateMachine.Ambient.ReadAmbientOp(AmbTemp, AmbPress, AmbHumi) : null)
.AddOperations(measureOperations)
.AddOperation(processDataLoggingOp)
.AddOperation(cBrd.StartMeasurementOp(outPath, Elde.TestMethods.Synchro,
test.Qfrom, test.Qto, totalPulses, (float)test.TolerRed))
.EnterState();
do
{
e = StateMachine.WaitRunDevsRunOps();
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
}
while (!e.Contains(Event.MeasurementStarted));
foreach (var rr in sensPath.RegisterReaders)
{
if (rr is WaterMeters.iPerl.WaterMeter) (rr as WaterMeters.iPerl.WaterMeter).TestName = test.Name;
}
/// Measurement loop - preparation
readRegistersOp = new Operations.ReadMoreRegistersOp(sensPath.RegisterReaders);
queryEnd1 = cBrd.QueryMeasurementEndOp();
int estimtdEndTime = StateMachine.Time + (int)test.TstTime;
ClearAllStatistics();
/// Measurement loop - begin
State.Create("Read water meters")
.AddOperation(checkUiOp)
.AddOperations(measureOperations)
.AddOperation(readRegistersOp)
.AddOperation(benchPath.TempMtrUp.ReadTempOp(ref TempUp))
.AddOperation(benchPath.TempMtrDown.ReadTempOp(ref TempDown))
.AddOperation(outPath.TempDiv.ReadTempOp(ref TempDiv))
.AddOperation(benchPath.PressMtrUp.ReadPressureOp(ref PressUp))
.AddOperation(benchPath.PressMtrDown.ReadPressureOp(ref PressDown))
.AddOperation(benchPath.PressMtrDelta == null ? null : benchPath.PressMtrDelta.ReadPressureOp(ref PressDelta))
.AddOperation(heatMetersPath == null ? null : heatMetersPath.TMeterRefWarm1.ReadTempOp(ref TempRefHi1))
.AddOperation(heatMetersPath == null ? null : heatMetersPath.TMeterRefWarm2.ReadTempOp(ref TempRefHi2))
.AddOperation(heatMetersPath == null ? null : heatMetersPath.TMeterRefCold1.ReadTempOp(ref TempRefLo1))
.AddOperation(heatMetersPath == null ? null : heatMetersPath.TMeterRefCold2.ReadTempOp(ref TempRefLo2))
.AddOperation((StateMachine.Ambient != null)
? StateMachine.Ambient.ReadAmbientOp(AmbTemp, AmbPress, AmbHumi)
: null)
.AddOperation(queryEnd1)
.AddOperation(processDataLoggingOp)
.EnterState();
do
{
e = StateMachine.WaitRunDevsRunOps();
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
if (e.Contains(Event.MeasurementCompleted)) goto test_completed;
/// Extract cameras from the current sensors path, add operations to the detection state
IList<IOperation> measureOperations = new List<IOperation>();
for (int i = 0; i < sensPath.RegisterReaders.Length; i++)
{
GenericDevices.ICameraRoi cameraRoi = sensPath.RegisterReaders[i] as GenericDevices.ICameraRoi;
if (cameraRoi != null) measureOperations.Add(cameraRoi.MeasureOp());
}
//------------------------------------------------
int remainingTime = Math.Max(estimtdEndTime - StateMachine.Time, 0);
if (remainingTime > 60)
{
Bridge.OnActivity(this, string.Format("{0} ... {1} {2} {3} {4}", Strings.Test_in_progress, remainingTime / 60, "min", remainingTime % 60, Strings.sec));
}
else
{
Bridge.OnActivity(this, string.Format("{0} ... {1} s", Strings.Test_in_progress, remainingTime));
}
Bridge.OnActivity(this, Strings.Test_in_progress);
//------------------------------------------------
State.Create("FlyingStart : Starting the test")
.AddOperation(checkUiOp)
.AddOperation(benchPath.TempMtrUp.ReadTempOp(ref TempUp))
.AddOperation(benchPath.TempMtrDown.ReadTempOp(ref TempDown))
.AddOperation(outPath.TempDiv.ReadTempOp(ref TempDiv))
.AddOperation(benchPath.PressMtrUp.ReadPressureOp(ref PressUp))
.AddOperation(benchPath.PressMtrDown.ReadPressureOp(ref PressDown))
.AddOperation(benchPath.PressMtrDelta == null ? null : benchPath.PressMtrDelta.ReadPressureOp(ref PressDelta))
.AddOperation(heatMetersPath == null ? null : heatMetersPath.TMeterRefWarm1.ReadTempOp(ref TempRefHi1))
.AddOperation(heatMetersPath == null ? null : heatMetersPath.TMeterRefWarm2.ReadTempOp(ref TempRefHi2))
.AddOperation(heatMetersPath == null ? null : heatMetersPath.TMeterRefCold1.ReadTempOp(ref TempRefLo1))
.AddOperation(heatMetersPath == null ? null : heatMetersPath.TMeterRefCold2.ReadTempOp(ref TempRefLo2))
.AddOperation((StateMachine.Ambient != null)
? StateMachine.Ambient.ReadAmbientOp(AmbTemp, AmbPress, AmbHumi) : null)
.AddOperations(measureOperations)
.AddOperation(processDataLoggingOp)
.AddOperation(cBrd.StartMeasurementOp(outPath, Elde.TestMethods.Synchro,
test.Qfrom, test.Qto, totalPulses, (float)test.TolerRed))
.EnterState();
do
{
e = StateMachine.WaitRunDevsRunOps();
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
}
while (!e.Contains(Event.MeasurementStarted));
RefFreq.Val = cBrd.ReferenceFreq;
RefFlow.Val = cBrd.ReferenceFlow;
UpdateAllStatistics();
foreach (var rr in sensPath.RegisterReaders)
{
if (rr is WaterMeters.iPerl.WaterMeter) (rr as WaterMeters.iPerl.WaterMeter).TestName = test.Name;
}
Bridge.OnProcessData(this, new ProcessDataEventArgs(test, repetitionNr, Config.Entities.Progress.Test));
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.Test));
}
while (true);
/// Measurement loop - end
/// Measurement loop - preparation
readRegistersOp = new Operations.ReadMoreRegistersOp(sensPath.RegisterReaders);
queryEnd1 = cBrd.QueryMeasurementEndOp();
int estimtdEndTime = StateMachine.Time + (int)test.TstTime;
ClearAllStatistics();
/// Measurement loop - begin
State.Create("Read water meters")
.AddOperation(checkUiOp)
.AddOperations(measureOperations)
.AddOperation(readRegistersOp)
.AddOperation(benchPath.TempMtrUp.ReadTempOp(ref TempUp))
.AddOperation(benchPath.TempMtrDown.ReadTempOp(ref TempDown))
.AddOperation(outPath.TempDiv.ReadTempOp(ref TempDiv))
.AddOperation(benchPath.PressMtrUp.ReadPressureOp(ref PressUp))
.AddOperation(benchPath.PressMtrDown.ReadPressureOp(ref PressDown))
.AddOperation(benchPath.PressMtrDelta == null ? null : benchPath.PressMtrDelta.ReadPressureOp(ref PressDelta))
.AddOperation(heatMetersPath == null ? null : heatMetersPath.TMeterRefWarm1.ReadTempOp(ref TempRefHi1))
.AddOperation(heatMetersPath == null ? null : heatMetersPath.TMeterRefWarm2.ReadTempOp(ref TempRefHi2))
.AddOperation(heatMetersPath == null ? null : heatMetersPath.TMeterRefCold1.ReadTempOp(ref TempRefLo1))
.AddOperation(heatMetersPath == null ? null : heatMetersPath.TMeterRefCold2.ReadTempOp(ref TempRefLo2))
.AddOperation((StateMachine.Ambient != null)
? StateMachine.Ambient.ReadAmbientOp(AmbTemp, AmbPress, AmbHumi)
: null)
.AddOperation(queryEnd1)
.AddOperation(processDataLoggingOp)
.EnterState();
do
{
e = StateMachine.WaitRunDevsRunOps();
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
if (e.Contains(Event.MeasurementCompleted)) goto test_completed;
//------------------------------------------------
int remainingTime = Math.Max(estimtdEndTime - StateMachine.Time, 0);
if (remainingTime > 60)
{
Bridge.OnActivity(this, string.Format("{0} ... {1} {2} {3} {4}", Strings.Test_in_progress, remainingTime / 60, "min", remainingTime % 60, Strings.sec));
}
else
{
Bridge.OnActivity(this, string.Format("{0} ... {1} s", Strings.Test_in_progress, remainingTime));
}
//------------------------------------------------
RefFreq.Val = cBrd.ReferenceFreq;
RefFlow.Val = cBrd.ReferenceFlow;
UpdateAllStatistics();
Bridge.OnProcessData(this, new ProcessDataEventArgs(test, repetitionNr, Config.Entities.Progress.Test));
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.Test));
}
while (true);
/// Measurement loop - end
test_completed:
//------------------------------------------------
Bridge.OnActivity(this, Strings.Test_completed);
//------------------------------------------------
//------------------------------------------------
Bridge.OnActivity(this, Strings.Test_completed);
//------------------------------------------------
TestEndTime = DateTime.Now;
TestEndTime = DateTime.Now;
/// Make sure the CycleBeginForm is closed so that water meter data (s/n) can be copied into results
if (UIFlowControl.Stop == WaitBeginFormClosed()) goto stopTest;
/// Make sure the CycleBeginForm is closed so that water meter data (s/n) can be copied into results
if (UIFlowControl.Stop == WaitBeginFormClosed()) goto stopTest;
///
/// Populate TestResult data entity with data
///
Results.Entities.TestRslt tstRslt = BatchRslts.GetTestRslt(testName, test.Part);
if (tstRslt != null)
{
/// Auxiliary results
tstRslt.AmbTempMean = (float)AmbTempStat.Average;
tstRslt.AmbTempStart = (float)AmbTempStat.First;
tstRslt.AmbTempEnd = (float)AmbTempStat.Last;
tstRslt.AmbTempMin = (float)AmbTempStat.Min;
tstRslt.AmbTempMax = (float)AmbTempStat.Max;
tstRslt.AmbPressMean = (float)AmbPressStat.Average;
tstRslt.AmbPressStart = (float)AmbPressStat.First;
tstRslt.AmbPressEnd = (float)AmbPressStat.Last;
tstRslt.AmbPressMin = (float)AmbPressStat.Min;
tstRslt.AmbPressMax = (float)AmbPressStat.Max;
tstRslt.AmbHumiMean = (float)AmbHumiStat.Average;
tstRslt.AmbHumiStart = (float)AmbHumiStat.First;
tstRslt.AmbHumiEnd = (float)AmbHumiStat.Last;
tstRslt.AmbHumiMin = (float)AmbHumiStat.Min;
tstRslt.AmbHumiMax = (float)AmbHumiStat.Max;
tstRslt.PressUpMean = (float)PressUpStat.Average;
tstRslt.PressUpStart = (float)PressUpStat.First;
tstRslt.PressUpEnd = (float)PressUpStat.Last;
tstRslt.PressUpMin = (float)PressUpStat.Min;
tstRslt.PressUpMax = (float)PressUpStat.Max;
tstRslt.PressDownMean = (float)PressDownStat.Average;
tstRslt.PressDownStart = (float)PressDownStat.First;
tstRslt.PressDownEnd = (float)PressDownStat.Last;
tstRslt.PressDownMin = (float)PressDownStat.Min;
tstRslt.PressDownMax = (float)PressDownStat.Max;
tstRslt.PressDeltaMean = (float)PressDeltaStat.Average;
tstRslt.PressDeltaStart = (float)PressDeltaStat.First;
tstRslt.PressDeltaEnd = (float)PressDeltaStat.Last;
tstRslt.PressDeltaMin = (float)PressDeltaStat.Min;
tstRslt.PressDeltaMax = (float)PressDeltaStat.Max;
tstRslt.TempUpMean = (float)TempUpStat.Average;
tstRslt.TempUpStart = (float)TempUpStat.First;
tstRslt.TempUpEnd = (float)TempUpStat.Last;
tstRslt.TempUpMin = (float)TempUpStat.Min;
tstRslt.TempUpMax = (float)TempUpStat.Max;
tstRslt.TempDownMean = (float)TempDownStat.Average;
tstRslt.TempDownStart = (float)TempDownStat.First;
tstRslt.TempDownEnd = (float)TempDownStat.Last;
tstRslt.TempDownMin = (float)TempDownStat.Min;
tstRslt.TempDownMax = (float)TempDownStat.Max;
tstRslt.TempDivMean = (float)TempDivStat.Average;
tstRslt.TempDivStart = (float)TempDivStat.First;
tstRslt.TempDivEnd = (float)TempDivStat.Last;
tstRslt.TempDivMin = (float)TempDivStat.Min;
tstRslt.TempDivMax = (float)TempDivStat.Max;
tstRslt.DensityIn = Formulas.WaterDensityFromTemp(tstRslt.TempUpMean); /// [kg/m3]
tstRslt.DensityOut = Formulas.WaterDensityFromTemp(tstRslt.TempDownMean); /// [kg/m3]
tstRslt.DensityDiv = Formulas.WaterDensityFromTemp(tstRslt.TempDivMean); /// [kg/m3]
/// Main results
tstRslt.StartTime = TestStartTime;
tstRslt.EndTime = TestEndTime;
tstRslt.FlowSetTime = flowSetTime;
tstRslt.TestTime = cBrd.TTime; /// [s] measurement time
tstRslt.PulsesMaster = Convert.ToDouble(cBrd.EtPulses(0)); /// Pulses of the master flow meter (test total)
tstRslt.MassStartRaw = 0;
tstRslt.MassStart = 0;
tstRslt.MassEndRaw = 0;
tstRslt.MassEnd = 0;
tstRslt.FlowMass = 0; /// [kg/h]
tstRslt.FlowVolume = 3.6 * LtrPerRefPulse * tstRslt.PulsesMaster / tstRslt.TestTime; /// [m3/h]
tstRslt.VolumeMaster = LtrPerRefPulse * tstRslt.PulsesMaster; /// [l] volume from the master flow meter
tstRslt.ConstMaster = outPath.FlowMeter.LtrPerPulseCorrected(tstRslt.FlowVolume); /// Corrected master pulses per liter
tstRslt.VolumeCTV = tstRslt.ConstMaster * tstRslt.PulsesMaster; /// [l] 1000.0f is because density is in [kg/m3]
tstRslt.ErrorMaster = 0.0; /// Cannot be determined without a mass measurement
tstRslt.FlowMin = (float)((tstRslt.VolumeMaster != 0) ? (RefFlowStat.Min * tstRslt.VolumeCTV / tstRslt.VolumeMaster) : RefFlowStat.Min);
tstRslt.FlowMax = (float)((tstRslt.VolumeMaster != 0) ? (RefFlowStat.Max * tstRslt.VolumeCTV / tstRslt.VolumeMaster) : RefFlowStat.Max);
///
/// Single meters
///
for (int i = 0; i < BatchRslts.WMPositionsCount; i++)
if (test.Part <= 2) /// 0 = measurement
/// 1 = measurement through line 1
/// 2 = measurement through line 2
{
if (test.Part != 0 && test.Part != Utils.PartNr(i + 1, BatchRslts.Batch.Compound)) continue;
///
/// Populate TestResult data entity with data
///
Results.Entities.TestRslt tstRslt = BatchRslts.GetTestRslt(testName, test.Part);
Results.Entities.MeterTestRslt meterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.Single);
GenericDevices.IRegisterReader regReader = sensPath.RegisterReaders[i];
WaterMeters.iPerl.WaterMeter iPerl = regReader as WaterMeters.iPerl.WaterMeter;
if (meterRslt != null && regReader != null)
if (tstRslt != null)
{
meterRslt.PulsesPerLiter = regReader.PulsesPerLtr;
meterRslt.PulsesMeter = Convert.ToDouble(regReader.WMPulses);
meterRslt.PulsesMaster = Convert.ToDouble(regReader.WMRefPulses);
/// Auxiliary results
tstRslt.AmbTempMean = (float)AmbTempStat.Average;
tstRslt.AmbTempStart = (float)AmbTempStat.First;
tstRslt.AmbTempEnd = (float)AmbTempStat.Last;
tstRslt.AmbTempMin = (float)AmbTempStat.Min;
tstRslt.AmbTempMax = (float)AmbTempStat.Max;
tstRslt.AmbPressMean = (float)AmbPressStat.Average;
tstRslt.AmbPressStart = (float)AmbPressStat.First;
tstRslt.AmbPressEnd = (float)AmbPressStat.Last;
tstRslt.AmbPressMin = (float)AmbPressStat.Min;
tstRslt.AmbPressMax = (float)AmbPressStat.Max;
tstRslt.AmbHumiMean = (float)AmbHumiStat.Average;
tstRslt.AmbHumiStart = (float)AmbHumiStat.First;
tstRslt.AmbHumiEnd = (float)AmbHumiStat.Last;
tstRslt.AmbHumiMin = (float)AmbHumiStat.Min;
tstRslt.AmbHumiMax = (float)AmbHumiStat.Max;
tstRslt.PressUpMean = (float)PressUpStat.Average;
tstRslt.PressUpStart = (float)PressUpStat.First;
tstRslt.PressUpEnd = (float)PressUpStat.Last;
tstRslt.PressUpMin = (float)PressUpStat.Min;
tstRslt.PressUpMax = (float)PressUpStat.Max;
tstRslt.PressDownMean = (float)PressDownStat.Average;
tstRslt.PressDownStart = (float)PressDownStat.First;
tstRslt.PressDownEnd = (float)PressDownStat.Last;
tstRslt.PressDownMin = (float)PressDownStat.Min;
tstRslt.PressDownMax = (float)PressDownStat.Max;
tstRslt.PressDeltaMean = (float)PressDeltaStat.Average;
tstRslt.PressDeltaStart = (float)PressDeltaStat.First;
tstRslt.PressDeltaEnd = (float)PressDeltaStat.Last;
tstRslt.PressDeltaMin = (float)PressDeltaStat.Min;
tstRslt.PressDeltaMax = (float)PressDeltaStat.Max;
tstRslt.TempUpMean = (float)TempUpStat.Average;
tstRslt.TempUpStart = (float)TempUpStat.First;
tstRslt.TempUpEnd = (float)TempUpStat.Last;
tstRslt.TempUpMin = (float)TempUpStat.Min;
tstRslt.TempUpMax = (float)TempUpStat.Max;
tstRslt.TempDownMean = (float)TempDownStat.Average;
tstRslt.TempDownStart = (float)TempDownStat.First;
tstRslt.TempDownEnd = (float)TempDownStat.Last;
tstRslt.TempDownMin = (float)TempDownStat.Min;
tstRslt.TempDownMax = (float)TempDownStat.Max;
tstRslt.TempDivMean = (float)TempDivStat.Average;
tstRslt.TempDivStart = (float)TempDivStat.First;
tstRslt.TempDivEnd = (float)TempDivStat.Last;
tstRslt.TempDivMin = (float)TempDivStat.Min;
tstRslt.TempDivMax = (float)TempDivStat.Max;
tstRslt.DensityIn = Formulas.WaterDensityFromTemp(tstRslt.TempUpMean); /// [kg/m3]
tstRslt.DensityOut = Formulas.WaterDensityFromTemp(tstRslt.TempDownMean); /// [kg/m3]
tstRslt.DensityDiv = Formulas.WaterDensityFromTemp(tstRslt.TempDivMean); /// [kg/m3]
if (iPerl != null)
{
meterRslt.TimestampStart = iPerl.TimestampSecStart;
meterRslt.TimestampEnd = iPerl.NoSamples ? (iPerl.TimestampSecStart + tstRslt.TestTime) : iPerl.TimestampSecEnd;
meterRslt.TestTime = iPerl.NoSamples ? tstRslt.TestTime : (meterRslt.TimestampEnd - meterRslt.TimestampStart);
meterRslt.VolumeStart = iPerl.VolumeLtrStart; /// liter
meterRslt.VolumeEnd = iPerl.VolumeLtrEnd; /// liter
meterRslt.VolumeMeter = Math.Abs(iPerl.VolumeLtrEnd - iPerl.VolumeLtrStart);
meterRslt.VolumeRef = tstRslt.VolumeCTV * meterRslt.TestTime / tstRslt.TestTime;
iPerl.VolumeLtrRef = meterRslt.VolumeRef;
iPerl.LastTestResult2 = iPerl.LastTestResult; /// Save shift previous test result
iPerl.LastTestResult = meterRslt; /// Save this test result
iPerl.NominalTestFlow = 500.0 * (test.Qfrom + test.Qto); /// Ave. + convert to liter/hour
}
else
{
meterRslt.TestTime = tstRslt.TestTime; /// TODO: Malo by sa citat z dosky
meterRslt.VolumeStart = 0;
meterRslt.VolumeEnd = 0;
meterRslt.VolumeMeter = meterRslt.PulsesMeter * regReader.LtrsPerPulse; /// liter
meterRslt.VolumeRef = meterRslt.PulsesMaster * tstRslt.ConstMaster; /// liter
}
/// Main results
tstRslt.StartTime = TestStartTime;
tstRslt.EndTime = TestEndTime;
tstRslt.FlowSetTime = flowSetTime;
tstRslt.TestTime = cBrd.TTime; /// [s] measurement time
tstRslt.PulsesMaster = Convert.ToDouble(cBrd.EtPulses(0)); /// Pulses of the master flow meter (test total)
tstRslt.MassStartRaw = 0;
tstRslt.MassStart = 0;
tstRslt.MassEndRaw = 0;
tstRslt.MassEnd = 0;
tstRslt.FlowMass = 0; /// [kg/h]
tstRslt.FlowVolume = 3.6 * LtrPerRefPulse * tstRslt.PulsesMaster / tstRslt.TestTime; /// [m3/h]
tstRslt.VolumeMaster = LtrPerRefPulse * tstRslt.PulsesMaster; /// [l] volume from the master flow meter
tstRslt.ConstMaster = outPath.FlowMeter.LtrPerPulseCorrected(tstRslt.FlowVolume); /// Corrected master pulses per liter
tstRslt.VolumeCTV = tstRslt.ConstMaster * tstRslt.PulsesMaster; /// [l] 1000.0f is because density is in [kg/m3]
tstRslt.ErrorMaster = 0.0; /// Cannot be determined without a mass measurement
meterRslt.Error = Formulas.ErrorFromVolumes(meterRslt.VolumeMeter, meterRslt.VolumeRef);
meterRslt.Passed = (meterRslt.Error >= test.ErrLimLo + test.Uncertainty)
&& (meterRslt.Error <= test.ErrLimHi - test.Uncertainty);
meterRslt.TestDone = true;
tstRslt.FlowMin = (float)((tstRslt.VolumeMaster != 0) ? (RefFlowStat.Min * tstRslt.VolumeCTV / tstRslt.VolumeMaster) : RefFlowStat.Min);
tstRslt.FlowMax = (float)((tstRslt.VolumeMaster != 0) ? (RefFlowStat.Max * tstRslt.VolumeCTV / tstRslt.VolumeMaster) : RefFlowStat.Max);
///
/// Single meters
///
for (int i = 0; i < BatchRslts.WMPositionsCount; i++)
{
if (test.Part != 0 && test.Part != Utils.PartNr(i + 1, BatchRslts.Batch.Compound)) continue;
Results.Entities.MeterTestRslt meterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.Single);
GenericDevices.IRegisterReader regReader = sensPath.RegisterReaders[i];
WaterMeters.iPerl.WaterMeter iPerl = regReader as WaterMeters.iPerl.WaterMeter;
if (meterRslt != null && regReader != null)
{
meterRslt.PulsesPerLiter = regReader.PulsesPerLtr;
meterRslt.PulsesMeter = Convert.ToDouble(regReader.WMPulses);
meterRslt.PulsesMaster = Convert.ToDouble(regReader.WMRefPulses);
if (iPerl != null)
{
meterRslt.TimestampStart = iPerl.TimestampSecStart;
meterRslt.TimestampEnd = iPerl.NoSamples ? (iPerl.TimestampSecStart + tstRslt.TestTime) : iPerl.TimestampSecEnd;
meterRslt.TestTime = iPerl.NoSamples ? tstRslt.TestTime : (meterRslt.TimestampEnd - meterRslt.TimestampStart);
meterRslt.VolumeStart = iPerl.VolumeLtrStart; /// liter
meterRslt.VolumeEnd = iPerl.VolumeLtrEnd; /// liter
meterRslt.VolumeMeter = Math.Abs(iPerl.VolumeLtrEnd - iPerl.VolumeLtrStart);
meterRslt.VolumeRef = tstRslt.VolumeCTV * meterRslt.TestTime / tstRslt.TestTime;
iPerl.VolumeLtrRef = meterRslt.VolumeRef;
iPerl.LastTestResult2 = iPerl.LastTestResult; /// Save shift previous test result
iPerl.LastTestResult = meterRslt; /// Save this test result
iPerl.NominalTestFlow = 500.0 * (test.Qfrom + test.Qto); /// Ave. + convert to liter/hour
}
else
{
meterRslt.TestTime = tstRslt.TestTime; /// TODO: Malo by sa citat z dosky
meterRslt.VolumeStart = 0;
meterRslt.VolumeEnd = 0;
meterRslt.VolumeMeter = meterRslt.PulsesMeter * regReader.LtrsPerPulse; /// liter
meterRslt.VolumeRef = meterRslt.PulsesMaster * tstRslt.ConstMaster; /// liter
}
meterRslt.Error = Formulas.ErrorFromVolumes(meterRslt.VolumeMeter, meterRslt.VolumeRef);
meterRslt.Passed = (meterRslt.Error >= test.ErrLimLo + test.Uncertainty)
&& (meterRslt.Error <= test.ErrLimHi - test.Uncertainty);
meterRslt.TestDone = true;
}
}
}
tstRslt.Components = Results.Entities.Components
.UpdateList(BatchRslts.ComponentsList,
new Results.Entities.Components((BenchInfo != null) ? BenchInfo.TestBenchId : 1,
(BenchInfo != null) ? BenchInfo.TestBenchName : "testbench",
inPath.Pump != null ? inPath.Pump.Name : string.Empty,
outPath.FlowMeter != null ? outPath.FlowMeter.Name : string.Empty,
outPath.Balance != null ? outPath.Balance.Name : string.Empty,
outPath.RegulValve != null ? outPath.RegulValve.Name : string.Empty,
outPath.Diverter != null ? outPath.Diverter.Name : string.Empty));
/// Update results
Bridge.OnTestCompleted(this, new TestCompletedEventArgs(testName, tstRslt));
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.TransitionAfter));
/// Append the results to the CSV-file
allResults.Info(TestResult2CsvLine(testName, test.Part));
}
}
else if (test.Part == 4)
{
///
/// Endurance test : switching mode
///
tstRslt.Components = Results.Entities.Components
.UpdateList(BatchRslts.ComponentsList,
new Results.Entities.Components((BenchInfo != null) ? BenchInfo.TestBenchId : 1,
(BenchInfo != null) ? BenchInfo.TestBenchName : "testbench",
inPath.Pump != null ? inPath.Pump.Name : string.Empty,
outPath.FlowMeter != null ? outPath.FlowMeter.Name : string.Empty,
outPath.Balance != null ? outPath.Balance.Name : string.Empty,
outPath.RegulValve != null ? outPath.RegulValve.Name : string.Empty,
outPath.Diverter != null ? outPath.Diverter.Name : string.Empty));
}
/// Update results
Bridge.OnTestCompleted(this, new TestCompletedEventArgs(testName, tstRslt));
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.TransitionAfter));
/// Append the results to the CSV-file
allResults.Info(TestResult2CsvLine(testName, test.Part));
if (++repetitionNr <= test.Repeats)
{

View File

@ -48,15 +48,12 @@ namespace TBF.Forms
if (User.CurrentUser.IsMemberOf(Config.Grp.GID.Administrators) || User.CurrentUser.IsMemberOf(Config.Grp.GID.HeadOfLab))
{
/// Admin and HeadOfLab can edit all users
ListOfUsers = session.CreateQuery("FROM User")
.List<User>();
ListOfUsers = session.QueryOver<User>().List();
}
else
{
/// user can only edit their own data
ListOfUsers = session.CreateQuery("FROM User WHERE id= :CurrentUserId")
.SetParameter("CurrentUserId", User.CurrentUser.Id)
.List<User>();
ListOfUsers = session.QueryOver<User>().Where(x => (x == User.CurrentUser)).List();
}
listViewUsers.Items.Clear();

View File

@ -379,8 +379,10 @@ namespace TBF
string oriProcName = procedureComboBox.Text;
IList<Procedure> procedures = Config.FluentCommon.CreateSession(Config.Entities.DBKind.Config)
.CreateQuery("FROM Procedure WHERE ProcedureState = 'Active' ORDER BY ItemNr")
.List<Procedure>();
.QueryOver<Procedure>()
.Where(x => (x.ProcedureState == ProcedureState.Active))
.OrderBy(x => x.ItemNr).Asc
.List();
procedureComboBox.Items.Clear();
foreach (var proc in procedures) procedureComboBox.Items.Add(proc.Name);
@ -499,10 +501,9 @@ namespace TBF
NHibernate.ISession session = Config.FluentCommon.CreateSession(Config.Entities.DBKind.Config);
IList<TestResult> testResults = session
.CreateQuery("FROM TestResult WHERE PurchaseOrder = :purchaseOrder")
.SetParameter("purchaseOrder", purchaseOrder)
.List<TestResult>();
IList<TestResult> testResults = session.QueryOver<TestResult>()
.Where(x => (x.PurchaseOrder == purchaseOrder))
.List();
if (testResults.Count == 0)
{
@ -554,10 +555,10 @@ namespace TBF
}
}
IList<Procedure> procedure = session
.CreateQuery("FROM Procedure WHERE ProcedureState = 'Active' AND Name = :procedureName")
.SetParameter("procedureName", testResults[0].ProcedureName)
.List<Procedure>();
IList<Procedure> procedure = session.QueryOver<Procedure>()
.Where(x => (x.ProcedureState == ProcedureState.Active))
.And(x => (x.Name == testResults[0].ProcedureName))
.List();
if (procedure.Count != 1)
{

View File

@ -52,8 +52,9 @@ namespace TBF
int platinumTempMetersCount = 0;
session = Config.FluentCommon.CreateSession(Config.Entities.DBKind.Config);
cmpntEntities = session.CreateQuery("FROM Component ORDER BY ItemNr")
.List<Component>();
cmpntEntities = session.QueryOver<Component>()
.OrderBy(x => x. ItemNr).Asc
.List();
// Density tab-page
fixedCount++;

View File

@ -179,8 +179,9 @@ namespace TBF
{
NHibernate.ISession session = Config.FluentCommon.CreateSession(Config.Entities.DBKind.Config);
IList<Config.Entities.Procedure> procedures = session.CreateQuery("FROM Procedure ORDER BY ItemNr")
.List<Config.Entities.Procedure>();
IList<Config.Entities.Procedure> procedures = session.QueryOver<Config.Entities.Procedure>()
.OrderBy(x => x.ItemNr).Asc
.List();
///IList<TBF.BenchControl.Generic.IComponent> components = TBF.BenchControl.TbfComponents.LoadComponentsFromDB(session);
///

View File

@ -264,9 +264,10 @@ namespace TBF
/// This is to trigger an exception in case of a power user and no Config database
IList<Procedure> listOfProcedures = Config.FluentCommon.CreateSession(Config.Entities.DBKind.Config)
.CreateQuery("FROM Procedure WHERE ProcedureState = 'Active' AND Name = :procName")
.SetParameter("procName", LocalSettings.LastProcedureName)
.List<Procedure>();
.QueryOver<Procedure>()
.Where(x => (x.ProcedureState == ProcedureState.Active))
.And(x => (x.Name == LocalSettings.LastProcedureName))
.List();
retryLogin = false;
break;
@ -309,9 +310,10 @@ namespace TBF
if (LocalSettings.LastProcedureName != null)
{
IList<Procedure> listOfProcedures = Config.FluentCommon.CreateSession(Config.Entities.DBKind.Config)
.CreateQuery("FROM Procedure WHERE ProcedureState = 'Active' AND Name = :procName")
.SetParameter("procName", LocalSettings.LastProcedureName)
.List<Procedure>();
.QueryOver<Procedure>()
.Where(x => (x.ProcedureState == ProcedureState.Active))
.And(x => (x.Name == LocalSettings.LastProcedureName))
.List();
if (listOfProcedures.Count == 1)
{

View File

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

View File

@ -114,10 +114,10 @@ namespace TBF.UiControls
string oriTestName = testComboBox.Text;
IList<Procedure> procedures = Config.FluentCommon.CreateSession(Config.Entities.DBKind.Config)
.CreateQuery("FROM Procedure WHERE ProcedureState = 'Active' AND Name = :name")
.SetParameter("name", Program.MainWnd.ProcedureName)
.List<Procedure>();
.QueryOver<Procedure>()
.Where(x => (x.ProcedureState == ProcedureState.Active))
.And(x => (x.Name == Program.MainWnd.ProcedureName))
.List();
if (procedures.Count != 1)
{
testComboBox.Text = string.Empty;

View File

@ -50,9 +50,9 @@ namespace TBF.UiControls
this.parentControl = parentControl;
/// Load the paths
MyItems = parent.Session
.CreateQuery("FROM BenchPath ORDER BY ItemNr")
.List<Config.Entities.BenchPath>();
MyItems = parent.Session.QueryOver<Config.Entities.BenchPath>()
.OrderBy(x => x.ItemNr).Asc
.List();
SubItemClicked += new Results.Forms.SubItemEventHandler(listViewEx_SubItemClicked);
SubItemRightClicked += new Results.Forms.SubItemEventHandler(listViewEx_SubItemRightClicked);

View File

@ -47,10 +47,9 @@ namespace TBF.UiControls
this.parentControl = parentControl;
/// Load the paths
//MyItems = parent.Session
// .CreateQuery("FROM FeedingPath ORDER BY ItemNr")
// .List<Config.Entities.FeedingPath>();
MyItems = parent.Session.QueryOver<FeedingPath>().OrderBy(x => x.ItemNr).Asc.List();
MyItems = parent.Session.QueryOver<FeedingPath>()
.OrderBy(x => x.ItemNr).Asc
.List();
SubItemClicked += new Results.Forms.SubItemEventHandler(listViewEx_SubItemClicked);
SubItemRightClicked += new Results.Forms.SubItemEventHandler(listViewEx_SubItemRightClicked);

View File

@ -53,9 +53,9 @@ namespace TBF.UiControls
#if HEAT_METERS_SUPPORT
/// Load the paths
MyItems = parent.Session
.CreateQuery("FROM HeatMetersPath ORDER BY ItemNr")
.List<Config.Entities.HeatMetersPath>();
MyItems = parent.Session.QueryOver<Config.Entities.HeatMetersPath>()
.OrderBy(x => x.ItemNr).Asc
.List();
SubItemClicked += new Results.Forms.SubItemEventHandler(listViewEx_SubItemClicked);
SubItemRightClicked += new Results.Forms.SubItemEventHandler(listViewEx_SubItemRightClicked);

View File

@ -40,9 +40,9 @@ namespace TBF.UiControls
this.parentControl = parentControl;
/// Load the paths
MyItems = parent.Session
.CreateQuery("FROM MetersPath ORDER BY ItemNr")
.List<Config.Entities.MetersPath>();
MyItems = parent.Session.QueryOver<Config.Entities.MetersPath>()
.OrderBy(x => x.ItemNr).Asc
.List();
SubItemClicked += new Results.Forms.SubItemEventHandler(listViewEx_SubItemClicked);
SubItemRightClicked += new Results.Forms.SubItemEventHandler(listViewEx_SubItemRightClicked);

View File

@ -53,9 +53,9 @@ namespace TBF.UiControls
this.parentControl = parentControl;
/// Load the paths
MyItems = parent.Session
.CreateQuery("FROM OutputPath ORDER BY ItemNr")
.List<Config.Entities.OutputPath>();
MyItems = parent.Session.QueryOver<Config.Entities.OutputPath>()
.OrderBy(x => x.ItemNr).Asc
.List();
SubItemClicked += new Results.Forms.SubItemEventHandler(listViewEx_SubItemClicked);
SubItemRightClicked += new Results.Forms.SubItemEventHandler(listViewEx_SubItemRightClicked);

View File

@ -76,8 +76,10 @@ namespace TBF.UiControls
/// Load the procedures
if (session == null) session = Config.FluentCommon.CreateSession(Config.Entities.DBKind.Config);
MyItems = session.CreateQuery("FROM Procedure WHERE ProcedureState = 'Active' ORDER BY ItemNr")
.List<Procedure>();
MyItems = session.QueryOver<Procedure>()
.Where(x => (x.ProcedureState == ProcedureState.Active))
.OrderBy(x => x.ItemNr).Asc
.List();
base.RedrawAll();
}