ILevelMeter.Level (immediate measurement), Nivotrack uses correction table, etc.
This commit is contained in:
parent
872409870e
commit
2a98c485ef
@ -19,6 +19,11 @@ namespace TBF.BenchControl.GenericDevices
|
||||
/// </summary>
|
||||
IList<MeasurementCorrection> Corrections { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Continuosly measured level in mm (last measured level in case of ManualLevelMsrmnt)
|
||||
/// </summary>
|
||||
double Level { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Events: Busy, LevelDone, Error
|
||||
/// </summary>
|
||||
|
||||
@ -23,13 +23,14 @@ namespace TBF.BenchControl.Hart.Nivotrack
|
||||
public class Nivotrack : ComponentBase, IDevice, ILevelMeter, IOperation
|
||||
{
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(Nivotrack));
|
||||
public override string ToString() { return string.Format("Nivotrack({0})", Cfg.ToString(1)); }
|
||||
public override string ToString() { return string.Format("{0}({1})", Cfg.Name, Cfg.ToString(-1)); }
|
||||
|
||||
private readonly NivotrackCfg nivotrackCfg;
|
||||
private readonly IHart hart;
|
||||
|
||||
bool readingValid;
|
||||
double waterLevel;
|
||||
double rawLevel_mm;
|
||||
public double Level { get { return ReadLevel(); } }
|
||||
|
||||
DoubleBox levelBox;
|
||||
|
||||
@ -64,7 +65,7 @@ namespace TBF.BenchControl.Hart.Nivotrack
|
||||
{
|
||||
if (nivotrackCfg.DebugLevel == DebugMode.Simulate) return;
|
||||
|
||||
waterLevel = 0;
|
||||
rawLevel_mm = 0;
|
||||
readingValid = false;
|
||||
}
|
||||
|
||||
@ -116,18 +117,12 @@ namespace TBF.BenchControl.Hart.Nivotrack
|
||||
/// A frame with a status and a primary variable
|
||||
///
|
||||
ushort state = (ushort)(256 * data[4] + data[5]);
|
||||
|
||||
byte unitsID = data[6];
|
||||
|
||||
float val = System.BitConverter.ToSingle(data, 7);
|
||||
|
||||
byte[] floatData2 = new byte[] { data[10], data[9], data[8], data[7] };
|
||||
float val2 = System.BitConverter.ToSingle(floatData2, 0);
|
||||
|
||||
waterLevel = val;
|
||||
byte[] floatData = new byte[] { data[10], data[9], data[8], data[7] };
|
||||
rawLevel_mm = System.BitConverter.ToSingle(floatData, 0);
|
||||
readingValid = true;
|
||||
|
||||
string msg = string.Format("{0} : Received water level = {1} mm / {2} mm, State = {3}", Name, val, val2, state.ToString("X4"));
|
||||
string msg = string.Format("{0} : Received water level = {1} mm, State = {2}", Name, rawLevel_mm, state.ToString("X4"));
|
||||
Debug.WriteLine(msg);
|
||||
log.Info(msg);
|
||||
}
|
||||
@ -160,9 +155,13 @@ namespace TBF.BenchControl.Hart.Nivotrack
|
||||
public void StopDevice2() { }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets the most recent raw level measurement and applies correction table
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public double ReadLevel()
|
||||
{
|
||||
return waterLevel;
|
||||
return Config.Formulas.CorrectedValue(rawLevel_mm, Corrections);
|
||||
}
|
||||
|
||||
/// <returns>Reference to the operation</returns>
|
||||
@ -177,7 +176,10 @@ namespace TBF.BenchControl.Hart.Nivotrack
|
||||
/// <summary>Start this operation</summary>
|
||||
public void Start()
|
||||
{
|
||||
if (readingValid && (levelBox != null)) levelBox.Val = waterLevel;
|
||||
if (readingValid && (levelBox != null))
|
||||
{
|
||||
levelBox.Val = ReadLevel();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Run this operation</summary>
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
///
|
||||
/// Copyright (c) 2018 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.IO.Ports;
|
||||
@ -10,7 +11,7 @@ using TBF.BenchControl.Generic;
|
||||
|
||||
namespace TBF.BenchControl.Hart.Nivotrack
|
||||
{
|
||||
public class NivotrackCfg : ComponentCfgBase, Generic.IChildComponentCfg, Config.Entities.IParamsProvider
|
||||
public class NivotrackCfg : ComponentCfgBase, Generic.IChildComponentCfg, Config.Entities.IParamsProvider, GenericDevices.ICalibInfoCfg
|
||||
{
|
||||
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(NivotrackCfg) })[0];
|
||||
public override XmlSerializer GetSerializer() { return Serializer; }
|
||||
@ -34,6 +35,28 @@ namespace TBF.BenchControl.Hart.Nivotrack
|
||||
public int Par1;
|
||||
public int Par2;
|
||||
|
||||
|
||||
/// Calibration info serialized parameters displayed in Metrology tab page
|
||||
string calibCertificateNr;
|
||||
DateTime calibDate;
|
||||
DateTime calibValidDate;
|
||||
public string CalibCertificateNr
|
||||
{
|
||||
get { return calibCertificateNr; }
|
||||
set { calibCertificateNr = value; }
|
||||
}
|
||||
public DateTime CalibDate
|
||||
{
|
||||
get { return calibDate; }
|
||||
set { calibDate = value; }
|
||||
}
|
||||
public DateTime CalibValidDate
|
||||
{
|
||||
get { return calibValidDate; }
|
||||
set { calibValidDate = value; }
|
||||
}
|
||||
|
||||
|
||||
/// Private parameterless constructor invoked by all other (public) constructors
|
||||
NivotrackCfg() { }
|
||||
|
||||
@ -79,7 +102,7 @@ namespace TBF.BenchControl.Hart.Nivotrack
|
||||
{
|
||||
if (i == -1)
|
||||
{
|
||||
return string.Format("Address={0}, Par1={1}, Par2={2}", Address, Par1, Par2);
|
||||
return string.Format("Address={0}", Address);
|
||||
}
|
||||
|
||||
switch (i)
|
||||
|
||||
@ -32,6 +32,8 @@ namespace TBF.BenchControl.Modbus.UltrasoundLevelMeter
|
||||
double temperature; /// [°C]
|
||||
ushort state;
|
||||
|
||||
public double Level { get { return level; } }
|
||||
|
||||
/// <summary>Measurement time stamp when MsrmntState == MsrmntState.Valid</summary>
|
||||
int msrmntTimeStamp;
|
||||
|
||||
|
||||
@ -16,9 +16,9 @@ namespace TBF.BenchControl.Various.ManualLevelMsrmnt
|
||||
|
||||
readonly TestMethodCfg myCfg;
|
||||
|
||||
DoubleBox levelBox;
|
||||
|
||||
public double WaterLevelMm;
|
||||
public double Level { get { return level_mm; } }
|
||||
double level_mm;
|
||||
DoubleBox levelBox;
|
||||
|
||||
WaterLevelForm waterLevelForm;
|
||||
|
||||
@ -88,8 +88,8 @@ namespace TBF.BenchControl.Various.ManualLevelMsrmnt
|
||||
if (!resultSaved && (currentOp == CurrentOp.EnterLevel) && (waterLevelForm != null))
|
||||
{
|
||||
/// Save the result (only once)
|
||||
WaterLevelMm = waterLevelForm.WaterLevelMm;
|
||||
if (levelBox != null) levelBox.Val = WaterLevelMm;
|
||||
level_mm = waterLevelForm.Level_mm;
|
||||
if (levelBox != null) levelBox.Val = level_mm;
|
||||
resultSaved = true;
|
||||
}
|
||||
|
||||
|
||||
@ -17,7 +17,7 @@ namespace TBF.BenchControl.Various.ManualLevelMsrmnt
|
||||
bool completed;
|
||||
|
||||
/// <summary> Water level in mm entered by the user </summary>
|
||||
public double WaterLevelMm;
|
||||
public double Level_mm;
|
||||
|
||||
|
||||
/// <summary>
|
||||
@ -28,7 +28,7 @@ namespace TBF.BenchControl.Various.ManualLevelMsrmnt
|
||||
{
|
||||
InitializeComponent();
|
||||
ControlBox = false;
|
||||
WaterLevelMm = 0;
|
||||
Level_mm = 0;
|
||||
completed = false;
|
||||
StartForceCloseHandler();
|
||||
}
|
||||
@ -57,7 +57,7 @@ namespace TBF.BenchControl.Various.ManualLevelMsrmnt
|
||||
|
||||
try
|
||||
{
|
||||
WaterLevelMm = Utils.ParseUDouble(waterLevelTextBox.Text);
|
||||
Level_mm = Utils.ParseUDouble(waterLevelTextBox.Text);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
@ -63,6 +63,8 @@ namespace TBF.BenchControl.Various.TankWithLevelMsrmnt
|
||||
public string Format { get { return "F3"; } }
|
||||
|
||||
|
||||
public double Volume { get { return Level2Volume(levelMeter.Level); } }
|
||||
|
||||
|
||||
public Tank()
|
||||
{
|
||||
@ -73,7 +75,7 @@ namespace TBF.BenchControl.Various.TankWithLevelMsrmnt
|
||||
/// </summary>
|
||||
/// <param name="cfg">Balance properties</param>
|
||||
/// <param components="cfg">A list of components loaded so far</param>
|
||||
public Tank(Generic.IComponentCfg cfg)
|
||||
public Tank(Generic.IComponentCfg cfg)
|
||||
: base(cfg)
|
||||
{
|
||||
tankCfg = cfg as TankCfg;
|
||||
@ -87,10 +89,9 @@ namespace TBF.BenchControl.Various.TankWithLevelMsrmnt
|
||||
if (tanksSoFar != null) for (int i = 0; i < tanksSoFar.Length; i++) Tanks[i] = tanksSoFar[i];
|
||||
Tanks[nextTankIdx - 1] = this;
|
||||
}
|
||||
currentOp = CurrentOp.None;
|
||||
|
||||
levelMeter = new Various.ManualLevelMsrmnt.ManualLevelMsrmnt();
|
||||
levelBox = new DoubleBox();
|
||||
currentOp = CurrentOp.None;
|
||||
levelBox = new DoubleBox();
|
||||
|
||||
log.Debug(this.ToString());
|
||||
}
|
||||
@ -102,8 +103,13 @@ namespace TBF.BenchControl.Various.TankWithLevelMsrmnt
|
||||
public void Initialize()
|
||||
{
|
||||
base.Initalize();
|
||||
|
||||
drainValve2 = TbfComponents.FindComponent(tankCfg.DrainValve2) as IValve;
|
||||
useCalibTable = LoadCalibrationTable(tankCfg.CalibrationTable);
|
||||
|
||||
levelMeter = TbfComponents.FindComponent(tankCfg.LevelMeasurement) as ILevelMeter;
|
||||
if (levelMeter == null) levelMeter = new Various.ManualLevelMsrmnt.ManualLevelMsrmnt();
|
||||
|
||||
useCalibTable = LoadCalibrationTable(tankCfg.CalibrationTable);
|
||||
}
|
||||
public void RunDeviceBefore() { }
|
||||
public void RunDeviceAfter() { }
|
||||
|
||||
@ -148,7 +148,7 @@ namespace TBF.BenchControl.Various.TankWithLevelMsrmnt
|
||||
config.DrainTimeSec = int.Parse(drainTimeTextBox.Text);
|
||||
config.DrainValve = drainValveComboBox.Text.Equals("---") ? string.Empty : drainValveComboBox.Text;
|
||||
config.DrainValve2 = drainValve2ComboBox.Text.Equals("---") ? string.Empty : drainValve2ComboBox.Text;
|
||||
config.LevelMeasurement = levelMeasurementComboBox.Text.Equals("---") ? string.Empty : drainValveComboBox.Text;
|
||||
config.LevelMeasurement = levelMeasurementComboBox.Text.Equals("---") ? string.Empty : levelMeasurementComboBox.Text;
|
||||
config.CalibrationTable = calibrationTableTextBox.Text;
|
||||
|
||||
return flags;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user